rocq/theories/Composition.v
A trusted puts contract with one continuous logical stdout and registration inventory. The additional guarantees are libc obligations, not a FILE implementation or a native coverage proof.
Keep the capability-backed stdio world, output obligations and exit registrations together; shutdown must not choose a new stdout state.
| program_stdio | ||
| program_stdout | ||
| program_pending | : listregistration |
Entry supplies well-formed logical output and distinct registration instances.
A prefix has either no acceptance observation or one cumulative summary. An empty trace must not hide accepted bytes. It is not an incremental sequence that can be concatenated with another cumulative summary.
Original argument memory fixes this call's source string. Its finite stream evolution may settle old output but accepts only a prefix of this string and newline. No eventual return or resumability is asserted.
Returning puts couples the exact before/after stdout states to its result. The ordinary contract still owns memory authority and ABI.
This strengthened contract retains puts' original capabilities, memory footprints and requests. Trusted prefix guarantees connect every normal, resource or unfinished endpoint to stdout and preserve registrations.
Every observed prefix carries an exact accounting witness, including prefixes which block or end for lack of resources.
Explore proof 5 tactics
Initial goal
intros xs m q trace q′ p & bytes & actions & tail & Hx & Hstr & Hrun & Hb & Hobs
exists actions
repeat split ; auto
apply stream_accounting
exact Hrun
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Stream well-formedness is derived from actual protocol steps, not stipulated independently at a prefix endpoint.
Explore proof 2 tactics
Initial goal
intros xs m q trace q′ p & bytes & actions & tail & _ & _ & Hrun & _ Hwf
eapply stream_run_wf ; eauto
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
No stream action turns a nonwide stream into a wide one.
Explore proof 5 tactics
Initial goal
intros q actions q′ H
induction H ; auto |
intros Ho
apply IHstream_run
destruct H ; simpl ; discriminate
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Prefix output errors remain set; normal completion is not required.
Explore proof 2 tactics
Initial goal
intros xs m q trace q′ p & bytes & actions & tail & _ & _ & Hrun & _ Herr
eapply stream_error_sticky ; eauto
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Neither normal nor unfinished puts prefixes can report process exit.
Explore proof 2 tactics
Initial goal
intros xs m q trace q′ status p & bytes & actions & tail & _ & _ & _ & _ & Hobs
destruct Hobs as → _ | → ; simpl ; intuition discriminate
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
The strengthened contract is conservative over the existing memory/effect boundary: forgetting logical output and registrations gives ordinary puts.
Projection does not re-run the call or change its exact effect path.
Explore proof 2 tactics
Initial goal
intros rep requests xs s m w born trace s′ m′ w′ He Hp _
split ; assumption
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Raw prefixes do not include contract preconditions: entry well-formedness is an explicit premise, even when the call never returns.
Explore proof 7 tactics
Initial goal
intros rep requests xs s m w born trace s′ m′ w′ He Hp Hpending Hstream Hwf Hnd
split ; exact Hpending |
split ; exact Hstream |
split
2 openfocused goal
–eapply puts_stream_prefix_wf ; eauto
deferred goal
–rewrite Hpending
exact Hnd
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Every strengthened completion is an existing puts completion; the additional world cannot mint capabilities or escape resource checks.
Explore proof 4 tactics
Initial goal
intros rep requests r args xs s m w trace ending s′ m′ w′ H
destruct H as trace ending s′ m′ w′ born Ha Hpre _ Hp Hpost _ Hnot Hret Hexit | why trace s′ m′ w′ born Ha Hpre _ Hp Hfailure Hresource
2 openfocused goal
–eapply E.invoke_normal with born := born ; eauto using program_prefix_projects
deferred goal
–eapply E.invoke_resource with born := born ; eauto using program_prefix_projects
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Normal and resource completions preserve the inventory and provide the same stdout continuity witness as an unfinished call observation.
Explore proof 3 tactics
Initial goal
intros rep requests r args xs s m w trace ending s′ m′ w′ H
destruct H
2 openfocused goal
all: eapply program_prefix_continuity ; eassumption | exact proj1proj2H0
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
A normal protocol execution is also a finite stream prefix, using the same actions, source memory, observations and endpoint.
Explore proof 8 tactics
Initial goal
intros xs m q trace ending q′ p & bytes & actions & result & Hx & Hstr & Ho Hrun tail Hb Hr & Htrace & Hend
exists p, bytes, actions, tail
split ; exact Hx |
split ; exact Hstr |
split ; exact Hrun |
split ; exact Hb |
right
exact Htrace
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Existing memory/effect evidence can be enriched by an explicit protocol witness; this does not conjure a native puts execution from stream actions.
Explore proof 10 tactics
Initial goal
intros rep requests r args xs s m w trace values s′ m′ w′ H Hwf Ho Hpending Hstream
inversion H ; subst
eapply E.invoke_normal ; eassumption | | | | eassumption | eassumption | eassumption
3 openfocused goal
focused goal
–split ; eassumption |
3 opendeferred goal
deferred goal
auto
2 opendeferred goal
deferred goal
–split ; exact proj1H2 |
2 opendeferred goal
split ; exact proj2H2 |
2 opendeferred goal
split ; exact Hpending |
2 opendeferred goal
eapply program_post_prefix ; eauto
deferred goal
–split ; eassumption
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Inhabited protocol boundaries, not native coverage
The same real main literal and libc root as the body checks, with one actual registration instance retained across puts.
This entry inventory has distinct tokens and the initial stdout is ready.
Explore proof 2 tactics
Initial goal
split ; exact stdout_initial_wf |
repeat constructor ; simpl ; tauto
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
A returning EOF can leave exactly its accepted prefix outstanding.
Proof 58 steps Qed
Partial acceptance is not dropped or replaced by an unrelated shutdown state.
Explore proof 1 tactics
Initial goal
apply eof_buffered_ 108; 108; 111; 10 ; reflexivity | repeat constructor ; lia
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
EOF permits both no acceptance and acceptance of the complete newline.
Explore proof 3 tactics
Initial goal
split ; eexists
4 openfocused goal
shelved goal
shelved goal
–apply eof_buffered_ hello_bytes ++ 10 ; reflexivity | constructor
2 opendeferred goal
shelved goal
–apply eof_buffered_ [ ] ; reflexivity | repeat constructor ; lia
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Oversize refusal remains a resource outcome, not a normal puts result.
This is an actual completed resource invocation AFTER partial acceptance. It retains output and the registration list without invoking normal exit.
Explore proof 37 tactics
Initial goal
destruct HiChecks.entry_pre as Hr Hw Hl
pose proof C.H.hi_literal_checkedHiChecks.memory Hl as Hstr
eapply C.E.invoke_resource with born := [ ]
5 openfocused goal
focused goal
focused goal
–split ; right ; exists TAtom"v1" ; reflexivity |
5 opendeferred goal
deferred goal
deferred goal
exists TmpTAtom"v0"
5 opendeferred goal
deferred goal
deferred goal
reflexivity
4 opendeferred goal
deferred goal
deferred goal
–split
5 openfocused goal
deferred goal
deferred goal
+split ; exact Hr |
5 opendeferred goal
deferred goal
deferred goal
split ; exact Hw |
5 opendeferred goal
deferred goal
deferred goal
exists hi_literal, hello_bytes
5 opendeferred goal
deferred goal
deferred goal
auto
4 opendeferred goal
deferred goal
deferred goal
+split ; exact initial_world_wf | discriminate
3 opendeferred goal
deferred goal
–split ; constructor |
3 opendeferred goal
split
4 openfocused goal
deferred goal
+split ; exact Hr |
4 opendeferred goal
deferred goal
split ; exact Hw |
4 opendeferred goal
deferred goal
split
5 openfocused goal
deferred goal
deferred goal
∗apply stdio_delegates_refl ; reflexivity | exact proj2Hw
4 opendeferred goal
deferred goal
deferred goal
∗right
4 opendeferred goal
deferred goal
exists hi_literal, hello_bytes, 104; 101, 108; 108; 111; 10
4 opendeferred goal
deferred goal
split ; reflexivity |
4 opendeferred goal
deferred goal
split ; exact Hstr |
4 opendeferred goal
deferred goal
split ; reflexivity
3 opendeferred goal
deferred goal
+split ; reflexivity |
3 opendeferred goal
exists hi_literal, hello_bytes, Accept104; 101, 108; 108; 111; 10
3 opendeferred goal
split ; reflexivity |
3 opendeferred goal
split ; exact Hstr |
3 opendeferred goal
split
4 openfocused goal
deferred goal
∗eapply stream_next ; apply stream_accept ; discriminate | repeat constructor ; lia | constructor
3 opendeferred goal
deferred goal
∗split ; reflexivity |
3 opendeferred goal
right
3 opendeferred goal
reflexivity
2 opendeferred goal
–apply C.E.failure_big with align := 16 size := 2 ^ 48 ; split ; reflexivity |
2 openunfold max_allocation_size
2 openlia
–right
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Empty observations can deliver OLD pending bytes without new acceptance.
Explore proof 10 tactics
Initial goal
exists hi_literal, hello_bytes, Deliver65; 66, hello_bytes ++ 10
split ; reflexivity |
split
2 openfocused goal
–apply HiChecks.H.hi_literal_checked
2 opendeferred goal
exact proj2proj2HiChecks.entry_pre
deferred goal
–split
2 openfocused goal
+eapply stream_next ; apply stream_deliver65; 66 [ ] false ; discriminate | constructor
deferred goal
+split ; reflexivity |
left
split ; reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
A silent summary cannot hide any newly accepted bytes.
Explore proof 1 tactics
Initial goal
intros _ Hb | Ht ; discriminate
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Changing the inventory violates the strengthened prefix even if all memory and byte observations could satisfy the ordinary contract.
Explore proof 2 tactics
Initial goal
intros born trace m′ q _ Hpending _
discriminate Hpending
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
A wide-oriented stream cannot enter this strengthened contract, even EOF.
Explore proof 3 tactics
Initial goal
intros _ _ Hwide
apply Hwide
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Endpoint equality does not identify a unique delivery history: when error is already set, delivery and error-discard can end identically.
Explore proof 1 tactics
Initial goal
split ; eapply stream_next ; apply stream_deliver65 [ ] true ; discriminate | constructor | apply stream_discard65 [ ] true ; discriminate | constructor
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.