Fil-C on Nix

Filnix wiki

the formal campaign

rocq/theories/LibcStreams.v

Composite stdout/stderr contracts. FILE metadata and physical counts live in libc_streams; stdout's only logical protocol lives in shutdown_stdout. Native representation and exclusive ownership remain trusted premises, not consequences of writable addresses. Closed handles retain identity and protocol, but grant no authority.

From Stdlib Require Import String ZArith List Bool Lia
From Nanofil Require Import Term Syntax Values Memory Runtime ExternalCalls ExternalMachine Locale Stdio Shutdown Streams Formatting Libc
Import ListNotations
Open Scope Z_scope
Open Scope list_scope

Exact handle comparison includes capability, not merely address.

14Definition same_filep q : ptr : bool ≔

Stdout's stable represented handle.

18Definition libc_stdoutw : libc_world : ptr ≔

Stderr's stable represented handle.

21Definition libc_stderrw : libc_world : ptr ≔

Selection is capability-sensitive even for a consumed handle.

25Definition libc_file_atw : libc_world p : ptr : optionlibc_file ≔

Lookup survives consumption and never restores a saved stdout FIFO.

Only active handles expose physical counts and ordinary stream calls.

39Definition libc_stream_atw : libc_world p : ptr : optionstream_info ≔
match libc_file_atw p with
None
⇒
None

These sources belong to FILE state, not to a caller's format strings. A zero-length handle span supplies its capability, not extra bytes.

48Definition file_sourcesfile : libc_file : listspan ≔

Errno's fixed capability supports its scalar write root in generic delegation. It grants no readable aux slot and is excluded from the private FILE pools by file_errno_apart.

54Definition libc_stream_sourcesw : libc_world p : ptr : listspan ≔
match libc_file_atw p with
Somefile
⇒
None
⇒
[ ]

Active roots only; closing retires historical buffer authority.

61Definition libc_stream_writesw : libc_world p : ptr : listspan ≔
match libc_file_atw p with
Somefile
⇒
None
⇒
[ ]

Only FILE-private spans may change pointer aux; the extra scalar errno root in libc_stream_writes may not do so.

69Definition libc_stream_aux_rootsw : libc_world p : ptr : listspan ≔
match libc_file_atw p with
Somefile
⇒
None
⇒
[ ]

Exclusive heaps are not inferred from the handle or its roots.

73Definition libc_stream_releasesw : libc_world p : ptr : listZ ≔
match libc_file_atw p with
Somefile
⇒
None
⇒
[ ]

Errno is a fixed scalar output, not FILE-private retained authority. Entry and endpoint representations independently establish this, including complete aux-loaded capabilities in private sources.

79Definition file_errno_apartm : mem cell : ptr file : libc_file : Prop ≔
∀root, Inroot file_rootsfile → spans_apartroot mkSpancell 4 ∧ ∀base, ptr_capcell = Objbase ∨ ptr_capcell = Robase → ¬Inbase file_ownedfile ∧ ¬available_capfile_sourcesfile [ ] m Objbase ∧ ¬available_capfile_sourcesfile [ ] m Robase

Structural obligations for an ACTIVE FILE. The supplied native representation additionally owns close rights and excludes caller setvbuf storage and static FILE identities from file_owned.

89Definition libc_file_readym : mem cell : ptr file : libc_file : Prop ≔
ptr_addrfile_handlefile ≠ 0 ∧ readable_bytesm file_handlefile 1 ∧ 0 ≤ file_pendingfile < 2 ^ 64 ∧ Forallwritable_spanm file_rootsfile ∧ Forallλsource ⇒ readable_bytesm span_ptrsource span_sizesource file_readsfile ∧ Foralllocale_heapm file_ownedfile ∧ file_errno_apartm cell file

Legacy puts roots are the same active stdout inventory, not a second grant. Historical roots in closed FILE records are deliberately omitted.

98Definition libc_active_rootsw : libc_world : listspan ≔

A selected close cannot release either stable FILE, locale storage, or authority retained by the other active FILE. Exclusive ownership against caller storage still belongs to the native representation.

106Definition libc_release_separatedm : mem w : libc_world : Prop ≔
∀p file, libc_file_atw p = Somefile → ∀base, Inbase file_ownedfile → ¬Inbase locale_ownedlibc_localefstw ∧ ∀q other, libc_file_atw q = Someother → file_handleother ≠ file_handlefile → ¬Inbase file_ownedother ∧ ¬available_capmkSpanlibc_stdoutw 0 :: mkSpanlibc_stderrw 0 :: locale_private_sourceslibc_localefstw ++ if same_filep libc_stdoutw then match libc_file_atw libc_stderrw with Someother ⇒ file_sourcesother | None ⇒ [ ] end else match libc_file_atw libc_stdoutw with Someother ⇒ file_sourcesother | None ⇒ [ ] end [ ] m Objbase ∧ ¬available_capmkSpanlibc_stdoutw 0 :: mkSpanlibc_stderrw 0 :: locale_private_sourceslibc_localefstw ++ if same_filep libc_stdoutw then match libc_file_atw libc_stderrw with Someother ⇒ file_sourcesother | None ⇒ [ ] end else match libc_file_atw libc_stdoutw with Someother ⇒ file_sourcesother | None ⇒ [ ] end [ ] m Robase

Endpoint readiness permits either FILE closed. It keeps locale/errno and shutdown structure coherent; it does not establish native representation, exclusive ownership or progress.

130Definition libc_stream_readyrep : mem → libc_world → Prop m w : Prop ≔

Stream calls preserve current locale, errno identity and lifecycle inventory. Only the selected FILE's state may change. Shared native metadata still needs the independent memory frame, not disjoint locks.

Concrete projections, with only native allocation policy and wide settlement remaining realization parameters. Wide conversion needs its own effects/representation witness even if settlement succeeds.

169Definition libc_stream_modelrep requests wide : stream_modellibc_world ≔

Reached ordinary entries. The fallback composes with the remaining libc registry; it cannot override these six actual plain symbols.

177Definition libc_stream_registryrep requests wide fallback : name → optioncontractlibc_world symbol : name : optioncontractlibc_world ≔
let model ≔ libc_stream_modelrep requests wide in
name_eqbsymbol TAtom"ferror"
→
name_eqbsymbol TAtom"__fpending"
→
name_eqbsymbol TAtom"fclose"
→
name_eqbsymbol TAtom"printf"
→
name_eqbsymbol TAtom"fprintf"
→
name_eqbsymbol TAtom"fputs"
→
else
fallbacksymbol

Lookup laws are definitional, independent of the fallback registry.

188Lemma libc_stream_registry_entries
∀ rep requests wide fallback
let model ≔ libc_stream_modelrep requests wide in
let registry ≔ libc_stream_registryrep requests wide fallback in
registryTAtom"ferror" = Someferror_contractmodel ∧ registryTAtom"__fpending" = Somefpending_contractmodel ∧ registryTAtom"fclose" = Somefclose_contractmodel ∧ registryTAtom"printf" = Someprintf_contractmodel libc_stdout ∧ registryTAtom"fprintf" = Somefprintf_contractmodel ∧ registryTAtom"fputs" = Somefputs_contractmodel
Explore proof 2 tactics

Initial goal

⊢
∀ rep : mem → libc_world → Prop requests : libc_world → ptr → Z → Z → Prop wide : libc_world → ptr → stream_state → stream_state → bool → Prop fallback : name → optioncontractlibc_world  ,
let model ≔ libc_stream_modelrep requests wide in
let registry ≔ libc_stream_registryrep requests wide fallback in
registryTAtom"ferror" = Someferror_contractmodel ∧ registryTAtom"__fpending" = Somefpending_contractmodel ∧ registryTAtom"fclose" = Somefclose_contractmodel ∧ registryTAtom"printf" = Someprintf_contractmodel libc_stdout ∧ registryTAtom"fprintf" = Somefprintf_contractmodel ∧ registryTAtom"fputs" = Somefputs_contractmodel

intros

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
fallback :
model :=
registry :=
libc_stream_registryrep requests wide fallback : name → optioncontractlibc_world
⊢
registryTAtom"ferror" = Someferror_contractmodel ∧ registryTAtom"__fpending" = Somefpending_contractmodel ∧ registryTAtom"fclose" = Somefclose_contractmodel ∧ registryTAtom"printf" = Someprintf_contractmodel libc_stdout ∧ registryTAtom"fprintf" = Somefprintf_contractmodel ∧ registryTAtom"fputs" = Somefputs_contractmodel

repeat split ; reflexivity

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros
repeat split ; reflexivity

Exact comparison accepts a retained handle with its own capability.

200Lemma same_file_refl
∀ p
same_filep p = true
Explore proof 5 tactics

Initial goal

⊢
∀p : ptr, same_filep p = true

intros a c

a :
Z
c :
⊢
same_fileptr_addr ≔ a; ptr_cap ≔ c ptr_addr ≔ a; ptr_cap ≔ c = true

unfold same_file

a :
Z
c :
⊢
ptr_addrptr_addr ≔ a; ptr_cap ≔ c =? ptr_addrptr_addr ≔ a; ptr_cap ≔ c && cap_eqbptr_capptr_addr ≔ a; ptr_cap ≔ c ptr_capptr_addr ≔ a; ptr_cap ≔ c = true

simpl

a :
Z
c :
⊢
a =? a && cap_eqbc c = true

rewrite Z.eqb_refl

a :
Z
c :
⊢
true && cap_eqbc c = true

destruct c ; simpl ; try apply Z.eqb_refl ; try apply term_eqb_refl ; reflexivity

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros a c
unfold same_file
simpl
rewrite Z.eqb_refl
destruct c ; simpl ; try apply Z.eqb_refl ; try apply term_eqb_refl ; reflexivity

Stdout always projects the authoritative shutdown protocol, closed or open; there is no pre-close snapshot to restore.

208Lemma libc_stdout_protocol
Explore proof 4 tactics
Source script
intros
reflexivity

A forged capability at the very same address is not the FILE.

213Lemma libc_file_forged
Explore proof 4 tactics

Initial goal

⊢
∀w : libc_world a : Z, same_fileptr_addr ≔ a; ptr_cap ≔ CNone libc_stdoutw = false → same_fileptr_addr ≔ a; ptr_cap ≔ CNone libc_stderrw = false → libc_stream_atw ptr_addr ≔ a; ptr_cap ≔ CNone = None

intros w a Ho He

a :
Z
Ho :
He :
⊢
libc_stream_atw ptr_addr ≔ a; ptr_cap ≔ CNone = None

unfold libc_stream_at , libc_file_at

a :
Z
Ho :
He :
⊢
match if same_fileptr_addr ≔ a; ptr_cap ≔ CNone libc_stdoutw then if stdout_usablelibc_stdiofstw then Somelibc_stdout_filelibc_streamsfstw else None else if same_fileptr_addr ≔ a; ptr_cap ≔ CNone libc_stderrw then if libc_stderr_openlibc_streamsfstw then Somelibc_stderr_filelibc_streamsfstw else None else None with
Somefile
⇒
None
⇒
None
=
None

rewrite Ho , He

a :
Z
Ho :
He :
⊢
None = None

reflexivity

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros w a Ho He
rewrite Ho , He
reflexivity

An active selected FILE has the structural representation obligations of its own inventory entry, not those of a sibling handle.

221Lemma libc_file_at_ready
∀ rep m w p file
libc_file_atw p = Somefile
Explore proof 3 tactics

Initial goal

⊢
∀rep : mem → libc_world → Prop m : mem w : libc_world p : ptr file : libc_file, libc_stream_readyrep m w → libc_file_atw p = Somefile → libc_file_readym libc_errnofstw file

intros rep m w p file _ & _ & _ & _ & _ & _ & _ & _ & _ & _ & Hro & Hre & _ Hfile

unfold libc_file_at in Hfile

destruct same_filep libc_stdoutw ; destruct stdout_usablelibc_stdiofstw eqn: Ho | destruct same_filep libc_stderrw ; destruct libc_stderr_openlibc_streamsfstw eqn: He | ; try discriminate ; injection Hfile as ← ; auto

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros rep m w p file _ & _ & _ & _ & _ & _ & _ & _ & _ & _ & Hro & Hre & _ Hfile
unfold libc_file_at in Hfile
destruct same_filep libc_stdoutw ; destruct stdout_usablelibc_stdiofstw eqn: Ho | destruct same_filep libc_stderrw ; destruct libc_stderr_openlibc_streamsfstw eqn: He | ; try discriminate ; injection Hfile as ← ; auto

Admission follows from represented endpoint structure and an active exact handle; no output success or chosen query result is assumed.

236Lemma libc_stream_open
∀ rep requests wide m w p file
libc_file_atw p = Somefile
∃info, stream_openlibc_stream_modelrep requests wide m w p info
Explore proof 23 tactics

Initial goal

⊢
∀rep : mem → libc_world → Prop requests : libc_world → ptr → Z → Z → Prop wide : libc_world → ptr → stream_state → stream_state → bool → Prop m : mem w : libc_world p : ptr file : libc_file, libc_stream_readyrep m w → libc_file_atw p = Somefile → ∃info : stream_info, stream_openlibc_stream_modelrep requests wide m w p info

intros rep requests wide m w p file Hready Hfile

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
Hready :
Hfile :
libc_file_atw p = Somefile
⊢
∃info : stream_info, stream_openlibc_stream_modelrep requests wide m w p info

pose proof Hready as _ & _ & Herrno & Hout & Herr & _ & _ & _ & _ & _ & Hro & Hre & _

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
Hready :
Hfile :
libc_file_atw p = Somefile
Herrno :
⊢
∃info : stream_info, stream_openlibc_stream_modelrep requests wide m w p info

pose proof libc_file_at_readyrep m w p file Hready Hfile as Hfile_ready

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
Hready :
Hfile :
libc_file_atw p = Somefile
Herrno :
Hfile_ready :
⊢
∃info : stream_info, stream_openlibc_stream_modelrep requests wide m w p info

destruct Hfile_ready as _ & _ & Hpending & Hroots & _

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
Hready :
Hfile :
libc_file_atw p = Somefile
Herrno :
Hpending :
0 ≤ file_pendingfile < 2 ^ 64
Hroots :
⊢
∃info : stream_info, stream_openlibc_stream_modelrep requests wide m w p info

exists mkStreamInfoif same_filep libc_stdoutw then 1 else 2 libc_stream_statew p file_pendingfile

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
Hready :
Hfile :
libc_file_atw p = Somefile
Herrno :
Hpending :
0 ≤ file_pendingfile < 2 ^ 64
Hroots :

split ; exact Hready |

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
Hready :
Hfile :
libc_file_atw p = Somefile
Herrno :
Hpending :
0 ≤ file_pendingfile < 2 ^ 64
Hroots :

split

2 open

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
Hready :
Hfile :
libc_file_atw p = Somefile
Herrno :
Hpending :
0 ≤ file_pendingfile < 2 ^ 64
Hroots :
⊢
focused goal
rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
Hready :
Hfile :
libc_file_atw p = Somefile
Herrno :
Hpending :
0 ≤ file_pendingfile < 2 ^ 64
Hroots :

–unfold stream_at , libc_stream_model , libc_stream_at

2 open

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
Hready :
Hfile :
libc_file_atw p = Somefile
Herrno :
Hpending :
0 ≤ file_pendingfile < 2 ^ 64
Hroots :
⊢
match libc_file_atw p with
Somefile0
⇒
None
⇒
None
=
deferred goal
rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
Hready :
Hfile :
libc_file_atw p = Somefile
Herrno :
Hpending :
0 ≤ file_pendingfile < 2 ^ 64
Hroots :

rewrite Hfile

2 open

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
Hready :
Hfile :
libc_file_atw p = Somefile
Herrno :
Hpending :
0 ≤ file_pendingfile < 2 ^ 64
Hroots :
deferred goal
rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
Hready :
Hfile :
libc_file_atw p = Somefile
Herrno :
Hpending :
0 ≤ file_pendingfile < 2 ^ 64
Hroots :

reflexivity

deferred goal
rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
Hready :
Hfile :
libc_file_atw p = Somefile
Herrno :
Hpending :
0 ≤ file_pendingfile < 2 ^ 64
Hroots :

–split ; reflexivity |

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
Hready :
Hfile :
libc_file_atw p = Somefile
Herrno :
Hpending :
0 ≤ file_pendingfile < 2 ^ 64
Hroots :

split

2 open

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
Hready :
Hfile :
libc_file_atw p = Somefile
Herrno :
Hpending :
0 ≤ file_pendingfile < 2 ^ 64
Hroots :
focused goal
rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
Hready :
Hfile :
libc_file_atw p = Somefile
Herrno :
Hpending :
0 ≤ file_pendingfile < 2 ^ 64
Hroots :
⊢
Forallwritable_spanm stream_writeslibc_stream_modelrep requests wide w p

+split ; | exact Hpending

2 open

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
Hready :
Hfile :
libc_file_atw p = Somefile
Herrno :
Hpending :
0 ≤ file_pendingfile < 2 ^ 64
Hroots :
deferred goal
rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
Hready :
Hfile :
libc_file_atw p = Somefile
Herrno :
Hpending :
0 ≤ file_pendingfile < 2 ^ 64
Hroots :
⊢
Forallwritable_spanm stream_writeslibc_stream_modelrep requests wide w p

unfold libc_stream_state

2 open

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
Hready :
Hfile :
libc_file_atw p = Somefile
Herrno :
Hpending :
0 ≤ file_pendingfile < 2 ^ 64
Hroots :
deferred goal
rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
Hready :
Hfile :
libc_file_atw p = Somefile
Herrno :
Hpending :
0 ≤ file_pendingfile < 2 ^ 64
Hroots :
⊢
Forallwritable_spanm stream_writeslibc_stream_modelrep requests wide w p

destruct same_filep libc_stdoutw ; exact Hout |

2 open

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
Hready :
Hfile :
libc_file_atw p = Somefile
Herrno :
Hpending :
0 ≤ file_pendingfile < 2 ^ 64
Hroots :
deferred goal
rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
Hready :
Hfile :
libc_file_atw p = Somefile
Herrno :
Hpending :
0 ≤ file_pendingfile < 2 ^ 64
Hroots :
⊢
Forallwritable_spanm stream_writeslibc_stream_modelrep requests wide w p

destruct same_filep libc_stderrw eqn: He ; exact Herr |

2 open

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
Hready :
Hfile :
libc_file_atw p = Somefile
Herrno :
Hpending :
0 ≤ file_pendingfile < 2 ^ 64
Hroots :
He :
deferred goal
rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
Hready :
Hfile :
libc_file_atw p = Somefile
Herrno :
Hpending :
0 ≤ file_pendingfile < 2 ^ 64
Hroots :
⊢
Forallwritable_spanm stream_writeslibc_stream_modelrep requests wide w p

apply stdout_initial_wf

deferred goal
rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
Hready :
Hfile :
libc_file_atw p = Somefile
Herrno :
Hpending :
0 ≤ file_pendingfile < 2 ^ 64
Hroots :
⊢
Forallwritable_spanm stream_writeslibc_stream_modelrep requests wide w p

+change Forallwritable_spanm libc_stream_writesw p

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
Hready :
Hfile :
libc_file_atw p = Somefile
Herrno :
Hpending :
0 ≤ file_pendingfile < 2 ^ 64
Hroots :

unfold libc_stream_writes

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
Hready :
Hfile :
libc_file_atw p = Somefile
Herrno :
Hpending :
0 ≤ file_pendingfile < 2 ^ 64
Hroots :
⊢
match libc_file_atw p with
Somefile0
⇒
file_rootsfile0 ++ span_ptr ≔ libc_errnofstw; span_size ≔ 4
None
⇒
[ ]

rewrite Hfile

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
Hready :
Hfile :
libc_file_atw p = Somefile
Herrno :
Hpending :
0 ≤ file_pendingfile < 2 ^ 64
Hroots :
⊢
Forallwritable_spanm file_rootsfile ++ span_ptr ≔ libc_errnofstw; span_size ≔ 4

apply Forall_app

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
Hready :
Hfile :
libc_file_atw p = Somefile
Herrno :
Hpending :
0 ≤ file_pendingfile < 2 ^ 64
Hroots :
⊢
Forallwritable_spanm file_rootsfile ∧ Forallwritable_spanm span_ptr ≔ libc_errnofstw; span_size ≔ 4

split ; exact Hroots |

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
Hready :
Hfile :
libc_file_atw p = Somefile
Herrno :
Hpending :
0 ≤ file_pendingfile < 2 ^ 64
Hroots :
⊢
Forallwritable_spanm span_ptr ≔ libc_errnofstw; span_size ≔ 4

constructor ; exact proj1proj2Herrno | constructor

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros rep requests wide m w p file Hready Hfile
pose proof Hready as _ & _ & Herrno & Hout & Herr & _ & _ & _ & _ & _ & Hro & Hre & _
pose proof libc_file_at_readyrep m w p file Hready Hfile as Hfile_ready
destruct Hfile_ready as _ & _ & Hpending & Hroots & _
split ; exact Hready |
split
rewrite Hfile
reflexivity
–split ; reflexivity |
split
+split ; | exact Hpending
destruct same_filep libc_stdoutw ; exact Hout |
destruct same_filep libc_stderrw eqn: He ; exact Herr |
rewrite Hfile
apply Forall_app
split ; exact Hroots |
constructor ; exact proj1proj2Herrno | constructor

Query/close admission is shared and independent of their outcomes.

259Lemma libc_stream_admitted
∀ rep requests wide m w p file
libc_file_atw p = Somefile
Explore proof 4 tactics

Initial goal

⊢
∀rep : mem → libc_world → Prop requests : libc_world → ptr → Z → Z → Prop wide : libc_world → ptr → stream_state → stream_state → bool → Prop m : mem w : libc_world p : ptr file : libc_file, libc_stream_readyrep m w → libc_file_atw p = Somefile → stream_call_prelibc_stream_modelrep requests wide WPtrp m w

intros

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
H0 :
libc_file_atw p = Somefile
⊢

destruct libc_stream_openrep requests wide m w p file H H0 as info Ho

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
H0 :
libc_file_atw p = Somefile
Ho :
stream_openlibc_stream_modelrep requests wide m w p info
⊢

exists p, info

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
H0 :
libc_file_atw p = Somefile
Ho :
stream_openlibc_stream_modelrep requests wide m w p info
⊢
WPtrp = WPtrp ∧ stream_openlibc_stream_modelrep requests wide m w p info

auto

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros
destruct libc_stream_openrep requests wide m w p file H H0 as info Ho
exists p, info
auto

Narrow literal/vararg interpretation is separate from the selected FILE representation. All errors and partial acceptance stay admitted.

269Lemma libc_output_admitted
∀ rep requests wide api xs m w file bytes
output_preapi libc_stream_modelrep requests wide libc_stdout xs m w
Explore proof 7 tactics

Initial goal

⊢
∀rep : mem → libc_world → Prop requests : libc_world → ptr → Z → Z → Prop wide : libc_world → ptr → stream_state → stream_state → bool → Prop api : narrow_api xs : listword m : mem w : libc_world file : libc_file bytes : listZ, libc_stream_readyrep m w → libc_file_atw output_targetapi libc_stdout w xs = Somefile → orientationlibc_stream_statew output_targetapi libc_stdout w xs ≠ WideOriented → output_textapi m xs bytes → output_preapi libc_stream_modelrep requests wide libc_stdout xs m w

intros rep requests wide api xs m w file bytes Hr Hfile Ho Htext

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
xs :
listword
m :
file :
bytes :
listZ
Hfile :
Htext :
output_textapi m xs bytes
⊢
output_preapi libc_stream_modelrep requests wide libc_stdout xs m w

destruct libc_stream_openrep requests wide m w _ file Hr Hfile as info Hopen

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
xs :
listword
m :
file :
bytes :
listZ
Hfile :
Htext :
output_textapi m xs bytes
Hopen :
stream_openlibc_stream_modelrep requests wide m w output_targetapi libc_stdout w xs info
⊢
output_preapi libc_stream_modelrep requests wide libc_stdout xs m w

exists info, bytes

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
xs :
listword
m :
file :
bytes :
listZ
Hfile :
Htext :
output_textapi m xs bytes
Hopen :
stream_openlibc_stream_modelrep requests wide m w output_targetapi libc_stdout w xs info
⊢
stream_openlibc_stream_modelrep requests wide m w output_targetapi libc_stdout w xs info ∧ orientationstream_protocolinfo ≠ WideOriented ∧ output_textapi m xs bytes

split ; exact Hopen |

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
xs :
listword
m :
file :
bytes :
listZ
Hfile :
Htext :
output_textapi m xs bytes
Hopen :
stream_openlibc_stream_modelrep requests wide m w output_targetapi libc_stdout w xs info
⊢

destruct Hopen as _ & _ & Hstate & _

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
xs :
listword
m :
file :
bytes :
listZ
Hfile :
Htext :
output_textapi m xs bytes
⊢

rewrite Hstate

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
xs :
listword
m :
file :
bytes :
listZ
Hfile :
Htext :
output_textapi m xs bytes

auto

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros rep requests wide api xs m w file bytes Hr Hfile Ho Htext
destruct libc_stream_openrep requests wide m w _ file Hr Hfile as info Hopen
exists info, bytes
split ; exact Hopen |
destruct Hopen as _ & _ & Hstate & _
rewrite Hstate
auto

An unchanged active endpoint delegates its fixed scalar errno root as well as its private roots; it needs no new allocation or owner.

284Lemma libc_stream_delegates_refl
∀ rep requests wide m w p
stream_delegateslibc_stream_modelrep requests wide w p [ ] m w
Proof 49 steps Qed
intros rep requests wide m w p Hr
split
–intros root Hin
destruct libc_file_atw p as file | eqn: Hfile
2: {unfold libc_stream_writes in Hin
rewrite Hfile in Hin
contradiction
destruct libc_stream_openrep requests wide m w p file Hr Hfile as info & _ & _ & _ & _ & Hw
change Forallwritable_spanm libc_stream_writesw p in Hw
assert Hwr : writable_spanm root by rewrite Forall_forall in Hw ; exact Hwroot Hin
split
+right
left
rewrite Hfile in Hin
rewrite Hfile
apply in_app_or in Hin as Hin | Hin
∗exists root
split ; | reflexivity
apply in_or_app
left
right
apply in_or_app
right
exact Hin
∗simpl in Hin
destruct Hin as [ <-| [ ] ]
exists mkSpanlibc_errnofstw 0
split ; | reflexivity
apply in_or_app
right
simpl
auto
+intros a Ha
left
exists root
auto
–split
+intros source Hin
left
exists source
auto
+intros base Hin
left
exact Hin

The same libc errno/locale/conversion registry stays usable after closing stdout; writable retired roots are not required.

313Lemma libc_stream_ready_libc
∀ rep m w
libc_readyrep m w
Explore proof 13 tactics

Initial goal

⊢
∀rep : mem → libc_world → Prop m : mem w : libc_world, libc_stream_readyrep m w → libc_readyrep m w

intros rep m w Hrep & Hlocale & Herrno & Hout & Herr & Hu & Hstatus & Hphase & Hdistinct & Hroots & Hro & Hre & Hrelease

rep :
mem → libc_world → Prop
m :
Hrep :
repm w
Hlocale :
locale_readyλ_ : mem _ : locale_world ⇒ True m libc_localefstw
Herrno :
Hstatus :
−2 ^ 31 ≤ shutdown_statussndw < 2 ^ 31
Hphase :
match shutdown_atsndw with
_
⇒
True
⊢
libc_readyrep m w

split ; exact Hrep |

rep :
mem → libc_world → Prop
m :
Hrep :
repm w
Hlocale :
locale_readyλ_ : mem _ : locale_world ⇒ True m libc_localefstw
Herrno :
Hstatus :
−2 ^ 31 ≤ shutdown_statussndw < 2 ^ 31
Hphase :
match shutdown_atsndw with
_
⇒
True
⊢
locale_readyλ_ : mem _ : locale_world ⇒ True m libc_localefstw
∧
∧
∧
∧
∧
−2 ^ 31 ≤ shutdown_statussndw < 2 ^ 31
∧
match shutdown_atsndw with
_
⇒
True

split ; exact Hlocale |

rep :
mem → libc_world → Prop
m :
Hrep :
repm w
Hlocale :
locale_readyλ_ : mem _ : locale_world ⇒ True m libc_localefstw
Herrno :
Hstatus :
−2 ^ 31 ≤ shutdown_statussndw < 2 ^ 31
Hphase :
match shutdown_atsndw with
_
⇒
True
⊢
∧
∧
∧
∧
−2 ^ 31 ≤ shutdown_statussndw < 2 ^ 31
∧
match shutdown_atsndw with
_
⇒
True

split

2 open

focused goal
rep :
mem → libc_world → Prop
m :
Hrep :
repm w
Hlocale :
locale_readyλ_ : mem _ : locale_world ⇒ True m libc_localefstw
Herrno :
Hstatus :
−2 ^ 31 ≤ shutdown_statussndw < 2 ^ 31
Hphase :
match shutdown_atsndw with
_
⇒
True
⊢
∧
∧
∧
−2 ^ 31 ≤ shutdown_statussndw < 2 ^ 31
∧
match shutdown_atsndw with
_
⇒
True

–rewrite Hroots

2 open

deferred goal
rep :
mem → libc_world → Prop
m :
Hrep :
repm w
Hlocale :
locale_readyλ_ : mem _ : locale_world ⇒ True m libc_localefstw
Herrno :
Hstatus :
−2 ^ 31 ≤ shutdown_statussndw < 2 ^ 31
Hphase :
match shutdown_atsndw with
_
⇒
True
⊢
∧
∧
∧
−2 ^ 31 ≤ shutdown_statussndw < 2 ^ 31
∧
match shutdown_atsndw with
_
⇒
True

unfold libc_active_roots

2 open

deferred goal
rep :
mem → libc_world → Prop
m :
Hrep :
repm w
Hlocale :
locale_readyλ_ : mem _ : locale_world ⇒ True m libc_localefstw
Herrno :
Hstatus :
−2 ^ 31 ≤ shutdown_statussndw < 2 ^ 31
Hphase :
match shutdown_atsndw with
_
⇒
True
⊢
∧
∧
∧
−2 ^ 31 ≤ shutdown_statussndw < 2 ^ 31
∧
match shutdown_atsndw with
_
⇒
True

apply Forall_app

2 open

deferred goal
rep :
mem → libc_world → Prop
m :
Hrep :
repm w
Hlocale :
locale_readyλ_ : mem _ : locale_world ⇒ True m libc_localefstw
Herrno :
Hstatus :
−2 ^ 31 ≤ shutdown_statussndw < 2 ^ 31
Hphase :
match shutdown_atsndw with
_
⇒
True
⊢
∧
∧
∧
−2 ^ 31 ≤ shutdown_statussndw < 2 ^ 31
∧
match shutdown_atsndw with
_
⇒
True

split

3 open

focused goal
rep :
mem → libc_world → Prop
m :
Hrep :
repm w
Hlocale :
locale_readyλ_ : mem _ : locale_world ⇒ True m libc_localefstw
Herrno :
Hstatus :
−2 ^ 31 ≤ shutdown_statussndw < 2 ^ 31
Hphase :
match shutdown_atsndw with
_
⇒
True
⊢
Forallwritable_spanm span_ptr ≔ libc_errnofstw; span_size ≔ 4
deferred goal
rep :
mem → libc_world → Prop
m :
Hrep :
repm w
Hlocale :
locale_readyλ_ : mem _ : locale_world ⇒ True m libc_localefstw
Herrno :
Hstatus :
−2 ^ 31 ≤ shutdown_statussndw < 2 ^ 31
Hphase :
match shutdown_atsndw with
_
⇒
True
⊢
∧
∧
∧
−2 ^ 31 ≤ shutdown_statussndw < 2 ^ 31
∧
match shutdown_atsndw with
_
⇒
True

+destruct stdout_usablelibc_stdiofstw eqn: Ho ; | constructor

3 open

rep :
mem → libc_world → Prop
m :
Hrep :
repm w
Hlocale :
locale_readyλ_ : mem _ : locale_world ⇒ True m libc_localefstw
Herrno :
Hstatus :
−2 ^ 31 ≤ shutdown_statussndw < 2 ^ 31
Hphase :
match shutdown_atsndw with
_
⇒
True
Ho :
deferred goal
rep :
mem → libc_world → Prop
m :
Hrep :
repm w
Hlocale :
locale_readyλ_ : mem _ : locale_world ⇒ True m libc_localefstw
Herrno :
Hstatus :
−2 ^ 31 ≤ shutdown_statussndw < 2 ^ 31
Hphase :
match shutdown_atsndw with
_
⇒
True
⊢
Forallwritable_spanm span_ptr ≔ libc_errnofstw; span_size ≔ 4
deferred goal
rep :
mem → libc_world → Prop
m :
Hrep :
repm w
Hlocale :
locale_readyλ_ : mem _ : locale_world ⇒ True m libc_localefstw
Herrno :
Hstatus :
−2 ^ 31 ≤ shutdown_statussndw < 2 ^ 31
Hphase :
match shutdown_atsndw with
_
⇒
True
⊢
∧
∧
∧
−2 ^ 31 ≤ shutdown_statussndw < 2 ^ 31
∧
match shutdown_atsndw with
_
⇒
True

destruct Hroeq_refl as _ & _ & _ & Hr & _

3 open

deferred goal
rep :
mem → libc_world → Prop
m :
Hrep :
repm w
Hlocale :
locale_readyλ_ : mem _ : locale_world ⇒ True m libc_localefstw
Herrno :
Hstatus :
−2 ^ 31 ≤ shutdown_statussndw < 2 ^ 31
Hphase :
match shutdown_atsndw with
_
⇒
True
⊢
Forallwritable_spanm span_ptr ≔ libc_errnofstw; span_size ≔ 4
deferred goal
rep :
mem → libc_world → Prop
m :
Hrep :
repm w
Hlocale :
locale_readyλ_ : mem _ : locale_world ⇒ True m libc_localefstw
Herrno :
Hstatus :
−2 ^ 31 ≤ shutdown_statussndw < 2 ^ 31
Hphase :
match shutdown_atsndw with
_
⇒
True
⊢
∧
∧
∧
−2 ^ 31 ≤ shutdown_statussndw < 2 ^ 31
∧
match shutdown_atsndw with
_
⇒
True

exact Hr

2 open

deferred goal
rep :
mem → libc_world → Prop
m :
Hrep :
repm w
Hlocale :
locale_readyλ_ : mem _ : locale_world ⇒ True m libc_localefstw
Herrno :
Hstatus :
−2 ^ 31 ≤ shutdown_statussndw < 2 ^ 31
Hphase :
match shutdown_atsndw with
_
⇒
True
⊢
Forallwritable_spanm span_ptr ≔ libc_errnofstw; span_size ≔ 4
deferred goal
rep :
mem → libc_world → Prop
m :
Hrep :
repm w
Hlocale :
locale_readyλ_ : mem _ : locale_world ⇒ True m libc_localefstw
Herrno :
Hstatus :
−2 ^ 31 ≤ shutdown_statussndw < 2 ^ 31
Hphase :
match shutdown_atsndw with
_
⇒
True
⊢
∧
∧
∧
−2 ^ 31 ≤ shutdown_statussndw < 2 ^ 31
∧
match shutdown_atsndw with
_
⇒
True

+constructor ; exact proj1proj2Herrno | constructor

deferred goal
rep :
mem → libc_world → Prop
m :
Hrep :
repm w
Hlocale :
locale_readyλ_ : mem _ : locale_world ⇒ True m libc_localefstw
Herrno :
Hstatus :
−2 ^ 31 ≤ shutdown_statussndw < 2 ^ 31
Hphase :
match shutdown_atsndw with
_
⇒
True
⊢
∧
∧
∧
−2 ^ 31 ≤ shutdown_statussndw < 2 ^ 31
∧
match shutdown_atsndw with
_
⇒
True

–auto

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros rep m w Hrep & Hlocale & Herrno & Hout & Herr & Hu & Hstatus & Hphase & Hdistinct & Hroots & Hro & Hre & Hrelease
split ; exact Hrep |
split ; exact Hlocale |
split
–rewrite Hroots
apply Forall_app
split
+destruct stdout_usablelibc_stdiofstw eqn: Ho ; | constructor
destruct Hroeq_refl as _ & _ & _ & Hr & _
exact Hr
+constructor ; exact proj1proj2Herrno | constructor
–auto

Keeping the world unchanged is a valid logical frame.

327Lemma libc_stream_frame_refl
∀ p w
Explore proof 3 tactics
Source script
intros
repeat split ; destruct same_filep libc_stdoutw ; auto

Errno is scalar-only even when its entry aux is nonempty. The frame is required at all call prefixes, including resource stops.

332Lemma libc_stream_errno_aux
∀ rep requests wide m w p file m′
libc_file_atw p = Somefile
stream_aux_framelibc_stream_modelrep requests wide m w p m′
Explore proof 20 tactics

Initial goal

⊢
∀rep : mem → libc_world → Prop requests : libc_world → ptr → Z → Z → Prop wide : libc_world → ptr → stream_state → stream_state → bool → Prop m : mem w : libc_world p : ptr file : libc_file m′ : mem, libc_stream_readyrep m w → libc_file_atw p = Somefile → stream_aux_framelibc_stream_modelrep requests wide m w p m′ → m_auxm′ ptr_addrlibc_errnofstw = m_auxm ptr_addrlibc_errnofstw

intros rep requests wide m w p file m′ Hr Hfile Hframe

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
m′ :
Hfile :
libc_file_atw p = Somefile
Hframe :
stream_aux_framelibc_stream_modelrep requests wide m w p m′

pose proof libc_file_at_readyrep m w p file Hr Hfile as _ & _ & _ & _ & _ & _ & Hapart & _

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
m′ :
Hfile :
libc_file_atw p = Somefile
Hframe :
stream_aux_framelibc_stream_modelrep requests wide m w p m′
Hapart :
∀root : span, Inroot file_rootsfile → spans_apartroot span_ptr ≔ libc_errnofstw; span_size ≔ 4

pose proof Hr as _ & _ & _ & Hcell & _ & _

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
m′ :
Hfile :
libc_file_atw p = Somefile
Hframe :
stream_aux_framelibc_stream_modelrep requests wide m w p m′
Hapart :
∀root : span, Inroot file_rootsfile → spans_apartroot span_ptr ≔ libc_errnofstw; span_size ≔ 4
Hcell :

apply Hframe

2 open

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
m′ :
Hfile :
libc_file_atw p = Somefile
Hframe :
stream_aux_framelibc_stream_modelrep requests wide m w p m′
Hapart :
∀root : span, Inroot file_rootsfile → spans_apartroot span_ptr ≔ libc_errnofstw; span_size ≔ 4
Hcell :
focused goal
rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
m′ :
Hfile :
libc_file_atw p = Somefile
Hframe :
stream_aux_framelibc_stream_modelrep requests wide m w p m′
Hapart :
∀root : span, Inroot file_rootsfile → spans_apartroot span_ptr ≔ libc_errnofstw; span_size ≔ 4
Hcell :

–eapply write_authority_in with roots := mkSpanlibc_errnofstw 4 born := [ ]

2 open

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
m′ :
Hfile :
libc_file_atw p = Somefile
Hframe :
stream_aux_framelibc_stream_modelrep requests wide m w p m′
Hapart :
∀root : span, Inroot file_rootsfile → spans_apartroot span_ptr ≔ libc_errnofstw; span_size ≔ 4
Hcell :
deferred goal
rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
m′ :
Hfile :
libc_file_atw p = Somefile
Hframe :
stream_aux_framelibc_stream_modelrep requests wide m w p m′
Hapart :
∀root : span, Inroot file_rootsfile → spans_apartroot span_ptr ≔ libc_errnofstw; span_size ≔ 4
Hcell :

left

2 open

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
m′ :
Hfile :
libc_file_atw p = Somefile
Hframe :
stream_aux_framelibc_stream_modelrep requests wide m w p m′
Hapart :
∀root : span, Inroot file_rootsfile → spans_apartroot span_ptr ≔ libc_errnofstw; span_size ≔ 4
Hcell :
⊢
∃s : span, Ins span_ptr ≔ libc_errnofstw; span_size ≔ 4 ∧ writable_spanm s ∧ span_containss ptr_addrlibc_errnofstw
deferred goal
rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
m′ :
Hfile :
libc_file_atw p = Somefile
Hframe :
stream_aux_framelibc_stream_modelrep requests wide m w p m′
Hapart :
∀root : span, Inroot file_rootsfile → spans_apartroot span_ptr ≔ libc_errnofstw; span_size ≔ 4
Hcell :

exists mkSpanlibc_errnofstw 4

2 open

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
m′ :
Hfile :
libc_file_atw p = Somefile
Hframe :
stream_aux_framelibc_stream_modelrep requests wide m w p m′
Hapart :
∀root : span, Inroot file_rootsfile → spans_apartroot span_ptr ≔ libc_errnofstw; span_size ≔ 4
Hcell :
deferred goal
rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
m′ :
Hfile :
libc_file_atw p = Somefile
Hframe :
stream_aux_framelibc_stream_modelrep requests wide m w p m′
Hapart :
∀root : span, Inroot file_rootsfile → spans_apartroot span_ptr ≔ libc_errnofstw; span_size ≔ 4
Hcell :

split ; simpl ; auto |

2 open

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
m′ :
Hfile :
libc_file_atw p = Somefile
Hframe :
stream_aux_framelibc_stream_modelrep requests wide m w p m′
Hapart :
∀root : span, Inroot file_rootsfile → spans_apartroot span_ptr ≔ libc_errnofstw; span_size ≔ 4
Hcell :
deferred goal
rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
m′ :
Hfile :
libc_file_atw p = Somefile
Hframe :
stream_aux_framelibc_stream_modelrep requests wide m w p m′
Hapart :
∀root : span, Inroot file_rootsfile → spans_apartroot span_ptr ≔ libc_errnofstw; span_size ≔ 4
Hcell :

split ; exact Hcell |

2 open

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
m′ :
Hfile :
libc_file_atw p = Somefile
Hframe :
stream_aux_framelibc_stream_modelrep requests wide m w p m′
Hapart :
∀root : span, Inroot file_rootsfile → spans_apartroot span_ptr ≔ libc_errnofstw; span_size ≔ 4
Hcell :
deferred goal
rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
m′ :
Hfile :
libc_file_atw p = Somefile
Hframe :
stream_aux_framelibc_stream_modelrep requests wide m w p m′
Hapart :
∀root : span, Inroot file_rootsfile → spans_apartroot span_ptr ≔ libc_errnofstw; span_size ≔ 4
Hcell :

unfold span_contains

2 open

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
m′ :
Hfile :
libc_file_atw p = Somefile
Hframe :
stream_aux_framelibc_stream_modelrep requests wide m w p m′
Hapart :
∀root : span, Inroot file_rootsfile → spans_apartroot span_ptr ≔ libc_errnofstw; span_size ≔ 4
Hcell :
deferred goal
rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
m′ :
Hfile :
libc_file_atw p = Somefile
Hframe :
stream_aux_framelibc_stream_modelrep requests wide m w p m′
Hapart :
∀root : span, Inroot file_rootsfile → spans_apartroot span_ptr ≔ libc_errnofstw; span_size ≔ 4
Hcell :

simpl

2 open

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
m′ :
Hfile :
libc_file_atw p = Somefile
Hframe :
stream_aux_framelibc_stream_modelrep requests wide m w p m′
Hapart :
∀root : span, Inroot file_rootsfile → spans_apartroot span_ptr ≔ libc_errnofstw; span_size ≔ 4
Hcell :
deferred goal
rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
m′ :
Hfile :
libc_file_atw p = Somefile
Hframe :
stream_aux_framelibc_stream_modelrep requests wide m w p m′
Hapart :
∀root : span, Inroot file_rootsfile → spans_apartroot span_ptr ≔ libc_errnofstw; span_size ≔ 4
Hcell :

lia

deferred goal
rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
m′ :
Hfile :
libc_file_atw p = Somefile
Hframe :
stream_aux_framelibc_stream_modelrep requests wide m w p m′
Hapart :
∀root : span, Inroot file_rootsfile → spans_apartroot span_ptr ≔ libc_errnofstw; span_size ≔ 4
Hcell :

–change ¬write_authoritylibc_stream_aux_rootsw p [ ] m ptr_addrlibc_errnofstw

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
m′ :
Hfile :
libc_file_atw p = Somefile
Hframe :
stream_aux_framelibc_stream_modelrep requests wide m w p m′
Hapart :
∀root : span, Inroot file_rootsfile → spans_apartroot span_ptr ≔ libc_errnofstw; span_size ≔ 4
Hcell :

unfold libc_stream_aux_roots

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
m′ :
Hfile :
libc_file_atw p = Somefile
Hframe :
stream_aux_framelibc_stream_modelrep requests wide m w p m′
Hapart :
∀root : span, Inroot file_rootsfile → spans_apartroot span_ptr ≔ libc_errnofstw; span_size ≔ 4
Hcell :
⊢
¬write_authoritymatch libc_file_atw p with Somefile0 ⇒ file_rootsfile0 | None ⇒ [ ] end [ ] m ptr_addrlibc_errnofstw

rewrite Hfile

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
m′ :
Hfile :
libc_file_atw p = Somefile
Hframe :
stream_aux_framelibc_stream_modelrep requests wide m w p m′
Hapart :
∀root : span, Inroot file_rootsfile → spans_apartroot span_ptr ≔ libc_errnofstw; span_size ≔ 4
Hcell :

intros root & Hin & _ & Ha | base & reg & & _

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
m′ :
Hfile :
libc_file_atw p = Somefile
Hframe :
stream_aux_framelibc_stream_modelrep requests wide m w p m′
Hapart :
∀root : span, Inroot file_rootsfile → spans_apartroot span_ptr ≔ libc_errnofstw; span_size ≔ 4
Hcell :
root :
Hin :
Inroot file_rootsfile
⊢
False

specialize Hapartroot Hin

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
m′ :
Hfile :
libc_file_atw p = Somefile
Hframe :
stream_aux_framelibc_stream_modelrep requests wide m w p m′
root :
Hapart :
Hcell :
Hin :
Inroot file_rootsfile
⊢
False

unfold spans_apart , span_contains in *

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
m′ :
Hfile :
libc_file_atw p = Somefile
Hframe :
stream_aux_framelibc_stream_modelrep requests wide m w p m′
root :
Hcell :
Hin :
Inroot file_rootsfile
⊢
False

simpl in *

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
m :
p :
file :
m′ :
Hfile :
libc_file_atw p = Somefile
Hframe :
stream_aux_framelibc_stream_modelrep requests wide m w p m′
root :
Hapart :
Hcell :
Hin :
Inroot file_rootsfile
⊢
False

lia

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros rep requests wide m w p file m′ Hr Hfile Hframe
pose proof libc_file_at_readyrep m w p file Hr Hfile as _ & _ & _ & _ & _ & _ & Hapart & _
pose proof Hr as _ & _ & _ & Hcell & _ & _
apply Hframe
–eapply write_authority_in with roots := mkSpanlibc_errnofstw 4 born := [ ]
left
exists mkSpanlibc_errnofstw 4
split ; simpl ; auto |
split ; exact Hcell |
simpl
lia
rewrite Hfile
intros root & Hin & _ & Ha | base & reg & & _
specialize Hapartroot Hin
simpl in *
lia

The registry and projections use the consumer's actual machine.

352Module LibcStreamsOn R : Runtime M : ExternalMachineSigR
353Module E ≔ M.E
354Module S ≔ StreamsOn R M
355Module F ≔ FormattingOn R M
356Module C ≔ LibcOn R M

A logical unchanged query has an independently admitted prefix. This is nonvacuity, not a claim that native locking changes nothing.

360Theorem query_unchanged_prefix
∀ rep requests wide p file s m w
libc_file_atw p = Somefile
E.prefixferror_contractlibc_stream_modelrep requests wide WPtrp s m w [ ] [ ] s m w
Explore proof 11 tactics

Initial goal

⊢
∀rep : mem → libc_world → Prop requests : libc_world → ptr → Z → Z → Prop wide : libc_world → ptr → stream_state → stream_state → bool → Prop p : ptr file : libc_file s : R.state m : mem w : libc_world, libc_stream_readyrep m w → libc_file_atw p = Somefile → E.prefixferror_contractlibc_stream_modelrep requests wide WPtrp s m w [ ] [ ] s m w

intros rep requests wide p file s m w Hr Hfile

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
p :
file :
s :
R.state
m :
Hfile :
libc_file_atw p = Somefile
⊢
E.prefixferror_contractlibc_stream_modelrep requests wide WPtrp s m w [ ] [ ] s m w

destruct libc_stream_openrep requests wide m w p file Hr Hfile as info Ho

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
p :
file :
s :
R.state
m :
Hfile :
libc_file_atw p = Somefile
Ho :
stream_openlibc_stream_modelrep requests wide m w p info
⊢
E.prefixferror_contractlibc_stream_modelrep requests wide WPtrp s m w [ ] [ ] s m w

split ; constructor |

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
p :
file :
s :
R.state
m :
Hfile :
libc_file_atw p = Somefile
Ho :
stream_openlibc_stream_modelrep requests wide m w p info
⊢
contract_prefixferror_contractlibc_stream_modelrep requests wide WPtrp m w [ ] [ ] m w

exists p, info

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
p :
file :
s :
R.state
m :
Hfile :
libc_file_atw p = Somefile
Ho :
stream_openlibc_stream_modelrep requests wide m w p info
⊢
WPtrp = WPtrp ∧ stream_atlibc_stream_modelrep requests wide w p = Someinfo ∧ stream_openlibc_stream_modelrep requests wide m w p info ∧ stream_framelibc_stream_modelrep requests wide p w w ∧ stream_delegateslibc_stream_modelrep requests wide w p [ ] m w ∧ [ ] = [ ] ∧ stream_aux_framelibc_stream_modelrep requests wide m w p m ∧ ∀a : Z, in_objectm a → ¬write_authoritystream_aux_rootslibc_stream_modelrep requests wide w p [ ] m a → m_bytesm a = m_bytesm a

split ; reflexivity |

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
p :
file :
s :
R.state
m :
Hfile :
libc_file_atw p = Somefile
Ho :
stream_openlibc_stream_modelrep requests wide m w p info
⊢
stream_atlibc_stream_modelrep requests wide w p = Someinfo ∧ stream_openlibc_stream_modelrep requests wide m w p info ∧ stream_framelibc_stream_modelrep requests wide p w w ∧ stream_delegateslibc_stream_modelrep requests wide w p [ ] m w ∧ [ ] = [ ] ∧ stream_aux_framelibc_stream_modelrep requests wide m w p m ∧ ∀a : Z, in_objectm a → ¬write_authoritystream_aux_rootslibc_stream_modelrep requests wide w p [ ] m a → m_bytesm a = m_bytesm a

split ; exact proj1proj2Ho |

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
p :
file :
s :
R.state
m :
Hfile :
libc_file_atw p = Somefile
Ho :
stream_openlibc_stream_modelrep requests wide m w p info
⊢
stream_openlibc_stream_modelrep requests wide m w p info ∧ stream_framelibc_stream_modelrep requests wide p w w ∧ stream_delegateslibc_stream_modelrep requests wide w p [ ] m w ∧ [ ] = [ ] ∧ stream_aux_framelibc_stream_modelrep requests wide m w p m ∧ ∀a : Z, in_objectm a → ¬write_authoritystream_aux_rootslibc_stream_modelrep requests wide w p [ ] m a → m_bytesm a = m_bytesm a

split ; exact Ho |

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
p :
file :
s :
R.state
m :
Hfile :
libc_file_atw p = Somefile
Ho :
stream_openlibc_stream_modelrep requests wide m w p info
⊢
stream_framelibc_stream_modelrep requests wide p w w ∧ stream_delegateslibc_stream_modelrep requests wide w p [ ] m w ∧ [ ] = [ ] ∧ stream_aux_framelibc_stream_modelrep requests wide m w p m ∧ ∀a : Z, in_objectm a → ¬write_authoritystream_aux_rootslibc_stream_modelrep requests wide w p [ ] m a → m_bytesm a = m_bytesm a

split ; apply libc_stream_frame_refl |

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
p :
file :
s :
R.state
m :
Hfile :
libc_file_atw p = Somefile
Ho :
stream_openlibc_stream_modelrep requests wide m w p info
⊢
stream_delegateslibc_stream_modelrep requests wide w p [ ] m w ∧ [ ] = [ ] ∧ stream_aux_framelibc_stream_modelrep requests wide m w p m ∧ ∀a : Z, in_objectm a → ¬write_authoritystream_aux_rootslibc_stream_modelrep requests wide w p [ ] m a → m_bytesm a = m_bytesm a

split ; apply libc_stream_delegates_refl ; exact Hr |

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
p :
file :
s :
R.state
m :
Hfile :
libc_file_atw p = Somefile
Ho :
stream_openlibc_stream_modelrep requests wide m w p info
⊢
[ ] = [ ] ∧ stream_aux_framelibc_stream_modelrep requests wide m w p m ∧ ∀a : Z, in_objectm a → ¬write_authoritystream_aux_rootslibc_stream_modelrep requests wide w p [ ] m a → m_bytesm a = m_bytesm a

split ; reflexivity |

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
p :
file :
s :
R.state
m :
Hfile :
libc_file_atw p = Somefile
Ho :
stream_openlibc_stream_modelrep requests wide m w p info
⊢
stream_aux_framelibc_stream_modelrep requests wide m w p m ∧ ∀a : Z, in_objectm a → ¬write_authoritystream_aux_rootslibc_stream_modelrep requests wide w p [ ] m a → m_bytesm a = m_bytesm a

split ; unfold stream_aux_frame | ; intros ; reflexivity

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros rep requests wide p file s m w Hr Hfile
destruct libc_stream_openrep requests wide m w p file Hr Hfile as info Ho
split ; constructor |
exists p, info
split ; reflexivity |
split ; exact proj1proj2Ho |
split ; exact Ho |
split ; apply libc_stream_frame_refl |
split ; apply libc_stream_delegates_refl ; exact Hr |
split ; reflexivity |
split ; unfold stream_aux_frame | ; intros ; reflexivity

The concrete ferror query admits either sticky-error value without assuming that the caller sees a successful output history.

376Theorem ferror_unchanged
∀ rep requests wide r args p file s m w
E.invokeferror_contractlibc_stream_modelrep requests wide r args WPtrp s m w [ ] CallReturnWIntif stream_errorlibc_stream_statew p then 1 else 0 s m w
Explore proof 19 tactics

Initial goal

⊢
∀rep : mem → libc_world → Prop requests : libc_world → ptr → Z → Z → Prop wide : libc_world → ptr → stream_state → stream_state → bool → Prop r : call_result args : listarg p : ptr file : libc_file s : R.state m : mem w : libc_world, stream_query_abiW r args → libc_stream_readyrep m w → libc_file_atw p = Somefile → E.invokeferror_contractlibc_stream_modelrep requests wide r args WPtrp s m w [ ] CallReturnWIntif stream_errorlibc_stream_statew p then 1 else 0 s m w

intros rep requests wide r args p file s m w Habi Hr Hfile

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
args :
listarg
p :
file :
s :
R.state
m :
Habi :
Hfile :
libc_file_atw p = Somefile
⊢
E.invokeferror_contractlibc_stream_modelrep requests wide r args WPtrp s m w [ ] CallReturnWIntif stream_errorlibc_stream_statew p then 1 else 0 s m w

destruct libc_stream_openrep requests wide m w p file Hr Hfile as info Ho

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
args :
listarg
p :
file :
s :
R.state
m :
Habi :
Hfile :
libc_file_atw p = Somefile
Ho :
stream_openlibc_stream_modelrep requests wide m w p info
⊢
E.invokeferror_contractlibc_stream_modelrep requests wide r args WPtrp s m w [ ] CallReturnWIntif stream_errorlibc_stream_statew p then 1 else 0 s m w

eapply S.ferror_return with born := [ ]

4 open

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
args :
listarg
p :
file :
s :
R.state
m :
Habi :
Hfile :
libc_file_atw p = Somefile
Ho :
stream_openlibc_stream_modelrep requests wide m w p info
focused goal
rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
args :
listarg
p :
file :
s :
R.state
m :
Habi :
Hfile :
libc_file_atw p = Somefile
Ho :
stream_openlibc_stream_modelrep requests wide m w p info
⊢
focused goal
rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
args :
listarg
p :
file :
s :
R.state
m :
Habi :
Hfile :
libc_file_atw p = Somefile
Ho :
stream_openlibc_stream_modelrep requests wide m w p info
⊢
S.E.prefixferror_contractlibc_stream_modelrep requests wide WPtrp s m w [ ] [ ] s m w
focused goal
rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
args :
listarg
p :
file :
s :
R.state
m :
Habi :
Hfile :
libc_file_atw p = Somefile
Ho :
stream_openlibc_stream_modelrep requests wide m w p info
⊢
ferror_postlibc_stream_modelrep requests wide WPtrp m w [ ] [ ] CallReturnWIntif stream_errorlibc_stream_statew p then 1 else 0 m w

–exact Habi

3 open

deferred goal
rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
args :
listarg
p :
file :
s :
R.state
m :
Habi :
Hfile :
libc_file_atw p = Somefile
Ho :
stream_openlibc_stream_modelrep requests wide m w p info
⊢
deferred goal
rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
args :
listarg
p :
file :
s :
R.state
m :
Habi :
Hfile :
libc_file_atw p = Somefile
Ho :
stream_openlibc_stream_modelrep requests wide m w p info
⊢
S.E.prefixferror_contractlibc_stream_modelrep requests wide WPtrp s m w [ ] [ ] s m w
deferred goal
rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
args :
listarg
p :
file :
s :
R.state
m :
Habi :
Hfile :
libc_file_atw p = Somefile
Ho :
stream_openlibc_stream_modelrep requests wide m w p info
⊢
ferror_postlibc_stream_modelrep requests wide WPtrp m w [ ] [ ] CallReturnWIntif stream_errorlibc_stream_statew p then 1 else 0 m w

–exists p, info

3 open

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
args :
listarg
p :
file :
s :
R.state
m :
Habi :
Hfile :
libc_file_atw p = Somefile
Ho :
stream_openlibc_stream_modelrep requests wide m w p info
⊢
WPtrp = WPtrp ∧ stream_openlibc_stream_modelrep requests wide m w p info
deferred goal
rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
args :
listarg
p :
file :
s :
R.state
m :
Habi :
Hfile :
libc_file_atw p = Somefile
Ho :
stream_openlibc_stream_modelrep requests wide m w p info
⊢
S.E.prefixferror_contractlibc_stream_modelrep requests wide WPtrp s m w [ ] [ ] s m w
deferred goal
rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
args :
listarg
p :
file :
s :
R.state
m :
Habi :
Hfile :
libc_file_atw p = Somefile
Ho :
stream_openlibc_stream_modelrep requests wide m w p info
⊢
ferror_postlibc_stream_modelrep requests wide WPtrp m w [ ] [ ] CallReturnWIntif stream_errorlibc_stream_statew p then 1 else 0 m w

auto

2 open

deferred goal
rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
args :
listarg
p :
file :
s :
R.state
m :
Habi :
Hfile :
libc_file_atw p = Somefile
Ho :
stream_openlibc_stream_modelrep requests wide m w p info
⊢
S.E.prefixferror_contractlibc_stream_modelrep requests wide WPtrp s m w [ ] [ ] s m w
deferred goal
rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
args :
listarg
p :
file :
s :
R.state
m :
Habi :
Hfile :
libc_file_atw p = Somefile
Ho :
stream_openlibc_stream_modelrep requests wide m w p info
⊢
ferror_postlibc_stream_modelrep requests wide WPtrp m w [ ] [ ] CallReturnWIntif stream_errorlibc_stream_statew p then 1 else 0 m w

–eapply query_unchanged_prefix ; eauto

deferred goal
rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
args :
listarg
p :
file :
s :
R.state
m :
Habi :
Hfile :
libc_file_atw p = Somefile
Ho :
stream_openlibc_stream_modelrep requests wide m w p info
⊢
ferror_postlibc_stream_modelrep requests wide WPtrp m w [ ] [ ] CallReturnWIntif stream_errorlibc_stream_statew p then 1 else 0 m w

–exists p, info, if stream_errorlibc_stream_statew p then 1 else 0

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
args :
listarg
p :
file :
s :
R.state
m :
Habi :
Hfile :
libc_file_atw p = Somefile
Ho :
stream_openlibc_stream_modelrep requests wide m w p info
⊢
WPtrp = WPtrp
∧
stream_atlibc_stream_modelrep requests wide w p = Someinfo
∧
stream_openlibc_stream_modelrep requests wide m w p info
∧
stream_framelibc_stream_modelrep requests wide p w w
∧
stream_delegateslibc_stream_modelrep requests wide w p [ ] m w
∧
[ ] = [ ]
∧
∧
0 ≤ if stream_errorlibc_stream_statew p then 1 else 0 < 2 ^ 32
∧

split ; reflexivity |

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
args :
listarg
p :
file :
s :
R.state
m :
Habi :
Hfile :
libc_file_atw p = Somefile
Ho :
stream_openlibc_stream_modelrep requests wide m w p info
⊢
stream_atlibc_stream_modelrep requests wide w p = Someinfo
∧
stream_openlibc_stream_modelrep requests wide m w p info
∧
stream_framelibc_stream_modelrep requests wide p w w
∧
stream_delegateslibc_stream_modelrep requests wide w p [ ] m w
∧
[ ] = [ ]
∧
∧
0 ≤ if stream_errorlibc_stream_statew p then 1 else 0 < 2 ^ 32
∧

split ; exact proj1proj2Ho |

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
args :
listarg
p :
file :
s :
R.state
m :
Habi :
Hfile :
libc_file_atw p = Somefile
Ho :
stream_openlibc_stream_modelrep requests wide m w p info
⊢
stream_openlibc_stream_modelrep requests wide m w p info
∧
stream_framelibc_stream_modelrep requests wide p w w
∧
stream_delegateslibc_stream_modelrep requests wide w p [ ] m w
∧
[ ] = [ ]
∧
∧
0 ≤ if stream_errorlibc_stream_statew p then 1 else 0 < 2 ^ 32
∧

split ; exact Ho |

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
args :
listarg
p :
file :
s :
R.state
m :
Habi :
Hfile :
libc_file_atw p = Somefile
Ho :
stream_openlibc_stream_modelrep requests wide m w p info
⊢
stream_framelibc_stream_modelrep requests wide p w w
∧
stream_delegateslibc_stream_modelrep requests wide w p [ ] m w
∧
[ ] = [ ]
∧
∧
0 ≤ if stream_errorlibc_stream_statew p then 1 else 0 < 2 ^ 32
∧

split ; apply libc_stream_frame_refl |

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
args :
listarg
p :
file :
s :
R.state
m :
Habi :
Hfile :
libc_file_atw p = Somefile
Ho :
stream_openlibc_stream_modelrep requests wide m w p info
⊢
stream_delegateslibc_stream_modelrep requests wide w p [ ] m w
∧
[ ] = [ ]
∧
∧
0 ≤ if stream_errorlibc_stream_statew p then 1 else 0 < 2 ^ 32
∧

split ; apply libc_stream_delegates_refl ; exact Hr |

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
args :
listarg
p :
file :
s :
R.state
m :
Habi :
Hfile :
libc_file_atw p = Somefile
Ho :
stream_openlibc_stream_modelrep requests wide m w p info
⊢
[ ] = [ ]
∧
∧
0 ≤ if stream_errorlibc_stream_statew p then 1 else 0 < 2 ^ 32
∧

split ; reflexivity |

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
args :
listarg
p :
file :
s :
R.state
m :
Habi :
Hfile :
libc_file_atw p = Somefile
Ho :
stream_openlibc_stream_modelrep requests wide m w p info
⊢
∧
0 ≤ if stream_errorlibc_stream_statew p then 1 else 0 < 2 ^ 32
∧

split ; reflexivity |

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
args :
listarg
p :
file :
s :
R.state
m :
Habi :
Hfile :
libc_file_atw p = Somefile
Ho :
stream_openlibc_stream_modelrep requests wide m w p info
⊢
0 ≤ if stream_errorlibc_stream_statew p then 1 else 0 < 2 ^ 32
∧

destruct Ho as _ & _ & Hstate & _

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
args :
listarg
p :
file :
s :
R.state
m :
Habi :
Hfile :
libc_file_atw p = Somefile
Hstate :
⊢
0 ≤ if stream_errorlibc_stream_statew p then 1 else 0 < 2 ^ 32
∧

rewrite Hstate

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
args :
listarg
p :
file :
s :
R.state
m :
Habi :
Hfile :
libc_file_atw p = Somefile
Hstate :
⊢
0 ≤ if stream_errorlibc_stream_statew p then 1 else 0 < 2 ^ 32
∧

cbn [ stream_state_at libc_stream_model ]

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
args :
listarg
p :
file :
s :
R.state
m :
Habi :
Hfile :
libc_file_atw p = Somefile
Hstate :
⊢
0 ≤ if stream_errorlibc_stream_statew p then 1 else 0 < 2 ^ 32
∧

destruct stream_errorlibc_stream_statew p ; split ; lia | split ; congruence | lia | split ; congruence

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros rep requests wide r args p file s m w Habi Hr Hfile
destruct libc_stream_openrep requests wide m w p file Hr Hfile as info Ho
eapply S.ferror_return with born := [ ]
–exact Habi
–exists p, info
auto
–eapply query_unchanged_prefix ; eauto
–exists p, info, if stream_errorlibc_stream_statew p then 1 else 0
split ; reflexivity |
split ; exact proj1proj2Ho |
split ; exact Ho |
split ; apply libc_stream_frame_refl |
split ; apply libc_stream_delegates_refl ; exact Hr |
split ; reflexivity |
split ; reflexivity |
destruct Ho as _ & _ & Hstate & _
rewrite Hstate
destruct stream_errorlibc_stream_statew p ; split ; lia | split ; congruence | lia | split ; congruence

Physical pending, not the logical FIFO length, is the query result.

399Theorem fpending_unchanged
∀ rep requests wide r args p file s m w
Proof 40 steps Qed
intros rep requests wide r args p file s m w Habi Hr Hfile
destruct libc_stream_openrep requests wide m w p file Hr Hfile as info Ho
assert Hpending : stream_pendinginfo = file_pendingfile
{destruct Ho as _ & Hinfo & _
change libc_stream_atw p = Someinfo in Hinfo
unfold libc_stream_at in Hinfo
rewrite Hfile in Hinfo
injection Hinfo as ←
reflexivity
assert Hrange : 0 ≤ file_pendingfile < 2 ^ 64
{destruct Ho as _ & _ & _ & _ Hrange & _
rewrite Hpending in Hrange
exact Hrange
eapply E.invoke_normal with born := [ ]
–exact Habi
–exists p, info
auto
–exact query_unchanged_prefixrep requests wide p file s m w Hr Hfile
–exists p, info
split ; reflexivity |
split ; exact proj1proj2Ho |
split ; exact Ho |
split ; apply libc_stream_frame_refl |
split ; apply libc_stream_delegates_refl ; exact Hr |
split ; reflexivity |
rewrite Hpending
reflexivity
–intros why Hbad
discriminate
–intros values Hvalues
injection Hvalues as ←
split
+exists WIntfile_pendingfile
split ; reflexivity |
simpl
rewrite Z.mod_small by exact Hrange
reflexivity
+constructor ; exact I | constructor
–intros status Hbad
discriminate

The old exact errno lookup is still admitted with closed stdout.

429Theorem errno_after_close
∀ rep r args s m w
E.invokeC.errno_contractrep r args [ ] s m w [ ] CallReturnWPtrlibc_errnofstw s m w
Explore proof 4 tactics

Initial goal

⊢
∀rep : mem → libc_world → Prop r : call_result args : listarg s : R.state m : mem w : libc_world, errno_location_abir args → libc_stream_readyrep m w → E.invokeC.errno_contractrep r args [ ] s m w [ ] CallReturnWPtrlibc_errnofstw s m w

intros

rep :
mem → libc_world → Prop
args :
listarg
s :
R.state
m :
⊢
E.invokeC.errno_contractrep r args [ ] s m w [ ] CallReturnWPtrlibc_errnofstw s m w

apply C.errno_admitted ; exact H |

rep :
mem → libc_world → Prop
args :
listarg
s :
R.state
m :
⊢
libc_readyrep m w

apply libc_stream_ready_libc

rep :
mem → libc_world → Prop
args :
listarg
s :
R.state
m :

exact H0

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros
apply C.errno_admitted ; exact H |
exact H0

Returning and resource-ending output expose the same represented world/frame/provenance cutpoint. Normal-result facts are separate.

437Theorem output_world
∀ rep requests wide api r args xs s m w trace ending s′ m′ w′
E.invokeoutput_contractapi libc_stream_modelrep requests wide libc_stdout r args xs s m w trace ending s′ m′ w′
libc_stream_readyrep m′ w′ ∧ libc_stream_frameoutput_targetapi libc_stdout w xs w w′ ∧ ∃born, stream_delegateslibc_stream_modelrep requests wide w output_targetapi libc_stdout w xs born m′ w′ ∧ stream_aux_framelibc_stream_modelrep requests wide m w output_targetapi libc_stdout w xs m′
Explore proof 6 tactics

Initial goal

⊢
∀rep : mem → libc_world → Prop requests : libc_world → ptr → Z → Z → Prop wide : libc_world → ptr → stream_state → stream_state → bool → Prop api : narrow_api r : call_result args : listarg xs : listword s : R.state m : mem w : libc_world trace : listevent ending : call_end s′ : R.state m′ : mem w′ : libc_world, E.invokeoutput_contractapi libc_stream_modelrep requests wide libc_stdout r args xs s m w trace ending s′ m′ w′ → libc_stream_readyrep m′ w′ ∧ libc_stream_frameoutput_targetapi libc_stdout w xs w w′ ∧ ∃born : listZ, stream_delegateslibc_stream_modelrep requests wide w output_targetapi libc_stdout w xs born m′ w′ ∧ stream_aux_framelibc_stream_modelrep requests wide m w output_targetapi libc_stdout w xs m′

intros rep requests wide api r args xs s m w trace ending s′ m′ w′ Hcall

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
args :
listarg
xs :
listword
s :
R.state
m :
trace :
listevent
ending :
s′ :
R.state
m′ :
Hcall :
E.invokeoutput_contractapi libc_stream_modelrep requests wide libc_stdout r args xs s m w trace ending s′ m′ w′
⊢
libc_stream_readyrep m′ w′ ∧ libc_stream_frameoutput_targetapi libc_stdout w xs w w′ ∧ ∃born : listZ, stream_delegateslibc_stream_modelrep requests wide w output_targetapi libc_stdout w xs born m′ w′ ∧ stream_aux_framelibc_stream_modelrep requests wide m w output_targetapi libc_stdout w xs m′

destruct E.invoke_prefix_ _ _ _ _ _ _ _ _ _ _ _ _ Hcall as born & He & info & info′ & bytes & actions & tail & Hinfo & Htext & Hbytes & Hrun & Hopen & Hid & Hframe & Hdelegate & Htrace & Haux

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
args :
listarg
xs :
listword
s :
R.state
m :
trace :
listevent
ending :
s′ :
R.state
m′ :
Hcall :
E.invokeoutput_contractapi libc_stream_modelrep requests wide libc_stdout r args xs s m w trace ending s′ m′ w′
born :
listZ
info, info′ :
bytes :
listZ
actions :
tail :
listZ
Hinfo :
stream_atlibc_stream_modelrep requests wide w output_targetapi libc_stdout w xs = Someinfo
Htext :
output_textapi m xs bytes
Hbytes :
bytes = acceptedactions ++ tail
Hopen :
stream_openlibc_stream_modelrep requests wide m′ w′ output_targetapi libc_stdout w xs info′
Hframe :
Hdelegate :
stream_delegateslibc_stream_modelrep requests wide w output_targetapi libc_stdout w xs born m′ w′
Htrace :
trace = [ ] ∧ acceptedactions = [ ] ∨ trace = StreamBytesstream_identifierinfo acceptedactions
Haux :
⊢
libc_stream_readyrep m′ w′ ∧ libc_stream_frameoutput_targetapi libc_stdout w xs w w′ ∧ ∃born0 : listZ, stream_delegateslibc_stream_modelrep requests wide w output_targetapi libc_stdout w xs born0 m′ w′ ∧ stream_aux_framelibc_stream_modelrep requests wide m w output_targetapi libc_stdout w xs m′

split ; exact proj1Hopen |

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
args :
listarg
xs :
listword
s :
R.state
m :
trace :
listevent
ending :
s′ :
R.state
m′ :
Hcall :
E.invokeoutput_contractapi libc_stream_modelrep requests wide libc_stdout r args xs s m w trace ending s′ m′ w′
born :
listZ
info, info′ :
bytes :
listZ
actions :
tail :
listZ
Hinfo :
stream_atlibc_stream_modelrep requests wide w output_targetapi libc_stdout w xs = Someinfo
Htext :
output_textapi m xs bytes
Hbytes :
bytes = acceptedactions ++ tail
Hopen :
stream_openlibc_stream_modelrep requests wide m′ w′ output_targetapi libc_stdout w xs info′
Hframe :
Hdelegate :
stream_delegateslibc_stream_modelrep requests wide w output_targetapi libc_stdout w xs born m′ w′
Htrace :
trace = [ ] ∧ acceptedactions = [ ] ∨ trace = StreamBytesstream_identifierinfo acceptedactions
Haux :
⊢
libc_stream_frameoutput_targetapi libc_stdout w xs w w′ ∧ ∃born0 : listZ, stream_delegateslibc_stream_modelrep requests wide w output_targetapi libc_stdout w xs born0 m′ w′ ∧ stream_aux_framelibc_stream_modelrep requests wide m w output_targetapi libc_stdout w xs m′

split ; exact Hframe |

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
args :
listarg
xs :
listword
s :
R.state
m :
trace :
listevent
ending :
s′ :
R.state
m′ :
Hcall :
E.invokeoutput_contractapi libc_stream_modelrep requests wide libc_stdout r args xs s m w trace ending s′ m′ w′
born :
listZ
info, info′ :
bytes :
listZ
actions :
tail :
listZ
Hinfo :
stream_atlibc_stream_modelrep requests wide w output_targetapi libc_stdout w xs = Someinfo
Htext :
output_textapi m xs bytes
Hbytes :
bytes = acceptedactions ++ tail
Hopen :
stream_openlibc_stream_modelrep requests wide m′ w′ output_targetapi libc_stdout w xs info′
Hframe :
Hdelegate :
stream_delegateslibc_stream_modelrep requests wide w output_targetapi libc_stdout w xs born m′ w′
Htrace :
trace = [ ] ∧ acceptedactions = [ ] ∨ trace = StreamBytesstream_identifierinfo acceptedactions
Haux :
⊢
∃born0 : listZ, stream_delegateslibc_stream_modelrep requests wide w output_targetapi libc_stdout w xs born0 m′ w′ ∧ stream_aux_framelibc_stream_modelrep requests wide m w output_targetapi libc_stdout w xs m′

exists born

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
args :
listarg
xs :
listword
s :
R.state
m :
trace :
listevent
ending :
s′ :
R.state
m′ :
Hcall :
E.invokeoutput_contractapi libc_stream_modelrep requests wide libc_stdout r args xs s m w trace ending s′ m′ w′
born :
listZ
info, info′ :
bytes :
listZ
actions :
tail :
listZ
Hinfo :
stream_atlibc_stream_modelrep requests wide w output_targetapi libc_stdout w xs = Someinfo
Htext :
output_textapi m xs bytes
Hbytes :
bytes = acceptedactions ++ tail
Hopen :
stream_openlibc_stream_modelrep requests wide m′ w′ output_targetapi libc_stdout w xs info′
Hframe :
Hdelegate :
stream_delegateslibc_stream_modelrep requests wide w output_targetapi libc_stdout w xs born m′ w′
Htrace :
trace = [ ] ∧ acceptedactions = [ ] ∨ trace = StreamBytesstream_identifierinfo acceptedactions
Haux :
⊢
stream_delegateslibc_stream_modelrep requests wide w output_targetapi libc_stdout w xs born m′ w′ ∧ stream_aux_framelibc_stream_modelrep requests wide m w output_targetapi libc_stdout w xs m′

auto

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros rep requests wide api r args xs s m w trace ending s′ m′ w′ Hcall
destruct E.invoke_prefix_ _ _ _ _ _ _ _ _ _ _ _ _ Hcall as born & He & info & info′ & bytes & actions & tail & Hinfo & Htext & Hbytes & Hrun & Hopen & Hid & Hframe & Hdelegate & Htrace & Haux
split ; exact proj1Hopen |
split ; exact Hframe |
exists born
auto

Ordinary narrow output results remain canonical, including errors.

456Theorem output_returned
∀ rep requests wide api r args xs s m w trace values s′ m′ w′
E.invokeoutput_contractapi libc_stream_modelrep requests wide libc_stdout r args xs s m w trace CallReturnvalues s′ m′ w′
∃result, values = WIntresult ∧ 0 ≤ result < 2 ^ 32
Explore proof 2 tactics

Initial goal

⊢
∀rep : mem → libc_world → Prop requests : libc_world → ptr → Z → Z → Prop wide : libc_world → ptr → stream_state → stream_state → bool → Prop api : narrow_api r : call_result args : listarg xs : listword s : R.state m : mem w : libc_world trace : listevent values : listword s′ : R.state m′ : mem w′ : libc_world, E.invokeoutput_contractapi libc_stream_modelrep requests wide libc_stdout r args xs s m w trace CallReturnvalues s′ m′ w′ → ∃result : Z, values = WIntresult ∧ 0 ≤ result < 2 ^ 32

intros

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
args :
listarg
xs :
listword
s :
R.state
m :
trace :
listevent
values :
listword
s′ :
R.state
m′ :
H :
E.invokeoutput_contractapi libc_stream_modelrep requests wide libc_stdout r args xs s m w trace CallReturnvalues s′ m′ w′
⊢
∃result : Z, values = WIntresult ∧ 0 ≤ result < 2 ^ 32

eapply F.output_returned ; eauto

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros
eapply F.output_returned ; eauto

Logical controls, not a claim that these tiny objects are native FILEs. Physical pending counts deliberately differ from FIFO length.

466Module LibcStreamChecks

Static handles live in separate existing fixture objects.

471Definition out_file ≔
mkLibcFilemkPtr1024 Obj1024 7 [ ] [ ] [ ]

Stderr has a different physical count.

473Definition err_file ≔
mkLibcFilemkPtr2048 Obj2048 3 [ ] [ ] [ ]

Close retires stdout after settling its two logical obligations; physical pending is deliberately not the FIFO length.

Neither stream's private zero-length source exposes errno authority.

485Lemma empty_file_errno
∀ a n
a ≠ 5120
Explore proof 5 tactics

Initial goal

⊢
∀a n : Z, a ≠ 5120 → file_errno_apartconversion_mem ptr_addr ≔ 5120; ptr_cap ≔ Obj5120 file_handle ≔ ptr_addr ≔ a; ptr_cap ≔ Obja; file_pending ≔ n; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ]

intros a n Hne

a, n :
Z
Hne :
a ≠ 5120
⊢
file_errno_apartconversion_mem ptr_addr ≔ 5120; ptr_cap ≔ Obj5120 file_handle ≔ ptr_addr ≔ a; ptr_cap ≔ Obja; file_pending ≔ n; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ]

split ; intros root |

a, n :
Z
Hne :
a ≠ 5120
⊢
∀base : Z, ptr_capptr_addr ≔ 5120; ptr_cap ≔ Obj5120 = Objbase ∨ ptr_capptr_addr ≔ 5120; ptr_cap ≔ Obj5120 = Robase → ¬Inbase file_ownedfile_handle ≔ ptr_addr ≔ a; ptr_cap ≔ Obja; file_pending ≔ n; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] ∧ ¬available_capfile_sourcesfile_handle ≔ ptr_addr ≔ a; ptr_cap ≔ Obja; file_pending ≔ n; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] [ ] conversion_mem Objbase ∧ ¬available_capfile_sourcesfile_handle ≔ ptr_addr ≔ a; ptr_cap ≔ Obja; file_pending ≔ n; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] [ ] conversion_mem Robase

intros base Hbase | Hbase ; injection Hbase as <-| discriminate

a, n :
Z
Hne :
a ≠ 5120
⊢
¬In5120 file_ownedfile_handle ≔ ptr_addr ≔ a; ptr_cap ≔ Obja; file_pending ≔ n; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] ∧ ¬available_capfile_sourcesfile_handle ≔ ptr_addr ≔ a; ptr_cap ≔ Obja; file_pending ≔ n; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] [ ] conversion_mem Obj5120 ∧ ¬available_capfile_sourcesfile_handle ≔ ptr_addr ≔ a; ptr_cap ≔ Obja; file_pending ≔ n; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] [ ] conversion_mem Ro5120

split ; intros |

a, n :
Z
Hne :
a ≠ 5120
⊢
¬available_capfile_sourcesfile_handle ≔ ptr_addr ≔ a; ptr_cap ≔ Obja; file_pending ≔ n; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] [ ] conversion_mem Obj5120 ∧ ¬available_capfile_sourcesfile_handle ≔ ptr_addr ≔ a; ptr_cap ≔ Obja; file_pending ≔ n; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] [ ] conversion_mem Ro5120

split ; intros Hnone | source & Hin & Hcap | source & addr & Hin & Ha & Hsize & _ | b & & _ ; try discriminate ; simpl in Hin ; destruct Hin as [ <-| [ ] ] ; simpl in * ; congruence | unfold span_contains in Ha ; simpl in Ha ; lia | discriminate | unfold span_contains in Ha ; simpl in Ha ; lia

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros a n Hne
split ; intros root |
intros base Hbase | Hbase ; injection Hbase as <-| discriminate
split ; intros |
split ; intros Hnone | source & Hin & Hcap | source & addr & Hin & Ha & Hsize & _ | b & & _ ; try discriminate ; simpl in Hin ; destruct Hin as [ <-| [ ] ] ; simpl in * ; congruence | unfold span_contains in Ha ; simpl in Ha ; lia | discriminate | unfold span_contains in Ha ; simpl in Ha ; lia

Both represented open FILE entries satisfy their structural slice.

Explore proof 15 tactics

Initial goal

assert Hread : ∀a, a = 1024 ∨ a = 2048 → readable_bytesconversion_mem mkPtra Obja 1

2 open

⊢
∀a : Z, a = 1024 ∨ a = 2048 → readable_bytesconversion_mem ptr_addr ≔ a; ptr_cap ≔ Obja 1
focused goal
Hread :
∀a : Z, a = 1024 ∨ a = 2048 → readable_bytesconversion_mem ptr_addr ≔ a; ptr_cap ≔ Obja 1

{intros a → | → ; split ; simpl ; lia | | simpl ; lia |

3 open

⊢
∃base : Z reg : region, ptr_capptr_addr ≔ 1024; ptr_cap ≔ Obj1024 = Objbase ∨ ptr_capptr_addr ≔ 1024; ptr_cap ≔ Obj1024 = Robase ∧ object_regionbase m_regionsconversion_mem = Somereg ∧ r_lifereg = Live ∧ access_resconversion_mem ptr_addrptr_addr ≔ 1024; ptr_cap ≔ Obj1024 ptr_capptr_addr ≔ 1024; ptr_cap ≔ Obj1024 1 Read 1 = Someok ∧ ∀i : Z, 0 ≤ i < 1 → 0 ≤ m_bytesconversion_mem ptr_addrptr_addr ≔ 1024; ptr_cap ≔ Obj1024 + i < 256
focused goal
⊢
∃base : Z reg : region, ptr_capptr_addr ≔ 2048; ptr_cap ≔ Obj2048 = Objbase ∨ ptr_capptr_addr ≔ 2048; ptr_cap ≔ Obj2048 = Robase ∧ object_regionbase m_regionsconversion_mem = Somereg ∧ r_lifereg = Live ∧ access_resconversion_mem ptr_addrptr_addr ≔ 2048; ptr_cap ≔ Obj2048 ptr_capptr_addr ≔ 2048; ptr_cap ≔ Obj2048 1 Read 1 = Someok ∧ ∀i : Z, 0 ≤ i < 1 → 0 ≤ m_bytesconversion_mem ptr_addrptr_addr ≔ 2048; ptr_cap ≔ Obj2048 + i < 256
deferred goal
Hread :
∀a : Z, a = 1024 ∨ a = 2048 → readable_bytesconversion_mem ptr_addr ≔ a; ptr_cap ≔ Obja 1

all: split

5 open

⊢
∃base : Z reg : region, ptr_capptr_addr ≔ 1024; ptr_cap ≔ Obj1024 = Objbase ∨ ptr_capptr_addr ≔ 1024; ptr_cap ≔ Obj1024 = Robase ∧ object_regionbase m_regionsconversion_mem = Somereg ∧ r_lifereg = Live
focused goal
⊢
access_resconversion_mem ptr_addrptr_addr ≔ 1024; ptr_cap ≔ Obj1024 ptr_capptr_addr ≔ 1024; ptr_cap ≔ Obj1024 1 Read 1 = Someok ∧ ∀i : Z, 0 ≤ i < 1 → 0 ≤ m_bytesconversion_mem ptr_addrptr_addr ≔ 1024; ptr_cap ≔ Obj1024 + i < 256
focused goal
⊢
∃base : Z reg : region, ptr_capptr_addr ≔ 2048; ptr_cap ≔ Obj2048 = Objbase ∨ ptr_capptr_addr ≔ 2048; ptr_cap ≔ Obj2048 = Robase ∧ object_regionbase m_regionsconversion_mem = Somereg ∧ r_lifereg = Live
focused goal
⊢
access_resconversion_mem ptr_addrptr_addr ≔ 2048; ptr_cap ≔ Obj2048 ptr_capptr_addr ≔ 2048; ptr_cap ≔ Obj2048 1 Read 1 = Someok ∧ ∀i : Z, 0 ≤ i < 1 → 0 ≤ m_bytesconversion_mem ptr_addrptr_addr ≔ 2048; ptr_cap ≔ Obj2048 + i < 256
deferred goal
Hread :
∀a : Z, a = 1024 ∨ a = 2048 → readable_bytesconversion_mem ptr_addr ≔ a; ptr_cap ≔ Obja 1

1: {exists 1024, mkRegion1024 1056 GlobalData Live

5 open

⊢
ptr_capptr_addr ≔ 1024; ptr_cap ≔ Obj1024 = Obj1024 ∨ ptr_capptr_addr ≔ 1024; ptr_cap ≔ Obj1024 = Ro1024 ∧ object_region1024 m_regionsconversion_mem = Somer_base ≔ 1024; r_end ≔ 1056; r_kind ≔ GlobalData; r_life ≔ Live ∧ r_lifer_base ≔ 1024; r_end ≔ 1056; r_kind ≔ GlobalData; r_life ≔ Live = Live
deferred goal
⊢
access_resconversion_mem ptr_addrptr_addr ≔ 1024; ptr_cap ≔ Obj1024 ptr_capptr_addr ≔ 1024; ptr_cap ≔ Obj1024 1 Read 1 = Someok ∧ ∀i : Z, 0 ≤ i < 1 → 0 ≤ m_bytesconversion_mem ptr_addrptr_addr ≔ 1024; ptr_cap ≔ Obj1024 + i < 256
deferred goal
⊢
∃base : Z reg : region, ptr_capptr_addr ≔ 2048; ptr_cap ≔ Obj2048 = Objbase ∨ ptr_capptr_addr ≔ 2048; ptr_cap ≔ Obj2048 = Robase ∧ object_regionbase m_regionsconversion_mem = Somereg ∧ r_lifereg = Live
deferred goal
⊢
access_resconversion_mem ptr_addrptr_addr ≔ 2048; ptr_cap ≔ Obj2048 ptr_capptr_addr ≔ 2048; ptr_cap ≔ Obj2048 1 Read 1 = Someok ∧ ∀i : Z, 0 ≤ i < 1 → 0 ≤ m_bytesconversion_mem ptr_addrptr_addr ≔ 2048; ptr_cap ≔ Obj2048 + i < 256
deferred goal
Hread :
∀a : Z, a = 1024 ∨ a = 2048 → readable_bytesconversion_mem ptr_addr ≔ a; ptr_cap ≔ Obja 1

auto

4 open

deferred goal
⊢
access_resconversion_mem ptr_addrptr_addr ≔ 1024; ptr_cap ≔ Obj1024 ptr_capptr_addr ≔ 1024; ptr_cap ≔ Obj1024 1 Read 1 = Someok ∧ ∀i : Z, 0 ≤ i < 1 → 0 ≤ m_bytesconversion_mem ptr_addrptr_addr ≔ 1024; ptr_cap ≔ Obj1024 + i < 256
deferred goal
⊢
∃base : Z reg : region, ptr_capptr_addr ≔ 2048; ptr_cap ≔ Obj2048 = Objbase ∨ ptr_capptr_addr ≔ 2048; ptr_cap ≔ Obj2048 = Robase ∧ object_regionbase m_regionsconversion_mem = Somereg ∧ r_lifereg = Live
deferred goal
⊢
access_resconversion_mem ptr_addrptr_addr ≔ 2048; ptr_cap ≔ Obj2048 ptr_capptr_addr ≔ 2048; ptr_cap ≔ Obj2048 1 Read 1 = Someok ∧ ∀i : Z, 0 ≤ i < 1 → 0 ≤ m_bytesconversion_mem ptr_addrptr_addr ≔ 2048; ptr_cap ≔ Obj2048 + i < 256
deferred goal
Hread :
∀a : Z, a = 1024 ∨ a = 2048 → readable_bytesconversion_mem ptr_addr ≔ a; ptr_cap ≔ Obja 1

2: {exists 2048, mkRegion2048 2056 Stack Live

4 open

⊢
ptr_capptr_addr ≔ 2048; ptr_cap ≔ Obj2048 = Obj2048 ∨ ptr_capptr_addr ≔ 2048; ptr_cap ≔ Obj2048 = Ro2048 ∧ object_region2048 m_regionsconversion_mem = Somer_base ≔ 2048; r_end ≔ 2056; r_kind ≔ Stack; r_life ≔ Live ∧ r_lifer_base ≔ 2048; r_end ≔ 2056; r_kind ≔ Stack; r_life ≔ Live = Live
deferred goal
⊢
access_resconversion_mem ptr_addrptr_addr ≔ 1024; ptr_cap ≔ Obj1024 ptr_capptr_addr ≔ 1024; ptr_cap ≔ Obj1024 1 Read 1 = Someok ∧ ∀i : Z, 0 ≤ i < 1 → 0 ≤ m_bytesconversion_mem ptr_addrptr_addr ≔ 1024; ptr_cap ≔ Obj1024 + i < 256
deferred goal
⊢
access_resconversion_mem ptr_addrptr_addr ≔ 2048; ptr_cap ≔ Obj2048 ptr_capptr_addr ≔ 2048; ptr_cap ≔ Obj2048 1 Read 1 = Someok ∧ ∀i : Z, 0 ≤ i < 1 → 0 ≤ m_bytesconversion_mem ptr_addrptr_addr ≔ 2048; ptr_cap ≔ Obj2048 + i < 256
deferred goal
Hread :
∀a : Z, a = 1024 ∨ a = 2048 → readable_bytesconversion_mem ptr_addr ≔ a; ptr_cap ≔ Obja 1

auto

3 open

deferred goal
⊢
access_resconversion_mem ptr_addrptr_addr ≔ 1024; ptr_cap ≔ Obj1024 ptr_capptr_addr ≔ 1024; ptr_cap ≔ Obj1024 1 Read 1 = Someok ∧ ∀i : Z, 0 ≤ i < 1 → 0 ≤ m_bytesconversion_mem ptr_addrptr_addr ≔ 1024; ptr_cap ≔ Obj1024 + i < 256
deferred goal
⊢
access_resconversion_mem ptr_addrptr_addr ≔ 2048; ptr_cap ≔ Obj2048 ptr_capptr_addr ≔ 2048; ptr_cap ≔ Obj2048 1 Read 1 = Someok ∧ ∀i : Z, 0 ≤ i < 1 → 0 ≤ m_bytesconversion_mem ptr_addrptr_addr ≔ 2048; ptr_cap ≔ Obj2048 + i < 256
deferred goal
Hread :
∀a : Z, a = 1024 ∨ a = 2048 → readable_bytesconversion_mem ptr_addr ≔ a; ptr_cap ≔ Obja 1

all: split ; reflexivity |

3 open

⊢
∀i : Z, 0 ≤ i < 1 → 0 ≤ m_bytesconversion_mem ptr_addrptr_addr ≔ 1024; ptr_cap ≔ Obj1024 + i < 256
focused goal
⊢
∀i : Z, 0 ≤ i < 1 → 0 ≤ m_bytesconversion_mem ptr_addrptr_addr ≔ 2048; ptr_cap ≔ Obj2048 + i < 256
deferred goal
Hread :
∀a : Z, a = 1024 ∨ a = 2048 → readable_bytesconversion_mem ptr_addr ≔ a; ptr_cap ≔ Obja 1

all: intros i Hi ; assert i = 0 as → by lia ; vm_compute ; split ; congruence

deferred goal
Hread :
∀a : Z, a = 1024 ∨ a = 2048 → readable_bytesconversion_mem ptr_addr ≔ a; ptr_cap ≔ Obja 1

split ; unfold out_file , err_file , libc_file_ready ; split ; discriminate | | discriminate |

2 open

Hread :
∀a : Z, a = 1024 ∨ a = 2048 → readable_bytesconversion_mem ptr_addr ≔ a; ptr_cap ≔ Obja 1
⊢
readable_bytesconversion_mem file_handlefile_handle ≔ ptr_addr ≔ 1024; ptr_cap ≔ Obj1024; file_pending ≔ 7; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] 1 ∧ 0 ≤ file_pendingfile_handle ≔ ptr_addr ≔ 1024; ptr_cap ≔ Obj1024; file_pending ≔ 7; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] < 2 ^ 64 ∧ Forallwritable_spanconversion_mem file_rootsfile_handle ≔ ptr_addr ≔ 1024; ptr_cap ≔ Obj1024; file_pending ≔ 7; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] ∧ Forallλsource : span ⇒ readable_bytesconversion_mem span_ptrsource span_sizesource file_readsfile_handle ≔ ptr_addr ≔ 1024; ptr_cap ≔ Obj1024; file_pending ≔ 7; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] ∧ Foralllocale_heapconversion_mem file_ownedfile_handle ≔ ptr_addr ≔ 1024; ptr_cap ≔ Obj1024; file_pending ≔ 7; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] ∧ file_errno_apartconversion_mem ptr_addr ≔ 5120; ptr_cap ≔ Obj5120 file_handle ≔ ptr_addr ≔ 1024; ptr_cap ≔ Obj1024; file_pending ≔ 7; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ]
focused goal
Hread :
∀a : Z, a = 1024 ∨ a = 2048 → readable_bytesconversion_mem ptr_addr ≔ a; ptr_cap ≔ Obja 1
⊢
readable_bytesconversion_mem file_handlefile_handle ≔ ptr_addr ≔ 2048; ptr_cap ≔ Obj2048; file_pending ≔ 3; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] 1 ∧ 0 ≤ file_pendingfile_handle ≔ ptr_addr ≔ 2048; ptr_cap ≔ Obj2048; file_pending ≔ 3; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] < 2 ^ 64 ∧ Forallwritable_spanconversion_mem file_rootsfile_handle ≔ ptr_addr ≔ 2048; ptr_cap ≔ Obj2048; file_pending ≔ 3; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] ∧ Forallλsource : span ⇒ readable_bytesconversion_mem span_ptrsource span_sizesource file_readsfile_handle ≔ ptr_addr ≔ 2048; ptr_cap ≔ Obj2048; file_pending ≔ 3; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] ∧ Foralllocale_heapconversion_mem file_ownedfile_handle ≔ ptr_addr ≔ 2048; ptr_cap ≔ Obj2048; file_pending ≔ 3; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] ∧ file_errno_apartconversion_mem ptr_addr ≔ 5120; ptr_cap ≔ Obj5120 file_handle ≔ ptr_addr ≔ 2048; ptr_cap ≔ Obj2048; file_pending ≔ 3; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ]

all: split ; apply Hread ; auto |

2 open

Hread :
∀a : Z, a = 1024 ∨ a = 2048 → readable_bytesconversion_mem ptr_addr ≔ a; ptr_cap ≔ Obja 1
⊢
0 ≤ file_pendingfile_handle ≔ ptr_addr ≔ 1024; ptr_cap ≔ Obj1024; file_pending ≔ 7; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] < 2 ^ 64 ∧ Forallwritable_spanconversion_mem file_rootsfile_handle ≔ ptr_addr ≔ 1024; ptr_cap ≔ Obj1024; file_pending ≔ 7; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] ∧ Forallλsource : span ⇒ readable_bytesconversion_mem span_ptrsource span_sizesource file_readsfile_handle ≔ ptr_addr ≔ 1024; ptr_cap ≔ Obj1024; file_pending ≔ 7; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] ∧ Foralllocale_heapconversion_mem file_ownedfile_handle ≔ ptr_addr ≔ 1024; ptr_cap ≔ Obj1024; file_pending ≔ 7; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] ∧ file_errno_apartconversion_mem ptr_addr ≔ 5120; ptr_cap ≔ Obj5120 file_handle ≔ ptr_addr ≔ 1024; ptr_cap ≔ Obj1024; file_pending ≔ 7; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ]
focused goal
Hread :
∀a : Z, a = 1024 ∨ a = 2048 → readable_bytesconversion_mem ptr_addr ≔ a; ptr_cap ≔ Obja 1
⊢
0 ≤ file_pendingfile_handle ≔ ptr_addr ≔ 2048; ptr_cap ≔ Obj2048; file_pending ≔ 3; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] < 2 ^ 64 ∧ Forallwritable_spanconversion_mem file_rootsfile_handle ≔ ptr_addr ≔ 2048; ptr_cap ≔ Obj2048; file_pending ≔ 3; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] ∧ Forallλsource : span ⇒ readable_bytesconversion_mem span_ptrsource span_sizesource file_readsfile_handle ≔ ptr_addr ≔ 2048; ptr_cap ≔ Obj2048; file_pending ≔ 3; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] ∧ Foralllocale_heapconversion_mem file_ownedfile_handle ≔ ptr_addr ≔ 2048; ptr_cap ≔ Obj2048; file_pending ≔ 3; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] ∧ file_errno_apartconversion_mem ptr_addr ≔ 5120; ptr_cap ≔ Obj5120 file_handle ≔ ptr_addr ≔ 2048; ptr_cap ≔ Obj2048; file_pending ≔ 3; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ]

all: split ; simpl ; lia |

2 open

Hread :
∀a : Z, a = 1024 ∨ a = 2048 → readable_bytesconversion_mem ptr_addr ≔ a; ptr_cap ≔ Obja 1
⊢
Forallwritable_spanconversion_mem file_rootsfile_handle ≔ ptr_addr ≔ 1024; ptr_cap ≔ Obj1024; file_pending ≔ 7; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] ∧ Forallλsource : span ⇒ readable_bytesconversion_mem span_ptrsource span_sizesource file_readsfile_handle ≔ ptr_addr ≔ 1024; ptr_cap ≔ Obj1024; file_pending ≔ 7; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] ∧ Foralllocale_heapconversion_mem file_ownedfile_handle ≔ ptr_addr ≔ 1024; ptr_cap ≔ Obj1024; file_pending ≔ 7; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] ∧ file_errno_apartconversion_mem ptr_addr ≔ 5120; ptr_cap ≔ Obj5120 file_handle ≔ ptr_addr ≔ 1024; ptr_cap ≔ Obj1024; file_pending ≔ 7; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ]
focused goal
Hread :
∀a : Z, a = 1024 ∨ a = 2048 → readable_bytesconversion_mem ptr_addr ≔ a; ptr_cap ≔ Obja 1
⊢
Forallwritable_spanconversion_mem file_rootsfile_handle ≔ ptr_addr ≔ 2048; ptr_cap ≔ Obj2048; file_pending ≔ 3; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] ∧ Forallλsource : span ⇒ readable_bytesconversion_mem span_ptrsource span_sizesource file_readsfile_handle ≔ ptr_addr ≔ 2048; ptr_cap ≔ Obj2048; file_pending ≔ 3; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] ∧ Foralllocale_heapconversion_mem file_ownedfile_handle ≔ ptr_addr ≔ 2048; ptr_cap ≔ Obj2048; file_pending ≔ 3; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] ∧ file_errno_apartconversion_mem ptr_addr ≔ 5120; ptr_cap ≔ Obj5120 file_handle ≔ ptr_addr ≔ 2048; ptr_cap ≔ Obj2048; file_pending ≔ 3; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ]

all: split ; constructor |

2 open

Hread :
∀a : Z, a = 1024 ∨ a = 2048 → readable_bytesconversion_mem ptr_addr ≔ a; ptr_cap ≔ Obja 1
⊢
Forallλsource : span ⇒ readable_bytesconversion_mem span_ptrsource span_sizesource file_readsfile_handle ≔ ptr_addr ≔ 1024; ptr_cap ≔ Obj1024; file_pending ≔ 7; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] ∧ Foralllocale_heapconversion_mem file_ownedfile_handle ≔ ptr_addr ≔ 1024; ptr_cap ≔ Obj1024; file_pending ≔ 7; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] ∧ file_errno_apartconversion_mem ptr_addr ≔ 5120; ptr_cap ≔ Obj5120 file_handle ≔ ptr_addr ≔ 1024; ptr_cap ≔ Obj1024; file_pending ≔ 7; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ]
focused goal
Hread :
∀a : Z, a = 1024 ∨ a = 2048 → readable_bytesconversion_mem ptr_addr ≔ a; ptr_cap ≔ Obja 1
⊢
Forallλsource : span ⇒ readable_bytesconversion_mem span_ptrsource span_sizesource file_readsfile_handle ≔ ptr_addr ≔ 2048; ptr_cap ≔ Obj2048; file_pending ≔ 3; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] ∧ Foralllocale_heapconversion_mem file_ownedfile_handle ≔ ptr_addr ≔ 2048; ptr_cap ≔ Obj2048; file_pending ≔ 3; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] ∧ file_errno_apartconversion_mem ptr_addr ≔ 5120; ptr_cap ≔ Obj5120 file_handle ≔ ptr_addr ≔ 2048; ptr_cap ≔ Obj2048; file_pending ≔ 3; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ]

all: split ; constructor |

2 open

Hread :
∀a : Z, a = 1024 ∨ a = 2048 → readable_bytesconversion_mem ptr_addr ≔ a; ptr_cap ≔ Obja 1
⊢
Foralllocale_heapconversion_mem file_ownedfile_handle ≔ ptr_addr ≔ 1024; ptr_cap ≔ Obj1024; file_pending ≔ 7; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] ∧ file_errno_apartconversion_mem ptr_addr ≔ 5120; ptr_cap ≔ Obj5120 file_handle ≔ ptr_addr ≔ 1024; ptr_cap ≔ Obj1024; file_pending ≔ 7; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ]
focused goal
Hread :
∀a : Z, a = 1024 ∨ a = 2048 → readable_bytesconversion_mem ptr_addr ≔ a; ptr_cap ≔ Obja 1
⊢
Foralllocale_heapconversion_mem file_ownedfile_handle ≔ ptr_addr ≔ 2048; ptr_cap ≔ Obj2048; file_pending ≔ 3; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ] ∧ file_errno_apartconversion_mem ptr_addr ≔ 5120; ptr_cap ≔ Obj5120 file_handle ≔ ptr_addr ≔ 2048; ptr_cap ≔ Obj2048; file_pending ≔ 3; file_reads ≔ [ ]; file_roots ≔ [ ]; file_owned ≔ [ ]

all: split ; constructor | apply empty_file_errno ; lia

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
assert Hread : ∀a, a = 1024 ∨ a = 2048 → readable_bytesconversion_mem mkPtra Obja 1
{intros a → | → ; split ; simpl ; lia | | simpl ; lia |
all: split
1: {exists 1024, mkRegion1024 1056 GlobalData Live
auto
2: {exists 2048, mkRegion2048 2056 Stack Live
auto
all: split ; reflexivity |
all: intros i Hi ; assert i = 0 as → by lia ; vm_compute ; split ; congruence
split ; unfold out_file , err_file , libc_file_ready ; split ; discriminate | | discriminate |
all: split ; apply Hread ; auto |
all: split ; simpl ; lia |
all: split ; constructor |
all: split ; constructor |
all: split ; constructor | apply empty_file_errno ; lia

Closed stdout is a nonempty represented state, not a vacuous pre.

519Lemma ready
∀ opened
Explore proof 17 tactics

Initial goal

⊢
∀opened : bool, libc_stream_readyλ_ : mem _ : libc_world ⇒ True conversion_mem worldopened

intros opened

opened :
bool
⊢

pose proof proj1conversion_pre1 ltac:lia as _ & Hl & _ & He & _

split ; exact I |

split ; exact Hl |

split ; exact He |

split ; split ; destruct opened ; repeat constructor ; lia | reflexivity |

split ; apply stdout_initial_wf |

split ; constructor |

split ; simpl ; lia |

split ; exact I |

split ; simpl ; lia |

split ; destruct opened ; reflexivity |

split ; intros _ ; exact proj1files_ready |

split ; intros _ ; exact proj2files_ready |

intros p file Hfile base Hin

opened :
bool
p :
file :
Hfile :
libc_file_atworldopened p = Somefile
base :
Z
Hin :
Inbase file_ownedfile
⊢
¬Inbase locale_ownedlibc_localefstworldopened ∧ ∀q : ptr other : libc_file, libc_file_atworldopened q = Someother → file_handleother ≠ file_handlefile → ¬Inbase file_ownedother ∧ ¬available_capspan_ptr ≔ libc_stdoutworldopened; span_size ≔ 0 :: span_ptr ≔ libc_stderrworldopened; span_size ≔ 0 :: locale_private_sourceslibc_localefstworldopened ++ if same_filep libc_stdoutworldopened then match libc_file_atworldopened libc_stderrworldopened with Someother ⇒ file_sourcesother | None ⇒ [ ] end else match libc_file_atworldopened libc_stdoutworldopened with Someother ⇒ file_sourcesother | None ⇒ [ ] end [ ] conversion_mem Objbase ∧ ¬available_capspan_ptr ≔ libc_stdoutworldopened; span_size ≔ 0 :: span_ptr ≔ libc_stderrworldopened; span_size ≔ 0 :: locale_private_sourceslibc_localefstworldopened ++ if same_filep libc_stdoutworldopened then match libc_file_atworldopened libc_stderrworldopened with Someother ⇒ file_sourcesother | None ⇒ [ ] end else match libc_file_atworldopened libc_stdoutworldopened with Someother ⇒ file_sourcesother | None ⇒ [ ] end [ ] conversion_mem Robase

unfold libc_file_at in Hfile

⊢
¬Inbase locale_ownedlibc_localefstworldopened ∧ ∀q : ptr other : libc_file, libc_file_atworldopened q = Someother → file_handleother ≠ file_handlefile → ¬Inbase file_ownedother ∧ ¬available_capspan_ptr ≔ libc_stdoutworldopened; span_size ≔ 0 :: span_ptr ≔ libc_stderrworldopened; span_size ≔ 0 :: locale_private_sourceslibc_localefstworldopened ++ if same_filep libc_stdoutworldopened then match libc_file_atworldopened libc_stderrworldopened with Someother ⇒ file_sourcesother | None ⇒ [ ] end else match libc_file_atworldopened libc_stdoutworldopened with Someother ⇒ file_sourcesother | None ⇒ [ ] end [ ] conversion_mem Objbase ∧ ¬available_capspan_ptr ≔ libc_stdoutworldopened; span_size ≔ 0 :: span_ptr ≔ libc_stderrworldopened; span_size ≔ 0 :: locale_private_sourceslibc_localefstworldopened ++ if same_filep libc_stdoutworldopened then match libc_file_atworldopened libc_stderrworldopened with Someother ⇒ file_sourcesother | None ⇒ [ ] end else match libc_file_atworldopened libc_stdoutworldopened with Someother ⇒ file_sourcesother | None ⇒ [ ] end [ ] conversion_mem Robase

destruct same_filep libc_stdoutworldopened ; destruct opened | destruct same_filep libc_stderrworldopened ; try discriminate ; injection Hfile as ← ; contradiction

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros opened
pose proof proj1conversion_pre1 ltac:lia as _ & Hl & _ & He & _
split ; exact I |
split ; exact Hl |
split ; exact He |
split ; split ; destruct opened ; repeat constructor ; lia | reflexivity |
split ; apply stdout_initial_wf |
split ; constructor |
split ; simpl ; lia |
split ; exact I |
split ; simpl ; lia |
split ; destruct opened ; reflexivity |
split ; intros _ ; exact proj1files_ready |
split ; intros _ ; exact proj2files_ready |
intros p file Hfile base Hin
unfold libc_file_at in Hfile
destruct same_filep libc_stdoutworldopened ; destruct opened | destruct same_filep libc_stderrworldopened ; try discriminate ; injection Hfile as ← ; contradiction

Same registered errno contract, after stdout closes, returns exactly the original capability and snapshot.

Explore proof 1 tactics

Initial goal

apply C.errno_after_close ; split ; left ; reflexivity | reflexivity | apply ready

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
apply C.errno_after_close ; split ; left ; reflexivity | reflexivity | apply ready

After stdout closes, stderr remains queryable with its own count.

544Example stderr_pending_after_close: M.E.invokefpending_contractlibc_stream_modelλ_ _ ⇒ True λ_ _ _ _ ⇒ False λ_ _ _ _ _ ⇒ False CVoid ArgP Const0 WPtrfile_handleerr_file InterpRuntime.start conversion_mem worldfalse [ ] CallReturnWInt3 InterpRuntime.start conversion_mem worldfalse
Explore proof 6 tactics

Initial goal

apply C.fpending_unchanged with file := err_file

3 open

focused goal
⊢
focused goal

–split ; left ; reflexivity |

3 open

⊢
∃v : value, ArgP Const0 = ArgP v
deferred goal
⊢
deferred goal

exists Const0

3 open

deferred goal
⊢
deferred goal

reflexivity

2 open

deferred goal
⊢
deferred goal

–apply ready

deferred goal

–reflexivity

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
apply C.fpending_unchanged with file := err_file
–split ; left ; reflexivity |
exists Const0
reflexivity
–apply ready
–reflexivity

Seven physical pending bytes are not the two logical obligations.

557Example stdout_pending_not_fifo: M.E.invokefpending_contractlibc_stream_modelλ_ _ ⇒ True λ_ _ _ _ ⇒ False λ_ _ _ _ _ ⇒ False CVoid ArgP Const0 WPtrfile_handleout_file InterpRuntime.start conversion_mem worldtrue [ ] CallReturnWInt7 InterpRuntime.start conversion_mem worldtrue
Explore proof 6 tactics

Initial goal

apply C.fpending_unchanged with file := out_file

3 open

focused goal
focused goal

–split ; left ; reflexivity |

3 open

⊢
∃v : value, ArgP Const0 = ArgP v
deferred goal
deferred goal

exists Const0

3 open

deferred goal
deferred goal

reflexivity

2 open

deferred goal
deferred goal

–apply ready

deferred goal

–reflexivity

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
apply C.fpending_unchanged with file := out_file
–split ; left ; reflexivity |
exists Const0
reflexivity
–apply ready
–reflexivity

A closed handle cannot be queried again, regardless of the registry.

570Example closed_query_rejected: ∀rep requests wide, ¬stream_call_prelibc_stream_modelrep requests wide WPtrfile_handleout_file conversion_mem worldfalse
Explore proof 3 tactics

Initial goal

⊢
∀rep : mem → libc_world → Prop requests : libc_world → ptr → Z → Z → Prop wide : libc_world → ptr → stream_state → stream_state → bool → Prop, ¬stream_call_prelibc_stream_modelrep requests wide WPtrfile_handleout_file conversion_mem worldfalse

intros rep requests wide p & info & Hxs & _ & Hinfo & _

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
p :
Hinfo :
stream_atlibc_stream_modelrep requests wide worldfalse p = Someinfo
⊢
False

injection Hxs as ←

rep :
mem → libc_world → Prop
requests :
libc_world → ptr → Z → Z → Prop
wide :
libc_world → ptr → stream_state → stream_state → bool → Prop
Hinfo :
stream_atlibc_stream_modelrep requests wide worldfalse ptr_addr ≔ 1024; ptr_cap ≔ Obj1024 = Someinfo
⊢
False

discriminate Hinfo

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros rep requests wide p & info & Hxs & _ & Hinfo & _
injection Hxs as ←
discriminate Hinfo

A genuine completed fclose, not merely a chosen closed fixture: error-discard settles the old FIFO and EOF still consumes the handle.

580Definition model ≔
libc_stream_modelλ_ _ ⇒ True λ_ _ _ _ ⇒ False λ_ _ _ _ _ ⇒ False
583Lemma close_settles
Explore proof 5 tactics

Initial goal

⊢
∀complete : bool, stream_settlementmodel worldtrue file_handleout_file orientation ≔ ByteOriented; outstanding ≔ 65; 66; stream_error ≔ true orientation ≔ ByteOriented; outstanding ≔ [ ]; stream_error ≔ true complete

intros

complete :
bool

exists Discard65; 66

complete :
bool
⊢
stream_runorientation ≔ ByteOriented; outstanding ≔ 65; 66; stream_error ≔ true Discard65; 66 orientation ≔ ByteOriented; outstanding ≔ [ ]; stream_error ≔ true ∧ acceptedDiscard65; 66 = [ ] ∧ complete = true → outstandingorientation ≔ ByteOriented; outstanding ≔ [ ]; stream_error ≔ true = [ ]

split

2 open

complete :
bool
focused goal
complete :
bool
⊢
acceptedDiscard65; 66 = [ ] ∧ complete = true → outstandingorientation ≔ ByteOriented; outstanding ≔ [ ]; stream_error ≔ true = [ ]

–eapply stream_next ; exact stream_discard65; 66 [ ] true ltac:discriminate | constructor

deferred goal
complete :
bool
⊢
acceptedDiscard65; 66 = [ ] ∧ complete = true → outstandingorientation ≔ ByteOriented; outstanding ≔ [ ]; stream_error ≔ true = [ ]

–split ; reflexivity

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros
exists Discard65; 66
split
–eapply stream_next ; exact stream_discard65; 66 [ ] true ltac:discriminate | constructor
–split ; reflexivity
Explore proof 1 tactics

Initial goal

repeat split ; reflexivity

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
repeat split ; reflexivity
Explore proof 2 tactics

Initial goal

split ; intros root |

⊢
∀source : span, Insource stream_sourcesmodel worldfalse file_handleout_file → ∃old : span, Inold stream_sourcesmodel worldtrue file_handleout_file ∧ ptr_capspan_ptrsource = ptr_capspan_ptrold ∨ ∃base : Z, Inbase [ ] ∧ ptr_capspan_ptrsource = Objbase ∨ ptr_capspan_ptrsource = Robase ∧ ∀base : Z, Inbase stream_releasesmodel worldfalse file_handleout_file → Inbase stream_releasesmodel worldtrue file_handleout_file ∨ Inbase [ ]

split ; intros x ; contradiction

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
split ; intros root |
split ; intros x ; contradiction
Explore proof 40 tactics

Initial goal

split ; | exact closed_errno

eapply M.E.invoke_normal with born := [ ]

7 open

focused goal
focused goal
focused goal
focused goal
focused goal
focused goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

–split ; left ; reflexivity |

7 open

⊢
∃v : value, ArgP Const0 = ArgP v
deferred goal
deferred goal
deferred goal
deferred goal
deferred goal
deferred goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

exists Const0

7 open

deferred goal
deferred goal
deferred goal
deferred goal
deferred goal
deferred goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

reflexivity

6 open

deferred goal
deferred goal
deferred goal
deferred goal
deferred goal
deferred goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

–apply libc_stream_admitted with file := out_file ; apply ready | reflexivity

5 open

deferred goal
deferred goal
deferred goal
deferred goal
deferred goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

–split ; constructor |

5 open

deferred goal
deferred goal
deferred goal
deferred goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

exists file_handleout_file, mkStreamInfo1 mkStreamByteOriented 65; 66 true 7, mkStreamByteOriented [ ] true

5 open

deferred goal
deferred goal
deferred goal
deferred goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

split ; reflexivity |

5 open

deferred goal
deferred goal
deferred goal
deferred goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

split ; reflexivity |

5 open

deferred goal
deferred goal
deferred goal
deferred goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

split ; apply close_settles |

5 open

deferred goal
deferred goal
deferred goal
deferred goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

split ; reflexivity |

5 open

deferred goal
deferred goal
deferred goal
deferred goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

split ; apply ready |

5 open

deferred goal
deferred goal
deferred goal
deferred goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

split ; apply close_frame |

5 open

deferred goal
deferred goal
deferred goal
deferred goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

split ; apply close_delegates |

5 open

deferred goal
deferred goal
deferred goal
deferred goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

split ; reflexivity |

5 open

deferred goal
deferred goal
deferred goal
deferred goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

split ; left ; reflexivity |

5 open

deferred goal
deferred goal
deferred goal
deferred goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

unfold stream_aux_frame

5 open

deferred goal
deferred goal
deferred goal
deferred goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

intros ; reflexivity

4 open

deferred goal
deferred goal
deferred goal
deferred goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

–exists file_handleout_file, mkStreamInfo1 mkStreamByteOriented 65; 66 true 7, mkStreamByteOriented [ ] true, stream_eof

4 open

deferred goal
deferred goal
deferred goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

split ; reflexivity |

4 open

deferred goal
deferred goal
deferred goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

split ; reflexivity |

4 open

deferred goal
deferred goal
deferred goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

split ; apply close_settles |

4 open

deferred goal
deferred goal
deferred goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

split ; reflexivity |

4 open

deferred goal
deferred goal
deferred goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

split ; right ; reflexivity |

4 open

deferred goal
deferred goal
deferred goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

split ; reflexivity |

4 open

deferred goal
deferred goal
deferred goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

split ; intros base |

4 open

deferred goal
deferred goal
deferred goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

split ; apply ready |

4 open

deferred goal
deferred goal
deferred goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

split ; apply close_frame |

4 open

deferred goal
deferred goal
deferred goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

auto

3 open

deferred goal
deferred goal
deferred goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

–intros why Hbad

3 open

deferred goal
deferred goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

discriminate

2 open

deferred goal
deferred goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

–intros values Hvalues

2 open

deferred goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

injection Hvalues as ←

2 open

deferred goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

split

3 open

focused goal
deferred goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

+exists WIntstream_eof

3 open

deferred goal
deferred goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

split ; reflexivity

2 open

deferred goal
deferred goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

+repeat constructor

deferred goal
⊢
∀status : Z, CallReturnWIntstream_eof = CallExitstatus → ∃before : listevent, [ ] = before ++ ProcessExitstatus

–intros status Hbad

status :
Z
⊢
∃before : listevent, [ ] = before ++ ProcessExitstatus

discriminate

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
split ; | exact closed_errno
eapply M.E.invoke_normal with born := [ ]
–split ; left ; reflexivity |
exists Const0
reflexivity
–apply libc_stream_admitted with file := out_file ; apply ready | reflexivity
–split ; constructor |
split ; reflexivity |
split ; reflexivity |
split ; apply close_settles |
split ; reflexivity |
split ; apply ready |
split ; apply close_frame |
split ; apply close_delegates |
split ; reflexivity |
split ; left ; reflexivity |
intros ; reflexivity
split ; reflexivity |
split ; reflexivity |
split ; apply close_settles |
split ; reflexivity |
split ; right ; reflexivity |
split ; reflexivity |
split ; intros base |
split ; apply ready |
split ; apply close_frame |
auto
–intros why Hbad
discriminate
–intros values Hvalues
injection Hvalues as ←
split
split ; reflexivity
+repeat constructor
–intros status Hbad
discriminate

The private-aux frame rejects clobbering a nontrivial errno aux, independently of the scalar byte-write permission.

632Example errno_aux_clobber_rejected: ∀m m′, in_objectm 5120 → m_auxm 5120 = Obj1024 → m_auxm′ 5120 = CNone → ¬stream_aux_framemodel m worldtrue file_handleout_file m′
Explore proof 6 tactics

Initial goal

⊢
∀m m′ : mem, in_objectm 5120 → m_auxm 5120 = Obj1024 → m_auxm′ 5120 = CNone → ¬stream_aux_framemodel m worldtrue file_handleout_file m′

intros m m′ Hin Hold Hnew Hframe

m, m′ :
Hin :
in_objectm 5120
Hold :
m_auxm 5120 = Obj1024
Hnew :
m_auxm′ 5120 = CNone
⊢
False

assert Houtside : ¬write_authoritystream_aux_rootsmodel worldtrue file_handleout_file [ ] m 5120

2 open

m, m′ :
Hin :
in_objectm 5120
Hold :
m_auxm 5120 = Obj1024
Hnew :
m_auxm′ 5120 = CNone
focused goal
m, m′ :
Hin :
in_objectm 5120
Hold :
m_auxm 5120 = Obj1024
Hnew :
m_auxm′ 5120 = CNone
⊢
False

{intros root & & _ | base & reg & & _

deferred goal
m, m′ :
Hin :
in_objectm 5120
Hold :
m_auxm 5120 = Obj1024
Hnew :
m_auxm′ 5120 = CNone
⊢
False

specialize Hframe5120 Hin Houtside

m, m′ :
Hin :
in_objectm 5120
Hold :
m_auxm 5120 = Obj1024
Hnew :
m_auxm′ 5120 = CNone
Hframe :
m_auxm′ 5120 = m_auxm 5120
⊢
False

rewrite Hold , Hnew in Hframe

m, m′ :
Hin :
in_objectm 5120
Hold :
m_auxm 5120 = Obj1024
Hnew :
m_auxm′ 5120 = CNone
Hframe :
CNone = Obj1024
⊢
False

discriminate

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros m m′ Hin Hold Hnew Hframe
{intros root & & _ | base & reg & & _
specialize Hframe5120 Hin Houtside
rewrite Hold , Hnew in Hframe
discriminate

Query-only byte framing protects the last errno byte too, even though ordinary effects authorize all four scalar errno writes.

645Example query_errno_byte_clobber_rejected: ∀spec s m′ s′ trace ending, spec = ferror_contractmodel ∨ spec = fpending_contractmodel → m_bytesm′ 5123 ≠ m_bytesconversion_mem 5123 → ¬M.E.invokespec CVoid ArgP Const0 WPtrfile_handleout_file s conversion_mem worldtrue trace ending s′ m′ worldtrue
Explore proof 3 tactics

Initial goal

⊢
∀spec : contractlibc_world s : InterpRuntime.state m′ : mem s′ : InterpRuntime.state trace : listevent ending : call_end, spec = ferror_contractmodel ∨ spec = fpending_contractmodel → m_bytesm′ 5123 ≠ m_bytesconversion_mem 5123 → ¬M.E.invokespec CVoid ArgP Const0 WPtrfile_handleout_file s conversion_mem worldtrue trace ending s′ m′ worldtrue

intros spec s m′ s′ trace ending Hspec Hchanged Hcall

m′ :
trace :
listevent
ending :
Hspec :
Hchanged :
m_bytesm′ 5123 ≠ m_bytesconversion_mem 5123
Hcall :
⊢
False

destruct Hspec as → | →

2 open

⊢
False
focused goal
⊢
False

all: destruct M.E.invoke_prefix_ _ _ _ _ _ _ _ _ _ _ _ _ Hcall as born & _ & p & info & Hxs & _ & _ & _ & _ & _ & _ & Hbytes ; injection Hxs as ← ; apply Hchanged , Hbytes ; exists 5120, mkRegion5120 5128 Heap Live ; split ; reflexivity | simpl ; lia | intros root & & _ | base & reg & & _

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros spec s m′ s′ trace ending Hspec Hchanged Hcall
destruct Hspec as → | →
all: destruct M.E.invoke_prefix_ _ _ _ _ _ _ _ _ _ _ _ _ Hcall as born & _ & p & info & Hxs & _ & _ & _ & _ & _ & _ & Hbytes ; injection Hxs as ← ; apply Hchanged , Hbytes ; exists 5120, mkRegion5120 5128 Heap Live ; split ; reflexivity | simpl ; lia | intros root & & _ | base & reg & & _

Two active, different FILEs may not both own the same release.

663Example overlapping_release_rejected: ∀m w p file q other base, libc_file_atw p = Somefile → libc_file_atw q = Someother → file_handleother ≠ file_handlefile → Inbase file_ownedfile → Inbase file_ownedother → ¬libc_release_separatedm w
Explore proof 3 tactics

Initial goal

⊢
∀m : mem w : libc_world p : ptr file : libc_file q : ptr other : libc_file base : Z, libc_file_atw p = Somefile → libc_file_atw q = Someother → file_handleother ≠ file_handlefile → Inbase file_ownedfile → Inbase file_ownedother → ¬libc_release_separatedm w

intros m w p file q other base Hp Hq Hne Hin Hother Hsep

m :
p :
file :
q :
other :
base :
Z
Hp :
libc_file_atw p = Somefile
Hq :
libc_file_atw q = Someother
Hne :
file_handleother ≠ file_handlefile
Hin :
Inbase file_ownedfile
Hother :
Inbase file_ownedother
⊢
False

destruct Hsepp file Hp base Hin as _ & Howners & _

m :
p :
file :
q :
other :
base :
Z
Hp :
libc_file_atw p = Somefile
Hq :
libc_file_atw q = Someother
Hne :
file_handleother ≠ file_handlefile
Hin :
Inbase file_ownedfile
Hother :
Inbase file_ownedother
Howners :
∀q : ptr other : libc_file, libc_file_atw q = Someother → file_handleother ≠ file_handlefile → ¬Inbase file_ownedother
⊢
False

exact Hownersq other Hq Hne Hother

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros m w p file q other base Hp Hq Hne Hin Hother Hsep
destruct Hsepp file Hp base Hin as _ & Howners & _
exact Hownersq other Hq Hne Hother

Stable FILE capability identities cannot enter an active release pool, even when the memory happens to classify them as Heap.

676Example static_handle_release_rejected: ∀m w p file base, libc_file_atw p = Somefile → ptr_caplibc_stdoutw = Objbase → Inbase file_ownedfile → ¬libc_release_separatedm w
Explore proof 10 tactics

Initial goal

⊢
∀m : mem w : libc_world p : ptr file : libc_file base : Z, libc_file_atw p = Somefile → ptr_caplibc_stdoutw = Objbase → Inbase file_ownedfile → ¬libc_release_separatedm w

intros m w p file base Hp Hcap Hin Hsep

m :
p :
file :
base :
Z
Hp :
libc_file_atw p = Somefile
Hcap :
Hin :
Inbase file_ownedfile
⊢
False

destruct Hsepp file Hp base Hin as _ & _ & Hnot & _

m :
p :
file :
base :
Z
Hp :
libc_file_atw p = Somefile
Hcap :
Hin :
Inbase file_ownedfile
Hnot :
¬available_capspan_ptr ≔ libc_stdoutw; span_size ≔ 0 :: span_ptr ≔ libc_stderrw; span_size ≔ 0 :: locale_private_sourceslibc_localefstw ++ if same_filep libc_stdoutw then match libc_file_atw libc_stderrw with Someother ⇒ file_sourcesother | None ⇒ [ ] end else match libc_file_atw libc_stdoutw with Someother ⇒ file_sourcesother | None ⇒ [ ] end [ ] m Objbase
⊢
False

apply Hnot

m :
p :
file :
base :
Z
Hp :
libc_file_atw p = Somefile
Hcap :
Hin :
Inbase file_ownedfile
Hnot :
¬available_capspan_ptr ≔ libc_stdoutw; span_size ≔ 0 :: span_ptr ≔ libc_stderrw; span_size ≔ 0 :: locale_private_sourceslibc_localefstw ++ if same_filep libc_stdoutw then match libc_file_atw libc_stderrw with Someother ⇒ file_sourcesother | None ⇒ [ ] end else match libc_file_atw libc_stdoutw with Someother ⇒ file_sourcesother | None ⇒ [ ] end [ ] m Objbase
⊢
::
::
++
→
Someother
⇒
None
⇒
[ ]
else
Someother
⇒
None
⇒
[ ]
[ ]
m
Objbase

right

m :
p :
file :
base :
Z
Hp :
libc_file_atw p = Somefile
Hcap :
Hin :
Inbase file_ownedfile
Hnot :
¬available_capspan_ptr ≔ libc_stdoutw; span_size ≔ 0 :: span_ptr ≔ libc_stderrw; span_size ≔ 0 :: locale_private_sourceslibc_localefstw ++ if same_filep libc_stdoutw then match libc_file_atw libc_stderrw with Someother ⇒ file_sourcesother | None ⇒ [ ] end else match libc_file_atw libc_stdoutw with Someother ⇒ file_sourcesother | None ⇒ [ ] end [ ] m Objbase
⊢
∃ s : span  ,
Ins
::
::
++
→
Someother
⇒
None
⇒
[ ]
else
Someother
⇒
None
⇒
[ ]
∧
∨
∃ s : span a : Z  ,
Ins
::
::
++
→
Someother
⇒
None
⇒
[ ]
else
Someother
⇒
None
⇒
[ ]
∧
span_containss a ∧ a + 8 ≤ ptr_addrspan_ptrs + span_sizes ∧ access_resm a ptr_capspan_ptrs 8 Read 8 = Someok ∧ Objbase = m_auxm a
∨
∃base0 : Z, Inbase0 [ ] ∧ Objbase = Objbase0 ∨ Objbase = Robase0

left

m :
p :
file :
base :
Z
Hp :
libc_file_atw p = Somefile
Hcap :
Hin :
Inbase file_ownedfile
Hnot :
¬available_capspan_ptr ≔ libc_stdoutw; span_size ≔ 0 :: span_ptr ≔ libc_stderrw; span_size ≔ 0 :: locale_private_sourceslibc_localefstw ++ if same_filep libc_stdoutw then match libc_file_atw libc_stderrw with Someother ⇒ file_sourcesother | None ⇒ [ ] end else match libc_file_atw libc_stdoutw with Someother ⇒ file_sourcesother | None ⇒ [ ] end [ ] m Objbase
⊢
∃ s : span  ,
Ins
::
::
++
→
Someother
⇒
None
⇒
[ ]
else
Someother
⇒
None
⇒
[ ]
∧

exists mkSpanlibc_stdoutw 0

m :
p :
file :
base :
Z
Hp :
libc_file_atw p = Somefile
Hcap :
Hin :
Inbase file_ownedfile
Hnot :
¬available_capspan_ptr ≔ libc_stdoutw; span_size ≔ 0 :: span_ptr ≔ libc_stderrw; span_size ≔ 0 :: locale_private_sourceslibc_localefstw ++ if same_filep libc_stdoutw then match libc_file_atw libc_stderrw with Someother ⇒ file_sourcesother | None ⇒ [ ] end else match libc_file_atw libc_stdoutw with Someother ⇒ file_sourcesother | None ⇒ [ ] end [ ] m Objbase
⊢
::
::
++
→
Someother
⇒
None
⇒
[ ]
else
Someother
⇒
None
⇒
[ ]
∧

split ; left ; reflexivity |

m :
p :
file :
base :
Z
Hp :
libc_file_atw p = Somefile
Hcap :
Hin :
Inbase file_ownedfile
Hnot :
¬available_capspan_ptr ≔ libc_stdoutw; span_size ≔ 0 :: span_ptr ≔ libc_stderrw; span_size ≔ 0 :: locale_private_sourceslibc_localefstw ++ if same_filep libc_stdoutw then match libc_file_atw libc_stderrw with Someother ⇒ file_sourcesother | None ⇒ [ ] end else match libc_file_atw libc_stdoutw with Someother ⇒ file_sourcesother | None ⇒ [ ] end [ ] m Objbase

simpl

m :
p :
file :
base :
Z
Hp :
libc_file_atw p = Somefile
Hcap :
Hin :
Inbase file_ownedfile
Hnot :
¬available_capspan_ptr ≔ libc_stdoutw; span_size ≔ 0 :: span_ptr ≔ libc_stderrw; span_size ≔ 0 :: locale_private_sourceslibc_localefstw ++ if same_filep libc_stdoutw then match libc_file_atw libc_stderrw with Someother ⇒ file_sourcesother | None ⇒ [ ] end else match libc_file_atw libc_stdoutw with Someother ⇒ file_sourcesother | None ⇒ [ ] end [ ] m Objbase

symmetry

m :
p :
file :
base :
Z
Hp :
libc_file_atw p = Somefile
Hcap :
Hin :
Inbase file_ownedfile
Hnot :
¬available_capspan_ptr ≔ libc_stdoutw; span_size ≔ 0 :: span_ptr ≔ libc_stderrw; span_size ≔ 0 :: locale_private_sourceslibc_localefstw ++ if same_filep libc_stdoutw then match libc_file_atw libc_stderrw with Someother ⇒ file_sourcesother | None ⇒ [ ] end else match libc_file_atw libc_stdoutw with Someother ⇒ file_sourcesother | None ⇒ [ ] end [ ] m Objbase

exact Hcap

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros m w p file base Hp Hcap Hin Hsep
destruct Hsepp file Hp base Hin as _ & _ & Hnot & _
apply Hnot
right
left
split ; left ; reflexivity |
simpl
symmetry
exact Hcap