rocq/theories/StepRules.v
What one step gives, rule by rule: for each instruction form of the core subset and each jump, the configuration step reaches from a frame at it, under premises small enough to compute on their own. They are the forward reading of Steps.v, whose lemmas say what a step that happened must have been.
A program proof that reduces step itself carries the whole function and memory through every reduction; Cycle.v and Buffer.v spend most of their time there (proof, docs/logic.md). With these rules, a proof names the instruction, checks the premises (a temporary's value, an operation on words, an access check against an object's region) and gets the next configuration as a term. They are the instruction rules of the program logic (docs/logic.md): its weakest-precondition rules are these, lifted.
Every rule is for a frame that is not doomed.
Operations
An instruction's result that continues keeps a frame that is not doomed undoomed.
Explore proof 7 tactics
Initial goal
intros ge fr m i e ls m′ Hd
unfold doomed_result
rewrite Hd
destruct i as d k o args | | | | | | | ; try reflexivity
destruct k ; try reflexivity
destruct o ; try reflexivity
destruct args as | a | a′ args ; reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
An instruction's result that allocates keeps a frame that is not doomed undoomed.
Explore proof 7 tactics
Initial goal
intros ge fr m i q kk Hd
unfold doomed_result
rewrite Hd
destruct i as d k o args | | | | | | | ; try reflexivity
destruct k ; try reflexivity
destruct o ; try reflexivity
destruct args as | a | a′ args ; reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
An instruction's result that calls keeps a frame that is not doomed undoomed.
Explore proof 7 tactics
Initial goal
intros ge fr m i g xs pd Hd
unfold doomed_result
rewrite Hd
destruct i as d k o args | | | | | | | ; try reflexivity
destruct k ; try reflexivity
destruct o ; try reflexivity
destruct args as | a | a′ args ; reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Explore proof 5 tactics
Initial goal
intros ge f e ls l i rest j cs m fuel out Hi Hd
unfold step ; cbn [ fr_at c_frame c_mem fr_doomed ]
rewrite Hi
rewrite Hd
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
A let of a general op whose arguments read as the words xs and whose op_res is the word w, in the memory m': the frame binds w to d and goes on, in m'.
Explore proof 12 tactics
Initial goal
intros ge f e ls l d k o args rest j cs m fuel classes xs w m′ Hg Hc Hx Ho
assert Hi : inst_stepge mkFramef e ls None Execl Letd k o args :: rest j m Letd k o args = SomeIContinueputd w e ls m′
2 openfocused goal
{transitivity let* classes ≔ op_arg_classeso k in let* xs ≔ map2_optionvalue_xge e classes args in let* out ≔ op_reso k xs m in match out with OpResr m′ ⇒ Somebind_resd r e ls m′ OpUBwhy ⇒ SomeIStopUBwhy OpAllocq kont ⇒ SomeIFreshq λbase ⇒ let x, m′ ≔ kontbase in putd x e, ls, m′ end
3 openfocused goal
deferred goal
–destruct o ; try discriminate Hg ; destruct k ; reflexivity
2 opendeferred goal
deferred goal
–rewrite Hc
2 opendeferred goal
cbn - [ op_res map2_option ]
2 opendeferred goal
rewrite Hx
2 opendeferred goal
cbn - [ op_res ]
2 opendeferred goal
rewrite Ho
2 opendeferred goal
reflexivity
deferred goal
rewrite rule_inst_ _ _ _ _ _ _ _ _ _ _ _ Hi by apply doomed_result_continue ; reflexivity
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Explore proof 5 tactics
Initial goal
intros ge f e ls l d k al args rest j cs m fuel size Hx Hs
assert Hi : inst_stepge mkFramef e ls None Execl Letd k Allocal args :: rest j m Letd k Allocal args = SomeIFreshheap_reqal size λbase ⇒ putd WPtrmkPtrbase Objbase e, ls, allocatedm heap_reqal size base
2 openfocused goal
{destruct k ; cbn - [ map2_option heap_req allocated max_allocation_size ] ; rewrite Hx ; cbn - [ heap_req allocated max_allocation_size ] ; replace max_allocation_size <? size with false by symmetry ; apply Z.ltb_ge ; exact Hs ; reflexivity
deferred goal
rewrite rule_inst_ _ _ _ _ _ _ _ _ _ _ _ Hi by apply doomed_result_fresh_none ; reflexivity
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Flights and stores
Explore proof 7 tactics
Initial goal
intros ge f e ls l d o args lw rest j cs m fuel xs n c Hx Ha Hc
assert Hi : inst_stepge mkFramef e ls None Execl Flightd o args lw :: rest j m Flightd o args lw = SomeIContinueputd WPtrmkPtrn c e ls m
2 openfocused goal
{cbn - [ map_option alu flight_cap ]
2 opendeferred goal
rewrite Hx , Ha , Hc
2 opendeferred goal
reflexivity
deferred goal
rewrite rule_inst_ _ _ _ _ _ _ _ _ _ _ _ Hi by apply doomed_result_continue ; reflexivity
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
A raw store of width w of the value v, which reads as x, through the proven pointer a, which reads as p, at offset off, where the store passes and leaves the memory m': the frame goes on in m'.
Explore proof 7 tactics
Initial goal
intros ge f e ls l w off v a rest j cs m fuel vk x p m′ Hw Hv Ha Hs
assert Hi : inst_stepge mkFramef e ls None Execl RawStorew off v a :: rest j m RawStorew off v a = SomeIContinuee ls m′
2 openfocused goal
{cbn - [ width_value_class value_x store_res raw_address ]
2 opendeferred goal
rewrite Hw , Hv , Ha , Hs
2 opendeferred goal
reflexivity
deferred goal
rewrite rule_inst_ _ _ _ _ _ _ _ _ _ _ _ Hi by apply doomed_result_continue ; reflexivity
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
A raw store of the pointer v, which reads as xp, through the proven pointer a, which reads as p, at offset off: where the 8-byte write access there passes and the protocol es leaves the memory m', the frame goes on in m'.
Explore proof 9 tactics
Initial goal
intros ge f e ls l off v a es rest j cs m fuel xp p m′ Hv Ha Hc Hs
assert Hi : inst_stepge mkFramef e ls None Execl RawStorePointeroff v a es :: rest j m RawStorePointeroff v a es = SomeIContinuee ls m′
2 openfocused goal
{cbn - [ value_x access_res pointer_store_effects raw_address ]
2 opendeferred goal
rewrite Hv , Ha , Hc
2 opendeferred goal
cbn - [ pointer_store_effects raw_address ]
2 opendeferred goal
rewrite Hs
2 opendeferred goal
reflexivity
deferred goal
rewrite rule_inst_ _ _ _ _ _ _ _ _ _ _ _ Hi by apply doomed_result_continue ; reflexivity
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Calls
A direct call of the function g, defined in the module, with arguments that read as xs and make its frame callee: the callee runs on top, and the caller waits at the rest of its block for the result r.
Explore proof 9 tactics
Initial goal
intros ge f e ls l r g args rest j cs m fuel xs gf callee Hx Hf Hc
assert Hi : inst_stepge mkFramef e ls None Execl Callr Globalg args :: rest j m Callr Globalg args = SomeICallgf xs mkPendingr None
2 openfocused goal
{cbn - [ map_option find_fn ]
2 opendeferred goal
rewrite Hx , Hf
2 opendeferred goal
reflexivity
deferred goal
rewrite rule_inst_ _ _ _ _ _ _ _ _ _ _ _ Hi by apply doomed_result_call ; reflexivity
cbn [ inst_next c_frame fr_fn fr_env fr_locals c_callers c_mem c_fuel ]
rewrite Hc
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
A call of libc's void free(p), a name the module neither defines nor holds as data, whose argument v reads as x, where the genv's free frees x without a trap and leaves the memory m': the frame goes on in m' (external_call).
Explore proof 11 tactics
Initial goal
intros ge f e ls l v rest j cs m fuel x m′ Hf Hd Hx Hfree
assert Hi : inst_stepge mkFramef e ls None Execl CallCVoid Globalfree_name ArgP v :: rest j m CallCVoid Globalfree_name ArgP v = SomeIContinuee ls m′
2 openfocused goal
{cbn - [ arg_x find_fn lookup ge_free ]
2 opendeferred goal
rewrite Hx , Hf
2 opendeferred goal
unfold external_call
2 opendeferred goal
rewrite Hd
2 opendeferred goal
cbn - [ ge_free ]
2 opendeferred goal
rewrite Hfree
2 opendeferred goal
reflexivity
deferred goal
rewrite rule_inst_ _ _ _ _ _ _ _ _ _ _ _ Hi by apply doomed_result_continue ; reflexivity
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Blocks and jumps
Entering the block l of f, found as b, from the edge from, with fuel left: its phis bind the environment e', and the frame goes on at its instructions with one fuel less.
Explore proof 7 tactics
Initial goal
intros ge f e ls l from cs m fuel b e′ Hf Hb Hp
unfold step ; cbn [ fr_at c_frame c_fuel fr_fn fr_env ]
replace fuel =? 0 with false by symmetry ; apply Z.eqb_neq ; exact Hf
rewrite Hb
cbn [ b_phis ]
rewrite Hp
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Entering a block with no fuel left ends the run, out of fuel.
Explore proof 1 tactics
Initial goal
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
A goto to the target t, polling or not, enters its block from l.
Explore proof 2 tactics
Initial goal
intros
destruct t ; reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
A branch on v, which reads as the integer n, enters t2's block from l if n is 0, else t1's.
Explore proof 5 tactics
Initial goal
intros ge f e ls l v t1 t2 cs m fuel n Hv
unfold step ; cbn [ fr_at c_frame fr_doomed jump_step fr_env ]
rewrite Hv
cbn [ or_stuck ]
destruct n =? 0 , t1 , t2 ; reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
A return of v, which reads as x at f's return class k: the invocation ends with Retx (return_step).
Explore proof 4 tactics
Initial goal
intros ge f e ls l v cs m fuel k x Hk Hv
unfold step ; cbn [ fr_at c_frame fr_doomed jump_step fr_env fr_fn ]
rewrite Hk , Hv
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
A return from a void function: the invocation ends with RetVoid (return_step).
Explore proof 2 tactics
Initial goal
intros
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
An invocation whose named locals end, leaving the memory m', and that has no caller: the run's outcome is o.
Explore proof 4 tactics
Initial goal
intros fr m fuel o m′ H
unfold return_step ; cbn [ c_frame c_mem c_callers ]
rewrite H
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
An invocation whose named locals end, leaving the memory m', and whose caller cf reads the result as pd says, binding its environment e': the caller goes on, in m'.
Explore proof 4 tactics
Initial goal
intros fr cf pd cs m fuel o m′ e′ H Hc He
unfold return_step ; cbn [ c_frame c_mem c_callers c_fuel ]
rewrite H , Hc , He
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
An invocation with no named locals ends without changing memory.
Explore proof 1 tactics
Initial goal
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Access checks
An access of size bytes at the address a through the capability of the object b, live or not, with the region reg: it passes where the bytes lie in its bounds and a is aligned.
Explore proof 7 tactics
Initial goal
intros m b reg a size r al Hr H1 H2 H3
unfold access_res , cap_access_res
rewrite Hr
replace b ≤? a && a + size ≤? r_endreg with true by symmetry ; apply andb_true_iff ; split ; apply Z.leb_le | apply Z.leb_le ; lia
unfold aligned_res
rewrite H3
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
A read through a read-write or read-only capability for the object b with the region reg, of size bytes at a within its bounds and aligned, passes.
Explore proof 8 tactics
Initial goal
intros m b reg c a size al [ ->| -> ] Hr H1 H2 H3 ; exact access_obj_ _ _ _ _ _ _ Hr H1 H2 H3 |
unfold access_res , cap_access_res
rewrite Hr
replace b ≤? a && a + size ≤? r_endreg with true by symmetry ; apply andb_true_iff ; split ; apply Z.leb_le | apply Z.leb_le ; lia
cbn [ readonly_access_res ]
unfold aligned_res
rewrite H3
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
A check of the pointer p whose access passes: p, proven.
Explore proof 4 tactics
Initial goal
intros m p lo hi r al H
cbn - [ access_res raw_address ]
rewrite H
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
A half_check of the pointer p, against the proof p1 of the same capability, at a live object b whose bounds hold the bytes, which are aligned, and which ends at or below 2^63: p, proven. Both the full check and the half check's native test pass.
Explore proof 22 tactics
Initial goal
intros m p1 p bd lo hi r al b reg H1 H2 Hr Hl Hlo Hhi Hlh Hend Hal
assert Hacc : access_resm raw_addressptr_addrp lo Objb hi − lo r al = Someok by eapply access_obj ; eauto
cbn - [ access_res raw_address half_passes ]
rewrite H1 , H2
cbn [ cap_eqb ]
rewrite Z.eqb_refl , Hacc
unfold half_passes
rewrite Hr
cbn [ option_map ]
replace half_boundbd raw_addressptr_addrp lo hi − lo b r_endreg r_lifereg with true
2 openfocused goal
–rewrite Hal , Z.eqb_refl
2 opendeferred goal
destruct r ; reflexivity
deferred goal
–symmetry
unfold half_bound
rewrite Hl
destruct bd ; apply Z.leb_le ; lia |
assert Hn : 0 ≤ raw_addressptr_addrp lo < 2 ^ 63
2 openfocused goal
{pose proof Z.mod_pos_boundptr_addrp + lo 2 ^ 64 ltac:lia as Hm
2 opendeferred goal
fold raw_addressptr_addrp lo in Hm
2 opendeferred goal
lia
deferred goal
replace 2 ^ 63 ≤? raw_addressptr_addrp lo with false by symmetry ; apply Z.leb_gt ; lia
apply Z.leb_le ; lia
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
A read half_check of the pointer p, against the proof p1 of the same capability, an object's or a read-only object's, at a live object b whose bounds hold the bytes, which are aligned, and which ends at or below 2^63: p, proven. A read-only capability passes a read's native test as an object's does.
Explore proof 23 tactics
Initial goal
intros m p1 p bd lo hi al b reg E Hc Hr Hl Hlo Hhi Hlh Hend Hal
destruct Hc as Hc | Hc ; rewrite Hc in E ; exact op_half_check_ _ _ _ _ _ Read _ _ _ E Hc Hr Hl Hlo Hhi Hlh Hend Hal |
assert Hacc : access_resm raw_addressptr_addrp lo Rob hi − lo Read al = Someok by eapply access_read ; eauto
cbn - [ access_res raw_address half_passes ]
rewrite E , Hc
cbn [ cap_eqb ]
rewrite Z.eqb_refl , Hacc
unfold half_passes
rewrite Hr
cbn [ option_map ]
replace half_boundbd raw_addressptr_addrp lo hi − lo b r_endreg r_lifereg with true
2 openfocused goal
–rewrite Hal , Z.eqb_refl
2 opendeferred goal
reflexivity
deferred goal
–symmetry
unfold half_bound
rewrite Hl
destruct bd ; apply Z.leb_le ; lia |
assert Hn : 0 ≤ raw_addressptr_addrp lo < 2 ^ 63
2 openfocused goal
{pose proof Z.mod_pos_boundptr_addrp + lo 2 ^ 64 ltac:lia as Hm
2 opendeferred goal
fold raw_addressptr_addrp lo in Hm
2 opendeferred goal
lia
deferred goal
replace 2 ^ 63 ≤? raw_addressptr_addrp lo with false by symmetry ; apply Z.leb_gt ; lia
apply Z.leb_le ; lia
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
A renew of the pointer p, against the proof p1 of the same capability, whose own access check passes: p, proven, as the check it replaced would have proven it.
Explore proof 6 tactics
Initial goal
intros m p1 p lo hi r al E H
cbn - [ access_res raw_address cap_eqb ]
rewrite E
replace cap_eqbptr_capp ptr_capp with true by symmetry ; destruct ptr_capp ; cbn ; try apply Z.eqb_refl ; try apply term_eqb_refl ; reflexivity
rewrite H
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
A raw load of 8 bytes at offset off from the proven pointer p, whose read access passes: the little-endian integer there.
Explore proof 8 tactics
Initial goal
intros m k p off H
assert E : op_resRawLoadLdL off k WPtrp m = op_res_intRawLoadLdL off k WPtrp m by destruct k ; reflexivity
rewrite E
cbn - [ access_res raw_address load_bytes ]
unfold int_load_res
cbn - [ access_res raw_address load_bytes ]
rewrite H
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
A raw load of the one-byte narrow type n at offset off from the proven pointer p, whose read access passes: the byte there, extended to the class k.
Explore proof 12 tactics
Initial goal
intros m k n p off Hn H
assert E : op_resRawLoadLdNarrown off k WPtrp m = op_res_intRawLoadLdNarrown off k WPtrp m by destruct k ; reflexivity
assert Hl : load_bytesm raw_addressptr_addrp off 1 = m_bytesm raw_addressptr_addrp off
2 openfocused goal
{unfold load_bytes
2 opendeferred goal
change Z.to_nat1 with 1%nat
2 opendeferred goal
cbn - [ raw_address ]
2 opendeferred goal
now rewrite Z.add_0_r
deferred goal
rewrite E
cbn - [ access_res raw_address load_bytes narrow_type extended ]
unfold int_load_res
rewrite Hn , H , Hl
destruct extendedn k _ ; reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
A raw pointer load at offset off from the proven pointer p, whose 8-byte read access passes and whose protocol es loads x: x.
Explore proof 6 tactics
Initial goal
intros m p off es x H He
cbn - [ access_res raw_address pointer_load_effects ]
rewrite H
cbn - [ raw_address pointer_load_effects ]
rewrite He
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Explore proof 1 tactics
Initial goal
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
The store protocol nanofil emits for a plain pointer store writes the capability to the aux, then the address to the bytes.
Explore proof 1 tactics
Initial goal
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
A read of size bytes at the address a through the read-only capability of the object b, with the region reg: it passes where the bytes lie in its bounds and a is aligned, as access_obj for a read.
Explore proof 7 tactics
Initial goal
intros m b reg a size al Hr H1 H2 H3
unfold access_res , cap_access_res
rewrite Hr
replace b ≤? a && a + size ≤? r_endreg with true by symmetry ; apply andb_true_iff ; split ; apply Z.leb_le | apply Z.leb_le ; lia
unfold readonly_access_res , aligned_res
rewrite H3
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
A store of the integer v as a long at the address a through the capability c, whose 8-byte write access passes: its bytes.
Explore proof 4 tactics
Initial goal
intros m a c v H
cbn - [ access_res store_bytes ]
rewrite H
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.