rocq/theories/HelloMain.v
GNU Hello's main through the program logic
Main's proof calls the triples of every Hello layer, so it applies each layer's functor to one Logic instance: two applications of Logic have distinct expressions, and their triples could not be combined. The world is libc's, and its interpretation wi stays abstract: each premise below is what one call needs of it, so a concrete interpretation discharges them once.
Main's function, read from the linked module.
A block of main.
A 16-aligned base is 8-aligned.
Explore proof 6 tactics
Initial goal
intros H
apply Z.mod_divide in H ; | lia
destruct H as k →
replace k × 16 with 2 × k × 8 by lia
apply Z.mod_mul
lia
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
The literals main copies: "" for setlocale, the default greeting, read-only, and close_stdout's function pointer.
"Hello, world!".
Its bytes.
close_stdout, as a function pointer.
Hello's symbols put them there.
Explore proof 2 tactics
Initial goal
vm_compute
auto
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Main's entry binds argc and argv.
Explore proof 1 tactics
Main's proof over one Logic instance shared by every layer.
The Iris instance of the registry and wi.
The expressions of the language.
The genv links Hello.
An allocation of a fresh object, with its pieces added, keeps wi.
memset has its contract, and zeroing eight bytes of a block the program owns keeps wi.
set_program_name's contracts, and the layout and store premises of its three cells, as HelloName states them.
setlocale has libc's contract. The world interpretation keeps every lent name where lent_at says, admits setlocale's precondition for a category and a string the program owns, and survives its return, which lends every category's new name and sets the codec piece.
setlocale(c, p) over libc's world, from wp_lend: owning every category's name, the codec piece and the string at p, the call lends every category's new name for good, gives the codec piece a new codec and binds d to null or c's new name.
Proof 33 steps Qed
A pointer store into a cell the program owns keeps wi.
atexit has a contract returning an int, which admits the call main makes, registering close_stdout, and whose return keeps the program's pieces and wi: the registration is libc's state.
Eight zero bytes and an empty slot at offset 0 are a null pointer cell.
Explore proof 8 tactics
Initial goal
rewrite / bytes / auxes / pcell - pts_app
assert E : byte_psb 0 replicate8 0 ++ aux_psb 0 CNone = cellb 0 0 ++ PAuxb 0, VAuxCNone
2 openfocused goal
{vm_compute
2 opendeferred goal
reflexivity
deferred goal
rewrite E pts_app
cbn [ ptr_addr ptr_cap ]
rewrite / pts ! big_sepL_cons big_sepL_nil
iSplit ; iIntros [H [A _]] ; iFrame | iIntros [A H] ; iFrame
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Enter a block of main.
mbszero at the start of an object: mbszero_spec at offset 0.
Explore proof 8 tactics
Initial goal
intros Lx Lc Hb8 Hend
pose proof mbszero_specregistry wi ge Hlinked b reg 0 xs cs Φ as H
rewrite ! Z.add_0_r in H
iApply H ; exact Hmemset | exact Lx | exact Lc | exact Hb8 | reflexivity | lia | exact Hend |
intros m m′ wd h Hr Hin Hw
pose proof Kmemsetb reg 0 xs cs m m′ wd h as K
rewrite ! Z.add_0_r in K
exact KHr Hin Hw
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
The instructions of main's start block from setlocale's call on.
The temporaries main has bound before setlocale: argc, argv, the greeting's cell b4, the state b6, and the literal "".
A fresh heap object of main: positive, 16-aligned, in the address space.
Main's start block up to setlocale: two fresh objects, b4 for the greeting's cell and b6 for the conversion state, which mbszero zeroes; argv0 loaded and handed to set_program_name, which leaves the name cells at a suffix of it; the literal "" copied.
Proof 66 steps Qed
The state is zeroed.
argv0, the program's name.
setlocale(LC_ALL, "").
The rest of main's start block, from setlocale's call: setlocale lends every category's new name and sets the codec; the default greeting is stored in b4's cell; atexit registers close_stdout; and the option loop is entered.
Proof 55 steps Qed
setlocale(LC_ALL, "").
The default greeting, stored in b4's cell.
atexit(close_stdout).
Main's start block, from its entry to the option loop: the two segments above.