SJTU | CS 2612, Programming Languages and Compilers - Final Project
This repo contains the files for the final project of CS2612, regarding the correctness of Basic Block generation in compiler design. The Coq files can be successfully compiled with Coq version 8.12.0.
We thank Prof. Cao and two TAs for their great help throughout the semester as well as personalized guidance for our project.
compcert_lib and sets are the given packages for homeworks and lecture notes.
grammar.v: the basic grammar of the taskBB_generation.v: defines the generation process of the Basic Blocks.cmd_denotations.v: defines the notations of original SimpleWhile commands.BB_denotations.v: defines the denotation of Basic Blocks.utils.v: some fundamental lemmas used for subsequent tasksBB_gen_properties.v: defines and proves some lemmas regarding the basic properties of the generation process of Basic Blocks.BB_aux_proof.v: defines important propositions and proves lemmas usingBB_gen_properties.vandutils.v.BB_sem_asgn_equiv.v: proves the equivalence of a singleCAsgncommand and the corresponding Basic Block results.BB_sem_if_equiv.v: proves the equivalence of a singleCIfcommand and the corresponding Basic Block results.BB_sem_while_equiv.v: NOT required after discussion with the instructor. But it must be compiled for the final theorem.BB_sem_equiv.v: proves the final theorem integrating the three types of commands.
In Repo's root path, first enter:
coq_makefile -f _CoqProject */*.v -o Makefilethen enter make and all the files will be compiled automatically.
- All the
whilebranches and theorems (including those in inductive proofs) have be Admitted with the acknowledgement of the instructor. - We assume that the program will never go wrong or infinite. Therefore, we have Admitted the following lemmas:
true_or_false_classic1,true_or_false_classic2,No_err_and_inf_for_expr. - For the
CIfcase, we have assumed that the commands in the branchesc1andc2cannot benilwith the acknowledgement of the instructor. - We have proved all the theorems except two:
an_over_pass_bridgeandBB_list_sem_simplify_r(both inBB_aux_proof.v). The two theorems is used in theIfbranch of thePconspart of the main theorem. Consider the structureBBs_if ++ BBnext :: BBswhereBBs_ifis the generated result of the firstCIfcommand andBnrm (BB_list_sem (BBs_if ++ BBnext :: BBs)) bs1 bs2. Given the requirements stated in the lemma, we claim that there exists a middle statexsuch thatBnrm (BB_list_sem BBs_if) bs1 xandBnrm (BB_list_sem (BBnext :: BBs)) x bs2. We believe that it is theoretically correct.