rocq/theories/Selected.v
Selected libc lifecycle segments, over the existing external-call effect discipline. Admission precedes behavior existence. Successful invocations supply their own logical endpoint and allocator readiness; neither is inferred from an unfinished prefix. Native satisfaction and coverage remain trusted obligations, not theorems of this adapter.
No changes to the core machine, runtime axioms or shutdown leaves.
Logical libc validity is separate from allocator readiness. Each action selects its own capability sources, writable spans, owned releases and allocation requests; reachability alone grants none of those rights. Validity must retain pending/active callback code and arguments, not require already-consumed arguments to remain live forever.
| libc_valid | : mem → stdio_world → shutdown_state → Prop | |
| selected_action | : mem → stdio_world → shutdown_state → shutdown_action → Prop | |
| segment_sources | : shutdown_state → shutdown_action → mem → stdio_world → listspan | |
| segment_writes | : shutdown_state → shutdown_action → mem → stdio_world → listspan | |
| segment_releases | : shutdown_state → shutdown_action → mem → stdio_world → listZ | |
| segment_requests | : shutdown_state → shutdown_action → mem → stdio_world → Z → Z → Prop | |
| segment_prefix | : shutdown_state → shutdown_action → mem → stdio_world → listZ → listevent → mem → stdio_world → Prop | |
| segment_panics | : shutdown_state → shutdown_action → reason → Prop |
Completion shares the very same logical target between the contract postcondition and the outer adapter. The lifecycle edge fixes phase, status, inventory and FIFO output transfer; validity supplies the native representation obligation. It says nothing about native totality.
Empty arguments/void return describe a logical segment marker, NOT a callback's C ABI or a native return from exit/_exit. Enabled selection and source validity are checked even when no invocation exists.
Runtime readiness is never hidden inside a memory-only precondition.
The adapter uses the contract's actual normal post, not a second independently supplied action-post or endpoint-readiness hypothesis.
Admission is independent of invocation existence, but restricted to explicitly selected actions. InCallback's logical register rule alone cannot authorize an unknown callback.
Explore proof 7 tactics
Initial goal
intros specs s m w sh action full _ Hvalid Hselect Hstep
split ; split ; reflexivity |
split ; reflexivity |
split ; exact Hvalid |
split ; exact Hselect |
exists full
exact Hstep
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
The born list, prefix and normal post all come from the SAME invocation. Runtime readiness follows its effect path; logical validity follows its post. Resource endings and unfinished prefixes do not take this rule.
Explore proof 4 tactics
Initial goal
intros specs s m w sh action trace s′ m′ w′ Hr Hcall
pose proof E.invoke_preserve_ _ _ _ _ _ _ _ _ _ _ _ _ Hcall Hr as Hr′ _
inversion Hcall ; subst
match goal withHpre : contract_pre_ _ _ _ , Hpost : contract_post_ _ _ _ _ _ _ _ _ |- _⇒destruct Hpre as _ Hvalid Hselect Henabled ; destruct Hpost as _ target Hstep Htrace Hvalid′ ; exists target ; eapply P.realize_action ; simpl ; exact Hstep | split ; assumption | eapply selected_admits ; split ; assumption | exact Hselect | exact Hstep | eassumption | repeat split ; assumption | exact Htrace | split ; assumptionend
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
The body may carry a stronger opaque invariant for its ACTUAL entry inventory. This conservative form accepts every well-formed logical output queue; queues are obligations, not a claim about physical FILE buffers. Native puts preservation of this stronger invariant remains part of the trusted contract, not a new runtime axiom.
Exact entry readiness survives a finite application run through the existing step theorem, without resetting to R.start after startup.
Explore proof 6 tactics
Initial goal
intros specs inventory requests st trace st′ Hrun
induction Hrun ; auto |
intros Hr
apply IHHrun
eapply P.M.step_ready ; | exact H | exact Hr
reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Reached returning puts retains the selected entry's inventory AND its callback-validity representation. The former alone would be insufficient. This discharges the existing reached-call closure, not native coverage.
Explore proof 12 tactics
Initial goal
intros specs inventory requests start Hstable Hinv Hr Hinitial
intros first s m w fuel trace n s′ m′ w′ Hrun Hcall
pose proof P.body_run_inventory_ _ Hstable _ _ _ Hrun Hinv as Hpending
simpl in Hpending
rewrite Hinitial in Hpending
destruct P.C.program_invoke_continuity_ _ _ _ _ _ _ _ _ _ _ _ _ Hcall as Hpending′ _ Hwf _
destruct E.invoke_prefix_ _ _ _ _ _ _ _ _ _ _ _ _ Hcall as born _ Hrep _ _
split
2 openfocused goal
–exact proj1E.invoke_preserve_ _ _ _ _ _ _ _ _ _ _ _ _ Hcall body_ready_ _ _ _ _ _ Hrun Hr
deferred goal
–rewrite Hpending′ , Hpending
apply Hrep
exact Hwf
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
A finite chain of actual normal invocations at exact shared snapshots. Logical edges name the targets; their validity and runtime readiness are extracted from those same calls, not supplied for each endpoint. This is not coverage of unfinished, refused or native executions.
Lift the invocation chain through the existing adapter. Logical target uniqueness identifies its extracted endpoint with the named cutpoint.
Explore proof 14 tactics
Initial goal
intros specs s m w sh trace s′ m′ w′ sh′ rep requests host Hrun
induction Hrun ; intros Hr
2 openfocused goal
–split ; constructor | auto
deferred goal
–destruct invocation_realizes_ _ _ _ _ _ _ _ _ _ Hr H0 as target Hreal
assert Htarget : target = sh1
2 openfocused goal
{inversion Hreal ; subst
2 opendeferred goal
eapply shutdown_step_target ; eauto
deferred goal
subst target
destruct IHHrunproj1E.invoke_preserve_ _ _ _ _ _ _ _ _ _ _ _ _ H0 Hr as Htail Hwf
split
2 openfocused goal
+eapply P.program_next ; apply P.program_shutdown with action := action ; exact Hreal | exact Htail
deferred goal
+intros Hq
apply Hwf
destruct H ; simpl in * ; try exact Hq ; eapply stream_step_wf ; eauto
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Conditional hi composition under the selected trusted libc contracts: exact successful entry, reached returning puts, normal shutdown calls, and an explicit completion witness at the resulting handoff. Nothing here claims that native execution supplies these witnesses or terminates.
Proof 17 steps Qed
Finite-observation safety is separate from witnessed completion. It includes unfinished/resource leaves, promises at most one exit event, and retains the shared nonfailure classification for application stops. It does not establish native coverage of the outer relation.
Explore proof 9 tactics
Initial goal
intros specs inventory requests completed s m w argc argv envp args environment fuel trace last Hstable Hentry Hrun
pose proof A.trusted_entry_bodyentry_repspecs inventory s m w argc argv envp args environment fuel Hentry as Hbody
destruct Hentry as _ & Hr & _
split ; eapply P.run_ready ; eauto |
split
2 openfocused goal
–eapply P.at_most_one_exit ; eauto
deferred goal
–intros why ms w′ →
eapply P.application_stopped_never_panics ; eauto
exact Hbody
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Logical instances exercise admission and cutpoints, not native libc. In particular the named callback below is a fixture, not an assertion that arbitrary user callbacks belong to the trusted libc boundary.
One admitted callback retains an actual readable object capability.
The pending inventory and currently running callback need valid arguments; consumed history alone does not retain dead argument objects.
Selection of a new registration is checked independently of token freshness.
A memory-backed fixture with separate readable argument and writable stdout roots. Neither root may be released; no allocations are authorized.
A nonempty inventory, with a retained capability rather than an integer address.
The entry representation is inhabited for every well-formed logical queue.
Explore proof 9 tactics
Initial goal
intros q Hwf
split ; split ; reflexivity |
split
2 openfocused goal
–split ; | exact I
2 opendeferred goal
constructor ; split ; reflexivity | constructor
deferred goal
–split ; exact Hwf |
repeat constructor
simpl
tauto
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Change only behavioral coverage: the same valid, selected source keeps its ABI/preconditions, permissions and post, but has no possible prefix. This is not a pinned native instance or a safe implementation.
Independent admission survives deleting every behavior. Thus neither admission nor absence of invocations can establish native coverage.
Explore proof 14 tactics
Initial goal
intros sh action
assert Hnone : ∀born trace s′ m′ w′, ¬S.E.prefixS.selected_contractuncovered_specs sh action [ ] InterpRuntime.start hello_mem hello_world born trace s′ m′ w′
2 openfocused goal
{intros born trace s′ m′ w′ _ Hfalse
2 opendeferred goal
exact Hfalse
deferred goal
split
2 openfocused goal
–eapply S.selected_admits
5 openfocused goal
focused goal
deferred goal
shelved goal
+split ; apply hello_ready ; split ; vm_compute ; congruence |
5 opendeferred goal
deferred goal
deferred goal
shelved goal
exact nonempty_entrystdout_initial stdout_initial_wf
4 opendeferred goal
deferred goal
deferred goal
shelved goal
+split ; reflexivity
3 opendeferred goal
deferred goal
shelved goal
+constructor
deferred goal
–split ; exact Hnone |
intros trace ending s′ m′ w′ Hcall
destruct S.E.invoke_prefix_ _ _ _ _ _ _ _ _ _ _ _ _ Hcall as born Hprefix
exact Hnoneborn trace s′ m′ w′ Hprefix
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
A fresh token cannot authorize an unknown callback, even where the logical register rule permits it. No invocation witness is needed for rejection.
Explore proof 2 tactics
Initial goal
intros s sh unknown _ _ _ Hname _ _
discriminate Hname
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Keeping the token and address while losing the retained capability's live bounds invalidates the entry, rather than silently removing its behavior.
Explore proof 2 tactics
Initial goal
intros s dead _ _ _ _ Hread _
discriminate Hread
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
A selected segment really has no release ownership, even of its readable callback argument. Reuse the existing asymmetric footprint regression.
Explore proof 5 tactics
Initial goal
intros _ & Hr & _
destruct Hr3072 mkRegion3072 3072 Heap Freed eq_refl as reg & Hreg & H | & _
change SomemkRegion3072 3080 Heap Live = Somereg in Hreg
injection Hreg as ←
discriminate H
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Read authority for the argument is not write authority for its bytes.
Explore proof 5 tactics
Initial goal
intros _ & _ & Hw & _
assert Hn : ¬write_authoritystdout_span [ ] hello_mem 3072
2 openfocused goal
{intros root & ← | & _ & Hin | base & reg & & _ ; unfold span_contains in Hin ; simpl in Hin ; lia
deferred goal
destruct Hw_ Hn as Hb _
discriminate Hb
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
An identity-memory fixture completes a selected, independently admissible logical action. Its full invocation—not merely a prefix—supplies the post.
Explore proof 20 tactics
Initial goal
intros m w sh action sh′ Hvalid Hselect Hstep Hvalid′
eapply S.E.invoke_normal with born := [ ]
7 openfocused goal
focused goal
focused goal
focused goal
focused goal
focused goal
–split ; reflexivity
6 opendeferred goal
deferred goal
deferred goal
deferred goal
deferred goal
deferred goal
–split ; reflexivity |
6 opendeferred goal
deferred goal
deferred goal
deferred goal
deferred goal
split ; exact Hvalid |
6 opendeferred goal
deferred goal
deferred goal
deferred goal
deferred goal
split ; exact Hselect |
6 opendeferred goal
deferred goal
deferred goal
deferred goal
deferred goal
exists sh′
6 opendeferred goal
deferred goal
deferred goal
deferred goal
deferred goal
exact Hstep
5 opendeferred goal
deferred goal
deferred goal
deferred goal
deferred goal
–split ; constructor | reflexivity
4 opendeferred goal
deferred goal
deferred goal
deferred goal
–split ; reflexivity |
4 opendeferred goal
deferred goal
deferred goal
exists sh′
4 opendeferred goal
deferred goal
deferred goal
split ; exact Hstep |
4 opendeferred goal
deferred goal
deferred goal
auto
3 opendeferred goal
deferred goal
deferred goal
–intros why Hbad
3 opendeferred goal
deferred goal
discriminate Hbad
2 opendeferred goal
deferred goal
–intros values Heq
2 opendeferred goal
injection Heq as ←
2 opendeferred goal
split ; constructor
deferred goal
–intros status Hbad
discriminate Hbad
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
The adapter's successful-invocation theorem is inhabited with a nonempty admitted inventory and retains the active callback's readable argument.
Explore proof 12 tactics
Initial goal
apply S.invocation_realizes ; apply hello_ready ; split ; vm_compute ; congruence |
eapply fixture_invocation with sh′ := mkShutdownInCallbackentry 0 [ ] 0%nat stdout_initial
4 openfocused goal
focused goal
focused goal
–exact nonempty_entrystdout_initial stdout_initial_wf
3 opendeferred goal
deferred goal
deferred goal
–split ; reflexivity
2 opendeferred goal
deferred goal
–constructor
deferred goal
–split ; split ; reflexivity |
split
2 openfocused goal
+split ; constructor | split ; reflexivity
deferred goal
+split ; exact stdout_initial_wf |
repeat constructor
simpl
tauto
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Valid completed cleanup cutpoints retain the same memory and consumed inventory while output obligations evolve. No terminal leaf is resumed.
All well-formed fixture cleanup snapshots satisfy the logical post.
Explore proof 7 tactics
Initial goal
intros q Hwf
split ; split ; reflexivity |
split ; split ; constructor |
split ; exact Hwf |
repeat constructor
simpl
tauto
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Each completed cutpoint comes from a real contract invocation.
Explore proof 25 tactics
Initial goal
intros q action q′ Hnot Hstream Hwf
assert Hstep : shutdown_stepcleanupq ShutdownOutputaction cleanupq′ by apply shutdown_cleanup_output ; assumption
assert Hcall := fixture_invocationhello_mem hello_world cleanupq ShutdownOutputaction cleanupq′ cleanup_valid_ Hwf I Hstep cleanup_valid_ stream_step_wf_ _ _ Hstream Hwf
assert Hevents : P.action_eventsShutdownOutputaction = [ ]
2 openfocused goal
{destruct action ; try reflexivity
2 opendeferred goal
exfalso
2 opendeferred goal
apply Hnotbytes
2 opendeferred goal
reflexivity
deferred goal
rewrite Hevents in Hcall
destruct S.E.invoke_prefix_ _ _ _ _ _ _ _ _ _ _ _ _ Hcall as born Hprefix
assert Hr := hello_readyInterpRuntime.start ltac:split ; vm_compute ; congruence
eapply P.realize_action with born := born
7 openfocused goal
focused goal
focused goal
focused goal
focused goal
focused goal
–exact Hstep
6 opendeferred goal
deferred goal
deferred goal
deferred goal
deferred goal
deferred goal
–split ; exact Hr | apply cleanup_valid ; exact Hwf
5 opendeferred goal
deferred goal
deferred goal
deferred goal
deferred goal
–eapply S.selected_admits ; split ; exact Hr | apply cleanup_valid ; exact Hwf | exact I | exact Hstep
4 opendeferred goal
deferred goal
deferred goal
deferred goal
–exact Hprefix
3 opendeferred goal
deferred goal
deferred goal
–split ; exact Hstep |
3 opendeferred goal
deferred goal
split ; symmetry ; exact Hevents |
3 opendeferred goal
deferred goal
apply cleanup_valid
3 opendeferred goal
deferred goal
eapply stream_step_wf ; eauto
2 opendeferred goal
deferred goal
–symmetry
2 opendeferred goal
exact Hevents
deferred goal
–split ; exact Hr |
apply cleanup_valid
eapply stream_step_wf ; eauto
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Delivery, a zero-progress error, and discard are three completed segments with exact intermediate queues. Silent observations do not mean delivery and discard are the same operation.
Explore proof 14 tactics
Initial goal
intros rep requests host
eapply P.program_next with trace := [ ] tail := [ ] mid := P.ShuttingDownInterpRuntime.start hello_mem hello_world cleanupmkStreamByteOriented 66 false
2 openfocused goal
–apply P.program_shutdown with action := ShutdownOutputDeliver65
2 opendeferred goal
apply cleanup_realized ; discriminate | apply stream_deliver65 66 false ; discriminate |
2 opendeferred goal
split ; repeat constructor ; lia | reflexivity
deferred goal
–eapply P.program_next with trace := [ ] tail := [ ] mid := P.ShuttingDownInterpRuntime.start hello_mem hello_world cleanupmkStreamByteOriented 66 true
2 openfocused goal
+apply P.program_shutdown with action := ShutdownOutputOutputError
2 opendeferred goal
apply cleanup_realized ; discriminate | constructor |
2 opendeferred goal
split ; repeat constructor ; lia | reflexivity
deferred goal
+eapply P.program_next with trace := [ ] tail := [ ]
3 openfocused goal
shelved goal
∗apply P.program_shutdown with action := ShutdownOutputDiscard66
6 opendeferred goal
shelved goal
shelved goal
shelved goal
shelved goal
apply cleanup_realized ; discriminate | apply stream_discard66 [ ] true ; discriminate |
2 opendeferred goal
split ; repeat constructor ; lia | reflexivity
deferred goal
∗constructor
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
A successful logical entry with argv, environment, the generated hi literal, stdout storage and the nonempty admitted callback inventory.
The concrete startup vectors and retained callback argument are genuine readable capabilities; a logical queue is not a physical FILE claim.
Explore proof 31 tactics
Initial goal
split
2 open–split ; lia |
2 opendeferred goal
split ; reflexivity |
2 opendeferred goal
split
3 openfocused goal
deferred goal
+split ; reflexivity |
3 opendeferred goal
deferred goal
exists hi_literal
3 opendeferred goal
deferred goal
split ; vm_compute ; repeat split ; congruence |
3 opendeferred goal
deferred goal
split ; vm_compute ; repeat split ; try congruence ; lia |
3 opendeferred goal
deferred goal
vm_compute
3 opendeferred goal
deferred goal
repeat split ; congruence
2 opendeferred goal
deferred goal
+vm_compute
2 opendeferred goal
repeat split ; congruence
deferred goal
–split
2 open+intros q Hwf
2 opensplit ; split ; reflexivity |
2 opensplit
3 openfocused goal
∗split ; | exact I
3 opendeferred goal
constructor ; split ; reflexivity | constructor
2 opendeferred goal
∗split ; exact Hwf |
2 openrepeat constructor
2 opensimpl
2 opentauto
+split
2 openfocused goal
∗split ; reflexivity |
2 opendeferred goal
constructor ; | constructor
2 opendeferred goal
split ; simpl ; lia |
2 opendeferred goal
exists 2048, mkRegion2048 2064 Heap Live
2 opendeferred goal
repeat split ; reflexivity
deferred goal
∗split ; reflexivity |
vm_compute
repeat split ; try congruence ; lia
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Every static object is below the actual entry allocator state, and the vector/literal stores do not write above that state.
Proof 42 steps Qed
The actual puts invocation keeps the nonempty inventory and accepts the bytes before the later hard exit, without asserting descriptor delivery.
Proof 42 steps Qed
Three genuine logical cutpoints: TLS, callback entry, then the callback's hard exit. Tokens are consumed once, and accepted bytes stay outstanding.
Proof 36 steps Qed
Host completion is witnessed only at this full handoff snapshot.
A different status or an invented empty queue does not match the witness.
Explore proof 1 tactics
Initial goal
split ; intros _ & _ & _ & Hsnapshot ; discriminate Hsnapshot
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
This full logical path uses the composition theorem, an actual returning puts, nonempty callback admission, and a supplied exact host witness. The observed exit is 258 mod 256 = 2, not main's original zero status.
Explore proof 15 tactics
Initial goal
replace StreamBytes1 hello_bytes ++ 10; ProcessExit2 with [ ] ++ StreamBytes1 hello_bytes ++ 10 ++ [ ] ++ ProcessExitprocess_status258 by reflexivity
eapply S.trusted_hi_completion with inventory := entry argc := 1 argv := entry_argv envp := entry_envp args := hello_bytes environment := [ ] n := 6
14 openfocused goal
focused goal
focused goal
focused goal
focused goal
focused goal
shelved goal
shelved goal
shelved goal
shelved goal
shelved goal
shelved goal
shelved goal
–apply HiChecks.interpreter_stdio_stable
13 opendeferred goal
deferred goal
deferred goal
deferred goal
deferred goal
deferred goal
shelved goal
shelved goal
shelved goal
shelved goal
shelved goal
shelved goal
shelved goal
–split ; exact proj1completion_entry_image |
13 opendeferred goal
deferred goal
deferred goal
deferred goal
deferred goal
shelved goal
shelved goal
shelved goal
shelved goal
shelved goal
shelved goal
shelved goal
split ; exact completion_ready |
13 opendeferred goal
deferred goal
deferred goal
deferred goal
deferred goal
shelved goal
shelved goal
shelved goal
shelved goal
shelved goal
shelved goal
shelved goal
split ; exact proj2completion_entry_image |
13 opendeferred goal
deferred goal
deferred goal
deferred goal
deferred goal
shelved goal
shelved goal
shelved goal
shelved goal
shelved goal
shelved goal
shelved goal
split
14 openfocused goal
deferred goal
deferred goal
deferred goal
deferred goal
deferred goal
shelved goal
shelved goal
shelved goal
shelved goal
shelved goal
shelved goal
shelved goal
+split ; exact stdout_initial_wf | repeat constructor ; simpl ; tauto
13 opendeferred goal
deferred goal
deferred goal
deferred goal
deferred goal
deferred goal
shelved goal
shelved goal
shelved goal
shelved goal
shelved goal
shelved goal
shelved goal
+discriminate
12 opendeferred goal
deferred goal
deferred goal
deferred goal
deferred goal
shelved goal
shelved goal
shelved goal
shelved goal
shelved goal
shelved goal
shelved goal
–reflexivity
11 opendeferred goal
deferred goal
deferred goal
deferred goal
shelved goal
shelved goal
shelved goal
shelved goal
shelved goal
shelved goal
shelved goal
–apply P.H.hi_reaches_call
7 opendeferred goal
deferred goal
deferred goal
shelved goal
shelved goal
shelved goal
lia
6 opendeferred goal
deferred goal
deferred goal
shelved goal
shelved goal
shelved goal
–exact completion_puts
2 opendeferred goal
deferred goal
–exact completion_shutdown
deferred goal
–repeat split ; reflexivity
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.