Verified Compiler Construction
Verified compilation proves a relationship between executions of source and target programs. A simulation must preserve observations even when one source step becomes several target steps.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 3
- Reading time
- 2 min
In this article3 chapters
A simulation is a relation between states
A source state and a target state can represent the same computation with different registers, layouts or control positions. Write \(s\sim t\) for the invariant connecting them. A forward simulation obligation has the shape
\[ s\sim t,\quad s\xrightarrow{a}s' \quad\Longrightarrow\quad \exists t'\ (t\xRightarrow{a}t'\ \land\ s'\sim t'). \]
The doubled arrow can match multiple target steps with the same observable trace, ignoring silent internal transitions. Initial states and final results require their own obligations. If the relation permits a source step to be matched by zero target steps, a well-founded measure may be needed to rule out an infinite source run matched by a finite target run.
Translation validation checks one concrete before-and-after pair. A compiler-wide proof additionally needs a general account of observable behavior across all relevant program contexts.
Eliminating an instruction is a stuttering case
Suppose an intermediate language copies a temporary that the next pass coalesces with its source. That copy can become no target instruction. Immediately after the source copy, the same target state may still represent every relevant live value. Progress of the proof then rests on moving past that source instruction in an appropriate measure. The example explains why checking equality of instruction counts would say little about correctness.
Scope, traces and defined source programs
CompCert organizes proofs pass by pass. Each pass relates adjacent languages, and simulation theorems compose. The precise final result accounts for nondeterministic source choices and source undefined behavior. The useful guarantee for a source program with defined behavior is about observations permitted by its formal semantics. Libraries, assembler boundaries and assumptions on the environment still have their own interfaces. Compare that semantics, representation invariants in SSA, and per-result checking in superoptimization.[1][2]