rocq/theories/LibcStreamLogic.v
Program-memory and selected-FILE world frames over the logic's exact machine. Private FILE representation is trusted; separation from program pieces is explicit and propagated, not assumed at return.
A fixed FILE handle's authority is apart from the program heap. This predicate intentionally does not promise that the handle is open: errno and hard-exit boundaries must remain usable after close.
A close-callback boundary may have a closed FILE, but must not yet have handed control to the host. Readiness alone does not say this.
Explore proof 9 tactics
Initial goal
intros world model w p born m w′ h Hroots & _ & Hrelease Hra Hrel Hb Hd
split
2 openfocused goal
–intros root a Hin Hspan Hown
2 opendeferred goal
destruct Hrootsroot Hin as _ Hauth
2 opendeferred goal
exact owned_not_authority_ _ _ _ _ Hd Hra Hb Hown Hautha Hspan
deferred goal
–intros base l v Hin Hlookup Hmem
destruct Hreleasebase Hin as Hold | Hnew
2 openfocused goal
+exact Hrelbase l v Hold Hlookup Hmem
deferred goal
+exact Hbbase l v Hnew Hlookup Hmem
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Use the consumer's logic and its inductive call relations, not a separately instantiated sibling machine. No new runtime law.
Native represented readiness at a collector poll is an explicit realization law. Region identity then proves the heap-separation part, rather than requiring a separate separation assumption.
Explore proof 14 tactics
Initial goal
intros rep p Hstable
split
intros s m s′ m′ w h Hsp Hr & Hapart & Hrel
split ; eapply Hstable ; eauto |
split ; | exact Hrel
intros root a Hin Hspan l & v & reg & Hl & Hmem & E Hlive & Hrange
apply Hapartroot a Hin Hspan
exists l, v, reg
split ; exact Hl |
split ; exact Hmem |
split ; | exact Hrange
split ; | exact Hlive
rewrite R.collector_live_ _ _ _ Hsp in E
exact E
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Narrow actions cannot turn a non-wide stream into a wide one.
Explore proof 5 tactics
Initial goal
intros q actions q′ Hrun
induction Hrun ; auto |
intros Hn
apply IHHrun
inversion H ; subst ; simpl ; congruence
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Active lookup is consistent with the sole authoritative protocol.
Explore proof 3 tactics
Initial goal
intros w p info Hinfo
unfold libc_stream_at in Hinfo
destruct libc_file_atw p ; injection Hinfo as ← ; reflexivity | discriminate
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Output does not close its selected handle or switch it to wide. This holds even when the accepted prefix ends in a resource failure.
Explore proof 15 tactics
Initial goal
intros rep requests wide api r args xs p s m w trace ending s′ m′ w′ → Hn Hcall
destruct M.E.invoke_prefix_ _ _ _ _ _ _ _ _ _ _ _ _ Hcall as born & _ & info & info′ & bytes & actions & tail & Hinfo & Htext & Hbytes & Hrun & Hready & Hinfo′ & Hframe & _
destruct Hready as _ & Hactive & Hstate & _
change stream_protocolinfo′ = libc_stream_statew′ output_targetapi libc_stdout w xs in Hstate
change libc_stream_atw output_targetapi libc_stdout w xs = Someinfo in Hinfo
split
2 openfocused goal
–change libc_stream_atw′ output_targetapi libc_stdout w xs = Someinfo′ in Hactive
2 opendeferred goal
unfold libc_stream_at in Hactive
2 opendeferred goal
destruct libc_file_atw′ _ as file | ; exists file ; reflexivity | discriminate
deferred goal
–split
2 openfocused goal
+rewrite <- Hstate
2 opendeferred goal
eapply narrow_run ; exact Hrun |
2 opendeferred goal
rewrite <- active_protocol_ _ _ Hinfo
2 opendeferred goal
exact Hn
deferred goal
+exact proj1Hframe
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Returning or resource-ending output preserves the program heap and re-establishes selected-FILE separation for the next call.
Explore proof 10 tactics
Initial goal
intros rep requests wide api r args xs p s m w trace ending s′ m′ w′ h → Hcall Ha Hd Hr Hready & Hra & Hrel
destruct M.E.invoke_prefix_ _ _ _ _ _ _ _ _ _ _ _ _ Hcall as born & Hp
destruct M.E.prefix_preserve_ _ _ _ _ _ _ _ _ _ _ Hp Hr as Hr′ _
destruct LG.prefix_agrees_ _ _ _ _ _ _ _ _ _ _ h Hp Hr Hd Ha Hra ltac:intros base l v as Ha′ & Hd′ & Hb & Hra′
destruct Hp as _ & info & info′ & bytes & actions & tail & Hinfo & Htext & Hbytes & Hrun & Hopen & Hid & Hframe & Hdelegate & Htrace & Haux
split ; exact Ha′ |
split ; exact Hd′ |
split ; exact Hr′ |
split ; exact proj1Hopen |
exact stream_delegates_apartlibc_world libc_stream_modelrep requests wide w _ born m′ w′ h Hdelegate Hra′ Hrel Hb Hd′
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
The result part of HelloVersion's frame is obtained independently from the normal contract result; no output-success premise is used.
Explore proof 7 tactics
Initial goal
intros
destruct output_frame_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ H H0 H1 H2 H3 H4 as Ha & Hd & Hr & Hw
split ; exact Ha |
split ; exact Hd |
split ; exact Hr |
split ; exact Hw |
eapply S.output_returned ; eauto
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Close may consume its own heaps, but never program-owned identities. Endpoint readiness and retired authority come from the close prefix, including on EOF and resource stops.
Explore proof 11 tactics
Initial goal
intros rep requests wide r args p s m w trace ending s′ m′ w′ h Hcall Ha Hd Hr Hready & Hra & Hrel
destruct M.E.invoke_prefix_ _ _ _ _ _ _ _ _ _ _ _ _ Hcall as born & Hp
destruct M.E.prefix_preserve_ _ _ _ _ _ _ _ _ _ _ Hp Hr as Hr′ _
destruct LG.prefix_agrees_ _ _ _ _ _ _ _ _ _ _ h Hp Hr Hd Ha Hra Hrel as Ha′ & Hd′ & Hb & Hra′
destruct Hp as _ & p0 & info & final & Hxs & Hinfo & Hsettled & Hstate & Hready′ & Hframe & Hdelegate & Htrace & Hclosed & Haux
injection Hxs as ←
split ; exact Ha′ |
split ; exact Hd′ |
split ; exact Hr′ |
split ; exact Hready′ |
exact stream_delegates_apartlibc_world libc_stream_modelrep requests wide w p born m′ w′ h Hdelegate Hra′ Hrel Hb Hd′
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Both pure queries can lock/mutate private metadata; their actual effects, rather than an assumed unchanged memory, carry the frame.
Explore proof 3 tactics
Initial goal
intros rep requests wide spec r args p s m w trace ending s′ m′ w′ h Hspec Hcall Ha Hd Hr Hready & Hra & Hrel
destruct Hspec as → | →
2 openfocused goal
all: destruct M.E.invoke_prefix_ _ _ _ _ _ _ _ _ _ _ _ _ Hcall as born & Hp ; destruct M.E.prefix_preserve_ _ _ _ _ _ _ _ _ _ _ Hp Hr as Hr′ _ ; destruct LG.prefix_agrees_ _ _ _ _ _ _ _ _ _ _ h Hp Hr Hd Ha Hra ltac:intros base l v as Ha′ & Hd′ & Hb & Hra′ ; destruct Hp as _ & p0 & info & Hxs & Hinfo & Hopen & Hframe & Hdelegate & Htrace & Haux ; injection Hxs as ← ; split ; exact Ha' | ; split ; exact Hd' | ; split ; exact Hr' | ; split ; exact proj1Hopen | ; exact stream_delegates_apartlibc_world libc_stream_modelrep requests wide w p born m′ w′ h Hdelegate Hra' Hrel Hb Hd'
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.