rocq/theories/Steps.v
What one step of Semantics.v's step does to the running frame, as Campaign 3's run-level invariant (Persistence.v) reads it.
step is one function over every point of a frame; the invariant asks, point by point, what the frame looks like after it: after a variadic callee's snapshot (step_snapshot), at a block's entry (step_enter), at an instruction (step_exec_cons) and at a return (return_step_next). The other lemmas say which instructions allocate, call or keep the locals, and how a doomed frame comes about and stays.
What a step does to the frame
A function that find_direct finds by the name n among the items of a module is one of its functions.
Explore proof 5 tactics
Initial goal
induction items as | it items IH ; simpl ; intros g H ; discriminate H |
destruct it ; try right ; apply IH ; exact H;match type of H withcontext [if name_eqb n then _ else _]⇒destruct name_eqbx nend;try right ; apply IH ; exact H;try discriminate H
injection H as ←
left
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
A function that find_fn finds by name, directly or through an alias, is a function of the running module.
Explore proof 6 tactics
Initial goal
unfold find_fn
intros ge n g H
destruct find_directn ge_modulege eqn: E
2 openfocused goal
–injection H as →
2 opendeferred goal
eapply find_direct_in ; eauto
deferred goal
–destruct find_aliasn ge_modulege ; eapply find_direct_in ; eauto | discriminate H
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
An instruction i that continues (IContinue) keeps the locals l of the frame fr, its invocation's named locals.
Explore proof 4 tactics
Initial goal
intros ge fr m i e l m′ H
destruct i
8 openfocused goal
focused goal
focused goal
focused goal
focused goal
focused goal
1: destruct special_leto eqn: Es ; destruct o ; try discriminate Es | rewrite inst_step_let_ _ _ _ _ _ _ Es in H
11 openfocused goal
focused goal
focused goal
focused goal
focused goal
focused goal
focused goal
focused goal
focused goal
all: unfold inst_step , external_call , bind_res , store_out in H ; cases H ; inversion H ; subst ; reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Explore proof 2 tactics
Initial goal
intros o k xs m q kont H
destruct o ; unfold op_res , op_res_int , float_integer in H ; cases H ; inversion H ; subst ; eauto
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Explore proof 17 tactics
Initial goal
intros ge fr m i q k H
destruct i
8 openfocused goal
focused goal
focused goal
focused goal
focused goal
focused goal
focused goal
1: destruct special_leto eqn: Es ; destruct o ; try discriminate Es | rewrite inst_step_let_ _ _ _ _ _ _ Es in H
11 openfocused goal
focused goal
focused goal
focused goal
focused goal
focused goal
focused goal
focused goal
focused goal
focused goal
all: unfold inst_step , external_call , bind_res , store_out in H ; cases H ; inversion H ; subst
2 openfocused goal
–match goal withE : op_res_ _ _ _ = SomeOpAlloc_ _ |- _⇒destruct op_res_alloc_op_ _ _ _ _ _ E as al →end
2 opendeferred goal
left
2 opendeferred goal
eexists ; eexists ; eexists ; eexists
6 opendeferred goal
shelved goal
shelved goal
shelved goal
shelved goal
split ; reflexivity |
2 opendeferred goal
intros base
2 opendeferred goal
simpl
2 opendeferred goal
match goal with|- sndfstlet _, _ ≔ in _ = _⇒destruct tend
2 opendeferred goal
reflexivity
deferred goal
–right
eexists ; eexists
3 openshelved goal
shelved goal
split ; reflexivity |
intros base
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
An instruction that calls (ICall) the function g is a call or a raw call, and g is a function of the module.
Explore proof 5 tactics
Initial goal
intros ge fr m i g xs pd H
destruct i
8 openfocused goal
focused goal
focused goal
focused goal
focused goal
1: destruct special_leto eqn: Es ; destruct o ; try discriminate Es | rewrite inst_step_let_ _ _ _ _ _ _ Es in H
11 openfocused goal
focused goal
focused goal
focused goal
focused goal
focused goal
focused goal
focused goal
all: unfold inst_step , external_call , bind_res , store_out in H ; cases H ; inversion H ; subst
3 openfocused goal
focused goal
all: split ; eapply find_fn_in ; eassumption | eauto
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
The evidence pass keeps no facts before a call (relies).
Explore proof 1 tactics
The pass keeps no facts before a raw call.
Explore proof 1 tactics
The pass keeps no facts before an alloc.
Explore proof 2 tactics
Source script
The pass keeps no facts before a named local's allocation.
Explore proof 1 tactics
Initial goal
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
The pass keeps its facts before every ahead-transparent instruction, one that may come between a check_ahead and its access.
Explore proof 5 tactics
Initial goal
unfold ahead_transparent , relies
intros s i H
apply andb_true_iff in H as H _
rewrite H
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
As doomed_result/5 in a frame fr that is not doomed: the result od is the instruction's result out as it is, or, for a doomed check_ahead, one that goes on with its pointer and dooms the frame.
Explore proof 12 tactics
Initial goal
intros ge fr m i out od Hd H
destruct ahead_insti eqn: Ea
2 open–destruct i as d k o args | | | | | | | ; try discriminate Ea
2 opendestruct k ; try discriminate Ea
2 opendestruct o ; try discriminate Ea
2 opendestruct args as | v | v′ args ; try discriminate Ea
2 openunfold doomed_result in H
2 openrewrite Hd in H
2 opencases H ; inversion H ; subst ; eauto
–rewrite doomed_result_other_ _ _ _ _ Ea in H
rewrite Hd in H
cases H ; inversion H ; subst ; auto
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
In a doomed frame, doomed_result/5 keeps it doomed, and the result is the instruction's own, a check_ahead that goes on, or an outcome.
Explore proof 13 tactics
Initial goal
intros ge fr m i out od Hd H
destruct fr_doomedfr as w0 | eqn: Ew ; | congruence
destruct ahead_insti eqn: Ea
2 openfocused goal
–destruct i as d k o args | | | | | | | ; try discriminate Ea
2 opendeferred goal
destruct k ; try discriminate Ea
2 opendeferred goal
destruct o ; try discriminate Ea
2 opendeferred goal
destruct args as | v | v′ args ; try discriminate Ea
2 opendeferred goal
unfold doomed_result in H
2 opendeferred goal
rewrite Ew in H
2 opendeferred goal
cases H ; inversion H ; subst ; simpl ; split ; discriminate | eauto
deferred goal
–rewrite doomed_result_other_ _ _ _ _ Ea in H
rewrite Ew in H
cases H ; inversion H ; subst ; simpl ; split ; discriminate | eauto
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
The next configuration after an instruction's result that is not an outcome: the same frame, at the instructions rest, with the new environment, locals and memory of a result that continues, or the callee's frame on top of the caller's, waiting at rest, for a call.
Explore proof 10 tactics
Initial goal
unfold inst_next
intros c l rest j out d c′ H
destruct out ; try discriminate H
2 openfocused goal
–injection H as ←
2 opendeferred goal
left
2 opendeferred goal
eauto
deferred goal
–destruct call_framef xs eqn: E ; | discriminate H
injection H as ←
right
eauto 7
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
After a result that allocates, the next configuration for each base the object can get is the same frame, at the instructions rest, with what the instruction makes of that base.
Explore proof 8 tactics
Initial goal
unfold inst_next
intros c l rest j out d q k H
destruct out ; try discriminate H;
injection H as ← ←
eexists
2 opensplit ; reflexivity |
intros base
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
A step at the instruction i that neither ends the run nor gets stuck runs in a frame that is not doomed or at an ahead-transparent i, and is inst_step, then doomed_result/5, then inst_next.
Explore proof 15 tactics
Initial goal
intros ge c l i rest j r Ha Hs Hd Hst
unfold step in Hs
rewrite Ha in Hs
destruct fr_doomedc_framec as w | eqn: Ew
2 openfocused goal
–destruct ahead_transparenti eqn: Et ; | subst r ; exfalso ; eapply Hd ; reflexivity
2 opendeferred goal
split ; right ; reflexivity |
2 opendeferred goal
destruct inst_stepge c_framec c_memc i as out0 | eqn: Ei ; | subst r ; exfalso ; eapply Hst ; reflexivity
2 opendeferred goal
destruct doomed_resultge c_framec c_memc i out0 as od | eqn: Eo ; | subst r ; exfalso ; eapply Hst ; reflexivity
2 opendeferred goal
exists out0, od
2 opendeferred goal
split ; first exact Ei | reflexivity | split ; first exact Eo | reflexivity | exact Hs
deferred goal
–split ; left ; reflexivity |
destruct inst_stepge c_framec c_memc i as out0 | eqn: Ei ; | subst r ; exfalso ; eapply Hst ; reflexivity
destruct doomed_resultge c_framec c_memc i out0 as od | eqn: Eo ; | subst r ; exfalso ; eapply Hst ; reflexivity
exists out0, od
split ; first exact Ei | reflexivity | split ; first exact Eo | reflexivity | exact Hs
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Explore proof 9 tactics
Initial goal
intros ge c l from c′ Ha H
unfold step in H
rewrite Ha in H
destruct c_fuelc =? 0 ; discriminate H |
apply or_stuck_next in H
destruct find_block_ _ as b | ; | discriminate H
destruct phis_envge b_phisb from fr_envc_framec as e | eqn: Ep ; | discriminate H
injection H as ←
eauto
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Entering a block never allocates.
Explore proof 9 tactics
Initial goal
intros ge c l from q k Ha H
unfold step in H
rewrite Ha in H
destruct c_fuelc =? 0 ; discriminate H |
apply or_stuck_fresh in H
destruct find_block_ _ as b | ; simpl in H ; | discriminate H
unfold phis_env in H
destruct from ; | destruct b_phisb ; simpl in H ; try discriminate H
destruct fold_left_ _ _ ; discriminate H
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
A variadic callee's snapshot of its arguments xs enters the entry block l, with the same callers, function, locals and doom.
Explore proof 5 tactics
Initial goal
intros ge c xs l c′ Ha H
unfold step in H
rewrite Ha in H
destruct xs ; injection H as ← ; simpl ; auto |
destruct negb_ ; discriminate H
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Where a snapshot allocates, it enters the entry block l with the same callers, function, locals and doom, whatever base the object gets.
Explore proof 8 tactics
Initial goal
intros ge c xs l q k Ha H base
unfold step in H
rewrite Ha in H
destruct xs ; discriminate H |
destruct negb_ ; discriminate H |
injection H as _ ←
simpl
auto
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
A return of the outcome o resumes the caller where it was waiting, with its function, locals, doom and point, and an environment given the callee's result.
Explore proof 9 tactics
Initial goal
unfold return_step
intros c o c′ H
apply or_stuck_next in H
destruct invalidate_locals_ _ as m | ; | discriminate H
destruct c_callersc as | caller pd callers ; discriminate H |
destruct match pd_convpd with None ⇒ Someo Somecw, kw ⇒ converted_outcomecw kw o end ; | discriminate H
destruct returned_env_ _ _ as e | ; | discriminate H
injection H as ←
eauto 8
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
A raw call through q, whose pointer p passed its function check (function_check_res), does not stop as unchecked.
Explore proof 9 tactics
Initial goal
intros ge fr m r q args p why Hq Hc H
unfold inst_step , value_x in H
rewrite Hq in H
cbn [ word_at_class ] in H
destruct map_option_ args ; | discriminate H
cbv beta iota zeta in H
rewrite Hc in H
cbn [ raw_res ] in H
cases H
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.