Fil-C on Nix

Filnix wiki

the formal campaign

rocq/theories/LibcDiagnosticLogic.v

Returning diagnostics on the consumer's same libc world and machine. Native diagnostic representation stays trusted. The frame below owns no diagnostic pool: it separates future write roots, not all retained sources or future release rights.

From iris.proofmode Require Import proofmode
From Stdlib Require Import String ZArith List Lia
From Nanofil Require Import Term Syntax Values Memory Runtime Identity ExternalCalls ExternalMachine Stdio Shutdown Streams Formatting Diagnostics Libc LibcStreams Pieces Heap ContractFrame Logic StringLogic LentLogic LibcStreamLogic LibcErrnoLogic LibcStreamTokens LibcStreamAdapter
Import ListNotations
Open Scope Z_scope
Open Scope list_scope

Preserve callback inventory, not the whole shutdown record: flushing stdout changes its authoritative protocol. Neither FILE inventory is frozen, and parser compatibility (including sampled errno) is separate.

18Definition libc_diagnostic_framew w′ : libc_world : Prop ≔
libc_stdoutw′ = libc_stdoutw ∧ libc_stderrw′ = libc_stderrw ∧ libc_localefstw′ = libc_localefstw ∧ libc_errnofstw′ = libc_errnofstw ∧ shutdown_atsndw′ = shutdown_atsndw ∧ shutdown_statussndw′ = shutdown_statussndw ∧ shutdown_pendingsndw′ = shutdown_pendingsndw ∧ shutdown_consumedsndw′ = shutdown_consumedsndw

Keep the native sources, writes, requests and segment interpretation. Readiness at both endpoints includes the independent FILE envelope.

29Definition libc_diagnostic_contextrep native : diagnostic_contextlibc_world ≔

Only this status-zero wrapper is an ordinary returning error symbol. Nonzero diagnostics still belong to the separate ending protocol.

38Definition libc_error_contractrep requests wide native : contractlibc_world ≔

Exact open observations cannot be framed unchanged through acceptance or settlement. Open-only and completed-closed names can.

44Definition diagnostic_named : stream_token h : gmappiece pval : Prop ≔
match h !! PNametoken_keyd with
None | SomeVStreamOpen_ | SomeVStream_ None
⇒
True
Some_
⇒
False
50Definition libc_diagnostic_wirep native out err b o m w h : Prop ≔

Transport only what the permitted name constructors actually observe.

57Lemma diagnostic_current
∀ d w w′ h h′
stream_currentd w′ h′ ∧ diagnostic_named h′
Explore proof 11 tactics

Initial goal

⊢
∀d : stream_token w w′ : libc_world h h′ : gmappiece pval, h′ !! PNametoken_keyd = h !! PNametoken_keyd → diagnostic_named h → stream_currentd w h → ∃info : stream_info, libc_stream_atw token_handled = Someinfo → ∃info : stream_info, libc_stream_atw′ token_handled = Someinfo → libc_stream_atw token_handled = None → libc_stream_atw′ token_handled = None ∧ libc_stream_statew′ token_handled = libc_stream_statew token_handled → stream_currentd w′ h′ ∧ diagnostic_named h′

intros d w w′ h h′ Hkey Hname Hcurrent Hopen Hclosed

w, w′ :
h, h′ :
Hkey :
h′ !! PNametoken_keyd = h !! PNametoken_keyd
Hname :
Hcurrent :
Hopen :
∃info : stream_info, libc_stream_atw token_handled = Someinfo → ∃info : stream_info, libc_stream_atw′ token_handled = Someinfo
⊢
stream_currentd w′ h′ ∧ diagnostic_named h′

unfold stream_current , diagnostic_name in *

w, w′ :
h, h′ :
Hkey :
h′ !! PNametoken_keyd = h !! PNametoken_keyd
Hname :
match h !! PNametoken_keyd with
SomeVStream_ None | SomeVStreamOpen_ | None
⇒
True
_
⇒
False
Hcurrent :
match h !! PNametoken_keyd with
SomeVStreamp snapshot
⇒
p = token_handled ∧ stream_observationw p snapshot
⇒
p = token_handled ∧ ∃info : stream_info, libc_stream_atw p = Someinfo
None
⇒
True
_
⇒
False
Hopen :
∃info : stream_info, libc_stream_atw token_handled = Someinfo → ∃info : stream_info, libc_stream_atw′ token_handled = Someinfo
⊢
match h′ !! PNametoken_keyd with
SomeVStreamp snapshot
⇒
p = token_handled ∧ stream_observationw′ p snapshot
⇒
p = token_handled ∧ ∃info : stream_info, libc_stream_atw′ p = Someinfo
None
⇒
True
_
⇒
False
∧
match h′ !! PNametoken_keyd with
SomeVStream_ None | SomeVStreamOpen_ | None
⇒
True
_
⇒
False

rewrite Hkey

w, w′ :
h, h′ :
Hkey :
h′ !! PNametoken_keyd = h !! PNametoken_keyd
Hname :
match h !! PNametoken_keyd with
SomeVStream_ None | SomeVStreamOpen_ | None
⇒
True
_
⇒
False
Hcurrent :
match h !! PNametoken_keyd with
SomeVStreamp snapshot
⇒
p = token_handled ∧ stream_observationw p snapshot
⇒
p = token_handled ∧ ∃info : stream_info, libc_stream_atw p = Someinfo
None
⇒
True
_
⇒
False
Hopen :
∃info : stream_info, libc_stream_atw token_handled = Someinfo → ∃info : stream_info, libc_stream_atw′ token_handled = Someinfo
⊢
match h !! PNametoken_keyd with
SomeVStreamp snapshot
⇒
p = token_handled ∧ stream_observationw′ p snapshot
⇒
p = token_handled ∧ ∃info : stream_info, libc_stream_atw′ p = Someinfo
None
⇒
True
_
⇒
False
∧
match h !! PNametoken_keyd with
SomeVStream_ None | SomeVStreamOpen_ | None
⇒
True
_
⇒
False

destruct h !! PNametoken_keyd as v | ; | auto

w, w′ :
h, h′ :
v :
Hkey :
h′ !! PNametoken_keyd = Somev
Hname :
match v with
⇒
True
_
⇒
False
Hcurrent :
match v with
VStreamp snapshot
⇒
p = token_handled ∧ stream_observationw p snapshot
⇒
p = token_handled ∧ ∃info : stream_info, libc_stream_atw p = Someinfo
_
⇒
False
Hopen :
∃info : stream_info, libc_stream_atw token_handled = Someinfo → ∃info : stream_info, libc_stream_atw′ token_handled = Someinfo
⊢
match v with
VStreamp snapshot
⇒
p = token_handled ∧ stream_observationw′ p snapshot
⇒
p = token_handled ∧ ∃info : stream_info, libc_stream_atw′ p = Someinfo
_
⇒
False
∧
match v with
⇒
True
_
⇒
False

destruct v ; try contradiction

2 open

w, w′ :
h, h′ :
p :
pending :
optionZ × listZ
Hkey :
h′ !! PNametoken_keyd = SomeVStreamp pending
Hname :
match pending with
Some_
⇒
False
None
⇒
True
Hcurrent :
p = token_handled ∧ stream_observationw p pending
Hopen :
∃info : stream_info, libc_stream_atw token_handled = Someinfo → ∃info : stream_info, libc_stream_atw′ token_handled = Someinfo
⊢
p = token_handled ∧ stream_observationw′ p pending
∧
match pending with
Some_
⇒
False
None
⇒
True
focused goal
w, w′ :
h, h′ :
p :
Hkey :
h′ !! PNametoken_keyd = SomeVStreamOpenp
Hname :
True
Hcurrent :
p = token_handled ∧ ∃info : stream_info, libc_stream_atw p = Someinfo
Hopen :
∃info : stream_info, libc_stream_atw token_handled = Someinfo → ∃info : stream_info, libc_stream_atw′ token_handled = Someinfo
⊢
p = token_handled ∧ ∃info : stream_info, libc_stream_atw′ p = Someinfo ∧ True

–destruct pending as physical fifo | ; contradiction |

2 open

w, w′ :
h, h′ :
p :
Hkey :
h′ !! PNametoken_keyd = SomeVStreamp None
Hname :
True
Hcurrent :
p = token_handled ∧ stream_observationw p None
Hopen :
∃info : stream_info, libc_stream_atw token_handled = Someinfo → ∃info : stream_info, libc_stream_atw′ token_handled = Someinfo
⊢
p = token_handled ∧ stream_observationw′ p None ∧ True
deferred goal
w, w′ :
h, h′ :
p :
Hkey :
h′ !! PNametoken_keyd = SomeVStreamOpenp
Hname :
True
Hcurrent :
p = token_handled ∧ ∃info : stream_info, libc_stream_atw p = Someinfo
Hopen :
∃info : stream_info, libc_stream_atw token_handled = Someinfo → ∃info : stream_info, libc_stream_atw′ token_handled = Someinfo
⊢
p = token_handled ∧ ∃info : stream_info, libc_stream_atw′ p = Someinfo ∧ True

destruct Hcurrent as → Hlookup Hfifo

2 open

w, w′ :
h, h′ :
Hkey :
h′ !! PNametoken_keyd = SomeVStreamtoken_handled None
Hname :
True
Hlookup :
Hopen :
∃info : stream_info, libc_stream_atw token_handled = Someinfo → ∃info : stream_info, libc_stream_atw′ token_handled = Someinfo
⊢
deferred goal
w, w′ :
h, h′ :
p :
Hkey :
h′ !! PNametoken_keyd = SomeVStreamOpenp
Hname :
True
Hcurrent :
p = token_handled ∧ ∃info : stream_info, libc_stream_atw p = Someinfo
Hopen :
∃info : stream_info, libc_stream_atw token_handled = Someinfo → ∃info : stream_info, libc_stream_atw′ token_handled = Someinfo
⊢
p = token_handled ∧ ∃info : stream_info, libc_stream_atw′ p = Someinfo ∧ True

destruct HclosedHlookup as Hlookup′ Hstate

2 open

w, w′ :
h, h′ :
Hkey :
h′ !! PNametoken_keyd = SomeVStreamtoken_handled None
Hname :
True
Hlookup :
Hopen :
∃info : stream_info, libc_stream_atw token_handled = Someinfo → ∃info : stream_info, libc_stream_atw′ token_handled = Someinfo
Hlookup′ :
⊢
deferred goal
w, w′ :
h, h′ :
p :
Hkey :
h′ !! PNametoken_keyd = SomeVStreamOpenp
Hname :
True
Hcurrent :
p = token_handled ∧ ∃info : stream_info, libc_stream_atw p = Someinfo
Hopen :
∃info : stream_info, libc_stream_atw token_handled = Someinfo → ∃info : stream_info, libc_stream_atw′ token_handled = Someinfo
⊢
p = token_handled ∧ ∃info : stream_info, libc_stream_atw′ p = Someinfo ∧ True

split ; split ; reflexivity | split ; exact Hlookup′ | rewrite Hstate ; exact Hfifo | exact I

deferred goal
w, w′ :
h, h′ :
p :
Hkey :
h′ !! PNametoken_keyd = SomeVStreamOpenp
Hname :
True
Hcurrent :
p = token_handled ∧ ∃info : stream_info, libc_stream_atw p = Someinfo
Hopen :
∃info : stream_info, libc_stream_atw token_handled = Someinfo → ∃info : stream_info, libc_stream_atw′ token_handled = Someinfo
⊢
p = token_handled ∧ ∃info : stream_info, libc_stream_atw′ p = Someinfo ∧ True

–destruct Hcurrent as → Hlookup

w, w′ :
h, h′ :
Hkey :
Hname :
True
Hlookup :
∃info : stream_info, libc_stream_atw token_handled = Someinfo
Hopen :
∃info : stream_info, libc_stream_atw token_handled = Someinfo → ∃info : stream_info, libc_stream_atw′ token_handled = Someinfo
⊢
token_handled = token_handled ∧ ∃info : stream_info, libc_stream_atw′ token_handled = Someinfo ∧ True

split ; split ; reflexivity | auto | exact I

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros d w w′ h h′ Hkey Hname Hcurrent Hopen Hclosed
rewrite Hkey
destruct h !! PNametoken_keyd as v | ; | auto
destruct v ; try contradiction
–destruct pending as physical fifo | ; contradiction |
destruct Hcurrent as → Hlookup Hfifo
destruct HclosedHlookup as Hlookup′ Hstate
split ; split ; reflexivity | split ; exact Hlookup′ | rewrite Hstate ; exact Hfifo | exact I
–destruct Hcurrent as → Hlookup
split ; split ; reflexivity | auto | exact I
78Module LibcDiagnosticLogicOn R : Runtime LG : StreamFrameLogicR
79Module M ≔ LG.L.M
80Module T ≔ LibcStreamTokensOn R LG

The empty return list comes from the supplied machine's normal branch, never from a resource prefix. The same invocation also supplies the formatting observations and both FILE delegations.

85Lemma error_returned
∀ rep requests wide native r args xs s m w trace values s′ m′ w′
M.E.invokelibc_error_contractrep requests wide native r args xs s m w trace CallReturnvalues s′ m′ w′
values = [ ] ∧ ∃born, M.E.prefixlibc_error_contractrep requests wide native xs s m w born trace s′ m′ w′
Explore proof 5 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 native : diagnostic_contextlibc_world 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, M.E.invokelibc_error_contractrep requests wide native r args xs s m w trace CallReturnvalues s′ m′ w′ → values = [ ] ∧ ∃born : listZ, M.E.prefixlibc_error_contractrep requests wide native xs s m w born trace s′ m′ w′

intros rep requests wide native r args xs s m w trace values s′ m′ w′ Hi

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′ :
Hi :
M.E.invokelibc_error_contractrep requests wide native r args xs s m w trace CallReturnvalues s′ m′ w′
⊢
values = [ ] ∧ ∃born : listZ, M.E.prefixlibc_error_contractrep requests wide native xs s m w born trace s′ m′ w′

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
args :
listarg
xs :
listword
s :
R.state
m :
trace :
listevent
values :
listword
s′ :
R.state
m′ :
Hi :
M.E.invokelibc_error_contractrep requests wide native r args xs s m w trace CallReturnvalues s′ m′ w′
⊢
values = [ ]
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
xs :
listword
s :
R.state
m :
trace :
listevent
values :
listword
s′ :
R.state
m′ :
Hi :
M.E.invokelibc_error_contractrep requests wide native r args xs s m w trace CallReturnvalues s′ m′ w′
⊢
∃born : listZ, M.E.prefixlibc_error_contractrep requests wide native xs s m w born trace s′ m′ w′

–inversion Hi ; subst

2 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
xs :
listword
s :
R.state
m :
trace :
listevent
values :
listword
s′ :
R.state
m′ :
Hi :
M.E.invokelibc_error_contractrep requests wide native r args xs s m w trace CallReturnvalues s′ m′ w′
born :
listZ
H :
contract_abilibc_error_contractrep requests wide native r args
H0 :
contract_prelibc_error_contractrep requests wide native xs m w
H1 :
M.E.prefixlibc_error_contractrep requests wide native xs s m w born trace s′ m′ w′
H2 :
contract_postlibc_error_contractrep requests wide native xs m w born trace CallReturnvalues m′ w′
H3 :
∀why : reason, CallReturnvalues ≠ CallResourcewhy
H4 :
∀values0 : listword, CallReturnvalues = CallReturnvalues0 → return_shapecontract_returnslibc_error_contractrep requests wide native values0 ∧ Forallword_authoritycontract_sourceslibc_error_contractrep requests wide native xs m w born m′ values0
H5 :
∀status : Z, CallReturnvalues = CallExitstatus → ∃before : listevent, trace = before ++ ProcessExitstatus
⊢
values = [ ]
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
xs :
listword
s :
R.state
m :
trace :
listevent
values :
listword
s′ :
R.state
m′ :
Hi :
M.E.invokelibc_error_contractrep requests wide native r args xs s m w trace CallReturnvalues s′ m′ w′
⊢
∃born : listZ, M.E.prefixlibc_error_contractrep requests wide native xs s m w born trace s′ m′ w′

match goal withHpost : contract_post_ _ _ _ _ _ _ _ _ |- _⇒apply error_post_void in Hpost ; injection Hpost ; autoend

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
xs :
listword
s :
R.state
m :
trace :
listevent
values :
listword
s′ :
R.state
m′ :
Hi :
M.E.invokelibc_error_contractrep requests wide native r args xs s m w trace CallReturnvalues s′ m′ w′
⊢
∃born : listZ, M.E.prefixlibc_error_contractrep requests wide native xs s m w born trace s′ m′ w′

–eapply M.E.invoke_prefix ; exact Hi

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros rep requests wide native r args xs s m w trace values s′ m′ w′ Hi
split
–inversion Hi ; subst
match goal withHpost : contract_post_ _ _ _ _ _ _ _ _ |- _⇒apply error_post_void in Hpost ; injection Hpost ; autoend
–eapply M.E.invoke_prefix ; exact Hi

Sample only the already-owned errno byte keys. Life projection omits neither private bytes nor auxiliary pieces. Future FILE release separation is restored against the FULL heap, including both lives.

104Theorem error_frame
∀ rep requests wide native out err b o r args xs s m w trace values s′ m′ w′ h old
M.E.invokelibc_error_contractrep requests wide native r args xs s m w trace CallReturnvalues s′ m′ w′
R.readys m
libc_diagnostic_wirep native out err b o m w h
lengthold = 4%nat
∀l v, l, v ∈ byte_psb o old → h !! l = Somev
∃ys, values = [ ] ∧ lengthys = 4%nat ∧ byte_psb o ys.*1 = byte_psb o old.*1 ∧ agreesm′ overwritebyte_psb o ys h ∧ live_disjointm′ ∧ R.readys′ m′ ∧ libc_diagnostic_wirep native out err b o m′ w′ overwritebyte_psb o ys h
Proof 190 steps Qed
intros rep requests wide native out err b o r args xs s m w trace values s′ m′ w′ h old Hi Ha Hd Hr Hpair Hroots Honame Hename Hlen Howned
destruct Hpair as Howf & Hewf & Hbase & Hkey & Hout & Herr & Hoc & Hec & Hprivate
destruct Hprivateout or_introleq_refl as Howi Horelease
destruct Hprivateerr or_introreq_refl as Hewi Herelease
pose proof stream_data_agreestoken_baseout token_baseerr m h Ha as Hdata
change agreesm dh in Hdata
destruct error_returnedrep requests wide native r args xs s m w trace values s' m' w' Hi as Hvalues born Hp
pose proof M.E.prefix_preserve_ _ _ _ _ _ _ _ _ _ _ Hp Hr as Hr′ Hpers
destruct LG.prefix_agrees_out_ _ _ _ _ _ _ _ _ _ _ dh errno_keysb o span_containserrno_spanb o Hp Hr Hd as Hexcept & Hids & Hd′ & Hborn
–intros l v Hl _
exact Hdatal v Hl
–intros l v Hl Hmem
eapply agree_piece_registered ; exact Hmem | exact Hdatal v Hl
intros root a Hin Hspan Hown
apply in_app_or in Hin as Hin | Hin
+rewrite Hout in Hin
eapply errno_roots_out ; exact proj1proj2Howi | exact proj1proj2proj2Howi | exact Hin | exact Hspan | exact Hown
+apply in_app_or in Hin as Hin | Hin
∗rewrite Herr in Hin
eapply errno_roots_out ; exact proj1proj2Hewi | exact proj1proj2proj2Hewi | exact Hin | exact Hspan | exact Hown
∗exfalso
exact Hrootsroot a Hin Hspan Hown
–exact proj2proj2proj2proj2Howi
–intros base l v Hin
contradiction
–destruct proj2Hp as Hformat Htrace
destruct Hformat as status & errnum & fmt & rest & text & body & info & info′ & segments & pieces & actions & Hxs & Hstring & Hformat & Hsegments & Hpieces & Hinfo & Hopen & Hid & Hid′ & Hrun & Haccepted & Hflush & Hready & Hframe & Houtdel & Herrdel & Hrootdel & Htrace′ & Haux
destruct Hready as Hnative Hready
destruct Hframe as Hnativeframe Hframe
change libc_diagnostic_framew w' in Hframe
destruct Hframe as Hout′ & Herr′ & Hlocale & Herrno & Hphase & Hstatus & Hpending & Hconsumed
assert He : libc_errnofstw' = mkPtrb + o Objb
{rewrite Herrno
exact proj1proj2Howi
assert Hbytes : all_agreem' byte_psb o errno_bytesm' b o
rewrite <- He
exact proj1proj2proj2Hready
set ys := errno_bytesm' b o
assert Hkeys : byte_psb o ys.*1 = byte_psb o old.*1
{rewrite ! byte_ps_keys
unfold ys , errno_bytes
rewrite length_map length_seq Hlen
reflexivity
set h′ := overwritebyte_psb o ys h
set dh′ := stream_data_heaptoken_baseout token_baseerr h'
assert Hlifeoff : ∀base, PLivebase ∉ byte_psb o ys.*1
{intros base Hin
rewrite byte_ps_keys in Hin
apply list_elem_of_fmap in Hin as i & E & _
discriminate E
assert Hcommute : dh' = overwritebyte_psb o ys dh
{unfold dh' , h' , dh
apply stream_data_overwrite ; apply Hlifeoff
assert Hkeysfull : memory_keys_fromh' h
{intros l v Hl Hmem
destruct lookup_overwrite_ _ _ _ Hl as Hin | _ Hold ; | eauto
assert Hinold : l ∈ byte_psb o old.*1
{rewrite <- Hkeys
apply list_elem_of_fmap
exists l, v
auto
apply list_elem_of_fmap in Hinold as key oldv & E & Hinold
simpl in E
subst key
exists oldv
exact Howned_ _ Hinold
assert Hkeysdata : memory_keys_fromdh' dh
{intros l v Hl Hmem
apply stream_data_lookup in Hl as Hl & Hno & Hne
destruct Hkeysfulll v Hl Hmem as oldv Hold
exists oldv
unfold dh
rewrite stream_data_lookup_ne ; assumption
assert Hdata′ : agreesm' dh'
{rewrite Hcommute
intros l v Hl
destruct lookup_overwrite_ _ _ _ Hl as Hin | Hnot Hold
–exact all_agree_elem_ _ _ _ Hbytes Hin
–apply Hexcept ; exact Hold |
rewrite <- errno_bytes_keysm' b o
exact Hnot
assert Ha′ : agreesm' h'
{eapply stream_data_restore ; exact Ha | exact Hdata' | exact Hpers | | | |
–apply overwrite_out , Hlifeoff
–apply overwrite_out , Hlifeoff
–intros reg Hlive
eapply T.prefix_handle_live ; exact Hp | exact Hr | exact Hd | exact Hlive |
intros Hnil
contradiction
–intros reg Hlive
eapply T.prefix_handle_live ; exact Hp | exact Hr | exact Hd | exact Hlive |
intros Hnil
contradiction
assert Hnamekeys : ∀d, h' !! PNametoken_keyd = h !! PNametoken_keyd
{intros d
rewrite byte_ps_keys
intros Hin
apply list_elem_of_fmap in Hin as i & E & _
discriminate E
assert Hcurrent : stream_currentout w' h' ∧ diagnostic_nameout h'
{eapply diagnostic_current ; apply Hnamekeys | exact Honame | exact Hoc | |
–intros i Hi0
unfold diagnostic_flush in Hflush
rewrite Hout Hi0 in Hflush
destruct Hflush as i′ & Hi′ & _
exists i'
exact Hi'
–intros Hclosed
unfold diagnostic_flush in Hflush
rewrite Hout Hclosed in Hflush
exact Hflush
assert Hcurrenterr : stream_currenterr w' h' ∧ diagnostic_nameerr h'
{eapply diagnostic_current ; apply Hnamekeys | exact Hename | exact Hec | |
–intros _
exists info'
rewrite <- Herr
exact proj1proj2Hopen
–intros Hclosed
change libc_stream_atw libc_stderrw = Someinfo in Hinfo
rewrite Herr Hclosed in Hinfo
discriminate Hinfo
assert Hprivate′ : ∀d, d = out ∨ d = err → libc_errno_wirep token_handled b o m' w' dh' ∧ ids_apartlibc_stream_releasesw' token_handled h'
{intros d Hdsel
destruct Hprivated Hdsel as Hwi Hrel
assert Hdelegate : stream_delegateslibc_stream_modelrep requests wide w token_handled born m' w'
{destruct Hdsel as → | → ; rewrite <- Hout | rewrite <- Herr ; assumption
assert Hwi′ : libc_errno_wirep token_handled b o m' w' dh'
{eapply errno_wi_endpoint ; exact Hwi | exact Hdata | exact Hpers | exact Hd' | exact Hready | exact Herrno | exact Hdelegate | exact Hborn | exact Hkeysdata
split ; exact Hwi' |
intros base l v Hin Hl Hmem
destruct decidel = PLivetoken_baseout as [ ->| Hno ]
–simpl
intros E
subst base
eapply libc_handle_not_released ; exact Hready | left ; reflexivity | | exact Hin
rewrite Hout' Hout
exact proj1Howf
–destruct decidel = PLivetoken_baseerr as [ ->| Hne ]
+simpl
intros E
subst base
eapply libc_handle_not_released ; exact Hready | right ; reflexivity | | exact Hin
rewrite Herr' Herr
exact proj1Hewf
+apply proj1proj2proj2proj2Hwi' base l v Hin ; | exact Hmem
unfold dh'
rewrite stream_data_lookup_ne ; assumption
assert Hroots′ : roots_apartdiagnostic_writesnative w' dh' m'
{intros root a Hin Hspan l & v & reg & Hl & Hmem & Hlive & Hrange
destruct Hkeysdatal v Hl Hmem as oldv Hold
assert Howned′ : owned_livedh m' a
{exists l, oldv, reg
auto
destruct Hrootdelroot Hin as _ Hauth
{intros oldroot addr Holdroot Holdspan key & val & rr & Hlookup & Hmemory & Hlive′ & Hbounds
apply Hrootsoldroot addr Holdroot Holdspan
exists key, val, rr
split ; exact Hlookup |
split ; exact Hmemory |
split ; | exact Hbounds
eapply registered_live_back ; exact Hpers | | exact Hlive'
eapply agree_piece_registered ; exact Hmemory | exact Hdatakey val Hlookup
exact owned_not_authoritydiagnostic_writesnative w born dh m' a Hd' Hapart Hborn Howned' Hautha Hspan
exists ys
split ; exact Hvalues |
split
{unfold ys , errno_bytes
rewrite length_map length_seq
reflexivity
split ; exact Hkeys |
split ; exact Ha' |
split ; exact Hd' |
split ; exact Hr' |
split
+split ; exact Howf |
split ; exact Hewf |
split ; exact Hbase |
split ; exact Hkey |
split ; rewrite Hout' ; exact Hout |
split ; rewrite Herr' ; exact Herr |
split ; exact proj1Hcurrent |
split ; exact proj1Hcurrenterr | exact Hprivate'
+exact conjHroots' conjproj2Hcurrent proj2Hcurrenterr

Caller-owned diagnostic strings are returned with their old values. Separation is checked against the sampled errno keys, not merely at entry: a diagnostic prefix must not overwrite the new errno bytes.

250Theorem error_pieces_frame
∀ rep requests wide native out err b o ps r args xs s m w trace values s′ m′ w′ h old
M.E.invokelibc_error_contractrep requests wide native r args xs s m w trace CallReturnvalues s′ m′ w′
R.readys m
libc_diagnostic_wirep native out err b o m w h
lengthold = 4%nat
∀l v, l, v ∈ ps ++ byte_psb o old → h !! l = Somev
∀l v, l, v ∈ ps → l ∉ errno_keysb o
∃ys, values = [ ] ∧ lengthys = 4%nat ∧ ps ++ byte_psb o ys.*1 = ps ++ byte_psb o old.*1 ∧ agreesm′ overwriteps ++ byte_psb o ys h ∧ live_disjointm′ ∧ R.readys′ m′ ∧ libc_diagnostic_wirep native out err b o m′ w′ overwriteps ++ byte_psb o ys h
Proof 29 steps Qed
intros rep requests wide native out err b o ps r args xs s m w tr vs s′ m′ w′ h old Hi Ha Hd Hr Hw Hlen Howned Hoff
destruct error_framerep requests wide native out err b o r args xs s m w tr vs s' m' w' h old Hi Ha Hd Hr Hw Hlen as ys & Hvs & Hys & Hkeys & Ha′ & Hd′ & Hr′ & Hw′
{intros l v Hin
apply Howned , elem_of_app
right
exact Hin
assert Heq : overwriteps ++ byte_psb o ys h = overwritebyte_psb o ys h
{rewrite overwrite_app
intros l v Hin
–apply Howned , elem_of_app
left
exact Hin
–rewrite Hkeys
change l ∉ byte_psb o old.*1
rewrite byte_ps_keys
unfold errno_keys in Hoff
rewrite byte_ps_keys in Hoff
rewrite Hlen
exact Hoffl v Hin
exists ys
split ; exact Hvs |
split ; exact Hys |
split
{rewrite ! fmap_app Hkeys
reflexivity
rewrite Heq
auto

Logical contract controls, not native FILEs or native diagnostic-pool realization. Both initial stdout states have actual admitted calls.

286Module LibcDiagnosticChecks
287Module D ≔ LibcDiagnosticLogicOn InterpRuntime StreamHandleChecks.LG
288Module F ≔ LibcStreamChecks
289Module T ≔ StreamTokenChecks
291Definition native ≔
mkDiagnosticContextlibc_world λ_ _ ⇒ True λ_ _ ⇒ [ ] λ_ ⇒ [ ] λ_ _ _ ⇒ False λ_ _ _ body segments ⇒ segments = body; 10 λ_ _ ⇒ True
294Definition context ≔
295Definition spec ≔
libc_error_contractλ_ _ ⇒ True λ_ _ _ _ ⇒ False λ_ _ _ _ _ ⇒ False native
297Definition fmt ≔
mkPtr4096 Ro4096
298Definition words ≔
299Definition args ≔
309Lemma final_ready
∀ opened
Explore proof 20 tactics

Initial goal

⊢
∀opened : bool, libc_stream_readyλ_ : mem _ : libc_world ⇒ True T.changed_errno final_worldopened

intros opened

opened :
bool

destruct T.changed_readyopened as Hrep & Hlocale & He & _ & _ & Hu & Hstatus & Hphase & Hdistinct & Hroots & Hout & Herr & Hsep

opened :
bool
Hrep :
True
Hlocale :
Hu :
shutdown_uniqueT.F.worldopened.2
Hstatus :
−2 ^ 31 ≤ shutdown_statusT.F.worldopened.2 < 2 ^ 31
Hphase :
match shutdown_atT.F.worldopened.2 with
⇒
Inregistration_tokenactive shutdown_consumedT.F.worldopened.2
_
⇒
True
Hdistinct :
ptr_addrlibc_stdoutT.F.worldopened ≠ ptr_addrlibc_stderrT.F.worldopened
Hroots :
stdio_rootslibc_stdioT.F.worldopened.1 = libc_active_rootsT.F.worldopened
Hout :
stdout_usablelibc_stdioT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stdout_filelibc_streamsT.F.worldopened.1
Herr :
libc_stderr_openlibc_streamsT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stderr_filelibc_streamsT.F.worldopened.1

split ; exact Hrep |

opened :
bool
Hrep :
True
Hlocale :
Hu :
shutdown_uniqueT.F.worldopened.2
Hstatus :
−2 ^ 31 ≤ shutdown_statusT.F.worldopened.2 < 2 ^ 31
Hphase :
match shutdown_atT.F.worldopened.2 with
⇒
Inregistration_tokenactive shutdown_consumedT.F.worldopened.2
_
⇒
True
Hdistinct :
ptr_addrlibc_stdoutT.F.worldopened ≠ ptr_addrlibc_stderrT.F.worldopened
Hroots :
stdio_rootslibc_stdioT.F.worldopened.1 = libc_active_rootsT.F.worldopened
Hout :
stdout_usablelibc_stdioT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stdout_filelibc_streamsT.F.worldopened.1
Herr :
libc_stderr_openlibc_streamsT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stderr_filelibc_streamsT.F.worldopened.1

split ; exact Hlocale |

opened :
bool
Hrep :
True
Hlocale :
Hu :
shutdown_uniqueT.F.worldopened.2
Hstatus :
−2 ^ 31 ≤ shutdown_statusT.F.worldopened.2 < 2 ^ 31
Hphase :
match shutdown_atT.F.worldopened.2 with
⇒
Inregistration_tokenactive shutdown_consumedT.F.worldopened.2
_
⇒
True
Hdistinct :
ptr_addrlibc_stdoutT.F.worldopened ≠ ptr_addrlibc_stderrT.F.worldopened
Hroots :
stdio_rootslibc_stdioT.F.worldopened.1 = libc_active_rootsT.F.worldopened
Hout :
stdout_usablelibc_stdioT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stdout_filelibc_streamsT.F.worldopened.1
Herr :
libc_stderr_openlibc_streamsT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stderr_filelibc_streamsT.F.worldopened.1

split ; exact He |

opened :
bool
Hrep :
True
Hlocale :
Hu :
shutdown_uniqueT.F.worldopened.2
Hstatus :
−2 ^ 31 ≤ shutdown_statusT.F.worldopened.2 < 2 ^ 31
Hphase :
match shutdown_atT.F.worldopened.2 with
⇒
Inregistration_tokenactive shutdown_consumedT.F.worldopened.2
_
⇒
True
Hdistinct :
ptr_addrlibc_stdoutT.F.worldopened ≠ ptr_addrlibc_stderrT.F.worldopened
Hroots :
stdio_rootslibc_stdioT.F.worldopened.1 = libc_active_rootsT.F.worldopened
Hout :
stdout_usablelibc_stdioT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stdout_filelibc_streamsT.F.worldopened.1
Herr :
libc_stderr_openlibc_streamsT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stderr_filelibc_streamsT.F.worldopened.1

split

2 open

opened :
bool
Hrep :
True
Hlocale :
Hu :
shutdown_uniqueT.F.worldopened.2
Hstatus :
−2 ^ 31 ≤ shutdown_statusT.F.worldopened.2 < 2 ^ 31
Hphase :
match shutdown_atT.F.worldopened.2 with
⇒
Inregistration_tokenactive shutdown_consumedT.F.worldopened.2
_
⇒
True
Hdistinct :
ptr_addrlibc_stdoutT.F.worldopened ≠ ptr_addrlibc_stderrT.F.worldopened
Hroots :
stdio_rootslibc_stdioT.F.worldopened.1 = libc_active_rootsT.F.worldopened
Hout :
stdout_usablelibc_stdioT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stdout_filelibc_streamsT.F.worldopened.1
Herr :
libc_stderr_openlibc_streamsT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stderr_filelibc_streamsT.F.worldopened.1
focused goal
opened :
bool
Hrep :
True
Hlocale :
Hu :
shutdown_uniqueT.F.worldopened.2
Hstatus :
−2 ^ 31 ≤ shutdown_statusT.F.worldopened.2 < 2 ^ 31
Hphase :
match shutdown_atT.F.worldopened.2 with
⇒
Inregistration_tokenactive shutdown_consumedT.F.worldopened.2
_
⇒
True
Hdistinct :
ptr_addrlibc_stdoutT.F.worldopened ≠ ptr_addrlibc_stderrT.F.worldopened
Hroots :
stdio_rootslibc_stdioT.F.worldopened.1 = libc_active_rootsT.F.worldopened
Hout :
stdout_usablelibc_stdioT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stdout_filelibc_streamsT.F.worldopened.1
Herr :
libc_stderr_openlibc_streamsT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stderr_filelibc_streamsT.F.worldopened.1

{change stream_wfmkStreamByteOriented [ ] true

2 open

opened :
bool
Hrep :
True
Hlocale :
Hu :
shutdown_uniqueT.F.worldopened.2
Hstatus :
−2 ^ 31 ≤ shutdown_statusT.F.worldopened.2 < 2 ^ 31
Hphase :
match shutdown_atT.F.worldopened.2 with
⇒
Inregistration_tokenactive shutdown_consumedT.F.worldopened.2
_
⇒
True
Hdistinct :
ptr_addrlibc_stdoutT.F.worldopened ≠ ptr_addrlibc_stderrT.F.worldopened
Hroots :
stdio_rootslibc_stdioT.F.worldopened.1 = libc_active_rootsT.F.worldopened
Hout :
stdout_usablelibc_stdioT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stdout_filelibc_streamsT.F.worldopened.1
Herr :
libc_stderr_openlibc_streamsT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stderr_filelibc_streamsT.F.worldopened.1
deferred goal
opened :
bool
Hrep :
True
Hlocale :
Hu :
shutdown_uniqueT.F.worldopened.2
Hstatus :
−2 ^ 31 ≤ shutdown_statusT.F.worldopened.2 < 2 ^ 31
Hphase :
match shutdown_atT.F.worldopened.2 with
⇒
Inregistration_tokenactive shutdown_consumedT.F.worldopened.2
_
⇒
True
Hdistinct :
ptr_addrlibc_stdoutT.F.worldopened ≠ ptr_addrlibc_stderrT.F.worldopened
Hroots :
stdio_rootslibc_stdioT.F.worldopened.1 = libc_active_rootsT.F.worldopened
Hout :
stdout_usablelibc_stdioT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stdout_filelibc_streamsT.F.worldopened.1
Herr :
libc_stderr_openlibc_streamsT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stderr_filelibc_streamsT.F.worldopened.1

cbn [ stream_wf outstanding orientation ]

2 open

opened :
bool
Hrep :
True
Hlocale :
Hu :
shutdown_uniqueT.F.worldopened.2
Hstatus :
−2 ^ 31 ≤ shutdown_statusT.F.worldopened.2 < 2 ^ 31
Hphase :
match shutdown_atT.F.worldopened.2 with
⇒
Inregistration_tokenactive shutdown_consumedT.F.worldopened.2
_
⇒
True
Hdistinct :
ptr_addrlibc_stdoutT.F.worldopened ≠ ptr_addrlibc_stderrT.F.worldopened
Hroots :
stdio_rootslibc_stdioT.F.worldopened.1 = libc_active_rootsT.F.worldopened
Hout :
stdout_usablelibc_stdioT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stdout_filelibc_streamsT.F.worldopened.1
Herr :
libc_stderr_openlibc_streamsT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stderr_filelibc_streamsT.F.worldopened.1
deferred goal
opened :
bool
Hrep :
True
Hlocale :
Hu :
shutdown_uniqueT.F.worldopened.2
Hstatus :
−2 ^ 31 ≤ shutdown_statusT.F.worldopened.2 < 2 ^ 31
Hphase :
match shutdown_atT.F.worldopened.2 with
⇒
Inregistration_tokenactive shutdown_consumedT.F.worldopened.2
_
⇒
True
Hdistinct :
ptr_addrlibc_stdoutT.F.worldopened ≠ ptr_addrlibc_stderrT.F.worldopened
Hroots :
stdio_rootslibc_stdioT.F.worldopened.1 = libc_active_rootsT.F.worldopened
Hout :
stdout_usablelibc_stdioT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stdout_filelibc_streamsT.F.worldopened.1
Herr :
libc_stderr_openlibc_streamsT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stderr_filelibc_streamsT.F.worldopened.1

split ; apply Forall_nil | intros _ ; reflexivity

deferred goal
opened :
bool
Hrep :
True
Hlocale :
Hu :
shutdown_uniqueT.F.worldopened.2
Hstatus :
−2 ^ 31 ≤ shutdown_statusT.F.worldopened.2 < 2 ^ 31
Hphase :
match shutdown_atT.F.worldopened.2 with
⇒
Inregistration_tokenactive shutdown_consumedT.F.worldopened.2
_
⇒
True
Hdistinct :
ptr_addrlibc_stdoutT.F.worldopened ≠ ptr_addrlibc_stderrT.F.worldopened
Hroots :
stdio_rootslibc_stdioT.F.worldopened.1 = libc_active_rootsT.F.worldopened
Hout :
stdout_usablelibc_stdioT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stdout_filelibc_streamsT.F.worldopened.1
Herr :
libc_stderr_openlibc_streamsT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stderr_filelibc_streamsT.F.worldopened.1

split

2 open

opened :
bool
Hrep :
True
Hlocale :
Hu :
shutdown_uniqueT.F.worldopened.2
Hstatus :
−2 ^ 31 ≤ shutdown_statusT.F.worldopened.2 < 2 ^ 31
Hphase :
match shutdown_atT.F.worldopened.2 with
⇒
Inregistration_tokenactive shutdown_consumedT.F.worldopened.2
_
⇒
True
Hdistinct :
ptr_addrlibc_stdoutT.F.worldopened ≠ ptr_addrlibc_stderrT.F.worldopened
Hroots :
stdio_rootslibc_stdioT.F.worldopened.1 = libc_active_rootsT.F.worldopened
Hout :
stdout_usablelibc_stdioT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stdout_filelibc_streamsT.F.worldopened.1
Herr :
libc_stderr_openlibc_streamsT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stderr_filelibc_streamsT.F.worldopened.1
focused goal
opened :
bool
Hrep :
True
Hlocale :
Hu :
shutdown_uniqueT.F.worldopened.2
Hstatus :
−2 ^ 31 ≤ shutdown_statusT.F.worldopened.2 < 2 ^ 31
Hphase :
match shutdown_atT.F.worldopened.2 with
⇒
Inregistration_tokenactive shutdown_consumedT.F.worldopened.2
_
⇒
True
Hdistinct :
ptr_addrlibc_stdoutT.F.worldopened ≠ ptr_addrlibc_stderrT.F.worldopened
Hroots :
stdio_rootslibc_stdioT.F.worldopened.1 = libc_active_rootsT.F.worldopened
Hout :
stdout_usablelibc_stdioT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stdout_filelibc_streamsT.F.worldopened.1
Herr :
libc_stderr_openlibc_streamsT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stderr_filelibc_streamsT.F.worldopened.1

{change stream_wfmkStreamByteOriented 67; 10 false

2 open

opened :
bool
Hrep :
True
Hlocale :
Hu :
shutdown_uniqueT.F.worldopened.2
Hstatus :
−2 ^ 31 ≤ shutdown_statusT.F.worldopened.2 < 2 ^ 31
Hphase :
match shutdown_atT.F.worldopened.2 with
⇒
Inregistration_tokenactive shutdown_consumedT.F.worldopened.2
_
⇒
True
Hdistinct :
ptr_addrlibc_stdoutT.F.worldopened ≠ ptr_addrlibc_stderrT.F.worldopened
Hroots :
stdio_rootslibc_stdioT.F.worldopened.1 = libc_active_rootsT.F.worldopened
Hout :
stdout_usablelibc_stdioT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stdout_filelibc_streamsT.F.worldopened.1
Herr :
libc_stderr_openlibc_streamsT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stderr_filelibc_streamsT.F.worldopened.1
deferred goal
opened :
bool
Hrep :
True
Hlocale :
Hu :
shutdown_uniqueT.F.worldopened.2
Hstatus :
−2 ^ 31 ≤ shutdown_statusT.F.worldopened.2 < 2 ^ 31
Hphase :
match shutdown_atT.F.worldopened.2 with
⇒
Inregistration_tokenactive shutdown_consumedT.F.worldopened.2
_
⇒
True
Hdistinct :
ptr_addrlibc_stdoutT.F.worldopened ≠ ptr_addrlibc_stderrT.F.worldopened
Hroots :
stdio_rootslibc_stdioT.F.worldopened.1 = libc_active_rootsT.F.worldopened
Hout :
stdout_usablelibc_stdioT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stdout_filelibc_streamsT.F.worldopened.1
Herr :
libc_stderr_openlibc_streamsT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stderr_filelibc_streamsT.F.worldopened.1

cbn [ stream_wf outstanding orientation ]

2 open

opened :
bool
Hrep :
True
Hlocale :
Hu :
shutdown_uniqueT.F.worldopened.2
Hstatus :
−2 ^ 31 ≤ shutdown_statusT.F.worldopened.2 < 2 ^ 31
Hphase :
match shutdown_atT.F.worldopened.2 with
⇒
Inregistration_tokenactive shutdown_consumedT.F.worldopened.2
_
⇒
True
Hdistinct :
ptr_addrlibc_stdoutT.F.worldopened ≠ ptr_addrlibc_stderrT.F.worldopened
Hroots :
stdio_rootslibc_stdioT.F.worldopened.1 = libc_active_rootsT.F.worldopened
Hout :
stdout_usablelibc_stdioT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stdout_filelibc_streamsT.F.worldopened.1
Herr :
libc_stderr_openlibc_streamsT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stderr_filelibc_streamsT.F.worldopened.1
deferred goal
opened :
bool
Hrep :
True
Hlocale :
Hu :
shutdown_uniqueT.F.worldopened.2
Hstatus :
−2 ^ 31 ≤ shutdown_statusT.F.worldopened.2 < 2 ^ 31
Hphase :
match shutdown_atT.F.worldopened.2 with
⇒
Inregistration_tokenactive shutdown_consumedT.F.worldopened.2
_
⇒
True
Hdistinct :
ptr_addrlibc_stdoutT.F.worldopened ≠ ptr_addrlibc_stderrT.F.worldopened
Hroots :
stdio_rootslibc_stdioT.F.worldopened.1 = libc_active_rootsT.F.worldopened
Hout :
stdout_usablelibc_stdioT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stdout_filelibc_streamsT.F.worldopened.1
Herr :
libc_stderr_openlibc_streamsT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stderr_filelibc_streamsT.F.worldopened.1

split ; repeat constructor ; lia | intros _ ; reflexivity

deferred goal
opened :
bool
Hrep :
True
Hlocale :
Hu :
shutdown_uniqueT.F.worldopened.2
Hstatus :
−2 ^ 31 ≤ shutdown_statusT.F.worldopened.2 < 2 ^ 31
Hphase :
match shutdown_atT.F.worldopened.2 with
⇒
Inregistration_tokenactive shutdown_consumedT.F.worldopened.2
_
⇒
True
Hdistinct :
ptr_addrlibc_stdoutT.F.worldopened ≠ ptr_addrlibc_stderrT.F.worldopened
Hroots :
stdio_rootslibc_stdioT.F.worldopened.1 = libc_active_rootsT.F.worldopened
Hout :
stdout_usablelibc_stdioT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stdout_filelibc_streamsT.F.worldopened.1
Herr :
libc_stderr_openlibc_streamsT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stderr_filelibc_streamsT.F.worldopened.1

split ; exact Hu |

opened :
bool
Hrep :
True
Hlocale :
Hu :
shutdown_uniqueT.F.worldopened.2
Hstatus :
−2 ^ 31 ≤ shutdown_statusT.F.worldopened.2 < 2 ^ 31
Hphase :
match shutdown_atT.F.worldopened.2 with
⇒
Inregistration_tokenactive shutdown_consumedT.F.worldopened.2
_
⇒
True
Hdistinct :
ptr_addrlibc_stdoutT.F.worldopened ≠ ptr_addrlibc_stderrT.F.worldopened
Hroots :
stdio_rootslibc_stdioT.F.worldopened.1 = libc_active_rootsT.F.worldopened
Hout :
stdout_usablelibc_stdioT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stdout_filelibc_streamsT.F.worldopened.1
Herr :
libc_stderr_openlibc_streamsT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stderr_filelibc_streamsT.F.worldopened.1

split ; exact Hstatus |

opened :
bool
Hrep :
True
Hlocale :
Hu :
shutdown_uniqueT.F.worldopened.2
Hstatus :
−2 ^ 31 ≤ shutdown_statusT.F.worldopened.2 < 2 ^ 31
Hphase :
match shutdown_atT.F.worldopened.2 with
⇒
Inregistration_tokenactive shutdown_consumedT.F.worldopened.2
_
⇒
True
Hdistinct :
ptr_addrlibc_stdoutT.F.worldopened ≠ ptr_addrlibc_stderrT.F.worldopened
Hroots :
stdio_rootslibc_stdioT.F.worldopened.1 = libc_active_rootsT.F.worldopened
Hout :
stdout_usablelibc_stdioT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stdout_filelibc_streamsT.F.worldopened.1
Herr :
libc_stderr_openlibc_streamsT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stderr_filelibc_streamsT.F.worldopened.1

split ; exact Hphase |

opened :
bool
Hrep :
True
Hlocale :
Hu :
shutdown_uniqueT.F.worldopened.2
Hstatus :
−2 ^ 31 ≤ shutdown_statusT.F.worldopened.2 < 2 ^ 31
Hphase :
match shutdown_atT.F.worldopened.2 with
⇒
Inregistration_tokenactive shutdown_consumedT.F.worldopened.2
_
⇒
True
Hdistinct :
ptr_addrlibc_stdoutT.F.worldopened ≠ ptr_addrlibc_stderrT.F.worldopened
Hroots :
stdio_rootslibc_stdioT.F.worldopened.1 = libc_active_rootsT.F.worldopened
Hout :
stdout_usablelibc_stdioT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stdout_filelibc_streamsT.F.worldopened.1
Herr :
libc_stderr_openlibc_streamsT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stderr_filelibc_streamsT.F.worldopened.1

split ; exact Hdistinct |

opened :
bool
Hrep :
True
Hlocale :
Hu :
shutdown_uniqueT.F.worldopened.2
Hstatus :
−2 ^ 31 ≤ shutdown_statusT.F.worldopened.2 < 2 ^ 31
Hphase :
match shutdown_atT.F.worldopened.2 with
⇒
Inregistration_tokenactive shutdown_consumedT.F.worldopened.2
_
⇒
True
Hdistinct :
ptr_addrlibc_stdoutT.F.worldopened ≠ ptr_addrlibc_stderrT.F.worldopened
Hroots :
stdio_rootslibc_stdioT.F.worldopened.1 = libc_active_rootsT.F.worldopened
Hout :
stdout_usablelibc_stdioT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stdout_filelibc_streamsT.F.worldopened.1
Herr :
libc_stderr_openlibc_streamsT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stderr_filelibc_streamsT.F.worldopened.1

split ; exact Hroots |

opened :
bool
Hrep :
True
Hlocale :
Hu :
shutdown_uniqueT.F.worldopened.2
Hstatus :
−2 ^ 31 ≤ shutdown_statusT.F.worldopened.2 < 2 ^ 31
Hphase :
match shutdown_atT.F.worldopened.2 with
⇒
Inregistration_tokenactive shutdown_consumedT.F.worldopened.2
_
⇒
True
Hdistinct :
ptr_addrlibc_stdoutT.F.worldopened ≠ ptr_addrlibc_stderrT.F.worldopened
Hroots :
stdio_rootslibc_stdioT.F.worldopened.1 = libc_active_rootsT.F.worldopened
Hout :
stdout_usablelibc_stdioT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stdout_filelibc_streamsT.F.worldopened.1
Herr :
libc_stderr_openlibc_streamsT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stderr_filelibc_streamsT.F.worldopened.1

split ; exact Hout |

opened :
bool
Hrep :
True
Hlocale :
Hu :
shutdown_uniqueT.F.worldopened.2
Hstatus :
−2 ^ 31 ≤ shutdown_statusT.F.worldopened.2 < 2 ^ 31
Hphase :
match shutdown_atT.F.worldopened.2 with
⇒
Inregistration_tokenactive shutdown_consumedT.F.worldopened.2
_
⇒
True
Hdistinct :
ptr_addrlibc_stdoutT.F.worldopened ≠ ptr_addrlibc_stderrT.F.worldopened
Hroots :
stdio_rootslibc_stdioT.F.worldopened.1 = libc_active_rootsT.F.worldopened
Hout :
stdout_usablelibc_stdioT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stdout_filelibc_streamsT.F.worldopened.1
Herr :
libc_stderr_openlibc_streamsT.F.worldopened.1 = true → libc_file_readyT.changed_errno libc_errnoT.F.worldopened.1 libc_stderr_filelibc_streamsT.F.worldopened.1

split ; exact Herr | exact Hsep

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros opened
destruct T.changed_readyopened as Hrep & Hlocale & He & _ & _ & Hu & Hstatus & Hphase & Hdistinct & Hroots & Hout & Herr & Hsep
split ; exact Hrep |
split ; exact Hlocale |
split ; exact He |
split
split ; apply Forall_nil | intros _ ; reflexivity
split
{change stream_wfmkStreamByteOriented 67; 10 false
split ; repeat constructor ; lia | intros _ ; reflexivity
split ; exact Hu |
split ; exact Hstatus |
split ; exact Hphase |
split ; exact Hdistinct |
split ; exact Hroots |
split ; exact Hout |
split ; exact Herr | exact Hsep
326Definition heapopened : bool : gmappiece pval ≔
<[PName−2 ≔ if opened then VStreamOpentoken_handleT.out else VStreamtoken_handleT.out None]><[PName−3 ≔ VStreamOpentoken_handleT.err]>StreamHandleChecks.heap
331Lemma heap_agrees
∀ opened
Explore proof 7 tactics

Initial goal

⊢
∀opened : bool, agreesconversion_mem heapopened

intros opened l v Hl

opened :
bool
v :
Hl :
heapopened !! l = Somev

unfold heap in Hl

opened :
bool
v :
Hl :
<[PName−2 ≔ if opened then VStreamOpentoken_handleT.out else VStreamtoken_handleT.out None]><[PName−3 ≔ VStreamOpentoken_handleT.err]>StreamHandleChecks.heap !! l = Somev

apply lookup_insert_Some in Hl as El Ev | _ Hl

2 open

opened :
bool
v :
El :
PName−2 = l
Ev :
else
=
v
focused goal
opened :
bool
v :
Hl :
<[PName−3 ≔ VStreamOpentoken_handleT.err]>StreamHandleChecks.heap !! l = Somev

–subst l v

2 open

opened :
bool
deferred goal
opened :
bool
v :
Hl :
<[PName−3 ≔ VStreamOpentoken_handleT.err]>StreamHandleChecks.heap !! l = Somev

destruct opened ; exact I

deferred goal
opened :
bool
v :
Hl :
<[PName−3 ≔ VStreamOpentoken_handleT.err]>StreamHandleChecks.heap !! l = Somev

–apply lookup_insert_Some in Hl as El Ev | _ Hl ; subst l v ; exact I |

opened :
bool
v :
Hl :

exact StreamHandleChecks.heap_agreesl v Hl

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros opened l v Hl
unfold heap in Hl
apply lookup_insert_Some in Hl as El Ev | _ Hl
–subst l v
destruct opened ; exact I
–apply lookup_insert_Some in Hl as El Ev | _ Hl ; subst l v ; exact I |
340Lemma entry_wi
∀ opened
libc_diagnostic_wiλ_ _ ⇒ True native T.out T.err 5120 0 conversion_mem F.worldopened heapopened
Proof 56 steps Qed
intros opened
assert Hkeys : ∀l v, stream_data_heap1024 2048 heapopened !! l = Somev → mem_piecel → l ∈ errno_keys5120 0
{intros l v Hl Hmem
apply stream_data_lookup in Hl as Hl & Hno & Hne
unfold heap in Hl
apply lookup_insert_Some in Hl as El Ev | _ Hl ; subst l ; contradiction |
apply lookup_insert_Some in Hl as El Ev | _ Hl ; subst l ; contradiction |
apply lookup_insert_Some in Hl as El Ev | _ Hl ; subst l ; contradiction |
apply lookup_insert_Some in Hl as El Ev | _ Hl ; subst l ; contradiction |
apply elem_of_list_to_map_2 in Hl
change l ∈ byte_ps5120 0 0; 0; 0; 0.*1
apply list_elem_of_fmap
exists l, v
auto
split
–split ; split ; reflexivity | simpl ; lia |
split ; split ; reflexivity | simpl ; lia |
split ; discriminate |
split ; discriminate |
split ; reflexivity |
split ; reflexivity |
split
cbn [ T.out token_key ]
rewrite lookup_insert_eq
destruct opened
–split ; reflexivity |
exists mkStreamInfo1 mkStreamByteOriented 65; 66 true 7
reflexivity
–split ; reflexivity |
split ; reflexivity
split
cbn [ T.err token_key ]
rewrite lookup_insert_ne ; | discriminate
rewrite lookup_insert_eq
split ; reflexivity |
destruct opened ; reflexivity
intros d → | →
all: split ; | intros base l v Hin ; destruct opened ; contradiction
all: split ; apply F.ready |
all: split ; reflexivity |
all: split ; intros root a Hin ; destruct opened ; contradiction |
all: split ; intros base l v Hin ; destruct opened ; contradiction |
all: intros l v Hl Hnot ; destruct l as base | base off | base off | key ; try exact I
all: exfalso ; apply Hnot ; eapply Hkeys ; exact Hl | exact I
–split ; intros root a |
cbn [ T.out T.err token_key ]
rewrite lookup_insert_eq
rewrite lookup_insert_ne ; | discriminate
rewrite lookup_insert_eq
destruct opened ; auto
382Lemma admitted
∀ opened
Explore proof 24 tactics

Initial goal

⊢
∀opened : bool, contract_prespec words conversion_mem F.worldopened

intros opened

opened :
bool

split

2 open

opened :
bool
⊢
contract_prediagnostic_contracterror_format_contractlibc_stream_modelλ_ : mem _ : libc_world ⇒ True λ_ : libc_world _ : ptr _ _ : Z ⇒ False λ_ : libc_world _ : ptr _ _ : stream_state _ : bool ⇒ False libc_stdout libc_stderr libc_diagnostic_contextλ_ : mem _ : libc_world ⇒ True native words conversion_mem F.worldopened
focused goal
opened :
bool

–split

3 open

opened :
bool
⊢
contract_preerror_format_contractlibc_stream_modelλ_ : mem _ : libc_world ⇒ True λ_ : libc_world _ : ptr _ _ : Z ⇒ False λ_ : libc_world _ : ptr _ _ : stream_state _ : bool ⇒ False libc_stdout libc_stderr libc_diagnostic_contextλ_ : mem _ : libc_world ⇒ True native words conversion_mem F.worldopened
focused goal
opened :
bool
⊢
∃status : Z, error_wordswords status
deferred goal
opened :
bool

+exists 0, 0, fmt, [ ], 67, 67, mkStreamInfo2 stdout_initial 3

3 open

opened :
bool
⊢
words = WInt0; WInt0; WPtrfmt ∧ 0 ≤ 0 < 2 ^ 32 ∧ 0 ≤ 0 < 2 ^ 32 ∧ c_stringconversion_mem fmt 67 ∧ narrow_formatconversion_mem 67 [ ] 67 ∧ diagnostic_readylibc_diagnostic_contextλ_ : mem _ : libc_world ⇒ True native conversion_mem F.worldopened ∧ Forallwritable_spanconversion_mem diagnostic_writeslibc_diagnostic_contextλ_ : mem _ : libc_world ⇒ True native F.worldopened ∧ stream_openlibc_stream_modelλ_ : mem _ : libc_world ⇒ True λ_ : libc_world _ : ptr _ _ : Z ⇒ False λ_ : libc_world _ : ptr _ _ : stream_state _ : bool ⇒ False conversion_mem F.worldopened libc_stderrF.worldopened stream_identifier ≔ 2; stream_protocol ≔ stdout_initial; stream_pending ≔ 3 ∧ orientationstream_protocolstream_identifier ≔ 2; stream_protocol ≔ stdout_initial; stream_pending ≔ 3 ≠ WideOriented ∧ libc_stdoutF.worldopened ≠ libc_stderrF.worldopened
deferred goal
opened :
bool
⊢
∃status : Z, error_wordswords status
deferred goal
opened :
bool

split ; reflexivity |

3 open

opened :
bool
⊢
0 ≤ 0 < 2 ^ 32 ∧ 0 ≤ 0 < 2 ^ 32 ∧ c_stringconversion_mem fmt 67 ∧ narrow_formatconversion_mem 67 [ ] 67 ∧ diagnostic_readylibc_diagnostic_contextλ_ : mem _ : libc_world ⇒ True native conversion_mem F.worldopened ∧ Forallwritable_spanconversion_mem diagnostic_writeslibc_diagnostic_contextλ_ : mem _ : libc_world ⇒ True native F.worldopened ∧ stream_openlibc_stream_modelλ_ : mem _ : libc_world ⇒ True λ_ : libc_world _ : ptr _ _ : Z ⇒ False λ_ : libc_world _ : ptr _ _ : stream_state _ : bool ⇒ False conversion_mem F.worldopened libc_stderrF.worldopened stream_identifier ≔ 2; stream_protocol ≔ stdout_initial; stream_pending ≔ 3 ∧ orientationstream_protocolstream_identifier ≔ 2; stream_protocol ≔ stdout_initial; stream_pending ≔ 3 ≠ WideOriented ∧ libc_stdoutF.worldopened ≠ libc_stderrF.worldopened
deferred goal
opened :
bool
⊢
∃status : Z, error_wordswords status
deferred goal
opened :
bool

split ; lia |

3 open

opened :
bool
⊢
0 ≤ 0 < 2 ^ 32 ∧ c_stringconversion_mem fmt 67 ∧ narrow_formatconversion_mem 67 [ ] 67 ∧ diagnostic_readylibc_diagnostic_contextλ_ : mem _ : libc_world ⇒ True native conversion_mem F.worldopened ∧ Forallwritable_spanconversion_mem diagnostic_writeslibc_diagnostic_contextλ_ : mem _ : libc_world ⇒ True native F.worldopened ∧ stream_openlibc_stream_modelλ_ : mem _ : libc_world ⇒ True λ_ : libc_world _ : ptr _ _ : Z ⇒ False λ_ : libc_world _ : ptr _ _ : stream_state _ : bool ⇒ False conversion_mem F.worldopened libc_stderrF.worldopened stream_identifier ≔ 2; stream_protocol ≔ stdout_initial; stream_pending ≔ 3 ∧ orientationstream_protocolstream_identifier ≔ 2; stream_protocol ≔ stdout_initial; stream_pending ≔ 3 ≠ WideOriented ∧ libc_stdoutF.worldopened ≠ libc_stderrF.worldopened
deferred goal
opened :
bool
⊢
∃status : Z, error_wordswords status
deferred goal
opened :
bool

split ; lia |

3 open

opened :
bool
⊢
c_stringconversion_mem fmt 67 ∧ narrow_formatconversion_mem 67 [ ] 67 ∧ diagnostic_readylibc_diagnostic_contextλ_ : mem _ : libc_world ⇒ True native conversion_mem F.worldopened ∧ Forallwritable_spanconversion_mem diagnostic_writeslibc_diagnostic_contextλ_ : mem _ : libc_world ⇒ True native F.worldopened ∧ stream_openlibc_stream_modelλ_ : mem _ : libc_world ⇒ True λ_ : libc_world _ : ptr _ _ : Z ⇒ False λ_ : libc_world _ : ptr _ _ : stream_state _ : bool ⇒ False conversion_mem F.worldopened libc_stderrF.worldopened stream_identifier ≔ 2; stream_protocol ≔ stdout_initial; stream_pending ≔ 3 ∧ orientationstream_protocolstream_identifier ≔ 2; stream_protocol ≔ stdout_initial; stream_pending ≔ 3 ≠ WideOriented ∧ libc_stdoutF.worldopened ≠ libc_stderrF.worldopened
deferred goal
opened :
bool
⊢
∃status : Z, error_wordswords status
deferred goal
opened :
bool

split

4 open

opened :
bool
focused goal
opened :
bool
⊢
narrow_formatconversion_mem 67 [ ] 67 ∧ diagnostic_readylibc_diagnostic_contextλ_ : mem _ : libc_world ⇒ True native conversion_mem F.worldopened ∧ Forallwritable_spanconversion_mem diagnostic_writeslibc_diagnostic_contextλ_ : mem _ : libc_world ⇒ True native F.worldopened ∧ stream_openlibc_stream_modelλ_ : mem _ : libc_world ⇒ True λ_ : libc_world _ : ptr _ _ : Z ⇒ False λ_ : libc_world _ : ptr _ _ : stream_state _ : bool ⇒ False conversion_mem F.worldopened libc_stderrF.worldopened stream_identifier ≔ 2; stream_protocol ≔ stdout_initial; stream_pending ≔ 3 ∧ orientationstream_protocolstream_identifier ≔ 2; stream_protocol ≔ stdout_initial; stream_pending ≔ 3 ≠ WideOriented ∧ libc_stdoutF.worldopened ≠ libc_stderrF.worldopened
deferred goal
opened :
bool
⊢
∃status : Z, error_wordswords status
deferred goal
opened :
bool

∗vm_compute

4 open

opened :
bool
⊢
Someok = Someok ∧ Datatypes.Lt = Datatypes.Lt ∧ Datatypes.Lt = Datatypes.Lt ∧ 67 = 67 ∧ 0 = 0
deferred goal
opened :
bool
⊢
narrow_formatconversion_mem 67 [ ] 67 ∧ diagnostic_readylibc_diagnostic_contextλ_ : mem _ : libc_world ⇒ True native conversion_mem F.worldopened ∧ Forallwritable_spanconversion_mem diagnostic_writeslibc_diagnostic_contextλ_ : mem _ : libc_world ⇒ True native F.worldopened ∧ stream_openlibc_stream_modelλ_ : mem _ : libc_world ⇒ True λ_ : libc_world _ : ptr _ _ : Z ⇒ False λ_ : libc_world _ : ptr _ _ : stream_state _ : bool ⇒ False conversion_mem F.worldopened libc_stderrF.worldopened stream_identifier ≔ 2; stream_protocol ≔ stdout_initial; stream_pending ≔ 3 ∧ orientationstream_protocolstream_identifier ≔ 2; stream_protocol ≔ stdout_initial; stream_pending ≔ 3 ≠ WideOriented ∧ libc_stdoutF.worldopened ≠ libc_stderrF.worldopened
deferred goal
opened :
bool
⊢
∃status : Z, error_wordswords status
deferred goal
opened :
bool

repeat split ; congruence

3 open

deferred goal
opened :
bool
⊢
narrow_formatconversion_mem 67 [ ] 67 ∧ diagnostic_readylibc_diagnostic_contextλ_ : mem _ : libc_world ⇒ True native conversion_mem F.worldopened ∧ Forallwritable_spanconversion_mem diagnostic_writeslibc_diagnostic_contextλ_ : mem _ : libc_world ⇒ True native F.worldopened ∧ stream_openlibc_stream_modelλ_ : mem _ : libc_world ⇒ True λ_ : libc_world _ : ptr _ _ : Z ⇒ False λ_ : libc_world _ : ptr _ _ : stream_state _ : bool ⇒ False conversion_mem F.worldopened libc_stderrF.worldopened stream_identifier ≔ 2; stream_protocol ≔ stdout_initial; stream_pending ≔ 3 ∧ orientationstream_protocolstream_identifier ≔ 2; stream_protocol ≔ stdout_initial; stream_pending ≔ 3 ≠ WideOriented ∧ libc_stdoutF.worldopened ≠ libc_stderrF.worldopened
deferred goal
opened :
bool
⊢
∃status : Z, error_wordswords status
deferred goal
opened :
bool

∗split ; apply format_literal ; lia | discriminate | constructor |

3 open

opened :
bool
⊢
diagnostic_readylibc_diagnostic_contextλ_ : mem _ : libc_world ⇒ True native conversion_mem F.worldopened ∧ Forallwritable_spanconversion_mem diagnostic_writeslibc_diagnostic_contextλ_ : mem _ : libc_world ⇒ True native F.worldopened ∧ stream_openlibc_stream_modelλ_ : mem _ : libc_world ⇒ True λ_ : libc_world _ : ptr _ _ : Z ⇒ False λ_ : libc_world _ : ptr _ _ : stream_state _ : bool ⇒ False conversion_mem F.worldopened libc_stderrF.worldopened stream_identifier ≔ 2; stream_protocol ≔ stdout_initial; stream_pending ≔ 3 ∧ orientationstream_protocolstream_identifier ≔ 2; stream_protocol ≔ stdout_initial; stream_pending ≔ 3 ≠ WideOriented ∧ libc_stdoutF.worldopened ≠ libc_stderrF.worldopened
deferred goal
opened :
bool
⊢
∃status : Z, error_wordswords status
deferred goal
opened :
bool

split ; split ; exact I | apply F.ready |

3 open

opened :
bool
⊢
Forallwritable_spanconversion_mem diagnostic_writeslibc_diagnostic_contextλ_ : mem _ : libc_world ⇒ True native F.worldopened ∧ stream_openlibc_stream_modelλ_ : mem _ : libc_world ⇒ True λ_ : libc_world _ : ptr _ _ : Z ⇒ False λ_ : libc_world _ : ptr _ _ : stream_state _ : bool ⇒ False conversion_mem F.worldopened libc_stderrF.worldopened stream_identifier ≔ 2; stream_protocol ≔ stdout_initial; stream_pending ≔ 3 ∧ orientationstream_protocolstream_identifier ≔ 2; stream_protocol ≔ stdout_initial; stream_pending ≔ 3 ≠ WideOriented ∧ libc_stdoutF.worldopened ≠ libc_stderrF.worldopened
deferred goal
opened :
bool
⊢
∃status : Z, error_wordswords status
deferred goal
opened :
bool

split ; constructor |

3 open

opened :
bool
⊢
stream_openlibc_stream_modelλ_ : mem _ : libc_world ⇒ True λ_ : libc_world _ : ptr _ _ : Z ⇒ False λ_ : libc_world _ : ptr _ _ : stream_state _ : bool ⇒ False conversion_mem F.worldopened libc_stderrF.worldopened stream_identifier ≔ 2; stream_protocol ≔ stdout_initial; stream_pending ≔ 3 ∧ orientationstream_protocolstream_identifier ≔ 2; stream_protocol ≔ stdout_initial; stream_pending ≔ 3 ≠ WideOriented ∧ libc_stdoutF.worldopened ≠ libc_stderrF.worldopened
deferred goal
opened :
bool
⊢
∃status : Z, error_wordswords status
deferred goal
opened :
bool

split

4 open

opened :
bool
⊢
stream_openlibc_stream_modelλ_ : mem _ : libc_world ⇒ True λ_ : libc_world _ : ptr _ _ : Z ⇒ False λ_ : libc_world _ : ptr _ _ : stream_state _ : bool ⇒ False conversion_mem F.worldopened libc_stderrF.worldopened stream_identifier ≔ 2; stream_protocol ≔ stdout_initial; stream_pending ≔ 3
focused goal
opened :
bool
deferred goal
opened :
bool
⊢
∃status : Z, error_wordswords status
deferred goal
opened :
bool

--destruct libc_stream_openλ_ _ ⇒ True λ_ _ _ _ ⇒ False λ_ _ _ _ _ ⇒ False conversion_mem F.worldopened file_handleF.err_file F.err_file F.readyopened ltac:destruct opened ; reflexivity as info Hopen

4 open

opened :
bool
Hopen :
stream_openlibc_stream_modelλ_ : mem _ : libc_world ⇒ True λ_ : libc_world _ : ptr _ _ : Z ⇒ False λ_ : libc_world _ : ptr _ _ : stream_state _ : bool ⇒ False conversion_mem F.worldopened file_handleF.err_file info
⊢
stream_openlibc_stream_modelλ_ : mem _ : libc_world ⇒ True λ_ : libc_world _ : ptr _ _ : Z ⇒ False λ_ : libc_world _ : ptr _ _ : stream_state _ : bool ⇒ False conversion_mem F.worldopened libc_stderrF.worldopened stream_identifier ≔ 2; stream_protocol ≔ stdout_initial; stream_pending ≔ 3
deferred goal
opened :
bool
deferred goal
opened :
bool
⊢
∃status : Z, error_wordswords status
deferred goal
opened :
bool

destruct Hopen as Hr Hlookup Hrest

4 open

opened :
bool
Hr :
stream_replibc_stream_modelλ_ : mem _ : libc_world ⇒ True λ_ : libc_world _ : ptr _ _ : Z ⇒ False λ_ : libc_world _ : ptr _ _ : stream_state _ : bool ⇒ False conversion_mem F.worldopened
Hlookup :
stream_atlibc_stream_modelλ_ : mem _ : libc_world ⇒ True λ_ : libc_world _ : ptr _ _ : Z ⇒ False λ_ : libc_world _ : ptr _ _ : stream_state _ : bool ⇒ False F.worldopened file_handleF.err_file = Someinfo
Hrest :
stream_protocolinfo = stream_state_atlibc_stream_modelλ_ : mem _ : libc_world ⇒ True λ_ : libc_world _ : ptr _ _ : Z ⇒ False λ_ : libc_world _ : ptr _ _ : stream_state _ : bool ⇒ False F.worldopened file_handleF.err_file ∧ stream_info_wfinfo ∧ Forallwritable_spanconversion_mem stream_writeslibc_stream_modelλ_ : mem _ : libc_world ⇒ True λ_ : libc_world _ : ptr _ _ : Z ⇒ False λ_ : libc_world _ : ptr _ _ : stream_state _ : bool ⇒ False F.worldopened file_handleF.err_file
⊢
stream_openlibc_stream_modelλ_ : mem _ : libc_world ⇒ True λ_ : libc_world _ : ptr _ _ : Z ⇒ False λ_ : libc_world _ : ptr _ _ : stream_state _ : bool ⇒ False conversion_mem F.worldopened libc_stderrF.worldopened stream_identifier ≔ 2; stream_protocol ≔ stdout_initial; stream_pending ≔ 3
deferred goal
opened :
bool
deferred goal
opened :
bool
⊢
∃status : Z, error_wordswords status
deferred goal
opened :
bool

assert info = mkStreamInfo2 stdout_initial 3 as →

5 open

opened :
bool
Hr :
stream_replibc_stream_modelλ_ : mem _ : libc_world ⇒ True λ_ : libc_world _ : ptr _ _ : Z ⇒ False λ_ : libc_world _ : ptr _ _ : stream_state _ : bool ⇒ False conversion_mem F.worldopened
Hlookup :
stream_atlibc_stream_modelλ_ : mem _ : libc_world ⇒ True λ_ : libc_world _ : ptr _ _ : Z ⇒ False λ_ : libc_world _ : ptr _ _ : stream_state _ : bool ⇒ False F.worldopened file_handleF.err_file = Someinfo
Hrest :
stream_protocolinfo = stream_state_atlibc_stream_modelλ_ : mem _ : libc_world ⇒ True λ_ : libc_world _ : ptr _ _ : Z ⇒ False λ_ : libc_world _ : ptr _ _ : stream_state _ : bool ⇒ False F.worldopened file_handleF.err_file ∧ stream_info_wfinfo ∧ Forallwritable_spanconversion_mem stream_writeslibc_stream_modelλ_ : mem _ : libc_world ⇒ True λ_ : libc_world _ : ptr _ _ : Z ⇒ False λ_ : libc_world _ : ptr _ _ : stream_state _ : bool ⇒ False F.worldopened file_handleF.err_file
focused goal
opened :
bool
Hr :
stream_replibc_stream_modelλ_ : mem _ : libc_world ⇒ True λ_ : libc_world _ : ptr _ _ : Z ⇒ False λ_ : libc_world _ : ptr _ _ : stream_state _ : bool ⇒ False conversion_mem F.worldopened
Hrest :
stream_protocolstream_identifier ≔ 2; stream_protocol ≔ stdout_initial; stream_pending ≔ 3 = stream_state_atlibc_stream_modelλ_ : mem _ : libc_world ⇒ True λ_ : libc_world _ : ptr _ _ : Z ⇒ False λ_ : libc_world _ : ptr _ _ : stream_state _ : bool ⇒ False F.worldopened file_handleF.err_file ∧ stream_info_wfstream_identifier ≔ 2; stream_protocol ≔ stdout_initial; stream_pending ≔ 3 ∧ Forallwritable_spanconversion_mem stream_writeslibc_stream_modelλ_ : mem _ : libc_world ⇒ True λ_ : libc_world _ : ptr _ _ : Z ⇒ False λ_ : libc_world _ : ptr _ _ : stream_state _ : bool ⇒ False F.worldopened file_handleF.err_file
Hlookup :
stream_atlibc_stream_modelλ_ : mem _ : libc_world ⇒ True λ_ : libc_world _ : ptr _ _ : Z ⇒ False λ_ : libc_world _ : ptr _ _ : stream_state _ : bool ⇒ False F.worldopened file_handleF.err_file = Somestream_identifier ≔ 2; stream_protocol ≔ stdout_initial; stream_pending ≔ 3
⊢
stream_openlibc_stream_modelλ_ : mem _ : libc_world ⇒ True λ_ : libc_world _ : ptr _ _ : Z ⇒ False λ_ : libc_world _ : ptr _ _ : stream_state _ : bool ⇒ False conversion_mem F.worldopened libc_stderrF.worldopened stream_identifier ≔ 2; stream_protocol ≔ stdout_initial; stream_pending ≔ 3
deferred goal
opened :
bool
deferred goal
opened :
bool
⊢
∃status : Z, error_wordswords status
deferred goal
opened :
bool

{destruct opened ; injection Hlookup ; auto

4 open

deferred goal
opened :
bool
Hr :
stream_replibc_stream_modelλ_ : mem _ : libc_world ⇒ True λ_ : libc_world _ : ptr _ _ : Z ⇒ False λ_ : libc_world _ : ptr _ _ : stream_state _ : bool ⇒ False conversion_mem F.worldopened
Hrest :
stream_protocolstream_identifier ≔ 2; stream_protocol ≔ stdout_initial; stream_pending ≔ 3 = stream_state_atlibc_stream_modelλ_ : mem _ : libc_world ⇒ True λ_ : libc_world _ : ptr _ _ : Z ⇒ False λ_ : libc_world _ : ptr _ _ : stream_state _ : bool ⇒ False F.worldopened file_handleF.err_file ∧ stream_info_wfstream_identifier ≔ 2; stream_protocol ≔ stdout_initial; stream_pending ≔ 3 ∧ Forallwritable_spanconversion_mem stream_writeslibc_stream_modelλ_ : mem _ : libc_world ⇒ True λ_ : libc_world _ : ptr _ _ : Z ⇒ False λ_ : libc_world _ : ptr _ _ : stream_state _ : bool ⇒ False F.worldopened file_handleF.err_file
Hlookup :
stream_atlibc_stream_modelλ_ : mem _ : libc_world ⇒ True λ_ : libc_world _ : ptr _ _ : Z ⇒ False λ_ : libc_world _ : ptr _ _ : stream_state _ : bool ⇒ False F.worldopened file_handleF.err_file = Somestream_identifier ≔ 2; stream_protocol ≔ stdout_initial; stream_pending ≔ 3
⊢
stream_openlibc_stream_modelλ_ : mem _ : libc_world ⇒ True λ_ : libc_world _ : ptr _ _ : Z ⇒ False λ_ : libc_world _ : ptr _ _ : stream_state _ : bool ⇒ False conversion_mem F.worldopened libc_stderrF.worldopened stream_identifier ≔ 2; stream_protocol ≔ stdout_initial; stream_pending ≔ 3
deferred goal
opened :
bool
deferred goal
opened :
bool
⊢
∃status : Z, error_wordswords status
deferred goal
opened :
bool

exact conjHr conjHlookup Hrest

3 open

deferred goal
opened :
bool
deferred goal
opened :
bool
⊢
∃status : Z, error_wordswords status
deferred goal
opened :
bool

--split ; discriminate | destruct opened ; discriminate

2 open

deferred goal
opened :
bool
⊢
∃status : Z, error_wordswords status
deferred goal
opened :
bool

+exists 0, 0, fmt, [ ]

2 open

opened :
bool
⊢
words = WInt0; WInt0; WPtrfmt ∧ 0 ≤ 0 < 2 ^ 32 ∧ 0 ≤ 0 < 2 ^ 32
deferred goal
opened :
bool

split ; reflexivity | lia

deferred goal
opened :
bool

–exists 0, fmt, [ ]

opened :
bool
⊢
words = WInt0; WInt0; WPtrfmt ∧ 0 ≤ 0 < 2 ^ 32 ∧ 0 ≤ 0 < 2 ^ 32

split ; reflexivity | lia

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros opened
split
–split
+exists 0, 0, fmt, [ ], 67, 67, mkStreamInfo2 stdout_initial 3
split ; reflexivity |
split ; lia |
split ; lia |
split
∗vm_compute
repeat split ; congruence
∗split ; apply format_literal ; lia | discriminate | constructor |
split ; split ; exact I | apply F.ready |
split ; constructor |
split
--destruct libc_stream_openλ_ _ ⇒ True λ_ _ _ _ ⇒ False λ_ _ _ _ _ ⇒ False conversion_mem F.worldopened file_handleF.err_file F.err_file F.readyopened ltac:destruct opened ; reflexivity as info Hopen
destruct Hopen as Hr Hlookup Hrest
assert info = mkStreamInfo2 stdout_initial 3 as →
{destruct opened ; injection Hlookup ; auto
exact conjHr conjHlookup Hrest
--split ; discriminate | destruct opened ; discriminate
+exists 0, 0, fmt, [ ]
split ; reflexivity | lia
–exists 0, fmt, [ ]
split ; reflexivity | lia
Proof 84 steps Qed
intros opened
exists 0, 0, fmt, [ ], 67, 67, mkStreamInfo2 stdout_initial 3, mkStreamInfo2 mkStreamByteOriented 67; 10 false 3, 67; 10, 67; 10, Accept67; 10
split ; reflexivity |
split ; vm_compute ; repeat split ; congruence |
split ; apply format_literal ; lia | discriminate | constructor |
split ; reflexivity |
split
–repeat constructor ; exists [ ] ; reflexivity |
constructor
–split ; destruct opened ; reflexivity |
split
+split ; apply final_ready |
split ; destruct opened ; reflexivity |
split ; reflexivity |
split
∗split ; split ; repeat constructor ; lia | reflexivity | simpl ; lia
constructor ; exact proj1proj2proj1proj2proj2final_readyopened | constructor
+split ; reflexivity |
split ; reflexivity |
split
∗eapply stream_next ; apply stream_accept ; discriminate | repeat constructor ; lia | constructor
∗split ; reflexivity |
split
--destruct opened
++exists mkStreamInfo1 mkStreamByteOriented [ ] true 7
split ; reflexivity |
split ; reflexivity |
split ; reflexivity |
split ; reflexivity | apply F.close_settles
++split ; reflexivity
--split ; split ; exact I | apply final_ready |
split ; split ; exact I | repeat split ; reflexivity |
split
++destruct opened
**split
---intros root E |
subst root
split
+++right
left
exists mkSpanmkPtr5120 Obj5120 0
split ; right ; left ; reflexivity | reflexivity
+++intros a Ha
left
exists errno_span5120 0
split ; left ; reflexivity |
split
***exact proj1proj2proj1proj2proj2final_readytrue
***exact Ha
---split
+++intros source Hin
left
exists source
split ; exact Hin | reflexivity
+++intros x ; contradiction
**split ; intros root |
split ; intros x ; contradiction
++split
**split
---intros root E |
subst root
split
+++right
left
exists mkSpanmkPtr5120 Obj5120 0
split ; right ; left ; reflexivity | reflexivity
+++intros a Ha
left
exists errno_span5120 0
split ; left ; reflexivity |
split
***exact proj1proj2proj1proj2proj2final_readyopened
***exact Ha
---split
+++intros source Hin
left
exists source
split ; destruct opened ; exact Hin | reflexivity
+++intros x ; destruct opened ; contradiction
**split ; intros root |
split ; right ; reflexivity |
intros a _ _
reflexivity
Explore proof 30 tactics

Initial goal

intros opened

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

7 open

opened :
bool
focused goal
opened :
bool
focused goal
focused goal
opened :
bool
focused goal
opened :
bool
⊢
∀why : reason, CallReturn[ ] ≠ CallResourcewhy
focused goal
opened :
bool
⊢
∀values : listword, CallReturn[ ] = CallReturnvalues → return_shapecontract_returnsspec values ∧ Forallword_authoritycontract_sourcesspec words conversion_mem F.worldopened [ ] T.changed_errno values
focused goal
opened :
bool
⊢
∀status : Z, CallReturn[ ] = CallExitstatus → ∃before : listevent, StreamBytes2 67; 10 = before ++ ProcessExitstatus

–split ; reflexivity |

7 open

opened :
bool
⊢
contract_abierror_format_contractlibc_stream_modelλ_ : mem _ : libc_world ⇒ True λ_ : libc_world _ : ptr _ _ : Z ⇒ False λ_ : libc_world _ : ptr _ _ : stream_state _ : bool ⇒ False libc_stdout libc_stderr libc_diagnostic_contextλ_ : mem _ : libc_world ⇒ True native CVoid args ∧ ∃status errnum format : value rest : listarg, args = ArgW status :: ArgW errnum :: ArgP format :: rest
deferred goal
opened :
bool
deferred goal
deferred goal
opened :
bool
deferred goal
opened :
bool
⊢
∀why : reason, CallReturn[ ] ≠ CallResourcewhy
deferred goal
opened :
bool
⊢
∀values : listword, CallReturn[ ] = CallReturnvalues → return_shapecontract_returnsspec values ∧ Forallword_authoritycontract_sourcesspec words conversion_mem F.worldopened [ ] T.changed_errno values
deferred goal
opened :
bool
⊢
∀status : Z, CallReturn[ ] = CallExitstatus → ∃before : listevent, StreamBytes2 67; 10 = before ++ ProcessExitstatus

split

8 open

opened :
bool
⊢
contract_abierror_format_contractlibc_stream_modelλ_ : mem _ : libc_world ⇒ True λ_ : libc_world _ : ptr _ _ : Z ⇒ False λ_ : libc_world _ : ptr _ _ : stream_state _ : bool ⇒ False libc_stdout libc_stderr libc_diagnostic_contextλ_ : mem _ : libc_world ⇒ True native CVoid args
focused goal
opened :
bool
⊢
∃status errnum format : value rest : listarg, args = ArgW status :: ArgW errnum :: ArgP format :: rest
deferred goal
opened :
bool
deferred goal
deferred goal
opened :
bool
deferred goal
opened :
bool
⊢
∀why : reason, CallReturn[ ] ≠ CallResourcewhy
deferred goal
opened :
bool
⊢
∀values : listword, CallReturn[ ] = CallReturnvalues → return_shapecontract_returnsspec values ∧ Forallword_authoritycontract_sourcesspec words conversion_mem F.worldopened [ ] T.changed_errno values
deferred goal
opened :
bool
⊢
∀status : Z, CallReturn[ ] = CallExitstatus → ∃before : listevent, StreamBytes2 67; 10 = before ++ ProcessExitstatus

+split ; reflexivity |

8 open

opened :
bool
⊢
∃status errnum fmt0 : value rest : listarg, args = ArgW status :: ArgW errnum :: ArgP fmt0 :: rest ∧ Forallpromoted_argument rest
deferred goal
opened :
bool
⊢
∃status errnum format : value rest : listarg, args = ArgW status :: ArgW errnum :: ArgP format :: rest
deferred goal
opened :
bool
deferred goal
deferred goal
opened :
bool
deferred goal
opened :
bool
⊢
∀why : reason, CallReturn[ ] ≠ CallResourcewhy
deferred goal
opened :
bool
⊢
∀values : listword, CallReturn[ ] = CallReturnvalues → return_shapecontract_returnsspec values ∧ Forallword_authoritycontract_sourcesspec words conversion_mem F.worldopened [ ] T.changed_errno values
deferred goal
opened :
bool
⊢
∀status : Z, CallReturn[ ] = CallExitstatus → ∃before : listevent, StreamBytes2 67; 10 = before ++ ProcessExitstatus

exists Const0, Const0, Const0, [ ]

8 open

opened :
bool
⊢
deferred goal
opened :
bool
⊢
∃status errnum format : value rest : listarg, args = ArgW status :: ArgW errnum :: ArgP format :: rest
deferred goal
opened :
bool
deferred goal
deferred goal
opened :
bool
deferred goal
opened :
bool
⊢
∀why : reason, CallReturn[ ] ≠ CallResourcewhy
deferred goal
opened :
bool
⊢
∀values : listword, CallReturn[ ] = CallReturnvalues → return_shapecontract_returnsspec values ∧ Forallword_authoritycontract_sourcesspec words conversion_mem F.worldopened [ ] T.changed_errno values
deferred goal
opened :
bool
⊢
∀status : Z, CallReturn[ ] = CallExitstatus → ∃before : listevent, StreamBytes2 67; 10 = before ++ ProcessExitstatus

split ; reflexivity | constructor

7 open

deferred goal
opened :
bool
⊢
∃status errnum format : value rest : listarg, args = ArgW status :: ArgW errnum :: ArgP format :: rest
deferred goal
opened :
bool
deferred goal
deferred goal
opened :
bool
deferred goal
opened :
bool
⊢
∀why : reason, CallReturn[ ] ≠ CallResourcewhy
deferred goal
opened :
bool
⊢
∀values : listword, CallReturn[ ] = CallReturnvalues → return_shapecontract_returnsspec values ∧ Forallword_authoritycontract_sourcesspec words conversion_mem F.worldopened [ ] T.changed_errno values
deferred goal
opened :
bool
⊢
∀status : Z, CallReturn[ ] = CallExitstatus → ∃before : listevent, StreamBytes2 67; 10 = before ++ ProcessExitstatus

+exists Const0, Const0, Const0, [ ]

7 open

opened :
bool
deferred goal
opened :
bool
deferred goal
deferred goal
opened :
bool
deferred goal
opened :
bool
⊢
∀why : reason, CallReturn[ ] ≠ CallResourcewhy
deferred goal
opened :
bool
⊢
∀values : listword, CallReturn[ ] = CallReturnvalues → return_shapecontract_returnsspec values ∧ Forallword_authoritycontract_sourcesspec words conversion_mem F.worldopened [ ] T.changed_errno values
deferred goal
opened :
bool
⊢
∀status : Z, CallReturn[ ] = CallExitstatus → ∃before : listevent, StreamBytes2 67; 10 = before ++ ProcessExitstatus

reflexivity

6 open

deferred goal
opened :
bool
deferred goal
deferred goal
opened :
bool
deferred goal
opened :
bool
⊢
∀why : reason, CallReturn[ ] ≠ CallResourcewhy
deferred goal
opened :
bool
⊢
∀values : listword, CallReturn[ ] = CallReturnvalues → return_shapecontract_returnsspec values ∧ Forallword_authoritycontract_sourcesspec words conversion_mem F.worldopened [ ] T.changed_errno values
deferred goal
opened :
bool
⊢
∀status : Z, CallReturn[ ] = CallExitstatus → ∃before : listevent, StreamBytes2 67; 10 = before ++ ProcessExitstatus

–apply admitted

5 open

deferred goal
deferred goal
opened :
bool
deferred goal
opened :
bool
⊢
∀why : reason, CallReturn[ ] ≠ CallResourcewhy
deferred goal
opened :
bool
⊢
∀values : listword, CallReturn[ ] = CallReturnvalues → return_shapecontract_returnsspec values ∧ Forallword_authoritycontract_sourcesspec words conversion_mem F.worldopened [ ] T.changed_errno values
deferred goal
opened :
bool
⊢
∀status : Z, CallReturn[ ] = CallExitstatus → ∃before : listevent, StreamBytes2 67; 10 = before ++ ProcessExitstatus

–split

6 open

focused goal
opened :
bool
deferred goal
opened :
bool
deferred goal
opened :
bool
⊢
∀why : reason, CallReturn[ ] ≠ CallResourcewhy
deferred goal
opened :
bool
⊢
∀values : listword, CallReturn[ ] = CallReturnvalues → return_shapecontract_returnsspec values ∧ Forallword_authoritycontract_sourcesspec words conversion_mem F.worldopened [ ] T.changed_errno values
deferred goal
opened :
bool
⊢
∀status : Z, CallReturn[ ] = CallExitstatus → ∃before : listevent, StreamBytes2 67; 10 = before ++ ProcessExitstatus

+eapply D.M.E.effects_local ; apply local_store_bytes | constructor

6 open

opened :
bool
⊢
∀b : Z, 5120 ≤ b < 5120 + 4 → write_authoritycontract_writesspec words conversion_mem F.worldopened [ ] conversion_mem b
deferred goal
opened :
bool
deferred goal
opened :
bool
deferred goal
opened :
bool
⊢
∀why : reason, CallReturn[ ] ≠ CallResourcewhy
deferred goal
opened :
bool
⊢
∀values : listword, CallReturn[ ] = CallReturnvalues → return_shapecontract_returnsspec values ∧ Forallword_authoritycontract_sourcesspec words conversion_mem F.worldopened [ ] T.changed_errno values
deferred goal
opened :
bool
⊢
∀status : Z, CallReturn[ ] = CallExitstatus → ∃before : listevent, StreamBytes2 67; 10 = before ++ ProcessExitstatus

intros a Ha

6 open

opened :
bool
a :
Z
Ha :
5120 ≤ a < 5120 + 4
deferred goal
opened :
bool
deferred goal
opened :
bool
deferred goal
opened :
bool
⊢
∀why : reason, CallReturn[ ] ≠ CallResourcewhy
deferred goal
opened :
bool
⊢
∀values : listword, CallReturn[ ] = CallReturnvalues → return_shapecontract_returnsspec values ∧ Forallword_authoritycontract_sourcesspec words conversion_mem F.worldopened [ ] T.changed_errno values
deferred goal
opened :
bool
⊢
∀status : Z, CallReturn[ ] = CallExitstatus → ∃before : listevent, StreamBytes2 67; 10 = before ++ ProcessExitstatus

left

6 open

opened :
bool
a :
Z
Ha :
5120 ≤ a < 5120 + 4
deferred goal
opened :
bool
deferred goal
opened :
bool
deferred goal
opened :
bool
⊢
∀why : reason, CallReturn[ ] ≠ CallResourcewhy
deferred goal
opened :
bool
⊢
∀values : listword, CallReturn[ ] = CallReturnvalues → return_shapecontract_returnsspec values ∧ Forallword_authoritycontract_sourcesspec words conversion_mem F.worldopened [ ] T.changed_errno values
deferred goal
opened :
bool
⊢
∀status : Z, CallReturn[ ] = CallExitstatus → ∃before : listevent, StreamBytes2 67; 10 = before ++ ProcessExitstatus

exists errno_span5120 0

6 open

opened :
bool
a :
Z
Ha :
5120 ≤ a < 5120 + 4
deferred goal
opened :
bool
deferred goal
opened :
bool
deferred goal
opened :
bool
⊢
∀why : reason, CallReturn[ ] ≠ CallResourcewhy
deferred goal
opened :
bool
⊢
∀values : listword, CallReturn[ ] = CallReturnvalues → return_shapecontract_returnsspec values ∧ Forallword_authoritycontract_sourcesspec words conversion_mem F.worldopened [ ] T.changed_errno values
deferred goal
opened :
bool
⊢
∀status : Z, CallReturn[ ] = CallExitstatus → ∃before : listevent, StreamBytes2 67; 10 = before ++ ProcessExitstatus

split ; apply in_or_app ; right ; apply in_or_app ; left ; destruct opened ; left ; reflexivity |

6 open

opened :
bool
a :
Z
Ha :
5120 ≤ a < 5120 + 4
deferred goal
opened :
bool
deferred goal
opened :
bool
deferred goal
opened :
bool
⊢
∀why : reason, CallReturn[ ] ≠ CallResourcewhy
deferred goal
opened :
bool
⊢
∀values : listword, CallReturn[ ] = CallReturnvalues → return_shapecontract_returnsspec values ∧ Forallword_authoritycontract_sourcesspec words conversion_mem F.worldopened [ ] T.changed_errno values
deferred goal
opened :
bool
⊢
∀status : Z, CallReturn[ ] = CallExitstatus → ∃before : listevent, StreamBytes2 67; 10 = before ++ ProcessExitstatus

split

7 open

opened :
bool
a :
Z
Ha :
5120 ≤ a < 5120 + 4
focused goal
opened :
bool
a :
Z
Ha :
5120 ≤ a < 5120 + 4
deferred goal
opened :
bool
deferred goal
opened :
bool
deferred goal
opened :
bool
⊢
∀why : reason, CallReturn[ ] ≠ CallResourcewhy
deferred goal
opened :
bool
⊢
∀values : listword, CallReturn[ ] = CallReturnvalues → return_shapecontract_returnsspec values ∧ Forallword_authoritycontract_sourcesspec words conversion_mem F.worldopened [ ] T.changed_errno values
deferred goal
opened :
bool
⊢
∀status : Z, CallReturn[ ] = CallExitstatus → ∃before : listevent, StreamBytes2 67; 10 = before ++ ProcessExitstatus

∗exact proj1proj2proj1proj2proj2F.readyopened

6 open

deferred goal
opened :
bool
a :
Z
Ha :
5120 ≤ a < 5120 + 4
deferred goal
opened :
bool
deferred goal
opened :
bool
deferred goal
opened :
bool
⊢
∀why : reason, CallReturn[ ] ≠ CallResourcewhy
deferred goal
opened :
bool
⊢
∀values : listword, CallReturn[ ] = CallReturnvalues → return_shapecontract_returnsspec values ∧ Forallword_authoritycontract_sourcesspec words conversion_mem F.worldopened [ ] T.changed_errno values
deferred goal
opened :
bool
⊢
∀status : Z, CallReturn[ ] = CallExitstatus → ∃before : listevent, StreamBytes2 67; 10 = before ++ ProcessExitstatus

∗unfold span_contains , errno_span

6 open

opened :
bool
a :
Z
Ha :
5120 ≤ a < 5120 + 4
⊢
ptr_addrspan_ptrspan_ptr ≔ ptr_addr ≔ 5120 + 0; ptr_cap ≔ Obj5120; span_size ≔ 4 ≤ a < ptr_addrspan_ptrspan_ptr ≔ ptr_addr ≔ 5120 + 0; ptr_cap ≔ Obj5120; span_size ≔ 4 + span_sizespan_ptr ≔ ptr_addr ≔ 5120 + 0; ptr_cap ≔ Obj5120; span_size ≔ 4
deferred goal
opened :
bool
deferred goal
opened :
bool
deferred goal
opened :
bool
⊢
∀why : reason, CallReturn[ ] ≠ CallResourcewhy
deferred goal
opened :
bool
⊢
∀values : listword, CallReturn[ ] = CallReturnvalues → return_shapecontract_returnsspec values ∧ Forallword_authoritycontract_sourcesspec words conversion_mem F.worldopened [ ] T.changed_errno values
deferred goal
opened :
bool
⊢
∀status : Z, CallReturn[ ] = CallExitstatus → ∃before : listevent, StreamBytes2 67; 10 = before ++ ProcessExitstatus

simpl

6 open

opened :
bool
a :
Z
Ha :
5120 ≤ a < 5120 + 4
⊢
5120 + 0 ≤ a < 5120 + 0 + 4
deferred goal
opened :
bool
deferred goal
opened :
bool
deferred goal
opened :
bool
⊢
∀why : reason, CallReturn[ ] ≠ CallResourcewhy
deferred goal
opened :
bool
⊢
∀values : listword, CallReturn[ ] = CallReturnvalues → return_shapecontract_returnsspec values ∧ Forallword_authoritycontract_sourcesspec words conversion_mem F.worldopened [ ] T.changed_errno values
deferred goal
opened :
bool
⊢
∀status : Z, CallReturn[ ] = CallExitstatus → ∃before : listevent, StreamBytes2 67; 10 = before ++ ProcessExitstatus

lia

5 open

deferred goal
opened :
bool
deferred goal
opened :
bool
deferred goal
opened :
bool
⊢
∀why : reason, CallReturn[ ] ≠ CallResourcewhy
deferred goal
opened :
bool
⊢
∀values : listword, CallReturn[ ] = CallReturnvalues → return_shapecontract_returnsspec values ∧ Forallword_authoritycontract_sourcesspec words conversion_mem F.worldopened [ ] T.changed_errno values
deferred goal
opened :
bool
⊢
∀status : Z, CallReturn[ ] = CallExitstatus → ∃before : listevent, StreamBytes2 67; 10 = before ++ ProcessExitstatus

+split ; apply format_prefix | constructor ; reflexivity | constructor

4 open

deferred goal
opened :
bool
deferred goal
opened :
bool
⊢
∀why : reason, CallReturn[ ] ≠ CallResourcewhy
deferred goal
opened :
bool
⊢
∀values : listword, CallReturn[ ] = CallReturnvalues → return_shapecontract_returnsspec values ∧ Forallword_authoritycontract_sourcesspec words conversion_mem F.worldopened [ ] T.changed_errno values
deferred goal
opened :
bool
⊢
∀status : Z, CallReturn[ ] = CallExitstatus → ∃before : listevent, StreamBytes2 67; 10 = before ++ ProcessExitstatus

–split ; split ; apply format_prefix | reflexivity | reflexivity

3 open

deferred goal
opened :
bool
⊢
∀why : reason, CallReturn[ ] ≠ CallResourcewhy
deferred goal
opened :
bool
⊢
∀values : listword, CallReturn[ ] = CallReturnvalues → return_shapecontract_returnsspec values ∧ Forallword_authoritycontract_sourcesspec words conversion_mem F.worldopened [ ] T.changed_errno values
deferred goal
opened :
bool
⊢
∀status : Z, CallReturn[ ] = CallExitstatus → ∃before : listevent, StreamBytes2 67; 10 = before ++ ProcessExitstatus

–intros why Hbad

3 open

opened :
bool
why :
Hbad :
⊢
False
deferred goal
opened :
bool
⊢
∀values : listword, CallReturn[ ] = CallReturnvalues → return_shapecontract_returnsspec values ∧ Forallword_authoritycontract_sourcesspec words conversion_mem F.worldopened [ ] T.changed_errno values
deferred goal
opened :
bool
⊢
∀status : Z, CallReturn[ ] = CallExitstatus → ∃before : listevent, StreamBytes2 67; 10 = before ++ ProcessExitstatus

discriminate Hbad

2 open

deferred goal
opened :
bool
⊢
∀values : listword, CallReturn[ ] = CallReturnvalues → return_shapecontract_returnsspec values ∧ Forallword_authoritycontract_sourcesspec words conversion_mem F.worldopened [ ] T.changed_errno values
deferred goal
opened :
bool
⊢
∀status : Z, CallReturn[ ] = CallExitstatus → ∃before : listevent, StreamBytes2 67; 10 = before ++ ProcessExitstatus

–intros vs Hvs

2 open

deferred goal
opened :
bool
⊢
∀status : Z, CallReturn[ ] = CallExitstatus → ∃before : listevent, StreamBytes2 67; 10 = before ++ ProcessExitstatus

injection Hvs as ←

2 open

deferred goal
opened :
bool
⊢
∀status : Z, CallReturn[ ] = CallExitstatus → ∃before : listevent, StreamBytes2 67; 10 = before ++ ProcessExitstatus

split ; reflexivity | constructor

deferred goal
opened :
bool
⊢
∀status : Z, CallReturn[ ] = CallExitstatus → ∃before : listevent, StreamBytes2 67; 10 = before ++ ProcessExitstatus

–intros status Hbad

opened :
bool
status :
Z
Hbad :
CallReturn[ ] = CallExitstatus
⊢
∃before : listevent, StreamBytes2 67; 10 = before ++ ProcessExitstatus

discriminate Hbad

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros opened
eapply D.M.E.invoke_normal with born := [ ]
–split ; reflexivity |
split
+split ; reflexivity |
exists Const0, Const0, Const0, [ ]
split ; reflexivity | constructor
+exists Const0, Const0, Const0, [ ]
reflexivity
–apply admitted
–split
+eapply D.M.E.effects_local ; apply local_store_bytes | constructor
intros a Ha
left
exists errno_span5120 0
split ; apply in_or_app ; right ; apply in_or_app ; left ; destruct opened ; left ; reflexivity |
split
∗exact proj1proj2proj1proj2proj2F.readyopened
simpl
lia
+split ; apply format_prefix | constructor ; reflexivity | constructor
–split ; split ; apply format_prefix | reflexivity | reflexivity
–intros why Hbad
discriminate Hbad
–intros vs Hvs
injection Hvs as ←
split ; reflexivity | constructor
–intros status Hbad
discriminate Hbad

Apply the actual frame with both lives/names and all errno bytes. The last sampled byte is one, not its old zero. Closed stdout stays a completed-closed observation; open stderr survives FIFO acceptance.

485Example framed_return: ∀opened, ∃ys, lengthys = 4%nat ∧ agreesT.changed_errno overwritebyte_ps5120 0 ys heapopened ∧ libc_diagnostic_wiλ_ _ ⇒ True native T.out T.err 5120 0 T.changed_errno final_worldopened overwritebyte_ps5120 0 ys heapopened ∧ overwritebyte_ps5120 0 ys heapopened !! PByte5120 3 = SomeVByte1 ∧ overwritebyte_ps5120 0 ys heapopened !! PName−2 = Someif opened then VStreamOpentoken_handleT.out else VStreamtoken_handleT.out None ∧ overwritebyte_ps5120 0 ys heapopened !! PName−3 = SomeVStreamOpentoken_handleT.err
Proof 41 steps Qed
intros opened
destruct D.error_frameλ_ _ ⇒ True λ_ _ _ _ ⇒ False λ_ _ _ _ _ ⇒ False native T.out T.err 5120 0 CVoid args words InterpRuntime.start conversion_mem F.worldopened StreamBytes2 67; 10 [ ] InterpRuntime.start T.changed_errno final_worldopened heapopened 0; 0; 0; 0 returning_callopened heap_agreesopened HelloErrnoChecks.disjoint HelloErrnoChecks.ready entry_wiopened eq_refl as ys & _ & Hlen & Hkeys & Ha & Hd & Hr & Hw
–intros l v Hin
destruct MemLogic.byte_ps_elem_ _ _ _ _ Hin as i & x & Hi & → & →
repeat rewrite lookup_insert_ne ; | discriminate
apply elem_of_list_to_map_1 ; | exact Hin
change base.NoDupPByte5120 0; PByte5120 1; PByte5120 2; PByte5120 3
repeat apply base.NoDup_cons_2 ; set_solver |
apply base.NoDup_nil_2
–exists ys
split ; exact Hlen |
split ; exact Ha |
split ; exact Hw |
split
+destruct ys as | a | b | c | d rest ; try discriminate Hlen
assert rest = [ ] as → by destruct rest ; reflexivity | discriminate Hlen
assert Hl : overwritebyte_ps5120 0 a; b; c; d heapopened !! PByte5120 3 = SomeVByted
repeat rewrite lookup_insert_ne ; | discriminate
apply lookup_insert_eq
destruct Ha_ _ Hl as _ Hbyte
destruct HbytemkRegion5120 5128 Heap Live eq_refl eq_refl as _ & _ & Hvalue
change 1 = d in Hvalue
rewrite Hvalue
exact Hl
+split
∗rewrite overwrite_out ; unfold heap ; apply lookup_insert_eq |
rewrite byte_ps_keys
intros Hin
apply list_elem_of_fmap in Hin as i & E & _
discriminate E
∗rewrite overwrite_out
--unfold heap
rewrite lookup_insert_ne ; | discriminate
apply lookup_insert_eq
--rewrite byte_ps_keys
intros Hin
apply list_elem_of_fmap in Hin as i & E & _
discriminate E
526Example evolving_protocols: libc_diagnostic_frameF.worldtrue final_worldtrue ∧ shutdown_pendingsndfinal_worldtrue = shutdown_pendingsndF.worldtrue ∧ sndfinal_worldtrue ≠ sndF.worldtrue ∧ outstandinglibc_stream_statefinal_worldtrue token_handleT.err = 67; 10
Explore proof 6 tactics

Initial goal

⊢
libc_diagnostic_frameF.worldtrue final_worldtrue ∧ shutdown_pendingfinal_worldtrue.2 = shutdown_pendingF.worldtrue.2 ∧ final_worldtrue.2 ≠ F.worldtrue.2 ∧ outstandinglibc_stream_statefinal_worldtrue token_handleT.err = 67; 10

split ; repeat split ; reflexivity |

⊢
shutdown_pendingfinal_worldtrue.2 = shutdown_pendingF.worldtrue.2 ∧ final_worldtrue.2 ≠ F.worldtrue.2 ∧ outstandinglibc_stream_statefinal_worldtrue token_handleT.err = 67; 10

split ; reflexivity |

⊢
final_worldtrue.2 ≠ F.worldtrue.2 ∧ outstandinglibc_stream_statefinal_worldtrue token_handleT.err = 67; 10

split ; | reflexivity

⊢
final_worldtrue.2 ≠ F.worldtrue.2

intros H

H :
final_worldtrue.2 = F.worldtrue.2
⊢
False

apply f_equalshutdown_stdout in H

⊢
False

discriminate H

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
split ; repeat split ; reflexivity |
split ; reflexivity |
split ; | reflexivity
intros H
apply f_equalshutdown_stdout in H
discriminate H
536Example exact_snapshot_rejected: ∀pending fifo, ¬diagnostic_nameT.out <[PName−2 ≔ VStreamtoken_handleT.out Somepending, fifo]>heaptrue
Explore proof 5 tactics

Initial goal

⊢
∀pending : Z fifo : listZ, ¬diagnostic_nameT.out <[PName−2 ≔ VStreamtoken_handleT.out Somepending, fifo]>heaptrue

intros

pending :
Z
fifo :
listZ
⊢
¬diagnostic_nameT.out <[PName−2 ≔ VStreamtoken_handleT.out Somepending, fifo]>heaptrue

unfold diagnostic_name

pending :
Z
fifo :
listZ
⊢
¬match <[PName−2 ≔ VStreamtoken_handleT.out Somepending, fifo]>heaptrue !! PNametoken_keyT.out with SomeVStream_ None | SomeVStreamOpen_ | None ⇒ True | _ ⇒ False end

cbn [ T.out token_key ]

pending :
Z
fifo :
listZ
⊢
¬match <[PName−2 ≔ VStreamtoken_handleT.out Somepending, fifo]>heaptrue !! PName−2 with SomeVStream_ None | SomeVStreamOpen_ | None ⇒ True | _ ⇒ False end

rewrite lookup_insert_eq

pending :
Z
fifo :
listZ
⊢
¬False

exact λH ⇒ H

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros
cbn [ T.out token_key ]
rewrite lookup_insert_eq
exact λH ⇒ H
541Example exact_open_becomes_stale: stream_currentT.out F.worldtrue T.open_heap ∧ ¬stream_currentT.out final_worldtrue T.open_heap
Explore proof 8 tactics

Initial goal

split ; exact proj1T.open_snapshots_current |

unfold stream_current , T.open_heap

⊢
¬match <[PName−2 ≔ VStreamtoken_handleT.out Some7, 65; 66]><[PName−3 ≔ VStreamtoken_handleT.err Some3, [ ]]>StreamHandleChecks.heap !! PNametoken_keyT.out with SomeVStreamp snapshot ⇒ p = token_handleT.out ∧ stream_observationfinal_worldtrue p snapshot | SomeVStreamOpenp ⇒ p = token_handleT.out ∧ ∃info : stream_info, libc_stream_atfinal_worldtrue p = Someinfo | None ⇒ True | _ ⇒ False end

cbn [ T.out token_key ]

⊢
¬match <[PName−2 ≔ VStreamtoken_handleT.out Some7, 65; 66]><[PName−3 ≔ VStreamtoken_handleT.err Some3, [ ]]>StreamHandleChecks.heap !! PName−2 with SomeVStreamp snapshot ⇒ p = token_handleT.out ∧ stream_observationfinal_worldtrue p snapshot | SomeVStreamOpenp ⇒ p = token_handleT.out ∧ ∃info : stream_info, libc_stream_atfinal_worldtrue p = Someinfo | None ⇒ True | _ ⇒ False end

rewrite lookup_insert_eq

⊢
¬token_handleT.out = token_handleT.out ∧ stream_observationfinal_worldtrue token_handleT.out Some7, 65; 66

intros _ info Hlookup _ Hfifo

Hlookup :
Hfifo :
⊢
False

change SomemkStreamInfo1 mkStreamByteOriented [ ] true 7 = Someinfo in Hlookup

Hlookup :
Somestream_identifier ≔ 1; stream_protocol ≔ orientation ≔ ByteOriented; outstanding ≔ [ ]; stream_error ≔ true; stream_pending ≔ 7 = Someinfo
Hfifo :
⊢
False

injection Hlookup as ←

discriminate Hfifo

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
split ; exact proj1T.open_snapshots_current |
cbn [ T.out token_key ]
rewrite lookup_insert_eq
intros _ info Hlookup _ Hfifo
change SomemkStreamInfo1 mkStreamByteOriented [ ] true 7 = Someinfo in Hlookup
injection Hlookup as ←
discriminate Hfifo
557Example private_byte_rejected: ∀m w h v, h !! PByte1024 0 = Somev → live_atm 1024 token_regionT.out → ¬libc_diagnostic_wiλ_ _ ⇒ True writing_native T.out T.err 5120 0 m w h
Explore proof 2 tactics

Initial goal

⊢
∀m : mem w : libc_world h : gmappiece pval v : pval, h !! PByte1024 0 = Somev → live_atm 1024 token_regionT.out → ¬libc_diagnostic_wiλ_ : mem _ : libc_world ⇒ True writing_native T.out T.err 5120 0 m w h

intros m w h v Hl Hlive _ Hroots _

m :
h :
v :
Hl :
h !! PByte1024 0 = Somev
Hlive :
⊢
False

exact StreamHandleChecks.private_byte_rejectedm h v Hl Hlive Hroots

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros m w h v Hl Hlive _ Hroots _
exact StreamHandleChecks.private_byte_rejectedm h v Hl Hlive Hroots
565Example private_aux_rejected: ∀m w h v, h !! PAux1024 0 = Somev → live_atm 1024 token_regionT.out → ¬libc_diagnostic_wiλ_ _ ⇒ True writing_native T.out T.err 5120 0 m w h
Explore proof 2 tactics

Initial goal

⊢
∀m : mem w : libc_world h : gmappiece pval v : pval, h !! PAux1024 0 = Somev → live_atm 1024 token_regionT.out → ¬libc_diagnostic_wiλ_ : mem _ : libc_world ⇒ True writing_native T.out T.err 5120 0 m w h

intros m w h v Hl Hlive _ Hroots _

m :
h :
v :
Hl :
h !! PAux1024 0 = Somev
Hlive :
⊢
False

exact StreamHandleChecks.private_aux_rejectedm h v Hl Hlive Hroots

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros m w h v Hl Hlive _ Hroots _
exact StreamHandleChecks.private_aux_rejectedm h v Hl Hlive Hroots
573Example nonzero_not_returning: ∀m w, ¬contract_prespec WInt1; WInt0; WPtrfmt m w
Explore proof 5 tactics

Initial goal

⊢

intros m w

apply nonzero_error_not_returning with status := 1

2 open

focused goal
⊢
1 ≠ 0

–exists 0, fmt, [ ]

2 open

⊢
WInt1; WInt0; WPtrfmt = WInt1; WInt0; WPtrfmt ∧ 0 ≤ 1 < 2 ^ 32 ∧ 0 ≤ 0 < 2 ^ 32
deferred goal
⊢
1 ≠ 0

split ; reflexivity | lia

deferred goal
⊢
1 ≠ 0

–lia

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros m w
apply nonzero_error_not_returning with status := 1
–exists 0, fmt, [ ]
split ; reflexivity | lia
–lia