(** ** Properties of contexts and relocations *)
Remark sreg_below_diff:
forall ctx r r', Plt r' ctx.(dreg) -> sreg ctx r <> r'.
Remark context_below_diff:
forall ctx1 ctx2 r1 r2,
context_below ctx1 ctx2 -> Ple r1 ctx1.(mreg) -> sreg ctx1 r1 <> sreg ctx2 r2.
Remark context_below_lt:
forall ctx1 ctx2 r, context_below ctx1 ctx2 -> Ple r ctx1.(mreg) -> Plt (sreg ctx1 r) ctx2.(dreg).
(* Remark context_below_le: forall ctx1 ctx2 r, context_below ctx1 ctx2 -> Ple r ctx1.(mreg) -> Ple (sreg ctx1 r) ctx2.(dreg). *)
(** ** Agreement between register sets before and after inlining. *)
Definition agree_regs (F: meminj) (ctx: context) (rs rs': regset) :=
(forall r, Ple r ctx.(mreg) -> Val.inject F rs#r rs'#(sreg ctx r))
/\(forall r, Plt ctx.(mreg) r -> rs#r = Vundef).
Definition val_reg_charact (F: meminj) (ctx: context) (rs': regset) (v: val) (r: reg) :=
(Plt ctx.(mreg) r /\ v = Vundef) \/ (Ple r ctx.(mreg) /\ Val.inject F v rs'#(sreg ctx r)).
Remark Plt_Ple_dec:
forall p q, {Plt p q} + {Ple q p}.

(* Specifications: *)
Lemma agree_val_reg_gen:
forall F ctx rs rs' r, agree_regs F ctx rs rs' -> val_reg_charact F ctx rs' rs#r r.
Lemma agree_val_regs_gen:
forall F ctx rs rs' rl,
agree_regs F ctx rs rs' -> list_forall2 (val_reg_charact F ctx rs') rs##rl rl.
Lemma agree_val_reg:
forall F ctx rs rs' r, agree_regs F ctx rs rs' -> Val.inject F rs#r rs'#(sreg ctx r).
Lemma agree_val_regs:
forall F ctx rs rs' rl, agree_regs F ctx rs rs' -> Val.inject_list F rs##rl rs'##(sregs ctx rl).
Lemma agree_set_reg:
forall F ctx rs rs' r v v',
agree_regs F ctx rs rs' ->
Val.inject F v v' ->
Ple r ctx.(mreg) ->
agree_regs F ctx (rs#r <- v) (rs'#(sreg ctx r) <- v').
Lemma agree_set_reg_undef:
forall F ctx rs rs' r v',
agree_regs F ctx rs rs' ->
agree_regs F ctx (rs#r <- Vundef) (rs'#(sreg ctx r) <- v').
Lemma agree_set_reg_undef':
forall F ctx rs rs' r,
agree_regs F ctx rs rs' ->
agree_regs F ctx (rs#r <- Vundef) rs'.
Lemma agree_regs_invariant:
forall F ctx rs rs1 rs2,
agree_regs F ctx rs rs1 ->
(forall r, Ple ctx.(dreg) r -> Plt r (ctx.(dreg) + ctx.(mreg)) -> rs2#r = rs1#r) ->
agree_regs F ctx rs rs2.
Lemma agree_regs_incr:
forall F ctx rs1 rs2 F',
agree_regs F ctx rs1 rs2 ->
inject_incr F F' ->
agree_regs F' ctx rs1 rs2.