Imports
Physical execution and width
@[expose] public section
Instruction traces
sectionnamespace ConjectureMachines.Riemann95.Traceopen Riemann120.Layer2 Schema Controlattribute [local irreducible] Control.instruction Control.effect Control.walked
Control.localEffects Control.outsideEffects Control.outsideInstrs Control.localInstrprivate theorem list_getD_append_left {α : Type*} : ∀ (l₁ l₂ : List α) (d : α) (i : ℕ),
i < l₁.length → (l₁ ++ l₂).getD i d = l₁.getD i d
| [], _, _, _, hi => absurd hi (Nat.not_lt_zero _)
| _ :: _, _, _, 0, _ => rfl
| _ :: xs, l₂, d, n + 1, hi => list_getD_append_left xs l₂ d n (Nat.lt_of_succ_lt_succ hi)theorem physical_arithmetic_step (c : ControlWord) (regs extra : List Nat)
(hlen : regs.length = 5) (P : Nat) (hP : (walked c).length + 3 ≤ P)
(next : RhRegCfg) (hnext : applyInstr (rawInstr c) regs = some next)
(r : Fin 5) (inc : Bool) (he : effect c = if inc then .inc r else .decnz r) :
∃ P' ≥ P, ∃ n ≥ 1, ∃ extra',
nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some (Physical.rootCfg P' next.stack (next.regs ++ extra')) ∧
(next.stack = [] → P + 1 ≤ P') := c:ControlWordregs:List ℕextra:List ℕhlen:regs.length = 5P:ℕhP:List.length (walked c) + 3 ≤ Pnext:RhRegCfghnext:applyInstr (rawInstr c) regs = some nextr:Fin 5inc:Boolhe:effect c = if inc = true then Effect.inc r else Effect.decnz r⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some (Physical.rootCfg P' next.stack (next.regs ++ extra')) ∧
(next.stack = [] → P + 1 ≤ P')
c:ControlWordregs:List ℕextra:List ℕhlen:regs.length = 5P:ℕhP:List.length (walked c) + 3 ≤ Pnext:RhRegCfghnext:applyInstr (rawInstr c) regs = some nextr:Fin 5inc:Boolhe:effect c = if inc = true then Effect.inc r else Effect.decnz rhr:↑r < regs.length⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some (Physical.rootCfg P' next.stack (next.regs ++ extra')) ∧
(next.stack = [] → P + 1 ≤ P')
c:ControlWordregs:List ℕextra:List ℕhlen:regs.length = 5P:ℕhP:List.length (walked c) + 3 ≤ Pnext:RhRegCfghnext:applyInstr (rawInstr c) regs = some nextr:Fin 5inc:Boolhe:effect c = if inc = true then Effect.inc r else Effect.decnz rhr:↑r < regs.lengthhrbank:↑r < (regs ++ extra).length⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some (Physical.rootCfg P' next.stack (next.regs ++ extra')) ∧
(next.stack = [] → P + 1 ≤ P')
obtain ⟨n,hn,hsteps⟩ := Dispatch.root_native c r inc he P (regs ++ extra) hrbank (byc:ControlWordregs:List ℕextra:List ℕhlen:regs.length = 5P:ℕhP:List.length (walked c) + 3 ≤ Pnext:RhRegCfghnext:applyInstr (rawInstr c) regs = some nextr:Fin 5inc:Boolhe:effect c = if inc = true then Effect.inc r else Effect.decnz rhr:↑r < regs.lengthhrbank:↑r < (regs ++ extra).length⊢ 3 ≤ P - List.length (walked c) omegaAll goals completed! 🐙)c:ControlWordregs:List ℕextra:List ℕhlen:regs.length = 5P:ℕhP:List.length (walked c) + 3 ≤ Pnext:RhRegCfghnext:applyInstr (rawInstr c) regs = some nextr:Fin 5inc:Boolhe:effect c = if inc = true then Effect.inc r else Effect.decnz rhr:↑r < regs.lengthhrbank:↑r < (regs ++ extra).lengthn:ℕhn:n ≥ 1hsteps:nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some
(Physical.rootCfg
(Physical.exactPad (if inc = true then 0 else if (regs ++ extra).getD (↑r) 0 = 0 then 1 else 0) (walked c)
(P - List.length (walked c)))
(popBreakRev (↑(if inc = true then 0 else if (regs ++ extra).getD (↑r) 0 = 0 then 1 else 0))
(List.reverse (walked c))).reverse
(if inc = true then (regs ++ extra).set (↑r) ((regs ++ extra).getD (↑r) 0 + 1)
else
if (regs ++ extra).getD (↑r) 0 = 0 then regs ++ extra
else (regs ++ extra).set (↑r) ((regs ++ extra).getD (↑r) 0 - 1) ++ [0]))⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some (Physical.rootCfg P' next.stack (next.regs ++ extra')) ∧
(next.stack = [] → P + 1 ≤ P')
simp only [list_getD_append_left regs extra 0 r.val hr] at hstepsc:ControlWordregs:List ℕextra:List ℕhlen:regs.length = 5P:ℕhP:List.length (walked c) + 3 ≤ Pnext:RhRegCfghnext:applyInstr (rawInstr c) regs = some nextr:Fin 5inc:Boolhe:effect c = if inc = true then Effect.inc r else Effect.decnz rhr:↑r < regs.lengthhrbank:↑r < (regs ++ extra).lengthn:ℕhn:n ≥ 1hsteps:nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some
(Physical.rootCfg
(Physical.exactPad (if inc = true then 0 else if regs.getD (↑r) 0 = 0 then 1 else 0) (walked c)
(P - List.length (walked c)))
(popBreakRev (↑(if inc = true then 0 else if regs.getD (↑r) 0 = 0 then 1 else 0))
(List.reverse (walked c))).reverse
(if inc = true then (regs ++ extra).set (↑r) (regs.getD (↑r) 0 + 1)
else if regs.getD (↑r) 0 = 0 then regs ++ extra else (regs ++ extra).set (↑r) (regs.getD (↑r) 0 - 1) ++ [0]))⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some (Physical.rootCfg P' next.stack (next.regs ++ extra')) ∧
(next.stack = [] → P + 1 ≤ P')
have strict (k : Fin 2) (hk : k.val ≤ (walked c).count 0)
(hempty : (popBreakRev k.val (walked c).reverse).reverse = []) :
P + 1 ≤ Physical.exactPad k (walked c) (P - (walked c).length) := by
have hh := Physical.exactPad_of_return_empty k (walked c)
(P - (walked c).length) hk hemptyc:ControlWordregs:List ℕextra:List ℕhlen:regs.length = 5P:ℕhP:List.length (walked c) + 3 ≤ Pnext:RhRegCfghnext:applyInstr (rawInstr c) regs = some nextr:Fin 5inc:Boolhe:effect c = if inc = true then Effect.inc r else Effect.decnz rhr:↑r < regs.lengthhrbank:↑r < (regs ++ extra).lengthn:ℕhn:n ≥ 1hsteps:nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some
(Physical.rootCfg
(Physical.exactPad (if inc = true then 0 else if regs.getD (↑r) 0 = 0 then 1 else 0) (walked c)
(P - List.length (walked c)))
(popBreakRev (↑(if inc = true then 0 else if regs.getD (↑r) 0 = 0 then 1 else 0))
(List.reverse (walked c))).reverse
(if inc = true then (regs ++ extra).set (↑r) (regs.getD (↑r) 0 + 1)
else if regs.getD (↑r) 0 = 0 then regs ++ extra else (regs ++ extra).set (↑r) (regs.getD (↑r) 0 - 1) ++ [0]))k:Fin 2hk:↑k ≤ List.count 0 (walked c)hempty:(popBreakRev (↑k) (List.reverse (walked c))).reverse = []hh:Physical.exactPad k (walked c) (P - List.length (walked c)) = List.length (walked c) + (P - List.length (walked c)) + 1⊢ P + 1 ≤ Physical.exactPad k (walked c) (P - List.length (walked c))
omegac:ControlWordregs:List ℕextra:List ℕhlen:regs.length = 5P:ℕhP:List.length (walked c) + 3 ≤ Pnext:RhRegCfghnext:applyInstr (rawInstr c) regs = some nextr:Fin 5inc:Boolhe:effect c = if inc = true then Effect.inc r else Effect.decnz rhr:↑r < regs.lengthhrbank:↑r < (regs ++ extra).lengthn:ℕhn:n ≥ 1hsteps:nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some
(Physical.rootCfg
(Physical.exactPad (if inc = true then 0 else if regs.getD (↑r) 0 = 0 then 1 else 0) (walked c)
(P - List.length (walked c)))
(popBreakRev (↑(if inc = true then 0 else if regs.getD (↑r) 0 = 0 then 1 else 0))
(List.reverse (walked c))).reverse
(if inc = true then (regs ++ extra).set (↑r) (regs.getD (↑r) 0 + 1)
else if regs.getD (↑r) 0 = 0 then regs ++ extra else (regs ++ extra).set (↑r) (regs.getD (↑r) 0 - 1) ++ [0]))strict:∀ (k : Fin 2),
↑k ≤ List.count 0 (walked c) →
(popBreakRev (↑k) (List.reverse (walked c))).reverse = [] →
P + 1 ≤ Physical.exactPad k (walked c) (P - List.length (walked c))⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some (Physical.rootCfg P' next.stack (next.regs ++ extra')) ∧
(next.stack = [] → P + 1 ≤ P')
cases inc with
| true =>truec:ControlWordregs:List ℕextra:List ℕhlen:regs.length = 5P:ℕhP:List.length (walked c) + 3 ≤ Pnext:RhRegCfghnext:applyInstr (rawInstr c) regs = some nextr:Fin 5hr:↑r < regs.lengthhrbank:↑r < (regs ++ extra).lengthn:ℕhn:n ≥ 1strict:∀ (k : Fin 2),
↑k ≤ List.count 0 (walked c) →
(popBreakRev (↑k) (List.reverse (walked c))).reverse = [] →
P + 1 ≤ Physical.exactPad k (walked c) (P - List.length (walked c))he:effect c = if true = true then Effect.inc r else Effect.decnz rhsteps:nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some
(Physical.rootCfg
(Physical.exactPad (if true = true then 0 else if regs.getD (↑r) 0 = 0 then 1 else 0) (walked c)
(P - List.length (walked c)))
(popBreakRev (↑(if true = true then 0 else if regs.getD (↑r) 0 = 0 then 1 else 0))
(List.reverse (walked c))).reverse
(if true = true then (regs ++ extra).set (↑r) (regs.getD (↑r) 0 + 1)
else if regs.getD (↑r) 0 = 0 then regs ++ extra else (regs ++ extra).set (↑r) (regs.getD (↑r) 0 - 1) ++ [0]))⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some (Physical.rootCfg P' next.stack (next.regs ++ extra')) ∧
(next.stack = [] → P + 1 ≤ P')
simp only [ite_true] at he hstepstruec:ControlWordregs:List ℕextra:List ℕhlen:regs.length = 5P:ℕhP:List.length (walked c) + 3 ≤ Pnext:RhRegCfghnext:applyInstr (rawInstr c) regs = some nextr:Fin 5hr:↑r < regs.lengthhrbank:↑r < (regs ++ extra).lengthn:ℕhn:n ≥ 1strict:∀ (k : Fin 2),
↑k ≤ List.count 0 (walked c) →
(popBreakRev (↑k) (List.reverse (walked c))).reverse = [] →
P + 1 ≤ Physical.exactPad k (walked c) (P - List.length (walked c))he:effect c = Effect.inc rhsteps:nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some
(Physical.rootCfg (Physical.exactPad 0 (walked c) (P - List.length (walked c)))
(popBreakRev (↑0) (List.reverse (walked c))).reverse ((regs ++ extra).set (↑r) (regs.getD (↑r) 0 + 1)))⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some (Physical.rootCfg P' next.stack (next.regs ++ extra')) ∧
(next.stack = [] → P + 1 ≤ P')
simp only [rawInstr,he,applyInstr,returned,Bool.false_eq_true,ite_false,
Option.some.injEq] at hnexttruec:ControlWordregs:List ℕextra:List ℕhlen:regs.length = 5P:ℕhP:List.length (walked c) + 3 ≤ Pnext:RhRegCfgr:Fin 5hr:↑r < regs.lengthhrbank:↑r < (regs ++ extra).lengthn:ℕhn:n ≥ 1strict:∀ (k : Fin 2),
↑k ≤ List.count 0 (walked c) →
(popBreakRev (↑k) (List.reverse (walked c))).reverse = [] →
P + 1 ≤ Physical.exactPad k (walked c) (P - List.length (walked c))he:effect c = Effect.inc rhsteps:nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some
(Physical.rootCfg (Physical.exactPad 0 (walked c) (P - List.length (walked c)))
(popBreakRev (↑0) (List.reverse (walked c))).reverse ((regs ++ extra).set (↑r) (regs.getD (↑r) 0 + 1)))hnext:{ stack := (popBreakRev 0 (List.reverse (walked c))).reverse, regs := regs.set (↑r) (regs.getD (↑r) 0 + 1) } = next⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some (Physical.rootCfg P' next.stack (next.regs ++ extra')) ∧
(next.stack = [] → P + 1 ≤ P')
subst nexttruec:ControlWordregs:List ℕextra:List ℕhlen:regs.length = 5P:ℕhP:List.length (walked c) + 3 ≤ Pr:Fin 5hr:↑r < regs.lengthhrbank:↑r < (regs ++ extra).lengthn:ℕhn:n ≥ 1strict:∀ (k : Fin 2),
↑k ≤ List.count 0 (walked c) →
(popBreakRev (↑k) (List.reverse (walked c))).reverse = [] →
P + 1 ≤ Physical.exactPad k (walked c) (P - List.length (walked c))he:effect c = Effect.inc rhsteps:nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some
(Physical.rootCfg (Physical.exactPad 0 (walked c) (P - List.length (walked c)))
(popBreakRev (↑0) (List.reverse (walked c))).reverse ((regs ++ extra).set (↑r) (regs.getD (↑r) 0 + 1)))⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some
(Physical.rootCfg P'
{ stack := (popBreakRev 0 (List.reverse (walked c))).reverse,
regs := regs.set (↑r) (regs.getD (↑r) 0 + 1) }.stack
({ stack := (popBreakRev 0 (List.reverse (walked c))).reverse,
regs := regs.set (↑r) (regs.getD (↑r) 0 + 1) }.regs ++
extra')) ∧
({ stack := (popBreakRev 0 (List.reverse (walked c))).reverse,
regs := regs.set (↑r) (regs.getD (↑r) 0 + 1) }.stack =
[] →
P + 1 ≤ P')
have hge := Physical.exactPad_ge 0 (walked c) (P - (walked c).length)truec:ControlWordregs:List ℕextra:List ℕhlen:regs.length = 5P:ℕhP:List.length (walked c) + 3 ≤ Pr:Fin 5hr:↑r < regs.lengthhrbank:↑r < (regs ++ extra).lengthn:ℕhn:n ≥ 1strict:∀ (k : Fin 2),
↑k ≤ List.count 0 (walked c) →
(popBreakRev (↑k) (List.reverse (walked c))).reverse = [] →
P + 1 ≤ Physical.exactPad k (walked c) (P - List.length (walked c))he:effect c = Effect.inc rhsteps:nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some
(Physical.rootCfg (Physical.exactPad 0 (walked c) (P - List.length (walked c)))
(popBreakRev (↑0) (List.reverse (walked c))).reverse ((regs ++ extra).set (↑r) (regs.getD (↑r) 0 + 1)))hge:List.length (walked c) + (P - List.length (walked c)) ≤ Physical.exactPad 0 (walked c) (P - List.length (walked c))⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some
(Physical.rootCfg P'
{ stack := (popBreakRev 0 (List.reverse (walked c))).reverse,
regs := regs.set (↑r) (regs.getD (↑r) 0 + 1) }.stack
({ stack := (popBreakRev 0 (List.reverse (walked c))).reverse,
regs := regs.set (↑r) (regs.getD (↑r) 0 + 1) }.regs ++
extra')) ∧
({ stack := (popBreakRev 0 (List.reverse (walked c))).reverse,
regs := regs.set (↑r) (regs.getD (↑r) 0 + 1) }.stack =
[] →
P + 1 ≤ P')
refine ⟨_,byc:ControlWordregs:List ℕextra:List ℕhlen:regs.length = 5P:ℕhP:List.length (walked c) + 3 ≤ Pr:Fin 5hr:↑r < regs.lengthhrbank:↑r < (regs ++ extra).lengthn:ℕhn:n ≥ 1strict:∀ (k : Fin 2),
↑k ≤ List.count 0 (walked c) →
(popBreakRev (↑k) (List.reverse (walked c))).reverse = [] →
P + 1 ≤ Physical.exactPad k (walked c) (P - List.length (walked c))he:effect c = Effect.inc rhsteps:nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some
(Physical.rootCfg (Physical.exactPad 0 (walked c) (P - List.length (walked c)))
(popBreakRev (↑0) (List.reverse (walked c))).reverse ((regs ++ extra).set (↑r) (regs.getD (↑r) 0 + 1)))hge:List.length (walked c) + (P - List.length (walked c)) ≤ Physical.exactPad 0 (walked c) (P - List.length (walked c))⊢ Physical.exactPad 0 (walked c) (P - List.length (walked c)) ≥ P omegaAll goals completed! 🐙,n,hn,extra,?_,strict 0 (byc:ControlWordregs:List ℕextra:List ℕhlen:regs.length = 5P:ℕhP:List.length (walked c) + 3 ≤ Pr:Fin 5hr:↑r < regs.lengthhrbank:↑r < (regs ++ extra).lengthn:ℕhn:n ≥ 1strict:∀ (k : Fin 2),
↑k ≤ List.count 0 (walked c) →
(popBreakRev (↑k) (List.reverse (walked c))).reverse = [] →
P + 1 ≤ Physical.exactPad k (walked c) (P - List.length (walked c))he:effect c = Effect.inc rhsteps:nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some
(Physical.rootCfg (Physical.exactPad 0 (walked c) (P - List.length (walked c)))
(popBreakRev (↑0) (List.reverse (walked c))).reverse ((regs ++ extra).set (↑r) (regs.getD (↑r) 0 + 1)))hge:List.length (walked c) + (P - List.length (walked c)) ≤ Physical.exactPad 0 (walked c) (P - List.length (walked c))⊢ ↑0 ≤ List.count 0 (walked c) omegaAll goals completed! 🐙)⟩
simpa only [List.set_append_left _ _ hr,Fin.val_zero] using hstepsAll goals completed! 🐙
| false =>falsec:ControlWordregs:List ℕextra:List ℕhlen:regs.length = 5P:ℕhP:List.length (walked c) + 3 ≤ Pnext:RhRegCfghnext:applyInstr (rawInstr c) regs = some nextr:Fin 5hr:↑r < regs.lengthhrbank:↑r < (regs ++ extra).lengthn:ℕhn:n ≥ 1strict:∀ (k : Fin 2),
↑k ≤ List.count 0 (walked c) →
(popBreakRev (↑k) (List.reverse (walked c))).reverse = [] →
P + 1 ≤ Physical.exactPad k (walked c) (P - List.length (walked c))he:effect c = if false = true then Effect.inc r else Effect.decnz rhsteps:nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some
(Physical.rootCfg
(Physical.exactPad (if false = true then 0 else if regs.getD (↑r) 0 = 0 then 1 else 0) (walked c)
(P - List.length (walked c)))
(popBreakRev (↑(if false = true then 0 else if regs.getD (↑r) 0 = 0 then 1 else 0))
(List.reverse (walked c))).reverse
(if false = true then (regs ++ extra).set (↑r) (regs.getD (↑r) 0 + 1)
else if regs.getD (↑r) 0 = 0 then regs ++ extra else (regs ++ extra).set (↑r) (regs.getD (↑r) 0 - 1) ++ [0]))⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some (Physical.rootCfg P' next.stack (next.regs ++ extra')) ∧
(next.stack = [] → P + 1 ≤ P')
simp only [Bool.false_eq_true,ite_false] at he hstepsfalsec:ControlWordregs:List ℕextra:List ℕhlen:regs.length = 5P:ℕhP:List.length (walked c) + 3 ≤ Pnext:RhRegCfghnext:applyInstr (rawInstr c) regs = some nextr:Fin 5hr:↑r < regs.lengthhrbank:↑r < (regs ++ extra).lengthn:ℕhn:n ≥ 1strict:∀ (k : Fin 2),
↑k ≤ List.count 0 (walked c) →
(popBreakRev (↑k) (List.reverse (walked c))).reverse = [] →
P + 1 ≤ Physical.exactPad k (walked c) (P - List.length (walked c))he:effect c = Effect.decnz rhsteps:nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some
(Physical.rootCfg
(Physical.exactPad (if regs.getD (↑r) 0 = 0 then 1 else 0) (walked c) (P - List.length (walked c)))
(popBreakRev (↑(if regs.getD (↑r) 0 = 0 then 1 else 0)) (List.reverse (walked c))).reverse
(if regs.getD (↑r) 0 = 0 then regs ++ extra else (regs ++ extra).set (↑r) (regs.getD (↑r) 0 - 1) ++ [0]))⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some (Physical.rootCfg P' next.stack (next.regs ++ extra')) ∧
(next.stack = [] → P + 1 ≤ P')
simp only [rawInstr,he,applyInstr,returned,Bool.false_eq_true,ite_false,beq_iff_eq] at hnextfalsec:ControlWordregs:List ℕextra:List ℕhlen:regs.length = 5P:ℕhP:List.length (walked c) + 3 ≤ Pnext:RhRegCfgr:Fin 5hr:↑r < regs.lengthhrbank:↑r < (regs ++ extra).lengthn:ℕhn:n ≥ 1strict:∀ (k : Fin 2),
↑k ≤ List.count 0 (walked c) →
(popBreakRev (↑k) (List.reverse (walked c))).reverse = [] →
P + 1 ≤ Physical.exactPad k (walked c) (P - List.length (walked c))he:effect c = Effect.decnz rhsteps:nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some
(Physical.rootCfg
(Physical.exactPad (if regs.getD (↑r) 0 = 0 then 1 else 0) (walked c) (P - List.length (walked c)))
(popBreakRev (↑(if regs.getD (↑r) 0 = 0 then 1 else 0)) (List.reverse (walked c))).reverse
(if regs.getD (↑r) 0 = 0 then regs ++ extra else (regs ++ extra).set (↑r) (regs.getD (↑r) 0 - 1) ++ [0]))hnext:(if regs.getD (↑r) 0 = 0 then some { stack := (popBreakRev 1 (List.reverse (walked c))).reverse, regs := regs }
else
some { stack := (popBreakRev 0 (List.reverse (walked c))).reverse, regs := regs.set (↑r) (regs.getD (↑r) 0 - 1) }) =
some next⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some (Physical.rootCfg P' next.stack (next.regs ++ extra')) ∧
(next.stack = [] → P + 1 ≤ P')
by_cases hz : regs.getD r.val 0 = 0posc:ControlWordregs:List ℕextra:List ℕhlen:regs.length = 5P:ℕhP:List.length (walked c) + 3 ≤ Pnext:RhRegCfgr:Fin 5hr:↑r < regs.lengthhrbank:↑r < (regs ++ extra).lengthn:ℕhn:n ≥ 1strict:∀ (k : Fin 2),
↑k ≤ List.count 0 (walked c) →
(popBreakRev (↑k) (List.reverse (walked c))).reverse = [] →
P + 1 ≤ Physical.exactPad k (walked c) (P - List.length (walked c))he:effect c = Effect.decnz rhsteps:nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some
(Physical.rootCfg
(Physical.exactPad (if regs.getD (↑r) 0 = 0 then 1 else 0) (walked c) (P - List.length (walked c)))
(popBreakRev (↑(if regs.getD (↑r) 0 = 0 then 1 else 0)) (List.reverse (walked c))).reverse
(if regs.getD (↑r) 0 = 0 then regs ++ extra else (regs ++ extra).set (↑r) (regs.getD (↑r) 0 - 1) ++ [0]))hnext:(if regs.getD (↑r) 0 = 0 then some { stack := (popBreakRev 1 (List.reverse (walked c))).reverse, regs := regs }
else
some { stack := (popBreakRev 0 (List.reverse (walked c))).reverse, regs := regs.set (↑r) (regs.getD (↑r) 0 - 1) }) =
some nexthz:regs.getD (↑r) 0 = 0⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some (Physical.rootCfg P' next.stack (next.regs ++ extra')) ∧
(next.stack = [] → P + 1 ≤ P')negc:ControlWordregs:List ℕextra:List ℕhlen:regs.length = 5P:ℕhP:List.length (walked c) + 3 ≤ Pnext:RhRegCfgr:Fin 5hr:↑r < regs.lengthhrbank:↑r < (regs ++ extra).lengthn:ℕhn:n ≥ 1strict:∀ (k : Fin 2),
↑k ≤ List.count 0 (walked c) →
(popBreakRev (↑k) (List.reverse (walked c))).reverse = [] →
P + 1 ≤ Physical.exactPad k (walked c) (P - List.length (walked c))he:effect c = Effect.decnz rhsteps:nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some
(Physical.rootCfg
(Physical.exactPad (if regs.getD (↑r) 0 = 0 then 1 else 0) (walked c) (P - List.length (walked c)))
(popBreakRev (↑(if regs.getD (↑r) 0 = 0 then 1 else 0)) (List.reverse (walked c))).reverse
(if regs.getD (↑r) 0 = 0 then regs ++ extra else (regs ++ extra).set (↑r) (regs.getD (↑r) 0 - 1) ++ [0]))hnext:(if regs.getD (↑r) 0 = 0 then some { stack := (popBreakRev 1 (List.reverse (walked c))).reverse, regs := regs }
else
some { stack := (popBreakRev 0 (List.reverse (walked c))).reverse, regs := regs.set (↑r) (regs.getD (↑r) 0 - 1) }) =
some nexthz:¬regs.getD (↑r) 0 = 0⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some (Physical.rootCfg P' next.stack (next.regs ++ extra')) ∧
(next.stack = [] → P + 1 ≤ P')
·posc:ControlWordregs:List ℕextra:List ℕhlen:regs.length = 5P:ℕhP:List.length (walked c) + 3 ≤ Pnext:RhRegCfgr:Fin 5hr:↑r < regs.lengthhrbank:↑r < (regs ++ extra).lengthn:ℕhn:n ≥ 1strict:∀ (k : Fin 2),
↑k ≤ List.count 0 (walked c) →
(popBreakRev (↑k) (List.reverse (walked c))).reverse = [] →
P + 1 ≤ Physical.exactPad k (walked c) (P - List.length (walked c))he:effect c = Effect.decnz rhsteps:nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some
(Physical.rootCfg
(Physical.exactPad (if regs.getD (↑r) 0 = 0 then 1 else 0) (walked c) (P - List.length (walked c)))
(popBreakRev (↑(if regs.getD (↑r) 0 = 0 then 1 else 0)) (List.reverse (walked c))).reverse
(if regs.getD (↑r) 0 = 0 then regs ++ extra else (regs ++ extra).set (↑r) (regs.getD (↑r) 0 - 1) ++ [0]))hnext:(if regs.getD (↑r) 0 = 0 then some { stack := (popBreakRev 1 (List.reverse (walked c))).reverse, regs := regs }
else
some { stack := (popBreakRev 0 (List.reverse (walked c))).reverse, regs := regs.set (↑r) (regs.getD (↑r) 0 - 1) }) =
some nexthz:regs.getD (↑r) 0 = 0⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some (Physical.rootCfg P' next.stack (next.regs ++ extra')) ∧
(next.stack = [] → P + 1 ≤ P') simp only [hz,ite_true,Option.some.injEq] at hnext hstepsposc:ControlWordregs:List ℕextra:List ℕhlen:regs.length = 5P:ℕhP:List.length (walked c) + 3 ≤ Pnext:RhRegCfgr:Fin 5hr:↑r < regs.lengthhrbank:↑r < (regs ++ extra).lengthn:ℕhn:n ≥ 1strict:∀ (k : Fin 2),
↑k ≤ List.count 0 (walked c) →
(popBreakRev (↑k) (List.reverse (walked c))).reverse = [] →
P + 1 ≤ Physical.exactPad k (walked c) (P - List.length (walked c))he:effect c = Effect.decnz rhz:regs.getD (↑r) 0 = 0hnext:{ stack := (popBreakRev 1 (List.reverse (walked c))).reverse, regs := regs } = nexthsteps:nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some
(Physical.rootCfg (Physical.exactPad 1 (walked c) (P - List.length (walked c)))
(popBreakRev (↑1) (List.reverse (walked c))).reverse (regs ++ extra))⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some (Physical.rootCfg P' next.stack (next.regs ++ extra')) ∧
(next.stack = [] → P + 1 ≤ P')
subst nextposc:ControlWordregs:List ℕextra:List ℕhlen:regs.length = 5P:ℕhP:List.length (walked c) + 3 ≤ Pr:Fin 5hr:↑r < regs.lengthhrbank:↑r < (regs ++ extra).lengthn:ℕhn:n ≥ 1strict:∀ (k : Fin 2),
↑k ≤ List.count 0 (walked c) →
(popBreakRev (↑k) (List.reverse (walked c))).reverse = [] →
P + 1 ≤ Physical.exactPad k (walked c) (P - List.length (walked c))he:effect c = Effect.decnz rhz:regs.getD (↑r) 0 = 0hsteps:nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some
(Physical.rootCfg (Physical.exactPad 1 (walked c) (P - List.length (walked c)))
(popBreakRev (↑1) (List.reverse (walked c))).reverse (regs ++ extra))⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some
(Physical.rootCfg P' { stack := (popBreakRev 1 (List.reverse (walked c))).reverse, regs := regs }.stack
({ stack := (popBreakRev 1 (List.reverse (walked c))).reverse, regs := regs }.regs ++ extra')) ∧
({ stack := (popBreakRev 1 (List.reverse (walked c))).reverse, regs := regs }.stack = [] → P + 1 ≤ P')
have hge := Physical.exactPad_ge 1 (walked c) (P - (walked c).length)posc:ControlWordregs:List ℕextra:List ℕhlen:regs.length = 5P:ℕhP:List.length (walked c) + 3 ≤ Pr:Fin 5hr:↑r < regs.lengthhrbank:↑r < (regs ++ extra).lengthn:ℕhn:n ≥ 1strict:∀ (k : Fin 2),
↑k ≤ List.count 0 (walked c) →
(popBreakRev (↑k) (List.reverse (walked c))).reverse = [] →
P + 1 ≤ Physical.exactPad k (walked c) (P - List.length (walked c))he:effect c = Effect.decnz rhz:regs.getD (↑r) 0 = 0hsteps:nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some
(Physical.rootCfg (Physical.exactPad 1 (walked c) (P - List.length (walked c)))
(popBreakRev (↑1) (List.reverse (walked c))).reverse (regs ++ extra))hge:List.length (walked c) + (P - List.length (walked c)) ≤ Physical.exactPad 1 (walked c) (P - List.length (walked c))⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some
(Physical.rootCfg P' { stack := (popBreakRev 1 (List.reverse (walked c))).reverse, regs := regs }.stack
({ stack := (popBreakRev 1 (List.reverse (walked c))).reverse, regs := regs }.regs ++ extra')) ∧
({ stack := (popBreakRev 1 (List.reverse (walked c))).reverse, regs := regs }.stack = [] → P + 1 ≤ P')
refine ⟨_,byc:ControlWordregs:List ℕextra:List ℕhlen:regs.length = 5P:ℕhP:List.length (walked c) + 3 ≤ Pr:Fin 5hr:↑r < regs.lengthhrbank:↑r < (regs ++ extra).lengthn:ℕhn:n ≥ 1strict:∀ (k : Fin 2),
↑k ≤ List.count 0 (walked c) →
(popBreakRev (↑k) (List.reverse (walked c))).reverse = [] →
P + 1 ≤ Physical.exactPad k (walked c) (P - List.length (walked c))he:effect c = Effect.decnz rhz:regs.getD (↑r) 0 = 0hsteps:nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some
(Physical.rootCfg (Physical.exactPad 1 (walked c) (P - List.length (walked c)))
(popBreakRev (↑1) (List.reverse (walked c))).reverse (regs ++ extra))hge:List.length (walked c) + (P - List.length (walked c)) ≤ Physical.exactPad 1 (walked c) (P - List.length (walked c))⊢ Physical.exactPad 1 (walked c) (P - List.length (walked c)) ≥ P omegaAll goals completed! 🐙,n,hn,extra,hsteps,strict 1 ?_⟩
exact Dispatch.dec_walk_count c r heAll goals completed! 🐙
·negc:ControlWordregs:List ℕextra:List ℕhlen:regs.length = 5P:ℕhP:List.length (walked c) + 3 ≤ Pnext:RhRegCfgr:Fin 5hr:↑r < regs.lengthhrbank:↑r < (regs ++ extra).lengthn:ℕhn:n ≥ 1strict:∀ (k : Fin 2),
↑k ≤ List.count 0 (walked c) →
(popBreakRev (↑k) (List.reverse (walked c))).reverse = [] →
P + 1 ≤ Physical.exactPad k (walked c) (P - List.length (walked c))he:effect c = Effect.decnz rhsteps:nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some
(Physical.rootCfg
(Physical.exactPad (if regs.getD (↑r) 0 = 0 then 1 else 0) (walked c) (P - List.length (walked c)))
(popBreakRev (↑(if regs.getD (↑r) 0 = 0 then 1 else 0)) (List.reverse (walked c))).reverse
(if regs.getD (↑r) 0 = 0 then regs ++ extra else (regs ++ extra).set (↑r) (regs.getD (↑r) 0 - 1) ++ [0]))hnext:(if regs.getD (↑r) 0 = 0 then some { stack := (popBreakRev 1 (List.reverse (walked c))).reverse, regs := regs }
else
some { stack := (popBreakRev 0 (List.reverse (walked c))).reverse, regs := regs.set (↑r) (regs.getD (↑r) 0 - 1) }) =
some nexthz:¬regs.getD (↑r) 0 = 0⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some (Physical.rootCfg P' next.stack (next.regs ++ extra')) ∧
(next.stack = [] → P + 1 ≤ P') simp only [hz,ite_false,Option.some.injEq] at hnext hstepsnegc:ControlWordregs:List ℕextra:List ℕhlen:regs.length = 5P:ℕhP:List.length (walked c) + 3 ≤ Pnext:RhRegCfgr:Fin 5hr:↑r < regs.lengthhrbank:↑r < (regs ++ extra).lengthn:ℕhn:n ≥ 1strict:∀ (k : Fin 2),
↑k ≤ List.count 0 (walked c) →
(popBreakRev (↑k) (List.reverse (walked c))).reverse = [] →
P + 1 ≤ Physical.exactPad k (walked c) (P - List.length (walked c))he:effect c = Effect.decnz rhz:¬regs.getD (↑r) 0 = 0hnext:{ stack := (popBreakRev 0 (List.reverse (walked c))).reverse, regs := regs.set (↑r) (regs.getD (↑r) 0 - 1) } = nexthsteps:nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some
(Physical.rootCfg (Physical.exactPad 0 (walked c) (P - List.length (walked c)))
(popBreakRev (↑0) (List.reverse (walked c))).reverse ((regs ++ extra).set (↑r) (regs.getD (↑r) 0 - 1) ++ [0]))⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some (Physical.rootCfg P' next.stack (next.regs ++ extra')) ∧
(next.stack = [] → P + 1 ≤ P')
subst nextnegc:ControlWordregs:List ℕextra:List ℕhlen:regs.length = 5P:ℕhP:List.length (walked c) + 3 ≤ Pr:Fin 5hr:↑r < regs.lengthhrbank:↑r < (regs ++ extra).lengthn:ℕhn:n ≥ 1strict:∀ (k : Fin 2),
↑k ≤ List.count 0 (walked c) →
(popBreakRev (↑k) (List.reverse (walked c))).reverse = [] →
P + 1 ≤ Physical.exactPad k (walked c) (P - List.length (walked c))he:effect c = Effect.decnz rhz:¬regs.getD (↑r) 0 = 0hsteps:nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some
(Physical.rootCfg (Physical.exactPad 0 (walked c) (P - List.length (walked c)))
(popBreakRev (↑0) (List.reverse (walked c))).reverse ((regs ++ extra).set (↑r) (regs.getD (↑r) 0 - 1) ++ [0]))⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some
(Physical.rootCfg P'
{ stack := (popBreakRev 0 (List.reverse (walked c))).reverse,
regs := regs.set (↑r) (regs.getD (↑r) 0 - 1) }.stack
({ stack := (popBreakRev 0 (List.reverse (walked c))).reverse,
regs := regs.set (↑r) (regs.getD (↑r) 0 - 1) }.regs ++
extra')) ∧
({ stack := (popBreakRev 0 (List.reverse (walked c))).reverse,
regs := regs.set (↑r) (regs.getD (↑r) 0 - 1) }.stack =
[] →
P + 1 ≤ P')
have hge := Physical.exactPad_ge 0 (walked c) (P - (walked c).length)negc:ControlWordregs:List ℕextra:List ℕhlen:regs.length = 5P:ℕhP:List.length (walked c) + 3 ≤ Pr:Fin 5hr:↑r < regs.lengthhrbank:↑r < (regs ++ extra).lengthn:ℕhn:n ≥ 1strict:∀ (k : Fin 2),
↑k ≤ List.count 0 (walked c) →
(popBreakRev (↑k) (List.reverse (walked c))).reverse = [] →
P + 1 ≤ Physical.exactPad k (walked c) (P - List.length (walked c))he:effect c = Effect.decnz rhz:¬regs.getD (↑r) 0 = 0hsteps:nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some
(Physical.rootCfg (Physical.exactPad 0 (walked c) (P - List.length (walked c)))
(popBreakRev (↑0) (List.reverse (walked c))).reverse ((regs ++ extra).set (↑r) (regs.getD (↑r) 0 - 1) ++ [0]))hge:List.length (walked c) + (P - List.length (walked c)) ≤ Physical.exactPad 0 (walked c) (P - List.length (walked c))⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some
(Physical.rootCfg P'
{ stack := (popBreakRev 0 (List.reverse (walked c))).reverse,
regs := regs.set (↑r) (regs.getD (↑r) 0 - 1) }.stack
({ stack := (popBreakRev 0 (List.reverse (walked c))).reverse,
regs := regs.set (↑r) (regs.getD (↑r) 0 - 1) }.regs ++
extra')) ∧
({ stack := (popBreakRev 0 (List.reverse (walked c))).reverse,
regs := regs.set (↑r) (regs.getD (↑r) 0 - 1) }.stack =
[] →
P + 1 ≤ P')
refine ⟨_,byc:ControlWordregs:List ℕextra:List ℕhlen:regs.length = 5P:ℕhP:List.length (walked c) + 3 ≤ Pr:Fin 5hr:↑r < regs.lengthhrbank:↑r < (regs ++ extra).lengthn:ℕhn:n ≥ 1strict:∀ (k : Fin 2),
↑k ≤ List.count 0 (walked c) →
(popBreakRev (↑k) (List.reverse (walked c))).reverse = [] →
P + 1 ≤ Physical.exactPad k (walked c) (P - List.length (walked c))he:effect c = Effect.decnz rhz:¬regs.getD (↑r) 0 = 0hsteps:nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some
(Physical.rootCfg (Physical.exactPad 0 (walked c) (P - List.length (walked c)))
(popBreakRev (↑0) (List.reverse (walked c))).reverse ((regs ++ extra).set (↑r) (regs.getD (↑r) 0 - 1) ++ [0]))hge:List.length (walked c) + (P - List.length (walked c)) ≤ Physical.exactPad 0 (walked c) (P - List.length (walked c))⊢ Physical.exactPad 0 (walked c) (P - List.length (walked c)) ≥ P omegaAll goals completed! 🐙,n,hn,extra ++ [0],?_,strict 0 (byc:ControlWordregs:List ℕextra:List ℕhlen:regs.length = 5P:ℕhP:List.length (walked c) + 3 ≤ Pr:Fin 5hr:↑r < regs.lengthhrbank:↑r < (regs ++ extra).lengthn:ℕhn:n ≥ 1strict:∀ (k : Fin 2),
↑k ≤ List.count 0 (walked c) →
(popBreakRev (↑k) (List.reverse (walked c))).reverse = [] →
P + 1 ≤ Physical.exactPad k (walked c) (P - List.length (walked c))he:effect c = Effect.decnz rhz:¬regs.getD (↑r) 0 = 0hsteps:nSteps n (Physical.rootCfg P (word c) (regs ++ extra)) =
some
(Physical.rootCfg (Physical.exactPad 0 (walked c) (P - List.length (walked c)))
(popBreakRev (↑0) (List.reverse (walked c))).reverse ((regs ++ extra).set (↑r) (regs.getD (↑r) 0 - 1) ++ [0]))hge:List.length (walked c) + (P - List.length (walked c)) ≤ Physical.exactPad 0 (walked c) (P - List.length (walked c))⊢ ↑0 ≤ List.count 0 (walked c) omegaAll goals completed! 🐙)⟩
simpa only [List.set_append_left _ _ hr,List.append_assoc,Fin.val_zero] using hstepsAll goals completed! 🐙theorem physical_step (a b : Control.Cfg) (hlen : a.regs.length = 5)
(P : Nat) (hP : (walked a.control).length + 3 ≤ P)
(hs : Control.step a = some b) (extra : List Nat) :
∃ P' ≥ P, ∃ n ≥ 1, ∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word b.control) (b.regs ++ extra')) := bya:Control.Cfgb:Control.Cfghlen:a.regs.length = 5P:ℕhP:List.length (walked a.control) + 3 ≤ Phs:Control.step a = some bextra:List ℕ⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word b.control) (b.regs ++ extra'))
have hnext : applyInstr (rawInstr a.control) a.regs = some ⟨word b.control,b.regs⟩ := by
rw [← step_encode,a:Control.Cfgb:Control.Cfghlen:a.regs.length = 5P:ℕhP:List.length (walked a.control) + 3 ≤ Phs:Control.step a = some bextra:List ℕ⊢ Option.map encodeCfg (Control.step a) = some { stack := word b.control, regs := b.regs }hsa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5P:ℕhP:List.length (walked a.control) + 3 ≤ Phs:Control.step a = some bextra:List ℕ⊢ Option.map encodeCfg (some b) = some { stack := word b.control, regs := b.regs }]a:Control.Cfgb:Control.Cfghlen:a.regs.length = 5P:ℕhP:List.length (walked a.control) + 3 ≤ Phs:Control.step a = some bextra:List ℕ⊢ Option.map encodeCfg (some b) = some { stack := word b.control, regs := b.regs }
rfla:Control.Cfgb:Control.Cfghlen:a.regs.length = 5P:ℕhP:List.length (walked a.control) + 3 ≤ Phs:Control.step a = some bextra:List ℕhnext:applyInstr (rawInstr a.control) a.regs = some { stack := word b.control, regs := b.regs }⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word b.control) (b.regs ++ extra'))
cases he : effect a.control with
| halt =>halta:Control.Cfgb:Control.Cfghlen:a.regs.length = 5P:ℕhP:List.length (walked a.control) + 3 ≤ Phs:Control.step a = some bextra:List ℕhnext:applyInstr (rawInstr a.control) a.regs = some { stack := word b.control, regs := b.regs }he:effect a.control = Effect.halt⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word b.control) (b.regs ++ extra')) simp only [rawInstr,he,applyInstr] at hnexthalta:Control.Cfgb:Control.Cfghlen:a.regs.length = 5P:ℕhP:List.length (walked a.control) + 3 ≤ Phs:Control.step a = some bextra:List ℕhe:effect a.control = Effect.halthnext:none = some { stack := word b.control, regs := b.regs }⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word b.control) (b.regs ++ extra')); contradictionAll goals completed! 🐙
| inc r =>inca:Control.Cfgb:Control.Cfghlen:a.regs.length = 5P:ℕhP:List.length (walked a.control) + 3 ≤ Phs:Control.step a = some bextra:List ℕhnext:applyInstr (rawInstr a.control) a.regs = some { stack := word b.control, regs := b.regs }r:Fin 5he:effect a.control = Effect.inc r⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word b.control) (b.regs ++ extra'))
obtain ⟨P',hge,n,hn,tail,ht,_⟩ :=
physical_arithmetic_step a.control a.regs extra hlen P hP _ hnext r true heinca:Control.Cfgb:Control.Cfghlen:a.regs.length = 5P:ℕhP:List.length (walked a.control) + 3 ≤ Phs:Control.step a = some bextra:List ℕhnext:applyInstr (rawInstr a.control) a.regs = some { stack := word b.control, regs := b.regs }r:Fin 5he:effect a.control = Effect.inc rP':ℕhge:P' ≥ Pn:ℕhn:n ≥ 1tail:List ℕht:nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some
(Physical.rootCfg P' { stack := word b.control, regs := b.regs }.stack
({ stack := word b.control, regs := b.regs }.regs ++ tail))right✝:{ stack := word b.control, regs := b.regs }.stack = [] → P + 1 ≤ P'⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word b.control) (b.regs ++ extra'))
exact ⟨P',hge,n,hn,tail,ht⟩All goals completed! 🐙
| decnz r =>decnza:Control.Cfgb:Control.Cfghlen:a.regs.length = 5P:ℕhP:List.length (walked a.control) + 3 ≤ Phs:Control.step a = some bextra:List ℕhnext:applyInstr (rawInstr a.control) a.regs = some { stack := word b.control, regs := b.regs }r:Fin 5he:effect a.control = Effect.decnz r⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word b.control) (b.regs ++ extra'))
obtain ⟨P',hge,n,hn,tail,ht,_⟩ :=
physical_arithmetic_step a.control a.regs extra hlen P hP _ hnext r false hedecnza:Control.Cfgb:Control.Cfghlen:a.regs.length = 5P:ℕhP:List.length (walked a.control) + 3 ≤ Phs:Control.step a = some bextra:List ℕhnext:applyInstr (rawInstr a.control) a.regs = some { stack := word b.control, regs := b.regs }r:Fin 5he:effect a.control = Effect.decnz rP':ℕhge:P' ≥ Pn:ℕhn:n ≥ 1tail:List ℕht:nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some
(Physical.rootCfg P' { stack := word b.control, regs := b.regs }.stack
({ stack := word b.control, regs := b.regs }.regs ++ tail))right✝:{ stack := word b.control, regs := b.regs }.stack = [] → P + 1 ≤ P'⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word b.control) (b.regs ++ extra'))
exact ⟨P',hge,n,hn,tail,ht⟩All goals completed! 🐙
| jump cont k =>jumpa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5P:ℕhP:List.length (walked a.control) + 3 ≤ Phs:Control.step a = some bextra:List ℕhnext:applyInstr (rawInstr a.control) a.regs = some { stack := word b.control, regs := b.regs }cont:Boolk:ℕhe:effect a.control = Effect.jump cont k⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word b.control) (b.regs ++ extra'))
have hj : rawInstr a.control = .jump (returned cont k (walked a.control)) := by
simp only [rawInstr,he]jumpa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5P:ℕhP:List.length (walked a.control) + 3 ≤ Phs:Control.step a = some bextra:List ℕhnext:applyInstr (rawInstr a.control) a.regs = some { stack := word b.control, regs := b.regs }cont:Boolk:ℕhe:effect a.control = Effect.jump cont khj:rawInstr a.control = RhInstr.jump (returned cont k (walked a.control))⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word b.control) (b.regs ++ extra'))
rw [hjjumpa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5P:ℕhP:List.length (walked a.control) + 3 ≤ Phs:Control.step a = some bextra:List ℕcont:Boolk:ℕhnext:applyInstr (RhInstr.jump (returned cont k (walked a.control))) a.regs = some { stack := word b.control, regs := b.regs }he:effect a.control = Effect.jump cont khj:rawInstr a.control = RhInstr.jump (returned cont k (walked a.control))⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word b.control) (b.regs ++ extra'))] at hnextjumpa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5P:ℕhP:List.length (walked a.control) + 3 ≤ Phs:Control.step a = some bextra:List ℕcont:Boolk:ℕhnext:applyInstr (RhInstr.jump (returned cont k (walked a.control))) a.regs = some { stack := word b.control, regs := b.regs }he:effect a.control = Effect.jump cont khj:rawInstr a.control = RhInstr.jump (returned cont k (walked a.control))⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word b.control) (b.regs ++ extra'))
simp only [applyInstr,Option.some.injEq] at hnextjumpa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5P:ℕhP:List.length (walked a.control) + 3 ≤ Phs:Control.step a = some bextra:List ℕcont:Boolk:ℕhe:effect a.control = Effect.jump cont khj:rawInstr a.control = RhInstr.jump (returned cont k (walked a.control))hnext:{ stack := returned cont k (walked a.control), regs := a.regs } = { stack := word b.control, regs := b.regs }⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word b.control) (b.regs ++ extra'))
obtain ⟨n,hn,ht⟩ := RootJump.root_jump a.control _ hj P hP (a.regs ++ extra)jumpa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5P:ℕhP:List.length (walked a.control) + 3 ≤ Phs:Control.step a = some bextra:List ℕcont:Boolk:ℕhe:effect a.control = Effect.jump cont khj:rawInstr a.control = RhInstr.jump (returned cont k (walked a.control))hnext:{ stack := returned cont k (walked a.control), regs := a.regs } = { stack := word b.control, regs := b.regs }n:ℕhn:n ≥ 1ht:nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P (returned cont k (walked a.control)) (a.regs ++ extra))⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word b.control) (b.regs ++ extra'))
have hw : returned cont k (walked a.control) = word b.control := congrArg RhRegCfg.stack hnextjumpa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5P:ℕhP:List.length (walked a.control) + 3 ≤ Phs:Control.step a = some bextra:List ℕcont:Boolk:ℕhe:effect a.control = Effect.jump cont khj:rawInstr a.control = RhInstr.jump (returned cont k (walked a.control))hnext:{ stack := returned cont k (walked a.control), regs := a.regs } = { stack := word b.control, regs := b.regs }n:ℕhn:n ≥ 1ht:nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P (returned cont k (walked a.control)) (a.regs ++ extra))hw:returned cont k (walked a.control) = word b.control⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word b.control) (b.regs ++ extra'))
have hr : a.regs = b.regs := congrArg RhRegCfg.regs hnextjumpa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5P:ℕhP:List.length (walked a.control) + 3 ≤ Phs:Control.step a = some bextra:List ℕcont:Boolk:ℕhe:effect a.control = Effect.jump cont khj:rawInstr a.control = RhInstr.jump (returned cont k (walked a.control))hnext:{ stack := returned cont k (walked a.control), regs := a.regs } = { stack := word b.control, regs := b.regs }n:ℕhn:n ≥ 1ht:nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P (returned cont k (walked a.control)) (a.regs ++ extra))hw:returned cont k (walked a.control) = word b.controlhr:a.regs = b.regs⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word b.control) (b.regs ++ extra'))
refine ⟨P,le_rfl,n,hn,extra,?_⟩jumpa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5P:ℕhP:List.length (walked a.control) + 3 ≤ Phs:Control.step a = some bextra:List ℕcont:Boolk:ℕhe:effect a.control = Effect.jump cont khj:rawInstr a.control = RhInstr.jump (returned cont k (walked a.control))hnext:{ stack := returned cont k (walked a.control), regs := a.regs } = { stack := word b.control, regs := b.regs }n:ℕhn:n ≥ 1ht:nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P (returned cont k (walked a.control)) (a.regs ++ extra))hw:returned cont k (walked a.control) = word b.controlhr:a.regs = b.regs⊢ nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P (word b.control) (b.regs ++ extra))
rw [←hw,jumpa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5P:ℕhP:List.length (walked a.control) + 3 ≤ Phs:Control.step a = some bextra:List ℕcont:Boolk:ℕhe:effect a.control = Effect.jump cont khj:rawInstr a.control = RhInstr.jump (returned cont k (walked a.control))hnext:{ stack := returned cont k (walked a.control), regs := a.regs } = { stack := word b.control, regs := b.regs }n:ℕhn:n ≥ 1ht:nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P (returned cont k (walked a.control)) (a.regs ++ extra))hw:returned cont k (walked a.control) = word b.controlhr:a.regs = b.regs⊢ nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P (returned cont k (walked a.control)) (b.regs ++ extra))←hrjumpa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5P:ℕhP:List.length (walked a.control) + 3 ≤ Phs:Control.step a = some bextra:List ℕcont:Boolk:ℕhe:effect a.control = Effect.jump cont khj:rawInstr a.control = RhInstr.jump (returned cont k (walked a.control))hnext:{ stack := returned cont k (walked a.control), regs := a.regs } = { stack := word b.control, regs := b.regs }n:ℕhn:n ≥ 1ht:nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P (returned cont k (walked a.control)) (a.regs ++ extra))hw:returned cont k (walked a.control) = word b.controlhr:a.regs = b.regs⊢ nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P (returned cont k (walked a.control)) (a.regs ++ extra))]jumpa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5P:ℕhP:List.length (walked a.control) + 3 ≤ Phs:Control.step a = some bextra:List ℕcont:Boolk:ℕhe:effect a.control = Effect.jump cont khj:rawInstr a.control = RhInstr.jump (returned cont k (walked a.control))hnext:{ stack := returned cont k (walked a.control), regs := a.regs } = { stack := word b.control, regs := b.regs }n:ℕhn:n ≥ 1ht:nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P (returned cont k (walked a.control)) (a.regs ++ extra))hw:returned cont k (walked a.control) = word b.controlhr:a.regs = b.regs⊢ nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P (returned cont k (walked a.control)) (a.regs ++ extra))
exact htAll goals completed! 🐙end ConjectureMachines.Riemann95.Traceend
Lifting traces
sectionnamespace ConjectureMachines.Riemann95.Traceopen Riemann120.Layer2 Schema Controltheorem bounded_trace_regs_length {B : Nat} {a b : Control.Cfg}
(ht : Relation.TransGen (BoundedEdge B) a b) (hlen : a.regs.length = 5) :
b.regs.length = 5 := byB:ℕa:Control.Cfgb:Control.Cfght:Relation.TransGen (BoundedEdge B) a bhlen:a.regs.length = 5⊢ b.regs.length = 5
induction ht with
| single he =>singleB:ℕa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5b✝:Control.Cfghe:BoundedEdge B a b✝⊢ b✝.regs.length = 5 exact (step_regs_length _ _ he.1).trans hlenAll goals completed! 🐙
| tail ht he ih =>tailB:ℕa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5b✝:Control.Cfgc✝:Control.Cfght:Relation.TransGen (BoundedEdge B) a b✝he:BoundedEdge B b✝ c✝ih:b✝.regs.length = 5⊢ c✝.regs.length = 5 exact (step_regs_length _ _ he.1).trans ihAll goals completed! 🐙theorem bounded_rtrace_regs_length {B : Nat} {a b : Control.Cfg}
(ht : Relation.ReflTransGen (BoundedEdge B) a b) (hlen : a.regs.length = 5) :
b.regs.length = 5 := byB:ℕa:Control.Cfgb:Control.Cfght:Relation.ReflTransGen (BoundedEdge B) a bhlen:a.regs.length = 5⊢ b.regs.length = 5
induction ht with
| refl =>reflB:ℕa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5⊢ a.regs.length = 5 exact hlenAll goals completed! 🐙
| tail ht he ih =>tailB:ℕa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5b✝:Control.Cfgc✝:Control.Cfght:Relation.ReflTransGen (BoundedEdge B) a b✝he:BoundedEdge B b✝ c✝ih:b✝.regs.length = 5⊢ c✝.regs.length = 5 exact (step_regs_length _ _ he.1).trans ihAll goals completed! 🐙theorem bounded_trace_lift (B P : Nat) (hP : B ≤ P) (a b : Control.Cfg)
(hlen : a.regs.length = 5) (ht : Relation.TransGen (BoundedEdge B) a b)
(extra : List Nat) :
∃ P' ≥ P, ∃ n ≥ 1, ∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word b.control) (b.regs ++ extra')) := byB:ℕP:ℕhP:B ≤ Pa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5ht:Relation.TransGen (BoundedEdge B) a bextra:List ℕ⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word b.control) (b.regs ++ extra'))
induction ht generalizing P extra with
| single he =>singleB:ℕa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5b✝:Control.Cfghe:BoundedEdge B a b✝P:ℕhP:B ≤ Pextra:List ℕ⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word b✝.control) (b✝.regs ++ extra')) exact physical_step a _ hlen P (le_trans he.2 hP) he.1 extraAll goals completed! 🐙
| @tail c d ht he ih =>tailB:ℕa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5c:Control.Cfgd:Control.Cfght:Relation.TransGen (BoundedEdge B) a che:BoundedEdge B c dih:∀ (P : ℕ),
B ≤ P →
∀ (extra : List ℕ),
∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word c.control) (c.regs ++ extra'))P:ℕhP:B ≤ Pextra:List ℕ⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word d.control) (d.regs ++ extra'))
obtain ⟨Q,hQ,n,hn,tail,hrun⟩ := ih P hP extratailB:ℕa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5c:Control.Cfgd:Control.Cfght:Relation.TransGen (BoundedEdge B) a che:BoundedEdge B c dih:∀ (P : ℕ),
B ≤ P →
∀ (extra : List ℕ),
∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word c.control) (c.regs ++ extra'))P:ℕhP:B ≤ Pextra:List ℕQ:ℕhQ:Q ≥ Pn:ℕhn:n ≥ 1tail:List ℕhrun:nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg Q (word c.control) (c.regs ++ tail))⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word d.control) (d.regs ++ extra'))
have hc : c.regs.length = 5 := bounded_trace_regs_length ht hlentailB:ℕa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5c:Control.Cfgd:Control.Cfght:Relation.TransGen (BoundedEdge B) a che:BoundedEdge B c dih:∀ (P : ℕ),
B ≤ P →
∀ (extra : List ℕ),
∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word c.control) (c.regs ++ extra'))P:ℕhP:B ≤ Pextra:List ℕQ:ℕhQ:Q ≥ Pn:ℕhn:n ≥ 1tail:List ℕhrun:nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg Q (word c.control) (c.regs ++ tail))hc:c.regs.length = 5⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word d.control) (d.regs ++ extra'))
obtain ⟨Q',hQ',s,hs,tail',hnext⟩ :=
physical_step c d hc Q (le_trans he.2 (le_trans hP hQ)) he.1 tailtailB:ℕa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5c:Control.Cfgd:Control.Cfght:Relation.TransGen (BoundedEdge B) a che:BoundedEdge B c dih:∀ (P : ℕ),
B ≤ P →
∀ (extra : List ℕ),
∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word c.control) (c.regs ++ extra'))P:ℕhP:B ≤ Pextra:List ℕQ:ℕhQ:Q ≥ Pn:ℕhn:n ≥ 1tail:List ℕhrun:nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg Q (word c.control) (c.regs ++ tail))hc:c.regs.length = 5Q':ℕhQ':Q' ≥ Qs:ℕhs:s ≥ 1tail':List ℕhnext:nSteps s (Physical.rootCfg Q (word c.control) (c.regs ++ tail)) =
some (Physical.rootCfg Q' (word d.control) (d.regs ++ tail'))⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word d.control) (d.regs ++ extra'))
refine ⟨Q',le_trans hQ hQ',n+s,byB:ℕa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5c:Control.Cfgd:Control.Cfght:Relation.TransGen (BoundedEdge B) a che:BoundedEdge B c dih:∀ (P : ℕ),
B ≤ P →
∀ (extra : List ℕ),
∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word c.control) (c.regs ++ extra'))P:ℕhP:B ≤ Pextra:List ℕQ:ℕhQ:Q ≥ Pn:ℕhn:n ≥ 1tail:List ℕhrun:nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg Q (word c.control) (c.regs ++ tail))hc:c.regs.length = 5Q':ℕhQ':Q' ≥ Qs:ℕhs:s ≥ 1tail':List ℕhnext:nSteps s (Physical.rootCfg Q (word c.control) (c.regs ++ tail)) =
some (Physical.rootCfg Q' (word d.control) (d.regs ++ tail'))⊢ n + s ≥ 1 omegaAll goals completed! 🐙,tail',?_⟩
rw [Dispatch.nSteps_composition,tailB:ℕa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5c:Control.Cfgd:Control.Cfght:Relation.TransGen (BoundedEdge B) a che:BoundedEdge B c dih:∀ (P : ℕ),
B ≤ P →
∀ (extra : List ℕ),
∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word c.control) (c.regs ++ extra'))P:ℕhP:B ≤ Pextra:List ℕQ:ℕhQ:Q ≥ Pn:ℕhn:n ≥ 1tail:List ℕhrun:nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg Q (word c.control) (c.regs ++ tail))hc:c.regs.length = 5Q':ℕhQ':Q' ≥ Qs:ℕhs:s ≥ 1tail':List ℕhnext:nSteps s (Physical.rootCfg Q (word c.control) (c.regs ++ tail)) =
some (Physical.rootCfg Q' (word d.control) (d.regs ++ tail'))⊢ (nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra))).bind (nSteps s) =
some (Physical.rootCfg Q' (word d.control) (d.regs ++ tail'))hruntailB:ℕa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5c:Control.Cfgd:Control.Cfght:Relation.TransGen (BoundedEdge B) a che:BoundedEdge B c dih:∀ (P : ℕ),
B ≤ P →
∀ (extra : List ℕ),
∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word c.control) (c.regs ++ extra'))P:ℕhP:B ≤ Pextra:List ℕQ:ℕhQ:Q ≥ Pn:ℕhn:n ≥ 1tail:List ℕhrun:nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg Q (word c.control) (c.regs ++ tail))hc:c.regs.length = 5Q':ℕhQ':Q' ≥ Qs:ℕhs:s ≥ 1tail':List ℕhnext:nSteps s (Physical.rootCfg Q (word c.control) (c.regs ++ tail)) =
some (Physical.rootCfg Q' (word d.control) (d.regs ++ tail'))⊢ (some (Physical.rootCfg Q (word c.control) (c.regs ++ tail))).bind (nSteps s) =
some (Physical.rootCfg Q' (word d.control) (d.regs ++ tail'))]tailB:ℕa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5c:Control.Cfgd:Control.Cfght:Relation.TransGen (BoundedEdge B) a che:BoundedEdge B c dih:∀ (P : ℕ),
B ≤ P →
∀ (extra : List ℕ),
∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word c.control) (c.regs ++ extra'))P:ℕhP:B ≤ Pextra:List ℕQ:ℕhQ:Q ≥ Pn:ℕhn:n ≥ 1tail:List ℕhrun:nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg Q (word c.control) (c.regs ++ tail))hc:c.regs.length = 5Q':ℕhQ':Q' ≥ Qs:ℕhs:s ≥ 1tail':List ℕhnext:nSteps s (Physical.rootCfg Q (word c.control) (c.regs ++ tail)) =
some (Physical.rootCfg Q' (word d.control) (d.regs ++ tail'))⊢ (some (Physical.rootCfg Q (word c.control) (c.regs ++ tail))).bind (nSteps s) =
some (Physical.rootCfg Q' (word d.control) (d.regs ++ tail'))
exact hnextAll goals completed! 🐙theorem bounded_rtrace_lift (B P : Nat) (hP : B ≤ P) (a b : Control.Cfg)
(hlen : a.regs.length = 5) (ht : Relation.ReflTransGen (BoundedEdge B) a b)
(extra : List Nat) :
∃ P' ≥ P, ∃ n : Nat, ∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word b.control) (b.regs ++ extra')) := byB:ℕP:ℕhP:B ≤ Pa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5ht:Relation.ReflTransGen (BoundedEdge B) a bextra:List ℕ⊢ ∃ P' ≥ P,
∃ n extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word b.control) (b.regs ++ extra'))
obtain heq | ht := Relation.reflTransGen_iff_eq_or_transGen.mp htinlB:ℕP:ℕhP:B ≤ Pa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5ht:Relation.ReflTransGen (BoundedEdge B) a bextra:List ℕheq:b = a⊢ ∃ P' ≥ P,
∃ n extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word b.control) (b.regs ++ extra'))inrB:ℕP:ℕhP:B ≤ Pa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5ht✝:Relation.ReflTransGen (BoundedEdge B) a bextra:List ℕht:Relation.TransGen (BoundedEdge B) a b⊢ ∃ P' ≥ P,
∃ n extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word b.control) (b.regs ++ extra'))
·inlB:ℕP:ℕhP:B ≤ Pa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5ht:Relation.ReflTransGen (BoundedEdge B) a bextra:List ℕheq:b = a⊢ ∃ P' ≥ P,
∃ n extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word b.control) (b.regs ++ extra')) subst binlB:ℕP:ℕhP:B ≤ Pa:Control.Cfghlen:a.regs.length = 5extra:List ℕht:Relation.ReflTransGen (BoundedEdge B) a a⊢ ∃ P' ≥ P,
∃ n extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word a.control) (a.regs ++ extra'))
exact ⟨P,le_rfl,0,extra,rfl⟩All goals completed! 🐙
·inrB:ℕP:ℕhP:B ≤ Pa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5ht✝:Relation.ReflTransGen (BoundedEdge B) a bextra:List ℕht:Relation.TransGen (BoundedEdge B) a b⊢ ∃ P' ≥ P,
∃ n extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word b.control) (b.regs ++ extra')) obtain ⟨P',hP',n,_,extra',hrun⟩ := bounded_trace_lift B P hP a b hlen ht extrainrB:ℕP:ℕhP:B ≤ Pa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5ht✝:Relation.ReflTransGen (BoundedEdge B) a bextra:List ℕht:Relation.TransGen (BoundedEdge B) a bP':ℕhP':P' ≥ Pn:ℕleft✝:n ≥ 1extra':List ℕhrun:nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word b.control) (b.regs ++ extra'))⊢ ∃ P' ≥ P,
∃ n extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word b.control) (b.regs ++ extra'))
exact ⟨P',hP',n,extra',hrun⟩All goals completed! 🐙theorem strict_exit_lift (B P : Nat) (hP : B ≤ P) (a b : Control.Cfg)
(hlen : a.regs.length = 5) (hb : word b.control = [])
(ht : StrictExitTrace B a b) (extra : List Nat) :
∃ P' ≥ P+1, ∃ n ≥ 1, ∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word b.control) (b.regs ++ extra')) := byB:ℕP:ℕhP:B ≤ Pa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5hb:word b.control = []ht:StrictExitTrace B a bextra:List ℕ⊢ ∃ P' ≥ P + 1,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word b.control) (b.regs ++ extra'))
obtain ⟨mid,hprefix,hedge,heffect,_,_⟩ := htB:ℕP:ℕhP:B ≤ Pa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5hb:word b.control = []extra:List ℕmid:Control.Cfghprefix:Relation.ReflTransGen (BoundedEdge B) a midhedge:BoundedEdge B mid bheffect:effect mid.control = Effect.decnz 2left✝:mid.regs.getD 2 0 = 0right✝:mid.regs = b.regs⊢ ∃ P' ≥ P + 1,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word b.control) (b.regs ++ extra'))
have hmidlen : mid.regs.length = 5 := bounded_rtrace_regs_length hprefix hlenB:ℕP:ℕhP:B ≤ Pa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5hb:word b.control = []extra:List ℕmid:Control.Cfghprefix:Relation.ReflTransGen (BoundedEdge B) a midhedge:BoundedEdge B mid bheffect:effect mid.control = Effect.decnz 2left✝:mid.regs.getD 2 0 = 0right✝:mid.regs = b.regshmidlen:mid.regs.length = 5⊢ ∃ P' ≥ P + 1,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word b.control) (b.regs ++ extra'))
obtain ⟨Q,hQ,n,tail,hrun⟩ := bounded_rtrace_lift B P hP a mid hlen hprefix extraB:ℕP:ℕhP:B ≤ Pa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5hb:word b.control = []extra:List ℕmid:Control.Cfghprefix:Relation.ReflTransGen (BoundedEdge B) a midhedge:BoundedEdge B mid bheffect:effect mid.control = Effect.decnz 2left✝:mid.regs.getD 2 0 = 0right✝:mid.regs = b.regshmidlen:mid.regs.length = 5Q:ℕhQ:Q ≥ Pn:ℕtail:List ℕhrun:nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg Q (word mid.control) (mid.regs ++ tail))⊢ ∃ P' ≥ P + 1,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word b.control) (b.regs ++ extra'))
have hnext : applyInstr (rawInstr mid.control) mid.regs = some ⟨word b.control,b.regs⟩ := by
rw [← step_encode,B:ℕP:ℕhP:B ≤ Pa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5hb:word b.control = []extra:List ℕmid:Control.Cfghprefix:Relation.ReflTransGen (BoundedEdge B) a midhedge:BoundedEdge B mid bheffect:effect mid.control = Effect.decnz 2left✝:mid.regs.getD 2 0 = 0right✝:mid.regs = b.regshmidlen:mid.regs.length = 5Q:ℕhQ:Q ≥ Pn:ℕtail:List ℕhrun:nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg Q (word mid.control) (mid.regs ++ tail))⊢ Option.map encodeCfg (Control.step mid) = some { stack := word b.control, regs := b.regs }hedge.1B:ℕP:ℕhP:B ≤ Pa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5hb:word b.control = []extra:List ℕmid:Control.Cfghprefix:Relation.ReflTransGen (BoundedEdge B) a midhedge:BoundedEdge B mid bheffect:effect mid.control = Effect.decnz 2left✝:mid.regs.getD 2 0 = 0right✝:mid.regs = b.regshmidlen:mid.regs.length = 5Q:ℕhQ:Q ≥ Pn:ℕtail:List ℕhrun:nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg Q (word mid.control) (mid.regs ++ tail))⊢ Option.map encodeCfg (some b) = some { stack := word b.control, regs := b.regs }]B:ℕP:ℕhP:B ≤ Pa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5hb:word b.control = []extra:List ℕmid:Control.Cfghprefix:Relation.ReflTransGen (BoundedEdge B) a midhedge:BoundedEdge B mid bheffect:effect mid.control = Effect.decnz 2left✝:mid.regs.getD 2 0 = 0right✝:mid.regs = b.regshmidlen:mid.regs.length = 5Q:ℕhQ:Q ≥ Pn:ℕtail:List ℕhrun:nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg Q (word mid.control) (mid.regs ++ tail))⊢ Option.map encodeCfg (some b) = some { stack := word b.control, regs := b.regs }
rflB:ℕP:ℕhP:B ≤ Pa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5hb:word b.control = []extra:List ℕmid:Control.Cfghprefix:Relation.ReflTransGen (BoundedEdge B) a midhedge:BoundedEdge B mid bheffect:effect mid.control = Effect.decnz 2left✝:mid.regs.getD 2 0 = 0right✝:mid.regs = b.regshmidlen:mid.regs.length = 5Q:ℕhQ:Q ≥ Pn:ℕtail:List ℕhrun:nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg Q (word mid.control) (mid.regs ++ tail))hnext:applyInstr (rawInstr mid.control) mid.regs = some { stack := word b.control, regs := b.regs }⊢ ∃ P' ≥ P + 1,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word b.control) (b.regs ++ extra'))
obtain ⟨Q',_,s,hs,tail',hfinal,hgrow⟩ :=
physical_arithmetic_step mid.control mid.regs tail hmidlen Q
(le_trans hedge.2 (le_trans hP hQ)) _ hnext 2 false heffectB:ℕP:ℕhP:B ≤ Pa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5hb:word b.control = []extra:List ℕmid:Control.Cfghprefix:Relation.ReflTransGen (BoundedEdge B) a midhedge:BoundedEdge B mid bheffect:effect mid.control = Effect.decnz 2left✝¹:mid.regs.getD 2 0 = 0right✝:mid.regs = b.regshmidlen:mid.regs.length = 5Q:ℕhQ:Q ≥ Pn:ℕtail:List ℕhrun:nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg Q (word mid.control) (mid.regs ++ tail))hnext:applyInstr (rawInstr mid.control) mid.regs = some { stack := word b.control, regs := b.regs }Q':ℕleft✝:Q' ≥ Qs:ℕhs:s ≥ 1tail':List ℕhfinal:nSteps s (Physical.rootCfg Q (word mid.control) (mid.regs ++ tail)) =
some
(Physical.rootCfg Q' { stack := word b.control, regs := b.regs }.stack
({ stack := word b.control, regs := b.regs }.regs ++ tail'))hgrow:{ stack := word b.control, regs := b.regs }.stack = [] → Q + 1 ≤ Q'⊢ ∃ P' ≥ P + 1,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word b.control) (b.regs ++ extra'))
have hstrict := hgrow hbB:ℕP:ℕhP:B ≤ Pa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5hb:word b.control = []extra:List ℕmid:Control.Cfghprefix:Relation.ReflTransGen (BoundedEdge B) a midhedge:BoundedEdge B mid bheffect:effect mid.control = Effect.decnz 2left✝¹:mid.regs.getD 2 0 = 0right✝:mid.regs = b.regshmidlen:mid.regs.length = 5Q:ℕhQ:Q ≥ Pn:ℕtail:List ℕhrun:nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg Q (word mid.control) (mid.regs ++ tail))hnext:applyInstr (rawInstr mid.control) mid.regs = some { stack := word b.control, regs := b.regs }Q':ℕleft✝:Q' ≥ Qs:ℕhs:s ≥ 1tail':List ℕhfinal:nSteps s (Physical.rootCfg Q (word mid.control) (mid.regs ++ tail)) =
some
(Physical.rootCfg Q' { stack := word b.control, regs := b.regs }.stack
({ stack := word b.control, regs := b.regs }.regs ++ tail'))hgrow:{ stack := word b.control, regs := b.regs }.stack = [] → Q + 1 ≤ Q'hstrict:Q + 1 ≤ Q'⊢ ∃ P' ≥ P + 1,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg P' (word b.control) (b.regs ++ extra'))
refine ⟨Q',byB:ℕP:ℕhP:B ≤ Pa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5hb:word b.control = []extra:List ℕmid:Control.Cfghprefix:Relation.ReflTransGen (BoundedEdge B) a midhedge:BoundedEdge B mid bheffect:effect mid.control = Effect.decnz 2left✝¹:mid.regs.getD 2 0 = 0right✝:mid.regs = b.regshmidlen:mid.regs.length = 5Q:ℕhQ:Q ≥ Pn:ℕtail:List ℕhrun:nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg Q (word mid.control) (mid.regs ++ tail))hnext:applyInstr (rawInstr mid.control) mid.regs = some { stack := word b.control, regs := b.regs }Q':ℕleft✝:Q' ≥ Qs:ℕhs:s ≥ 1tail':List ℕhfinal:nSteps s (Physical.rootCfg Q (word mid.control) (mid.regs ++ tail)) =
some
(Physical.rootCfg Q' { stack := word b.control, regs := b.regs }.stack
({ stack := word b.control, regs := b.regs }.regs ++ tail'))hgrow:{ stack := word b.control, regs := b.regs }.stack = [] → Q + 1 ≤ Q'hstrict:Q + 1 ≤ Q'⊢ Q' ≥ P + 1 omegaAll goals completed! 🐙,n+s,byB:ℕP:ℕhP:B ≤ Pa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5hb:word b.control = []extra:List ℕmid:Control.Cfghprefix:Relation.ReflTransGen (BoundedEdge B) a midhedge:BoundedEdge B mid bheffect:effect mid.control = Effect.decnz 2left✝¹:mid.regs.getD 2 0 = 0right✝:mid.regs = b.regshmidlen:mid.regs.length = 5Q:ℕhQ:Q ≥ Pn:ℕtail:List ℕhrun:nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg Q (word mid.control) (mid.regs ++ tail))hnext:applyInstr (rawInstr mid.control) mid.regs = some { stack := word b.control, regs := b.regs }Q':ℕleft✝:Q' ≥ Qs:ℕhs:s ≥ 1tail':List ℕhfinal:nSteps s (Physical.rootCfg Q (word mid.control) (mid.regs ++ tail)) =
some
(Physical.rootCfg Q' { stack := word b.control, regs := b.regs }.stack
({ stack := word b.control, regs := b.regs }.regs ++ tail'))hgrow:{ stack := word b.control, regs := b.regs }.stack = [] → Q + 1 ≤ Q'hstrict:Q + 1 ≤ Q'⊢ n + s ≥ 1 omegaAll goals completed! 🐙,tail',?_⟩
rw [Dispatch.nSteps_composition,B:ℕP:ℕhP:B ≤ Pa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5hb:word b.control = []extra:List ℕmid:Control.Cfghprefix:Relation.ReflTransGen (BoundedEdge B) a midhedge:BoundedEdge B mid bheffect:effect mid.control = Effect.decnz 2left✝¹:mid.regs.getD 2 0 = 0right✝:mid.regs = b.regshmidlen:mid.regs.length = 5Q:ℕhQ:Q ≥ Pn:ℕtail:List ℕhrun:nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg Q (word mid.control) (mid.regs ++ tail))hnext:applyInstr (rawInstr mid.control) mid.regs = some { stack := word b.control, regs := b.regs }Q':ℕleft✝:Q' ≥ Qs:ℕhs:s ≥ 1tail':List ℕhfinal:nSteps s (Physical.rootCfg Q (word mid.control) (mid.regs ++ tail)) =
some
(Physical.rootCfg Q' { stack := word b.control, regs := b.regs }.stack
({ stack := word b.control, regs := b.regs }.regs ++ tail'))hgrow:{ stack := word b.control, regs := b.regs }.stack = [] → Q + 1 ≤ Q'hstrict:Q + 1 ≤ Q'⊢ (nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra))).bind (nSteps s) =
some (Physical.rootCfg Q' (word b.control) (b.regs ++ tail'))hrunB:ℕP:ℕhP:B ≤ Pa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5hb:word b.control = []extra:List ℕmid:Control.Cfghprefix:Relation.ReflTransGen (BoundedEdge B) a midhedge:BoundedEdge B mid bheffect:effect mid.control = Effect.decnz 2left✝¹:mid.regs.getD 2 0 = 0right✝:mid.regs = b.regshmidlen:mid.regs.length = 5Q:ℕhQ:Q ≥ Pn:ℕtail:List ℕhrun:nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg Q (word mid.control) (mid.regs ++ tail))hnext:applyInstr (rawInstr mid.control) mid.regs = some { stack := word b.control, regs := b.regs }Q':ℕleft✝:Q' ≥ Qs:ℕhs:s ≥ 1tail':List ℕhfinal:nSteps s (Physical.rootCfg Q (word mid.control) (mid.regs ++ tail)) =
some
(Physical.rootCfg Q' { stack := word b.control, regs := b.regs }.stack
({ stack := word b.control, regs := b.regs }.regs ++ tail'))hgrow:{ stack := word b.control, regs := b.regs }.stack = [] → Q + 1 ≤ Q'hstrict:Q + 1 ≤ Q'⊢ (some (Physical.rootCfg Q (word mid.control) (mid.regs ++ tail))).bind (nSteps s) =
some (Physical.rootCfg Q' (word b.control) (b.regs ++ tail'))]B:ℕP:ℕhP:B ≤ Pa:Control.Cfgb:Control.Cfghlen:a.regs.length = 5hb:word b.control = []extra:List ℕmid:Control.Cfghprefix:Relation.ReflTransGen (BoundedEdge B) a midhedge:BoundedEdge B mid bheffect:effect mid.control = Effect.decnz 2left✝¹:mid.regs.getD 2 0 = 0right✝:mid.regs = b.regshmidlen:mid.regs.length = 5Q:ℕhQ:Q ≥ Pn:ℕtail:List ℕhrun:nSteps n (Physical.rootCfg P (word a.control) (a.regs ++ extra)) =
some (Physical.rootCfg Q (word mid.control) (mid.regs ++ tail))hnext:applyInstr (rawInstr mid.control) mid.regs = some { stack := word b.control, regs := b.regs }Q':ℕleft✝:Q' ≥ Qs:ℕhs:s ≥ 1tail':List ℕhfinal:nSteps s (Physical.rootCfg Q (word mid.control) (mid.regs ++ tail)) =
some
(Physical.rootCfg Q' { stack := word b.control, regs := b.regs }.stack
({ stack := word b.control, regs := b.regs }.regs ++ tail'))hgrow:{ stack := word b.control, regs := b.regs }.stack = [] → Q + 1 ≤ Q'hstrict:Q + 1 ≤ Q'⊢ (some (Physical.rootCfg Q (word mid.control) (mid.regs ++ tail))).bind (nSteps s) =
some (Physical.rootCfg Q' (word b.control) (b.regs ++ tail'))
exact hfinalAll goals completed! 🐙end ConjectureMachines.Riemann95.Traceend
Width execution
sectionnamespace ConjectureMachines.Riemann95.Traceopen Riemann120.Layer2 Schema Controltheorem physical_precredit_width (P x j f : Nat) (extra : List Nat)
(hP : widthBudget j ≤ P) :
∃ P' ≥ P, ∃ n ≥ 1, ∃ extra',
nSteps n (Physical.rootCfg P [1,1,1,1] ([0,0,f,x,j] ++ extra)) =
some (Physical.rootCfg P'
(if Algorithm.residual j f = 0 then [] else word (.outside finalHaltId))
([0,0,Algorithm.residual j f-1,x+j,0] ++ extra')) := byP:ℕx:ℕj:ℕf:ℕextra:List ℕhP:widthBudget j ≤ P⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P [1, 1, 1, 1] ([0, 0, f, x, j] ++ extra)) =
some
(Physical.rootCfg P' (if Algorithm.residual j f = 0 then [] else word (ControlWord.outside finalHaltId))
([0, 0, Algorithm.residual j f - 1, x + j, 0] ++ extra'))
have h := bounded_trace_lift (widthBudget j) P hP _ _ (byP:ℕx:ℕj:ℕf:ℕextra:List ℕhP:widthBudget j ≤ P⊢ { control := ControlWord.outside widthCallId, regs := [0, 0, f, x, j] }.regs.length = 5 rflAll goals completed! 🐙)
(bounded_precredit_width x j f) extraP:ℕx:ℕj:ℕf:ℕextra:List ℕhP:widthBudget j ≤ Ph:∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n
(Physical.rootCfg P (word { control := ControlWord.outside widthCallId, regs := [0, 0, f, x, j] }.control)
({ control := ControlWord.outside widthCallId, regs := [0, 0, f, x, j] }.regs ++ extra)) =
some
(Physical.rootCfg P'
(word
{
control :=
if Algorithm.residual j f = 0 then ControlWord.outside 0 else ControlWord.outside finalHaltId,
regs := [0, 0, Algorithm.residual j f - 1, x + j, 0] }.control)
({ control := if Algorithm.residual j f = 0 then ControlWord.outside 0 else ControlWord.outside finalHaltId,
regs := [0, 0, Algorithm.residual j f - 1, x + j, 0] }.regs ++
extra'))⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P [1, 1, 1, 1] ([0, 0, f, x, j] ++ extra)) =
some
(Physical.rootCfg P' (if Algorithm.residual j f = 0 then [] else word (ControlWord.outside finalHaltId))
([0, 0, Algorithm.residual j f - 1, x + j, 0] ++ extra'))
rw [widthCall_wordP:ℕx:ℕj:ℕf:ℕextra:List ℕhP:widthBudget j ≤ Ph:∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n
(Physical.rootCfg P [1, 1, 1, 1]
({ control := ControlWord.outside widthCallId, regs := [0, 0, f, x, j] }.regs ++ extra)) =
some
(Physical.rootCfg P'
(word
{
control :=
if Algorithm.residual j f = 0 then ControlWord.outside 0 else ControlWord.outside finalHaltId,
regs := [0, 0, Algorithm.residual j f - 1, x + j, 0] }.control)
({ control := if Algorithm.residual j f = 0 then ControlWord.outside 0 else ControlWord.outside finalHaltId,
regs := [0, 0, Algorithm.residual j f - 1, x + j, 0] }.regs ++
extra'))⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P [1, 1, 1, 1] ([0, 0, f, x, j] ++ extra)) =
some
(Physical.rootCfg P' (if Algorithm.residual j f = 0 then [] else word (ControlWord.outside finalHaltId))
([0, 0, Algorithm.residual j f - 1, x + j, 0] ++ extra'))] at hP:ℕx:ℕj:ℕf:ℕextra:List ℕhP:widthBudget j ≤ Ph:∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n
(Physical.rootCfg P [1, 1, 1, 1]
({ control := ControlWord.outside widthCallId, regs := [0, 0, f, x, j] }.regs ++ extra)) =
some
(Physical.rootCfg P'
(word
{
control :=
if Algorithm.residual j f = 0 then ControlWord.outside 0 else ControlWord.outside finalHaltId,
regs := [0, 0, Algorithm.residual j f - 1, x + j, 0] }.control)
({ control := if Algorithm.residual j f = 0 then ControlWord.outside 0 else ControlWord.outside finalHaltId,
regs := [0, 0, Algorithm.residual j f - 1, x + j, 0] }.regs ++
extra'))⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P [1, 1, 1, 1] ([0, 0, f, x, j] ++ extra)) =
some
(Physical.rootCfg P' (if Algorithm.residual j f = 0 then [] else word (ControlWord.outside finalHaltId))
([0, 0, Algorithm.residual j f - 1, x + j, 0] ++ extra'))
by_cases hz : Algorithm.residual j f = 0posP:ℕx:ℕj:ℕf:ℕextra:List ℕhP:widthBudget j ≤ Ph:∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n
(Physical.rootCfg P [1, 1, 1, 1]
({ control := ControlWord.outside widthCallId, regs := [0, 0, f, x, j] }.regs ++ extra)) =
some
(Physical.rootCfg P'
(word
{
control :=
if Algorithm.residual j f = 0 then ControlWord.outside 0 else ControlWord.outside finalHaltId,
regs := [0, 0, Algorithm.residual j f - 1, x + j, 0] }.control)
({ control := if Algorithm.residual j f = 0 then ControlWord.outside 0 else ControlWord.outside finalHaltId,
regs := [0, 0, Algorithm.residual j f - 1, x + j, 0] }.regs ++
extra'))hz:Algorithm.residual j f = 0⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P [1, 1, 1, 1] ([0, 0, f, x, j] ++ extra)) =
some
(Physical.rootCfg P' (if Algorithm.residual j f = 0 then [] else word (ControlWord.outside finalHaltId))
([0, 0, Algorithm.residual j f - 1, x + j, 0] ++ extra'))negP:ℕx:ℕj:ℕf:ℕextra:List ℕhP:widthBudget j ≤ Ph:∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n
(Physical.rootCfg P [1, 1, 1, 1]
({ control := ControlWord.outside widthCallId, regs := [0, 0, f, x, j] }.regs ++ extra)) =
some
(Physical.rootCfg P'
(word
{
control :=
if Algorithm.residual j f = 0 then ControlWord.outside 0 else ControlWord.outside finalHaltId,
regs := [0, 0, Algorithm.residual j f - 1, x + j, 0] }.control)
({ control := if Algorithm.residual j f = 0 then ControlWord.outside 0 else ControlWord.outside finalHaltId,
regs := [0, 0, Algorithm.residual j f - 1, x + j, 0] }.regs ++
extra'))hz:¬Algorithm.residual j f = 0⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P [1, 1, 1, 1] ([0, 0, f, x, j] ++ extra)) =
some
(Physical.rootCfg P' (if Algorithm.residual j f = 0 then [] else word (ControlWord.outside finalHaltId))
([0, 0, Algorithm.residual j f - 1, x + j, 0] ++ extra'))
·posP:ℕx:ℕj:ℕf:ℕextra:List ℕhP:widthBudget j ≤ Ph:∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n
(Physical.rootCfg P [1, 1, 1, 1]
({ control := ControlWord.outside widthCallId, regs := [0, 0, f, x, j] }.regs ++ extra)) =
some
(Physical.rootCfg P'
(word
{
control :=
if Algorithm.residual j f = 0 then ControlWord.outside 0 else ControlWord.outside finalHaltId,
regs := [0, 0, Algorithm.residual j f - 1, x + j, 0] }.control)
({ control := if Algorithm.residual j f = 0 then ControlWord.outside 0 else ControlWord.outside finalHaltId,
regs := [0, 0, Algorithm.residual j f - 1, x + j, 0] }.regs ++
extra'))hz:Algorithm.residual j f = 0⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P [1, 1, 1, 1] ([0, 0, f, x, j] ++ extra)) =
some
(Physical.rootCfg P' (if Algorithm.residual j f = 0 then [] else word (ControlWord.outside finalHaltId))
([0, 0, Algorithm.residual j f - 1, x + j, 0] ++ extra')) simpa only [hz,ite_true,initial_word] using hAll goals completed! 🐙
·negP:ℕx:ℕj:ℕf:ℕextra:List ℕhP:widthBudget j ≤ Ph:∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n
(Physical.rootCfg P [1, 1, 1, 1]
({ control := ControlWord.outside widthCallId, regs := [0, 0, f, x, j] }.regs ++ extra)) =
some
(Physical.rootCfg P'
(word
{
control :=
if Algorithm.residual j f = 0 then ControlWord.outside 0 else ControlWord.outside finalHaltId,
regs := [0, 0, Algorithm.residual j f - 1, x + j, 0] }.control)
({ control := if Algorithm.residual j f = 0 then ControlWord.outside 0 else ControlWord.outside finalHaltId,
regs := [0, 0, Algorithm.residual j f - 1, x + j, 0] }.regs ++
extra'))hz:¬Algorithm.residual j f = 0⊢ ∃ P' ≥ P,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P [1, 1, 1, 1] ([0, 0, f, x, j] ++ extra)) =
some
(Physical.rootCfg P' (if Algorithm.residual j f = 0 then [] else word (ControlWord.outside finalHaltId))
([0, 0, Algorithm.residual j f - 1, x + j, 0] ++ extra')) simpa only [hz,ite_false] using hAll goals completed! 🐙theorem physical_precredit_width_zero (P x j f : Nat) (extra : List Nat)
(hP : widthBudget j ≤ P) (hr : Algorithm.residual j f = 0) :
∃ P' ≥ P+1, ∃ n ≥ 1, ∃ extra',
nSteps n (Physical.rootCfg P [1,1,1,1] ([0,0,f,x,j] ++ extra)) =
some (Physical.rootCfg P' [] ([0,0,0,x+j,0] ++ extra')) := byP:ℕx:ℕj:ℕf:ℕextra:List ℕhP:widthBudget j ≤ Phr:Algorithm.residual j f = 0⊢ ∃ P' ≥ P + 1,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P [1, 1, 1, 1] ([0, 0, f, x, j] ++ extra)) =
some (Physical.rootCfg P' [] ([0, 0, 0, x + j, 0] ++ extra'))
have h := strict_exit_lift (widthBudget j) P hP _ _ (byP:ℕx:ℕj:ℕf:ℕextra:List ℕhP:widthBudget j ≤ Phr:Algorithm.residual j f = 0⊢ { control := ControlWord.outside widthCallId, regs := [0, 0, f, x, j] }.regs.length = 5 rflAll goals completed! 🐙) (byP:ℕx:ℕj:ℕf:ℕextra:List ℕhP:widthBudget j ≤ Phr:Algorithm.residual j f = 0⊢ word { control := ControlWord.outside 0, regs := [0, 0, 0, x + j, 0] }.control = [] rflAll goals completed! 🐙)
(strict_precredit_width_zero x j f hr) extraP:ℕx:ℕj:ℕf:ℕextra:List ℕhP:widthBudget j ≤ Phr:Algorithm.residual j f = 0h:∃ P' ≥ P + 1,
∃ n ≥ 1,
∃ extra',
nSteps n
(Physical.rootCfg P (word { control := ControlWord.outside widthCallId, regs := [0, 0, f, x, j] }.control)
({ control := ControlWord.outside widthCallId, regs := [0, 0, f, x, j] }.regs ++ extra)) =
some
(Physical.rootCfg P' (word { control := ControlWord.outside 0, regs := [0, 0, 0, x + j, 0] }.control)
({ control := ControlWord.outside 0, regs := [0, 0, 0, x + j, 0] }.regs ++ extra'))⊢ ∃ P' ≥ P + 1,
∃ n ≥ 1,
∃ extra',
nSteps n (Physical.rootCfg P [1, 1, 1, 1] ([0, 0, f, x, j] ++ extra)) =
some (Physical.rootCfg P' [] ([0, 0, 0, x + j, 0] ++ extra'))
simpa only [widthCall_word,initial_word] using hAll goals completed! 🐙end ConjectureMachines.Riemann95.Traceend