Library RTLgenproof

Correctness proof for RTL generation.

Require Import Coqlib.
Require Import Maps.
Require Import AST.
Require Import Integers.
Require Import Values.
Require Import Mem.
Require Import Events.
Require Import Smallstep.
Require Import Globalenvs.
Require Import Switch.
Require Import Registers.
Require Import Cminor.
Require Import Op.
Require Import CminorSel.
Require Import RTL.
Require Import RTLgen.
Require Import RTLgenspec.

Correspondence between Cminor environments and RTL register sets


A compilation environment (mapping) is well-formed if the following properties hold:
  • Two distinct Cminor local variables are mapped to distinct pseudo-registers.
  • A Cminor local variable and a let-bound variable are mapped to distinct pseudo-registers.

Record map_wf (m: mapping) : Prop :=
  mk_map_wf {
    map_wf_inj:
      (forall id1 id2 r,
         m.(map_vars)!id1 = Some r -> m.(map_vars)!id2 = Some r -> id1 = id2);
     map_wf_disj:
      (forall id r,
         m.(map_vars)!id = Some r -> In r m.(map_letvars) -> False)
  }.

Lemma init_mapping_wf:
  map_wf init_mapping.


Lemma add_var_wf:
  forall s1 s2 map name r map' i,
  add_var map name s1 = OK (r,map') s2 i ->
  map_wf map -> map_valid map s1 -> map_wf map'.


Lemma add_vars_wf:
  forall names s1 s2 map map' rl i,
  add_vars map names s1 = OK (rl,map') s2 i ->
  map_wf map -> map_valid map s1 -> map_wf map'.


Lemma add_letvar_wf:
  forall map r,
  map_wf map -> ~reg_in_map map r -> map_wf (add_letvar map r).


An RTL register environment matches a CminorSel local environment and let-environment if the value of every local or let-bound variable in the CminorSel environments is identical to the value of the corresponding pseudo-register in the RTL register environment.

Record match_env
      (map: mapping) (e: env) (le: letenv) (rs: regset) : Prop :=
  mk_match_env {
    me_vars:
      (forall id v,
         e!id = Some v -> exists r, map.(map_vars)!id = Some r /\ rs#r = v);
    me_letvars:
      rs##(map.(map_letvars)) = le
  }.

Lemma match_env_find_var:
  forall map e le rs id v r,
  match_env map e le rs ->
  e!id = Some v ->
  map.(map_vars)!id = Some r ->
  rs#r = v.


Lemma match_env_find_letvar:
  forall map e le rs idx v r,
  match_env map e le rs ->
  List.nth_error le idx = Some v ->
  List.nth_error map.(map_letvars) idx = Some r ->
  rs#r = v.


Lemma match_env_invariant:
  forall map e le rs rs',
  match_env map e le rs ->
  (forall r, (reg_in_map map r) -> rs'#r = rs#r) ->
  match_env map e le rs'.


Matching between environments is preserved when an unmapped register (not corresponding to any Cminor variable) is assigned in the RTL execution.

Lemma match_env_update_temp:
  forall map e le rs r v,
  match_env map e le rs ->
  ~(reg_in_map map r) ->
  match_env map e le (rs#r <- v).

Hint Resolve match_env_update_temp: rtlg.

Matching between environments is preserved by simultaneous assignment to a Cminor local variable (in the Cminor environments) and to the corresponding RTL pseudo-register (in the RTL register environment).

Lemma match_env_update_var:
  forall map e le rs id r v,
  map_wf map ->
  map.(map_vars)!id = Some r ->
  match_env map e le rs ->
  match_env map (PTree.set id v e) le (rs#r <- v).


Lemma match_env_bind_letvar:
  forall map e le rs r v,
  match_env map e le rs ->
  rs#r = v ->
  match_env (add_letvar map r) e (v :: le) rs.


Lemma match_env_unbind_letvar:
  forall map e le rs r v,
  match_env (add_letvar map r) e (v :: le) rs ->
  match_env map e le rs.


Lemma match_env_empty:
  forall map,
  map.(map_letvars) = nil ->
  match_env map (PTree.empty val) nil (Regmap.init Vundef).


The assignment of function arguments to local variables (on the Cminor side) and pseudo-registers (on the RTL side) preserves matching between environments.

Lemma match_set_params_init_regs:
  forall il rl s1 map2 s2 vl i,
  add_vars init_mapping il s1 = OK (rl, map2) s2 i ->
  match_env map2 (set_params vl il) nil (init_regs vl rl)
  /\ (forall r, reg_fresh r s2 -> (init_regs vl rl)#r = Vundef).


Lemma match_set_locals:
  forall map1 s1,
  map_wf map1 ->
  forall il rl map2 s2 e le rs i,
  match_env map1 e le rs ->
  (forall r, reg_fresh r s1 -> rs#r = Vundef) ->
  add_vars map1 il s1 = OK (rl, map2) s2 i ->
  match_env map2 (set_locals il e) le rs.


Lemma match_init_env_init_reg:
  forall params s0 rparams map1 s1 i1 vars rvars map2 s2 i2 vparams,
  add_vars init_mapping params s0 = OK (rparams, map1) s1 i1 ->
  add_vars map1 vars s1 = OK (rvars, map2) s2 i2 ->
  match_env map2 (set_locals vars (set_params vparams params))
            nil (init_regs vparams rparams).


The simulation argument


Require Import Errors.

Section CORRECTNESS.

Variable prog: CminorSel.program.
Variable tprog: RTL.program.
Hypothesis TRANSL: transl_program prog = OK tprog.

Let ge : CminorSel.genv := Genv.globalenv prog.
Let tge : RTL.genv := Genv.globalenv tprog.

Relationship between the global environments for the original CminorSel program and the generated RTL program.

Lemma symbols_preserved:
  forall (s: ident), Genv.find_symbol tge s = Genv.find_symbol ge s.
Proof
  (Genv.find_symbol_transf_partial transl_fundef _ TRANSL).

Lemma function_ptr_translated:
  forall (b: block) (f: CminorSel.fundef),
  Genv.find_funct_ptr ge b = Some f ->
  exists tf,
  Genv.find_funct_ptr tge b = Some tf /\ transl_fundef f = OK tf.
Proof
  (Genv.find_funct_ptr_transf_partial transl_fundef TRANSL).

Lemma functions_translated:
  forall (v: val) (f: CminorSel.fundef),
  Genv.find_funct ge v = Some f ->
  exists tf,
  Genv.find_funct tge v = Some tf /\ transl_fundef f = OK tf.
Proof
  (Genv.find_funct_transf_partial transl_fundef TRANSL).

Lemma sig_transl_function:
  forall (f: CminorSel.fundef) (tf: RTL.fundef),
  transl_fundef f = OK tf ->
  RTL.funsig tf = CminorSel.funsig f.


Correctness of the code generated by add_move.

Lemma tr_move_correct:
  forall r1 ns r2 nd cs code sp rs m,
  tr_move code ns r1 nd r2 ->
  exists rs',
  star step tge (State cs code sp ns rs m) E0 (State cs code sp nd rs' m) /\
  rs'#r2 = rs#r1 /\
  (forall r, r <> r2 -> rs'#r = rs#r).


Correctness of the code generated by store_var and store_optvar.

Lemma tr_store_var_correct:
  forall rs cs code map r id ns nd e sp m,
  tr_store_var code map r id ns nd ->
  map_wf map ->
  match_env map e nil rs ->
  exists rs',
     star step tge (State cs code sp ns rs m)
                E0 (State cs code sp nd rs' m)
  /\ match_env map (PTree.set id rs#r e) nil rs'.


Lemma tr_store_optvar_correct:
  forall rs cs code map r optid ns nd e sp m,
  tr_store_optvar code map r optid ns nd ->
  map_wf map ->
  match_env map e nil rs ->
  exists rs',
     star step tge (State cs code sp ns rs m)
                E0 (State cs code sp nd rs' m)
  /\ match_env map (set_optvar optid rs#r e) nil rs'.


Correctness of the translation of switch statements

Lemma transl_switch_correct:
  forall cs sp e m code map r nexits t ns,
  tr_switch code map r nexits t ns ->
  forall rs i act,
  rs#r = Vint i ->
  map_wf map ->
  match_env map e nil rs ->
  comptree_match i t = Some act ->
  exists nd, exists rs',
  star step tge (State cs code sp ns rs m) E0 (State cs code sp nd rs' m) /\
  nth_error nexits act = Some nd /\
  match_env map e nil rs'.


Semantic preservation for the translation of expressions


Section CORRECTNESS_EXPR.

Variable sp: val.
Variable e: env.
Variable m: mem.

The proof of semantic preservation for the translation of expressions is a simulation argument based on diagrams of the following form:
                    I /\ P
    e, le, m, a ------------- State cs code sp ns rs m
         ||                      |
         ||                      |*
         ||                      |
         \/                      v
    e, le, m', v ------------ State cs code sp nd rs' m'
                    I /\ Q


where tr_expr code map pr a ns nd rd is assumed to hold. The left vertical arrow represents an evaluation of the expression a. The right vertical arrow represents the execution of zero, one or several instructions in the generated RTL flow graph code.

The invariant I is the agreement between Cminor environments and RTL register environment, as captured by match_envs.

The precondition P includes the well-formedness of the compilation environment mut.

The postconditions Q state that in the final register environment rs', register rd contains value v, and the registers in the set of preserved registers pr are unchanged, as are the registers in the codomain of map.

We formalize this simulation property by the following predicate parameterized by the CminorSel evaluation (left arrow).

Definition transl_expr_prop
     (le: letenv) (a: expr) (v: val) : Prop :=
  forall cs code map pr ns nd rd rs
    (MWF: map_wf map)
    (TE: tr_expr code map pr a ns nd rd)
    (ME: match_env map e le rs),
  exists rs',
     star step tge (State cs code sp ns rs m) E0 (State cs code sp nd rs' m)
  /\ match_env map e le rs'
  /\ rs'#rd = v
  /\ (forall r, reg_in_map map r \/ In r pr -> rs'#r = rs#r).

The simulation properties for lists of expressions and for conditional expressions are similar.

Definition transl_exprlist_prop
     (le: letenv) (al: exprlist) (vl: list val) : Prop :=
  forall cs code map pr ns nd rl rs
    (MWF: map_wf map)
    (TE: tr_exprlist code map pr al ns nd rl)
    (ME: match_env map e le rs),
  exists rs',
     star step tge (State cs code sp ns rs m) E0 (State cs code sp nd rs' m)
  /\ match_env map e le rs'
  /\ rs'##rl = vl
  /\ (forall r, reg_in_map map r \/ In r pr -> rs'#r = rs#r).

Definition transl_condition_prop
     (le: letenv) (a: condexpr) (vb: bool) : Prop :=
  forall cs code map pr ns ntrue nfalse rs
    (MWF: map_wf map)
    (TE: tr_condition code map pr a ns ntrue nfalse)
    (ME: match_env map e le rs),
  exists rs',
     star step tge (State cs code sp ns rs m) E0
                   (State cs code sp (if vb then ntrue else nfalse) rs' m)
  /\ match_env map e le rs'
  /\ (forall r, reg_in_map map r \/ In r pr -> rs'#r = rs#r).

The correctness of the translation is a huge induction over the Cminor evaluation derivation for the source program. To keep the proof manageable, we put each case of the proof in a separate lemma. There is one lemma for each Cminor evaluation rule. It takes as hypotheses the premises of the Cminor evaluation rule, plus the induction hypotheses, that is, the transl_expr_prop, etc, corresponding to the evaluations of sub-expressions or sub-statements.

Lemma transl_expr_Evar_correct:
  forall (le : letenv) (id : positive) (v : val),
  e ! id = Some v ->
  transl_expr_prop le (Evar id) v.


Lemma transl_expr_Eop_correct:
  forall (le : letenv) (op : operation) (args : exprlist)
         (vargs : list val) (v : val),
  eval_exprlist ge sp e m le args vargs ->
  transl_exprlist_prop le args vargs ->
  eval_operation ge sp op vargs = Some v ->
  transl_expr_prop le (Eop op args) v.


Lemma transl_expr_Eload_correct:
  forall (le : letenv) (chunk : memory_chunk) (addr : Op.addressing)
         (args : exprlist) (vargs : list val) (vaddr v : val),
  eval_exprlist ge sp e m le args vargs ->
  transl_exprlist_prop le args vargs ->
  Op.eval_addressing ge sp addr vargs = Some vaddr ->
  loadv chunk m vaddr = Some v ->
  transl_expr_prop le (Eload chunk addr args) v.


Lemma transl_expr_Econdition_correct:
  forall (le : letenv) (cond : condexpr) (ifso ifnot : expr)
         (vcond : bool) (v : val),
  eval_condexpr ge sp e m le cond vcond ->
  transl_condition_prop le cond vcond ->
  eval_expr ge sp e m le (if vcond then ifso else ifnot) v ->
  transl_expr_prop le (if vcond then ifso else ifnot) v ->
  transl_expr_prop le (Econdition cond ifso ifnot) v.


Lemma transl_expr_Elet_correct:
  forall (le : letenv) (a1 a2 : expr) (v1 v2 : val),
  eval_expr ge sp e m le a1 v1 ->
  transl_expr_prop le a1 v1 ->
  eval_expr ge sp e m (v1 :: le) a2 v2 ->
  transl_expr_prop (v1 :: le) a2 v2 ->
  transl_expr_prop le (Elet a1 a2) v2.


Lemma transl_expr_Eletvar_correct:
  forall (le : list val) (n : nat) (v : val),
  nth_error le n = Some v ->
  transl_expr_prop le (Eletvar n) v.


Lemma transl_condition_CEtrue_correct:
  forall (le : letenv),
  transl_condition_prop le CEtrue true.


Lemma transl_condition_CEfalse_correct:
  forall (le : letenv),
  transl_condition_prop le CEfalse false.


Lemma transl_condition_CEcond_correct:
  forall (le : letenv) (cond : condition) (args : exprlist)
         (vargs : list val) (b : bool),
  eval_exprlist ge sp e m le args vargs ->
  transl_exprlist_prop le args vargs ->
  eval_condition cond vargs = Some b ->
  transl_condition_prop le (CEcond cond args) b.


Lemma transl_condition_CEcondition_correct:
  forall (le : letenv) (cond ifso ifnot : condexpr) (vcond v : bool),
  eval_condexpr ge sp e m le cond vcond ->
  transl_condition_prop le cond vcond ->
  eval_condexpr ge sp e m le (if vcond then ifso else ifnot) v ->
  transl_condition_prop le (if vcond then ifso else ifnot) v ->
  transl_condition_prop le (CEcondition cond ifso ifnot) v.


Lemma transl_exprlist_Enil_correct:
  forall (le : letenv),
  transl_exprlist_prop le Enil nil.


Lemma transl_exprlist_Econs_correct:
  forall (le : letenv) (a1 : expr) (al : exprlist) (v1 : val)
         (vl : list val),
  eval_expr ge sp e m le a1 v1 ->
  transl_expr_prop le a1 v1 ->
  eval_exprlist ge sp e m le al vl ->
  transl_exprlist_prop le al vl ->
  transl_exprlist_prop le (Econs a1 al) (v1 :: vl).


Theorem transl_expr_correct:
  forall le a v,
  eval_expr ge sp e m le a v ->
  transl_expr_prop le a v.
Proof
  (eval_expr_ind3 ge sp e m
     transl_expr_prop
     transl_condition_prop
     transl_exprlist_prop
     transl_expr_Evar_correct
     transl_expr_Eop_correct
     transl_expr_Eload_correct
     transl_expr_Econdition_correct
     transl_expr_Elet_correct
     transl_expr_Eletvar_correct
     transl_condition_CEtrue_correct
     transl_condition_CEfalse_correct
     transl_condition_CEcond_correct
     transl_condition_CEcondition_correct
     transl_exprlist_Enil_correct
     transl_exprlist_Econs_correct).

Theorem transl_condexpr_correct:
  forall le a v,
  eval_condexpr ge sp e m le a v ->
  transl_condition_prop le a v.
Proof
  (eval_condexpr_ind3 ge sp e m
     transl_expr_prop
     transl_condition_prop
     transl_exprlist_prop
     transl_expr_Evar_correct
     transl_expr_Eop_correct
     transl_expr_Eload_correct
     transl_expr_Econdition_correct
     transl_expr_Elet_correct
     transl_expr_Eletvar_correct
     transl_condition_CEtrue_correct
     transl_condition_CEfalse_correct
     transl_condition_CEcond_correct
     transl_condition_CEcondition_correct
     transl_exprlist_Enil_correct
     transl_exprlist_Econs_correct).

Theorem transl_exprlist_correct:
  forall le a v,
  eval_exprlist ge sp e m le a v ->
  transl_exprlist_prop le a v.
Proof
  (eval_exprlist_ind3 ge sp e m
     transl_expr_prop
     transl_condition_prop
     transl_exprlist_prop
     transl_expr_Evar_correct
     transl_expr_Eop_correct
     transl_expr_Eload_correct
     transl_expr_Econdition_correct
     transl_expr_Elet_correct
     transl_expr_Eletvar_correct
     transl_condition_CEtrue_correct
     transl_condition_CEfalse_correct
     transl_condition_CEcond_correct
     transl_condition_CEcondition_correct
     transl_exprlist_Enil_correct
     transl_exprlist_Econs_correct).

End CORRECTNESS_EXPR.

Measure over CminorSel states


Open Local Scope nat_scope.

Fixpoint size_stmt (s: stmt) : nat :=
  match s with
  | Sskip => 0
  | Sseq s1 s2 => (size_stmt s1 + size_stmt s2 + 1)
  | Sifthenelse e s1 s2 => (size_stmt s1 + size_stmt s2 + 1)
  | Sloop s1 => (size_stmt s1 + 1)
  | Sblock s1 => (size_stmt s1 + 1)
  | Sexit n => 0
  | Slabel lbl s1 => (size_stmt s1 + 1)
  | _ => 1
  end.

Fixpoint size_cont (k: cont) : nat :=
  match k with
  | Kseq s k1 => (size_stmt s + size_cont k1 + 1)
  | Kblock k1 => (size_cont k1 + 1)
  | _ => 0%nat
  end.

Definition measure_state (S: CminorSel.state) :=
  match S with
  | CminorSel.State _ s k _ _ _ =>
      existS (fun (x: nat) => nat)
             (size_stmt s + size_cont k)
             (size_stmt s)
  | _ =>
      existS (fun (x: nat) => nat) 0 0
  end.

Require Import Relations.
Require Import Wellfounded.

Definition lt_state (S1 S2: CminorSel.state) :=
  lexprod nat (fun (x: nat) => nat)
          lt (fun (x: nat) => lt)
          (measure_state S1) (measure_state S2).

Lemma lt_state_intro:
  forall f1 s1 k1 sp1 e1 m1 f2 s2 k2 sp2 e2 m2,
  size_stmt s1 + size_cont k1 < size_stmt s2 + size_cont k2
  \/ (size_stmt s1 + size_cont k1 = size_stmt s2 + size_cont k2
      /\ size_stmt s1 < size_stmt s2) ->
  lt_state (CminorSel.State f1 s1 k1 sp1 e1 m1)
           (CminorSel.State f2 s2 k2 sp2 e2 m2).


Ltac Lt_state :=
  apply lt_state_intro; simpl; try omega.

Require Import Wf_nat.

Lemma lt_state_wf:
  well_founded lt_state.


Semantic preservation for the translation of statements


The simulation diagram for the translation of statements and functions is a "star" diagram of the form:
           I                         I
     S1 ------- R1             S1 ------- R1
     |          |              |          |
   t |        + | t      or  t |        * | t    and |S2| < |S1|
     v          v              v          |
     S2 ------- R2             S2 ------- R2
           I                         I


where I is the match_states predicate defined below. It includes:
  • Agreement between the Cminor statement under consideration and the current program point in the RTL control-flow graph, as captured by the tr_stmt predicate.
  • Agreement between the Cminor continuation and the RTL control-flow graph and call stack, as captured by the tr_cont predicate below.
  • Agreement between Cminor environments and RTL register environments, as captured by match_envs.



Inductive tr_funbody (c: code) (map: mapping) (f: CminorSel.function)
                     (ngoto: labelmap) (nret: node) (rret: option reg) : Prop :=
  | tr_funbody_intro: forall nentry r,
      rret = ret_reg f.(CminorSel.fn_sig) r ->
      tr_stmt c map f.(fn_body) nentry nret nil ngoto nret rret ->
      tr_funbody c map f ngoto nret rret.

Inductive tr_cont: RTL.code -> mapping ->
                   CminorSel.cont -> node -> list node -> labelmap -> node -> option reg ->
                   list RTL.stackframe -> Prop :=
  | tr_Kseq: forall c map s k nd nexits ngoto nret rret cs n,
      tr_stmt c map s nd n nexits ngoto nret rret ->
      tr_cont c map k n nexits ngoto nret rret cs ->
      tr_cont c map (Kseq s k) nd nexits ngoto nret rret cs
  | tr_Kblock: forall c map k nd nexits ngoto nret rret cs,
      tr_cont c map k nd nexits ngoto nret rret cs ->
      tr_cont c map (Kblock k) nd (nd :: nexits) ngoto nret rret cs
  | tr_Kstop: forall c map ngoto nret rret cs,
      c!nret = Some(Ireturn rret) ->
      match_stacks Kstop cs ->
      tr_cont c map Kstop nret nil ngoto nret rret cs
  | tr_Kcall: forall c map optid f sp e k ngoto nret rret cs,
      c!nret = Some(Ireturn rret) ->
      match_stacks (Kcall optid f sp e k) cs ->
      tr_cont c map (Kcall optid f sp e k) nret nil ngoto nret rret cs

with match_stacks: CminorSel.cont -> list RTL.stackframe -> Prop :=
  | match_stacks_stop:
      match_stacks Kstop nil
  | match_stacks_call: forall optid f sp e k r c n rs cs map nexits ngoto nret rret n',
      map_wf map ->
      tr_funbody c map f ngoto nret rret ->
      match_env map e nil rs ->
      tr_store_optvar c map r optid n n' ->
      ~reg_in_map map r ->
      tr_cont c map k n' nexits ngoto nret rret cs ->
      match_stacks (Kcall optid f sp e k) (Stackframe r c sp n rs :: cs).

Inductive match_states: CminorSel.state -> RTL.state -> Prop :=
  | match_state:
      forall f s k sp e m cs c ns rs map ncont nexits ngoto nret rret
        (MWF: map_wf map)
        (TS: tr_stmt c map s ns ncont nexits ngoto nret rret)
        (TF: tr_funbody c map f ngoto nret rret)
        (TK: tr_cont c map k ncont nexits ngoto nret rret cs)
        (ME: match_env map e nil rs),
      match_states (CminorSel.State f s k sp e m)
                   (RTL.State cs c sp ns rs m)
  | match_callstate:
      forall f args k m cs tf
        (TF: transl_fundef f = OK tf)
        (MS: match_stacks k cs),
      match_states (CminorSel.Callstate f args k m)
                   (RTL.Callstate cs tf args m)
  | match_returnstate:
      forall v k m cs
        (MS: match_stacks k cs),
      match_states (CminorSel.Returnstate v k m)
                   (RTL.Returnstate cs v m).

Lemma match_stacks_call_cont:
  forall c map k ncont nexits ngoto nret rret cs,
  tr_cont c map k ncont nexits ngoto nret rret cs ->
  match_stacks (call_cont k) cs /\ c!nret = Some(Ireturn rret).


Lemma tr_cont_call_cont:
  forall c map k ncont nexits ngoto nret rret cs,
  tr_cont c map k ncont nexits ngoto nret rret cs ->
  tr_cont c map (call_cont k) nret nil ngoto nret rret cs.


Lemma tr_find_label:
  forall c map lbl n (ngoto: labelmap) nret rret s' k' cs,
  ngoto!lbl = Some n ->
  forall s k ns1 nd1 nexits1,
  find_label lbl s k = Some (s', k') ->
  tr_stmt c map s ns1 nd1 nexits1 ngoto nret rret ->
  tr_cont c map k nd1 nexits1 ngoto nret rret cs ->
  exists ns2, exists nd2, exists nexits2,
     c!n = Some(Inop ns2)
  /\ tr_stmt c map s' ns2 nd2 nexits2 ngoto nret rret
  /\ tr_cont c map k' nd2 nexits2 ngoto nret rret cs.


Theorem transl_step_correct:
  forall S1 t S2, CminorSel.step ge S1 t S2 ->
  forall R1, match_states S1 R1 ->
  exists R2,
  (plus RTL.step tge R1 t R2 \/ (star RTL.step tge R1 t R2 /\ lt_state S2 S1))
  /\ match_states S2 R2.


Lemma transl_initial_states:
  forall S, CminorSel.initial_state prog S ->
  exists R, RTL.initial_state tprog R /\ match_states S R.


Lemma transl_final_states:
  forall S R r,
  match_states S R -> CminorSel.final_state S r -> RTL.final_state R r.


Theorem transf_program_correct:
  forall (beh: program_behavior), not_wrong beh ->
  CminorSel.exec_program prog beh -> RTL.exec_program tprog beh.


End CORRECTNESS.