Fil-C on Nix

Filnix wiki

the formal campaign

rocq/theories/Soundness.v

Campaign 3's theorem, valid_no_unchecked: if the validator accepts a module, no run of it that starts ready ever steps to unchecked (formal.md, Campaign 3; rocq.md, No run is unchecked).

The interpreter's unchecked(Reason) is the outcome a validated module must never reach: it marks a raw access or a reuse form the validator accepted but whose justification was false at run time. So the theorem says the validator's checks are sound: every access it lets go unchecked is in fact in bounds, or traps as a checked access would. It rests on the runtime axioms of Runtime.v and on the run starting ready; the runtime's safepoints spare the pass's facts for every runtime (Invariant.v's spares_any), and the interpreter's instance is interp_valid_no_unchecked. The validator here is Validate.v's transcription, which the gates compare with ir:valid_module/1; external calls other than free are stuck in the model, so the theorem says nothing about a run past one. The proof is assembled from the run theorems, one per place an unchecked can come from:

SourceRun theorem
a raw load, store or callChain.v's run_access_checked
a renew, a renew over a hull, a half checkRenew.v's run_reuse_checked
a renew_if, a check_limitGuard.v's run_guard_checked
a frame a check_ahead doomedDoomed.v's run_doomed_checked
the runtime's freeRuntime.v's axiom free_checked

Decisions

DecisionWhy
free never answering unchecked is the module type's axiom free_checkedmbrock's decision, with the native test axiom-free.c
the theorem takes no hypothesis about safepointsevery runtime spares the pass's facts (Invariant.v's spares_any); spares was a hypothesis until 2026-11-09, while a handler's free at a pointer store's aux exit counted as the runtime's (The runtime's safepoints)
a run is stated over Guard.v's machine instancethe doomed frame's run is carried over to Doomed.v's (mreachable_doom)
From Stdlib Require Import String ZArith List Bool Lia Relations
From Nanofil Require Import Term Maps Syntax Cfg Values Memory Runtime Ops Semantics Machine Validate Dominance Walk Steps Invariant Persistence Identity Single Chain Renew Guard Doomed
Import ListNotations
Open Scope Z_scope

Where unchecked comes from

The ops o whose result may be unchecked: a raw load, whose access the check before it covers (raw_res/2), or a reuse form (renew, renew over a hull, half check, renew_if, check_limit), whose source or limit may not be the one the pass took.

52Definition unchecked_opo : op : bool ≔
match o with
RawLoad_ _ | RawLoadPointer_ _ | Renew_ _ _ _ | RenewHull_ _ _ _ | HalfCheck_ _ _ _ _ | RenewIf_ _ _ _ | CheckLimit_ _ _ _
⇒
true
_
⇒
false

No op but an unchecked_op answers unchecked (kind_res/8): a check answers its access check, which traps or passes.

61Lemma op_unchecked_source
∀ o k xs m r m′
op_reso k xs m = SomeOpResRUncheckedr m′
unchecked_opo = true
Explore proof 8 tactics

Initial goal

⊢
∀o : op k : class xs : listword m : Memory.mem r : reason m′ : Memory.mem, op_reso k xs m = SomeOpResRUncheckedr m′ → unchecked_opo = true

intros o k xs m r m′ H

o :
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
op_reso k xs m = SomeOpResRUncheckedr m′
⊢
unchecked_opo = true

destruct o ; try reflexivity ; exfalso

34 open

xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
op_resAdd k xs m = SomeOpResRUncheckedr m′
⊢
False
focused goal
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
op_resSub k xs m = SomeOpResRUncheckedr m′
⊢
False
focused goal
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
op_resMul k xs m = SomeOpResRUncheckedr m′
⊢
False
focused goal
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
op_resDiv k xs m = SomeOpResRUncheckedr m′
⊢
False
focused goal
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
op_resUdiv k xs m = SomeOpResRUncheckedr m′
⊢
False
focused goal
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
op_resRem k xs m = SomeOpResRUncheckedr m′
⊢
False
focused goal
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
op_resUrem k xs m = SomeOpResRUncheckedr m′
⊢
False
focused goal
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
op_resAnd k xs m = SomeOpResRUncheckedr m′
⊢
False
focused goal
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
op_resOr k xs m = SomeOpResRUncheckedr m′
⊢
False
focused goal
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
op_resXor k xs m = SomeOpResRUncheckedr m′
⊢
False
focused goal
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
op_resSar k xs m = SomeOpResRUncheckedr m′
⊢
False
focused goal
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
op_resShr k xs m = SomeOpResRUncheckedr m′
⊢
False
focused goal
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
op_resShl k xs m = SomeOpResRUncheckedr m′
⊢
False
focused goal
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
op_resNeg k xs m = SomeOpResRUncheckedr m′
⊢
False
focused goal
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
op_resCopy k xs m = SomeOpResRUncheckedr m′
⊢
False
focused goal
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
op_resPtoi k xs m = SomeOpResRUncheckedr m′
⊢
False
focused goal
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
op_resItop k xs m = SomeOpResRUncheckedr m′
⊢
False
focused goal
c :
k0, k :
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
op_resCmpc k0 k xs m = SomeOpResRUncheckedr m′
⊢
False
focused goal
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
op_resExtt k xs m = SomeOpResRUncheckedr m′
⊢
False
focused goal
k0, k :
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
op_resExtFk0 k xs m = SomeOpResRUncheckedr m′
⊢
False
focused goal
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
op_resTruncd k xs m = SomeOpResRUncheckedr m′
⊢
False
focused goal
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
op_resTruncx k xs m = SomeOpResRUncheckedr m′
⊢
False
focused goal
k0 :
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
op_resFloatToIntk0 sg k xs m = SomeOpResRUncheckedr m′
⊢
False
focused goal
k0 :
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
op_resIntToFloatk0 sg k xs m = SomeOpResRUncheckedr m′
⊢
False
focused goal
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
op_resCast k xs m = SomeOpResRUncheckedr m′
⊢
False
focused goal
align :
Z
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
op_resAllocalign k xs m = SomeOpResRUncheckedr m′
⊢
False
focused goal
lo, hi :
Z
r0 :
align :
Z
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
op_resChecklo hi r0 align k xs m = SomeOpResRUncheckedr m′
⊢
False
focused goal
lo, hi :
Z
r0 :
align, ahi :
Z
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
op_resCheckAheadlo hi r0 align ahi k xs m = SomeOpResRUncheckedr m′
⊢
False
focused goal
lo, hi :
Z
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
op_resSpanTestlo hi k xs m = SomeOpResRUncheckedr m′
⊢
False
focused goal
size :
Z
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
op_resLimitsize k xs m = SomeOpResRUncheckedr m′
⊢
False
focused goal
x :
off, bytes :
Z
r0 :
align :
Z
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
op_resCheckLocalx off bytes r0 align k xs m = SomeOpResRUncheckedr m′
⊢
False
focused goal
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
⊢
False
focused goal
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
op_resVaArgs k xs m = SomeOpResRUncheckedr m′
⊢
False
focused goal
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
op_resVaArg k xs m = SomeOpResRUncheckedr m′
⊢
False

all: unfold op_res , op_res_int in H ; cases H

6 open

k0 :
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
w :
l :
listword
n :
Z
Heqw0 :
w = WIntn
Heql0 :
l = [ ]
Heql :
xs = WIntn
f :
Ieee.fmt
Heqo :
fmt_ofk0 = Somef
H :
float_integerf sg k n m = SomeOpResRUncheckedr m′
⊢
False
focused goal
lo, hi :
Z
r0 :
align :
Z
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
Heqc :
k = A
w :
l :
listword
p :
Heqw0 :
w = WPtrp
Heql0 :
l = [ ]
Heql :
xs = WPtrp
r1 :
resunit
Heqo :
access_resm raw_addressptr_addrp lo ptr_capp hi − lo r0 align = Somer1
H :
SomeOpReschecked_resr1 WPtrp m = SomeOpResRUncheckedr m′
⊢
False
focused goal
x :
off, bytes :
Z
r0 :
align :
Z
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
None = SomeOpResRUncheckedr m′
⊢
False
focused goal
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
None = SomeOpResRUncheckedr m′
⊢
False
focused goal
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
H :
None = SomeOpResRUncheckedr m′
⊢
False
focused goal
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
w :
l :
listword
p :
Heqw0 :
w = WPtrp
Heql0 :
l = [ ]
Heql :
xs = WPtrp
p0 :
resword × Memory.mem
Heqo :
va_arg_resk p m = Somep0
H :
SomeOpResfstp0 sndp0 = SomeOpResRUncheckedr m′
⊢
False

all: try discriminate H

3 open

k0 :
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
w :
l :
listword
n :
Z
Heqw0 :
w = WIntn
Heql0 :
l = [ ]
Heql :
xs = WIntn
f :
Ieee.fmt
Heqo :
fmt_ofk0 = Somef
H :
float_integerf sg k n m = SomeOpResRUncheckedr m′
⊢
False
focused goal
lo, hi :
Z
r0 :
align :
Z
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
Heqc :
k = A
w :
l :
listword
p :
Heqw0 :
w = WPtrp
Heql0 :
l = [ ]
Heql :
xs = WPtrp
r1 :
resunit
Heqo :
access_resm raw_addressptr_addrp lo ptr_capp hi − lo r0 align = Somer1
H :
SomeOpReschecked_resr1 WPtrp m = SomeOpResRUncheckedr m′
⊢
False
focused goal
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
w :
l :
listword
p :
Heqw0 :
w = WPtrp
Heql0 :
l = [ ]
Heql :
xs = WPtrp
p0 :
resword × Memory.mem
Heqo :
va_arg_resk p m = Somep0
H :
SomeOpResfstp0 sndp0 = SomeOpResRUncheckedr m′
⊢
False

all: try (match goal withE : access_res_ _ _ _ _ _ = SomeRUnchecked_ |- _⇒exact access_res_checked_ _ _ _ _ _ _ E _ eq_reflend)

3 open

k0 :
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
w :
l :
listword
n :
Z
Heqw0 :
w = WIntn
Heql0 :
l = [ ]
Heql :
xs = WIntn
f :
Ieee.fmt
Heqo :
fmt_ofk0 = Somef
H :
float_integerf sg k n m = SomeOpResRUncheckedr m′
⊢
False
focused goal
lo, hi :
Z
r0 :
align :
Z
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
Heqc :
k = A
w :
l :
listword
p :
Heqw0 :
w = WPtrp
Heql0 :
l = [ ]
Heql :
xs = WPtrp
r1 :
resunit
Heqo :
access_resm raw_addressptr_addrp lo ptr_capp hi − lo r0 align = Somer1
H :
SomeOpReschecked_resr1 WPtrp m = SomeOpResRUncheckedr m′
⊢
False
focused goal
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
w :
l :
listword
p :
Heqw0 :
w = WPtrp
Heql0 :
l = [ ]
Heql :
xs = WPtrp
p0 :
resword × Memory.mem
Heqo :
va_arg_resk p m = Somep0
H :
SomeOpResfstp0 sndp0 = SomeOpResRUncheckedr m′
⊢
False

all: try (match goal withE : access_res_ _ _ _ _ _ = Some?x |- _⇒destruct x ; cbn [ checked_res ] in H ; try discriminate H ; exact access_res_checked_ _ _ _ _ _ _ E _ eq_reflend)

2 open

k0 :
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
w :
l :
listword
n :
Z
Heqw0 :
w = WIntn
Heql0 :
l = [ ]
Heql :
xs = WIntn
f :
Ieee.fmt
Heqo :
fmt_ofk0 = Somef
H :
float_integerf sg k n m = SomeOpResRUncheckedr m′
⊢
False
focused goal
xs :
listword
m :
Memory.mem
m′ :
Memory.mem
w :
l :
listword
p :
Heqw0 :
w = WPtrp
Heql0 :
l = [ ]
Heql :
xs = WPtrp
p0 :
resword × Memory.mem
Heqo :
va_arg_resk p m = Somep0
H :
SomeOpResfstp0 sndp0 = SomeOpResRUncheckedr m′
⊢
False

all: try unfold float_integer in H ; cases H ; fail

xs :
listword
m :
Memory.mem
m′ :
Memory.mem
w :
l :
listword
p :
Heqw0 :
w = WPtrp
Heql0 :
l = [ ]
Heql :
xs = WPtrp
p0 :
resword × Memory.mem
Heqo :
va_arg_resk p m = Somep0
H :
SomeOpResfstp0 sndp0 = SomeOpResRUncheckedr m′
⊢
False

all: match goal withE : va_arg_res_ _ _ = Some?p0 |- _⇒injection H as H3 _ ; exact va_arg_reason_ _ _ _ _ E H3end

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros o k xs m r m′ H
destruct o ; try reflexivity ; exfalso
all: unfold op_res , op_res_int in H ; cases H
all: try discriminate H
all: try (match goal withE : access_res_ _ _ _ _ _ = SomeRUnchecked_ |- _⇒exact access_res_checked_ _ _ _ _ _ _ E _ eq_reflend)
all: try (match goal withE : access_res_ _ _ _ _ _ = Some?x |- _⇒destruct x ; cbn [ checked_res ] in H ; try discriminate H ; exact access_res_checked_ _ _ _ _ _ _ E _ eq_reflend)
all: try unfold float_integer in H ; cases H ; fail
all: match goal withE : va_arg_res_ _ _ = Some?p0 |- _⇒injection H as H3 _ ; exact va_arg_reason_ _ _ _ _ E H3end

An instruction i's result is unchecked only as a let of an unchecked_op, a raw store, a raw call, or a call of free that the runtime's free (ge_free) answered so (inst_result/5).

80Lemma inst_unchecked_source
∀ ge fr m i w
inst_stepge fr m i = SomeIStopUncheckedw
∃q k o args, i = Letq k o args ∧ unchecked_opo = true ∨ ∃wd off v a, i = RawStorewd off v a ∨ ∃off v a es, i = RawStorePointeroff v a es ∨ ∃r cl args, i = RawCallr cl args ∨ ∃r args x m′, i = Callr Globalfree_name args ∧ ge_freege x m = SomeRUncheckedw, m′
Proof 65 steps Qed
intros ge fr m i w H
destruct i as q k o args | d o args lw | wd off v a | off v a es | r cl args | r cl args | x size | file line
–left
exists q, k, o, args
split ; reflexivity |
destruct special_leto eqn: Es
+exfalso
destruct o ; try discriminate Es ; cbn - [ access_res function_check_res ] in H
∗destruct k ; try discriminate H ; destruct args ; try discriminate H ; cases H ; unfold bind_res , checked_res in H ; cases H
match goal withE : access_res_ _ _ _ _ _ = Some?x |- _⇒destruct x ; try discriminate ; exact access_res_checked_ _ _ _ _ _ _ E _ eq_reflend
∗destruct k ; try discriminate H ; destruct args as | v | ; try discriminate H ; cases H ; unfold bind_res , checked_res in H ; cases H
match goal withE : function_check_res_ _ = Some?x |- _⇒destruct x ; try discriminate ; unfold function_check_res in E ; cases Eend
∗destruct k ; try discriminate H ; destruct args as | v | ; try discriminate H ; destruct v ; cases H
all: discriminate H
+rewrite inst_step_let in H by exact Es
cbv zeta in H
destruct op_arg_classeso k as cls | ; | discriminate H
simpl in H
destruct map2_option_ cls args as xs | ; | discriminate H
simpl in H
destruct op_reso k xs m as rr m′ | why | q0 kont | eqn: Eo ; try discriminate H
unfold bind_res in H
destruct rr ; try discriminate H
injection H as ←
exact op_unchecked_source_ _ _ _ _ _ Eo
–exfalso
simpl in H
–right
left
do 4 eexists
reflexivity
–right
right
left
do 4 eexists
reflexivity
–do 4 right
simpl in H
destruct cl as n | n | g ; try discriminate H
destruct map_option_ args as xs | ; | discriminate H
simpl in H
destruct find_fnge g as gf | g′ | ; try discriminate H
unfold external_call in H
destruct lookupg ge_globalsge ; discriminate H |
destruct negbname_eqbg free_name eqn: En ; discriminate H |
apply negb_false_iff , name_eqb_true in En
subst g
injection H as ←
subst
do 4 eexists
split ; reflexivity | eassumption
–right
right
right
left
do 3 eexists
reflexivity
–exfalso
simpl in H
–exfalso
simpl in H
discriminate H

Raw accesses go through a temporary

A raw load or store i of a function of a checked_module md reads its address from a temporary, so the validator saw it as a raw access (raw_access is not None, raw_access/5): valid_use/3 reads no global at the proof class a and no constant at a proof class.

131Lemma raw_tmp
∀ md f b i
InIFuncf md
Ini b_instsb
∃q k t off args, i = Letq k RawLoadt off args ∨ ∃q k off es args, i = Letq k RawLoadPointeroff es args ∨ ∃wd off v a, i = RawStorewd off v a ∨ ∃off v a es, i = RawStorePointeroff v a es
raw_accessi ≠ None
Explore proof 16 tactics

Initial goal

⊢
∀md : module f : func b : block i : inst, checked_modulemd → InIFuncf md → Inb fn_blocksf → Ini b_instsb → ∃q : name k : class t : load_type off : Z args : listvalue, i = Letq k RawLoadt off args ∨ ∃q : name k : class off : Z es : listeffect args : listvalue, i = Letq k RawLoadPointeroff es args ∨ ∃wd : width off : Z v a : value, i = RawStorewd off v a ∨ ∃off : Z v a : value es : listeffect, i = RawStorePointeroff v a es → raw_accessi ≠ None

intros md f b i Hmd Hin Hb Hi Hr

md :
f :
i :
Hin :
InIFuncf md
Hb :
Hi :
Ini b_instsb
Hr :
∃q : name k : class t : load_type off : Z args : listvalue, i = Letq k RawLoadt off args ∨ ∃q : name k : class off : Z es : listeffect args : listvalue, i = Letq k RawLoadPointeroff es args ∨ ∃wd : width off : Z v a : value, i = RawStorewd off v a ∨ ∃off : Z v a : value es : listeffect, i = RawStorePointeroff v a es
⊢
raw_accessi ≠ None

destruct inst_valid_ _ _ _ Hmd Hin Hb Hi as cls Hvi

md :
f :
i :
Hin :
InIFuncf md
Hb :
Hi :
Ini b_instsb
Hr :
∃q : name k : class t : load_type off : Z args : listvalue, i = Letq k RawLoadt off args ∨ ∃q : name k : class off : Z es : listeffect args : listvalue, i = Letq k RawLoadPointeroff es args ∨ ∃wd : width off : Z v a : value, i = RawStorewd off v a ∨ ∃off : Z v a : value es : listeffect, i = RawStorePointeroff v a es
cls :
listname × class
Hvi :
valid_instmd cls i = true
⊢
raw_accessi ≠ None

destruct Hr as q & k & t & off & args & → | q & k & off & es & args & → | wd & off & v & a & → | off & v & a & es & →

4 open

md :
f :
Hin :
InIFuncf md
Hb :
q :
off :
Z
args :
listvalue
Hi :
InLetq k RawLoadt off args b_instsb
cls :
listname × class
Hvi :
valid_instmd cls Letq k RawLoadt off args = true
⊢
raw_accessLetq k RawLoadt off args ≠ None
focused goal
md :
f :
Hin :
InIFuncf md
Hb :
q :
off :
Z
es :
listeffect
args :
listvalue
Hi :
InLetq k RawLoadPointeroff es args b_instsb
cls :
listname × class
Hvi :
valid_instmd cls Letq k RawLoadPointeroff es args = true
⊢
raw_accessLetq k RawLoadPointeroff es args ≠ None
focused goal
md :
f :
Hin :
InIFuncf md
Hb :
wd :
off :
Z
v, a :
Hi :
InRawStorewd off v a b_instsb
cls :
listname × class
Hvi :
valid_instmd cls RawStorewd off v a = true
⊢
raw_accessRawStorewd off v a ≠ None
focused goal
md :
f :
Hin :
InIFuncf md
Hb :
off :
Z
v, a :
es :
listeffect
Hi :
cls :
listname × class
Hvi :
valid_instmd cls RawStorePointeroff v a es = true
⊢
raw_accessRawStorePointeroff v a es ≠ None

–destruct k ; destruct args as | n | n | g | v2 args ; simpl in Hvi;repeat match goal withH : _ && _ = true |- _⇒apply andb_true_iff in H as ? ?end;try discriminate;simpl;discriminate

3 open

deferred goal
md :
f :
Hin :
InIFuncf md
Hb :
q :
off :
Z
es :
listeffect
args :
listvalue
Hi :
InLetq k RawLoadPointeroff es args b_instsb
cls :
listname × class
Hvi :
valid_instmd cls Letq k RawLoadPointeroff es args = true
⊢
raw_accessLetq k RawLoadPointeroff es args ≠ None
deferred goal
md :
f :
Hin :
InIFuncf md
Hb :
wd :
off :
Z
v, a :
Hi :
InRawStorewd off v a b_instsb
cls :
listname × class
Hvi :
valid_instmd cls RawStorewd off v a = true
⊢
raw_accessRawStorewd off v a ≠ None
deferred goal
md :
f :
Hin :
InIFuncf md
Hb :
off :
Z
v, a :
es :
listeffect
Hi :
cls :
listname × class
Hvi :
valid_instmd cls RawStorePointeroff v a es = true
⊢
raw_accessRawStorePointeroff v a es ≠ None

–destruct k ; destruct args as | n | n | g | v2 args ; simpl in Hvi;repeat match goal withH : _ && _ = true |- _⇒apply andb_true_iff in H as ? ?end;try discriminate;simpl;discriminate

2 open

deferred goal
md :
f :
Hin :
InIFuncf md
Hb :
wd :
off :
Z
v, a :
Hi :
InRawStorewd off v a b_instsb
cls :
listname × class
Hvi :
valid_instmd cls RawStorewd off v a = true
⊢
raw_accessRawStorewd off v a ≠ None
deferred goal
md :
f :
Hin :
InIFuncf md
Hb :
off :
Z
v, a :
es :
listeffect
Hi :
cls :
listname × class
Hvi :
valid_instmd cls RawStorePointeroff v a es = true
⊢
raw_accessRawStorePointeroff v a es ≠ None

–simpl in Hvi

2 open

md :
f :
Hin :
InIFuncf md
Hb :
wd :
off :
Z
v, a :
Hi :
InRawStorewd off v a b_instsb
cls :
listname × class
Hvi :
match width_value_okwd with
Somek
⇒
valid_usecls k v && valid_usecls A a
None
⇒
false
=
true
⊢
raw_accessRawStorewd off v a ≠ None
deferred goal
md :
f :
Hin :
InIFuncf md
Hb :
off :
Z
v, a :
es :
listeffect
Hi :
cls :
listname × class
Hvi :
valid_instmd cls RawStorePointeroff v a es = true
⊢
raw_accessRawStorePointeroff v a es ≠ None

destruct width_value_okwd ; | discriminate Hvi

2 open

md :
f :
Hin :
InIFuncf md
Hb :
wd :
off :
Z
v, a :
Hi :
InRawStorewd off v a b_instsb
cls :
listname × class
Hvi :
valid_usecls c v && valid_usecls A a = true
⊢
raw_accessRawStorewd off v a ≠ None
deferred goal
md :
f :
Hin :
InIFuncf md
Hb :
off :
Z
v, a :
es :
listeffect
Hi :
cls :
listname × class
Hvi :
valid_instmd cls RawStorePointeroff v a es = true
⊢
raw_accessRawStorePointeroff v a es ≠ None

apply andb_true_iff in Hvi as _ Hvi

2 open

md :
f :
Hin :
InIFuncf md
Hb :
wd :
off :
Z
v, a :
Hi :
InRawStorewd off v a b_instsb
cls :
listname × class
Hvi :
valid_usecls A a = true
⊢
raw_accessRawStorewd off v a ≠ None
deferred goal
md :
f :
Hin :
InIFuncf md
Hb :
off :
Z
v, a :
es :
listeffect
Hi :
cls :
listname × class
Hvi :
valid_instmd cls RawStorePointeroff v a es = true
⊢
raw_accessRawStorePointeroff v a es ≠ None

destruct a as n | n | g ; simpl in Hvi ; try discriminate Hvi

2 open

md :
f :
Hin :
InIFuncf md
Hb :
wd :
off :
Z
n :
Hi :
InRawStorewd off v Tmpn b_instsb
cls :
listname × class
Hvi :
match lookupn cls with
SomeA
⇒
true
_
⇒
false
=
true
⊢
raw_accessRawStorewd off v Tmpn ≠ None
deferred goal
md :
f :
Hin :
InIFuncf md
Hb :
off :
Z
v, a :
es :
listeffect
Hi :
cls :
listname × class
Hvi :
valid_instmd cls RawStorePointeroff v a es = true
⊢
raw_accessRawStorePointeroff v a es ≠ None

simpl

2 open

md :
f :
Hin :
InIFuncf md
Hb :
wd :
off :
Z
n :
Hi :
InRawStorewd off v Tmpn b_instsb
cls :
listname × class
Hvi :
match lookupn cls with
SomeA
⇒
true
_
⇒
false
=
true
⊢
Somen, XWidthwd, off, Write ≠ None
deferred goal
md :
f :
Hin :
InIFuncf md
Hb :
off :
Z
v, a :
es :
listeffect
Hi :
cls :
listname × class
Hvi :
valid_instmd cls RawStorePointeroff v a es = true
⊢
raw_accessRawStorePointeroff v a es ≠ None

discriminate

deferred goal
md :
f :
Hin :
InIFuncf md
Hb :
off :
Z
v, a :
es :
listeffect
Hi :
cls :
listname × class
Hvi :
valid_instmd cls RawStorePointeroff v a es = true
⊢
raw_accessRawStorePointeroff v a es ≠ None

–simpl in Hvi

md :
f :
Hin :
InIFuncf md
Hb :
off :
Z
v, a :
es :
listeffect
Hi :
cls :
listname × class
⊢
raw_accessRawStorePointeroff v a es ≠ None

apply andb_true_iff in Hvi as _ Hvi

md :
f :
Hin :
InIFuncf md
Hb :
off :
Z
v, a :
es :
listeffect
Hi :
cls :
listname × class
Hvi :
valid_usecls A a = true
⊢
raw_accessRawStorePointeroff v a es ≠ None

destruct a as n | n | g ; simpl in Hvi ; try discriminate Hvi

md :
f :
Hin :
InIFuncf md
Hb :
off :
Z
n :
es :
listeffect
Hi :
cls :
listname × class
Hvi :
match lookupn cls with
SomeA
⇒
true
_
⇒
false
=
true
⊢
raw_accessRawStorePointeroff v Tmpn es ≠ None

simpl

md :
f :
Hin :
InIFuncf md
Hb :
off :
Z
n :
es :
listeffect
Hi :
cls :
listname × class
Hvi :
match lookupn cls with
SomeA
⇒
true
_
⇒
false
=
true
⊢
Somen, XPtr, off, Write ≠ None

discriminate

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros md f b i Hmd Hin Hb Hi Hr
destruct inst_valid_ _ _ _ Hmd Hin Hb Hi as cls Hvi
destruct Hr as q & k & t & off & args & → | q & k & off & es & args & → | wd & off & v & a & → | off & v & a & es & →
–destruct k ; destruct args as | n | n | g | v2 args ; simpl in Hvi;repeat match goal withH : _ && _ = true |- _⇒apply andb_true_iff in H as ? ?end;try discriminate;simpl;discriminate
–destruct k ; destruct args as | n | n | g | v2 args ; simpl in Hvi;repeat match goal withH : _ && _ = true |- _⇒apply andb_true_iff in H as ? ?end;try discriminate;simpl;discriminate
–simpl in Hvi
destruct width_value_okwd ; | discriminate Hvi
apply andb_true_iff in Hvi as _ Hvi
destruct a as n | n | g ; simpl in Hvi ; try discriminate Hvi
simpl
discriminate
–simpl in Hvi
apply andb_true_iff in Hvi as _ Hvi
destruct a as n | n | g ; simpl in Hvi ; try discriminate Hvi
simpl
discriminate

A step that is not doomed

In a frame fr that is not doomed, doomed_result/5 keeps an instruction's result out as it is, or goes on.

159Lemma undoomed_result
∀ ge fr m i out od
fr_doomedfr = None
doomed_resultge fr m i out = Someod
fstod = out ∨ ∃e locals m′, fstod = IContinuee locals m′
Explore proof 4 tactics

Initial goal

⊢
∀ge : genv fr : frame m : Memory.mem i : inst out : inst_out od : inst_out × optionreason, fr_doomedfr = None → doomed_resultge fr m i out = Someod → fstod = out ∨ ∃e : env locals : listname × optionZ m′ : Memory.mem, fstod = IContinuee locals m′

intros ge fr m i out od Hd H

ge :
fr :
m :
Memory.mem
i :
od :
inst_out × optionreason
Hd :
fr_doomedfr = None
H :
doomed_resultge fr m i out = Someod
⊢
fstod = out ∨ ∃e : env locals : listname × optionZ m′ : Memory.mem, fstod = IContinuee locals m′

unfold doomed_result in H

ge :
fr :
m :
Memory.mem
i :
od :
inst_out × optionreason
Hd :
fr_doomedfr = None
H :
match i with
Letd A CheckAhead_ _ _ _ _ v
⇒
match out with
⇒
let* p ≔ value_xge fr_envfr P v in
Some
match fr_doomedfr with
Somew
⇒
Somew
None
⇒
Somewhy
⇒
match fr_doomedfr with
Somewhy
⇒
match w with
⇒
Someout, fr_doomedfr
None
⇒
Someout, None
_
⇒
Someout, fr_doomedfr
Letd A CheckAhead_ _ _ _ _ v :: _ :: _
⇒
match out with
⇒
match fr_doomedfr with
Somewhy
⇒
match w with
⇒
Someout, fr_doomedfr
None
⇒
Someout, None
_
⇒
Someout, fr_doomedfr
Letd W _ _ | Letd L _ _ | Letd P _ _ | Letd A Add _ | Letd A Sub _ | Letd A Mul _ | Letd A Div _ | Letd A Udiv _ | Letd A Rem _ | Letd A Urem _ | Letd A And _ | Letd A Or _ | Letd A Xor _ | Letd A Sar _ | Letd A Shr _ | Letd A Shl _ | Letd A Neg _ | Letd A Copy _ | Letd A Ptoi _ | Letd A Itop _ | Letd A Cmp_ _ _ | Letd A Ext_ _ | Letd A ExtF_ _ | Letd A Truncd _ | Letd A Truncx _ | Letd A FloatToInt_ _ _ | Letd A IntToFloat_ _ _ | Letd A Cast _ | Letd A Alloc_ _ | Letd A Check_ _ _ _ _ | Letd A CheckAhead_ _ _ _ _ [ ] | Letd A Renew_ _ _ _ _ | Letd A RenewHull_ _ _ _ _ | Letd A HalfCheck_ _ _ _ _ _ | Letd A SpanTest_ _ _ | Letd A RenewIf_ _ _ _ _ | Letd A Limit_ _ | Letd A CheckLimit_ _ _ _ _ | Letd A CheckLocal_ _ _ _ _ _ | Letd A CheckFunction _ | Letd A RawLoad_ _ _ | Letd A RawLoadPointer_ _ _ | Letd A VaArgs _ | Letd A VaArg _ | Letd F _ _ | Letd Single _ _ | Letd Double _ _ | Letd Extended _ _
⇒
match out with
⇒
match fr_doomedfr with
Somewhy
⇒
match w with
⇒
Someout, fr_doomedfr
None
⇒
Someout, None
_
⇒
Someout, fr_doomedfr
_
⇒
match out with
⇒
match fr_doomedfr with
Somewhy
⇒
match w with
⇒
Someout, fr_doomedfr
None
⇒
Someout, None
_
⇒
Someout, fr_doomedfr
=
Someod
⊢
fstod = out ∨ ∃e : env locals : listname × optionZ m′ : Memory.mem, fstod = IContinuee locals m′

rewrite Hd in H

ge :
fr :
m :
Memory.mem
i :
od :
inst_out × optionreason
Hd :
fr_doomedfr = None
H :
match i with
Letd A CheckAhead_ _ _ _ _ v
⇒
match out with
⇒
let* p ≔ value_xge fr_envfr P v in
SomeIContinueputd p fr_envfr fr_localsfr m, Somewhy
_
⇒
Someout, None
Letd A CheckAhead_ _ _ _ _ v :: _ :: _
⇒
match out with
IContinue_ _ _ | _
⇒
Someout, None
Letd W _ _ | Letd L _ _ | Letd P _ _ | Letd A Add _ | Letd A Sub _ | Letd A Mul _ | Letd A Div _ | Letd A Udiv _ | Letd A Rem _ | Letd A Urem _ | Letd A And _ | Letd A Or _ | Letd A Xor _ | Letd A Sar _ | Letd A Shr _ | Letd A Shl _ | Letd A Neg _ | Letd A Copy _ | Letd A Ptoi _ | Letd A Itop _ | Letd A Cmp_ _ _ | Letd A Ext_ _ | Letd A ExtF_ _ | Letd A Truncd _ | Letd A Truncx _ | Letd A FloatToInt_ _ _ | Letd A IntToFloat_ _ _ | Letd A Cast _ | Letd A Alloc_ _ | Letd A Check_ _ _ _ _ | Letd A CheckAhead_ _ _ _ _ [ ] | Letd A Renew_ _ _ _ _ | Letd A RenewHull_ _ _ _ _ | Letd A HalfCheck_ _ _ _ _ _ | Letd A SpanTest_ _ _ | Letd A RenewIf_ _ _ _ _ | Letd A Limit_ _ | Letd A CheckLimit_ _ _ _ _ | Letd A CheckLocal_ _ _ _ _ _ | Letd A CheckFunction _ | Letd A RawLoad_ _ _ | Letd A RawLoadPointer_ _ _ | Letd A VaArgs _ | Letd A VaArg _ | Letd F _ _ | Letd Single _ _ | Letd Double _ _ | Letd Extended _ _
⇒
match out with
IContinue_ _ _ | _
⇒
Someout, None
_
⇒
match out with
IContinue_ _ _ | _
⇒
Someout, None
=
Someod
⊢
fstod = out ∨ ∃e : env locals : listname × optionZ m′ : Memory.mem, fstod = IContinuee locals m′

cases H ; injection H as ← ; simpl ; first left ; reflexivity | right ; do 3 eexists ; reflexivity

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros ge fr m i out od Hd H
unfold doomed_result in H
rewrite Hd in H
cases H ; injection H as ← ; simpl ; first left ; reflexivity | right ; do 3 eexists ; reflexivity

A return that ends the run ends it with the outcome o it returns, not another (call_outcome_result/5).

169Lemma return_step_done
∀ c o o′
return_stepc o = Doneo′
o′ = o
Explore proof 5 tactics

Initial goal

⊢
∀c : config o o′ : outcome, return_stepc o = Doneo′ → o′ = o

unfold return_step , or_stuck

⊢
∀ c : config o o′ : outcome  ,
match let* m ≔ invalidate_localsfr_localsc_framec c_memc in match c_callersc with [ ] ⇒ SomeDoneo | caller, pd :: callers ⇒ let* o'0 ≔ match pd_convpd with Somecw, kw ⇒ converted_outcomecw kw o | None ⇒ Someo end in let* e ≔ returned_envpd_respd o'0 fr_envcaller in SomeNextc_frame ≔ fr_fn ≔ fr_fncaller; fr_env ≔ e; fr_locals ≔ fr_localscaller; fr_doomed ≔ fr_doomedcaller; fr_at ≔ fr_atcaller; c_callers ≔ callers; c_mem ≔ m; c_fuel ≔ c_fuelc end with
Somes
⇒
s
None
⇒
Stuck"return"
=
Doneo′
→
o′ = o

intros c o o′ H

o, o′ :
H :
match let* m ≔ invalidate_localsfr_localsc_framec c_memc in match c_callersc with [ ] ⇒ SomeDoneo | caller, pd :: callers ⇒ let* o′ ≔ match pd_convpd with Somecw, kw ⇒ converted_outcomecw kw o | None ⇒ Someo end in let* e ≔ returned_envpd_respd o′ fr_envcaller in SomeNextc_frame ≔ fr_fn ≔ fr_fncaller; fr_env ≔ e; fr_locals ≔ fr_localscaller; fr_doomed ≔ fr_doomedcaller; fr_at ≔ fr_atcaller; c_callers ≔ callers; c_mem ≔ m; c_fuel ≔ c_fuelc end with
Somes
⇒
s
None
⇒
Stuck"return"
=
Doneo′
⊢
o′ = o

cases H

o, o′ :
Heqo0 :
match c_callersc with
[ ]
⇒
SomeDoneo
caller, pd :: callers
⇒
let* o′ ≔
match pd_convpd with
Somecw, kw
⇒
None
⇒
Someo
in
let* e ≔ returned_envpd_respd o′ fr_envcaller in
SomeNextc_frame ≔ fr_fn ≔ fr_fncaller; fr_env ≔ e; fr_locals ≔ fr_localscaller; fr_doomed ≔ fr_doomedcaller; fr_at ≔ fr_atcaller; c_callers ≔ callers; c_mem ≔ m; c_fuel ≔ c_fuelc
=
Somes
H :
s = Doneo′
⊢
o′ = o

all: repeat match goal withE : Some_ = Some_ |- _⇒injection E as EE : ?x = Done_ |- _⇒is_var x ; subst xE : context [match _ with _ ⇒ _ end] |- _⇒progress cases Eend

o, o′ :
m :
Memory.mem
Heql :
c_callersc = [ ]
Heqo0 :
o = o′
⊢
o′ = o

all: congruence

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros c o o′ H
all: repeat match goal withE : Some_ = Some_ |- _⇒injection E as EE : ?x = Done_ |- _⇒is_var x ; subst xE : context [match _ with _ ⇒ _ end] |- _⇒progress cases Eend
all: congruence

A frame that is not doomed steps to unchecked only where its next instruction i's result is: a block's entry, a jump and a return give no such outcome (block_outcome/7, jump_outcome/7).

183Lemma step_unchecked_inst
∀ ge c w
∃l i rest j, fr_atc_framec = Execl i :: rest j ∧ inst_stepge c_framec c_memc i = SomeIStopUncheckedw
Explore proof 27 tactics

Initial goal

⊢
∀ge : genv c : config w : reason, fr_doomedc_framec = None → stepge c = DoneUncheckedw → ∃l : name i : inst rest : listinst j : jump, fr_atc_framec = Execl i :: rest j ∧ inst_stepge c_framec c_memc i = SomeIStopUncheckedw

intros ge c w Hd H

ge :
Hd :
H :
⊢
∃l : name i : inst rest : listinst j : jump, fr_atc_framec = Execl i :: rest j ∧ inst_stepge c_framec c_memc i = SomeIStopUncheckedw

unfold step in H

ge :
Hd :
H :
match fr_atc_framec with
Snapshot_ :: _ as xs l
⇒
negbforallbsnapshot_word xs
→
Stuck"snapshot"
else
Freshheap_req16 8 × Z.of_natDatatypes.lengthxs λbase : Z ⇒ c_frame ≔ fr_fn ≔ fr_fnc_framec; fr_env ≔ putva_snapshot WPtrptr_addr ≔ base; ptr_cap ≔ Robase fr_envc_framec; fr_locals ≔ fr_localsc_framec; fr_doomed ≔ fr_doomedc_framec; fr_at ≔ Enterl None; c_callers ≔ c_callersc; c_mem ≔ snapshot_valuesxs base allocatedc_memc heap_req16 8 × Z.of_natDatatypes.lengthxs base; c_fuel ≔ c_fuelc
Enterl from
⇒
else
or_stuck"block"
Execl [ ] j
⇒
jump_stepge c l j
Execl i :: rest j
⇒
match let* why ≔ fr_doomedc_framec in if ahead_transparenti then None else Somewhy with
Somewhy
⇒
None
⇒
or_stuck"instruction"
let* out0 ≔ inst_stepge c_framec c_memc i in
let* od ≔ doomed_resultge c_framec c_memc i out0 in
Someinst_nextc l rest j fstod sndod
=
⊢
∃l : name i : inst rest : listinst j : jump, fr_atc_framec = Execl i :: rest j ∧ inst_stepge c_framec c_memc i = SomeIStopUncheckedw

destruct fr_atc_framec as xs l | l from | l | i rest j eqn: Ha

4 open

ge :
Hd :
xs :
listword
l :
H :
match xs with
_ :: _
⇒
negbforallbsnapshot_word xs
→
Stuck"snapshot"
else
Freshheap_req16 8 × Z.of_natDatatypes.lengthxs λbase : Z ⇒ c_frame ≔ fr_fn ≔ fr_fnc_framec; fr_env ≔ putva_snapshot WPtrptr_addr ≔ base; ptr_cap ≔ Robase fr_envc_framec; fr_locals ≔ fr_localsc_framec; fr_doomed ≔ fr_doomedc_framec; fr_at ≔ Enterl None; c_callers ≔ c_callersc; c_mem ≔ snapshot_valuesxs base allocatedc_memc heap_req16 8 × Z.of_natDatatypes.lengthxs base; c_fuel ≔ c_fuelc
=
⊢
∃l0 : name i : inst rest : listinst j : jump, Snapshotxs l = Execl0 i :: rest j ∧ inst_stepge c_framec c_memc i = SomeIStopUncheckedw
focused goal
ge :
Hd :
l :
from :
optionname
Ha :
⊢
∃l0 : name i : inst rest : listinst j : jump, Enterl from = Execl0 i :: rest j ∧ inst_stepge c_framec c_memc i = SomeIStopUncheckedw
focused goal
ge :
Hd :
l :
j :
Ha :
fr_atc_framec = Execl [ ] j
H :
⊢
∃l0 : name i : inst rest : listinst j0 : jump, Execl [ ] j = Execl0 i :: rest j0 ∧ inst_stepge c_framec c_memc i = SomeIStopUncheckedw
focused goal
ge :
Hd :
l :
i :
rest :
listinst
j :
Ha :
fr_atc_framec = Execl i :: rest j
H :
match let* why ≔ fr_doomedc_framec in if ahead_transparenti then None else Somewhy with
Somewhy
⇒
None
⇒
or_stuck"instruction"
let* out0 ≔ inst_stepge c_framec c_memc i in
let* od ≔ doomed_resultge c_framec c_memc i out0 in
Someinst_nextc l rest j fstod sndod
=
⊢
∃l0 : name i0 : inst rest0 : listinst j0 : jump, Execl i :: rest j = Execl0 i0 :: rest0 j0 ∧ inst_stepge c_framec c_memc i0 = SomeIStopUncheckedw

–destruct xs ; discriminate H |

4 open

ge :
Hd :
w0 :
xs :
listword
l :
Ha :
fr_atc_framec = Snapshotw0 :: xs l
H :
negbforallbsnapshot_word w0 :: xs
→
Stuck"snapshot"
else
Freshheap_req16 8 × Z.of_natDatatypes.lengthw0 :: xs λbase : Z ⇒ c_frame ≔ fr_fn ≔ fr_fnc_framec; fr_env ≔ putva_snapshot WPtrptr_addr ≔ base; ptr_cap ≔ Robase fr_envc_framec; fr_locals ≔ fr_localsc_framec; fr_doomed ≔ fr_doomedc_framec; fr_at ≔ Enterl None; c_callers ≔ c_callersc; c_mem ≔ snapshot_valuesw0 :: xs base allocatedc_memc heap_req16 8 × Z.of_natDatatypes.lengthw0 :: xs base; c_fuel ≔ c_fuelc
=
⊢
∃l0 : name i : inst rest : listinst j : jump, Snapshotw0 :: xs l = Execl0 i :: rest j ∧ inst_stepge c_framec c_memc i = SomeIStopUncheckedw
deferred goal
ge :
Hd :
l :
from :
optionname
Ha :
⊢
∃l0 : name i : inst rest : listinst j : jump, Enterl from = Execl0 i :: rest j ∧ inst_stepge c_framec c_memc i = SomeIStopUncheckedw
deferred goal
ge :
Hd :
l :
j :
Ha :
fr_atc_framec = Execl [ ] j
H :
⊢
∃l0 : name i : inst rest : listinst j0 : jump, Execl [ ] j = Execl0 i :: rest j0 ∧ inst_stepge c_framec c_memc i = SomeIStopUncheckedw
deferred goal
ge :
Hd :
l :
i :
rest :
listinst
j :
Ha :
fr_atc_framec = Execl i :: rest j
H :
match let* why ≔ fr_doomedc_framec in if ahead_transparenti then None else Somewhy with
Somewhy
⇒
None
⇒
or_stuck"instruction"
let* out0 ≔ inst_stepge c_framec c_memc i in
let* od ≔ doomed_resultge c_framec c_memc i out0 in
Someinst_nextc l rest j fstod sndod
=
⊢
∃l0 : name i0 : inst rest0 : listinst j0 : jump, Execl i :: rest j = Execl0 i0 :: rest0 j0 ∧ inst_stepge c_framec c_memc i0 = SomeIStopUncheckedw

destruct negb_ ; discriminate H

3 open

deferred goal
ge :
Hd :
l :
from :
optionname
Ha :
⊢
∃l0 : name i : inst rest : listinst j : jump, Enterl from = Execl0 i :: rest j ∧ inst_stepge c_framec c_memc i = SomeIStopUncheckedw
deferred goal
ge :
Hd :
l :
j :
Ha :
fr_atc_framec = Execl [ ] j
H :
⊢
∃l0 : name i : inst rest : listinst j0 : jump, Execl [ ] j = Execl0 i :: rest j0 ∧ inst_stepge c_framec c_memc i = SomeIStopUncheckedw
deferred goal
ge :
Hd :
l :
i :
rest :
listinst
j :
Ha :
fr_atc_framec = Execl i :: rest j
H :
match let* why ≔ fr_doomedc_framec in if ahead_transparenti then None else Somewhy with
Somewhy
⇒
None
⇒
or_stuck"instruction"
let* out0 ≔ inst_stepge c_framec c_memc i in
let* od ≔ doomed_resultge c_framec c_memc i out0 in
Someinst_nextc l rest j fstod sndod
=
⊢
∃l0 : name i0 : inst rest0 : listinst j0 : jump, Execl i :: rest j = Execl0 i0 :: rest0 j0 ∧ inst_stepge c_framec c_memc i0 = SomeIStopUncheckedw

–destruct c_fuelc =? 0 ; discriminate H |

3 open

ge :
Hd :
l :
from :
optionname
Ha :
⊢
∃l0 : name i : inst rest : listinst j : jump, Enterl from = Execl0 i :: rest j ∧ inst_stepge c_framec c_memc i = SomeIStopUncheckedw
deferred goal
ge :
Hd :
l :
j :
Ha :
fr_atc_framec = Execl [ ] j
H :
⊢
∃l0 : name i : inst rest : listinst j0 : jump, Execl [ ] j = Execl0 i :: rest j0 ∧ inst_stepge c_framec c_memc i = SomeIStopUncheckedw
deferred goal
ge :
Hd :
l :
i :
rest :
listinst
j :
Ha :
fr_atc_framec = Execl i :: rest j
H :
match let* why ≔ fr_doomedc_framec in if ahead_transparenti then None else Somewhy with
Somewhy
⇒
None
⇒
or_stuck"instruction"
let* out0 ≔ inst_stepge c_framec c_memc i in
let* od ≔ doomed_resultge c_framec c_memc i out0 in
Someinst_nextc l rest j fstod sndod
=
⊢
∃l0 : name i0 : inst rest0 : listinst j0 : jump, Execl i :: rest j = Execl0 i0 :: rest0 j0 ∧ inst_stepge c_framec c_memc i0 = SomeIStopUncheckedw

unfold or_stuck in H

3 open

ge :
Hd :
l :
from :
optionname
Ha :
H :
match let* b ≔ find_blockl fn_blocksfr_fnc_framec in let* e ≔ phis_envge b_phisb from fr_envc_framec in SomeNextc_frame ≔ fr_fn ≔ fr_fnc_framec; fr_env ≔ e; fr_locals ≔ fr_localsc_framec; fr_doomed ≔ fr_doomedc_framec; fr_at ≔ Execl b_instsb b_jumpb; c_callers ≔ c_callersc; c_mem ≔ c_memc; c_fuel ≔ c_fuelc − 1 with
Somes
⇒
s
None
⇒
Stuck"block"
=
⊢
∃l0 : name i : inst rest : listinst j : jump, Enterl from = Execl0 i :: rest j ∧ inst_stepge c_framec c_memc i = SomeIStopUncheckedw
deferred goal
ge :
Hd :
l :
j :
Ha :
fr_atc_framec = Execl [ ] j
H :
⊢
∃l0 : name i : inst rest : listinst j0 : jump, Execl [ ] j = Execl0 i :: rest j0 ∧ inst_stepge c_framec c_memc i = SomeIStopUncheckedw
deferred goal
ge :
Hd :
l :
i :
rest :
listinst
j :
Ha :
fr_atc_framec = Execl i :: rest j
H :
match let* why ≔ fr_doomedc_framec in if ahead_transparenti then None else Somewhy with
Somewhy
⇒
None
⇒
or_stuck"instruction"
let* out0 ≔ inst_stepge c_framec c_memc i in
let* od ≔ doomed_resultge c_framec c_memc i out0 in
Someinst_nextc l rest j fstod sndod
=
⊢
∃l0 : name i0 : inst rest0 : listinst j0 : jump, Execl i :: rest j = Execl0 i0 :: rest0 j0 ∧ inst_stepge c_framec c_memc i0 = SomeIStopUncheckedw

destruct find_blockl _ ; simpl in H ; | discriminate H

3 open

ge :
Hd :
l :
from :
optionname
Ha :
H :
match let* e ≔ phis_envge b_phisb from fr_envc_framec in SomeNextc_frame ≔ fr_fn ≔ fr_fnc_framec; fr_env ≔ e; fr_locals ≔ fr_localsc_framec; fr_doomed ≔ fr_doomedc_framec; fr_at ≔ Execl b_instsb b_jumpb; c_callers ≔ c_callersc; c_mem ≔ c_memc; c_fuel ≔ c_fuelc − 1 with
Somes
⇒
s
None
⇒
Stuck"block"
=
⊢
∃l0 : name i : inst rest : listinst j : jump, Enterl from = Execl0 i :: rest j ∧ inst_stepge c_framec c_memc i = SomeIStopUncheckedw
deferred goal
ge :
Hd :
l :
j :
Ha :
fr_atc_framec = Execl [ ] j
H :
⊢
∃l0 : name i : inst rest : listinst j0 : jump, Execl [ ] j = Execl0 i :: rest j0 ∧ inst_stepge c_framec c_memc i = SomeIStopUncheckedw
deferred goal
ge :
Hd :
l :
i :
rest :
listinst
j :
Ha :
fr_atc_framec = Execl i :: rest j
H :
match let* why ≔ fr_doomedc_framec in if ahead_transparenti then None else Somewhy with
Somewhy
⇒
None
⇒
or_stuck"instruction"
let* out0 ≔ inst_stepge c_framec c_memc i in
let* od ≔ doomed_resultge c_framec c_memc i out0 in
Someinst_nextc l rest j fstod sndod
=
⊢
∃l0 : name i0 : inst rest0 : listinst j0 : jump, Execl i :: rest j = Execl0 i0 :: rest0 j0 ∧ inst_stepge c_framec c_memc i0 = SomeIStopUncheckedw

destruct phis_env_ _ _ _ ; simpl in H ; discriminate H

2 open

deferred goal
ge :
Hd :
l :
j :
Ha :
fr_atc_framec = Execl [ ] j
H :
⊢
∃l0 : name i : inst rest : listinst j0 : jump, Execl [ ] j = Execl0 i :: rest j0 ∧ inst_stepge c_framec c_memc i = SomeIStopUncheckedw
deferred goal
ge :
Hd :
l :
i :
rest :
listinst
j :
Ha :
fr_atc_framec = Execl i :: rest j
H :
match let* why ≔ fr_doomedc_framec in if ahead_transparenti then None else Somewhy with
Somewhy
⇒
None
⇒
or_stuck"instruction"
let* out0 ≔ inst_stepge c_framec c_memc i in
let* od ≔ doomed_resultge c_framec c_memc i out0 in
Someinst_nextc l rest j fstod sndod
=
⊢
∃l0 : name i0 : inst rest0 : listinst j0 : jump, Execl i :: rest j = Execl0 i0 :: rest0 j0 ∧ inst_stepge c_framec c_memc i0 = SomeIStopUncheckedw

–exfalso

2 open

ge :
Hd :
l :
j :
Ha :
fr_atc_framec = Execl [ ] j
H :
⊢
False
deferred goal
ge :
Hd :
l :
i :
rest :
listinst
j :
Ha :
fr_atc_framec = Execl i :: rest j
H :
match let* why ≔ fr_doomedc_framec in if ahead_transparenti then None else Somewhy with
Somewhy
⇒
None
⇒
or_stuck"instruction"
let* out0 ≔ inst_stepge c_framec c_memc i in
let* od ≔ doomed_resultge c_framec c_memc i out0 in
Someinst_nextc l rest j fstod sndod
=
⊢
∃l0 : name i0 : inst rest0 : listinst j0 : jump, Execl i :: rest j = Execl0 i0 :: rest0 j0 ∧ inst_stepge c_framec c_memc i0 = SomeIStopUncheckedw

unfold jump_step , edge_step , or_stuck in H

2 open

ge :
Hd :
l :
j :
Ha :
fr_atc_framec = Execl [ ] j
H :
match fr_doomedc_framec with
Somewhy
⇒
match j with
JBranchv t1 t2
⇒
match match value_xge fr_envc_framec W v with SomeWIntn ⇒ Somematch if n =? 0 then t2 else t1 with To_ ⇒ Nextcontinue_atc with_pointc_framec Enteredge_labelif n =? 0 then t2 else t1 Somel c_memc c_fuelc | Poll_ ⇒ match fr_doomedc_framec with Somewhy0 ⇒ DoneUncheckedAheadwhy0 | None ⇒ Nextcontinue_atc with_pointc_framec Enteredge_labelif n =? 0 then t2 else t1 Somel c_memc c_fuelc end end | _ ⇒ None end with
Somes
⇒
s
None
⇒
Stuck"branch"
None
⇒
match j with
JBranchv t1 t2
⇒
match match value_xge fr_envc_framec W v with SomeWIntn ⇒ Somematch if n =? 0 then t2 else t1 with To_ ⇒ Nextcontinue_atc with_pointc_framec Enteredge_labelif n =? 0 then t2 else t1 Somel c_memc c_fuelc | Poll_ ⇒ match fr_doomedc_framec with Somewhy ⇒ DoneUncheckedAheadwhy | None ⇒ Nextcontinue_atc with_pointc_framec Enteredge_labelif n =? 0 then t2 else t1 Somel c_memc c_fuelc end end | _ ⇒ None end with
Somes
⇒
s
None
⇒
Stuck"branch"
⇒
match match fn_retfr_fnc_framec with RClassk ⇒ let* x ≔ value_xge fr_envc_framec k v in Somereturn_stepc Retx | _ ⇒ None end with
Somes
⇒
s
None
⇒
Stuck"ret"
⇒
match match fn_retfr_fnc_framec with RTupleks ⇒ let* xs ≔ map2_optionvalue_xge fr_envc_framec ks vs in Somereturn_stepc Retsxs | _ ⇒ None end with
Somes
⇒
s
None
⇒
Stuck"rets"
=
⊢
False
deferred goal
ge :
Hd :
l :
i :
rest :
listinst
j :
Ha :
fr_atc_framec = Execl i :: rest j
H :
match let* why ≔ fr_doomedc_framec in if ahead_transparenti then None else Somewhy with
Somewhy
⇒
None
⇒
or_stuck"instruction"
let* out0 ≔ inst_stepge c_framec c_memc i in
let* od ≔ doomed_resultge c_framec c_memc i out0 in
Someinst_nextc l rest j fstod sndod
=
⊢
∃l0 : name i0 : inst rest0 : listinst j0 : jump, Execl i :: rest j = Execl0 i0 :: rest0 j0 ∧ inst_stepge c_framec c_memc i0 = SomeIStopUncheckedw

rewrite Hd in H

2 open

ge :
Hd :
l :
j :
Ha :
fr_atc_framec = Execl [ ] j
H :
match j with
JBranchv t1 t2
⇒
match match value_xge fr_envc_framec W v with SomeWIntn ⇒ Somematch if n =? 0 then t2 else t1 with To_ | _ ⇒ Nextcontinue_atc with_pointc_framec Enteredge_labelif n =? 0 then t2 else t1 Somel c_memc c_fuelc end | _ ⇒ None end with
Somes
⇒
s
None
⇒
Stuck"branch"
⇒
match match fn_retfr_fnc_framec with RClassk ⇒ let* x ≔ value_xge fr_envc_framec k v in Somereturn_stepc Retx | _ ⇒ None end with
Somes
⇒
s
None
⇒
Stuck"ret"
⇒
match match fn_retfr_fnc_framec with RTupleks ⇒ let* xs ≔ map2_optionvalue_xge fr_envc_framec ks vs in Somereturn_stepc Retsxs | _ ⇒ None end with
Somes
⇒
s
None
⇒
Stuck"rets"
=
⊢
False
deferred goal
ge :
Hd :
l :
i :
rest :
listinst
j :
Ha :
fr_atc_framec = Execl i :: rest j
H :
match let* why ≔ fr_doomedc_framec in if ahead_transparenti then None else Somewhy with
Somewhy
⇒
None
⇒
or_stuck"instruction"
let* out0 ≔ inst_stepge c_framec c_memc i in
let* od ≔ doomed_resultge c_framec c_memc i out0 in
Someinst_nextc l rest j fstod sndod
=
⊢
∃l0 : name i0 : inst rest0 : listinst j0 : jump, Execl i :: rest j = Execl0 i0 :: rest0 j0 ∧ inst_stepge c_framec c_memc i0 = SomeIStopUncheckedw

cbv zeta in H

2 open

ge :
Hd :
l :
j :
Ha :
fr_atc_framec = Execl [ ] j
H :
match j with
JBranchv t1 t2
⇒
match match value_xge fr_envc_framec W v with SomeWIntn ⇒ Somematch if n =? 0 then t2 else t1 with To_ | _ ⇒ Nextcontinue_atc with_pointc_framec Enteredge_labelif n =? 0 then t2 else t1 Somel c_memc c_fuelc end | _ ⇒ None end with
Somes
⇒
s
None
⇒
Stuck"branch"
⇒
match match fn_retfr_fnc_framec with RClassk ⇒ let* x ≔ value_xge fr_envc_framec k v in Somereturn_stepc Retx | _ ⇒ None end with
Somes
⇒
s
None
⇒
Stuck"ret"
⇒
match match fn_retfr_fnc_framec with RTupleks ⇒ let* xs ≔ map2_optionvalue_xge fr_envc_framec ks vs in Somereturn_stepc Retsxs | _ ⇒ None end with
Somes
⇒
s
None
⇒
Stuck"rets"
=
⊢
False
deferred goal
ge :
Hd :
l :
i :
rest :
listinst
j :
Ha :
fr_atc_framec = Execl i :: rest j
H :
match let* why ≔ fr_doomedc_framec in if ahead_transparenti then None else Somewhy with
Somewhy
⇒
None
⇒
or_stuck"instruction"
let* out0 ≔ inst_stepge c_framec c_memc i in
let* od ≔ doomed_resultge c_framec c_memc i out0 in
Someinst_nextc l rest j fstod sndod
=
⊢
∃l0 : name i0 : inst rest0 : listinst j0 : jump, Execl i :: rest j = Execl0 i0 :: rest0 j0 ∧ inst_stepge c_framec c_memc i0 = SomeIStopUncheckedw

cases H

5 open

ge :
Hd :
l :
j :
t1, t2 :
Heqj0 :
j = JBranchv t1 t2
Ha :
fr_atc_framec = Execl [ ] JBranchv t1 t2
Heqo :
match value_xge fr_envc_framec W v with
SomeWIntn
⇒
Some
match if n =? 0 then t2 else t1 with
_
⇒
None
=
Somes
H :
⊢
False
focused goal
ge :
Hd :
l :
j :
Heqj0 :
j = JRetv
Ha :
Heqo :
match fn_retfr_fnc_framec with
⇒
let* x ≔ value_xge fr_envc_framec k v in
_
⇒
None
=
Somes
H :
⊢
False
focused goal
ge :
Hd :
l :
j :
vs :
listvalue
Heqj0 :
j = JRetsvs
Ha :
Heqo :
match fn_retfr_fnc_framec with
⇒
let* xs ≔ map2_optionvalue_xge fr_envc_framec ks vs in
_
⇒
None
=
Somes
H :
⊢
False
focused goal
⊢
False
deferred goal
ge :
Hd :
l :
i :
rest :
listinst
j :
Ha :
fr_atc_framec = Execl i :: rest j
H :
match let* why ≔ fr_doomedc_framec in if ahead_transparenti then None else Somewhy with
Somewhy
⇒
None
⇒
or_stuck"instruction"
let* out0 ≔ inst_stepge c_framec c_memc i in
let* od ≔ doomed_resultge c_framec c_memc i out0 in
Someinst_nextc l rest j fstod sndod
=
⊢
∃l0 : name i0 : inst rest0 : listinst j0 : jump, Execl i :: rest j = Execl0 i0 :: rest0 j0 ∧ inst_stepge c_framec c_memc i0 = SomeIStopUncheckedw

all: repeat match goal withE : Some_ = Some_ |- _⇒injection E as EE : return_step_ _ = Done_ |- _⇒apply return_step_done in E ; discriminate EE : ?x = Done_ |- _⇒is_var x ; subst xE : context [match _ with _ ⇒ _ end] |- _⇒progress cases Eend

deferred goal
ge :
Hd :
l :
i :
rest :
listinst
j :
Ha :
fr_atc_framec = Execl i :: rest j
H :
match let* why ≔ fr_doomedc_framec in if ahead_transparenti then None else Somewhy with
Somewhy
⇒
None
⇒
or_stuck"instruction"
let* out0 ≔ inst_stepge c_framec c_memc i in
let* od ≔ doomed_resultge c_framec c_memc i out0 in
Someinst_nextc l rest j fstod sndod
=
⊢
∃l0 : name i0 : inst rest0 : listinst j0 : jump, Execl i :: rest j = Execl0 i0 :: rest0 j0 ∧ inst_stepge c_framec c_memc i0 = SomeIStopUncheckedw

–rewrite Hd in H

ge :
Hd :
l :
i :
rest :
listinst
j :
Ha :
fr_atc_framec = Execl i :: rest j
H :
or_stuck"instruction"
let* out0 ≔ inst_stepge c_framec c_memc i in
let* od ≔ doomed_resultge c_framec c_memc i out0 in
Someinst_nextc l rest j fstod sndod
=
⊢
∃l0 : name i0 : inst rest0 : listinst j0 : jump, Execl i :: rest j = Execl0 i0 :: rest0 j0 ∧ inst_stepge c_framec c_memc i0 = SomeIStopUncheckedw

cbv zeta in H

ge :
Hd :
l :
i :
rest :
listinst
j :
Ha :
fr_atc_framec = Execl i :: rest j
H :
or_stuck"instruction"
let* out0 ≔ inst_stepge c_framec c_memc i in
let* od ≔ doomed_resultge c_framec c_memc i out0 in
Someinst_nextc l rest j fstod sndod
=
⊢
∃l0 : name i0 : inst rest0 : listinst j0 : jump, Execl i :: rest j = Execl0 i0 :: rest0 j0 ∧ inst_stepge c_framec c_memc i0 = SomeIStopUncheckedw

destruct inst_stepge c_framec c_memc i as out0 | eqn: Ei ; | discriminate H

ge :
Hd :
l :
i :
rest :
listinst
j :
Ha :
fr_atc_framec = Execl i :: rest j
out0 :
Ei :
inst_stepge c_framec c_memc i = Someout0
H :
or_stuck"instruction"
let* od ≔ doomed_resultge c_framec c_memc i out0 in
Someinst_nextc l rest j fstod sndod
=
⊢
∃l0 : name i0 : inst rest0 : listinst j0 : jump, Execl i :: rest j = Execl0 i0 :: rest0 j0 ∧ inst_stepge c_framec c_memc i0 = SomeIStopUncheckedw

simpl in H

ge :
Hd :
l :
i :
rest :
listinst
j :
Ha :
fr_atc_framec = Execl i :: rest j
out0 :
Ei :
inst_stepge c_framec c_memc i = Someout0
H :
or_stuck"instruction"
let* od ≔ doomed_resultge c_framec c_memc i out0 in
Someinst_nextc l rest j fstod sndod
=
⊢
∃l0 : name i0 : inst rest0 : listinst j0 : jump, Execl i :: rest j = Execl0 i0 :: rest0 j0 ∧ inst_stepge c_framec c_memc i0 = SomeIStopUncheckedw

destruct doomed_resultge c_framec c_memc i out0 as od | eqn: Eo ; | discriminate H

ge :
Hd :
l :
i :
rest :
listinst
j :
Ha :
fr_atc_framec = Execl i :: rest j
out0 :
Ei :
inst_stepge c_framec c_memc i = Someout0
od :
inst_out × optionreason
Eo :
doomed_resultge c_framec c_memc i out0 = Someod
H :
or_stuck"instruction" Someinst_nextc l rest j fstod sndod = DoneUncheckedw
⊢
∃l0 : name i0 : inst rest0 : listinst j0 : jump, Execl i :: rest j = Execl0 i0 :: rest0 j0 ∧ inst_stepge c_framec c_memc i0 = SomeIStopUncheckedw

simpl in H

ge :
Hd :
l :
i :
rest :
listinst
j :
Ha :
fr_atc_framec = Execl i :: rest j
out0 :
Ei :
inst_stepge c_framec c_memc i = Someout0
od :
inst_out × optionreason
Eo :
doomed_resultge c_framec c_memc i out0 = Someod
H :
inst_nextc l rest j fstod sndod = DoneUncheckedw
⊢
∃l0 : name i0 : inst rest0 : listinst j0 : jump, Execl i :: rest j = Execl0 i0 :: rest0 j0 ∧ inst_stepge c_framec c_memc i0 = SomeIStopUncheckedw

apply inst_next_done in H

ge :
Hd :
l :
i :
rest :
listinst
j :
Ha :
fr_atc_framec = Execl i :: rest j
out0 :
Ei :
inst_stepge c_framec c_memc i = Someout0
od :
inst_out × optionreason
Eo :
doomed_resultge c_framec c_memc i out0 = Someod
H :
fstod = IStopUncheckedw
⊢
∃l0 : name i0 : inst rest0 : listinst j0 : jump, Execl i :: rest j = Execl0 i0 :: rest0 j0 ∧ inst_stepge c_framec c_memc i0 = SomeIStopUncheckedw

destruct undoomed_result_ _ _ _ _ _ Hd Eo as Ho | e & locals & m′ & Ho ; rewrite H in Ho ; | discriminate Ho

ge :
Hd :
l :
i :
rest :
listinst
j :
Ha :
fr_atc_framec = Execl i :: rest j
out0 :
Ei :
inst_stepge c_framec c_memc i = Someout0
od :
inst_out × optionreason
Eo :
doomed_resultge c_framec c_memc i out0 = Someod
H :
fstod = IStopUncheckedw
Ho :
⊢
∃l0 : name i0 : inst rest0 : listinst j0 : jump, Execl i :: rest j = Execl0 i0 :: rest0 j0 ∧ inst_stepge c_framec c_memc i0 = SomeIStopUncheckedw

exists l, i, rest, j

ge :
Hd :
l :
i :
rest :
listinst
j :
Ha :
fr_atc_framec = Execl i :: rest j
out0 :
Ei :
inst_stepge c_framec c_memc i = Someout0
od :
inst_out × optionreason
Eo :
doomed_resultge c_framec c_memc i out0 = Someod
H :
fstod = IStopUncheckedw
Ho :
⊢
Execl i :: rest j = Execl i :: rest j ∧ inst_stepge c_framec c_memc i = SomeIStopUncheckedw

split ; reflexivity |

ge :
Hd :
l :
i :
rest :
listinst
j :
Ha :
fr_atc_framec = Execl i :: rest j
out0 :
Ei :
inst_stepge c_framec c_memc i = Someout0
od :
inst_out × optionreason
Eo :
doomed_resultge c_framec c_memc i out0 = Someod
H :
fstod = IStopUncheckedw
Ho :

rewrite Ei , Ho

ge :
Hd :
l :
i :
rest :
listinst
j :
Ha :
fr_atc_framec = Execl i :: rest j
out0 :
Ei :
inst_stepge c_framec c_memc i = Someout0
od :
inst_out × optionreason
Eo :
doomed_resultge c_framec c_memc i out0 = Someod
H :
fstod = IStopUncheckedw
Ho :
⊢
Someout0 = Someout0

reflexivity

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros ge c w Hd H
unfold step in H
destruct fr_atc_framec as xs l | l from | l | i rest j eqn: Ha
–destruct xs ; discriminate H |
destruct negb_ ; discriminate H
–destruct c_fuelc =? 0 ; discriminate H |
unfold or_stuck in H
destruct find_blockl _ ; simpl in H ; | discriminate H
destruct phis_env_ _ _ _ ; simpl in H ; discriminate H
–exfalso
unfold jump_step , edge_step , or_stuck in H
rewrite Hd in H
cbv zeta in H
all: repeat match goal withE : Some_ = Some_ |- _⇒injection E as EE : return_step_ _ = Done_ |- _⇒apply return_step_done in E ; discriminate EE : ?x = Done_ |- _⇒is_var x ; subst xE : context [match _ with _ ⇒ _ end] |- _⇒progress cases Eend
–rewrite Hd in H
cbv zeta in H
destruct inst_stepge c_framec c_memc i as out0 | eqn: Ei ; | discriminate H
simpl in H
destruct doomed_resultge c_framec c_memc i out0 as od | eqn: Eo ; | discriminate H
simpl in H
apply inst_next_done in H
destruct undoomed_result_ _ _ _ _ _ Hd Eo as Ho | e & locals & m′ & Ho ; rewrite H in Ho ; | discriminate Ho
exists l, i, rest, j
split ; reflexivity |
rewrite Ei , Ho
reflexivity

Along a run

The theorem for any runtime R that meets Runtime.v's module type.

213Module Sound R : Runtime
215Module GD ≔ Guards R
216Module D ≔ Doom R

A step of Guard.v's machine instance, the one Chain.v's, Renew.v's and Guard.v's run theorems share, is a step of Doomed.v's.

220Lemma mstep_doom
∀ ge st st′
D.P.I.RM.mstepge st st′
Explore proof 2 tactics

Initial goal

⊢
∀ge : genv st st′ : GD.G.H.P.I.RM.mstate, GD.G.H.P.I.RM.mstepge st st′ → D.P.I.RM.mstepge st st′

intros ge st st′ H

ge :
H :
⊢
D.P.I.RM.mstepge st st′

destruct H ; econstructor ; eassumption

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros ge st st′ H
destruct H ; econstructor ; eassumption

A run of Guard.v's machine instance is a run of Doomed.v's, so run_doomed_checked applies to it.

225Lemma mreachable_doom
∀ ge st st′
Explore proof 6 tactics

Initial goal

⊢
∀ge : genv st st′ : GD.G.H.P.I.RM.mstate, GD.G.H.P.I.RM.mreachablege st st′ → D.P.I.RM.mreachablege st st′

intros ge st st′ H

induction H as st st′ H | st | st1 st2 st3 _ IH1 _ IH2

3 open

ge :
H :
⊢
focused goal
focused goal
ge :
st1, st2, st3 :
IH1 :
IH2 :
⊢

–apply rt_step

3 open

ge :
H :
⊢
D.P.I.RM.mstepge st st′
deferred goal
deferred goal
ge :
st1, st2, st3 :
IH1 :
IH2 :
⊢

exact mstep_doom_ _ _ H

2 open

deferred goal
deferred goal
ge :
st1, st2, st3 :
IH1 :
IH2 :
⊢

–apply rt_refl

deferred goal
ge :
st1, st2, st3 :
IH1 :
IH2 :
⊢

–exact rt_trans_ _ _ _ _ IH1 IH2

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros ge st st′ H
induction H as st st′ H | st | st1 st2 st3 _ IH1 _ IH2
–apply rt_step
exact mstep_doom_ _ _ H
–apply rt_refl
–exact rt_trans_ _ _ _ _ IH1 IH2

Soundness of checking. Take a module md the validator accepts (checked_module), a function f of it called with arguments xs, and a memory m where the runtime R is ready. In every state c a run reaches from that call, the next step is not unchecked: every access the checked code did not check was in bounds or trapped as a check would. It rests on Runtime.v's axioms (among them free_checked: free never answers unchecked); every runtime spares the pass's facts at safepoints (spares_any; see The evidence invariant over runs). The proof sends a doomed frame to run_doomed_checked, and any other to the run theorem for its instruction.

246Theorem valid_no_unchecked
∀ ge md f xs fr m fuel s0 c s w
ge_modulege = md
ge_freege = R.free
InIFuncf md
call_framef xs = Somefr
R.readys0 m
GD.G.H.P.I.RM.mreachablege mkConfigfr [ ] m fuel, s0 c, s
Proof 29 steps Qed
intros ge md f xs fr m fuel s0 c s w Hmd Hge Hfree Hin Hcf H0 Hreach E
destruct fr_doomedc_framec as why | eqn: Ed
–exact D.run_doomed_checkedge md f xs fr m fuel s0 c s w Hmd Hge Hfree Hin Hcf H0 mreachable_doom_ _ _ Hreach ltac:rewrite Ed ; discriminate E
–destruct step_unchecked_inst_ _ _ Ed E as l & i & rest & j & Ha & Hi
pose proof GD.G.H.S.run_sinv_ _ _ _ _ _ _ _ _ Hmd Hge Hfree Hin Hcf H0 GD.G.H.mreachable_same_ _ _ Hreach as Hsh _ _
simpl in Hsh
unfold shaped in Hsh
cbv zeta in Hsh
destruct Hsh as Hinf Hsh
rewrite Ha in Hsh
destruct Hsh as _ & b & k & Hb & _ & Hk & _
destruct find_block_in_ _ _ Hb as Hbin _
assert Hii : Ini b_instsb
{rewrite <- firstn_skipnk b_instsb
apply in_or_app
right
rewrite <- Hk
left
reflexivity
pose proof raw_tmp_ _ _ _ Hmd Hinf Hbin Hii as Hraw
pose proof GD.G.H.run_access_checkedge md f xs fr m fuel s0 c s l i rest j w Hmd Hge Hfree Hin Hcf H0 Hreach Ed Ha as Hacc
destruct inst_unchecked_source_ _ _ _ _ Hi as q & kc & o & args & → & Ho | wd & off & v & a & → | off & v & a & es & → | r & cl & args & → | r & args & x & m′ & → & Hf
+destruct o ; try discriminate Ho
all: first exact Haccor_introlHrawltac:left ; do 5 eexists ; reflexivity Hi | exact Haccor_introlHrawltac:right ; left ; do 5 eexists ; reflexivity Hi | exact GD.G.run_reuse_checkedge md f xs fr m fuel s0 c s l _ rest j w Hmd Hge Hfree Hin Hcf H0 Hreach Ed Ha ltac:left ; do 7 eexists ; reflexivity Hi | exact GD.G.run_reuse_checkedge md f xs fr m fuel s0 c s l _ rest j w Hmd Hge Hfree Hin Hcf H0 Hreach Ed Ha ltac:right ; left ; do 7 eexists ; reflexivity Hi | exact GD.G.run_reuse_checkedge md f xs fr m fuel s0 c s l _ rest j w Hmd Hge Hfree Hin Hcf H0 Hreach Ed Ha ltac:right ; right ; do 8 eexists ; reflexivity Hi | exact GD.run_guard_checkedge md f xs fr m fuel s0 c s l _ rest j w Hmd Hge Hfree Hin Hcf H0 Hreach Ed Ha ltac:left ; do 7 eexists ; reflexivity Hi | exact GD.run_guard_checkedge md f xs fr m fuel s0 c s l _ rest j w Hmd Hge Hfree Hin Hcf H0 Hreach Ed Ha ltac:right ; do 7 eexists ; reflexivity Hi
+exact Haccor_introlHrawltac:right ; right ; left ; do 4 eexists ; reflexivity Hi
+exact Haccor_introlHrawltac:right ; right ; right ; do 4 eexists ; reflexivity Hi
+exact Haccor_introrex_intro_ r ex_intro_ cl ex_intro_ args eq_refl Hi
+rewrite Hfree in Hf
exact R.free_checked_ _ _ _ Hf

The interpreter's runtime

The theorem for the interpreter's runtime.

295Module InterpSound ≔ Sound InterpRuntime

valid_no_unchecked for the interpreter's runtime: in every state of a run of a checked module's function that starts ready, no step is unchecked. No hypothesis remains but the ready start; Print Assumptions reports it closed.

301Corollary interp_valid_no_unchecked
∀ md globals f xs fr m fuel s0 c s w
let ge ≔ mkGenvmd globals InterpRuntime.free in
checked_modulemd → InIFuncf md → call_framef xs = Somefr → InterpRuntime.readys0 m → InterpSound.GD.G.H.P.I.RM.mreachablege mkConfigfr [ ] m fuel, s0 c, s → stepge c ≠ DoneUncheckedw
Explore proof 2 tactics

Initial goal

⊢
∀ md : module globals : listname × ptr f : func xs : listword fr : frame m : Memory.mem fuel : Z s0 : InterpRuntime.state c : config s : InterpRuntime.state w : reason  ,
let ge ≔ ge_module ≔ md; ge_globals ≔ globals; ge_free ≔ InterpRuntime.free in
checked_modulemd → InIFuncf md → call_framef xs = Somefr → InterpRuntime.readys0 m → InterpSound.GD.G.H.P.I.RM.mreachablege c_frame ≔ fr; c_callers ≔ [ ]; c_mem ≔ m; c_fuel ≔ fuel, s0 c, s → stepge c ≠ DoneUncheckedw

intros md globals f xs fr m fuel s0 c s w ge Hmd Hin Hcf H0 Hreach

md :
globals :
listname × ptr
f :
xs :
listword
fr :
m :
Memory.mem
fuel :
Z
ge :=
ge_module ≔ md; ge_globals ≔ globals; ge_free ≔ InterpRuntime.free : genv
Hin :
InIFuncf md
Hcf :
call_framef xs = Somefr
Hreach :
InterpSound.GD.G.H.P.I.RM.mreachablege c_frame ≔ fr; c_callers ≔ [ ]; c_mem ≔ m; c_fuel ≔ fuel, s0 c, s
⊢

exact InterpSound.valid_no_uncheckedge md f xs fr m fuel s0 c s w Hmd eq_refl eq_refl Hin Hcf H0 Hreach

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros md globals f xs fr m fuel s0 c s w ge Hmd Hin Hcf H0 Hreach
exact InterpSound.valid_no_uncheckedge md f xs fr m fuel s0 c s w Hmd eq_refl eq_refl Hin Hcf H0 Hreach