rocq/theories/ScanLogic.v
rocq/programs/scan.c through the program logic of Logic.v, with strlen, strchr and puts called through Campaign 4's contracts.
scan reads memory after a libc call: it takes the length of its string s, finds the first l in it, prints the rest of s from there, and then reads the byte after that l through the pointer strchr returned. Each call is a triple of StringLogic.v, used as a rule: wp_strlen and wp_strchr hand the string back unchanged, wp_puts hands back the suffix it was lent (string_suffix), which the frame for external calls keeps through puts's writes. The read after puts takes the object's life and the one byte from the suffix (string_byte) for a read check through the string's capability, read-write or read-only (wp_check_read), and a byte load (wp_raw_load_byte). That the l is not the NUL is what puts the byte after it inside the string.
scan_logic_safe is the labelled machine's safety from any memory holding the string, with its object apart from the stdio world's roots; interp_scan_logic_safe instantiates it on Hi.v's fixture, whose literal is "hello".
The module
The checked module nanofil makes of scan.c (scan_term).
The fixture decodes to scan_module.
Explore proof 2 tactics
Initial goal
vm_compute
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
The module's one function, scan.
The module's symbols: scan alone; strlen, strchr and puts are external.
Laying out the module gives scan_globals.
Explore proof 2 tactics
Initial goal
vm_compute
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Block l of scan, or an empty one.
The entry block: strlen, strchr, and the test for a miss.
The miss: return 0.
The hit: puts, then the read after it.
scan has its entry block.
Explore proof 2 tactics
Initial goal
vm_compute
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
scan has its miss block.
Explore proof 2 tactics
Source script
scan has its hit block.
Explore proof 2 tactics
Initial goal
vm_compute
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
scan returns an int.
Explore proof 1 tactics
scan called with the pointer p.
A call of scan with p starts it at scan_entry.
Explore proof 1 tactics
Initial goal
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
The contracts scan is linked with: strlen, strchr and puts, the last with the trusted stream representation rep.
The raw address of a at offset 0 is a, inside the address space.
Explore proof 5 tactics
Initial goal
intros H
unfold raw_address
rewrite Z.add_0_r
apply Z.mod_small
exact H
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Prove an address premise: drop the wraps of raw_address and of the flight's sum where arithmetic shows them the identity, then arithmetic.
scan over any runtime R.
The linked genv: the module, its symbol, R's free.
puts's trusted stream representation and allocation requests.
Hi.v's premise: a safepoint keeps rep and readiness.
stdio_wi survives safepoints, by stdio_stable.
The Iris instance of scan: its contracts and stdio_wi.
The expressions of scan's language.
scan, owning the string at p, is safe and returns an int.
Proof 70 steps Qed
A hit at i, before the NUL.
A miss: return 0.
scan is safe: from a ready runtime, live objects apart, puts's rep and readiness of the world, and a string at p, in an object no root of the world reaches into, with any fuel, no labelled run stops with a failure_ending, and a run that returns returns an int. By heap_labelled_safe from scan_spec, the ghost heap starting with the string's pieces.
Explore proof 21 tactics
Initial goal
intros Hr Hd Hrep Hw Hok Ha Hapart
apply heap_labelled_safeΣ scan_registryrep requests stdio_wirep scan_ge scan_entryp m s w list_to_mapstring_psp b reg bytes
5 openfocused goal
focused goal
focused goal
focused goal
–exact Hr
4 opendeferred goal
deferred goal
deferred goal
deferred goal
–exact Hd
3 opendeferred goal
deferred goal
deferred goal
–intros l v Hl
3 opendeferred goal
deferred goal
exact all_agree_elem_ _ _ _ Ha elem_of_list_to_map_2_ _ _ Hl
2 opendeferred goal
deferred goal
–split ; exact Hrep |
2 opendeferred goal
split ; exact Hw |
2 opendeferred goal
intros sp a Hin Hs l & v & reg′ & Hl & _ & E _ & Hb
2 opendeferred goal
apply elem_of_list_to_map_2 in Hl
2 opendeferred goal
rewrite string_ps_id_ _ _ _ _ _ Hl in E , Hb
2 opendeferred goal
destruct Ha as E′ _ _
2 opendeferred goal
cbn [ fst snd ] in E′
2 opendeferred goal
rewrite E′ in E
2 opendeferred goal
injection E as ←
2 opendeferred goal
exact Hapartsp a Hin Hs Hb
deferred goal
–intros HinvG HheapG
rewrite big_sepM_list_to_map ; | exact string_ps_nodupp b reg bytes
iIntros Hs
iApply scan_specp b reg bytes with [$Hs]
done
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
The interpreter's runtime
scan over the interpreter's runtime.
scan is safe under the interpreter's runtime, called with Hi.v's literal "hello" in Hi.v's fixture memory, with the fixture's stream representation.
Explore proof 19 tactics
Initial goal
intros fuel
destruct HiChecks.entry_pre as Hrep & Hw & Hv
apply InterpScanLogic.scan_logic_safefixture_rep fixture_requests HiChecks.interpreter_stdio_stablefixture_rep hiΣ _ _ _ _ _ 65552 lit_reg hello_bytes
7 openfocused goal
focused goal
focused goal
focused goal
focused goal
focused goal
–exact hi_memory_ready
6 opendeferred goal
deferred goal
deferred goal
deferred goal
deferred goal
deferred goal
–exact hi_memory_disjoint
5 opendeferred goal
deferred goal
deferred goal
deferred goal
deferred goal
–exact Hrep
4 opendeferred goal
deferred goal
deferred goal
deferred goal
–exact Hw
3 opendeferred goal
deferred goal
deferred goal
–unfold string_ok
3 opendeferred goal
deferred goal
cbn
3 opendeferred goal
deferred goal
split ; right ; reflexivity |
3 opendeferred goal
deferred goal
repeat split ; try lia
3 opendeferred goal
deferred goal
repeat constructor ; lia
2 opendeferred goal
deferred goal
–apply all_agree_intro
2 opendeferred goal
intros l v Hl
2 opendeferred goal
exact InterpHiLogic.lit_valid_agrees_ Hv l v Hl
deferred goal
–intros sp a [ <-| [ ] ] Hs
unfold span_contains in Hs
cbn in Hs
lia
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.