rocq/theories/LibcErrnoLogic.v
Selected FILE calls with program-owned errno bytes. Private FILE storage remains separate; only the four scalar bytes are handed to close. Query frames restore those bytes without a ghost update.
Explore proof 4 tactics
Initial goal
intros
unfold errno_keys , errno_bytes
rewrite ! byte_ps_keys length_map length_seq
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Explore proof 22 tactics
Initial goal
intros m b o _ & _ & base & reg & Hcap & E & L & Haccess & _
injection Hcap as ←
destruct access_regionm b + o Objb b 4 Write 1 or_introleq_refl Haccess as reg0 & E0 & Hlo & Hhi
rewrite E in E0
injection E0 as ←
apply all_agree_intro
intros l v Hin
destruct byte_ps_elem_ _ _ _ _ Hin as i & x & Hxi & → & →
assert Hi : i < 4%nat
2 openfocused goal
{apply lookup_lt_Some in Hxi
2 opendeferred goal
unfold errno_bytes in Hxi
2 opendeferred goal
rewrite length_map length_seq in Hxi
2 opendeferred goal
exact Hxi
deferred goal
assert Hx : x = m_bytesm b + o + Z.of_nati
2 openfocused goal
{destruct i as | | | | i ; try lia ; injection Hxi as ← ; reflexivity
deferred goal
cbn [ agree_piece ]
split ; unfold registered ; congruence |
intros reg′ E′ _
rewrite E in E′
injection E′ as ←
split ; lia |
split ; lia | symmetry ; exact Hx
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Other byte/aux pieces must not alias the four handed-over bytes. In particular no errno aux slot is handed over. FILE roots and release identities remain private, even though errno is owned.
Explore proof 8 tactics
Initial goal
intros p b o m w h He Hr root a Hin Hspan Hown
unfold libc_stream_writes in Hin
destruct libc_file_atw p as file | eqn: Hfile ; | contradiction
apply in_app_or in Hin as [ Hin | [ <-| [ ] ] ]
2 openfocused goal
–exfalso
2 opendeferred goal
apply Hrroot a ; unfold libc_stream_aux_roots ; rewrite Hfile ; exact Hin | assumption | assumption
deferred goal
–rewrite He in Hspan
exact Hspan
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
An old registered object's live endpoint is its old region: an effects path cannot resurrect or replace the identity.
Explore proof 9 tactics
Initial goal
intros m m′ b reg Hp Hreg E L
unfold registered in Hreg
destruct object_regionb m_regionsm as old | eqn: E0 ; | contradiction
destruct Hpb old E0 as E′ | E′ ; rewrite E in E' ; injection E' as Hsame
2 openfocused goal
–subst old
2 opendeferred goal
split ; assumption
deferred goal
–apply f_equalr_life in Hsame
cbn [ freed_region r_life ] in Hsame
congruence
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
A ghost update may replace values of existing memory keys, but cannot introduce a new program-owned object identity.
Separation depends on memory keys, not their stored ghost values. This transports it across sampled errno and stream-name updates.
Explore proof 15 tactics
Initial goal
intros rep p b o m w h h′ Hr & He & Hroots & Hrelease & Hoff Hkeys
split ; exact Hr |
split ; exact He |
split ; | split
3 openfocused goal
focused goal
–intros root a Hin Hspan l & v & reg & Hl & Hmem & Hlive & Hrange
3 opendeferred goal
deferred goal
destruct Hkeysl v Hl Hmem as old Hold
3 opendeferred goal
deferred goal
apply Hrootsroot a Hin Hspan
3 opendeferred goal
deferred goal
exists l, old, reg
3 opendeferred goal
deferred goal
exact conjHold conjHmem conjHlive Hrange
2 opendeferred goal
deferred goal
–intros base l v Hin Hl Hmem
2 opendeferred goal
destruct Hkeysl v Hl Hmem as old Hold
2 opendeferred goal
exact Hreleasebase l old Hin Hold Hmem
deferred goal
–intros l v Hl Hnot
destruct l as base | base off | base off | key ; try exact I
2 openfocused goal
all: destruct Hkeys_ _ Hl I as old Hold ; exact Hoff_ old Hold Hnot
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Proof 50 steps Qed
The unselected FILE keeps its inventory. Its private frame transports through old-object persistence even when the selected FILE writes.
Explore proof 18 tactics
Initial goal
intros rep p b o m w m′ w′ h Hready & He & Hroots & Hrelease & Hoff Ha Hp Hready′ He′ Hroots′ Hrelease′
split ; exact Hready′ |
split ; congruence |
split ; | split
3 openfocused goal
focused goal
–rewrite Hroots′
3 opendeferred goal
deferred goal
intros root a Hin Hspan l & v & reg & Hl & Hmem & Hlive & Hrange
3 opendeferred goal
deferred goal
apply Hrootsroot a Hin Hspan
3 opendeferred goal
deferred goal
exists l, v, reg
3 opendeferred goal
deferred goal
split ; exact Hl |
3 opendeferred goal
deferred goal
split ; exact Hmem |
3 opendeferred goal
deferred goal
split ; | exact Hrange
3 opendeferred goal
deferred goal
eapply registered_live_back ; exact Hp | | exact Hlive
3 opendeferred goal
deferred goal
eapply agree_piece_registered ; exact Hmem | exact Hal v Hl
2 opendeferred goal
deferred goal
–rewrite Hrelease′
2 opendeferred goal
exact Hrelease
deferred goal
–intros l v Hl Hnot
destruct l as base | base off | base off | key ; try exact I
2 openfocused goal
all: intros reg Hlive Ho Hend Hout ; apply Hoff_ v Hl Hnot reg ; | exact Ho | exact Hend | exact Hout ; pose proof Ha_ v Hl as Hreg ; apply agree_piece_registered in Hreg ; | exact I ; eapply registered_live_back ; exact Hp | | exact Hlive ; exact Hreg
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Explore proof 2 tactics
Initial goal
intros ps
induction ps as | l v ps IH ; intros qs h ; simpl ; reflexivity | rewrite IH ; reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
This frame accepts owned errno, unlike the all-roots-apart frame. It applies to finite prefixes, not just successful close results.
Explore proof 12 tactics
Initial goal
intros rep p b o spec xs s m w born trace s′ m′ w′ h Hp Hw Hrelease Ha Hd Hr Hready & He & Hroots & Hrel & Hoff
destruct LG.prefix_agrees_out_ _ _ _ _ _ _ _ _ _ _ h errno_keysb o span_containserrno_spanb o Hp Hr Hd as Ha′ & Hids′ & Hd′ & Hb
6 openfocused goal
focused goal
focused goal
focused goal
focused goal
–intros l v Hl _
6 opendeferred goal
deferred goal
deferred goal
deferred goal
deferred goal
exact Hal v Hl
5 opendeferred goal
deferred goal
deferred goal
deferred goal
deferred goal
–intros l v Hl Hmem
5 opendeferred goal
deferred goal
deferred goal
deferred goal
eapply agree_piece_registered ; exact Hmem | exact Hal v Hl
4 opendeferred goal
deferred goal
deferred goal
deferred goal
–rewrite Hw
4 opendeferred goal
deferred goal
deferred goal
eapply errno_roots_out ; eauto
3 opendeferred goal
deferred goal
deferred goal
–exact Hoff
2 opendeferred goal
deferred goal
–destruct Hrelease as → | → ; intros base l v | exact Hrel
deferred goal
–destruct M.E.prefix_preserve_ _ _ _ _ _ _ _ _ _ _ Hp Hr as Hr′ Hpers
exact conjHa′ conjHids′ conjHd′ conjHb conjHr′ Hpers
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
The query's byte frame restores its original owned errno pieces. The rest of the heap was already preserved by the effects frame.
Explore proof 4 tactics
Initial goal
intros rep requests wide p b o spec r args s m w trace ending s′ m′ w′ h Hspec Hcall Ha Hd Hr Hwi
destruct M.E.invoke_prefix_ _ _ _ _ _ _ _ _ _ _ _ _ Hcall as born & Hp
destruct Hspec as → | →
2 openfocused goal
all: destruct errno_prefix_framerep p b o _ _ _ _ _ _ _ _ _ _ h Hp eq_refl or_introleq_refl Ha Hd Hr Hwi as Hexcept & Hids & Hd′ & Hb & Hr′ & Hpers ; split ; | auto ; destruct Hwi as Hready & He & Hroots & Hrel & Hoff ; destruct Hp as _ & p0 & info & Hxs & Hinfo & Hopen & Hframe & Hdelegate & Htrace & Haux & Hbytes ; injection Hxs as ← ; intros l v Hl ; destruct decidel ∈ errno_keysb o as Hkey | Hkey ; | exact Hexceptl v Hl Hkey ; unfold errno_keys in Hkey ; rewrite byte_ps_keys in Hkey ; apply list_elem_of_fmap in Hkey as i & → & Hi ; apply elem_of_seqZ in Hi ; pose proof Ha_ _ Hl as Hag ; destruct v ; cbn [ agree_piece ] in Hag |- * ; try contradiction ; destruct Hag as Hreg Hin ; split ; exact Hids_ _ Hl I | ; intros reg E L ; destruct registered_live_backm m′ b reg Hpers Hreg conjE L as E0 L0 ; destruct Hinreg E0 L0 as Ho & Hend & Hval ; split ; exact Ho | ; split ; exact Hend | ; assert Hobject : in_objectm b + i by exists b, reg ; split ; exact E0 | lia ; assert Hown : owned_liveh m b + i by exists PByteb i, VBytev, reg ; repeat split ; try assumption ; simpl ; lia ; assert Houtside : ¬write_authoritylibc_stream_aux_rootsw p [ ] m b + i by eapply owned_not_authority ; exact Hd | exact Hroots | intros base l0 v0 | exact Hown ; rewrite Hbytesb + i Hobject Houtside ; exact Hval
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Both queries re-establish the same owned-errno world interpretation, not merely the result shape or memory agreement.
Explore proof 8 tactics
Initial goal
intros rep requests wide p b o spec r args s m w trace ending s′ m′ w′ h Hspec Hcall Ha Hd Hr Hwi
destruct query_agreesrep requests wide p b o spec r args s m w trace ending s′ m′ w′ h Hspec Hcall Ha Hd Hr Hwi as Ha′ & Hd′ & Hr′
split ; exact Ha′ |
split ; exact Hd′ |
split ; exact Hr′ |
destruct M.E.invoke_prefix_ _ _ _ _ _ _ _ _ _ _ _ _ Hcall as born & Hp
destruct Hspec as → | →
2 openfocused goal
all: destruct errno_prefix_framerep p b o _ _ _ _ _ _ _ _ _ _ h Hp eq_refl or_introleq_refl Ha Hd Hr Hwi as _ & _ & _ & Hb & _ & Hpers ; destruct Hp as _ & p0 & info & Hxs & Hinfo & Hopen & Hframe & Hdelegate & _ ; injection Hxs as ← ; eapply errno_wi_endpoint ; exact Hwi | exact Ha | exact Hpers | exact Hd′ | exact proj1Hopen | exact proj1proj2proj2proj2Hframe | exact Hdelegate | exact Hb | ; intros l v Hl _ ; eauto
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Close can write owned errno while framing everything else. The bytes returned to the logic are read from the actual final memory; no errno value is guessed from EOF or from a host syscall.
Proof 43 steps Qed
The stream assertion may also change logical values at close. Its memory pieces must remain the same, and its keys must not overlap errno. The supplied replacement law is pure ghost bookkeeping, not an assumption about what the native call did to memory.
Proof 56 steps Qed
Nonvacuity through the actual HelloClose logic instance. This heap really owns errno, so the previous all-write-roots frame rejects it.
Explore proof 3 tactics
Initial goal
intros b reg Hreg
cbn [ conversion_mem m_regions object_region r_base ] in Hreg
repeat destruct _ =? _ eqn :? in Hreg ; try discriminate ; injection Hreg as ←;repeat match goal withH : _ =? _ = true |- _⇒apply Z.eqb_eq in Hend;subst;auto 10
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Explore proof 3 tactics
Initial goal
intros b1 r1 b2 r2 E1 L1 E2 L2 Hne
apply regions in E1 , E2
repeat destruct E1 as E1 | E1 ; destruct E1 as → → ; repeat destruct E2 as E2 | E2 ; destruct E2 as → → ; simpl in * ; lia
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Explore proof 10 tactics
Initial goal
split ; change 0 < 4294967296 ≤ 281474976710656 ; lia |
split
2 openfocused goal
–intros b reg E
2 opendeferred goal
apply regions in E
2 opendeferred goal
change 0 ≤ b < 4294967296 ∧ r_endreg ≤ 4294967296 ∧ r_lifereg = Freed → r_endreg = b
2 opendeferred goal
repeat destruct E as E | E ; destruct E as → → ; simpl ; intuition try discriminate ; lia
deferred goal
–intros a Ha
change 4294967296 ≤ a in Ha
cbn [ conversion_mem m_bytes m_aux ]
repeat match goal with|- context [a =? ]⇒destruct Z.eqb_speca b ; subst ; lia | end;auto
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Explore proof 6 tactics
Initial goal
intros l v Hl
apply elem_of_list_to_map_2 in Hl
eapply all_agree_elem ; | exact Hl
change all_agreeconversion_mem byte_ps5120 0 errno_bytesconversion_mem 5120 0
apply errno_bytes_agree
exact proj1proj2proj2F.readytrue
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Explore proof 12 tactics
Initial goal
split ; apply F.ready |
split ; reflexivity |
split ; intros root a |
split ; intros base l v |
intros l v Hl Hnot
apply elem_of_list_to_map_2 in Hl
exfalso
apply Hnot
change l ∈ byte_ps5120 0 0; 0; 0; 0.*1
apply list_elem_of_fmap
exists l, v
auto
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Explore proof 13 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 E.query_frameλ_ _ ⇒ True λ_ _ _ _ ⇒ False λ_ _ _ _ _ ⇒ False file_handleF.out_file 5120 0 _ _ _ _ _ _ _ _ _ _ _ heap or_introreq_refl Hcall heap_agrees as Ha & _ & _ & Hw
4 openfocused goal
focused goal
focused goal
–exact disjoint
3 opendeferred goal
deferred goal
deferred goal
–exact ready
2 opendeferred goal
deferred goal
–exact heap_wi
deferred goal
–auto
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Explore proof 19 tactics
Initial goal
intros _ & Hroots & _
apply HrootsmkSpanmkPtr5120 Obj5120 4 5123
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 PByte5120 3, VByte0, mkRegion5120 5128 Heap Live
split
2 openfocused goal
+unfold heap
2 opendeferred goal
apply elem_of_list_to_map_1
3 openfocused goal
deferred goal
∗change base.NoDupPByte5120 0; PByte5120 1; PByte5120 2; PByte5120 3
3 opendeferred goal
deferred goal
repeat apply base.NoDup_cons_2 ; set_solver |
3 opendeferred goal
deferred goal
apply base.NoDup_nil_2
2 opendeferred goal
deferred goal
∗apply list_elem_of_In
2 opendeferred goal
simpl
2 opendeferred goal
auto 10
deferred goal
+split ; exact I |
split ; split ; reflexivity | simpl ; lia
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.