Skip to content

Removing the global environment from Smallstep.semantics #258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions backend/Allocproof.v
Original file line number Diff line number Diff line change
Expand Up @@ -1847,8 +1847,8 @@ Lemma exec_moves:
satisf rs ls e' ->
wt_regset env rs ->
exists ls',
star step tge (Block s f sp (expand_moves mv bb) ls m)
E0 (Block s f sp bb ls' m)
star (step tge) (Block s f sp (expand_moves mv bb) ls m)
E0 (Block s f sp bb ls' m)
/\ satisf rs ls' e.
Proof.
Opaque destroyed_by_op.
Expand Down Expand Up @@ -1908,8 +1908,8 @@ Inductive match_stackframes: list RTL.stackframe -> list LTL.stackframe -> signa
Val.has_type v (env res) ->
agree_callee_save ls ls1 ->
exists ls2,
star LTL.step tge (Block ts tf sp bb ls1 m)
E0 (State ts tf sp pc ls2 m)
star (LTL.step tge) (Block ts tf sp bb ls1 m)
E0 (State ts tf sp pc ls2 m)
/\ satisf (rs#res <- v) ls2 e),
match_stackframes
(RTL.Stackframe res f sp pc rs :: s)
Expand Down Expand Up @@ -1990,7 +1990,7 @@ Qed.
Lemma step_simulation:
forall S1 t S2, RTL.step ge S1 t S2 -> wt_state S1 ->
forall S1', match_states S1 S1' ->
exists S2', plus LTL.step tge S1' t S2' /\ match_states S2 S2'.
exists S2', plus (LTL.step tge) S1' t S2' /\ match_states S2 S2'.
Proof.
induction 1; intros WT S1' MS; inv MS; try UseShape.

Expand Down
2 changes: 1 addition & 1 deletion backend/Asmgenproof0.v
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ Lemma exec_straight_steps_1:
rs#PC = Vptr b ofs ->
Genv.find_funct_ptr ge b = Some (Internal fn) ->
code_tail (Ptrofs.unsigned ofs) (fn_code fn) c ->
plus step ge (State rs m) E0 (State rs' m').
plus (step ge) (State rs m) E0 (State rs' m').
Proof.
induction 1; intros.
apply plus_one.
Expand Down
16 changes: 8 additions & 8 deletions backend/Cminor.v
Original file line number Diff line number Diff line change
Expand Up @@ -908,13 +908,13 @@ Lemma eval_funcall_exec_stmt_steps:
eval_funcall ge m fd args t m' res ->
forall k,
is_call_cont k ->
star step ge (Callstate fd args k m)
t (Returnstate res k m'))
star (step ge) (Callstate fd args k m)
t (Returnstate res k m'))
/\(forall f sp e m s t e' m' out,
exec_stmt ge f sp e m s t e' m' out ->
forall k,
exists S,
star step ge (State f s k sp e m) t S
star (step ge) (State f s k sp e m) t S
/\ outcome_state_match sp e' m' f k out S).
Proof.
apply eval_funcall_exec_stmt_ind2; intros.
Expand Down Expand Up @@ -1070,28 +1070,28 @@ Lemma eval_funcall_steps:
eval_funcall ge m fd args t m' res ->
forall k,
is_call_cont k ->
star step ge (Callstate fd args k m)
t (Returnstate res k m').
star (step ge) (Callstate fd args k m)
t (Returnstate res k m').
Proof (proj1 eval_funcall_exec_stmt_steps).

Lemma exec_stmt_steps:
forall f sp e m s t e' m' out,
exec_stmt ge f sp e m s t e' m' out ->
forall k,
exists S,
star step ge (State f s k sp e m) t S
star (step ge) (State f s k sp e m) t S
/\ outcome_state_match sp e' m' f k out S.
Proof (proj2 eval_funcall_exec_stmt_steps).

Lemma evalinf_funcall_forever:
forall m fd args T k,
evalinf_funcall ge m fd args T ->
forever_plus step ge (Callstate fd args k m) T.
forever_plus (step ge) (Callstate fd args k m) T.
Proof.
cofix CIH_FUN.
assert (forall sp e m s T f k,
execinf_stmt ge f sp e m s T ->
forever_plus step ge (State f s k sp e m) T).
forever_plus (step ge) (State f s k sp e m) T).
cofix CIH_STMT.
intros. inv H.

Expand Down
6 changes: 3 additions & 3 deletions backend/Debugvarproof.v
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,8 @@ Qed.

Lemma eval_add_delta_ranges:
forall s f sp c rs m before after,
star step tge (State s f sp (add_delta_ranges before after c) rs m)
E0 (State s f sp c rs m).
star (step tge) (State s f sp (add_delta_ranges before after c) rs m)
E0 (State s f sp c rs m).
Proof.
intros. unfold add_delta_ranges.
destruct (delta_state before after) as [killed born].
Expand Down Expand Up @@ -423,7 +423,7 @@ Qed.
Theorem transf_step_correct:
forall s1 t s2, step ge s1 t s2 ->
forall ts1 (MS: match_states s1 ts1),
exists ts2, plus step tge ts1 t ts2 /\ match_states s2 ts2.
exists ts2, plus (step tge) ts1 t ts2 /\ match_states s2 ts2.
Proof.
induction 1; intros ts1 MS; inv MS; try (inv TRC).
- (* getstack *)
Expand Down
6 changes: 3 additions & 3 deletions backend/Inliningproof.v
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ Lemma tr_moves_init_regs:
(forall r, In r rdsts -> Ple r ctx2.(mreg)) ->
list_forall2 (val_reg_charact F ctx1 rs1) vl rsrcs ->
exists rs2,
star step tge (State stk f sp pc1 rs1 m)
E0 (State stk f sp pc2 rs2 m)
star (step tge) (State stk f sp pc1 rs1 m)
E0 (State stk f sp pc2 rs2 m)
/\ agree_regs F ctx2 (init_regs vl rdsts) rs2
/\ forall r, Plt r ctx2.(dreg) -> rs2#r = rs1#r.
Proof.
Expand Down Expand Up @@ -933,7 +933,7 @@ Theorem step_simulation:
forall S1 t S2,
step ge S1 t S2 ->
forall S1' (MS: match_states S1 S1'),
(exists S2', plus step tge S1' t S2' /\ match_states S2 S2')
(exists S2', plus (step tge) S1' t S2' /\ match_states S2 S2')
\/ (measure S2 < measure S1 /\ t = E0 /\ match_states S2 S1')%nat.
Proof.
induction 1; intros; inv MS.
Expand Down
10 changes: 5 additions & 5 deletions backend/Linearizeproof.v
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ Lemma starts_with_correct:
unique_labels c2 ->
starts_with lbl c1 = true ->
find_label lbl c2 = Some c3 ->
plus step tge (State s f sp c1 ls m)
E0 (State s f sp c3 ls m).
plus (step tge) (State s f sp c1 ls m)
E0 (State s f sp c3 ls m).
Proof.
induction c1.
simpl; intros; discriminate.
Expand Down Expand Up @@ -456,8 +456,8 @@ Lemma add_branch_correct:
transf_function f = OK tf ->
is_tail k tf.(fn_code) ->
find_label lbl tf.(fn_code) = Some c ->
plus step tge (State s tf sp (add_branch lbl k) ls m)
E0 (State s tf sp c ls m).
plus (step tge) (State s tf sp (add_branch lbl k) ls m)
E0 (State s tf sp c ls m).
Proof.
intros. unfold add_branch.
caseEq (starts_with lbl k); intro SW.
Expand Down Expand Up @@ -556,7 +556,7 @@ Qed.
Theorem transf_step_correct:
forall s1 t s2, LTL.step ge s1 t s2 ->
forall s1' (MS: match_states s1 s1'),
(exists s2', plus Linear.step tge s1' t s2' /\ match_states s2 s2')
(exists s2', plus (Linear.step tge) s1' t s2' /\ match_states s2 s2')
\/ (measure s2 < measure s1 /\ t = E0 /\ match_states s2 s1')%nat.
Proof.
induction 1; intros; try (inv MS).
Expand Down
12 changes: 6 additions & 6 deletions backend/RTLgenproof.v
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ Lemma tr_move_correct:
forall r1 ns r2 nd cs f sp rs m,
tr_move f.(fn_code) ns r1 nd r2 ->
exists rs',
star step tge (State cs f sp ns rs m) E0 (State cs f sp nd rs' m) /\
star (step tge) (State cs f sp ns rs m) E0 (State cs f sp nd rs' m) /\
rs'#r2 = rs#r1 /\
(forall r, r <> r2 -> rs'#r = rs#r).
Proof.
Expand Down Expand Up @@ -474,7 +474,7 @@ Definition transl_expr_prop
(ME: match_env map e le rs)
(EXT: Mem.extends m tm),
exists rs', exists tm',
star step tge (State cs f sp ns rs tm) E0 (State cs f sp nd rs' tm')
star (step tge) (State cs f sp ns rs tm) E0 (State cs f sp nd rs' tm')
/\ match_env map (set_optvar dst v e) le rs'
/\ Val.lessdef v rs'#rd
/\ (forall r, In r pr -> rs'#r = rs#r)
Expand All @@ -488,7 +488,7 @@ Definition transl_exprlist_prop
(ME: match_env map e le rs)
(EXT: Mem.extends m tm),
exists rs', exists tm',
star step tge (State cs f sp ns rs tm) E0 (State cs f sp nd rs' tm')
star (step tge) (State cs f sp ns rs tm) E0 (State cs f sp nd rs' tm')
/\ match_env map e le rs'
/\ Val.lessdef_list vl rs'##rl
/\ (forall r, In r pr -> rs'#r = rs#r)
Expand All @@ -502,7 +502,7 @@ Definition transl_condexpr_prop
(ME: match_env map e le rs)
(EXT: Mem.extends m tm),
exists rs', exists tm',
plus step tge (State cs f sp ns rs tm) E0 (State cs f sp (if v then ntrue else nfalse) rs' tm')
plus (step tge) (State cs f sp ns rs tm) E0 (State cs f sp (if v then ntrue else nfalse) rs' tm')
/\ match_env map e le rs'
/\ (forall r, In r pr -> rs'#r = rs#r)
/\ Mem.extends m tm'.
Expand Down Expand Up @@ -947,7 +947,7 @@ Definition transl_exitexpr_prop
(ME: match_env map e le rs)
(EXT: Mem.extends m tm),
exists nd, exists rs', exists tm',
star step tge (State cs f sp ns rs tm) E0 (State cs f sp nd rs' tm')
star (step tge) (State cs f sp ns rs tm) E0 (State cs f sp nd rs' tm')
/\ nth_error nexits x = Some nd
/\ match_env map e le rs'
/\ Mem.extends m tm'.
Expand Down Expand Up @@ -1298,7 +1298,7 @@ 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))
(plus (RTL.step tge) R1 t R2 \/ (star (RTL.step tge) R1 t R2 /\ lt_state S2 S1))
/\ match_states S2 R2.
Proof.
induction 1; intros R1 MSTATE; inv MSTATE.
Expand Down
22 changes: 11 additions & 11 deletions backend/Stackingproof.v
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ Lemma save_callee_save_rec_correct:
m |= range sp pos (size_callee_save_area_rec l pos) ** P ->
agree_regs j ls rs ->
exists rs', exists m',
star step tge
star (step tge)
(State cs fb (Vptr sp Ptrofs.zero) (save_callee_save_rec l pos k) rs m)
E0 (State cs fb (Vptr sp Ptrofs.zero) k rs' m')
/\ m' |= contains_callee_saves j sp pos l ls ** P
Expand Down Expand Up @@ -1000,9 +1000,9 @@ Lemma save_callee_save_correct:
let ls1 := LTL.undef_regs destroyed_at_function_entry (LTL.call_regs ls) in
let rs1 := undef_regs destroyed_at_function_entry rs in
exists rs', exists m',
star step tge
(State cs fb (Vptr sp Ptrofs.zero) (save_callee_save fe k) rs1 m)
E0 (State cs fb (Vptr sp Ptrofs.zero) k rs' m')
star (step tge)
(State cs fb (Vptr sp Ptrofs.zero) (save_callee_save fe k) rs1 m)
E0 (State cs fb (Vptr sp Ptrofs.zero) k rs' m')
/\ m' |= contains_callee_saves j sp fe.(fe_ofs_callee_save) b.(used_callee_save) ls0 ** P
/\ (forall ofs k p, Mem.perm m sp ofs k p -> Mem.perm m' sp ofs k p)
/\ agree_regs j ls1 rs'.
Expand Down Expand Up @@ -1050,9 +1050,9 @@ Lemma function_prologue_correct:
Mem.alloc m1' 0 tf.(fn_stacksize) = (m2', sp')
/\ store_stack m2' (Vptr sp' Ptrofs.zero) Tptr tf.(fn_link_ofs) parent = Some m3'
/\ store_stack m3' (Vptr sp' Ptrofs.zero) Tptr tf.(fn_retaddr_ofs) ra = Some m4'
/\ star step tge
(State cs fb (Vptr sp' Ptrofs.zero) (save_callee_save fe k) rs1 m4')
E0 (State cs fb (Vptr sp' Ptrofs.zero) k rs' m5')
/\ star (step tge)
(State cs fb (Vptr sp' Ptrofs.zero) (save_callee_save fe k) rs1 m4')
E0 (State cs fb (Vptr sp' Ptrofs.zero) k rs' m5')
/\ agree_regs j' ls1 rs'
/\ agree_locs ls1 ls0
/\ m5' |= frame_contents j' sp' ls1 ls0 parent ra ** minjection j' m2 ** globalenv_inject ge j' ** P
Expand Down Expand Up @@ -1171,7 +1171,7 @@ Lemma restore_callee_save_rec_correct:
agree_unused ls0 rs ->
(forall r, In r l -> mreg_within_bounds b r) ->
exists rs',
star step tge
star (step tge)
(State cs fb (Vptr sp Ptrofs.zero) (restore_callee_save_rec l ofs k) rs m)
E0 (State cs fb (Vptr sp Ptrofs.zero) k rs' m)
/\ (forall r, In r l -> Val.inject j (ls0 (R r)) (rs' r))
Expand Down Expand Up @@ -1216,7 +1216,7 @@ Lemma restore_callee_save_correct:
m |= frame_contents j sp ls ls0 pa ra ** P ->
agree_unused j ls0 rs ->
exists rs',
star step tge
star (step tge)
(State cs fb (Vptr sp Ptrofs.zero) (restore_callee_save fe k) rs m)
E0 (State cs fb (Vptr sp Ptrofs.zero) k rs' m)
/\ (forall r,
Expand Down Expand Up @@ -1255,7 +1255,7 @@ Lemma function_epilogue_correct:
load_stack m' (Vptr sp' Ptrofs.zero) Tptr tf.(fn_link_ofs) = Some pa
/\ load_stack m' (Vptr sp' Ptrofs.zero) Tptr tf.(fn_retaddr_ofs) = Some ra
/\ Mem.free m' sp' 0 tf.(fn_stacksize) = Some m1'
/\ star step tge
/\ star (step tge)
(State cs fb (Vptr sp' Ptrofs.zero) (restore_callee_save fe k) rs m')
E0 (State cs fb (Vptr sp' Ptrofs.zero) k rs1 m')
/\ agree_regs j (return_regs ls0 ls) rs1
Expand Down Expand Up @@ -1804,7 +1804,7 @@ Inductive match_states: Linear.state -> Mach.state -> Prop :=
Theorem transf_step_correct:
forall s1 t s2, Linear.step ge s1 t s2 ->
forall (WTS: wt_state s1) s1' (MS: match_states s1 s1'),
exists s2', plus step tge s1' t s2' /\ match_states s2 s2'.
exists s2', plus (step tge) s1' t s2' /\ match_states s2 s2'.
Proof.
induction 1; intros;
try inv MS;
Expand Down
4 changes: 2 additions & 2 deletions cfrontend/Clight.v
Original file line number Diff line number Diff line change
Expand Up @@ -715,11 +715,11 @@ Definition step2 (ge: genv) := step ge (function_entry2 ge).

Definition semantics1 (p: program) :=
let ge := globalenv p in
Semantics_gen step1 (initial_state p) final_state ge ge.
Semantics_gen (step1 ge) (initial_state p) final_state ge.

Definition semantics2 (p: program) :=
let ge := globalenv p in
Semantics_gen step2 (initial_state p) final_state ge ge.
Semantics_gen (step2 ge) (initial_state p) final_state ge.

(** This semantics is receptive to changes in events. *)

Expand Down
12 changes: 6 additions & 6 deletions cfrontend/ClightBigstep.v
Original file line number Diff line number Diff line change
Expand Up @@ -300,14 +300,14 @@ Lemma exec_stmt_eval_funcall_steps:
(forall e le m s t le' m' out,
exec_stmt ge e le m s t le' m' out ->
forall f k, exists S,
star step1 ge (State f s k e le m) t S
star (step1 ge) (State f s k e le m) t S
/\ outcome_state_match e le' m' f k out S)
/\
(forall m fd args t m' res,
eval_funcall ge m fd args t m' res ->
forall k,
is_call_cont k ->
star step1 ge (Callstate fd args k m) t (Returnstate res k m')).
star (step1 ge) (Callstate fd args k m) t (Returnstate res k m')).
Proof.
apply exec_stmt_funcall_ind; intros.

Expand Down Expand Up @@ -478,7 +478,7 @@ Lemma exec_stmt_steps:
forall e le m s t le' m' out,
exec_stmt ge e le m s t le' m' out ->
forall f k, exists S,
star step1 ge (State f s k e le m) t S
star (step1 ge) (State f s k e le m) t S
/\ outcome_state_match e le' m' f k out S.
Proof (proj1 exec_stmt_eval_funcall_steps).

Expand All @@ -487,20 +487,20 @@ Lemma eval_funcall_steps:
eval_funcall ge m fd args t m' res ->
forall k,
is_call_cont k ->
star step1 ge (Callstate fd args k m) t (Returnstate res k m').
star (step1 ge) (Callstate fd args k m) t (Returnstate res k m').
Proof (proj2 exec_stmt_eval_funcall_steps).

Definition order (x y: unit) := False.

Lemma evalinf_funcall_forever:
forall m fd args T k,
evalinf_funcall ge m fd args T ->
forever_N step1 order ge tt (Callstate fd args k m) T.
forever_N (step1 ge) order tt (Callstate fd args k m) T.
Proof.
cofix CIH_FUN.
assert (forall e le m s T f k,
execinf_stmt ge e le m s T ->
forever_N step1 order ge tt (State f s k e le m) T).
forever_N (step1 ge) order tt (State f s k e le m) T).
cofix CIH_STMT.
intros. inv H.

Expand Down
14 changes: 7 additions & 7 deletions cfrontend/Cminorgenproof.v
Original file line number Diff line number Diff line change
Expand Up @@ -1651,8 +1651,8 @@ Lemma match_is_call_cont:
match_cont k tk cenv xenv cs ->
Csharpminor.is_call_cont k ->
exists tk',
star step tge (State tfn Sskip tk sp te tm)
E0 (State tfn Sskip tk' sp te tm)
star (step tge) (State tfn Sskip tk sp te tm)
E0 (State tfn Sskip tk' sp te tm)
/\ is_call_cont tk'
/\ match_cont k tk' cenv nil cs.
Proof.
Expand Down Expand Up @@ -1745,7 +1745,7 @@ Lemma switch_descent:
exists k',
transl_lblstmt_cont cenv xenv ls k k'
/\ (forall f sp e m,
plus step tge (State f s k sp e m) E0 (State f body k' sp e m)).
plus (step tge) (State f s k sp e m) E0 (State f body k' sp e m)).
Proof.
induction ls; intros.
- monadInv H. econstructor; split.
Expand All @@ -1765,8 +1765,8 @@ Lemma switch_ascent:
forall k k1,
transl_lblstmt_cont cenv xenv ls k k1 ->
exists k2,
star step tge (State f (Sexit n) k1 sp e m)
E0 (State f (Sexit O) k2 sp e m)
star (step tge) (State f (Sexit n) k1 sp e m)
E0 (State f (Sexit O) k2 sp e m)
/\ transl_lblstmt_cont cenv xenv ls' k k2.
Proof.
induction 1; intros.
Expand Down Expand Up @@ -1799,7 +1799,7 @@ Lemma switch_match_states:
(MK: match_cont k tk cenv xenv cs)
(TK: transl_lblstmt_cont cenv xenv ls tk tk'),
exists S,
plus step tge (State tfn (Sexit O) tk' (Vptr sp Ptrofs.zero) te tm) E0 S
plus (step tge) (State tfn (Sexit O) tk' (Vptr sp Ptrofs.zero) te tm) E0 S
/\ match_states (Csharpminor.State fn (seq_of_lbl_stmt ls) k e le m) S.
Proof.
intros. inv TK.
Expand Down Expand Up @@ -1946,7 +1946,7 @@ Definition measure (S: Csharpminor.state) : nat :=
Lemma transl_step_correct:
forall S1 t S2, Csharpminor.step ge S1 t S2 ->
forall T1, match_states S1 T1 ->
(exists T2, plus step tge T1 t T2 /\ match_states S2 T2)
(exists T2, plus (step tge) T1 t T2 /\ match_states S2 T2)
\/ (measure S2 < measure S1 /\ t = E0 /\ match_states S2 T1)%nat.
Proof.
induction 1; intros T1 MSTATE; inv MSTATE.
Expand Down
Loading