Fil-C on Nix

Filnix wiki

the formal campaign

rocq/theories/Linked.v

Retained void callbacks at the labelled program boundary. Entry is independently admitted AFTER the exit-registry pop; execution uses ordinary ExternalMachine steps. A stopped return snapshot precedes local teardown, so the shutdown endpoint reconstructs that memory. This slice does not intercept exit requests or claim native coverage.

From Stdlib Require Import String ZArith List Bool Lia
From Nanofil Require Import Term Syntax Values Memory Runtime Ops Semantics Machine Identity ExternalCalls Startup Stdio Shutdown ExitMemory Walk ExternalMachine
Import ListNotations
Open Scope Z_scope
Open Scope list_scope

A detached installed slot retains its callable address AND capability. Free/reserved slots cannot select callback code.

16Definition callback_targetslot : exit_slot : optionname × ptr ≔
match slot with
AtSlot_ symbol function | OnSlot_ symbol function _ | CxaSlot_ symbol function _ _
⇒
Somesymbol, function
_
⇒
None

Native argument classes, not re-evaluated IR operands. The dummy constants are immaterial to indirect_call_conv, which reads only these classes and the separately retained words.

26Definition callback_argsslot : exit_slot : listarg ≔
match slot with
OnSlot_ _ _ _
⇒
CxaSlot_ _ _ _ _
⇒
_
⇒
[ ]

The current signed status is passed as full canonical int bits, not the host's low-byte wait status. This pin calls cxa(arg,status).

35Definition callback_wordsslot : exit_slot status : Z : listword ≔
match slot with
OnSlot_ _ _ argument
⇒
WIntstatus mod 2 ^ 32; WPtrargument
CxaSlot_ _ _ argument _
⇒
WPtrargument; WIntstatus mod 2 ^ 32
_
⇒
[ ]

The exact selected defined code and generic calling convention. Module checking and semantic admission are not consequences of a retained Fn capability or of a successful call_frame. Only void, nonvariadic callbacks are covered by this first bridge.

46Definition callback_codege slot entry status fr : Prop ≔
exit_slot_pendingslot = entry ∧ checked_modulege_modulege ∧ ∃symbol function f converted, callback_targetslot = Somesymbol, function ∧ ptr_capfunction = Fnsymbol ∧ function_check_resge function = Someok ∧ find_fnge symbol = SomeDefinedf ∧ fn_retf = RVoid ∧ variadic_funcf = false ∧ indirect_call_convf CVoid callback_argsslot callback_wordsslot status = SomeConvertedconverted None ∧ call_framef converted = Somefr

Local teardown changes only region lifetimes, never bytes or aux, including a global slot retaining a pointer into the ended frame.

57Lemma callback_locals_contents
∀ locals m m′
invalidate_localslocals m = Somem′
m_bytesm′ = m_bytesm ∧ m_auxm′ = m_auxm
Explore proof 10 tactics

Initial goal

⊢
∀locals : listname × optionZ m m′ : mem, invalidate_localslocals m = Somem′ → m_bytesm′ = m_bytesm ∧ m_auxm′ = m_auxm

unfold invalidate_locals

⊢
∀ locals : listname × optionZ m m′ : mem  ,
fold_left
λ acc : optionmem l : name × optionZ  ⇒
let* m0 ≔ acc in
match sndl with
Somebase
⇒
let* reg ≔ object_regionbase m_regionsm0 in
match r_kindreg with
⇒
match r_lifereg with
⇒
let* rs ≔ replace_regionbase r_base ≔ base; r_end ≔ base; r_kind ≔ Stack; r_life ≔ Freed m_regionsm0 in
Somem_bytes ≔ m_bytesm0; m_regions ≔ rs; m_aux ≔ m_auxm0
⇒
None
_
⇒
None
None
⇒
Somem0
locals
Somem
=
Somem′
→
m_bytesm′ = m_bytesm ∧ m_auxm′ = m_auxm

intros locals

locals :
listname × optionZ
⊢
∀ m m′ : mem  ,
fold_left
λ acc : optionmem l : name × optionZ  ⇒
let* m0 ≔ acc in
match sndl with
Somebase
⇒
let* reg ≔ object_regionbase m_regionsm0 in
match r_kindreg with
⇒
match r_lifereg with
⇒
let* rs ≔ replace_regionbase r_base ≔ base; r_end ≔ base; r_kind ≔ Stack; r_life ≔ Freed m_regionsm0 in
Somem_bytes ≔ m_bytesm0; m_regions ≔ rs; m_aux ≔ m_auxm0
⇒
None
_
⇒
None
None
⇒
Somem0
locals
Somem
=
Somem′
→
m_bytesm′ = m_bytesm ∧ m_auxm′ = m_auxm

induction locals as | x slot locals IH ; simpl ; intros m m′ H

2 open

m, m′ :
H :
Somem = Somem′
⊢
m_bytesm′ = m_bytesm ∧ m_auxm′ = m_auxm
focused goal
x :
slot :
optionZ
locals :
listname × optionZ
IH :
∀ m m′ : mem  ,
fold_left
λ acc : optionmem l : name × optionZ  ⇒
let* m0 ≔ acc in
match sndl with
Somebase
⇒
let* reg ≔ object_regionbase m_regionsm0 in
match r_kindreg with
⇒
match r_lifereg with
⇒
let* rs ≔ replace_regionbase r_base ≔ base; r_end ≔ base; r_kind ≔ Stack; r_life ≔ Freed m_regionsm0 in
Somem_bytes ≔ m_bytesm0; m_regions ≔ rs; m_aux ≔ m_auxm0
⇒
None
_
⇒
None
None
⇒
Somem0
locals
Somem
=
Somem′
→
m_bytesm′ = m_bytesm ∧ m_auxm′ = m_auxm
m, m′ :
H :
fold_left
λ acc : optionmem l : name × optionZ  ⇒
let* m ≔ acc in
match sndl with
Somebase
⇒
let* reg ≔ object_regionbase m_regionsm in
match r_kindreg with
⇒
match r_lifereg with
⇒
let* rs ≔ replace_regionbase r_base ≔ base; r_end ≔ base; r_kind ≔ Stack; r_life ≔ Freed m_regionsm in
Somem_bytes ≔ m_bytesm; m_regions ≔ rs; m_aux ≔ m_auxm
⇒
None
_
⇒
None
None
⇒
Somem
locals
match slot with
Somebase
⇒
let* reg ≔ object_regionbase m_regionsm in
match r_kindreg with
⇒
match r_lifereg with
⇒
let* rs ≔ replace_regionbase r_base ≔ base; r_end ≔ base; r_kind ≔ Stack; r_life ≔ Freed m_regionsm in
Somem_bytes ≔ m_bytesm; m_regions ≔ rs; m_aux ≔ m_auxm
⇒
None
_
⇒
None
None
⇒
Somem
=
Somem′
⊢
m_bytesm′ = m_bytesm ∧ m_auxm′ = m_auxm

–injection H as ←

2 open

m :
⊢
m_bytesm = m_bytesm ∧ m_auxm = m_auxm
deferred goal
x :
slot :
optionZ
locals :
listname × optionZ
IH :
∀ m m′ : mem  ,
fold_left
λ acc : optionmem l : name × optionZ  ⇒
let* m0 ≔ acc in
match sndl with
Somebase
⇒
let* reg ≔ object_regionbase m_regionsm0 in
match r_kindreg with
⇒
match r_lifereg with
⇒
let* rs ≔ replace_regionbase r_base ≔ base; r_end ≔ base; r_kind ≔ Stack; r_life ≔ Freed m_regionsm0 in
Somem_bytes ≔ m_bytesm0; m_regions ≔ rs; m_aux ≔ m_auxm0
⇒
None
_
⇒
None
None
⇒
Somem0
locals
Somem
=
Somem′
→
m_bytesm′ = m_bytesm ∧ m_auxm′ = m_auxm
m, m′ :
H :
fold_left
λ acc : optionmem l : name × optionZ  ⇒
let* m ≔ acc in
match sndl with
Somebase
⇒
let* reg ≔ object_regionbase m_regionsm in
match r_kindreg with
⇒
match r_lifereg with
⇒
let* rs ≔ replace_regionbase r_base ≔ base; r_end ≔ base; r_kind ≔ Stack; r_life ≔ Freed m_regionsm in
Somem_bytes ≔ m_bytesm; m_regions ≔ rs; m_aux ≔ m_auxm
⇒
None
_
⇒
None
None
⇒
Somem
locals
match slot with
Somebase
⇒
let* reg ≔ object_regionbase m_regionsm in
match r_kindreg with
⇒
match r_lifereg with
⇒
let* rs ≔ replace_regionbase r_base ≔ base; r_end ≔ base; r_kind ≔ Stack; r_life ≔ Freed m_regionsm in
Somem_bytes ≔ m_bytesm; m_regions ≔ rs; m_aux ≔ m_auxm
⇒
None
_
⇒
None
None
⇒
Somem
=
Somem′
⊢
m_bytesm′ = m_bytesm ∧ m_auxm′ = m_auxm

auto

deferred goal
x :
slot :
optionZ
locals :
listname × optionZ
IH :
∀ m m′ : mem  ,
fold_left
λ acc : optionmem l : name × optionZ  ⇒
let* m0 ≔ acc in
match sndl with
Somebase
⇒
let* reg ≔ object_regionbase m_regionsm0 in
match r_kindreg with
⇒
match r_lifereg with
⇒
let* rs ≔ replace_regionbase r_base ≔ base; r_end ≔ base; r_kind ≔ Stack; r_life ≔ Freed m_regionsm0 in
Somem_bytes ≔ m_bytesm0; m_regions ≔ rs; m_aux ≔ m_auxm0
⇒
None
_
⇒
None
None
⇒
Somem0
locals
Somem
=
Somem′
→
m_bytesm′ = m_bytesm ∧ m_auxm′ = m_auxm
m, m′ :
H :
fold_left
λ acc : optionmem l : name × optionZ  ⇒
let* m ≔ acc in
match sndl with
Somebase
⇒
let* reg ≔ object_regionbase m_regionsm in
match r_kindreg with
⇒
match r_lifereg with
⇒
let* rs ≔ replace_regionbase r_base ≔ base; r_end ≔ base; r_kind ≔ Stack; r_life ≔ Freed m_regionsm in
Somem_bytes ≔ m_bytesm; m_regions ≔ rs; m_aux ≔ m_auxm
⇒
None
_
⇒
None
None
⇒
Somem
locals
match slot with
Somebase
⇒
let* reg ≔ object_regionbase m_regionsm in
match r_kindreg with
⇒
match r_lifereg with
⇒
let* rs ≔ replace_regionbase r_base ≔ base; r_end ≔ base; r_kind ≔ Stack; r_life ≔ Freed m_regionsm in
Somem_bytes ≔ m_bytesm; m_regions ≔ rs; m_aux ≔ m_auxm
⇒
None
_
⇒
None
None
⇒
Somem
=
Somem′
⊢
m_bytesm′ = m_bytesm ∧ m_auxm′ = m_auxm

–destruct slot as base | ; | exact IH_ _ H

x :
base :
Z
locals :
listname × optionZ
IH :
∀ m m′ : mem  ,
fold_left
λ acc : optionmem l : name × optionZ  ⇒
let* m0 ≔ acc in
match sndl with
Somebase
⇒
let* reg ≔ object_regionbase m_regionsm0 in
match r_kindreg with
⇒
match r_lifereg with
⇒
let* rs ≔ replace_regionbase r_base ≔ base; r_end ≔ base; r_kind ≔ Stack; r_life ≔ Freed m_regionsm0 in
Somem_bytes ≔ m_bytesm0; m_regions ≔ rs; m_aux ≔ m_auxm0
⇒
None
_
⇒
None
None
⇒
Somem0
locals
Somem
=
Somem′
→
m_bytesm′ = m_bytesm ∧ m_auxm′ = m_auxm
m, m′ :
H :
fold_left
λ acc : optionmem l : name × optionZ  ⇒
let* m ≔ acc in
match sndl with
Somebase
⇒
let* reg ≔ object_regionbase m_regionsm in
match r_kindreg with
⇒
match r_lifereg with
⇒
let* rs ≔ replace_regionbase r_base ≔ base; r_end ≔ base; r_kind ≔ Stack; r_life ≔ Freed m_regionsm in
Somem_bytes ≔ m_bytesm; m_regions ≔ rs; m_aux ≔ m_auxm
⇒
None
_
⇒
None
None
⇒
Somem
locals
let* reg ≔ object_regionbase m_regionsm in
match r_kindreg with
⇒
match r_lifereg with
⇒
let* rs ≔ replace_regionbase r_base ≔ base; r_end ≔ base; r_kind ≔ Stack; r_life ≔ Freed m_regionsm in
Somem_bytes ≔ m_bytesm; m_regions ≔ rs; m_aux ≔ m_auxm
⇒
None
_
⇒
None
=
Somem′
⊢
m_bytesm′ = m_bytesm ∧ m_auxm′ = m_auxm

destruct object_regionbase m_regionsm as reg | eqn: Er ; | rewrite fold_left_none in H ; discriminate H

x :
base :
Z
locals :
listname × optionZ
IH :
∀ m m′ : mem  ,
fold_left
λ acc : optionmem l : name × optionZ  ⇒
let* m0 ≔ acc in
match sndl with
Somebase
⇒
let* reg ≔ object_regionbase m_regionsm0 in
match r_kindreg with
⇒
match r_lifereg with
⇒
let* rs ≔ replace_regionbase r_base ≔ base; r_end ≔ base; r_kind ≔ Stack; r_life ≔ Freed m_regionsm0 in
Somem_bytes ≔ m_bytesm0; m_regions ≔ rs; m_aux ≔ m_auxm0
⇒
None
_
⇒
None
None
⇒
Somem0
locals
Somem
=
Somem′
→
m_bytesm′ = m_bytesm ∧ m_auxm′ = m_auxm
m, m′ :
reg :
Er :
object_regionbase m_regionsm = Somereg
H :
fold_left
λ acc : optionmem l : name × optionZ  ⇒
let* m ≔ acc in
match sndl with
Somebase
⇒
let* reg ≔ object_regionbase m_regionsm in
match r_kindreg with
⇒
match r_lifereg with
⇒
let* rs ≔ replace_regionbase r_base ≔ base; r_end ≔ base; r_kind ≔ Stack; r_life ≔ Freed m_regionsm in
Somem_bytes ≔ m_bytesm; m_regions ≔ rs; m_aux ≔ m_auxm
⇒
None
_
⇒
None
None
⇒
Somem
locals
match r_kindreg with
⇒
match r_lifereg with
⇒
let* rs ≔ replace_regionbase r_base ≔ base; r_end ≔ base; r_kind ≔ Stack; r_life ≔ Freed m_regionsm in
Somem_bytes ≔ m_bytesm; m_regions ≔ rs; m_aux ≔ m_auxm
⇒
None
_
⇒
None
=
Somem′
⊢
m_bytesm′ = m_bytesm ∧ m_auxm′ = m_auxm

destruct r_kindreg , r_lifereg ; simpl in H ; try rewrite fold_left_none in H ; discriminate H

x :
base :
Z
locals :
listname × optionZ
IH :
∀ m m′ : mem  ,
fold_left
λ acc : optionmem l : name × optionZ  ⇒
let* m0 ≔ acc in
match sndl with
Somebase
⇒
let* reg ≔ object_regionbase m_regionsm0 in
match r_kindreg with
⇒
match r_lifereg with
⇒
let* rs ≔ replace_regionbase r_base ≔ base; r_end ≔ base; r_kind ≔ Stack; r_life ≔ Freed m_regionsm0 in
Somem_bytes ≔ m_bytesm0; m_regions ≔ rs; m_aux ≔ m_auxm0
⇒
None
_
⇒
None
None
⇒
Somem0
locals
Somem
=
Somem′
→
m_bytesm′ = m_bytesm ∧ m_auxm′ = m_auxm
m, m′ :
reg :
Er :
object_regionbase m_regionsm = Somereg
H :
fold_left
λ acc : optionmem l : name × optionZ  ⇒
let* m ≔ acc in
match sndl with
Somebase
⇒
let* reg ≔ object_regionbase m_regionsm in
match r_kindreg with
⇒
match r_lifereg with
⇒
let* rs ≔ replace_regionbase r_base ≔ base; r_end ≔ base; r_kind ≔ Stack; r_life ≔ Freed m_regionsm in
Somem_bytes ≔ m_bytesm; m_regions ≔ rs; m_aux ≔ m_auxm
⇒
None
_
⇒
None
None
⇒
Somem
locals
let* rs ≔ replace_regionbase r_base ≔ base; r_end ≔ base; r_kind ≔ Stack; r_life ≔ Freed m_regionsm in
Somem_bytes ≔ m_bytesm; m_regions ≔ rs; m_aux ≔ m_auxm
=
Somem′
⊢
m_bytesm′ = m_bytesm ∧ m_auxm′ = m_auxm

destruct replace_regionbase _ m_regionsm as rs | eqn: Ers ; | rewrite fold_left_none in H ; discriminate H

x :
base :
Z
locals :
listname × optionZ
IH :
∀ m m′ : mem  ,
fold_left
λ acc : optionmem l : name × optionZ  ⇒
let* m0 ≔ acc in
match sndl with
Somebase
⇒
let* reg ≔ object_regionbase m_regionsm0 in
match r_kindreg with
⇒
match r_lifereg with
⇒
let* rs ≔ replace_regionbase r_base ≔ base; r_end ≔ base; r_kind ≔ Stack; r_life ≔ Freed m_regionsm0 in
Somem_bytes ≔ m_bytesm0; m_regions ≔ rs; m_aux ≔ m_auxm0
⇒
None
_
⇒
None
None
⇒
Somem0
locals
Somem
=
Somem′
→
m_bytesm′ = m_bytesm ∧ m_auxm′ = m_auxm
m, m′ :
reg :
Er :
object_regionbase m_regionsm = Somereg
rs :
listregion
Ers :
replace_regionbase r_base ≔ base; r_end ≔ base; r_kind ≔ Stack; r_life ≔ Freed m_regionsm = Somers
H :
fold_left
λ acc : optionmem l : name × optionZ  ⇒
let* m ≔ acc in
match sndl with
Somebase
⇒
let* reg ≔ object_regionbase m_regionsm in
match r_kindreg with
⇒
match r_lifereg with
⇒
let* rs ≔ replace_regionbase r_base ≔ base; r_end ≔ base; r_kind ≔ Stack; r_life ≔ Freed m_regionsm in
Somem_bytes ≔ m_bytesm; m_regions ≔ rs; m_aux ≔ m_auxm
⇒
None
_
⇒
None
None
⇒
Somem
locals
Somem_bytes ≔ m_bytesm; m_regions ≔ rs; m_aux ≔ m_auxm
=
Somem′
⊢
m_bytesm′ = m_bytesm ∧ m_auxm′ = m_auxm

exact IH_ _ H

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros locals
induction locals as | x slot locals IH ; simpl ; intros m m′ H
–injection H as ←
auto
–destruct slot as base | ; | exact IH_ _ H
destruct object_regionbase m_regionsm as reg | eqn: Er ; | rewrite fold_left_none in H ; discriminate H
destruct r_kindreg , r_lifereg ; simpl in H ; try rewrite fold_left_none in H ; discriminate H
destruct replace_regionbase _ m_regionsm as rs | eqn: Ers ; | rewrite fold_left_none in H ; discriminate H
exact IH_ _ H

This additive boundary changes neither machine nor runtime.

74Module Linked R : Runtime
75Module M ≔ ExternalMachine R
76Module RM ≔ M.P.I.RM
Import RM
79Section World
80Variable payload : Type

One authoritative shutdown inventory accompanies arbitrary libc state. Callback effects update this very world; return never restores a registration-time snapshot.

85Definition callback_world: Type ≔

Entry is checked at the current post-pop memory/runtime/world. The physical pop/mark and its effects remain ExitMemory's separate boundary; this relation does not claim them from a decoded slot alone. No run, successful callback or return is hidden inside admission.

91Definition callback_entryadmitted : registration → R.state → mem → callback_world → Prop ge slot entry s m w fuel c : Prop ≔
R.readys m ∧ shutdown_atsndw = InCallbackentry ∧ shutdown_uniquesndw ∧ Inregistration_tokenentry shutdown_consumedsndw ∧ −2 ^ 31 ≤ shutdown_statussndw < 2 ^ 31 ∧ admittedentry s m w ∧ ∃fr, callback_codege slot entry shutdown_statussndw fr ∧ c = mkConfigfr [ ] m fuel

Successful return reconstructs the memory that Semantics computed but did not retain in Done. It keeps the CURRENT libc payload, status, pending list, consumed history, output state, runtime and fuel. Other terminals, including an already completed ExternalExit, do not resume.

105Inductive callback_returnentry : registration : M.statecallback_world → mstate → callback_world → Prop ≔
∀ c s data status pending consumed q m_return
c_callersc = [ ]
shutdown_uniquemkShutdownInCallbackentry status pending consumed q
Inregistration_tokenentry consumed
callback_return_void
callback_returnentry M.StoppedCoreEndRetVoid c, s data, mkShutdownInCallbackentry status pending consumed q with_memc m_return, s data, mkShutdownHandlers status pending consumed q

The endpoint exposes the very same m_return needed by the handler's Iris return postcondition, not merely an existential outcome state.

119Theorem callback_return_endpoint
∀ entry st ms′ w′
callback_returnentry st ms′ w′
∃c s w m_return, st = M.StoppedCoreEndRetVoid c, s w ∧ c_callersc = [ ] ∧ invalidate_localsfr_localsc_framec c_memc = Somem_return ∧ ms′ = with_memc m_return, s ∧ fstw′ = fstw ∧ shutdown_stepsndw ReturnCallback sndw′
Explore proof 5 tactics

Initial goal

payload :
Type
⊢
∀entry : registration st : M.statecallback_world ms′ : mstate w′ : callback_world, callback_returnentry st ms′ w′ → ∃c : config s : R.state w : callback_world m_return : mem, st = M.StoppedCoreEndRetVoid c, s w ∧ c_callersc = [ ] ∧ invalidate_localsfr_localsc_framec c_memc = Somem_return ∧ ms′ = with_memc m_return, s ∧ fstw′ = fstw ∧ shutdown_stepsndw ReturnCallback sndw′

intros entry st ms′ w′ H

payload :
Type
st :
ms′ :
H :
callback_returnentry st ms′ w′
⊢
∃c : config s : R.state w : callback_world m_return : mem, st = M.StoppedCoreEndRetVoid c, s w ∧ c_callersc = [ ] ∧ invalidate_localsfr_localsc_framec c_memc = Somem_return ∧ ms′ = with_memc m_return, s ∧ fstw′ = fstw ∧ shutdown_stepsndw ReturnCallback sndw′

destruct H

payload :
Type
s :
R.state
data :
payload
status :
Z
pending :
consumed :
listnat
m_return :
H :
c_callersc = [ ]
H0 :
H1 :
Inregistration_tokenentry consumed
⊢
∃c0 : config s0 : R.state w : callback_world m_return0 : mem, M.StoppedCoreEndRetVoid c, s data, shutdown_at ≔ InCallbackentry; shutdown_status ≔ status; shutdown_pending ≔ pending; shutdown_consumed ≔ consumed; shutdown_stdout ≔ q = M.StoppedCoreEndRetVoid c0, s0 w ∧ c_callersc0 = [ ] ∧ invalidate_localsfr_localsc_framec0 c_memc0 = Somem_return0 ∧ with_memc m_return, s = with_memc0 m_return0, s0 ∧ fstdata, shutdown_at ≔ Handlers; shutdown_status ≔ status; shutdown_pending ≔ pending; shutdown_consumed ≔ consumed; shutdown_stdout ≔ q = fstw ∧ shutdown_stepsndw ReturnCallback snddata, shutdown_at ≔ Handlers; shutdown_status ≔ status; shutdown_pending ≔ pending; shutdown_consumed ≔ consumed; shutdown_stdout ≔ q

exists c, s, data, mkShutdownInCallbackentry status pending consumed q, m_return

payload :
Type
s :
R.state
data :
payload
status :
Z
pending :
consumed :
listnat
m_return :
H :
c_callersc = [ ]
H0 :
H1 :
Inregistration_tokenentry consumed
⊢
M.StoppedCoreEndRetVoid c, s data, shutdown_at ≔ InCallbackentry; shutdown_status ≔ status; shutdown_pending ≔ pending; shutdown_consumed ≔ consumed; shutdown_stdout ≔ q = M.StoppedCoreEndRetVoid c, s data, shutdown_at ≔ InCallbackentry; shutdown_status ≔ status; shutdown_pending ≔ pending; shutdown_consumed ≔ consumed; shutdown_stdout ≔ q ∧ c_callersc = [ ] ∧ invalidate_localsfr_localsc_framec c_memc = Somem_return ∧ with_memc m_return, s = with_memc m_return, s ∧ fstdata, shutdown_at ≔ Handlers; shutdown_status ≔ status; shutdown_pending ≔ pending; shutdown_consumed ≔ consumed; shutdown_stdout ≔ q = fstdata, shutdown_at ≔ InCallbackentry; shutdown_status ≔ status; shutdown_pending ≔ pending; shutdown_consumed ≔ consumed; shutdown_stdout ≔ q ∧ shutdown_stepsnddata, shutdown_at ≔ InCallbackentry; shutdown_status ≔ status; shutdown_pending ≔ pending; shutdown_consumed ≔ consumed; shutdown_stdout ≔ q ReturnCallback snddata, shutdown_at ≔ Handlers; shutdown_status ≔ status; shutdown_pending ≔ pending; shutdown_consumed ≔ consumed; shutdown_stdout ≔ q

repeat split ; auto

payload :
Type
s :
R.state
data :
payload
status :
Z
pending :
consumed :
listnat
m_return :
H :
c_callersc = [ ]
H0 :
H1 :
Inregistration_tokenentry consumed
⊢
shutdown_stepsnddata, shutdown_at ≔ InCallbackentry; shutdown_status ≔ status; shutdown_pending ≔ pending; shutdown_consumed ≔ consumed; shutdown_stdout ≔ q ReturnCallback snddata, shutdown_at ≔ Handlers; shutdown_status ≔ status; shutdown_pending ≔ pending; shutdown_consumed ≔ consumed; shutdown_stdout ≔ q

constructor

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros entry st ms′ w′ H
destruct H
exists c, s, data, mkShutdownInCallbackentry status pending consumed q, m_return
repeat split ; auto
constructor

Readiness and object persistence along ordinary labelled callback prefixes; this makes no return, termination or failure-freedom claim.

134Theorem callback_prefix_preserve
∀ registry : name → optioncontractcallback_world ge st trace st′
ge_freege = R.free
M.runregistry ge st trace st′
M.state_ready_ st
M.state_ready_ st′ ∧ persistsc_memfstM.machine_of_ st c_memfstM.machine_of_ st′
Explore proof 7 tactics

Initial goal

payload :
Type
⊢
∀registry : name → optioncontractcallback_world ge : genv st : M.statecallback_world trace : listevent st′ : M.statecallback_world, ge_freege = R.free → M.runregistry ge st trace st′ → M.state_readycallback_world st → M.state_readycallback_world st′ ∧ persistsc_memfstM.machine_ofcallback_world st c_memfstM.machine_ofcallback_world st′

intros registry ge st trace st′ Hfree H

payload :
Type
registry :
ge :
st :
trace :
listevent
st′ :
Hfree :
ge_freege = R.free
H :
M.runregistry ge st trace st′
⊢
M.state_readycallback_world st → M.state_readycallback_world st′ ∧ persistsc_memfstM.machine_ofcallback_world st c_memfstM.machine_ofcallback_world st′

induction H ; intros Hr

2 open

payload :
Type
registry :
ge :
Hfree :
ge_freege = R.free
st :
Hr :
M.state_readycallback_world st
⊢
M.state_readycallback_world st ∧ persistsc_memfstM.machine_ofcallback_world st c_memfstM.machine_ofcallback_world st
focused goal
payload :
Type
registry :
ge :
Hfree :
ge_freege = R.free
st :
trace :
listevent
mid :
tail :
listevent
last :
H :
M.stepregistry ge st trace mid
H0 :
M.runregistry ge mid tail last
IHrun :
M.state_readycallback_world mid → M.state_readycallback_world last ∧ persistsc_memfstM.machine_ofcallback_world mid c_memfstM.machine_ofcallback_world last
Hr :
M.state_readycallback_world st
⊢
M.state_readycallback_world last ∧ persistsc_memfstM.machine_ofcallback_world st c_memfstM.machine_ofcallback_world last

–split ; exact Hr | apply persists_refl

deferred goal
payload :
Type
registry :
ge :
Hfree :
ge_freege = R.free
st :
trace :
listevent
mid :
tail :
listevent
last :
H :
M.stepregistry ge st trace mid
H0 :
M.runregistry ge mid tail last
IHrun :
M.state_readycallback_world mid → M.state_readycallback_world last ∧ persistsc_memfstM.machine_ofcallback_world mid c_memfstM.machine_ofcallback_world last
Hr :
M.state_readycallback_world st
⊢
M.state_readycallback_world last ∧ persistsc_memfstM.machine_ofcallback_world st c_memfstM.machine_ofcallback_world last

–pose proof M.step_ready_ _ _ _ _ _ Hfree H Hr as Hr1

payload :
Type
registry :
ge :
Hfree :
ge_freege = R.free
st :
trace :
listevent
mid :
tail :
listevent
last :
H :
M.stepregistry ge st trace mid
H0 :
M.runregistry ge mid tail last
IHrun :
M.state_readycallback_world mid → M.state_readycallback_world last ∧ persistsc_memfstM.machine_ofcallback_world mid c_memfstM.machine_ofcallback_world last
Hr :
M.state_readycallback_world st
Hr1 :
M.state_readycallback_world mid
⊢
M.state_readycallback_world last ∧ persistsc_memfstM.machine_ofcallback_world st c_memfstM.machine_ofcallback_world last

destruct IHrunHr1 as Hr′ Hp

payload :
Type
registry :
ge :
Hfree :
ge_freege = R.free
st :
trace :
listevent
mid :
tail :
listevent
last :
H :
M.stepregistry ge st trace mid
H0 :
M.runregistry ge mid tail last
IHrun :
M.state_readycallback_world mid → M.state_readycallback_world last ∧ persistsc_memfstM.machine_ofcallback_world mid c_memfstM.machine_ofcallback_world last
Hr :
M.state_readycallback_world st
Hr1 :
M.state_readycallback_world mid
Hr′ :
M.state_readycallback_world last
Hp :
persistsc_memfstM.machine_ofcallback_world mid c_memfstM.machine_ofcallback_world last
⊢
M.state_readycallback_world last ∧ persistsc_memfstM.machine_ofcallback_world st c_memfstM.machine_ofcallback_world last

split ; exact Hr′ |

payload :
Type
registry :
ge :
Hfree :
ge_freege = R.free
st :
trace :
listevent
mid :
tail :
listevent
last :
H :
M.stepregistry ge st trace mid
H0 :
M.runregistry ge mid tail last
IHrun :
M.state_readycallback_world mid → M.state_readycallback_world last ∧ persistsc_memfstM.machine_ofcallback_world mid c_memfstM.machine_ofcallback_world last
Hr :
M.state_readycallback_world st
Hr1 :
M.state_readycallback_world mid
Hr′ :
M.state_readycallback_world last
Hp :
persistsc_memfstM.machine_ofcallback_world mid c_memfstM.machine_ofcallback_world last
⊢
persistsc_memfstM.machine_ofcallback_world st c_memfstM.machine_ofcallback_world last

eapply persists_trans ; eapply M.step_persists ; eauto | exact Hp

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros registry ge st trace st′ Hfree H
induction H ; intros Hr
–split ; exact Hr | apply persists_refl
–pose proof M.step_ready_ _ _ _ _ _ Hfree H Hr as Hr1
destruct IHrunHr1 as Hr′ Hp
split ; exact Hr′ |
eapply persists_trans ; eapply M.step_persists ; eauto | exact Hp

A return remains ready and retains every identity after invalidating locals; exact byte/aux preservation is stronger than mere keptness.

148Theorem callback_return_preserve
∀ entry st ms′ w′
callback_returnentry st ms′ w′
M.state_ready_ st
ready_statems′ ∧ persistsc_memfstM.machine_of_ st c_memfstms′ ∧ m_bytesc_memfstms′ = m_bytesc_memfstM.machine_of_ st ∧ m_auxc_memfstms′ = m_auxc_memfstM.machine_of_ st
Explore proof 10 tactics

Initial goal

payload :
Type
⊢
∀entry : registration st : M.statecallback_world ms′ : mstate w′ : callback_world, callback_returnentry st ms′ w′ → M.state_readycallback_world st → ready_statems′ ∧ persistsc_memfstM.machine_ofcallback_world st c_memfstms′ ∧ m_bytesc_memfstms′ = m_bytesc_memfstM.machine_ofcallback_world st ∧ m_auxc_memfstms′ = m_auxc_memfstM.machine_ofcallback_world st

intros entry st ms′ w′ H

payload :
Type
st :
ms′ :
H :
callback_returnentry st ms′ w′
⊢
M.state_readycallback_world st → ready_statems′ ∧ persistsc_memfstM.machine_ofcallback_world st c_memfstms′ ∧ m_bytesc_memfstms′ = m_bytesc_memfstM.machine_ofcallback_world st ∧ m_auxc_memfstms′ = m_auxc_memfstM.machine_ofcallback_world st

destruct H as c s data status pending consumed q m_return Hcallers Hunique Htoken Hlocals

payload :
Type
s :
R.state
data :
payload
status :
Z
pending :
consumed :
listnat
m_return :
Hcallers :
c_callersc = [ ]
Hunique :
Htoken :
Inregistration_tokenentry consumed
Hlocals :
⊢
M.state_readycallback_world M.StoppedCoreEndRetVoid c, s data, shutdown_at ≔ InCallbackentry; shutdown_status ≔ status; shutdown_pending ≔ pending; shutdown_consumed ≔ consumed; shutdown_stdout ≔ q → ready_statewith_memc m_return, s ∧ persistsc_memfstM.machine_ofcallback_world M.StoppedCoreEndRetVoid c, s data, shutdown_at ≔ InCallbackentry; shutdown_status ≔ status; shutdown_pending ≔ pending; shutdown_consumed ≔ consumed; shutdown_stdout ≔ q c_memfstwith_memc m_return, s ∧ m_bytesc_memfstwith_memc m_return, s = m_bytesc_memfstM.machine_ofcallback_world M.StoppedCoreEndRetVoid c, s data, shutdown_at ≔ InCallbackentry; shutdown_status ≔ status; shutdown_pending ≔ pending; shutdown_consumed ≔ consumed; shutdown_stdout ≔ q ∧ m_auxc_memfstwith_memc m_return, s = m_auxc_memfstM.machine_ofcallback_world M.StoppedCoreEndRetVoid c, s data, shutdown_at ≔ InCallbackentry; shutdown_status ≔ status; shutdown_pending ≔ pending; shutdown_consumed ≔ consumed; shutdown_stdout ≔ q

simpl

payload :
Type
s :
R.state
data :
payload
status :
Z
pending :
consumed :
listnat
m_return :
Hcallers :
c_callersc = [ ]
Hunique :
Htoken :
Inregistration_tokenentry consumed
Hlocals :
⊢
M.state_readycallback_world M.StoppedCoreEndRetVoid c, s data, shutdown_at ≔ InCallbackentry; shutdown_status ≔ status; shutdown_pending ≔ pending; shutdown_consumed ≔ consumed; shutdown_stdout ≔ q → ready_statewith_memc m_return, s ∧ persistsc_memc m_return ∧ m_bytesm_return = m_bytesc_memc ∧ m_auxm_return = m_auxc_memc

intros Hr

payload :
Type
s :
R.state
data :
payload
status :
Z
pending :
consumed :
listnat
m_return :
Hcallers :
c_callersc = [ ]
Hunique :
Htoken :
Inregistration_tokenentry consumed
Hlocals :
Hr :
M.state_readycallback_world M.StoppedCoreEndRetVoid c, s data, shutdown_at ≔ InCallbackentry; shutdown_status ≔ status; shutdown_pending ≔ pending; shutdown_consumed ≔ consumed; shutdown_stdout ≔ q
⊢
ready_statewith_memc m_return, s ∧ persistsc_memc m_return ∧ m_bytesm_return = m_bytesc_memc ∧ m_auxm_return = m_auxc_memc

pose proof invalidate_locals_kept_ _ _ Hlocals as Hkept

payload :
Type
s :
R.state
data :
payload
status :
Z
pending :
consumed :
listnat
m_return :
Hcallers :
c_callersc = [ ]
Hunique :
Htoken :
Inregistration_tokenentry consumed
Hlocals :
Hr :
M.state_readycallback_world M.StoppedCoreEndRetVoid c, s data, shutdown_at ≔ InCallbackentry; shutdown_status ≔ status; shutdown_pending ≔ pending; shutdown_consumed ≔ consumed; shutdown_stdout ≔ q
Hkept :
keptc_memc m_return
⊢
ready_statewith_memc m_return, s ∧ persistsc_memc m_return ∧ m_bytesm_return = m_bytesc_memc ∧ m_auxm_return = m_auxc_memc

split ; eapply R.ready_kept ; eauto |

payload :
Type
s :
R.state
data :
payload
status :
Z
pending :
consumed :
listnat
m_return :
Hcallers :
c_callersc = [ ]
Hunique :
Htoken :
Inregistration_tokenentry consumed
Hlocals :
Hr :
M.state_readycallback_world M.StoppedCoreEndRetVoid c, s data, shutdown_at ≔ InCallbackentry; shutdown_status ≔ status; shutdown_pending ≔ pending; shutdown_consumed ≔ consumed; shutdown_stdout ≔ q
Hkept :
keptc_memc m_return
⊢
persistsc_memc m_return ∧ m_bytesm_return = m_bytesc_memc ∧ m_auxm_return = m_auxc_memc

split

2 open

payload :
Type
s :
R.state
data :
payload
status :
Z
pending :
consumed :
listnat
m_return :
Hcallers :
c_callersc = [ ]
Hunique :
Htoken :
Inregistration_tokenentry consumed
Hlocals :
Hr :
M.state_readycallback_world M.StoppedCoreEndRetVoid c, s data, shutdown_at ≔ InCallbackentry; shutdown_status ≔ status; shutdown_pending ≔ pending; shutdown_consumed ≔ consumed; shutdown_stdout ≔ q
Hkept :
keptc_memc m_return
⊢
persistsc_memc m_return
focused goal
payload :
Type
s :
R.state
data :
payload
status :
Z
pending :
consumed :
listnat
m_return :
Hcallers :
c_callersc = [ ]
Hunique :
Htoken :
Inregistration_tokenentry consumed
Hlocals :
Hr :
M.state_readycallback_world M.StoppedCoreEndRetVoid c, s data, shutdown_at ≔ InCallbackentry; shutdown_status ≔ status; shutdown_pending ≔ pending; shutdown_consumed ≔ consumed; shutdown_stdout ≔ q
Hkept :
keptc_memc m_return
⊢
m_bytesm_return = m_bytesc_memc ∧ m_auxm_return = m_auxc_memc

–eapply kept_ids_persists ; exact Hkept |

2 open

payload :
Type
s :
R.state
data :
payload
status :
Z
pending :
consumed :
listnat
m_return :
Hcallers :
c_callersc = [ ]
Hunique :
Htoken :
Inregistration_tokenentry consumed
Hlocals :
Hr :
M.state_readycallback_world M.StoppedCoreEndRetVoid c, s data, shutdown_at ≔ InCallbackentry; shutdown_status ≔ status; shutdown_pending ≔ pending; shutdown_consumed ≔ consumed; shutdown_stdout ≔ q
Hkept :
keptc_memc m_return
⊢
idsc_memc m_return
deferred goal
payload :
Type
s :
R.state
data :
payload
status :
Z
pending :
consumed :
listnat
m_return :
Hcallers :
c_callersc = [ ]
Hunique :
Htoken :
Inregistration_tokenentry consumed
Hlocals :
Hr :
M.state_readycallback_world M.StoppedCoreEndRetVoid c, s data, shutdown_at ≔ InCallbackentry; shutdown_status ≔ status; shutdown_pending ≔ pending; shutdown_consumed ≔ consumed; shutdown_stdout ≔ q
Hkept :
keptc_memc m_return
⊢
m_bytesm_return = m_bytesc_memc ∧ m_auxm_return = m_auxc_memc

eapply invalidate_locals_ids ; eauto

deferred goal
payload :
Type
s :
R.state
data :
payload
status :
Z
pending :
consumed :
listnat
m_return :
Hcallers :
c_callersc = [ ]
Hunique :
Htoken :
Inregistration_tokenentry consumed
Hlocals :
Hr :
M.state_readycallback_world M.StoppedCoreEndRetVoid c, s data, shutdown_at ≔ InCallbackentry; shutdown_status ≔ status; shutdown_pending ≔ pending; shutdown_consumed ≔ consumed; shutdown_stdout ≔ q
Hkept :
keptc_memc m_return
⊢
m_bytesm_return = m_bytesc_memc ∧ m_auxm_return = m_auxc_memc

–eapply callback_locals_contents ; eauto

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros entry st ms′ w′ H
destruct H as c s data status pending consumed q m_return Hcallers Hunique Htoken Hlocals
simpl
intros Hr
pose proof invalidate_locals_kept_ _ _ Hlocals as Hkept
split ; eapply R.ready_kept ; eauto |
split
–eapply kept_ids_persists ; exact Hkept |
eapply invalidate_locals_ids ; eauto
–eapply callback_locals_contents ; eauto

Existing stopped outcomes cannot silently become returned callbacks.

164Theorem callback_return_only_void
∀ entry why ms w ms′ w′
callback_returnentry M.Stoppedwhy ms w ms′ w′
Explore proof 3 tactics

Initial goal

payload :
Type
⊢
∀entry : registration why : ending ms : M.P.I.RM.mstate w : callback_world ms′ : mstate w′ : callback_world, callback_returnentry M.Stoppedwhy ms w ms′ w′ → why = CoreEndRetVoid

intros

payload :
Type
why :
ms′ :
H :
callback_returnentry M.Stoppedwhy ms w ms′ w′
⊢

inversion H

payload :
Type
why :
ms′ :
H :
callback_returnentry M.Stoppedwhy ms w ms′ w′
s :
R.state
data :
payload
status :
Z
pending :
consumed :
listnat
m_return :
H3 :
c_callersc = [ ]
H4 :
H7 :
Inregistration_tokenentry consumed
H0 :
H1 :
c, s = ms
H2 :
data, shutdown_at ≔ InCallbackentry; shutdown_status ≔ status; shutdown_pending ≔ pending; shutdown_consumed ≔ consumed; shutdown_stdout ≔ q = w
H5 :
with_memc m_return, s = ms′
H6 :
data, shutdown_at ≔ Handlers; shutdown_status ≔ status; shutdown_pending ≔ pending; shutdown_consumed ≔ consumed; shutdown_stdout ≔ q = w′

reflexivity

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros
inversion H
reflexivity

A completed ordinary run followed by local teardown preserves readiness and every starting identity, with no reset of the runtime or fuel.

170Theorem callback_run_preserve
∀ registry ge start trace stopped entry ms′ w′
ge_freege = R.free
M.runregistry ge start trace stopped
callback_returnentry stopped ms′ w′
M.state_ready_ start
ready_statems′ ∧ persistsc_memfstM.machine_of_ start c_memfstms′
Explore proof 5 tactics

Initial goal

payload :
Type
⊢
∀registry : name → optioncontractcallback_world ge : genv start : M.statecallback_world trace : listevent stopped : M.statecallback_world entry : registration ms′ : mstate w′ : callback_world, ge_freege = R.free → M.runregistry ge start trace stopped → callback_returnentry stopped ms′ w′ → M.state_readycallback_world start → ready_statems′ ∧ persistsc_memfstM.machine_ofcallback_world start c_memfstms′

intros registry ge start trace stopped entry ms′ w′ Hfree Hrun Hreturn Hr

payload :
Type
registry :
ge :
start :
trace :
listevent
stopped :
ms′ :
Hfree :
ge_freege = R.free
Hrun :
M.runregistry ge start trace stopped
Hreturn :
callback_returnentry stopped ms′ w′
Hr :
M.state_readycallback_world start
⊢
ready_statems′ ∧ persistsc_memfstM.machine_ofcallback_world start c_memfstms′

destruct callback_prefix_preserve_ _ _ _ _ Hfree Hrun Hr as Hr1 Hp1

payload :
Type
registry :
ge :
start :
trace :
listevent
stopped :
ms′ :
Hfree :
ge_freege = R.free
Hrun :
M.runregistry ge start trace stopped
Hreturn :
callback_returnentry stopped ms′ w′
Hr :
M.state_readycallback_world start
Hr1 :
M.state_readycallback_world stopped
Hp1 :
persistsc_memfstM.machine_ofcallback_world start c_memfstM.machine_ofcallback_world stopped
⊢
ready_statems′ ∧ persistsc_memfstM.machine_ofcallback_world start c_memfstms′

destruct callback_return_preserve_ _ _ _ Hreturn Hr1 as Hr2 & Hp2 & _

payload :
Type
registry :
ge :
start :
trace :
listevent
stopped :
ms′ :
Hfree :
ge_freege = R.free
Hrun :
M.runregistry ge start trace stopped
Hreturn :
callback_returnentry stopped ms′ w′
Hr :
M.state_readycallback_world start
Hr1 :
M.state_readycallback_world stopped
Hp1 :
persistsc_memfstM.machine_ofcallback_world start c_memfstM.machine_ofcallback_world stopped
Hr2 :
Hp2 :
persistsc_memfstM.machine_ofcallback_world stopped c_memfstms′
⊢
ready_statems′ ∧ persistsc_memfstM.machine_ofcallback_world start c_memfstms′

split ; exact Hr2 |

payload :
Type
registry :
ge :
start :
trace :
listevent
stopped :
ms′ :
Hfree :
ge_freege = R.free
Hrun :
M.runregistry ge start trace stopped
Hreturn :
callback_returnentry stopped ms′ w′
Hr :
M.state_readycallback_world start
Hr1 :
M.state_readycallback_world stopped
Hp1 :
persistsc_memfstM.machine_ofcallback_world start c_memfstM.machine_ofcallback_world stopped
Hr2 :
Hp2 :
persistsc_memfstM.machine_ofcallback_world stopped c_memfstms′
⊢
persistsc_memfstM.machine_ofcallback_world start c_memfstms′

eapply persists_trans ; eauto

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros registry ge start trace stopped entry ms′ w′ Hfree Hrun Hreturn Hr
destruct callback_prefix_preserve_ _ _ _ _ Hfree Hrun Hr as Hr1 Hp1
destruct callback_return_preserve_ _ _ _ Hreturn Hr1 as Hr2 & Hp2 & _
split ; exact Hr2 |
eapply persists_trans ; eauto

Consumers accept an existing callback bridge and its exact machine inductives, rather than instantiate a generatively distinct machine.

186Module Type LinkedSig R : Runtime
Include Linked R

Independent execution controls, not native exit-registry memory.

191Module LinkedChecks
192Module L ≔ Linked InterpRuntime
193Module M ≔ L.M
194Module RM ≔ L.RM

Adversarial core code makes a local escape into a global, calls another ordinary function, then returns. It deliberately uses an A word as P: it is NOT claimed to pass checking or callback admission. Finalization must still invalidate its locals, not restore a live pre-return snapshot. Checked code selection is exercised separately.

201Definition escape_function: func ≔

A genuine nested call, with its own enter and return steps. Its harmless null-pointer flight makes the separate module checked-stage.

212Definition escape_helper: func ≔

The handwritten symbol map supplies callable addresses and a writable global cell. Checking code is separate from that memory image.

All three bindings are deliberately independent of the allocator.

221Definition escape_ge: genv ≔
mkGenvescape_module TAtom"escape", mkPtr1024 FnTAtom"escape"; TAtom"helper", mkPtr1040 FnTAtom"helper"; TAtom"sink", mkPtr2048 Obj2048 InterpRuntime.free

The writable global cell initially stores canonical null.

227Definition escape_memory: mem ≔
mkMemλ_ ⇒ 0 mkRegion2048 2056 GlobalData Live λ_ ⇒ CNone

Registration instances, not callback names, determine consumption.

231Definition escape_registration: registration ≔

The current world already contains a consumed active token and an older pending handler. Payload and signed status must survive return.

236Definition escape_world: L.callback_worldnat ≔

Entry retains the shared memory and an explicit finite fuel budget.

240Definition escape_start: config ≔
mkConfigmkFrameescape_function [ ] TAtom"local", None None EnterTAtom"entry" None [ ] escape_memory 23

The actual allocation and pointer-store endpoint, before return.

245Definition escape_written: mem ≔
store_bytesstore_auxallocatedescape_memory local_req8 4294967296 2048 Obj4294967296 2048 8 4294967296

Parent entry and helper entry each consumed one unit of fuel.

250Definition escape_terminal: config ≔
mkConfigmkFrameescape_function TAtom"dst", WPtrmkPtr2048 Obj2048; TAtom"p", WPtrmkPtr4294967296 Obj4294967296 TAtom"local", Some4294967296 None ExecTAtom"entry" [ ] JRetVoid [ ] escape_written 21

This independently named memory is NOT the stopped observation snapshot.

258Definition escape_returned: mem ≔

A separately checked handler makes address rejection nonvacuous.

263Definition void_ge: genv ≔

Cxa's unused extras go through generic conversion before call_frame in a separately checked module; they do not add parameters to the public void(void) handler. The adversarial escape code is excluded.

269Example callback_void_code_selected: ∀status, callback_codevoid_ge CxaSlot8 TAtom"helper" mkPtr1040 FnTAtom"helper" mkPtr0 CNone mkPtr0 CNone mkRegistration8 CxaExitTAtom"helper" WPtrmkPtr0 CNone status mkFrameescape_helper [ ] [ ] None EnterTAtom"entry" None
Explore proof 5 tactics

Initial goal

⊢
∀status : Z, callback_codevoid_ge CxaSlot8 TAtom"helper" ptr_addr ≔ 1040; ptr_cap ≔ FnTAtom"helper" ptr_addr ≔ 0; ptr_cap ≔ CNone ptr_addr ≔ 0; ptr_cap ≔ CNone registration_token ≔ 8; registration_callback ≔ CxaExitTAtom"helper" WPtrptr_addr ≔ 0; ptr_cap ≔ CNone status fr_fn ≔ escape_helper; fr_env ≔ [ ]; fr_locals ≔ [ ]; fr_doomed ≔ None; fr_at ≔ EnterTAtom"entry" None

intros status

status :
Z
⊢
callback_codevoid_ge CxaSlot8 TAtom"helper" ptr_addr ≔ 1040; ptr_cap ≔ FnTAtom"helper" ptr_addr ≔ 0; ptr_cap ≔ CNone ptr_addr ≔ 0; ptr_cap ≔ CNone registration_token ≔ 8; registration_callback ≔ CxaExitTAtom"helper" WPtrptr_addr ≔ 0; ptr_cap ≔ CNone status fr_fn ≔ escape_helper; fr_env ≔ [ ]; fr_locals ≔ [ ]; fr_doomed ≔ None; fr_at ≔ EnterTAtom"entry" None

split ; reflexivity |

status :
Z
⊢
checked_modulege_modulevoid_ge ∧ ∃symbol : name function : ptr f : func converted : listword, callback_targetCxaSlot8 TAtom"helper" ptr_addr ≔ 1040; ptr_cap ≔ FnTAtom"helper" ptr_addr ≔ 0; ptr_cap ≔ CNone ptr_addr ≔ 0; ptr_cap ≔ CNone = Somesymbol, function ∧ ptr_capfunction = Fnsymbol ∧ function_check_resvoid_ge function = Someok ∧ find_fnvoid_ge symbol = SomeDefinedf ∧ fn_retf = RVoid ∧ variadic_funcf = false ∧ indirect_call_convf CVoid callback_argsCxaSlot8 TAtom"helper" ptr_addr ≔ 1040; ptr_cap ≔ FnTAtom"helper" ptr_addr ≔ 0; ptr_cap ≔ CNone ptr_addr ≔ 0; ptr_cap ≔ CNone callback_wordsCxaSlot8 TAtom"helper" ptr_addr ≔ 1040; ptr_cap ≔ FnTAtom"helper" ptr_addr ≔ 0; ptr_cap ≔ CNone ptr_addr ≔ 0; ptr_cap ≔ CNone status = SomeConvertedconverted None ∧ call_framef converted = Somefr_fn ≔ escape_helper; fr_env ≔ [ ]; fr_locals ≔ [ ]; fr_doomed ≔ None; fr_at ≔ EnterTAtom"entry" None

split ; vm_compute ; auto |

status :
Z
⊢
∃symbol : name function : ptr f : func converted : listword, callback_targetCxaSlot8 TAtom"helper" ptr_addr ≔ 1040; ptr_cap ≔ FnTAtom"helper" ptr_addr ≔ 0; ptr_cap ≔ CNone ptr_addr ≔ 0; ptr_cap ≔ CNone = Somesymbol, function ∧ ptr_capfunction = Fnsymbol ∧ function_check_resvoid_ge function = Someok ∧ find_fnvoid_ge symbol = SomeDefinedf ∧ fn_retf = RVoid ∧ variadic_funcf = false ∧ indirect_call_convf CVoid callback_argsCxaSlot8 TAtom"helper" ptr_addr ≔ 1040; ptr_cap ≔ FnTAtom"helper" ptr_addr ≔ 0; ptr_cap ≔ CNone ptr_addr ≔ 0; ptr_cap ≔ CNone callback_wordsCxaSlot8 TAtom"helper" ptr_addr ≔ 1040; ptr_cap ≔ FnTAtom"helper" ptr_addr ≔ 0; ptr_cap ≔ CNone ptr_addr ≔ 0; ptr_cap ≔ CNone status = SomeConvertedconverted None ∧ call_framef converted = Somefr_fn ≔ escape_helper; fr_env ≔ [ ]; fr_locals ≔ [ ]; fr_doomed ≔ None; fr_at ≔ EnterTAtom"entry" None

exists TAtom"helper", mkPtr1040 FnTAtom"helper", escape_helper, [ ]

status :
Z
⊢
callback_targetCxaSlot8 TAtom"helper" ptr_addr ≔ 1040; ptr_cap ≔ FnTAtom"helper" ptr_addr ≔ 0; ptr_cap ≔ CNone ptr_addr ≔ 0; ptr_cap ≔ CNone = SomeTAtom"helper", ptr_addr ≔ 1040; ptr_cap ≔ FnTAtom"helper" ∧ ptr_capptr_addr ≔ 1040; ptr_cap ≔ FnTAtom"helper" = FnTAtom"helper" ∧ function_check_resvoid_ge ptr_addr ≔ 1040; ptr_cap ≔ FnTAtom"helper" = Someok ∧ find_fnvoid_ge TAtom"helper" = SomeDefinedescape_helper ∧ fn_retescape_helper = RVoid ∧ variadic_funcescape_helper = false ∧ indirect_call_convescape_helper CVoid callback_argsCxaSlot8 TAtom"helper" ptr_addr ≔ 1040; ptr_cap ≔ FnTAtom"helper" ptr_addr ≔ 0; ptr_cap ≔ CNone ptr_addr ≔ 0; ptr_cap ≔ CNone callback_wordsCxaSlot8 TAtom"helper" ptr_addr ≔ 1040; ptr_cap ≔ FnTAtom"helper" ptr_addr ≔ 0; ptr_cap ≔ CNone ptr_addr ≔ 0; ptr_cap ≔ CNone status = SomeConverted[ ] None ∧ call_frameescape_helper [ ] = Somefr_fn ≔ escape_helper; fr_env ≔ [ ]; fr_locals ≔ [ ]; fr_doomed ≔ None; fr_at ≔ EnterTAtom"entry" None

repeat split ; reflexivity

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros status
split ; reflexivity |
split ; vm_compute ; auto |
exists TAtom"helper", mkPtr1040 FnTAtom"helper", escape_helper, [ ]
repeat split ; reflexivity

The adversarial entry-to-return core run really allocates the local and stores its pointer. No opaque callback-success action is used; no validation or native reachability is claimed for this control.

Proof 9 steps Qed
eapply M.run_cons with trace := [ ] tail := [ ] ; apply M.step_core ; eapply RM.mstep_next ; reflexivity |
eapply M.run_cons with trace := [ ] tail := [ ] ; apply M.step_core ; eapply RM.mstep_alloc with base := 4294967296 q := local_req8 ; reflexivity | simpl ; lia | reflexivity |

Normalize each endpoint, but keep symbolic byte/aux functions folded.

do 7 cbv - [ store_bytes store_aux ] ; eapply M.run_cons with trace := [ ] tail := [ ] ; apply M.step_core ; eapply RM.mstep_next ; cbv - [ store_bytes store_aux ] ; reflexivity |
eapply M.run_cons with trace := [ ] tail := [ ]
+intros site _ & Hpoint & _
discriminate Hpoint
+reflexivity
–constructor

The escaped identity is live in the stopped snapshot, freed at the reconstructed endpoint, and still present in the global's aux slot.

307Example escape_lifetime_boundary: object_region4294967296 m_regionsc_memescape_terminal = SomemkRegion4294967296 4294967304 Stack Live ∧ invalidate_localsfr_localsc_frameescape_terminal c_memescape_terminal = Someescape_returned ∧ pointer_slotescape_returned 2048 mkPtr4294967296 Obj4294967296 ∧ object_region4294967296 m_regionsescape_returned = SomemkRegion4294967296 4294967296 Stack Freed ∧ access_resescape_returned 4294967296 Obj4294967296 1 Read 1 = SomeRTrapOutOfBounds
Explore proof 1 tactics

Initial goal

⊢
object_region4294967296 m_regionsc_memescape_terminal = Somer_base ≔ 4294967296; r_end ≔ 4294967304; r_kind ≔ Stack; r_life ≔ Live ∧ invalidate_localsfr_localsc_frameescape_terminal c_memescape_terminal = Someescape_returned ∧ pointer_slotescape_returned 2048 ptr_addr ≔ 4294967296; ptr_cap ≔ Obj4294967296 ∧ object_region4294967296 m_regionsescape_returned = Somer_base ≔ 4294967296; r_end ≔ 4294967296; r_kind ≔ Stack; r_life ≔ Freed ∧ access_resescape_returned 4294967296 Obj4294967296 1 Read 1 = SomeRTrapOutOfBounds

repeat split ; try reflexivity ; simpl ; lia

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
repeat split ; try reflexivity ; simpl ; lia

Normal finalization resumes Handlers with the current pending list, status, payload, consumed token and remaining fuel, not the entry frame.

Explore proof 4 tactics

Initial goal

constructor ; reflexivity | | left ; reflexivity | reflexivity

unfold shutdown_unique

simpl

⊢
NoDup7%nat; 1%nat

repeat constructor ; simpl ; intuition discriminate

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
constructor ; reflexivity | | left ; reflexivity | reflexivity
simpl
repeat constructor ; simpl ; intuition discriminate

Correct Fn authority with a wrong callable address cannot be admitted.

330Example callback_wrong_address: function_check_resvoid_ge mkPtr1041 FnTAtom"helper" = SomeRTrapNotAFunction ∧ ∀fr, ¬callback_codevoid_ge CxaSlot8 TAtom"helper" mkPtr1041 FnTAtom"helper" mkPtr0 CNone mkPtr0 CNone mkRegistration8 CxaExitTAtom"helper" WPtrmkPtr0 CNone −257 fr
Explore proof 4 tactics

Initial goal

⊢
function_check_resvoid_ge ptr_addr ≔ 1041; ptr_cap ≔ FnTAtom"helper" = SomeRTrapNotAFunction ∧ ∀fr : frame, ¬callback_codevoid_ge CxaSlot8 TAtom"helper" ptr_addr ≔ 1041; ptr_cap ≔ FnTAtom"helper" ptr_addr ≔ 0; ptr_cap ≔ CNone ptr_addr ≔ 0; ptr_cap ≔ CNone registration_token ≔ 8; registration_callback ≔ CxaExitTAtom"helper" WPtrptr_addr ≔ 0; ptr_cap ≔ CNone −257 fr

split ; reflexivity |

⊢
∀fr : frame, ¬callback_codevoid_ge CxaSlot8 TAtom"helper" ptr_addr ≔ 1041; ptr_cap ≔ FnTAtom"helper" ptr_addr ≔ 0; ptr_cap ≔ CNone ptr_addr ≔ 0; ptr_cap ≔ CNone registration_token ≔ 8; registration_callback ≔ CxaExitTAtom"helper" WPtrptr_addr ≔ 0; ptr_cap ≔ CNone −257 fr

intros fr _ & _ & symbol & function & f & converted & Htarget & _ & Hcheck & _

fr :
symbol :
function :
f :
converted :
listword
Htarget :
callback_targetCxaSlot8 TAtom"helper" ptr_addr ≔ 1041; ptr_cap ≔ FnTAtom"helper" ptr_addr ≔ 0; ptr_cap ≔ CNone ptr_addr ≔ 0; ptr_cap ≔ CNone = Somesymbol, function
Hcheck :
⊢
False

injection Htarget as ← ←

fr :
f :
converted :
listword
Hcheck :
function_check_resvoid_ge ptr_addr ≔ 1041; ptr_cap ≔ FnTAtom"helper" = Someok
⊢
False

discriminate Hcheck

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
split ; reflexivity |
intros fr _ & _ & symbol & function & f & converted & Htarget & _ & Hcheck & _
injection Htarget as ← ←
discriminate Hcheck

Native flavor order and signed status differ from the host wait byte.

341Example callback_native_words: callback_wordsAtSlot8 TAtom"helper" mkPtr1040 FnTAtom"helper" −257 = [ ] ∧ callback_wordsOnSlot8 TAtom"helper" mkPtr1040 FnTAtom"helper" mkPtr2049 Ro2048 −257 = WInt4294967039; WPtrmkPtr2049 Ro2048 ∧ callback_wordsCxaSlot8 TAtom"helper" mkPtr1040 FnTAtom"helper" mkPtr2049 Ro2048 mkPtr4096 Obj4096 −257 = WPtrmkPtr2049 Ro2048; WInt4294967039
Explore proof 1 tactics

Initial goal

⊢
callback_wordsAtSlot8 TAtom"helper" ptr_addr ≔ 1040; ptr_cap ≔ FnTAtom"helper" −257 = [ ] ∧ callback_wordsOnSlot8 TAtom"helper" ptr_addr ≔ 1040; ptr_cap ≔ FnTAtom"helper" ptr_addr ≔ 2049; ptr_cap ≔ Ro2048 −257 = WInt4294967039; WPtrptr_addr ≔ 2049; ptr_cap ≔ Ro2048 ∧ callback_wordsCxaSlot8 TAtom"helper" ptr_addr ≔ 1040; ptr_cap ≔ FnTAtom"helper" ptr_addr ≔ 2049; ptr_cap ≔ Ro2048 ptr_addr ≔ 4096; ptr_cap ≔ Obj4096 −257 = WPtrptr_addr ≔ 2049; ptr_cap ≔ Ro2048; WInt4294967039

repeat split ; reflexivity

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
repeat split ; reflexivity

Already completed external exits and fuel/resource endings do not acquire a normal callback return edge.

352Example callback_terminal_controls: ∀ms′ w′, ¬L.callback_returnnat escape_registration M.StoppedExternalExit9 escape_terminal, 4294967328 escape_world ms′ w′ ∧ ¬L.callback_returnnat escape_registration M.StoppedCoreEndOutOfFuel escape_terminal, 4294967328 escape_world ms′ w′
Explore proof 2 tactics

Initial goal

intros

split ; intro H ; inversion H

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros
split ; intro H ; inversion H