Section X86CoreErasure.
Variable the_program: Asm.program.
Variable Hsafe : Asm_core.safe_genv (@the_ge the_program).
Instance X86Sem : Semantics := @X86Context.X86Sem the_program Hsafe.
Definition reg_erasure (r:PregEq.t) (rs rs' : regset) : Prop :=
val_erasure (Pregmap.get r rs) (Pregmap.get r rs').
Definition regs_erasure rs rs' : Prop :=
forall r, reg_erasure r rs rs'.
Definition core_erasure c c' :=
match c, c' with
| State rs  _, State rs' _ =>
regs_erasure rs rs'
end.
(* Definition erasedPerm c := *)
(*   match c with *)
(*   | State _ mem => *)
(*     forall (b : block) (ofs : Z) (k : perm_kind), *)
(*       Mem.valid_block mem b -> (Mem.mem_access mem) !! b ofs k = Some Freeable *)
(*   end. *)
Proof with eauto with val_erasure.
intros rs r;
unfold reg_erasure...
Qed.
Hint Immediate regs_erasure_refl : regs_erasure.
Hint Immediate val_erasure_list_refl : val_erasure.
Proof with eauto with val_erasure regs_erasure.
destruct c; simpl.
repeat split...
Qed.
Hint Immediate core_erasure_refl: regs_erasure.
Hint Resolve regs_erasure_get regs_erasure_refl regs_erasure_set
: regs_erasure.
Notation the_ge := (@the_ge the_program).
(** ** Result about at_external, after_external and initial_core *)
Hint Resolve regs_erasure_set_undef : regs_erasure.
Hint Resolve regs_erasure_set_res : regs_erasure.
Proof with eauto 10 with val_erasure regs_erasure.
intros.
unfold eval_addrmode.
assert (Hptr64: Archi.ptr64 = false) by auto.
rewrite Hptr64.
eapply eval_addrmode32_erase;
now eauto.
Qed.
Proof with eauto 12 using val_erasure_cmpu with regs_erasure val_erasure.
intros.
unfold compare_ints...
Qed.
Hint Extern 0 (val_erasure Vundef _) => reflexivity : val_erasure.
Proof with eauto 10 using val_erasure_cmpu with regs_erasure val_erasure.
intros.
unfold compare_floats.
destruct v1,v2; inv Hval_erasure; inv Hval_erasure2; simpl;
eauto 6 with regs_erasure val_erasure;
try destruct v1'; try destruct v2';
eauto 6 with regs_erasure val_erasure;
unfold Val.of_bool;
repeat rewrite if_negb;
repeat match goal with
| [|- context[match ?Expr with | _ => _ end]] =>
destruct Expr eqn:?
end...
Qed.
Proof with eauto 10 using val_erasure_cmpu with regs_erasure val_erasure.
intros.
unfold compare_floats32.
destruct v1,v2; inv Hval_erasure; inv Hval_erasure2; simpl;
eauto 6 with regs_erasure val_erasure;
try destruct v1'; try destruct v2';
eauto 6 with regs_erasure val_erasure;
unfold Val.of_bool;
repeat rewrite if_negb;
repeat match goal with
| [|- context[match ?Expr with | _ => _ end]] =>
destruct Expr eqn:?
end...
Qed.
Hint Transparent undef_regs: regs_erasure.
Proof with eauto 10 using val_erasure_cmpu with regs_erasure val_erasure.
intros.
unfold compare_longs.
destruct v1,v2; inv Hval1; inv Hval2; simpl;
eauto 6 with regs_erasure val_erasure;
try destruct v1'; try destruct v2';
eauto 6 with regs_erasure val_erasure;
unfold Val.of_bool;
repeat rewrite if_negb;
repeat match goal with
| [|- context[match ?Expr with | _ => _ end]] =>
destruct Expr eqn:?
end...
Qed.
Hint Resolve compare_ints_erasure compare_floats_erasure compare_longs_erasure
compare_floats32_erasure val_erasure_addrmode eval_addrmode32_erase
eval_addrmode64_erase regs_erasure_undef : regs_erasure.
Hint Extern 0 (val_erasure (undef_regs _ _ # _ <- _ _) _) =>
eapply regs_erasure_set : regs_erasure.

Lemma exec_instr_erased:
forall (fn : function) (i : instruction) (rs rs' rs2: regset)
(m m' m2 : mem) ev
(HeraseCores: regs_erasure rs rs')
(HerasedMem: mem_erasure m m')
(Hexec_ev: Asm_event.drf_instr the_ge (fn_code fn) i rs m = Some ev)
(Hexec: exec_instr the_ge fn i rs m = Next rs2 m2),
exists rs2' m2' ev',
exec_instr the_ge fn i rs' m' = Next rs2' m2' /\
Asm_event.drf_instr the_ge (fn_code fn) i rs' m' = Some ev' /\
regs_erasure rs2 rs2' /\ mem_erasure m2 (erasePerm m2') /\
mem_event_list_erasure ev ev'.