rocq/theories/HelloClose.v
GNU Hello's closeout helpers through the separation logic. Module statics and the four errno bytes are owned pieces. Stream operations are premise triples, including their frame obligations; the null file name excludes the named-file diagnostic.
Keep unknown arithmetic folded in computed instruction premises.
The stream-closing helper from the linked IR.
The exit callback from the linked IR.
A close_stream block.
A close_stdout block.
The canonical W loaded from four owned bytes, signed or unsigned.
A canonical W value fits its return channel.
Explore proof 4 tactics
close_stream binds its stream argument.
Explore proof 1 tactics
Initial goal
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
The stream helper over any runtime.
The instance used by all closeout triples.
Expressions in the linked program.
The represented errno cell is fixed in this thread.
The errno pointer used in the IR.
Errno lookup exports the represented cell without changing any pieces. Local rule for promotion to a libc logic module.
Proof 30 steps Qed
A four-byte load from owned memory. Local rule for promotion to MemLogic.v; it needs neither a world fact nor eight-byte ownership.
Proof 36 steps Qed
An invocation frame, promoted locally to an Iris call rule. The pure endpoint premise describes the whole authoritative heap after the call, including updates to pieces the caller handed over. Local bridge for promotion to Logic.v.
Proof 25 steps Qed
Stream admission and consumption are represented by ghost pieces; fclose replaces their values with closed-state pieces of the same keys, rather than restoring usability of the stream.
Ownership of a usable stream's represented pieces.
Query specs, including their exact ABI and pure frame obligations. The query preserves the original owned pieces and libc world.
fclose's spec consumes usable stream pieces, returning closed pieces and arbitrary four-byte errno contents. Its frame premise includes readiness, separation and libc's world, not just the returned value.
Derive the two query call-site triples from their raw contracts.
Proof 31 steps Qed
Derive the consuming close call-site triple from its raw contract.
Proof 28 steps Qed
Storing zero into owned errno preserves libc's world interpretation.
The errno cell is inside the represented address space.
Find a stream-close block without unfolding the module in a proof.
A pure instruction, with the environment kept abstract.
After the error decision, close_stream returns zero or EOF, clearing errno only when an earlier error accompanies a successful fclose.
Proof 47 steps Qed
Hand the merged error flag to the shared return blocks.
close_stream consumes a usable stream and returns zero or EOF. It returns ownership of errno, whose contents may have changed. Sticky error, pending data, fclose failure and EBADF take distinct paths.
Proof 63 steps Qed
Hello's read-only unnamed-file diagnostic strings.
The write-error text.
The caller hands the diagnostic's represented string pieces to error; they return unchanged while errno may change.
error with zero status returns void; it never substitutes an exit for the following _exit. Resource terminals need no continuation.
Proof 37 steps Qed
_exit's raw contract admits a canonical status and has no ordinary return endpoint. Its actual process-exit semantics belong to Ending.
An admissible _exit call is safe under every postcondition.
Proof 19 steps Qed
Load a stream pointer while borrowing its life from the stream's represented pieces, without duplicating that linear life token.
Proof 26 steps Qed
The null file-name pointer is eight owned zero bytes and a null aux slot. This is a module invariant, not a fact about libc's world.
Explore proof 3 tactics
Initial goal
change ptsHeap.cell65584 0 0 ∗ ptsPAux65584 0, VAuxCNone ⊣⊢ ptsPAux65584 0, VAuxCNone ++ Heap.cell65584 0 0
rewrite pts_app
apply bi.sep_comm
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
The concrete module cells; libc supplies only stdout and stderr's pointer-cell locations. All these pieces are handed back on return.
Closeout's owned module memory and the imported pointer cells.
The module's symbols put closeout's statics and literals there.
Explore proof 6 tactics
Initial goal
destruct Hlinked as _ & Hg & _
repeat split ; try apply Hg ; vm_compute ; reflexivity
exists mkPtr65648 Ro65648
apply Hg
vm_compute
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Enter one of close_stdout's blocks.
The linked module dispatches close_stream to its proved body.
Explore proof 4 tactics
Initial goal
unfold find_fn
rewrite proj1Hlinked
vm_compute
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
A null file name takes the unnamed-file diagnostic, then _exit. quotearg_colon is not called and needs no premise triple.
Proof 62 steps Qed
Close stderr after stdout was settled. Its failure exits directly; a successful return preserves all module cells and errno ownership.
Proof 49 steps Qed
The exit callback closes stdout then stderr. It returns all module statics and pointer cells on normal return; errors either report the unnamed write failure and exit or, for stderr, exit directly.
Proof 61 steps Qed
HelloCloseOn over a Logic instance of its own.