LVC

LVC is a verfied compiler which is based on the intermediate language IL, a functional language with nested, mutually recursive definitions. IL replaces SSA's dominance criterion by lexical scoping, hence we say IL realizes "Functional SSA".

In previous work we showed that SSA-based register allocation can be faithfully implemented on functional SSA. In this work we are concerned with the verified translation from an imperative language to functional SSA, which is closely related to SSA construction.

The translation starts with a language that already employs nested, mutually recursive function definitions, but uses imperative variables. The translation consists of the following phases:

  1. Unreachable Code Analysis and Unreachable Code Elimination
  2. Liveness Analysis and Dead Variable Elimination
  3. Adding parameters to function definitions to obtain a functional program
All three phases are fully verified, and no translation validation is used.

Our framework has a generic fixed-point solver and supports forward and backward analyses. The fixed-point solver is implemented in Coq and requires a proof that the analysis domain is a partial order without infinite ascending chains to guarantee termination.

We specify soundness and completeness of unreachable code, devise an unreachable code analysis, and prove the unreachable code analysis sound and complete. Based on unreachable code, we implement unreachable code elimination (UCE) and prove it correct.

We specify soundness of liveness, devise a liveness analysis, and prove the analysis sound. Based on liveness, we implement dead variable elimination (DVE) and prove it correct.

The proofs for UCE and DVE require an interesting simulation argument: In both cases a step must be argued where the source program reduces (for example, a variable definition) while the target program does not reduce (because the variable definition has been removed). Our proof method is induction on the program structure, facilitated by a fixed-point lemma about our simulation, which we call the extension lemma. We prove the extension lemma for the imperative interpretation and for the functional interpretation.