rocq/theories/LibcStreamTokens.v
Callback stream tokens retain native handle lives but do not own private FILE bytes. The projection here is pure proof bookkeeping; it never deletes authoritative Iris resources.
Only designated life keys disappear. Byte and auxiliary pieces in either FILE object remain, so private-root separation still rejects caller ownership of FILE storage.
Explore proof 5 tactics
Initial goal
intros out_base err_base h l v Hl
unfold stream_data_heap in Hl
apply lookup_delete_Some in Hl as Hout Hl
apply lookup_delete_Some in Hl as Herr Hl
auto
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Explore proof 3 tactics
Initial goal
intros out_base err_base h l Hout Herr
unfold stream_data_heap
rewrite ! lookup_delete_ne ; congruence
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Explore proof 3 tactics
Initial goal
intros out_base err_base m h Ha l v Hl
apply stream_data_lookup in Hl as Hl _
exact Hal v Hl
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Restore exactly the removed lives, including their original region. Registration/persistence alone would also permit a freed handle.
Explore proof 15 tactics
Initial goal
intros out_base err_base m m′ h h′ Ha Hdata Hp Houtkey Herrkey Hout Herr l v Hl
destruct decidel = PLiveout_base as [ ->| Hneout ]
2 openfocused goal
–rewrite Houtkey in Hl
2 opendeferred goal
pose proof Ha_ _ Hl as Hag
2 opendeferred goal
destruct v ; cbn [ agree_piece ] in Hag |- * ; try contradiction ; apply Hout ; exact Hag |
2 opendeferred goal
unfold registered in *
2 opendeferred goal
destruct object_regionout_base m_regionsm as reg | eqn: E ; destruct Hp_ _ E as E′ | E′ ; rewrite E' ; discriminate | contradiction
deferred goal
–destruct decidel = PLiveerr_base as [ ->| Hneerr ]
2 openfocused goal
+rewrite Herrkey in Hl
2 opendeferred goal
pose proof Ha_ _ Hl as Hag
2 opendeferred goal
destruct v ; cbn [ agree_piece ] in Hag |- * ; try contradiction ; apply Herr ; exact Hag |
2 opendeferred goal
unfold registered in *
2 opendeferred goal
destruct object_regionerr_base m_regionsm as reg | eqn: E ; destruct Hp_ _ E as E′ | E′ ; rewrite E' ; discriminate | contradiction
deferred goal
+apply Hdata
rewrite stream_data_lookup_ne ; assumption
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Updating data/ghost values commutes with the pure life projection, but updating one of the two erased life keys does not.
Explore proof 9 tactics
Initial goal
induction ps as | l v ps IH ; intros out_base err_base h Hout Herr ; reflexivity |
cbn [ fmap fst ] in Hout , Herr
apply not_elem_of_cons in Hout as Hout Houts
apply not_elem_of_cons in Herr as Herr Herrs
cbn [ overwrite ]
unfold stream_data_heap at 1
rewrite ! delete_insert_ne ; try congruence
change <[l ≔ v]>stream_data_heapout_base err_base overwriteps h = <[l ≔ v]>overwriteps stream_data_heapout_base err_base h
rewrite IH ; auto
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Native readiness excludes BOTH stable FILE identities from every active release pool, not just the selected handle's identity.
Explore proof 13 tactics
Initial goal
intros rep m w p q base _ & _ & _ & _ & _ & _ & _ & _ & _ & _ & _ & _ & Hsep Hq Hcap Hin
unfold libc_stream_releases in Hin
destruct libc_file_atw p as file | eqn: Hfile ; | contradiction
destruct Hsepp file Hfile base Hin as _ & _ & Hnot & _
apply Hnot
right
left
exists mkSpanq 0
split
2 openfocused goal
–destruct Hq as → | → ; left ; reflexivity | right ; left ; reflexivity
deferred goal
–simpl
symmetry
exact Hcap
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
The existing effects frame proves stable handle life independently of byte-write roots. It may mutate locks inside the FILE object; only releasing that object's identity is excluded. Fresh allocation cannot turn the old handle into a born identity.
Explore proof 26 tactics
Initial goal
intros world spec xs s m w born trace s′ m′ w′ b reg Hp Hr Hd Hlive Hrelease
assert Ha : agreesm singletonMPLiveb VLivereg : gmappiece pval
2 openagrees m {[PLive b := VLive reg]}focused goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval){intros l v Hl
2 openHl : {[PLive b := VLive reg]} !! l = Some vdeferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)apply lookup_singleton_Some in Hl as Hl Hv
2 opendeferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)subst l v
2 opendeferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)exact Hlive
deferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)destruct LG.prefix_agrees_out_ _ _ _ _ _ _ _ _ _ _ singletonMPLiveb VLivereg : gmappiece pval [ ] λ_ ⇒ True Hp Hr Hd as Hafter & _
6 openHa : agrees m ({[PLive b := VLive reg]} : gmap piece pval)agrees_except [] m {[PLive b := VLive reg]}focused goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)LG.ids_registered {[PLive b := VLive reg]} mfocused goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)roots_out (contract_writes spec xs m w) {[PLive b := VLive reg]} m
(λ _ : Z, True)focused goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)pieces_off [] {[PLive b := VLive reg]} m (λ _ : Z, True)focused goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)ids_apart (contract_releases spec xs m w) {[PLive b := VLive reg]}focused goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)Hafter : agrees_except [] m' {[PLive b := VLive reg]}–intros l v Hl _
6 openHa : agrees m ({[PLive b := VLive reg]} : gmap piece pval)Hl : {[PLive b := VLive reg]} !! l = Some vdeferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)LG.ids_registered {[PLive b := VLive reg]} mdeferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)roots_out (contract_writes spec xs m w) {[PLive b := VLive reg]} m
(λ _ : Z, True)deferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)pieces_off [] {[PLive b := VLive reg]} m (λ _ : Z, True)deferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)ids_apart (contract_releases spec xs m w) {[PLive b := VLive reg]}deferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)Hafter : agrees_except [] m' {[PLive b := VLive reg]}exact Hal v Hl
5 opendeferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)LG.ids_registered {[PLive b := VLive reg]} mdeferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)roots_out (contract_writes spec xs m w) {[PLive b := VLive reg]} m
(λ _ : Z, True)deferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)pieces_off [] {[PLive b := VLive reg]} m (λ _ : Z, True)deferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)ids_apart (contract_releases spec xs m w) {[PLive b := VLive reg]}deferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)Hafter : agrees_except [] m' {[PLive b := VLive reg]}–intros l v Hl Hmem
5 openHa : agrees m ({[PLive b := VLive reg]} : gmap piece pval)Hl : {[PLive b := VLive reg]} !! l = Some vdeferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)roots_out (contract_writes spec xs m w) {[PLive b := VLive reg]} m
(λ _ : Z, True)deferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)pieces_off [] {[PLive b := VLive reg]} m (λ _ : Z, True)deferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)ids_apart (contract_releases spec xs m w) {[PLive b := VLive reg]}deferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)Hafter : agrees_except [] m' {[PLive b := VLive reg]}eapply agree_piece_registered ; exact Hmem | exact Hal v Hl
4 opendeferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)roots_out (contract_writes spec xs m w) {[PLive b := VLive reg]} m
(λ _ : Z, True)deferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)pieces_off [] {[PLive b := VLive reg]} m (λ _ : Z, True)deferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)ids_apart (contract_releases spec xs m w) {[PLive b := VLive reg]}deferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)Hafter : agrees_except [] m' {[PLive b := VLive reg]}–intros root a Hin Hspan Howned
4 openHa : agrees m ({[PLive b := VLive reg]} : gmap piece pval)Howned : owned_live {[PLive b := VLive reg]} m adeferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)pieces_off [] {[PLive b := VLive reg]} m (λ _ : Z, True)deferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)ids_apart (contract_releases spec xs m w) {[PLive b := VLive reg]}deferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)Hafter : agrees_except [] m' {[PLive b := VLive reg]}exact I
3 opendeferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)pieces_off [] {[PLive b := VLive reg]} m (λ _ : Z, True)deferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)ids_apart (contract_releases spec xs m w) {[PLive b := VLive reg]}deferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)Hafter : agrees_except [] m' {[PLive b := VLive reg]}–intros l v Hl _
3 openHa : agrees m ({[PLive b := VLive reg]} : gmap piece pval)Hl : {[PLive b := VLive reg]} !! l = Some vdeferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)ids_apart (contract_releases spec xs m w) {[PLive b := VLive reg]}deferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)Hafter : agrees_except [] m' {[PLive b := VLive reg]}apply lookup_singleton_Some in Hl as Hl Hv
3 openHa : agrees m ({[PLive b := VLive reg]} : gmap piece pval)deferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)ids_apart (contract_releases spec xs m w) {[PLive b := VLive reg]}deferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)Hafter : agrees_except [] m' {[PLive b := VLive reg]}subst l v
3 openHa : agrees m ({[PLive b := VLive reg]} : gmap piece pval)deferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)ids_apart (contract_releases spec xs m w) {[PLive b := VLive reg]}deferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)Hafter : agrees_except [] m' {[PLive b := VLive reg]}exact I
2 opendeferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)ids_apart (contract_releases spec xs m w) {[PLive b := VLive reg]}deferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)Hafter : agrees_except [] m' {[PLive b := VLive reg]}–intros base l v Hin Hl Hmem
2 openHa : agrees m ({[PLive b := VLive reg]} : gmap piece pval)Hl : {[PLive b := VLive reg]} !! l = Some vdeferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)Hafter : agrees_except [] m' {[PLive b := VLive reg]}apply lookup_singleton_Some in Hl as Hl Hv
2 openHa : agrees m ({[PLive b := VLive reg]} : gmap piece pval)deferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)Hafter : agrees_except [] m' {[PLive b := VLive reg]}subst l v
2 openHa : agrees m ({[PLive b := VLive reg]} : gmap piece pval)deferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)Hafter : agrees_except [] m' {[PLive b := VLive reg]}simpl
2 openHa : agrees m ({[PLive b := VLive reg]} : gmap piece pval)deferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)Hafter : agrees_except [] m' {[PLive b := VLive reg]}intros →
2 openHa : agrees m {[PLive base := VLive reg]}deferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)Hafter : agrees_except [] m' {[PLive b := VLive reg]}contradiction
deferred goal
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)Hafter : agrees_except [] m' {[PLive b := VLive reg]}–apply HafterPLiveb VLivereg ; apply lookup_singleton_Some ; auto |
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)Hafter : agrees_except [] m' {[PLive b := VLive reg]}intros Hnil
Ha : agrees m ({[PLive b := VLive reg]} : gmap piece pval)Hafter : agrees_except [] m' {[PLive b := VLive reg]}inversion Hnil
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
A query may write private locks inside either stable handle. The data frame deliberately omits only their life keys, then the no-release effects frame restores those exact original regions.
Explore proof 11 tactics
Initial goal
intros rep requests wide out_base err_base p b o spec r args s m w trace ending s′ m′ w′ h Hspec Hcall Ha Hd Hr Hwi
pose proof stream_data_agreesout_base err_base m h Ha as Hdata
destruct EL.query_framerep requests wide p b o spec r args s m w trace ending s′ m′ w′ stream_data_heapout_base err_base h Hspec Hcall Hdata Hd Hr Hwi as Hdata′ & Hd′ & Hr′ & Hwi′
destruct M.E.invoke_prefix_ _ _ _ _ _ _ _ _ _ _ _ _ Hcall as born & Hp
destruct M.E.prefix_preserve_ _ _ _ _ _ _ _ _ _ _ Hp Hr as _ Hpers
assert Hrelease : ∀base, ¬Inbase contract_releasesspec WPtrp m w
2 openfocused goal
{intros base
2 opendeferred goal
destruct Hspec as → | → ; cbn [ ferror_contract fpending_contract contract_releases ] ; tauto
deferred goal
split ; | auto
eapply stream_data_restore ; exact Ha | exact Hdata′ | exact Hpers | reflexivity | reflexivity | |
2 openfocused goal
all: intros reg Hlive ; eapply prefix_handle_live ; eauto
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Close updates actual endpoint errno bytes and retains both native handle lives, including on a resource-ending prefix. This theorem deliberately makes no closed-token claim on that prefix.
Proof 40 steps Qed
Logical controls use HelloClose's actual machine. The tiny fixture objects are not claimed to be native FILE representations.
Explore proof 12 tactics
Initial goal
assert Hnone : ∀base, E.heap !! PLivebase = None
2 openfocused goal
{intros base
2 opendeferred goal
apply eq_None_not_Some
2 opendeferred goal
intros v Hl
2 opendeferred goal
unfold E.heap in Hl
2 opendeferred goal
apply elem_of_list_to_map_2 in Hl
2 opendeferred goal
destruct MemLogic.byte_ps_elem_ _ _ _ _ Hl as i & x & Hi & He & Hv
2 opendeferred goal
discriminate He
deferred goal
unfold stream_data_heap , heap
rewrite delete_insert_ne ; | discriminate
rewrite ! delete_insert_eq
rewrite ! delete_id ; auto
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Explore proof 5 tactics
Initial goal
intros l v Hl
unfold heap in Hl
apply lookup_insert_Some in Hl as He Hv | Hne Hl ; subst l v ; split ; reflexivity |
apply lookup_insert_Some in Hl as He Hv | Hne′ Hl ; subst l v ; split ; reflexivity |
exact E.heap_agreesl v Hl
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Owned errno plus BOTH stable native lives coexist with the query frame; this is not an empty ghost heap or a sibling logic.
Explore proof 12 tactics
Initial goal
assert Hcall : LG.L.M.E.invokefpending_contractF.model CVoid ArgP Const0 WPtrfile_handleF.out_file InterpRuntime.start conversion_mem F.worldtrue [ ] CallReturnWInt7 InterpRuntime.start conversion_mem F.worldtrue
2 openfocused goal
{apply C.fpending_unchanged with file := F.out_file
4 openfocused goal
focused goal
deferred goal
–split ; left ; reflexivity |
4 opendeferred goal
deferred goal
deferred goal
exists Const0
4 opendeferred goal
deferred goal
deferred goal
reflexivity
3 opendeferred goal
deferred goal
deferred goal
–apply F.ready
2 opendeferred goal
deferred goal
–reflexivity
deferred goal
split ; exact Hcall |
destruct T.query_frameλ_ _ ⇒ True λ_ _ _ _ ⇒ False λ_ _ _ _ _ ⇒ False 1024 2048 file_handleF.out_file 5120 0 _ _ _ _ _ _ _ _ _ _ _ heap or_introreq_refl Hcall heap_agrees E.disjoint E.ready as Ha & _ & _ & Hw
2 openfocused goal
–rewrite data_heap
2 opendeferred goal
exact E.heap_wi
deferred goal
–auto
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Erasing a life is not erasing caller ownership of the FILE's bytes or auxiliary slots. Either kind still excludes a private root.
Explore proof 13 tactics
Initial goal
intros m h v Hl Hlive Hr
apply HrmkSpanmkPtr1024 Obj1024 1 1024
3 openfocused goal
focused goal
–left
3 opendeferred goal
deferred goal
reflexivity
2 opendeferred goal
deferred goal
–unfold span_contains
2 opendeferred goal
simpl
2 opendeferred goal
lia
deferred goal
–exists PByte1024 0, v, mkRegion1024 1056 GlobalData Live
split ; rewrite stream_data_lookup_ne ; congruence |
split ; exact I |
split ; exact Hlive |
simpl
lia
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Explore proof 13 tactics
Initial goal
intros m h v Hl Hlive Hr
apply HrmkSpanmkPtr1024 Obj1024 1 1024
3 openfocused goal
focused goal
–left
3 opendeferred goal
deferred goal
reflexivity
2 opendeferred goal
deferred goal
–unfold span_contains
2 opendeferred goal
simpl
2 opendeferred goal
lia
deferred goal
–exists PAux1024 0, v, mkRegion1024 1056 GlobalData Live
split ; rewrite stream_data_lookup_ne ; congruence |
split ; exact I |
split ; exact Hlive |
simpl
lia
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.