Imports
/- Copyright (c) 2026 Google LLC. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. -/ module public import BusyBeaver.Basic

Reflective Symbolic Execution & Certificate Checker (BusyBeaver.Cert)

A small verified certificate checker for BusyBeaver machines: symbolic configurations (SC) over block-repetition variables, rewrite rules (RDef) validated by concrete symbolic execution, and a Bool-valued proof-script interpreter (run) whose success is sound for ReachesStar / ReachesPlus and for membership in the hub TapePatternSet (checkTrans_sound, checkHaltTrans_sound, checkHub_sound, checkInit_sound). Machines whose closure proofs are produced as certificates (e.g. M_1RB1RF_1LCHHH_1LE1RD_1RA0RC_0LF0LA_0LD0RB and M_1RBHHH_1RC1LE_0RD0RF_0RE0LA_1LF0LB_1LA1LD) import this module; it is not needed by the hand-written machine proofs.

@[expose] public sectionnamespace BusyBeaveropen Turingnamespace Certmacro "nlin" : tactic => `(tactic| ((try simp only [Nat.add_mul, Nat.mul_add, Nat.mul_assoc]) <;> omega))abbrev Sym := Fin 2abbrev St := Fin 6abbrev TM := Machine Sym St

List Powers and Half-Tape Lemmas

theorem lpow_rot (u w : List Sym) (n : ℕ) : (u ++ w) ^ n ++ u = u ++ (w ++ u) ^ n := u:List Symw:List Symn:ℕ⊢ (u ++ w) ^ n ++ u = u ++ (w ++ u) ^ n induction n with u:List Symw:List Sym⊢ (u ++ w) ^ 0 ++ u = u ++ (w ++ u) ^ 0 All goals completed! 🐙 u:List Symw:List Symn:ℕih:(u ++ w) ^ n ++ u = u ++ (w ++ u) ^ n⊢ (u ++ w) ^ (n + 1) ++ u = u ++ (w ++ u) ^ (n + 1) u:List Symw:List Symn:ℕih:(u ++ w) ^ n ++ u = u ++ (w ++ u) ^ n⊢ u ++ w ++ (u ++ (w ++ u) ^ n) = u ++ (w ++ u ++ (w ++ u) ^ n); All goals completed! 🐙theorem lb_zeros_default1 (z : List Sym) (hz : ∀ x ∈ z, x = 0) : ListBlank.append z default = default := z:List Symhz:∀ x ∈ z, x = 0⊢ z +> default = default induction z with hz:∀ x ∈ [], x = 0⊢ [] +> default = default All goals completed! 🐙 x:Symz:List Symihz:(∀ x ∈ z, x = 0) → z +> default = defaulthz:∀ x_1 ∈ x :: z, x_1 = 0⊢ (x :: z) +> default = default All goals completed! 🐙theorem lb_zeros_default (z : List Sym) (hz : ∀ x ∈ z, x = 0) (n : ℕ) : ListBlank.append (z ^ n) default = default := z:List Symhz:∀ x ∈ z, x = 0n:ℕ⊢ z ^ n +> default = default induction n with z:List Symhz:∀ x ∈ z, x = 0⊢ z ^ 0 +> default = default All goals completed! 🐙 z:List Symhz:∀ x ∈ z, x = 0n:ℕih:z ^ n +> default = default⊢ z ^ (n + 1) +> default = default All goals completed! 🐙

Linear Expressions over Variables

structure Lin where c : ℕ cs : List ℕ deriving DecidableEqdef dotv (v : ℕ → ℕ) : List ℕ → ℕ → ℕ | [], _ => 0 | a :: as, i => a * v i + dotv v as (i + 1)def Lin.eval (v : ℕ → ℕ) (e : Lin) : ℕ := e.c + dotv v e.cs 0-- all coefficients zero (structural recursion, so the kernel can evaluate it) def zall : List ℕ → Bool | [] => true | a :: as => a == 0 && zall asdef csEq : List ℕ → List ℕ → Bool | [], bs => zall bs | a :: as, [] => zall (a :: as) | a :: as, b :: bs => a == b && csEq as bsdef Lin.beq (a b : Lin) : Bool := a.c == b.c && csEq a.cs b.cstheorem zall_dotv : ∀ (bs : List ℕ), zall bs = true → ∀ v i, dotv v bs i = 0 | [], _, _, _ => rfl b:ℕbs:List ℕh:zall (b :: bs) = truev:ℕ → ℕi:ℕ⊢ dotv v (b :: bs) i = 0 b:ℕbs:List ℕh:zall (b :: bs) = truev:ℕ → ℕi:ℕ⊢ dotv v (b :: bs) i = 0 b:ℕbs:List ℕv:ℕ → ℕi:ℕh:b = 0 ∧ zall bs = true⊢ dotv v (b :: bs) i = 0 All goals completed! 🐙theorem csEq_nil_left (bs : List ℕ) (h : csEq [] bs = true) (v : ℕ → ℕ) (i : ℕ) : dotv v bs i = 0 := zall_dotv bs h v itheorem csEq_sound : ∀ (as bs : List ℕ), csEq as bs = true → ∀ v i, dotv v as i = dotv v bs i bs:List ℕh:csEq [] bs = truev:ℕ → ℕi:ℕ⊢ dotv v [] i = dotv v bs i bs:List ℕh:csEq [] bs = truev:ℕ → ℕi:ℕ⊢ dotv v [] i = dotv v bs i bs:List ℕh:csEq [] bs = truev:ℕ → ℕi:ℕ⊢ dotv v [] i = 0; All goals completed! 🐙 a:ℕas:List ℕh:csEq (a :: as) [] = truev:ℕ → ℕi:ℕ⊢ dotv v (a :: as) i = dotv v [] i a:ℕas:List ℕh:csEq (a :: as) [] = truev:ℕ → ℕi:ℕ⊢ dotv v (a :: as) i = dotv v [] i a:ℕas:List ℕh:csEq (a :: as) [] = truev:ℕ → ℕi:ℕ⊢ 0 = dotv v [] i; All goals completed! 🐙 a:ℕas:List ℕb:ℕbs:List ℕh:csEq (a :: as) (b :: bs) = truev:ℕ → ℕi:ℕ⊢ dotv v (a :: as) i = dotv v (b :: bs) i a:ℕas:List ℕb:ℕbs:List ℕh:csEq (a :: as) (b :: bs) = truev:ℕ → ℕi:ℕ⊢ dotv v (a :: as) i = dotv v (b :: bs) i a:ℕas:List ℕb:ℕbs:List ℕv:ℕ → ℕi:ℕh:a = b ∧ csEq as bs = true⊢ dotv v (a :: as) i = dotv v (b :: bs) i All goals completed! 🐙theorem Lin.beq_sound (a b : Lin) (h : a.beq b = true) (v : ℕ → ℕ) : a.eval v = b.eval v := a:Linb:Linh:a.beq b = truev:ℕ → ℕ⊢ eval v a = eval v b a:Linb:Linv:ℕ → ℕh:a.c = b.c ∧ csEq a.cs b.cs = true⊢ eval v a = eval v b All goals completed! 🐙def Lin.const (k : ℕ) : Lin := ⟨k, []⟩def Lin.var (i : ℕ) : Lin := ⟨0, List.replicate i 0 ++ [1]⟩theorem Lin.eval_const (k : ℕ) (v : ℕ → ℕ) : (Lin.const k).eval v = k := k:ℕv:ℕ → ℕ⊢ eval v (const k) = k All goals completed! 🐙theorem dotv_var (v : ℕ → ℕ) : ∀ (i j : ℕ), dotv v (List.replicate i 0 ++ [1]) j = v (j + i) v:ℕ → ℕj:ℕ⊢ dotv v (List.replicate 0 0 ++ [1]) j = v (j + 0) v:ℕ → ℕj:ℕ⊢ dotv v (List.replicate 0 0 ++ [1]) j = v (j + 0) All goals completed! 🐙 v:ℕ → ℕi:ℕj:ℕ⊢ dotv v (List.replicate (i + 1) 0 ++ [1]) j = v (j + (i + 1)) v:ℕ → ℕi:ℕj:ℕ⊢ dotv v (List.replicate (i + 1) 0 ++ [1]) j = v (j + (i + 1)) v:ℕ → ℕi:ℕj:ℕ⊢ dotv v (List.replicate i 0 ++ [1]) (j + 1) = v (j + (i + 1)) v:ℕ → ℕi:ℕj:ℕ⊢ v (j + 1 + i) = v (j + (i + 1)); v:ℕ → ℕi:ℕj:ℕ⊢ j + 1 + i = j + (i + 1); All goals completed! 🐙theorem Lin.eval_var (i : ℕ) (v : ℕ → ℕ) : (Lin.var i).eval v = v i := i:ℕv:ℕ → ℕ⊢ eval v (var i) = v i All goals completed! 🐙def allZero : List ℕ → Bool | [] => true | a :: as => a == 0 && allZero astheorem allZero_dotv : ∀ (as : List ℕ), allZero as = true → ∀ v i, dotv v as i = 0 | [], _, _, _ => rfl a:ℕas:List ℕh:allZero (a :: as) = truev:ℕ → ℕi:ℕ⊢ dotv v (a :: as) i = 0 a:ℕas:List ℕh:allZero (a :: as) = truev:ℕ → ℕi:ℕ⊢ dotv v (a :: as) i = 0 a:ℕas:List ℕv:ℕ → ℕi:ℕh:a = 0 ∧ allZero as = true⊢ dotv v (a :: as) i = 0 All goals completed! 🐙def Lin.isConst (e : Lin) (k : ℕ) : Bool := e.c == k && allZero e.cstheorem Lin.isConst_eval (e : Lin) (k : ℕ) (h : e.isConst k = true) (v : ℕ → ℕ) : e.eval v = k := e:Link:ℕh:e.isConst k = truev:ℕ → ℕ⊢ eval v e = k e:Link:ℕv:ℕ → ℕh:e.c = k ∧ allZero e.cs = true⊢ eval v e = k All goals completed! 🐙def addCs : List ℕ → List ℕ → List ℕ | [], bs => bs | a :: as, [] => a :: as | a :: as, b :: bs => (a + b) :: addCs as bstheorem dotv_addCs (v : ℕ → ℕ) : ∀ (as bs : List ℕ) (i : ℕ), dotv v (addCs as bs) i = dotv v as i + dotv v bs i v:ℕ → ℕbs:List ℕi:ℕ⊢ dotv v (addCs [] bs) i = dotv v [] i + dotv v bs i v:ℕ → ℕbs:List ℕi:ℕ⊢ dotv v (addCs [] bs) i = dotv v [] i + dotv v bs i All goals completed! 🐙 v:ℕ → ℕa:ℕas:List ℕi:ℕ⊢ dotv v (addCs (a :: as) []) i = dotv v (a :: as) i + dotv v [] i v:ℕ → ℕa:ℕas:List ℕi:ℕ⊢ dotv v (addCs (a :: as) []) i = dotv v (a :: as) i + dotv v [] i All goals completed! 🐙 v:ℕ → ℕa:ℕas:List ℕb:ℕbs:List ℕi:ℕ⊢ dotv v (addCs (a :: as) (b :: bs)) i = dotv v (a :: as) i + dotv v (b :: bs) i v:ℕ → ℕa:ℕas:List ℕb:ℕbs:List ℕi:ℕ⊢ dotv v (addCs (a :: as) (b :: bs)) i = dotv v (a :: as) i + dotv v (b :: bs) i v:ℕ → ℕa:ℕas:List ℕb:ℕbs:List ℕi:ℕ⊢ (a + b) * v i + (dotv v as (i + 1) + dotv v bs (i + 1)) = a * v i + dotv v as (i + 1) + (b * v i + dotv v bs (i + 1)); All goals completed! 🐙def Lin.add (a b : Lin) : Lin := ⟨a.c + b.c, addCs a.cs b.cs⟩theorem Lin.eval_add (a b : Lin) (v : ℕ → ℕ) : (a.add b).eval v = a.eval v + b.eval v := a:Linb:Linv:ℕ → ℕ⊢ eval v (a.add b) = eval v a + eval v b a:Linb:Linv:ℕ → ℕ⊢ a.c + b.c + (dotv v a.cs 0 + dotv v b.cs 0) = a.c + dotv v a.cs 0 + (b.c + dotv v b.cs 0); All goals completed! 🐙def Lin.scale (k : ℕ) (a : Lin) : Lin := ⟨k * a.c, a.cs.map (k * ·)⟩theorem dotv_scale (v : ℕ → ℕ) (k : ℕ) : ∀ (as : List ℕ) (i : ℕ), dotv v (as.map (k * ·)) i = k * dotv v as i v:ℕ → ℕk:ℕi:ℕ⊢ dotv v (List.map (fun x ↦ k * x) []) i = k * dotv v [] i v:ℕ → ℕk:ℕi:ℕ⊢ dotv v (List.map (fun x ↦ k * x) []) i = k * dotv v [] i All goals completed! 🐙 v:ℕ → ℕk:ℕa:ℕas:List ℕi:ℕ⊢ dotv v (List.map (fun x ↦ k * x) (a :: as)) i = k * dotv v (a :: as) i v:ℕ → ℕk:ℕa:ℕas:List ℕi:ℕ⊢ dotv v (List.map (fun x ↦ k * x) (a :: as)) i = k * dotv v (a :: as) i v:ℕ → ℕk:ℕa:ℕas:List ℕi:ℕ⊢ k * a * v i + k * dotv v as (i + 1) = k * (a * v i + dotv v as (i + 1)); All goals completed! 🐙theorem Lin.eval_scale (k : ℕ) (a : Lin) (v : ℕ → ℕ) : (a.scale k).eval v = k * a.eval v := k:ℕa:Linv:ℕ → ℕ⊢ eval v (scale k a) = k * eval v a k:ℕa:Linv:ℕ → ℕ⊢ k * a.c + k * dotv v a.cs 0 = k * (a.c + dotv v a.cs 0); All goals completed! 🐙def Lin.dec (a : Lin) : Lin := ⟨a.c - 1, a.cs⟩theorem Lin.eval_dec (a : Lin) (h : 1 ≤ a.c) (v : ℕ → ℕ) : a.eval v = a.dec.eval v + 1 := a:Linh:1 ≤ a.cv:ℕ → ℕ⊢ eval v a = eval v a.dec + 1 a:Linh:1 ≤ a.cv:ℕ → ℕ⊢ a.c + dotv v a.cs 0 = a.c - 1 + dotv v a.cs 0 + 1; All goals completed! 🐙def divCs (k : ℕ) : List ℕ → Option (List ℕ) | [] => some [] | a :: as => if a % k == 0 then (divCs k as).map (fun r => (a / k) :: r) else nonetheorem divCs_sound (v : ℕ → ℕ) (k : ℕ) : ∀ (as rs : List ℕ), divCs k as = some rs → ∀ i, dotv v as i = k * dotv v rs i v:ℕ → ℕk:ℕrs:List ℕh:divCs k [] = some rsi:ℕ⊢ dotv v [] i = k * dotv v rs i v:ℕ → ℕk:ℕrs:List ℕh:divCs k [] = some rsi:ℕ⊢ dotv v [] i = k * dotv v rs i v:ℕ → ℕk:ℕrs:List ℕi:ℕh:[] = rs⊢ dotv v [] i = k * dotv v rs i; v:ℕ → ℕk:ℕi:ℕ⊢ dotv v [] i = k * dotv v [] i; All goals completed! 🐙 v:ℕ → ℕk:ℕa:ℕas:List ℕrs:List ℕh:divCs k (a :: as) = some rsi:ℕ⊢ dotv v (a :: as) i = k * dotv v rs i v:ℕ → ℕk:ℕa:ℕas:List ℕrs:List ℕh:divCs k (a :: as) = some rsi:ℕ⊢ dotv v (a :: as) i = k * dotv v rs i v:ℕ → ℕk:ℕa:ℕas:List ℕrs:List ℕh:(if (a % k == 0) = true then Option.map (fun r ↦ a / k :: r) (divCs k as) else none) = some rsi:ℕ⊢ dotv v (a :: as) i = k * dotv v rs i v:ℕ → ℕk:ℕa:ℕas:List ℕrs:List ℕi:ℕh✝:(a % k == 0) = trueh:Option.map (fun r ↦ a / k :: r) (divCs k as) = some rs⊢ dotv v (a :: as) i = k * dotv v rs iv:ℕ → ℕk:ℕa:ℕas:List ℕrs:List ℕi:ℕh✝:¬(a % k == 0) = trueh:none = some rs⊢ dotv v (a :: as) i = k * dotv v rs i v:ℕ → ℕk:ℕa:ℕas:List ℕrs:List ℕi:ℕh✝:(a % k == 0) = trueh:Option.map (fun r ↦ a / k :: r) (divCs k as) = some rs⊢ dotv v (a :: as) i = k * dotv v rs i v:ℕ → ℕk:ℕa:ℕas:List ℕrs:List ℕi:ℕhk:(a % k == 0) = trueh:Option.map (fun r ↦ a / k :: r) (divCs k as) = some rs⊢ dotv v (a :: as) i = k * dotv v rs i v:ℕ → ℕk:ℕa:ℕas:List ℕrs:List ℕi:ℕh:Option.map (fun r ↦ a / k :: r) (divCs k as) = some rshk:a % k = 0⊢ dotv v (a :: as) i = k * dotv v rs i cases hd : divCs k as with v:ℕ → ℕk:ℕa:ℕas:List ℕrs:List ℕi:ℕh:Option.map (fun r ↦ a / k :: r) (divCs k as) = some rshk:a % k = 0hd:divCs k as = none⊢ dotv v (a :: as) i = k * dotv v rs i All goals completed! 🐙 v:ℕ → ℕk:ℕa:ℕas:List ℕrs:List ℕi:ℕh:Option.map (fun r ↦ a / k :: r) (divCs k as) = some rshk:a % k = 0r:List ℕhd:divCs k as = some r⊢ dotv v (a :: as) i = k * dotv v rs i v:ℕ → ℕk:ℕa:ℕas:List ℕrs:List ℕi:ℕhk:a % k = 0r:List ℕhd:divCs k as = some rh:a / k :: r = rs⊢ dotv v (a :: as) i = k * dotv v rs i v:ℕ → ℕk:ℕa:ℕas:List ℕi:ℕhk:a % k = 0r:List ℕhd:divCs k as = some r⊢ dotv v (a :: as) i = k * dotv v (a / k :: r) i v:ℕ → ℕk:ℕa:ℕas:List ℕi:ℕhk:a % k = 0r:List ℕhd:divCs k as = some r⊢ a * v i + k * dotv v r (i + 1) = k * (a / k * v i + dotv v r (i + 1)) v:ℕ → ℕk:ℕa:ℕas:List ℕi:ℕhk:a % k = 0r:List ℕhd:divCs k as = some rthis:a = k * (a / k)⊢ a * v i + k * dotv v r (i + 1) = k * (a / k * v i + dotv v r (i + 1)) conv_lhs => v:ℕ → ℕk:ℕa:ℕas:List ℕi:ℕhk:a % k = 0r:List ℕhd:divCs k as = some rthis:a = k * (a / k)| k * (a / k) * v i + k * dotv v r (i + 1) All goals completed! 🐙 v:ℕ → ℕk:ℕa:ℕas:List ℕrs:List ℕi:ℕh✝:¬(a % k == 0) = trueh:none = some rs⊢ dotv v (a :: as) i = k * dotv v rs i All goals completed! 🐙def Lin.div (k : ℕ) (a : Lin) : Option Lin := if a.c % k == 0 then (divCs k a.cs).map (fun r => ⟨a.c / k, r⟩) else nonetheorem Lin.div_sound (k : ℕ) (a b : Lin) (h : a.div k = some b) (v : ℕ → ℕ) : a.eval v = k * b.eval v := k:ℕa:Linb:Linh:div k a = some bv:ℕ → ℕ⊢ eval v a = k * eval v b k:ℕa:Linb:Linh:(if (a.c % k == 0) = true then Option.map (fun r ↦ { c := a.c / k, cs := r }) (divCs k a.cs) else none) = some bv:ℕ → ℕ⊢ eval v a = k * eval v b k:ℕa:Linb:Linv:ℕ → ℕh✝:(a.c % k == 0) = trueh:Option.map (fun r ↦ { c := a.c / k, cs := r }) (divCs k a.cs) = some b⊢ eval v a = k * eval v bk:ℕa:Linb:Linv:ℕ → ℕh✝:¬(a.c % k == 0) = trueh:none = some b⊢ eval v a = k * eval v b k:ℕa:Linb:Linv:ℕ → ℕh✝:(a.c % k == 0) = trueh:Option.map (fun r ↦ { c := a.c / k, cs := r }) (divCs k a.cs) = some b⊢ eval v a = k * eval v b k:ℕa:Linb:Linv:ℕ → ℕhk:(a.c % k == 0) = trueh:Option.map (fun r ↦ { c := a.c / k, cs := r }) (divCs k a.cs) = some b⊢ eval v a = k * eval v b k:ℕa:Linb:Linv:ℕ → ℕh:Option.map (fun r ↦ { c := a.c / k, cs := r }) (divCs k a.cs) = some bhk:a.c % k = 0⊢ eval v a = k * eval v b cases hd : divCs k a.cs with k:ℕa:Linb:Linv:ℕ → ℕh:Option.map (fun r ↦ { c := a.c / k, cs := r }) (divCs k a.cs) = some bhk:a.c % k = 0hd:divCs k a.cs = none⊢ eval v a = k * eval v b All goals completed! 🐙 k:ℕa:Linb:Linv:ℕ → ℕh:Option.map (fun r ↦ { c := a.c / k, cs := r }) (divCs k a.cs) = some bhk:a.c % k = 0r:List ℕhd:divCs k a.cs = some r⊢ eval v a = k * eval v b k:ℕa:Linb:Linv:ℕ → ℕhk:a.c % k = 0r:List ℕhd:divCs k a.cs = some rh:{ c := a.c / k, cs := r } = b⊢ eval v a = k * eval v b k:ℕa:Linv:ℕ → ℕhk:a.c % k = 0r:List ℕhd:divCs k a.cs = some r⊢ eval v a = k * eval v { c := a.c / k, cs := r } k:ℕa:Linv:ℕ → ℕhk:a.c % k = 0r:List ℕhd:divCs k a.cs = some r⊢ a.c + k * dotv v r 0 = k * (a.c / k + dotv v r 0) k:ℕa:Linv:ℕ → ℕhk:a.c % k = 0r:List ℕhd:divCs k a.cs = some rthis:a.c = k * (a.c / k)⊢ a.c + k * dotv v r 0 = k * (a.c / k + dotv v r 0) conv_lhs => k:ℕa:Linv:ℕ → ℕhk:a.c % k = 0r:List ℕhd:divCs k a.cs = some rthis:a.c = k * (a.c / k)| k * (a.c / k) + k * dotv v r 0 All goals completed! 🐙 k:ℕa:Linb:Linv:ℕ → ℕh✝:¬(a.c % k == 0) = trueh:none = some b⊢ eval v a = k * eval v b All goals completed! 🐙-- single-variable substitution x_i := f def setZero : List ℕ → ℕ → List ℕ | [], _ => [] | _ :: as, 0 => 0 :: as | a :: as, i + 1 => a :: setZero as idef getC : List ℕ → ℕ → ℕ | [], _ => 0 | a :: _, 0 => a | _ :: as, i + 1 => getC as itheorem dotv_setZero (v : ℕ → ℕ) : ∀ (as : List ℕ) (j i : ℕ), dotv v as i = dotv v (setZero as j) i + getC as j * v (i + j) v:ℕ → ℕj:ℕi:ℕ⊢ dotv v [] i = dotv v (setZero [] j) i + getC [] j * v (i + j) v:ℕ → ℕj:ℕi:ℕ⊢ dotv v [] i = dotv v (setZero [] j) i + getC [] j * v (i + j) All goals completed! 🐙 v:ℕ → ℕa:ℕas:List ℕi:ℕ⊢ dotv v (a :: as) i = dotv v (setZero (a :: as) 0) i + getC (a :: as) 0 * v (i + 0) v:ℕ → ℕa:ℕas:List ℕi:ℕ⊢ dotv v (a :: as) i = dotv v (setZero (a :: as) 0) i + getC (a :: as) 0 * v (i + 0) v:ℕ → ℕa:ℕas:List ℕi:ℕ⊢ a * v i + dotv v as (i + 1) = dotv v as (i + 1) + a * v i; All goals completed! 🐙 v:ℕ → ℕa:ℕas:List ℕj:ℕi:ℕ⊢ dotv v (a :: as) i = dotv v (setZero (a :: as) (j + 1)) i + getC (a :: as) (j + 1) * v (i + (j + 1)) v:ℕ → ℕa:ℕas:List ℕj:ℕi:ℕ⊢ dotv v (a :: as) i = dotv v (setZero (a :: as) (j + 1)) i + getC (a :: as) (j + 1) * v (i + (j + 1)) v:ℕ → ℕa:ℕas:List ℕj:ℕi:ℕ⊢ a * v i + dotv v as (i + 1) = a * v i + dotv v (setZero as j) (i + 1) + getC as j * v (i + (j + 1)) v:ℕ → ℕa:ℕas:List ℕj:ℕi:ℕ⊢ a * v i + (dotv v (setZero as j) (i + 1) + getC as j * v (i + 1 + j)) = a * v i + dotv v (setZero as j) (i + 1) + getC as j * v (i + (j + 1)) v:ℕ → ℕa:ℕas:List ℕj:ℕi:ℕthis:i + 1 + j = i + (j + 1)⊢ a * v i + (dotv v (setZero as j) (i + 1) + getC as j * v (i + 1 + j)) = a * v i + dotv v (setZero as j) (i + 1) + getC as j * v (i + (j + 1)) v:ℕ → ℕa:ℕas:List ℕj:ℕi:ℕthis:i + 1 + j = i + (j + 1)⊢ a * v i + (dotv v (setZero as j) (i + 1) + getC as j * v (i + (j + 1))) = a * v i + dotv v (setZero as j) (i + 1) + getC as j * v (i + (j + 1)); All goals completed! 🐙theorem getC_setZero : ∀ (as : List ℕ) (j : ℕ), getC (setZero as j) j = 0 j:ℕ⊢ getC (setZero [] j) j = 0 j:ℕ⊢ getC (setZero [] j) j = 0 All goals completed! 🐙 a:ℕas:List ℕ⊢ getC (setZero (a :: as) 0) 0 = 0 a:ℕas:List ℕ⊢ getC (setZero (a :: as) 0) 0 = 0 All goals completed! 🐙 a:ℕas:List ℕj:ℕ⊢ getC (setZero (a :: as) (j + 1)) (j + 1) = 0 a:ℕas:List ℕj:ℕ⊢ getC (setZero (a :: as) (j + 1)) (j + 1) = 0 All goals completed! 🐙theorem dotv_update_lt (v : ℕ → ℕ) (p x : ℕ) : ∀ (as : List ℕ) (i : ℕ), p < i → dotv (Function.update v p x) as i = dotv v as i | [], i, _ => rfl v:ℕ → ℕp:ℕx:ℕa:ℕas:List ℕi:ℕh:p < i⊢ dotv (Function.update v p x) (a :: as) i = dotv v (a :: as) i v:ℕ → ℕp:ℕx:ℕa:ℕas:List ℕi:ℕh:p < i⊢ dotv (Function.update v p x) (a :: as) i = dotv v (a :: as) i v:ℕ → ℕp:ℕx:ℕa:ℕas:List ℕi:ℕh:p < i⊢ a * Function.update v p x i + dotv (Function.update v p x) as (i + 1) = a * v i + dotv v as (i + 1) v:ℕ → ℕp:ℕx:ℕa:ℕas:List ℕi:ℕh:p < i⊢ a * Function.update v p x i + dotv v as (i + 1) = a * v i + dotv v as (i + 1) v:ℕ → ℕp:ℕx:ℕa:ℕas:List ℕi:ℕh:p < ithis:Function.update v p x i = v i⊢ a * Function.update v p x i + dotv v as (i + 1) = a * v i + dotv v as (i + 1) All goals completed! 🐙theorem dotv_update (v : ℕ → ℕ) (x : ℕ) : ∀ (as : List ℕ) (j i : ℕ), dotv (Function.update v (i + j) x) as i + getC as j * v (i + j) = dotv v as i + getC as j * x v:ℕ → ℕx:ℕj:ℕi:ℕ⊢ dotv (Function.update v (i + j) x) [] i + getC [] j * v (i + j) = dotv v [] i + getC [] j * x v:ℕ → ℕx:ℕj:ℕi:ℕ⊢ dotv (Function.update v (i + j) x) [] i + getC [] j * v (i + j) = dotv v [] i + getC [] j * x All goals completed! 🐙 v:ℕ → ℕx:ℕa:ℕas:List ℕi:ℕ⊢ dotv (Function.update v (i + 0) x) (a :: as) i + getC (a :: as) 0 * v (i + 0) = dotv v (a :: as) i + getC (a :: as) 0 * x v:ℕ → ℕx:ℕa:ℕas:List ℕi:ℕ⊢ dotv (Function.update v (i + 0) x) (a :: as) i + getC (a :: as) 0 * v (i + 0) = dotv v (a :: as) i + getC (a :: as) 0 * x v:ℕ → ℕx:ℕa:ℕas:List ℕi:ℕ⊢ a * Function.update v i x i + dotv (Function.update v i x) as (i + 1) + a * v i = a * v i + dotv v as (i + 1) + a * x v:ℕ → ℕx:ℕa:ℕas:List ℕi:ℕ⊢ a * Function.update v i x i + dotv v as (i + 1) + a * v i = a * v i + dotv v as (i + 1) + a * x v:ℕ → ℕx:ℕa:ℕas:List ℕi:ℕ⊢ a * x + dotv v as (i + 1) + a * v i = a * v i + dotv v as (i + 1) + a * x; All goals completed! 🐙 v:ℕ → ℕx:ℕa:ℕas:List ℕj:ℕi:ℕ⊢ dotv (Function.update v (i + (j + 1)) x) (a :: as) i + getC (a :: as) (j + 1) * v (i + (j + 1)) = dotv v (a :: as) i + getC (a :: as) (j + 1) * x v:ℕ → ℕx:ℕa:ℕas:List ℕj:ℕi:ℕ⊢ dotv (Function.update v (i + (j + 1)) x) (a :: as) i + getC (a :: as) (j + 1) * v (i + (j + 1)) = dotv v (a :: as) i + getC (a :: as) (j + 1) * x v:ℕ → ℕx:ℕa:ℕas:List ℕj:ℕi:ℕ⊢ a * Function.update v (i + (j + 1)) x i + dotv (Function.update v (i + (j + 1)) x) as (i + 1) + getC as j * v (i + (j + 1)) = a * v i + dotv v as (i + 1) + getC as j * x v:ℕ → ℕx:ℕa:ℕas:List ℕj:ℕi:ℕh2:i + (j + 1) = i + 1 + j⊢ a * Function.update v (i + (j + 1)) x i + dotv (Function.update v (i + (j + 1)) x) as (i + 1) + getC as j * v (i + (j + 1)) = a * v i + dotv v as (i + 1) + getC as j * x v:ℕ → ℕx:ℕa:ℕas:List ℕj:ℕi:ℕh2:i + (j + 1) = i + 1 + jh1:Function.update v (i + 1 + j) x i = v i⊢ a * Function.update v (i + (j + 1)) x i + dotv (Function.update v (i + (j + 1)) x) as (i + 1) + getC as j * v (i + (j + 1)) = a * v i + dotv v as (i + 1) + getC as j * x v:ℕ → ℕx:ℕa:ℕas:List ℕj:ℕi:ℕh2:i + (j + 1) = i + 1 + jh1:Function.update v (i + 1 + j) x i = v i⊢ a * v i + dotv (Function.update v (i + 1 + j) x) as (i + 1) + getC as j * v (i + 1 + j) = a * v i + dotv v as (i + 1) + getC as j * x v:ℕ → ℕx:ℕa:ℕas:List ℕj:ℕi:ℕh2:i + (j + 1) = i + 1 + jh1:Function.update v (i + 1 + j) x i = v ithis:dotv (Function.update v (i + 1 + j) x) as (i + 1) + getC as j * v (i + 1 + j) = dotv v as (i + 1) + getC as j * x⊢ a * v i + dotv (Function.update v (i + 1 + j) x) as (i + 1) + getC as j * v (i + 1 + j) = a * v i + dotv v as (i + 1) + getC as j * x All goals completed! 🐙def Lin.subst (a : Lin) (i : ℕ) (f : Lin) : Lin := (⟨a.c, setZero a.cs i⟩ : Lin).add (f.scale (getC a.cs i))theorem Lin.eval_subst (a : Lin) (i : ℕ) (f : Lin) (v : ℕ → ℕ) : (a.subst i f).eval v = a.eval (Function.update v i (f.eval v)) := a:Lini:ℕf:Linv:ℕ → ℕ⊢ eval v (a.subst i f) = eval (Function.update v i (eval v f)) a a:Lini:ℕf:Linv:ℕ → ℕh1:dotv (Function.update v i (eval v f)) a.cs 0 = dotv (Function.update v i (eval v f)) (setZero a.cs i) 0 + getC a.cs i * Function.update v i (eval v f) (0 + i)⊢ eval v (a.subst i f) = eval (Function.update v i (eval v f)) a a:Lini:ℕf:Linv:ℕ → ℕh1:dotv (Function.update v i (eval v f)) a.cs 0 = dotv (Function.update v i (eval v f)) (setZero a.cs i) 0 + getC a.cs i * Function.update v i (eval v f) (0 + i)h2:dotv (Function.update v (0 + i) (eval v f)) (setZero a.cs i) 0 + getC (setZero a.cs i) i * v (0 + i) = dotv v (setZero a.cs i) 0 + getC (setZero a.cs i) i * eval v f⊢ eval v (a.subst i f) = eval (Function.update v i (eval v f)) a a:Lini:ℕf:Linv:ℕ → ℕh1:dotv (Function.update v i (eval v f)) a.cs 0 = dotv (Function.update v i (eval v f)) (setZero a.cs i) 0 + getC a.cs i * Function.update v i (eval v f) (0 + i)h2:dotv (Function.update v i (eval v f)) (setZero a.cs i) 0 + 0 * v i = dotv v (setZero a.cs i) 0 + 0 * eval v f⊢ eval v (a.subst i f) = eval (Function.update v i (eval v f)) a a:Lini:ℕf:Linv:ℕ → ℕh1:dotv (Function.update v i (eval v f)) a.cs 0 = dotv (Function.update v i (eval v f)) (setZero a.cs i) 0 + getC a.cs i * eval v fh2:dotv (Function.update v i (eval v f)) (setZero a.cs i) 0 + 0 * v i = dotv v (setZero a.cs i) 0 + 0 * eval v f⊢ eval v (a.subst i f) = eval (Function.update v i (eval v f)) a a:Lini:ℕf:Linv:ℕ → ℕh1:dotv (Function.update v i (eval v f)) a.cs 0 = dotv (Function.update v i (eval v f)) (setZero a.cs i) 0 + getC a.cs i * eval v fh2:dotv (Function.update v i (eval v f)) (setZero a.cs i) 0 + 0 * v i = dotv v (setZero a.cs i) 0 + 0 * eval v f⊢ eval v { c := a.c, cs := setZero a.cs i } + getC a.cs i * eval v f = eval (Function.update v i (eval v f)) a a:Lini:ℕf:Linv:ℕ → ℕh1:dotv (Function.update v i (eval v f)) a.cs 0 = dotv (Function.update v i (eval v f)) (setZero a.cs i) 0 + getC a.cs i * eval v fh2:dotv (Function.update v i (eval v f)) (setZero a.cs i) 0 + 0 * v i = dotv v (setZero a.cs i) 0 + 0 * eval v f⊢ a.c + dotv v (setZero a.cs i) 0 + getC a.cs i * eval v f = a.c + dotv (Function.update v i (eval v f)) a.cs 0 All goals completed! 🐙-- simultaneous substitution x_j := σ[j] (variables beyond σ are kept) def substCs : List ℕ → List Lin → ℕ → Lin | [], _, _ => Lin.const 0 | a :: as, σ, i => ((σ.headD (Lin.var i)).scale a).add (substCs as σ.tail (i + 1))def sem (σ : List Lin) (v : ℕ → ℕ) (j : ℕ) : ℕ := (σ.getD j (Lin.var j)).eval vtheorem getD_zero (x : Lin) (σ : List Lin) (d : Lin) : (x :: σ).getD 0 d = x := rfltheorem getD_succ (x : Lin) (σ : List Lin) (j : ℕ) (d : Lin) : (x :: σ).getD (j + 1) d = σ.getD j d := rfltheorem headD_drop : ∀ (σ : List Lin) (i : ℕ) (d : Lin), (σ.drop i).headD d = σ.getD i d i:ℕd:Lin⊢ (List.drop i []).headD d = [].getD i d i:ℕd:Lin⊢ (List.drop i []).headD d = [].getD i d d:Lin⊢ (List.drop 0 []).headD d = [].getD 0 dd:Linn✝:ℕ⊢ (List.drop (n✝ + 1) []).headD d = [].getD (n✝ + 1) d d:Lin⊢ (List.drop 0 []).headD d = [].getD 0 dd:Linn✝:ℕ⊢ (List.drop (n✝ + 1) []).headD d = [].getD (n✝ + 1) d All goals completed! 🐙 x:Linσ:List Lind:Lin⊢ (List.drop 0 (x :: σ)).headD d = (x :: σ).getD 0 d x:Linσ:List Lind:Lin⊢ (List.drop 0 (x :: σ)).headD d = (x :: σ).getD 0 d All goals completed! 🐙 x:Linσ:List Lini:ℕd:Lin⊢ (List.drop (i + 1) (x :: σ)).headD d = (x :: σ).getD (i + 1) d x:Linσ:List Lini:ℕd:Lin⊢ (List.drop (i + 1) (x :: σ)).headD d = (x :: σ).getD (i + 1) d x:Linσ:List Lini:ℕd:Lin⊢ (List.drop i σ).headD d = σ.getD i d; All goals completed! 🐙theorem tail_drop' : ∀ (σ : List Lin) (i : ℕ), (σ.drop i).tail = σ.drop (i + 1) i:ℕ⊢ (List.drop i []).tail = List.drop (i + 1) [] i:ℕ⊢ (List.drop i []).tail = List.drop (i + 1) [] ⊢ (List.drop 0 []).tail = List.drop (0 + 1) []n✝:ℕ⊢ (List.drop (n✝ + 1) []).tail = List.drop (n✝ + 1 + 1) [] ⊢ (List.drop 0 []).tail = List.drop (0 + 1) []n✝:ℕ⊢ (List.drop (n✝ + 1) []).tail = List.drop (n✝ + 1 + 1) [] All goals completed! 🐙 x:Linσ:List Lin⊢ (List.drop 0 (x :: σ)).tail = List.drop (0 + 1) (x :: σ) x:Linσ:List Lin⊢ (List.drop 0 (x :: σ)).tail = List.drop (0 + 1) (x :: σ) All goals completed! 🐙 x:Linσ:List Lini:ℕ⊢ (List.drop (i + 1) (x :: σ)).tail = List.drop (i + 1 + 1) (x :: σ) x:Linσ:List Lini:ℕ⊢ (List.drop (i + 1) (x :: σ)).tail = List.drop (i + 1 + 1) (x :: σ) x:Linσ:List Lini:ℕ⊢ (List.drop i σ).tail = List.drop (i + 1) σ; All goals completed! 🐙theorem substCs_eval (v : ℕ → ℕ) : ∀ (as : List ℕ) (σ : List Lin) (i : ℕ), (substCs as (σ.drop i) i).eval v = dotv (sem σ v) as i v:ℕ → ℕσ:List Lini:ℕ⊢ Lin.eval v (substCs [] (List.drop i σ) i) = dotv (sem σ v) [] i v:ℕ → ℕσ:List Lini:ℕ⊢ Lin.eval v (substCs [] (List.drop i σ) i) = dotv (sem σ v) [] i All goals completed! 🐙 v:ℕ → ℕa:ℕas:List ℕσ:List Lini:ℕ⊢ Lin.eval v (substCs (a :: as) (List.drop i σ) i) = dotv (sem σ v) (a :: as) i v:ℕ → ℕa:ℕas:List ℕσ:List Lini:ℕ⊢ Lin.eval v (substCs (a :: as) (List.drop i σ) i) = dotv (sem σ v) (a :: as) i v:ℕ → ℕa:ℕas:List ℕσ:List Lini:ℕ⊢ a * Lin.eval v ((List.drop i σ).headD (Lin.var i)) + Lin.eval v (substCs as (List.drop i σ).tail (i + 1)) = a * sem σ v i + dotv (sem σ v) as (i + 1) v:ℕ → ℕa:ℕas:List ℕσ:List Lini:ℕ⊢ a * Lin.eval v (σ.getD i (Lin.var i)) + dotv (sem σ v) as (i + 1) = a * sem σ v i + dotv (sem σ v) as (i + 1) All goals completed! 🐙def Lin.substAll (σ : List Lin) (a : Lin) : Lin := (Lin.const a.c).add (substCs a.cs σ 0)theorem Lin.eval_substAll (σ : List Lin) (a : Lin) (v : ℕ → ℕ) : (a.substAll σ).eval v = a.eval (sem σ v) := σ:List Lina:Linv:ℕ → ℕ⊢ eval v (substAll σ a) = eval (sem σ v) a σ:List Lina:Linv:ℕ → ℕthis:eval v (substCs a.cs (List.drop 0 σ) 0) = dotv (sem σ v) a.cs 0⊢ eval v (substAll σ a) = eval (sem σ v) a σ:List Lina:Linv:ℕ → ℕthis:eval v (substCs a.cs σ 0) = dotv (sem σ v) a.cs 0⊢ eval v (substAll σ a) = eval (sem σ v) a σ:List Lina:Linv:ℕ → ℕthis:eval v (substCs a.cs σ 0) = dotv (sem σ v) a.cs 0⊢ a.c + dotv (sem σ v) a.cs 0 = eval (sem σ v) a; All goals completed! 🐙-- recognising a bare variable def varIdx : List ℕ → ℕ → Option ℕ | [], _ => none | a :: as, i => if a == 1 && allZero as then some i else if a == 0 then varIdx as (i + 1) else nonetheorem varIdx_sound (v : ℕ → ℕ) : ∀ (as : List ℕ) (i k : ℕ), varIdx as i = some k → dotv v as i = v k v:ℕ → ℕi:ℕk:ℕh:varIdx [] i = some k⊢ dotv v [] i = v k v:ℕ → ℕi:ℕk:ℕh:varIdx [] i = some k⊢ dotv v [] i = v k All goals completed! 🐙 v:ℕ → ℕa:ℕas:List ℕi:ℕk:ℕh:varIdx (a :: as) i = some k⊢ dotv v (a :: as) i = v k v:ℕ → ℕa:ℕas:List ℕi:ℕk:ℕh:varIdx (a :: as) i = some k⊢ dotv v (a :: as) i = v k v:ℕ → ℕa:ℕas:List ℕi:ℕk:ℕh:(if (a == 1 && allZero as) = true then some i else if (a == 0) = true then varIdx as (i + 1) else none) = some k⊢ dotv v (a :: as) i = v k v:ℕ → ℕa:ℕas:List ℕi:ℕk:ℕh✝:(a == 1 && allZero as) = trueh:some i = some k⊢ dotv v (a :: as) i = v kv:ℕ → ℕa:ℕas:List ℕi:ℕk:ℕh✝:¬(a == 1 && allZero as) = trueh:(if (a == 0) = true then varIdx as (i + 1) else none) = some k⊢ dotv v (a :: as) i = v k v:ℕ → ℕa:ℕas:List ℕi:ℕk:ℕh✝:(a == 1 && allZero as) = trueh:some i = some k⊢ dotv v (a :: as) i = v k v:ℕ → ℕa:ℕas:List ℕi:ℕk:ℕh1:(a == 1 && allZero as) = trueh:some i = some k⊢ dotv v (a :: as) i = v k v:ℕ → ℕa:ℕas:List ℕi:ℕk:ℕh:some i = some kh1:a = 1 ∧ allZero as = true⊢ dotv v (a :: as) i = v k v:ℕ → ℕa:ℕas:List ℕi:ℕk:ℕh1:a = 1 ∧ allZero as = trueh:i = k⊢ dotv v (a :: as) i = v k v:ℕ → ℕa:ℕas:List ℕi:ℕh1:a = 1 ∧ allZero as = true⊢ dotv v (a :: as) i = v i All goals completed! 🐙 v:ℕ → ℕa:ℕas:List ℕi:ℕk:ℕh✝:¬(a == 1 && allZero as) = trueh:(if (a == 0) = true then varIdx as (i + 1) else none) = some k⊢ dotv v (a :: as) i = v k v:ℕ → ℕa:ℕas:List ℕi:ℕk:ℕh✝¹:¬(a == 1 && allZero as) = trueh✝:(a == 0) = trueh:varIdx as (i + 1) = some k⊢ dotv v (a :: as) i = v kv:ℕ → ℕa:ℕas:List ℕi:ℕk:ℕh✝¹:¬(a == 1 && allZero as) = trueh✝:¬(a == 0) = trueh:none = some k⊢ dotv v (a :: as) i = v k v:ℕ → ℕa:ℕas:List ℕi:ℕk:ℕh✝¹:¬(a == 1 && allZero as) = trueh✝:(a == 0) = trueh:varIdx as (i + 1) = some k⊢ dotv v (a :: as) i = v k v:ℕ → ℕa:ℕas:List ℕi:ℕk:ℕh✝:¬(a == 1 && allZero as) = trueh2:(a == 0) = trueh:varIdx as (i + 1) = some k⊢ dotv v (a :: as) i = v k v:ℕ → ℕa:ℕas:List ℕi:ℕk:ℕh✝:¬(a == 1 && allZero as) = trueh:varIdx as (i + 1) = some kh2:a = 0⊢ dotv v (a :: as) i = v k All goals completed! 🐙 v:ℕ → ℕa:ℕas:List ℕi:ℕk:ℕh✝¹:¬(a == 1 && allZero as) = trueh✝:¬(a == 0) = trueh:none = some k⊢ dotv v (a :: as) i = v k All goals completed! 🐙def Lin.asVar (e : Lin) : Option ℕ := if e.c == 0 then varIdx e.cs 0 else nonetheorem Lin.asVar_sound (e : Lin) (k : ℕ) (h : e.asVar = some k) (v : ℕ → ℕ) : e.eval v = v k := e:Link:ℕh:e.asVar = some kv:ℕ → ℕ⊢ eval v e = v k e:Link:ℕh:(if (e.c == 0) = true then varIdx e.cs 0 else none) = some kv:ℕ → ℕ⊢ eval v e = v k e:Link:ℕv:ℕ → ℕh✝:(e.c == 0) = trueh:varIdx e.cs 0 = some k⊢ eval v e = v ke:Link:ℕv:ℕ → ℕh✝:¬(e.c == 0) = trueh:none = some k⊢ eval v e = v k e:Link:ℕv:ℕ → ℕh✝:(e.c == 0) = trueh:varIdx e.cs 0 = some k⊢ eval v e = v k e:Link:ℕv:ℕ → ℕh0:(e.c == 0) = trueh:varIdx e.cs 0 = some k⊢ eval v e = v k e:Link:ℕv:ℕ → ℕh:varIdx e.cs 0 = some kh0:e.c = 0⊢ eval v e = v k All goals completed! 🐙 e:Link:ℕv:ℕ → ℕh✝:¬(e.c == 0) = trueh:none = some k⊢ eval v e = v k All goals completed! 🐙

Symbolic Tapes

structure Seg where b : List Sym e : Lin

Denotation of a half-tape (listed from the head outwards) on top of a tail t.

def hden (v : ℕ → ℕ) : List Seg → ListBlank Sym → ListBlank Sym | [], t => t | s :: r, t => ListBlank.append (s.b ^ s.e.eval v) (hden v r t)theorem den_append (v : ℕ → ℕ) : ∀ (A B : List Seg) (t : ListBlank Sym), hden v (A ++ B) t = hden v A (hden v B t) | [], B, t => rfl v:ℕ → ℕs:SegA:List SegB:List Segt:ListBlank Sym⊢ hden v (s :: A ++ B) t = hden v (s :: A) (hden v B t) v:ℕ → ℕs:SegA:List SegB:List Segt:ListBlank Sym⊢ hden v (s :: A ++ B) t = hden v (s :: A) (hden v B t) All goals completed! 🐙theorem den_single (v : ℕ → ℕ) (w : Sym) (r : List Seg) (t : ListBlank Sym) : hden v (⟨[w], Lin.const 1⟩ :: r) t = ListBlank.cons w (hden v r t) := v:ℕ → ℕw:Symr:List Segt:ListBlank Sym⊢ hden v ({ b := [w], e := Lin.const 1 } :: r) t = w >> hden v r t v:ℕ → ℕw:Symr:List Segt:ListBlank Sym⊢ [w] +> hden v r t = w >> hden v r t; All goals completed! 🐙def sideSubst (i : ℕ) (f : Lin) : List Seg → List Seg | [] => [] | s :: A => ⟨s.b, s.e.subst i f⟩ :: sideSubst i f Atheorem den_subst (v : ℕ → ℕ) (i : ℕ) (f : Lin) : ∀ (A : List Seg) (t : ListBlank Sym), hden v (sideSubst i f A) t = hden (Function.update v i (f.eval v)) A t | [], t => rfl v:ℕ → ℕi:ℕf:Lins:SegA:List Segt:ListBlank Sym⊢ hden v (sideSubst i f (s :: A)) t = hden (Function.update v i (Lin.eval v f)) (s :: A) t v:ℕ → ℕi:ℕf:Lins:SegA:List Segt:ListBlank Sym⊢ hden v (sideSubst i f (s :: A)) t = hden (Function.update v i (Lin.eval v f)) (s :: A) t All goals completed! 🐙def sideSubstAll (σ : List Lin) : List Seg → List Seg | [] => [] | s :: A => ⟨s.b, s.e.substAll σ⟩ :: sideSubstAll σ Atheorem den_substAll (v : ℕ → ℕ) (σ : List Lin) : ∀ (A : List Seg) (t : ListBlank Sym), hden v (sideSubstAll σ A) t = hden (sem σ v) A t | [], t => rfl v:ℕ → ℕσ:List Lins:SegA:List Segt:ListBlank Sym⊢ hden v (sideSubstAll σ (s :: A)) t = hden (sem σ v) (s :: A) t v:ℕ → ℕσ:List Lins:SegA:List Segt:ListBlank Sym⊢ hden v (sideSubstAll σ (s :: A)) t = hden (sem σ v) (s :: A) t All goals completed! 🐙def sideEq : List Seg → List Seg → Bool | [], [] => true | a :: as, b :: bs => (a.b == b.b && a.e.beq b.e) && sideEq as bs | _, _ => falsetheorem sideEq_sound : ∀ (A B : List Seg), sideEq A B = true → ∀ v t, hden v A t = hden v B t | [], [], _, v, t => rfl a:Segas:List Segb:Segbs:List Segh:sideEq (a :: as) (b :: bs) = truev:ℕ → ℕt:ListBlank Sym⊢ hden v (a :: as) t = hden v (b :: bs) t a:Segas:List Segb:Segbs:List Segh:sideEq (a :: as) (b :: bs) = truev:ℕ → ℕt:ListBlank Sym⊢ hden v (a :: as) t = hden v (b :: bs) t a:Segas:List Segb:Segbs:List Segv:ℕ → ℕt:ListBlank Symh:(a.b = b.b ∧ a.e.beq b.e = true) ∧ sideEq as bs = true⊢ hden v (a :: as) t = hden v (b :: bs) t All goals completed! 🐙 head✝:Segtail✝:List Segh:sideEq [] (head✝ :: tail✝) = truex✝¹:ℕ → ℕx✝:ListBlank Sym⊢ hden x✝¹ [] x✝ = hden x✝¹ (head✝ :: tail✝) x✝ head✝:Segtail✝:List Segh:sideEq [] (head✝ :: tail✝) = truex✝¹:ℕ → ℕx✝:ListBlank Sym⊢ hden x✝¹ [] x✝ = hden x✝¹ (head✝ :: tail✝) x✝ All goals completed! 🐙 head✝:Segtail✝:List Segh:sideEq (head✝ :: tail✝) [] = truex✝¹:ℕ → ℕx✝:ListBlank Sym⊢ hden x✝¹ (head✝ :: tail✝) x✝ = hden x✝¹ [] x✝ head✝:Segtail✝:List Segh:sideEq (head✝ :: tail✝) [] = truex✝¹:ℕ → ℕx✝:ListBlank Sym⊢ hden x✝¹ (head✝ :: tail✝) x✝ = hden x✝¹ [] x✝ All goals completed! 🐙def singles : List Sym → List Seg | [] => [] | x :: xs => ⟨[x], Lin.const 1⟩ :: singles xstheorem den_singles (v : ℕ → ℕ) : ∀ (b : List Sym) (r : List Seg) (t : ListBlank Sym), hden v (singles b ++ r) t = ListBlank.append b (hden v r t) | [], r, t => rfl v:ℕ → ℕx:Symxs:List Symr:List Segt:ListBlank Sym⊢ hden v (singles (x :: xs) ++ r) t = (x :: xs) +> hden v r t v:ℕ → ℕx:Symxs:List Symr:List Segt:ListBlank Sym⊢ hden v (singles (x :: xs) ++ r) t = (x :: xs) +> hden v r t All goals completed! 🐙def takeSingles : ℕ → List Seg → Option (List Sym × List Seg) | 0, A => some ([], A) | k + 1, s :: A => match s.b with | [x] => if s.e.isConst 1 then (takeSingles k A).map (fun p => (x :: p.1, p.2)) else none | _ => none | _ + 1, [] => nonetheorem takeSingles_sound (v : ℕ → ℕ) : ∀ (k : ℕ) (A : List Seg) (xs : List Sym) (r : List Seg), takeSingles k A = some (xs, r) → ∀ t, hden v A t = ListBlank.append xs (hden v r t) v:ℕ → ℕA:List Segxs:List Symr:List Segh:takeSingles 0 A = some (xs, r)t:ListBlank Sym⊢ hden v A t = xs +> hden v r t v:ℕ → ℕA:List Segxs:List Symr:List Segh:takeSingles 0 A = some (xs, r)t:ListBlank Sym⊢ hden v A t = xs +> hden v r t v:ℕ → ℕA:List Segxs:List Symr:List Segt:ListBlank Symh:[] = xs ∧ A = r⊢ hden v A t = xs +> hden v r t v:ℕ → ℕA:List Segxs:List Symr:List Segt:ListBlank Symh:[] = xs ∧ A = r⊢ hden v A t = [] +> hden v A t; All goals completed! 🐙 v:ℕ → ℕk:ℕxs:List Symr:List Segh:takeSingles (k + 1) [] = some (xs, r)t:ListBlank Sym⊢ hden v [] t = xs +> hden v r t v:ℕ → ℕk:ℕxs:List Symr:List Segh:takeSingles (k + 1) [] = some (xs, r)t:ListBlank Sym⊢ hden v [] t = xs +> hden v r t All goals completed! 🐙 v:ℕ → ℕk:ℕb:List Syme:LinA:List Segxs:List Symr:List Segh:takeSingles (k + 1) ({ b := b, e := e } :: A) = some (xs, r)t:ListBlank Sym⊢ hden v ({ b := b, e := e } :: A) t = xs +> hden v r t v:ℕ → ℕk:ℕb:List Syme:LinA:List Segxs:List Symr:List Segh:takeSingles (k + 1) ({ b := b, e := e } :: A) = some (xs, r)t:ListBlank Sym⊢ hden v ({ b := b, e := e } :: A) t = xs +> hden v r t v:ℕ → ℕk:ℕe:LinA:List Segxs:List Symr:List Segt:ListBlank Symh:takeSingles (k + 1) ({ b := [], e := e } :: A) = some (xs, r)⊢ hden v ({ b := [], e := e } :: A) t = xs +> hden v r tv:ℕ → ℕk:ℕe:LinA:List Segxs:List Symr:List Segt:ListBlank Symx:Symh:takeSingles (k + 1) ({ b := [x], e := e } :: A) = some (xs, r)⊢ hden v ({ b := [x], e := e } :: A) t = xs +> hden v r tv:ℕ → ℕk:ℕe:LinA:List Segxs:List Symr:List Segt:ListBlank Symx:Symy:Symb:List Symh:takeSingles (k + 1) ({ b := x :: y :: b, e := e } :: A) = some (xs, r)⊢ hden v ({ b := x :: y :: b, e := e } :: A) t = xs +> hden v r t v:ℕ → ℕk:ℕe:LinA:List Segxs:List Symr:List Segt:ListBlank Symh:takeSingles (k + 1) ({ b := [], e := e } :: A) = some (xs, r)⊢ hden v ({ b := [], e := e } :: A) t = xs +> hden v r t All goals completed! 🐙 v:ℕ → ℕk:ℕe:LinA:List Segxs:List Symr:List Segt:ListBlank Symx:Symh:takeSingles (k + 1) ({ b := [x], e := e } :: A) = some (xs, r)⊢ hden v ({ b := [x], e := e } :: A) t = xs +> hden v r t v:ℕ → ℕk:ℕe:LinA:List Segxs:List Symr:List Segt:ListBlank Symx:Symh:(if e.isConst 1 = true then Option.map (fun p ↦ (x :: p.1, p.2)) (takeSingles k A) else none) = some (xs, r)⊢ hden v ({ b := [x], e := e } :: A) t = xs +> hden v r t v:ℕ → ℕk:ℕe:LinA:List Segxs:List Symr:List Segt:ListBlank Symx:Symh✝:e.isConst 1 = trueh:Option.map (fun p ↦ (x :: p.1, p.2)) (takeSingles k A) = some (xs, r)⊢ hden v ({ b := [x], e := e } :: A) t = xs +> hden v r tv:ℕ → ℕk:ℕe:LinA:List Segxs:List Symr:List Segt:ListBlank Symx:Symh✝:¬e.isConst 1 = trueh:none = some (xs, r)⊢ hden v ({ b := [x], e := e } :: A) t = xs +> hden v r t v:ℕ → ℕk:ℕe:LinA:List Segxs:List Symr:List Segt:ListBlank Symx:Symh✝:e.isConst 1 = trueh:Option.map (fun p ↦ (x :: p.1, p.2)) (takeSingles k A) = some (xs, r)⊢ hden v ({ b := [x], e := e } :: A) t = xs +> hden v r t v:ℕ → ℕk:ℕe:LinA:List Segxs:List Symr:List Segt:ListBlank Symx:Symhe:e.isConst 1 = trueh:Option.map (fun p ↦ (x :: p.1, p.2)) (takeSingles k A) = some (xs, r)⊢ hden v ({ b := [x], e := e } :: A) t = xs +> hden v r t cases hk : takeSingles k A with v:ℕ → ℕk:ℕe:LinA:List Segxs:List Symr:List Segt:ListBlank Symx:Symhe:e.isConst 1 = trueh:Option.map (fun p ↦ (x :: p.1, p.2)) (takeSingles k A) = some (xs, r)hk:takeSingles k A = none⊢ hden v ({ b := [x], e := e } :: A) t = xs +> hden v r t All goals completed! 🐙 v:ℕ → ℕk:ℕe:LinA:List Segxs:List Symr:List Segt:ListBlank Symx:Symhe:e.isConst 1 = trueh:Option.map (fun p ↦ (x :: p.1, p.2)) (takeSingles k A) = some (xs, r)p:List Sym × List Seghk:takeSingles k A = some p⊢ hden v ({ b := [x], e := e } :: A) t = xs +> hden v r t v:ℕ → ℕk:ℕe:LinA:List Segxs:List Symr:List Segt:ListBlank Symx:Symhe:e.isConst 1 = truep:List Sym × List Seghk:takeSingles k A = some ph:x :: p.1 = xs ∧ p.2 = r⊢ hden v ({ b := [x], e := e } :: A) t = xs +> hden v r t v:ℕ → ℕk:ℕe:LinA:List Segxs:List Symr:List Segt:ListBlank Symx:Symhe:e.isConst 1 = truep1:List Symp2:List Seghk:takeSingles k A = some (p1, p2)h:x :: (p1, p2).1 = xs ∧ (p1, p2).2 = r⊢ hden v ({ b := [x], e := e } :: A) t = xs +> hden v r t v:ℕ → ℕk:ℕe:LinA:List Segxs:List Symr:List Segt:ListBlank Symx:Symhe:e.isConst 1 = truep1:List Symp2:List Seghk:takeSingles k A = some (p1, p2)h:x :: (p1, p2).1 = xs ∧ (p1, p2).2 = r⊢ hden v ({ b := [x], e := e } :: A) t = (x :: (p1, p2).1) +> hden v (p1, p2).2 t v:ℕ → ℕk:ℕe:LinA:List Segxs:List Symr:List Segt:ListBlank Symx:Symhe:e.isConst 1 = truep1:List Symp2:List Seghk:takeSingles k A = some (p1, p2)h:x :: (p1, p2).1 = xs ∧ (p1, p2).2 = r⊢ x >> hden v A t = x >> p1 +> hden v p2 t All goals completed! 🐙 v:ℕ → ℕk:ℕe:LinA:List Segxs:List Symr:List Segt:ListBlank Symx:Symh✝:¬e.isConst 1 = trueh:none = some (xs, r)⊢ hden v ({ b := [x], e := e } :: A) t = xs +> hden v r t All goals completed! 🐙 v:ℕ → ℕk:ℕe:LinA:List Segxs:List Symr:List Segt:ListBlank Symx:Symy:Symb:List Symh:takeSingles (k + 1) ({ b := x :: y :: b, e := e } :: A) = some (xs, r)⊢ hden v ({ b := x :: y :: b, e := e } :: A) t = xs +> hden v r t All goals completed! 🐙

Local Rewrites of Half-Tapes (Denotation Preserving for Every Tail)

inductive RW | splitF | splitB | merge | unpack | pack (k : ℕ) | zdrop | group (k : ℕ) | ungroup (k : ℕ) (b0 : List Sym) | rot (j : ℕ) | rotB (j : ℕ) | zins (b : List Sym)def rwLocal : RW → List Seg → Option (List Seg) | .splitF, s :: r => if 1 ≤ s.e.c then some (⟨s.b, Lin.const 1⟩ :: ⟨s.b, s.e.dec⟩ :: r) else none | .splitB, s :: r => if 1 ≤ s.e.c then some (⟨s.b, s.e.dec⟩ :: ⟨s.b, Lin.const 1⟩ :: r) else none | .merge, s1 :: s2 :: r => if s1.b == s2.b then some (⟨s1.b, s1.e.add s2.e⟩ :: r) else none | .unpack, s :: r => if s.e.isConst 1 then some (singles s.b ++ r) else none | .pack k, A => (takeSingles k A).map (fun p => ⟨p.1, Lin.const 1⟩ :: p.2) | .zdrop, s :: r => if s.e.isConst 0 then some r else none | .group k, s :: r => (s.e.div k).map (fun e' => ⟨s.b ^ k, e'⟩ :: r) | .ungroup k b0, s :: r => if s.b == b0 ^ k then some (⟨b0, s.e.scale k⟩ :: r) else none | .rot j, s1 :: s2 :: r => if s2.b == s1.b.take j && s2.e.isConst 1 then some (s2 :: ⟨s1.b.drop j ++ s1.b.take j, s1.e⟩ :: r) else none | .rotB j, s1 :: s2 :: r => if s1.e.isConst 1 && s1.b.length == j && s2.b.drop (s2.b.length - j) == s1.b then some (⟨s1.b ++ s2.b.take (s2.b.length - j), s2.e⟩ :: s1 :: r) else none | .zins b, A => some (⟨b, Lin.const 0⟩ :: A) | _, _ => nonetheorem rwLocal_sound (v : ℕ → ℕ) (rw : RW) (A A' : List Seg) (h : rwLocal rw A = some A') (t : ListBlank Sym) : hden v A t = hden v A' t := v:ℕ → ℕrw:RWA:List SegA':List Segh:rwLocal rw A = some A't:ListBlank Sym⊢ hden v A t = hden v A' t cases rw with v:ℕ → ℕA:List SegA':List Segt:ListBlank Symh:rwLocal RW.splitF A = some A'⊢ hden v A t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symh:rwLocal RW.splitF [] = some A'⊢ hden v [] t = hden v A' tv:ℕ → ℕA':List Segt:ListBlank Syms:Segr:List Segh:rwLocal RW.splitF (s :: r) = some A'⊢ hden v (s :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symh:rwLocal RW.splitF [] = some A'⊢ hden v [] t = hden v A' t All goals completed! 🐙 v:ℕ → ℕA':List Segt:ListBlank Syms:Segr:List Segh:rwLocal RW.splitF (s :: r) = some A'⊢ hden v (s :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Syms:Segr:List Segh:(if 1 ≤ s.e.c then some ({ b := s.b, e := Lin.const 1 } :: { b := s.b, e := s.e.dec } :: r) else none) = some A'⊢ hden v (s :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Syms:Segr:List Segh✝:1 ≤ s.e.ch:some ({ b := s.b, e := Lin.const 1 } :: { b := s.b, e := s.e.dec } :: r) = some A'⊢ hden v (s :: r) t = hden v A' tv:ℕ → ℕA':List Segt:ListBlank Syms:Segr:List Segh✝:¬1 ≤ s.e.ch:none = some A'⊢ hden v (s :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Syms:Segr:List Segh✝:1 ≤ s.e.ch:some ({ b := s.b, e := Lin.const 1 } :: { b := s.b, e := s.e.dec } :: r) = some A'⊢ hden v (s :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Syms:Segr:List Seghc:1 ≤ s.e.ch:some ({ b := s.b, e := Lin.const 1 } :: { b := s.b, e := s.e.dec } :: r) = some A'⊢ hden v (s :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Syms:Segr:List Seghc:1 ≤ s.e.ch:{ b := s.b, e := Lin.const 1 } :: { b := s.b, e := s.e.dec } :: r = A'⊢ hden v (s :: r) t = hden v A' t; v:ℕ → ℕt:ListBlank Syms:Segr:List Seghc:1 ≤ s.e.c⊢ hden v (s :: r) t = hden v ({ b := s.b, e := Lin.const 1 } :: { b := s.b, e := s.e.dec } :: r) t v:ℕ → ℕt:ListBlank Syms:Segr:List Seghc:1 ≤ s.e.c⊢ s.b ^ Lin.eval v s.e +> hden v r t = s.b +> s.b ^ Lin.eval v s.e.dec +> hden v r t All goals completed! 🐙 v:ℕ → ℕA':List Segt:ListBlank Syms:Segr:List Segh✝:¬1 ≤ s.e.ch:none = some A'⊢ hden v (s :: r) t = hden v A' t All goals completed! 🐙 v:ℕ → ℕA:List SegA':List Segt:ListBlank Symh:rwLocal RW.splitB A = some A'⊢ hden v A t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symh:rwLocal RW.splitB [] = some A'⊢ hden v [] t = hden v A' tv:ℕ → ℕA':List Segt:ListBlank Syms:Segr:List Segh:rwLocal RW.splitB (s :: r) = some A'⊢ hden v (s :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symh:rwLocal RW.splitB [] = some A'⊢ hden v [] t = hden v A' t All goals completed! 🐙 v:ℕ → ℕA':List Segt:ListBlank Syms:Segr:List Segh:rwLocal RW.splitB (s :: r) = some A'⊢ hden v (s :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Syms:Segr:List Segh:(if 1 ≤ s.e.c then some ({ b := s.b, e := s.e.dec } :: { b := s.b, e := Lin.const 1 } :: r) else none) = some A'⊢ hden v (s :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Syms:Segr:List Segh✝:1 ≤ s.e.ch:some ({ b := s.b, e := s.e.dec } :: { b := s.b, e := Lin.const 1 } :: r) = some A'⊢ hden v (s :: r) t = hden v A' tv:ℕ → ℕA':List Segt:ListBlank Syms:Segr:List Segh✝:¬1 ≤ s.e.ch:none = some A'⊢ hden v (s :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Syms:Segr:List Segh✝:1 ≤ s.e.ch:some ({ b := s.b, e := s.e.dec } :: { b := s.b, e := Lin.const 1 } :: r) = some A'⊢ hden v (s :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Syms:Segr:List Seghc:1 ≤ s.e.ch:some ({ b := s.b, e := s.e.dec } :: { b := s.b, e := Lin.const 1 } :: r) = some A'⊢ hden v (s :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Syms:Segr:List Seghc:1 ≤ s.e.ch:{ b := s.b, e := s.e.dec } :: { b := s.b, e := Lin.const 1 } :: r = A'⊢ hden v (s :: r) t = hden v A' t; v:ℕ → ℕt:ListBlank Syms:Segr:List Seghc:1 ≤ s.e.c⊢ hden v (s :: r) t = hden v ({ b := s.b, e := s.e.dec } :: { b := s.b, e := Lin.const 1 } :: r) t v:ℕ → ℕt:ListBlank Syms:Segr:List Seghc:1 ≤ s.e.c⊢ s.b ^ Lin.eval v s.e +> hden v r t = s.b ^ Lin.eval v s.e.dec +> s.b +> hden v r t All goals completed! 🐙 v:ℕ → ℕA':List Segt:ListBlank Syms:Segr:List Segh✝:¬1 ≤ s.e.ch:none = some A'⊢ hden v (s :: r) t = hden v A' t All goals completed! 🐙 v:ℕ → ℕA:List SegA':List Segt:ListBlank Symh:rwLocal RW.merge A = some A'⊢ hden v A t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symh:rwLocal RW.merge [] = some A'⊢ hden v [] t = hden v A' tv:ℕ → ℕA':List Segt:ListBlank Syms1:Segh:rwLocal RW.merge [s1] = some A'⊢ hden v [s1] t = hden v A' tv:ℕ → ℕA':List Segt:ListBlank Syms1:Segs2:Segr:List Segh:rwLocal RW.merge (s1 :: s2 :: r) = some A'⊢ hden v (s1 :: s2 :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symh:rwLocal RW.merge [] = some A'⊢ hden v [] t = hden v A' t All goals completed! 🐙 v:ℕ → ℕA':List Segt:ListBlank Syms1:Segh:rwLocal RW.merge [s1] = some A'⊢ hden v [s1] t = hden v A' t All goals completed! 🐙 v:ℕ → ℕA':List Segt:ListBlank Syms1:Segs2:Segr:List Segh:rwLocal RW.merge (s1 :: s2 :: r) = some A'⊢ hden v (s1 :: s2 :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Syms1:Segs2:Segr:List Segh:(if (s1.b == s2.b) = true then some ({ b := s1.b, e := s1.e.add s2.e } :: r) else none) = some A'⊢ hden v (s1 :: s2 :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Syms1:Segs2:Segr:List Segh✝:(s1.b == s2.b) = trueh:some ({ b := s1.b, e := s1.e.add s2.e } :: r) = some A'⊢ hden v (s1 :: s2 :: r) t = hden v A' tv:ℕ → ℕA':List Segt:ListBlank Syms1:Segs2:Segr:List Segh✝:¬(s1.b == s2.b) = trueh:none = some A'⊢ hden v (s1 :: s2 :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Syms1:Segs2:Segr:List Segh✝:(s1.b == s2.b) = trueh:some ({ b := s1.b, e := s1.e.add s2.e } :: r) = some A'⊢ hden v (s1 :: s2 :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Syms1:Segs2:Segr:List Seghb:(s1.b == s2.b) = trueh:some ({ b := s1.b, e := s1.e.add s2.e } :: r) = some A'⊢ hden v (s1 :: s2 :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Syms1:Segs2:Segr:List Segh:some ({ b := s1.b, e := s1.e.add s2.e } :: r) = some A'hb:s1.b = s2.b⊢ hden v (s1 :: s2 :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Syms1:Segs2:Segr:List Seghb:s1.b = s2.bh:{ b := s1.b, e := s1.e.add s2.e } :: r = A'⊢ hden v (s1 :: s2 :: r) t = hden v A' t; v:ℕ → ℕt:ListBlank Syms1:Segs2:Segr:List Seghb:s1.b = s2.b⊢ hden v (s1 :: s2 :: r) t = hden v ({ b := s1.b, e := s1.e.add s2.e } :: r) t All goals completed! 🐙 v:ℕ → ℕA':List Segt:ListBlank Syms1:Segs2:Segr:List Segh✝:¬(s1.b == s2.b) = trueh:none = some A'⊢ hden v (s1 :: s2 :: r) t = hden v A' t All goals completed! 🐙 v:ℕ → ℕA:List SegA':List Segt:ListBlank Symh:rwLocal RW.unpack A = some A'⊢ hden v A t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symh:rwLocal RW.unpack [] = some A'⊢ hden v [] t = hden v A' tv:ℕ → ℕA':List Segt:ListBlank Syms:Segr:List Segh:rwLocal RW.unpack (s :: r) = some A'⊢ hden v (s :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symh:rwLocal RW.unpack [] = some A'⊢ hden v [] t = hden v A' t All goals completed! 🐙 v:ℕ → ℕA':List Segt:ListBlank Syms:Segr:List Segh:rwLocal RW.unpack (s :: r) = some A'⊢ hden v (s :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Syms:Segr:List Segh:(if s.e.isConst 1 = true then some (singles s.b ++ r) else none) = some A'⊢ hden v (s :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Syms:Segr:List Segh✝:s.e.isConst 1 = trueh:some (singles s.b ++ r) = some A'⊢ hden v (s :: r) t = hden v A' tv:ℕ → ℕA':List Segt:ListBlank Syms:Segr:List Segh✝:¬s.e.isConst 1 = trueh:none = some A'⊢ hden v (s :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Syms:Segr:List Segh✝:s.e.isConst 1 = trueh:some (singles s.b ++ r) = some A'⊢ hden v (s :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Syms:Segr:List Seghc:s.e.isConst 1 = trueh:some (singles s.b ++ r) = some A'⊢ hden v (s :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Syms:Segr:List Seghc:s.e.isConst 1 = trueh:singles s.b ++ r = A'⊢ hden v (s :: r) t = hden v A' t; v:ℕ → ℕt:ListBlank Syms:Segr:List Seghc:s.e.isConst 1 = true⊢ hden v (s :: r) t = hden v (singles s.b ++ r) t v:ℕ → ℕt:ListBlank Syms:Segr:List Seghc:s.e.isConst 1 = true⊢ hden v (s :: r) t = s.b +> hden v r t All goals completed! 🐙 v:ℕ → ℕA':List Segt:ListBlank Syms:Segr:List Segh✝:¬s.e.isConst 1 = trueh:none = some A'⊢ hden v (s :: r) t = hden v A' t All goals completed! 🐙 v:ℕ → ℕA:List SegA':List Segt:ListBlank Symk:ℕh:rwLocal (RW.pack k) A = some A'⊢ hden v A t = hden v A' t v:ℕ → ℕA:List SegA':List Segt:ListBlank Symk:ℕh:Option.map (fun p ↦ { b := p.1, e := Lin.const 1 } :: p.2) (takeSingles k A) = some A'⊢ hden v A t = hden v A' t cases hk : takeSingles k A with v:ℕ → ℕA:List SegA':List Segt:ListBlank Symk:ℕh:Option.map (fun p ↦ { b := p.1, e := Lin.const 1 } :: p.2) (takeSingles k A) = some A'hk:takeSingles k A = none⊢ hden v A t = hden v A' t All goals completed! 🐙 v:ℕ → ℕA:List SegA':List Segt:ListBlank Symk:ℕh:Option.map (fun p ↦ { b := p.1, e := Lin.const 1 } :: p.2) (takeSingles k A) = some A'p:List Sym × List Seghk:takeSingles k A = some p⊢ hden v A t = hden v A' t v:ℕ → ℕA:List SegA':List Segt:ListBlank Symk:ℕp:List Sym × List Seghk:takeSingles k A = some ph:{ b := p.1, e := Lin.const 1 } :: p.2 = A'⊢ hden v A t = hden v A' t; v:ℕ → ℕA:List Segt:ListBlank Symk:ℕp:List Sym × List Seghk:takeSingles k A = some p⊢ hden v A t = hden v ({ b := p.1, e := Lin.const 1 } :: p.2) t v:ℕ → ℕA:List Segt:ListBlank Symk:ℕp:List Sym × List Seghk:takeSingles k A = some p⊢ p.1 +> hden v p.2 t = hden v ({ b := p.1, e := Lin.const 1 } :: p.2) t All goals completed! 🐙 v:ℕ → ℕA:List SegA':List Segt:ListBlank Symh:rwLocal RW.zdrop A = some A'⊢ hden v A t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symh:rwLocal RW.zdrop [] = some A'⊢ hden v [] t = hden v A' tv:ℕ → ℕA':List Segt:ListBlank Syms:Segr:List Segh:rwLocal RW.zdrop (s :: r) = some A'⊢ hden v (s :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symh:rwLocal RW.zdrop [] = some A'⊢ hden v [] t = hden v A' t All goals completed! 🐙 v:ℕ → ℕA':List Segt:ListBlank Syms:Segr:List Segh:rwLocal RW.zdrop (s :: r) = some A'⊢ hden v (s :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Syms:Segr:List Segh:(if s.e.isConst 0 = true then some r else none) = some A'⊢ hden v (s :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Syms:Segr:List Segh✝:s.e.isConst 0 = trueh:some r = some A'⊢ hden v (s :: r) t = hden v A' tv:ℕ → ℕA':List Segt:ListBlank Syms:Segr:List Segh✝:¬s.e.isConst 0 = trueh:none = some A'⊢ hden v (s :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Syms:Segr:List Segh✝:s.e.isConst 0 = trueh:some r = some A'⊢ hden v (s :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Syms:Segr:List Seghc:s.e.isConst 0 = trueh:some r = some A'⊢ hden v (s :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Syms:Segr:List Seghc:s.e.isConst 0 = trueh:r = A'⊢ hden v (s :: r) t = hden v A' t; v:ℕ → ℕt:ListBlank Syms:Segr:List Seghc:s.e.isConst 0 = true⊢ hden v (s :: r) t = hden v r t All goals completed! 🐙 v:ℕ → ℕA':List Segt:ListBlank Syms:Segr:List Segh✝:¬s.e.isConst 0 = trueh:none = some A'⊢ hden v (s :: r) t = hden v A' t All goals completed! 🐙 v:ℕ → ℕA:List SegA':List Segt:ListBlank Symk:ℕh:rwLocal (RW.group k) A = some A'⊢ hden v A t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symk:ℕh:rwLocal (RW.group k) [] = some A'⊢ hden v [] t = hden v A' tv:ℕ → ℕA':List Segt:ListBlank Symk:ℕs:Segr:List Segh:rwLocal (RW.group k) (s :: r) = some A'⊢ hden v (s :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symk:ℕh:rwLocal (RW.group k) [] = some A'⊢ hden v [] t = hden v A' t All goals completed! 🐙 v:ℕ → ℕA':List Segt:ListBlank Symk:ℕs:Segr:List Segh:rwLocal (RW.group k) (s :: r) = some A'⊢ hden v (s :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symk:ℕs:Segr:List Segh:Option.map (fun e' ↦ { b := s.b ^ k, e := e' } :: r) (Lin.div k s.e) = some A'⊢ hden v (s :: r) t = hden v A' t cases hd : s.e.div k with v:ℕ → ℕA':List Segt:ListBlank Symk:ℕs:Segr:List Segh:Option.map (fun e' ↦ { b := s.b ^ k, e := e' } :: r) (Lin.div k s.e) = some A'hd:Lin.div k s.e = none⊢ hden v (s :: r) t = hden v A' t All goals completed! 🐙 v:ℕ → ℕA':List Segt:ListBlank Symk:ℕs:Segr:List Segh:Option.map (fun e' ↦ { b := s.b ^ k, e := e' } :: r) (Lin.div k s.e) = some A'e':Linhd:Lin.div k s.e = some e'⊢ hden v (s :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symk:ℕs:Segr:List Sege':Linhd:Lin.div k s.e = some e'h:{ b := s.b ^ k, e := e' } :: r = A'⊢ hden v (s :: r) t = hden v A' t; v:ℕ → ℕt:ListBlank Symk:ℕs:Segr:List Sege':Linhd:Lin.div k s.e = some e'⊢ hden v (s :: r) t = hden v ({ b := s.b ^ k, e := e' } :: r) t All goals completed! 🐙 v:ℕ → ℕA:List SegA':List Segt:ListBlank Symk:ℕb0:List Symh:rwLocal (RW.ungroup k b0) A = some A'⊢ hden v A t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symk:ℕb0:List Symh:rwLocal (RW.ungroup k b0) [] = some A'⊢ hden v [] t = hden v A' tv:ℕ → ℕA':List Segt:ListBlank Symk:ℕb0:List Syms:Segr:List Segh:rwLocal (RW.ungroup k b0) (s :: r) = some A'⊢ hden v (s :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symk:ℕb0:List Symh:rwLocal (RW.ungroup k b0) [] = some A'⊢ hden v [] t = hden v A' t All goals completed! 🐙 v:ℕ → ℕA':List Segt:ListBlank Symk:ℕb0:List Syms:Segr:List Segh:rwLocal (RW.ungroup k b0) (s :: r) = some A'⊢ hden v (s :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symk:ℕb0:List Syms:Segr:List Segh:(if (s.b == b0 ^ k) = true then some ({ b := b0, e := Lin.scale k s.e } :: r) else none) = some A'⊢ hden v (s :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symk:ℕb0:List Syms:Segr:List Segh✝:(s.b == b0 ^ k) = trueh:some ({ b := b0, e := Lin.scale k s.e } :: r) = some A'⊢ hden v (s :: r) t = hden v A' tv:ℕ → ℕA':List Segt:ListBlank Symk:ℕb0:List Syms:Segr:List Segh✝:¬(s.b == b0 ^ k) = trueh:none = some A'⊢ hden v (s :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symk:ℕb0:List Syms:Segr:List Segh✝:(s.b == b0 ^ k) = trueh:some ({ b := b0, e := Lin.scale k s.e } :: r) = some A'⊢ hden v (s :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symk:ℕb0:List Syms:Segr:List Seghb:(s.b == b0 ^ k) = trueh:some ({ b := b0, e := Lin.scale k s.e } :: r) = some A'⊢ hden v (s :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symk:ℕb0:List Syms:Segr:List Segh:some ({ b := b0, e := Lin.scale k s.e } :: r) = some A'hb:s.b = b0 ^ k⊢ hden v (s :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symk:ℕb0:List Syms:Segr:List Seghb:s.b = b0 ^ kh:{ b := b0, e := Lin.scale k s.e } :: r = A'⊢ hden v (s :: r) t = hden v A' t; v:ℕ → ℕt:ListBlank Symk:ℕb0:List Syms:Segr:List Seghb:s.b = b0 ^ k⊢ hden v (s :: r) t = hden v ({ b := b0, e := Lin.scale k s.e } :: r) t All goals completed! 🐙 v:ℕ → ℕA':List Segt:ListBlank Symk:ℕb0:List Syms:Segr:List Segh✝:¬(s.b == b0 ^ k) = trueh:none = some A'⊢ hden v (s :: r) t = hden v A' t All goals completed! 🐙 v:ℕ → ℕA:List SegA':List Segt:ListBlank Symj:ℕh:rwLocal (RW.rot j) A = some A'⊢ hden v A t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symj:ℕh:rwLocal (RW.rot j) [] = some A'⊢ hden v [] t = hden v A' tv:ℕ → ℕA':List Segt:ListBlank Symj:ℕs1:Segh:rwLocal (RW.rot j) [s1] = some A'⊢ hden v [s1] t = hden v A' tv:ℕ → ℕA':List Segt:ListBlank Symj:ℕs1:Segs2:Segr:List Segh:rwLocal (RW.rot j) (s1 :: s2 :: r) = some A'⊢ hden v (s1 :: s2 :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symj:ℕh:rwLocal (RW.rot j) [] = some A'⊢ hden v [] t = hden v A' t All goals completed! 🐙 v:ℕ → ℕA':List Segt:ListBlank Symj:ℕs1:Segh:rwLocal (RW.rot j) [s1] = some A'⊢ hden v [s1] t = hden v A' t All goals completed! 🐙 v:ℕ → ℕA':List Segt:ListBlank Symj:ℕs1:Segs2:Segr:List Segh:rwLocal (RW.rot j) (s1 :: s2 :: r) = some A'⊢ hden v (s1 :: s2 :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symj:ℕs1:Segs2:Segr:List Segh:(if (s2.b == List.take j s1.b && s2.e.isConst 1) = true then some (s2 :: { b := List.drop j s1.b ++ List.take j s1.b, e := s1.e } :: r) else none) = some A'⊢ hden v (s1 :: s2 :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symj:ℕs1:Segs2:Segr:List Segh✝:(s2.b == List.take j s1.b && s2.e.isConst 1) = trueh:some (s2 :: { b := List.drop j s1.b ++ List.take j s1.b, e := s1.e } :: r) = some A'⊢ hden v (s1 :: s2 :: r) t = hden v A' tv:ℕ → ℕA':List Segt:ListBlank Symj:ℕs1:Segs2:Segr:List Segh✝:¬(s2.b == List.take j s1.b && s2.e.isConst 1) = trueh:none = some A'⊢ hden v (s1 :: s2 :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symj:ℕs1:Segs2:Segr:List Segh✝:(s2.b == List.take j s1.b && s2.e.isConst 1) = trueh:some (s2 :: { b := List.drop j s1.b ++ List.take j s1.b, e := s1.e } :: r) = some A'⊢ hden v (s1 :: s2 :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symj:ℕs1:Segs2:Segr:List Seghc:(s2.b == List.take j s1.b && s2.e.isConst 1) = trueh:some (s2 :: { b := List.drop j s1.b ++ List.take j s1.b, e := s1.e } :: r) = some A'⊢ hden v (s1 :: s2 :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symj:ℕs1:Segs2:Segr:List Segh:some (s2 :: { b := List.drop j s1.b ++ List.take j s1.b, e := s1.e } :: r) = some A'hc:s2.b = List.take j s1.b ∧ s2.e.isConst 1 = true⊢ hden v (s1 :: s2 :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symj:ℕs1:Segs2:Segr:List Seghc:s2.b = List.take j s1.b ∧ s2.e.isConst 1 = trueh:s2 :: { b := List.drop j s1.b ++ List.take j s1.b, e := s1.e } :: r = A'⊢ hden v (s1 :: s2 :: r) t = hden v A' t; v:ℕ → ℕt:ListBlank Symj:ℕs1:Segs2:Segr:List Seghc:s2.b = List.take j s1.b ∧ s2.e.isConst 1 = true⊢ hden v (s1 :: s2 :: r) t = hden v (s2 :: { b := List.drop j s1.b ++ List.take j s1.b, e := s1.e } :: r) t v:ℕ → ℕt:ListBlank Symj:ℕs1:Segs2:Segr:List Seghc:s2.b = List.take j s1.b ∧ s2.e.isConst 1 = true⊢ s1.b ^ Lin.eval v s1.e +> List.take j s1.b +> hden v r t = List.take j s1.b +> (List.drop j s1.b ++ List.take j s1.b) ^ Lin.eval v s1.e +> hden v r t v:ℕ → ℕt:ListBlank Symj:ℕs1:Segs2:Segr:List Seghc:s2.b = List.take j s1.b ∧ s2.e.isConst 1 = true⊢ (s1.b ^ Lin.eval v s1.e ++ List.take j s1.b) +> hden v r t = (List.take j s1.b ++ (List.drop j s1.b ++ List.take j s1.b) ^ Lin.eval v s1.e) +> hden v r t v:ℕ → ℕt:ListBlank Symj:ℕs1:Segs2:Segr:List Seghc:s2.b = List.take j s1.b ∧ s2.e.isConst 1 = truekey:(List.take j s1.b ++ List.drop j s1.b) ^ Lin.eval v s1.e ++ List.take j s1.b = List.take j s1.b ++ (List.drop j s1.b ++ List.take j s1.b) ^ Lin.eval v s1.e⊢ (s1.b ^ Lin.eval v s1.e ++ List.take j s1.b) +> hden v r t = (List.take j s1.b ++ (List.drop j s1.b ++ List.take j s1.b) ^ Lin.eval v s1.e) +> hden v r t v:ℕ → ℕt:ListBlank Symj:ℕs1:Segs2:Segr:List Seghc:s2.b = List.take j s1.b ∧ s2.e.isConst 1 = truekey:s1.b ^ Lin.eval v s1.e ++ List.take j s1.b = List.take j s1.b ++ (List.drop j s1.b ++ List.take j s1.b) ^ Lin.eval v s1.e⊢ (s1.b ^ Lin.eval v s1.e ++ List.take j s1.b) +> hden v r t = (List.take j s1.b ++ (List.drop j s1.b ++ List.take j s1.b) ^ Lin.eval v s1.e) +> hden v r t All goals completed! 🐙 v:ℕ → ℕA':List Segt:ListBlank Symj:ℕs1:Segs2:Segr:List Segh✝:¬(s2.b == List.take j s1.b && s2.e.isConst 1) = trueh:none = some A'⊢ hden v (s1 :: s2 :: r) t = hden v A' t All goals completed! 🐙 v:ℕ → ℕA:List SegA':List Segt:ListBlank Symj:ℕh:rwLocal (RW.rotB j) A = some A'⊢ hden v A t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symj:ℕh:rwLocal (RW.rotB j) [] = some A'⊢ hden v [] t = hden v A' tv:ℕ → ℕA':List Segt:ListBlank Symj:ℕs1:Segh:rwLocal (RW.rotB j) [s1] = some A'⊢ hden v [s1] t = hden v A' tv:ℕ → ℕA':List Segt:ListBlank Symj:ℕs1:Segs2:Segr:List Segh:rwLocal (RW.rotB j) (s1 :: s2 :: r) = some A'⊢ hden v (s1 :: s2 :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symj:ℕh:rwLocal (RW.rotB j) [] = some A'⊢ hden v [] t = hden v A' t All goals completed! 🐙 v:ℕ → ℕA':List Segt:ListBlank Symj:ℕs1:Segh:rwLocal (RW.rotB j) [s1] = some A'⊢ hden v [s1] t = hden v A' t All goals completed! 🐙 v:ℕ → ℕA':List Segt:ListBlank Symj:ℕs1:Segs2:Segr:List Segh:rwLocal (RW.rotB j) (s1 :: s2 :: r) = some A'⊢ hden v (s1 :: s2 :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symj:ℕs1:Segs2:Segr:List Segh:(if (s1.e.isConst 1 && s1.b.length == j && List.drop (s2.b.length - j) s2.b == s1.b) = true then some ({ b := s1.b ++ List.take (s2.b.length - j) s2.b, e := s2.e } :: s1 :: r) else none) = some A'⊢ hden v (s1 :: s2 :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symj:ℕs1:Segs2:Segr:List Segh✝:(s1.e.isConst 1 && s1.b.length == j && List.drop (s2.b.length - j) s2.b == s1.b) = trueh:some ({ b := s1.b ++ List.take (s2.b.length - j) s2.b, e := s2.e } :: s1 :: r) = some A'⊢ hden v (s1 :: s2 :: r) t = hden v A' tv:ℕ → ℕA':List Segt:ListBlank Symj:ℕs1:Segs2:Segr:List Segh✝:¬(s1.e.isConst 1 && s1.b.length == j && List.drop (s2.b.length - j) s2.b == s1.b) = trueh:none = some A'⊢ hden v (s1 :: s2 :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symj:ℕs1:Segs2:Segr:List Segh✝:(s1.e.isConst 1 && s1.b.length == j && List.drop (s2.b.length - j) s2.b == s1.b) = trueh:some ({ b := s1.b ++ List.take (s2.b.length - j) s2.b, e := s2.e } :: s1 :: r) = some A'⊢ hden v (s1 :: s2 :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symj:ℕs1:Segs2:Segr:List Seghc:(s1.e.isConst 1 && s1.b.length == j && List.drop (s2.b.length - j) s2.b == s1.b) = trueh:some ({ b := s1.b ++ List.take (s2.b.length - j) s2.b, e := s2.e } :: s1 :: r) = some A'⊢ hden v (s1 :: s2 :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symj:ℕs1:Segs2:Segr:List Segh:some ({ b := s1.b ++ List.take (s2.b.length - j) s2.b, e := s2.e } :: s1 :: r) = some A'hc:(s1.e.isConst 1 = true ∧ s1.b.length = j) ∧ List.drop (s2.b.length - j) s2.b = s1.b⊢ hden v (s1 :: s2 :: r) t = hden v A' t v:ℕ → ℕA':List Segt:ListBlank Symj:ℕs1:Segs2:Segr:List Seghc:(s1.e.isConst 1 = true ∧ s1.b.length = j) ∧ List.drop (s2.b.length - j) s2.b = s1.bh:{ b := s1.b ++ List.take (s2.b.length - j) s2.b, e := s2.e } :: s1 :: r = A'⊢ hden v (s1 :: s2 :: r) t = hden v A' t; v:ℕ → ℕt:ListBlank Symj:ℕs1:Segs2:Segr:List Seghc:(s1.e.isConst 1 = true ∧ s1.b.length = j) ∧ List.drop (s2.b.length - j) s2.b = s1.b⊢ hden v (s1 :: s2 :: r) t = hden v ({ b := s1.b ++ List.take (s2.b.length - j) s2.b, e := s2.e } :: s1 :: r) t v:ℕ → ℕt:ListBlank Symj:ℕs1:Segs2:Segr:List Seghc:(s1.e.isConst 1 = true ∧ s1.b.length = j) ∧ List.drop (s2.b.length - j) s2.b = s1.b⊢ s1.b +> s2.b ^ Lin.eval v s2.e +> hden v r t = (s1.b ++ List.take (s2.b.length - j) s2.b) ^ Lin.eval v s2.e +> s1.b +> hden v r t v:ℕ → ℕt:ListBlank Symj:ℕs1:Segs2:Segr:List Seghc:(s1.e.isConst 1 = true ∧ s1.b.length = j) ∧ List.drop (s2.b.length - j) s2.b = s1.b⊢ (s1.b ++ s2.b ^ Lin.eval v s2.e) +> hden v r t = ((s1.b ++ List.take (s2.b.length - j) s2.b) ^ Lin.eval v s2.e ++ s1.b) +> hden v r t v:ℕ → ℕt:ListBlank Symj:ℕs1:Segs2:Segr:List Seghc:(s1.e.isConst 1 = true ∧ s1.b.length = j) ∧ List.drop (s2.b.length - j) s2.b = s1.bhb:s2.b = List.take (s2.b.length - j) s2.b ++ s1.b⊢ (s1.b ++ s2.b ^ Lin.eval v s2.e) +> hden v r t = ((s1.b ++ List.take (s2.b.length - j) s2.b) ^ Lin.eval v s2.e ++ s1.b) +> hden v r t All goals completed! 🐙 v:ℕ → ℕA':List Segt:ListBlank Symj:ℕs1:Segs2:Segr:List Segh✝:¬(s1.e.isConst 1 && s1.b.length == j && List.drop (s2.b.length - j) s2.b == s1.b) = trueh:none = some A'⊢ hden v (s1 :: s2 :: r) t = hden v A' t All goals completed! 🐙 v:ℕ → ℕA:List SegA':List Segt:ListBlank Symb:List Symh:rwLocal (RW.zins b) A = some A'⊢ hden v A t = hden v A' t v:ℕ → ℕA:List SegA':List Segt:ListBlank Symb:List Symh:{ b := b, e := Lin.const 0 } :: A = A'⊢ hden v A t = hden v A' t; v:ℕ → ℕA:List Segt:ListBlank Symb:List Sym⊢ hden v A t = hden v ({ b := b, e := Lin.const 0 } :: A) t All goals completed! 🐙def rwAt (rw : RW) : ℕ → List Seg → Option (List Seg) | 0, A => rwLocal rw A | p + 1, s :: A => (rwAt rw p A).map (s :: ·) | _ + 1, [] => nonetheorem rwAt_sound (v : ℕ → ℕ) (rw : RW) : ∀ (p : ℕ) (A A' : List Seg), rwAt rw p A = some A' → ∀ t, hden v A t = hden v A' t | 0, A, A', h, t => rwLocal_sound v rw A A' h t v:ℕ → ℕrw:RWp:ℕA':List Segh:rwAt rw (p + 1) [] = some A't:ListBlank Sym⊢ hden v [] t = hden v A' t v:ℕ → ℕrw:RWp:ℕA':List Segh:rwAt rw (p + 1) [] = some A't:ListBlank Sym⊢ hden v [] t = hden v A' t All goals completed! 🐙 v:ℕ → ℕrw:RWp:ℕs:SegA:List SegA':List Segh:rwAt rw (p + 1) (s :: A) = some A't:ListBlank Sym⊢ hden v (s :: A) t = hden v A' t v:ℕ → ℕrw:RWp:ℕs:SegA:List SegA':List Segh:rwAt rw (p + 1) (s :: A) = some A't:ListBlank Sym⊢ hden v (s :: A) t = hden v A' t v:ℕ → ℕrw:RWp:ℕs:SegA:List SegA':List Segh:Option.map (fun x ↦ s :: x) (rwAt rw p A) = some A't:ListBlank Sym⊢ hden v (s :: A) t = hden v A' t cases hp : rwAt rw p A with v:ℕ → ℕrw:RWp:ℕs:SegA:List SegA':List Segh:Option.map (fun x ↦ s :: x) (rwAt rw p A) = some A't:ListBlank Symhp:rwAt rw p A = none⊢ hden v (s :: A) t = hden v A' t All goals completed! 🐙 v:ℕ → ℕrw:RWp:ℕs:SegA:List SegA':List Segh:Option.map (fun x ↦ s :: x) (rwAt rw p A) = some A't:ListBlank SymB:List Seghp:rwAt rw p A = some B⊢ hden v (s :: A) t = hden v A' t v:ℕ → ℕrw:RWp:ℕs:SegA:List SegA':List Segt:ListBlank SymB:List Seghp:rwAt rw p A = some Bh:s :: B = A'⊢ hden v (s :: A) t = hden v A' t; v:ℕ → ℕrw:RWp:ℕs:SegA:List Segt:ListBlank SymB:List Seghp:rwAt rw p A = some B⊢ hden v (s :: A) t = hden v (s :: B) t All goals completed! 🐙def dropTail (A : List Seg) : Option (List Seg) := match A.getLast? with | some s => if s.b.all (· == 0) then some A.dropLast else none | none => nonetheorem dropTail_sound (v : ℕ → ℕ) (A A' : List Seg) (h : dropTail A = some A') : hden v A default = hden v A' default := v:ℕ → ℕA:List SegA':List Segh:dropTail A = some A'⊢ hden v A default = hden v A' default v:ℕ → ℕA:List SegA':List Segh:(match A.getLast? with | some s => if (s.b.all fun x ↦ x == 0) = true then some A.dropLast else none | none => none) = some A'⊢ hden v A default = hden v A' default cases hl : A.getLast? with v:ℕ → ℕA:List SegA':List Segh:(match A.getLast? with | some s => if (s.b.all fun x ↦ x == 0) = true then some A.dropLast else none | none => none) = some A'hl:A.getLast? = none⊢ hden v A default = hden v A' default All goals completed! 🐙 v:ℕ → ℕA:List SegA':List Segh:(match A.getLast? with | some s => if (s.b.all fun x ↦ x == 0) = true then some A.dropLast else none | none => none) = some A's:Seghl:A.getLast? = some s⊢ hden v A default = hden v A' default v:ℕ → ℕA:List SegA':List Segs:Seghl:A.getLast? = some sh:(if (s.b.all fun x ↦ x == 0) = true then some A.dropLast else none) = some A'⊢ hden v A default = hden v A' default v:ℕ → ℕA:List SegA':List Segs:Seghl:A.getLast? = some sh✝:(s.b.all fun x ↦ x == 0) = trueh:some A.dropLast = some A'⊢ hden v A default = hden v A' defaultv:ℕ → ℕA:List SegA':List Segs:Seghl:A.getLast? = some sh✝:¬(s.b.all fun x ↦ x == 0) = trueh:none = some A'⊢ hden v A default = hden v A' default v:ℕ → ℕA:List SegA':List Segs:Seghl:A.getLast? = some sh✝:(s.b.all fun x ↦ x == 0) = trueh:some A.dropLast = some A'⊢ hden v A default = hden v A' default v:ℕ → ℕA:List SegA':List Segs:Seghl:A.getLast? = some shz:(s.b.all fun x ↦ x == 0) = trueh:some A.dropLast = some A'⊢ hden v A default = hden v A' default v:ℕ → ℕA:List SegA':List Segs:Seghl:A.getLast? = some shz:(s.b.all fun x ↦ x == 0) = trueh:A.dropLast = A'⊢ hden v A default = hden v A' default; v:ℕ → ℕA:List Segs:Seghl:A.getLast? = some shz:(s.b.all fun x ↦ x == 0) = true⊢ hden v A default = hden v A.dropLast default v:ℕ → ℕA:List Segs:Seghl:A.getLast? = some shz:(s.b.all fun x ↦ x == 0) = truehA:A = A.dropLast ++ [s]⊢ hden v A default = hden v A.dropLast default conv_lhs => v:ℕ → ℕA:List Segs:Seghl:A.getLast? = some shz:(s.b.all fun x ↦ x == 0) = truehA:A = A.dropLast ++ [s]| hden v (A.dropLast ++ [s]) default v:ℕ → ℕA:List Segs:Seghl:A.getLast? = some shz:(s.b.all fun x ↦ x == 0) = truehA:A = A.dropLast ++ [s]⊢ hden v A.dropLast (hden v [s] default) = hden v A.dropLast default v:ℕ → ℕA:List Segs:Seghl:A.getLast? = some shz:(s.b.all fun x ↦ x == 0) = truehA:A = A.dropLast ++ [s]⊢ hden v [s] default = default v:ℕ → ℕA:List Segs:Seghl:A.getLast? = some shz:(s.b.all fun x ↦ x == 0) = truehA:A = A.dropLast ++ [s]⊢ s.b ^ Lin.eval v s.e +> default = default v:ℕ → ℕA:List Segs:Seghl:A.getLast? = some shz:(s.b.all fun x ↦ x == 0) = truehA:A = A.dropLast ++ [s]⊢ ∀ x ∈ s.b, x = 0 v:ℕ → ℕA:List Segs:Seghl:A.getLast? = some shz:(s.b.all fun x ↦ x == 0) = truehA:A = A.dropLast ++ [s]x:Symhx:x ∈ s.b⊢ x = 0 v:ℕ → ℕA:List Segs:Seghl:A.getLast? = some shz:(s.b.all fun x ↦ x == 0) = truehA:A = A.dropLast ++ [s]x:Symhx:x ∈ s.bthis:(x == 0) = true⊢ x = 0 All goals completed! 🐙 v:ℕ → ℕA:List SegA':List Segs:Seghl:A.getLast? = some sh✝:¬(s.b.all fun x ↦ x == 0) = trueh:none = some A'⊢ hden v A default = hden v A' default All goals completed! 🐙

Symbolic Configurations, Concrete Steps and Block Shifts

structure SC where q : St dr : Bool L : List Seg R : List Seg

dr = true: head reads the first cell of R (L q> R); dr = false: head reads the first cell of L (L <q R).

def cfgOf (q : St) (dr : Bool) (Lt Rt : ListBlank Sym) : Cfg Sym St := if dr then ⟨some q, ⟨Rt.head, Lt, Rt.tail⟩⟩ else ⟨some q, ⟨Lt.head, Lt.tail, Rt⟩⟩def SC.den (c : SC) (v : ℕ → ℕ) (tl tr : ListBlank Sym) : Cfg Sym St := cfgOf c.q c.dr (hden v c.L tl) (hden v c.R tr)def SC.subst (i : ℕ) (f : Lin) (c : SC) : SC := ⟨c.q, c.dr, sideSubst i f c.L, sideSubst i f c.R⟩def SC.substAll (σ : List Lin) (c : SC) : SC := ⟨c.q, c.dr, sideSubstAll σ c.L, sideSubstAll σ c.R⟩theorem SC.den_subst (c : SC) (i : ℕ) (f : Lin) (v : ℕ → ℕ) (tl tr : ListBlank Sym) : (c.subst i f).den v tl tr = c.den (Function.update v i (f.eval v)) tl tr := c:SCi:ℕf:Linv:ℕ → ℕtl:ListBlank Symtr:ListBlank Sym⊢ (subst i f c).den v tl tr = c.den (Function.update v i (Lin.eval v f)) tl tr All goals completed! 🐙theorem SC.den_substAll (c : SC) (σ : List Lin) (v : ℕ → ℕ) (tl tr : ListBlank Sym) : (c.substAll σ).den v tl tr = c.den (sem σ v) tl tr := c:SCσ:List Linv:ℕ → ℕtl:ListBlank Symtr:ListBlank Sym⊢ (substAll σ c).den v tl tr = c.den (sem σ v) tl tr All goals completed! 🐙def SC.beq (a b : SC) : Bool := a.q == b.q && a.dr == b.dr && sideEq a.L b.L && sideEq a.R b.Rtheorem SC.beq_sound (a b : SC) (h : a.beq b = true) (v : ℕ → ℕ) (tl tr : ListBlank Sym) : a.den v tl tr = b.den v tl tr := a:SCb:SCh:a.beq b = truev:ℕ → ℕtl:ListBlank Symtr:ListBlank Sym⊢ a.den v tl tr = b.den v tl tr a:SCb:SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symh:((a.q = b.q ∧ a.dr = b.dr) ∧ sideEq a.L b.L = true) ∧ sideEq a.R b.R = true⊢ a.den v tl tr = b.den v tl tr All goals completed! 🐙def popHead (dflt : Bool) : List Seg → Option (Sym × List Seg) | [] => if dflt then some (0, []) else none | s :: r => match s.b with | [x] => if s.e.isConst 1 then some (x, r) else none | _ => nonetheorem popHead_sound (dflt : Bool) (A : List Seg) (x : Sym) (r : List Seg) (h : popHead dflt A = some (x, r)) (v : ℕ → ℕ) (t : ListBlank Sym) (ht : dflt = true → t = default) : hden v A t = ListBlank.cons x (hden v r t) := dflt:BoolA:List Segx:Symr:List Segh:popHead dflt A = some (x, r)v:ℕ → ℕt:ListBlank Symht:dflt = true → t = default⊢ hden v A t = x >> hden v r t dflt:Boolx:Symr:List Segv:ℕ → ℕt:ListBlank Symht:dflt = true → t = defaulth:popHead dflt [] = some (x, r)⊢ hden v [] t = x >> hden v r tdflt:Boolx:Symr:List Segv:ℕ → ℕt:ListBlank Symht:dflt = true → t = defaultA:List Segb:List Syme:Linh:popHead dflt ({ b := b, e := e } :: A) = some (x, r)⊢ hden v ({ b := b, e := e } :: A) t = x >> hden v r t dflt:Boolx:Symr:List Segv:ℕ → ℕt:ListBlank Symht:dflt = true → t = defaulth:popHead dflt [] = some (x, r)⊢ hden v [] t = x >> hden v r t dflt:Boolx:Symr:List Segv:ℕ → ℕt:ListBlank Symht:dflt = true → t = defaulth:(if dflt = true then some (0, []) else none) = some (x, r)⊢ hden v [] t = x >> hden v r t dflt:Boolx:Symr:List Segv:ℕ → ℕt:ListBlank Symht:dflt = true → t = defaulth✝:dflt = trueh:some (0, []) = some (x, r)⊢ hden v [] t = x >> hden v r tdflt:Boolx:Symr:List Segv:ℕ → ℕt:ListBlank Symht:dflt = true → t = defaulth✝:¬dflt = trueh:none = some (x, r)⊢ hden v [] t = x >> hden v r t dflt:Boolx:Symr:List Segv:ℕ → ℕt:ListBlank Symht:dflt = true → t = defaulth✝:dflt = trueh:some (0, []) = some (x, r)⊢ hden v [] t = x >> hden v r t dflt:Boolx:Symr:List Segv:ℕ → ℕt:ListBlank Symht:dflt = true → t = defaulthd:dflt = trueh:some (0, []) = some (x, r)⊢ hden v [] t = x >> hden v r t dflt:Boolx:Symr:List Segv:ℕ → ℕt:ListBlank Symht:dflt = true → t = defaulthd:dflt = trueh:0 = x ∧ [] = r⊢ hden v [] t = x >> hden v r t dflt:Boolx:Symr:List Segv:ℕ → ℕt:ListBlank Symht:dflt = true → t = defaulthd:dflt = trueh:0 = x ∧ [] = r⊢ hden v [] t = 0 >> hden v [] t All goals completed! 🐙 dflt:Boolx:Symr:List Segv:ℕ → ℕt:ListBlank Symht:dflt = true → t = defaulth✝:¬dflt = trueh:none = some (x, r)⊢ hden v [] t = x >> hden v r t All goals completed! 🐙 dflt:Boolx:Symr:List Segv:ℕ → ℕt:ListBlank Symht:dflt = true → t = defaultA:List Segb:List Syme:Linh:popHead dflt ({ b := b, e := e } :: A) = some (x, r)⊢ hden v ({ b := b, e := e } :: A) t = x >> hden v r t dflt:Boolx:Symr:List Segv:ℕ → ℕt:ListBlank Symht:dflt = true → t = defaultA:List Sege:Linh:popHead dflt ({ b := [], e := e } :: A) = some (x, r)⊢ hden v ({ b := [], e := e } :: A) t = x >> hden v r tdflt:Boolx:Symr:List Segv:ℕ → ℕt:ListBlank Symht:dflt = true → t = defaultA:List Sege:Liny:Symh:popHead dflt ({ b := [y], e := e } :: A) = some (x, r)⊢ hden v ({ b := [y], e := e } :: A) t = x >> hden v r tdflt:Boolx:Symr:List Segv:ℕ → ℕt:ListBlank Symht:dflt = true → t = defaultA:List Sege:Liny:Symz:Symb:List Symh:popHead dflt ({ b := y :: z :: b, e := e } :: A) = some (x, r)⊢ hden v ({ b := y :: z :: b, e := e } :: A) t = x >> hden v r t dflt:Boolx:Symr:List Segv:ℕ → ℕt:ListBlank Symht:dflt = true → t = defaultA:List Sege:Linh:popHead dflt ({ b := [], e := e } :: A) = some (x, r)⊢ hden v ({ b := [], e := e } :: A) t = x >> hden v r t All goals completed! 🐙 dflt:Boolx:Symr:List Segv:ℕ → ℕt:ListBlank Symht:dflt = true → t = defaultA:List Sege:Liny:Symh:popHead dflt ({ b := [y], e := e } :: A) = some (x, r)⊢ hden v ({ b := [y], e := e } :: A) t = x >> hden v r t dflt:Boolx:Symr:List Segv:ℕ → ℕt:ListBlank Symht:dflt = true → t = defaultA:List Sege:Liny:Symh:(if e.isConst 1 = true then some (y, A) else none) = some (x, r)⊢ hden v ({ b := [y], e := e } :: A) t = x >> hden v r t dflt:Boolx:Symr:List Segv:ℕ → ℕt:ListBlank Symht:dflt = true → t = defaultA:List Sege:Liny:Symh✝:e.isConst 1 = trueh:some (y, A) = some (x, r)⊢ hden v ({ b := [y], e := e } :: A) t = x >> hden v r tdflt:Boolx:Symr:List Segv:ℕ → ℕt:ListBlank Symht:dflt = true → t = defaultA:List Sege:Liny:Symh✝:¬e.isConst 1 = trueh:none = some (x, r)⊢ hden v ({ b := [y], e := e } :: A) t = x >> hden v r t dflt:Boolx:Symr:List Segv:ℕ → ℕt:ListBlank Symht:dflt = true → t = defaultA:List Sege:Liny:Symh✝:e.isConst 1 = trueh:some (y, A) = some (x, r)⊢ hden v ({ b := [y], e := e } :: A) t = x >> hden v r t dflt:Boolx:Symr:List Segv:ℕ → ℕt:ListBlank Symht:dflt = true → t = defaultA:List Sege:Liny:Symhe:e.isConst 1 = trueh:some (y, A) = some (x, r)⊢ hden v ({ b := [y], e := e } :: A) t = x >> hden v r t dflt:Boolx:Symr:List Segv:ℕ → ℕt:ListBlank Symht:dflt = true → t = defaultA:List Sege:Liny:Symhe:e.isConst 1 = trueh:y = x ∧ A = r⊢ hden v ({ b := [y], e := e } :: A) t = x >> hden v r t dflt:Boolx:Symr:List Segv:ℕ → ℕt:ListBlank Symht:dflt = true → t = defaultA:List Sege:Liny:Symhe:e.isConst 1 = trueh:y = x ∧ A = r⊢ hden v ({ b := [y], e := e } :: A) t = y >> hden v A t All goals completed! 🐙 dflt:Boolx:Symr:List Segv:ℕ → ℕt:ListBlank Symht:dflt = true → t = defaultA:List Sege:Liny:Symh✝:¬e.isConst 1 = trueh:none = some (x, r)⊢ hden v ({ b := [y], e := e } :: A) t = x >> hden v r t All goals completed! 🐙 dflt:Boolx:Symr:List Segv:ℕ → ℕt:ListBlank Symht:dflt = true → t = defaultA:List Sege:Liny:Symz:Symb:List Symh:popHead dflt ({ b := y :: z :: b, e := e } :: A) = some (x, r)⊢ hden v ({ b := y :: z :: b, e := e } :: A) t = x >> hden v r t All goals completed! 🐙def symStep (M : TM) (dflt : Bool) (c : SC) : Option SC := if c.dr then match popHead dflt c.R with | some (x, r) => match M c.q x with | some (some q', Stmt.write w Dir.right) => some ⟨q', true, ⟨[w], Lin.const 1⟩ :: c.L, r⟩ | some (some q', Stmt.write w Dir.left) => some ⟨q', false, c.L, ⟨[w], Lin.const 1⟩ :: r⟩ | _ => none | none => none else match popHead dflt c.L with | some (x, l) => match M c.q x with | some (some q', Stmt.write w Dir.right) => some ⟨q', true, ⟨[w], Lin.const 1⟩ :: l, c.R⟩ | some (some q', Stmt.write w Dir.left) => some ⟨q', false, l, ⟨[w], Lin.const 1⟩ :: c.R⟩ | _ => none | none => nonetheorem symStep_sound (M : TM) (dflt : Bool) (c c' : SC) (h : symStep M dflt c = some c') (v : ℕ → ℕ) (tl tr : ListBlank Sym) (ht : dflt = true → tl = default ∧ tr = default) : step M (c.den v tl tr) = some (c'.den v tl tr) := M:TMdflt:Boolc:SCc':SCh:symStep M dflt c = some c'v:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = default⊢ c.den v tl tr [M]⊢ c'.den v tl tr M:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:Stdr:BoolL:List SegR:List Segh:symStep M dflt { q := q, dr := dr, L := L, R := R } = some c'⊢ { q := q, dr := dr, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl tr cases dr with M:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segh:symStep M dflt { q := q, dr := true, L := L, R := R } = some c'⊢ { q := q, dr := true, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl tr M:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segh:(match popHead dflt R with | some (x, r) => match M q x with | some (some q', { symbol := w, dir := Dir.right }) => some { q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: L, R := r } | some (some q', { symbol := w, dir := Dir.left }) => some { q := q', dr := false, L := L, R := { b := [w], e := Lin.const 1 } :: r } | x => none | none => none) = some c'⊢ { q := q, dr := true, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl tr cases hp : popHead dflt R with M:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segh:(match popHead dflt R with | some (x, r) => match M q x with | some (some q', { symbol := w, dir := Dir.right }) => some { q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: L, R := r } | some (some q', { symbol := w, dir := Dir.left }) => some { q := q', dr := false, L := L, R := { b := [w], e := Lin.const 1 } :: r } | x => none | none => none) = some c'hp:popHead dflt R = none⊢ { q := q, dr := true, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl tr All goals completed! 🐙 M:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segh:(match popHead dflt R with | some (x, r) => match M q x with | some (some q', { symbol := w, dir := Dir.right }) => some { q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: L, R := r } | some (some q', { symbol := w, dir := Dir.left }) => some { q := q', dr := false, L := L, R := { b := [w], e := Lin.const 1 } :: r } | x => none | none => none) = some c'p:Sym × List Seghp:popHead dflt R = some p⊢ { q := q, dr := true, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl tr M:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segh:(match popHead dflt R with | some (x, r) => match M q x with | some (some q', { symbol := w, dir := Dir.right }) => some { q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: L, R := r } | some (some q', { symbol := w, dir := Dir.left }) => some { q := q', dr := false, L := L, R := { b := [w], e := Lin.const 1 } :: r } | x => none | none => none) = some c'x:Symr:List Seghp:popHead dflt R = some (x, r)⊢ { q := q, dr := true, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl tr M:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segh:(match popHead dflt R with | some (x, r) => match M q x with | some (some q', { symbol := w, dir := Dir.right }) => some { q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: L, R := r } | some (some q', { symbol := w, dir := Dir.left }) => some { q := q', dr := false, L := L, R := { b := [w], e := Lin.const 1 } :: r } | x => none | none => none) = some c'x:Symr:List Seghp:popHead dflt R = some (x, r)hd:hden v R tr = x >> hden v r tr⊢ { q := q, dr := true, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl tr M:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Symr:List Seghp:popHead dflt R = some (x, r)hd:hden v R tr = x >> hden v r trh:(match M q x with | some (some q', { symbol := w, dir := Dir.right }) => some { q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: L, R := r } | some (some q', { symbol := w, dir := Dir.left }) => some { q := q', dr := false, L := L, R := { b := [w], e := Lin.const 1 } :: r } | x => none) = some c'⊢ { q := q, dr := true, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl tr cases hM : M q x with M:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Symr:List Seghp:popHead dflt R = some (x, r)hd:hden v R tr = x >> hden v r trh:(match M q x with | some (some q', { symbol := w, dir := Dir.right }) => some { q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: L, R := r } | some (some q', { symbol := w, dir := Dir.left }) => some { q := q', dr := false, L := L, R := { b := [w], e := Lin.const 1 } :: r } | x => none) = some c'hM:M q x = none⊢ { q := q, dr := true, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl tr All goals completed! 🐙 M:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Symr:List Seghp:popHead dflt R = some (x, r)hd:hden v R tr = x >> hden v r trh:(match M q x with | some (some q', { symbol := w, dir := Dir.right }) => some { q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: L, R := r } | some (some q', { symbol := w, dir := Dir.left }) => some { q := q', dr := false, L := L, R := { b := [w], e := Lin.const 1 } :: r } | x => none) = some c'o:Option St × Stmt SymhM:M q x = some o⊢ { q := q, dr := true, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl tr M:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Symr:List Seghp:popHead dflt R = some (x, r)hd:hden v R tr = x >> hden v r trh:(match M q x with | some (some q', { symbol := w, dir := Dir.right }) => some { q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: L, R := r } | some (some q', { symbol := w, dir := Dir.left }) => some { q := q', dr := false, L := L, R := { b := [w], e := Lin.const 1 } :: r } | x => none) = some c'w:Symd:DirhM:M q x = some (none, { symbol := w, dir := d })⊢ { q := q, dr := true, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl trM:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Symr:List Seghp:popHead dflt R = some (x, r)hd:hden v R tr = x >> hden v r trh:(match M q x with | some (some q', { symbol := w, dir := Dir.right }) => some { q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: L, R := r } | some (some q', { symbol := w, dir := Dir.left }) => some { q := q', dr := false, L := L, R := { b := [w], e := Lin.const 1 } :: r } | x => none) = some c'q':Stw:Symd:DirhM:M q x = some (some q', { symbol := w, dir := d })⊢ { q := q, dr := true, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl tr M:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Symr:List Seghp:popHead dflt R = some (x, r)hd:hden v R tr = x >> hden v r trh:(match M q x with | some (some q', { symbol := w, dir := Dir.right }) => some { q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: L, R := r } | some (some q', { symbol := w, dir := Dir.left }) => some { q := q', dr := false, L := L, R := { b := [w], e := Lin.const 1 } :: r } | x => none) = some c'w:Symd:DirhM:M q x = some (none, { symbol := w, dir := d })⊢ { q := q, dr := true, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl tr All goals completed! 🐙 M:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Symr:List Seghp:popHead dflt R = some (x, r)hd:hden v R tr = x >> hden v r trh:(match M q x with | some (some q', { symbol := w, dir := Dir.right }) => some { q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: L, R := r } | some (some q', { symbol := w, dir := Dir.left }) => some { q := q', dr := false, L := L, R := { b := [w], e := Lin.const 1 } :: r } | x => none) = some c'q':Stw:Symd:DirhM:M q x = some (some q', { symbol := w, dir := d })⊢ { q := q, dr := true, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl tr M:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Symr:List Seghp:popHead dflt R = some (x, r)hd:hden v R tr = x >> hden v r trh:(match M q x with | some (some q', { symbol := w, dir := Dir.right }) => some { q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: L, R := r } | some (some q', { symbol := w, dir := Dir.left }) => some { q := q', dr := false, L := L, R := { b := [w], e := Lin.const 1 } :: r } | x => none) = some c'q':Stw:SymhM:M q x = some (some q', { symbol := w, dir := Dir.left })⊢ { q := q, dr := true, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl trM:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Symr:List Seghp:popHead dflt R = some (x, r)hd:hden v R tr = x >> hden v r trh:(match M q x with | some (some q', { symbol := w, dir := Dir.right }) => some { q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: L, R := r } | some (some q', { symbol := w, dir := Dir.left }) => some { q := q', dr := false, L := L, R := { b := [w], e := Lin.const 1 } :: r } | x => none) = some c'q':Stw:SymhM:M q x = some (some q', { symbol := w, dir := Dir.right })⊢ { q := q, dr := true, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl tr M:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Symr:List Seghp:popHead dflt R = some (x, r)hd:hden v R tr = x >> hden v r trh:(match M q x with | some (some q', { symbol := w, dir := Dir.right }) => some { q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: L, R := r } | some (some q', { symbol := w, dir := Dir.left }) => some { q := q', dr := false, L := L, R := { b := [w], e := Lin.const 1 } :: r } | x => none) = some c'q':Stw:SymhM:M q x = some (some q', { symbol := w, dir := Dir.left })⊢ { q := q, dr := true, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl trM:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Symr:List Seghp:popHead dflt R = some (x, r)hd:hden v R tr = x >> hden v r trh:(match M q x with | some (some q', { symbol := w, dir := Dir.right }) => some { q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: L, R := r } | some (some q', { symbol := w, dir := Dir.left }) => some { q := q', dr := false, L := L, R := { b := [w], e := Lin.const 1 } :: r } | x => none) = some c'q':Stw:SymhM:M q x = some (some q', { symbol := w, dir := Dir.right })⊢ { q := q, dr := true, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl tr M:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Symr:List Seghp:popHead dflt R = some (x, r)hd:hden v R tr = x >> hden v r trq':Stw:SymhM:M q x = some (some q', { symbol := w, dir := Dir.right })h:{ q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: L, R := r } = c'⊢ { q := q, dr := true, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl tr M:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Symr:List Seghp:popHead dflt R = some (x, r)hd:hden v R tr = x >> hden v r trq':Stw:SymhM:M q x = some (some q', { symbol := w, dir := Dir.left })h:{ q := q', dr := false, L := L, R := { b := [w], e := Lin.const 1 } :: r } = c'⊢ { q := q, dr := true, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl trM:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Symr:List Seghp:popHead dflt R = some (x, r)hd:hden v R tr = x >> hden v r trq':Stw:SymhM:M q x = some (some q', { symbol := w, dir := Dir.right })h:{ q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: L, R := r } = c'⊢ { q := q, dr := true, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl tr M:TMdflt:Boolv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Symr:List Seghp:popHead dflt R = some (x, r)hd:hden v R tr = x >> hden v r trq':Stw:SymhM:M q x = some (some q', { symbol := w, dir := Dir.right })⊢ { q := q, dr := true, L := L, R := R }.den v tl tr [M]⊢ { q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: L, R := r }.den v tl tr M:TMdflt:Boolv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Symr:List Seghp:popHead dflt R = some (x, r)hd:hden v R tr = x >> hden v r trq':Stw:SymhM:M q x = some (some q', { symbol := w, dir := Dir.left })⊢ { q := q, dr := true, L := L, R := R }.den v tl tr [M]⊢ { q := q', dr := false, L := L, R := { b := [w], e := Lin.const 1 } :: r }.den v tl trM:TMdflt:Boolv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Symr:List Seghp:popHead dflt R = some (x, r)hd:hden v R tr = x >> hden v r trq':Stw:SymhM:M q x = some (some q', { symbol := w, dir := Dir.right })⊢ { q := q, dr := true, L := L, R := R }.den v tl tr [M]⊢ { q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: L, R := r }.den v tl tr All goals completed! 🐙 M:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segh:symStep M dflt { q := q, dr := false, L := L, R := R } = some c'⊢ { q := q, dr := false, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl tr M:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segh:(match popHead dflt L with | some (x, l) => match M q x with | some (some q', { symbol := w, dir := Dir.right }) => some { q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: l, R := R } | some (some q', { symbol := w, dir := Dir.left }) => some { q := q', dr := false, L := l, R := { b := [w], e := Lin.const 1 } :: R } | x => none | none => none) = some c'⊢ { q := q, dr := false, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl tr cases hp : popHead dflt L with M:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segh:(match popHead dflt L with | some (x, l) => match M q x with | some (some q', { symbol := w, dir := Dir.right }) => some { q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: l, R := R } | some (some q', { symbol := w, dir := Dir.left }) => some { q := q', dr := false, L := l, R := { b := [w], e := Lin.const 1 } :: R } | x => none | none => none) = some c'hp:popHead dflt L = none⊢ { q := q, dr := false, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl tr All goals completed! 🐙 M:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segh:(match popHead dflt L with | some (x, l) => match M q x with | some (some q', { symbol := w, dir := Dir.right }) => some { q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: l, R := R } | some (some q', { symbol := w, dir := Dir.left }) => some { q := q', dr := false, L := l, R := { b := [w], e := Lin.const 1 } :: R } | x => none | none => none) = some c'p:Sym × List Seghp:popHead dflt L = some p⊢ { q := q, dr := false, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl tr M:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segh:(match popHead dflt L with | some (x, l) => match M q x with | some (some q', { symbol := w, dir := Dir.right }) => some { q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: l, R := R } | some (some q', { symbol := w, dir := Dir.left }) => some { q := q', dr := false, L := l, R := { b := [w], e := Lin.const 1 } :: R } | x => none | none => none) = some c'x:Syml:List Seghp:popHead dflt L = some (x, l)⊢ { q := q, dr := false, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl tr M:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segh:(match popHead dflt L with | some (x, l) => match M q x with | some (some q', { symbol := w, dir := Dir.right }) => some { q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: l, R := R } | some (some q', { symbol := w, dir := Dir.left }) => some { q := q', dr := false, L := l, R := { b := [w], e := Lin.const 1 } :: R } | x => none | none => none) = some c'x:Syml:List Seghp:popHead dflt L = some (x, l)hd:hden v L tl = x >> hden v l tl⊢ { q := q, dr := false, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl tr M:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Syml:List Seghp:popHead dflt L = some (x, l)hd:hden v L tl = x >> hden v l tlh:(match M q x with | some (some q', { symbol := w, dir := Dir.right }) => some { q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: l, R := R } | some (some q', { symbol := w, dir := Dir.left }) => some { q := q', dr := false, L := l, R := { b := [w], e := Lin.const 1 } :: R } | x => none) = some c'⊢ { q := q, dr := false, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl tr cases hM : M q x with M:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Syml:List Seghp:popHead dflt L = some (x, l)hd:hden v L tl = x >> hden v l tlh:(match M q x with | some (some q', { symbol := w, dir := Dir.right }) => some { q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: l, R := R } | some (some q', { symbol := w, dir := Dir.left }) => some { q := q', dr := false, L := l, R := { b := [w], e := Lin.const 1 } :: R } | x => none) = some c'hM:M q x = none⊢ { q := q, dr := false, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl tr All goals completed! 🐙 M:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Syml:List Seghp:popHead dflt L = some (x, l)hd:hden v L tl = x >> hden v l tlh:(match M q x with | some (some q', { symbol := w, dir := Dir.right }) => some { q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: l, R := R } | some (some q', { symbol := w, dir := Dir.left }) => some { q := q', dr := false, L := l, R := { b := [w], e := Lin.const 1 } :: R } | x => none) = some c'o:Option St × Stmt SymhM:M q x = some o⊢ { q := q, dr := false, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl tr M:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Syml:List Seghp:popHead dflt L = some (x, l)hd:hden v L tl = x >> hden v l tlh:(match M q x with | some (some q', { symbol := w, dir := Dir.right }) => some { q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: l, R := R } | some (some q', { symbol := w, dir := Dir.left }) => some { q := q', dr := false, L := l, R := { b := [w], e := Lin.const 1 } :: R } | x => none) = some c'w:Symd:DirhM:M q x = some (none, { symbol := w, dir := d })⊢ { q := q, dr := false, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl trM:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Syml:List Seghp:popHead dflt L = some (x, l)hd:hden v L tl = x >> hden v l tlh:(match M q x with | some (some q', { symbol := w, dir := Dir.right }) => some { q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: l, R := R } | some (some q', { symbol := w, dir := Dir.left }) => some { q := q', dr := false, L := l, R := { b := [w], e := Lin.const 1 } :: R } | x => none) = some c'q':Stw:Symd:DirhM:M q x = some (some q', { symbol := w, dir := d })⊢ { q := q, dr := false, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl tr M:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Syml:List Seghp:popHead dflt L = some (x, l)hd:hden v L tl = x >> hden v l tlh:(match M q x with | some (some q', { symbol := w, dir := Dir.right }) => some { q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: l, R := R } | some (some q', { symbol := w, dir := Dir.left }) => some { q := q', dr := false, L := l, R := { b := [w], e := Lin.const 1 } :: R } | x => none) = some c'w:Symd:DirhM:M q x = some (none, { symbol := w, dir := d })⊢ { q := q, dr := false, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl tr All goals completed! 🐙 M:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Syml:List Seghp:popHead dflt L = some (x, l)hd:hden v L tl = x >> hden v l tlh:(match M q x with | some (some q', { symbol := w, dir := Dir.right }) => some { q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: l, R := R } | some (some q', { symbol := w, dir := Dir.left }) => some { q := q', dr := false, L := l, R := { b := [w], e := Lin.const 1 } :: R } | x => none) = some c'q':Stw:Symd:DirhM:M q x = some (some q', { symbol := w, dir := d })⊢ { q := q, dr := false, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl tr M:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Syml:List Seghp:popHead dflt L = some (x, l)hd:hden v L tl = x >> hden v l tlh:(match M q x with | some (some q', { symbol := w, dir := Dir.right }) => some { q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: l, R := R } | some (some q', { symbol := w, dir := Dir.left }) => some { q := q', dr := false, L := l, R := { b := [w], e := Lin.const 1 } :: R } | x => none) = some c'q':Stw:SymhM:M q x = some (some q', { symbol := w, dir := Dir.left })⊢ { q := q, dr := false, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl trM:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Syml:List Seghp:popHead dflt L = some (x, l)hd:hden v L tl = x >> hden v l tlh:(match M q x with | some (some q', { symbol := w, dir := Dir.right }) => some { q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: l, R := R } | some (some q', { symbol := w, dir := Dir.left }) => some { q := q', dr := false, L := l, R := { b := [w], e := Lin.const 1 } :: R } | x => none) = some c'q':Stw:SymhM:M q x = some (some q', { symbol := w, dir := Dir.right })⊢ { q := q, dr := false, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl tr M:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Syml:List Seghp:popHead dflt L = some (x, l)hd:hden v L tl = x >> hden v l tlh:(match M q x with | some (some q', { symbol := w, dir := Dir.right }) => some { q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: l, R := R } | some (some q', { symbol := w, dir := Dir.left }) => some { q := q', dr := false, L := l, R := { b := [w], e := Lin.const 1 } :: R } | x => none) = some c'q':Stw:SymhM:M q x = some (some q', { symbol := w, dir := Dir.left })⊢ { q := q, dr := false, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl trM:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Syml:List Seghp:popHead dflt L = some (x, l)hd:hden v L tl = x >> hden v l tlh:(match M q x with | some (some q', { symbol := w, dir := Dir.right }) => some { q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: l, R := R } | some (some q', { symbol := w, dir := Dir.left }) => some { q := q', dr := false, L := l, R := { b := [w], e := Lin.const 1 } :: R } | x => none) = some c'q':Stw:SymhM:M q x = some (some q', { symbol := w, dir := Dir.right })⊢ { q := q, dr := false, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl tr M:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Syml:List Seghp:popHead dflt L = some (x, l)hd:hden v L tl = x >> hden v l tlq':Stw:SymhM:M q x = some (some q', { symbol := w, dir := Dir.right })h:{ q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: l, R := R } = c'⊢ { q := q, dr := false, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl tr M:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Syml:List Seghp:popHead dflt L = some (x, l)hd:hden v L tl = x >> hden v l tlq':Stw:SymhM:M q x = some (some q', { symbol := w, dir := Dir.left })h:{ q := q', dr := false, L := l, R := { b := [w], e := Lin.const 1 } :: R } = c'⊢ { q := q, dr := false, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl trM:TMdflt:Boolc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Syml:List Seghp:popHead dflt L = some (x, l)hd:hden v L tl = x >> hden v l tlq':Stw:SymhM:M q x = some (some q', { symbol := w, dir := Dir.right })h:{ q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: l, R := R } = c'⊢ { q := q, dr := false, L := L, R := R }.den v tl tr [M]⊢ c'.den v tl tr M:TMdflt:Boolv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Syml:List Seghp:popHead dflt L = some (x, l)hd:hden v L tl = x >> hden v l tlq':Stw:SymhM:M q x = some (some q', { symbol := w, dir := Dir.right })⊢ { q := q, dr := false, L := L, R := R }.den v tl tr [M]⊢ { q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: l, R := R }.den v tl tr M:TMdflt:Boolv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Syml:List Seghp:popHead dflt L = some (x, l)hd:hden v L tl = x >> hden v l tlq':Stw:SymhM:M q x = some (some q', { symbol := w, dir := Dir.left })⊢ { q := q, dr := false, L := L, R := R }.den v tl tr [M]⊢ { q := q', dr := false, L := l, R := { b := [w], e := Lin.const 1 } :: R }.den v tl trM:TMdflt:Boolv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Syml:List Seghp:popHead dflt L = some (x, l)hd:hden v L tl = x >> hden v l tlq':Stw:SymhM:M q x = some (some q', { symbol := w, dir := Dir.right })⊢ { q := q, dr := false, L := L, R := R }.den v tl tr [M]⊢ { q := q', dr := true, L := { b := [w], e := Lin.const 1 } :: l, R := R }.den v tl tr All goals completed! 🐙def isHalt (M : TM) (dflt : Bool) (c : SC) : Bool := match popHead dflt (if c.dr then c.R else c.L) with | some (x, _) => (M c.q x).isNone | none => falsetheorem isHalt_sound (M : TM) (dflt : Bool) (c : SC) (h : isHalt M dflt c = true) (v : ℕ → ℕ) (tl tr : ListBlank Sym) (ht : dflt = true → tl = default ∧ tr = default) : (step M (c.den v tl tr)).isNone = true := M:TMdflt:Boolc:SCh:isHalt M dflt c = truev:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = default⊢ (step M (c.den v tl tr)).isNone = true M:TMdflt:Boolv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:Stdr:BoolL:List SegR:List Segh:isHalt M dflt { q := q, dr := dr, L := L, R := R } = true⊢ (step M ({ q := q, dr := dr, L := L, R := R }.den v tl tr)).isNone = true M:TMdflt:Boolv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:Stdr:BoolL:List SegR:List Segh:(match popHead dflt (if { q := q, dr := dr, L := L, R := R }.dr = true then { q := q, dr := dr, L := L, R := R }.R else { q := q, dr := dr, L := L, R := R }.L) with | some (x, snd) => (M { q := q, dr := dr, L := L, R := R }.q x).isNone | none => false) = true⊢ (step M ({ q := q, dr := dr, L := L, R := R }.den v tl tr)).isNone = true cases hp : popHead dflt (if dr then R else L) with M:TMdflt:Boolv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:Stdr:BoolL:List SegR:List Segh:(match popHead dflt (if { q := q, dr := dr, L := L, R := R }.dr = true then { q := q, dr := dr, L := L, R := R }.R else { q := q, dr := dr, L := L, R := R }.L) with | some (x, snd) => (M { q := q, dr := dr, L := L, R := R }.q x).isNone | none => false) = truehp:popHead dflt (if dr = true then R else L) = none⊢ (step M ({ q := q, dr := dr, L := L, R := R }.den v tl tr)).isNone = true All goals completed! 🐙 M:TMdflt:Boolv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:Stdr:BoolL:List SegR:List Segh:(match popHead dflt (if { q := q, dr := dr, L := L, R := R }.dr = true then { q := q, dr := dr, L := L, R := R }.R else { q := q, dr := dr, L := L, R := R }.L) with | some (x, snd) => (M { q := q, dr := dr, L := L, R := R }.q x).isNone | none => false) = truep:Sym × List Seghp:popHead dflt (if dr = true then R else L) = some p⊢ (step M ({ q := q, dr := dr, L := L, R := R }.den v tl tr)).isNone = true M:TMdflt:Boolv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:Stdr:BoolL:List SegR:List Segh:(match popHead dflt (if { q := q, dr := dr, L := L, R := R }.dr = true then { q := q, dr := dr, L := L, R := R }.R else { q := q, dr := dr, L := L, R := R }.L) with | some (x, snd) => (M { q := q, dr := dr, L := L, R := R }.q x).isNone | none => false) = truex:Symr:List Seghp:popHead dflt (if dr = true then R else L) = some (x, r)⊢ (step M ({ q := q, dr := dr, L := L, R := R }.den v tl tr)).isNone = true M:TMdflt:Boolv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:Stdr:BoolL:List SegR:List Segx:Symr:List Seghp:popHead dflt (if dr = true then R else L) = some (x, r)h:M q x = none⊢ (step M ({ q := q, dr := dr, L := L, R := R }.den v tl tr)).isNone = true cases dr with M:TMdflt:Boolv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Symr:List Segh:M q x = nonehp:popHead dflt (if true = true then R else L) = some (x, r)⊢ (step M ({ q := q, dr := true, L := L, R := R }.den v tl tr)).isNone = true M:TMdflt:Boolv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Symr:List Segh:M q x = nonehp:popHead dflt (if true = true then R else L) = some (x, r)hd:hden v R tr = x >> hden v r tr⊢ (step M ({ q := q, dr := true, L := L, R := R }.den v tl tr)).isNone = true All goals completed! 🐙 M:TMdflt:Boolv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Symr:List Segh:M q x = nonehp:popHead dflt (if false = true then R else L) = some (x, r)⊢ (step M ({ q := q, dr := false, L := L, R := R }.den v tl tr)).isNone = true M:TMdflt:Boolv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultq:StL:List SegR:List Segx:Symr:List Segh:M q x = nonehp:popHead dflt (if false = true then R else L) = some (x, r)hd:hden v L tl = x >> hden v r tl⊢ (step M ({ q := q, dr := false, L := L, R := R }.den v tl tr)).isNone = true All goals completed! 🐙-- local simulation inside one block, head entering from the left (moving right) def runR (M : TM) : ℕ → St → List Sym → List Sym → Option (St × List Sym) | _, q, lw, [] => some (q, lw) | 0, _, _, _ :: _ => none | f + 1, q, lw, s :: rw => match M q s with | some (some q', Stmt.write w Dir.right) => runR M f q' (w :: lw) rw | some (some q', Stmt.write w Dir.left) => match lw with | [] => none | x :: lw' => runR M f q' lw' (x :: w :: rw) | _ => nonetheorem runR_sound (M : TM) : ∀ (f : ℕ) (q : St) (lw rw : List Sym) (q' : St) (lw' : List Sym), runR M f q lw rw = some (q', lw') → ∀ (L R : ListBlank Sym), ReachesStar M (cfgOf q true (ListBlank.append lw L) (ListBlank.append rw R)) (cfgOf q' true (ListBlank.append lw' L) R) M:TMf:ℕq:Stlw:List Symq':Stlw':List Symh:runR M f q lw [] = some (q', lw')L:ListBlank SymR:ListBlank Sym⊢ cfgOf q true (lw +> L) ([] +> R) [M]⊢* cfgOf q' true (lw' +> L) R M:TMf:ℕq:Stlw:List Symq':Stlw':List Symh:runR M f q lw [] = some (q', lw')L:ListBlank SymR:ListBlank Sym⊢ cfgOf q true (lw +> L) ([] +> R) [M]⊢* cfgOf q' true (lw' +> L) R M:TMf:ℕq:Stlw:List Symq':Stlw':List Symh:runR M f q lw [] = some (q', lw')L:ListBlank SymR:ListBlank Symh':q = q' ∧ lw = lw'⊢ cfgOf q true (lw +> L) ([] +> R) [M]⊢* cfgOf q' true (lw' +> L) R M:TMf:ℕq:Stlw:List Symq':Stlw':List Symh:runR M f q lw [] = some (q', lw')L:ListBlank SymR:ListBlank Symh':q = q' ∧ lw = lw'⊢ cfgOf q true (lw +> L) ([] +> R) [M]⊢* cfgOf q true (lw +> L) R; All goals completed! 🐙 M:TMq:Stlw:List Syms:Symrw:List Symq':Stlw':List Symh:runR M 0 q lw (s :: rw) = some (q', lw')L:ListBlank SymR:ListBlank Sym⊢ cfgOf q true (lw +> L) ((s :: rw) +> R) [M]⊢* cfgOf q' true (lw' +> L) R M:TMq:Stlw:List Syms:Symrw:List Symq':Stlw':List Symh:runR M 0 q lw (s :: rw) = some (q', lw')L:ListBlank SymR:ListBlank Sym⊢ cfgOf q true (lw +> L) ((s :: rw) +> R) [M]⊢* cfgOf q' true (lw' +> L) R All goals completed! 🐙 M:TMf:ℕq:Stlw:List Syms:Symrw:List Symq':Stlw':List Symh:runR M (f + 1) q lw (s :: rw) = some (q', lw')L:ListBlank SymR:ListBlank Sym⊢ cfgOf q true (lw +> L) ((s :: rw) +> R) [M]⊢* cfgOf q' true (lw' +> L) R M:TMf:ℕq:Stlw:List Syms:Symrw:List Symq':Stlw':List Symh:runR M (f + 1) q lw (s :: rw) = some (q', lw')L:ListBlank SymR:ListBlank Sym⊢ cfgOf q true (lw +> L) ((s :: rw) +> R) [M]⊢* cfgOf q' true (lw' +> L) R M:TMf:ℕq:Stlw:List Syms:Symrw:List Symq':Stlw':List Symh:(match M q s with | some (some q', { symbol := w, dir := Dir.right }) => runR M f q' (w :: lw) rw | some (some q', { symbol := w, dir := Dir.left }) => match lw with | [] => none | x :: lw' => runR M f q' lw' (x :: w :: rw) | x => none) = some (q', lw')L:ListBlank SymR:ListBlank Sym⊢ cfgOf q true (lw +> L) ((s :: rw) +> R) [M]⊢* cfgOf q' true (lw' +> L) R cases hM : M q s with M:TMf:ℕq:Stlw:List Syms:Symrw:List Symq':Stlw':List Symh:(match M q s with | some (some q', { symbol := w, dir := Dir.right }) => runR M f q' (w :: lw) rw | some (some q', { symbol := w, dir := Dir.left }) => match lw with | [] => none | x :: lw' => runR M f q' lw' (x :: w :: rw) | x => none) = some (q', lw')L:ListBlank SymR:ListBlank SymhM:M q s = none⊢ cfgOf q true (lw +> L) ((s :: rw) +> R) [M]⊢* cfgOf q' true (lw' +> L) R All goals completed! 🐙 M:TMf:ℕq:Stlw:List Syms:Symrw:List Symq':Stlw':List Symh:(match M q s with | some (some q', { symbol := w, dir := Dir.right }) => runR M f q' (w :: lw) rw | some (some q', { symbol := w, dir := Dir.left }) => match lw with | [] => none | x :: lw' => runR M f q' lw' (x :: w :: rw) | x => none) = some (q', lw')L:ListBlank SymR:ListBlank Symo:Option St × Stmt SymhM:M q s = some o⊢ cfgOf q true (lw +> L) ((s :: rw) +> R) [M]⊢* cfgOf q' true (lw' +> L) R M:TMf:ℕq:Stlw:List Syms:Symrw:List Symq':Stlw':List Symh:(match M q s with | some (some q', { symbol := w, dir := Dir.right }) => runR M f q' (w :: lw) rw | some (some q', { symbol := w, dir := Dir.left }) => match lw with | [] => none | x :: lw' => runR M f q' lw' (x :: w :: rw) | x => none) = some (q', lw')L:ListBlank SymR:ListBlank Symw:Symd:DirhM:M q s = some (none, { symbol := w, dir := d })⊢ cfgOf q true (lw +> L) ((s :: rw) +> R) [M]⊢* cfgOf q' true (lw' +> L) RM:TMf:ℕq:Stlw:List Syms:Symrw:List Symq':Stlw':List Symh:(match M q s with | some (some q', { symbol := w, dir := Dir.right }) => runR M f q' (w :: lw) rw | some (some q', { symbol := w, dir := Dir.left }) => match lw with | [] => none | x :: lw' => runR M f q' lw' (x :: w :: rw) | x => none) = some (q', lw')L:ListBlank SymR:ListBlank Symq2:Stw:Symd:DirhM:M q s = some (some q2, { symbol := w, dir := d })⊢ cfgOf q true (lw +> L) ((s :: rw) +> R) [M]⊢* cfgOf q' true (lw' +> L) R M:TMf:ℕq:Stlw:List Syms:Symrw:List Symq':Stlw':List Symh:(match M q s with | some (some q', { symbol := w, dir := Dir.right }) => runR M f q' (w :: lw) rw | some (some q', { symbol := w, dir := Dir.left }) => match lw with | [] => none | x :: lw' => runR M f q' lw' (x :: w :: rw) | x => none) = some (q', lw')L:ListBlank SymR:ListBlank Symw:Symd:DirhM:M q s = some (none, { symbol := w, dir := d })⊢ cfgOf q true (lw +> L) ((s :: rw) +> R) [M]⊢* cfgOf q' true (lw' +> L) R All goals completed! 🐙 M:TMf:ℕq:Stlw:List Syms:Symrw:List Symq':Stlw':List Symh:(match M q s with | some (some q', { symbol := w, dir := Dir.right }) => runR M f q' (w :: lw) rw | some (some q', { symbol := w, dir := Dir.left }) => match lw with | [] => none | x :: lw' => runR M f q' lw' (x :: w :: rw) | x => none) = some (q', lw')L:ListBlank SymR:ListBlank Symq2:Stw:Symd:DirhM:M q s = some (some q2, { symbol := w, dir := d })⊢ cfgOf q true (lw +> L) ((s :: rw) +> R) [M]⊢* cfgOf q' true (lw' +> L) R cases d with M:TMf:ℕq:Stlw:List Syms:Symrw:List Symq':Stlw':List Symh:(match M q s with | some (some q', { symbol := w, dir := Dir.right }) => runR M f q' (w :: lw) rw | some (some q', { symbol := w, dir := Dir.left }) => match lw with | [] => none | x :: lw' => runR M f q' lw' (x :: w :: rw) | x => none) = some (q', lw')L:ListBlank SymR:ListBlank Symq2:Stw:SymhM:M q s = some (some q2, { symbol := w, dir := Dir.right })⊢ cfgOf q true (lw +> L) ((s :: rw) +> R) [M]⊢* cfgOf q' true (lw' +> L) R M:TMf:ℕq:Stlw:List Syms:Symrw:List Symq':Stlw':List SymL:ListBlank SymR:ListBlank Symq2:Stw:SymhM:M q s = some (some q2, { symbol := w, dir := Dir.right })h:runR M f q2 (w :: lw) rw = some (q', lw')⊢ cfgOf q true (lw +> L) ((s :: rw) +> R) [M]⊢* cfgOf q' true (lw' +> L) R M:TMf:ℕq:Stlw:List Syms:Symrw:List Symq':Stlw':List SymL:ListBlank SymR:ListBlank Symq2:Stw:SymhM:M q s = some (some q2, { symbol := w, dir := Dir.right })h:runR M f q2 (w :: lw) rw = some (q', lw')⊢ cfgOf q true (lw +> L) ((s :: rw) +> R) [M]⊢ cfgOf q2 true ((w :: lw) +> L) (rw +> R) All goals completed! 🐙 M:TMf:ℕq:Stlw:List Syms:Symrw:List Symq':Stlw':List Symh:(match M q s with | some (some q', { symbol := w, dir := Dir.right }) => runR M f q' (w :: lw) rw | some (some q', { symbol := w, dir := Dir.left }) => match lw with | [] => none | x :: lw' => runR M f q' lw' (x :: w :: rw) | x => none) = some (q', lw')L:ListBlank SymR:ListBlank Symq2:Stw:SymhM:M q s = some (some q2, { symbol := w, dir := Dir.left })⊢ cfgOf q true (lw +> L) ((s :: rw) +> R) [M]⊢* cfgOf q' true (lw' +> L) R M:TMf:ℕq:Stlw:List Syms:Symrw:List Symq':Stlw':List SymL:ListBlank SymR:ListBlank Symq2:Stw:SymhM:M q s = some (some q2, { symbol := w, dir := Dir.left })h:(match lw with | [] => none | x :: lw' => runR M f q2 lw' (x :: w :: rw)) = some (q', lw')⊢ cfgOf q true (lw +> L) ((s :: rw) +> R) [M]⊢* cfgOf q' true (lw' +> L) R M:TMf:ℕq:Sts:Symrw:List Symq':Stlw':List SymL:ListBlank SymR:ListBlank Symq2:Stw:SymhM:M q s = some (some q2, { symbol := w, dir := Dir.left })h:(match [] with | [] => none | x :: lw' => runR M f q2 lw' (x :: w :: rw)) = some (q', lw')⊢ cfgOf q true ([] +> L) ((s :: rw) +> R) [M]⊢* cfgOf q' true (lw' +> L) RM:TMf:ℕq:Sts:Symrw:List Symq':Stlw':List SymL:ListBlank SymR:ListBlank Symq2:Stw:SymhM:M q s = some (some q2, { symbol := w, dir := Dir.left })x:Symlw2:List Symh:(match x :: lw2 with | [] => none | x :: lw' => runR M f q2 lw' (x :: w :: rw)) = some (q', lw')⊢ cfgOf q true ((x :: lw2) +> L) ((s :: rw) +> R) [M]⊢* cfgOf q' true (lw' +> L) R M:TMf:ℕq:Sts:Symrw:List Symq':Stlw':List SymL:ListBlank SymR:ListBlank Symq2:Stw:SymhM:M q s = some (some q2, { symbol := w, dir := Dir.left })h:(match [] with | [] => none | x :: lw' => runR M f q2 lw' (x :: w :: rw)) = some (q', lw')⊢ cfgOf q true ([] +> L) ((s :: rw) +> R) [M]⊢* cfgOf q' true (lw' +> L) R All goals completed! 🐙 M:TMf:ℕq:Sts:Symrw:List Symq':Stlw':List SymL:ListBlank SymR:ListBlank Symq2:Stw:SymhM:M q s = some (some q2, { symbol := w, dir := Dir.left })x:Symlw2:List Symh:(match x :: lw2 with | [] => none | x :: lw' => runR M f q2 lw' (x :: w :: rw)) = some (q', lw')⊢ cfgOf q true ((x :: lw2) +> L) ((s :: rw) +> R) [M]⊢* cfgOf q' true (lw' +> L) R M:TMf:ℕq:Sts:Symrw:List Symq':Stlw':List SymL:ListBlank SymR:ListBlank Symq2:Stw:SymhM:M q s = some (some q2, { symbol := w, dir := Dir.left })x:Symlw2:List Symh:runR M f q2 lw2 (x :: w :: rw) = some (q', lw')⊢ cfgOf q true ((x :: lw2) +> L) ((s :: rw) +> R) [M]⊢* cfgOf q' true (lw' +> L) R M:TMf:ℕq:Sts:Symrw:List Symq':Stlw':List SymL:ListBlank SymR:ListBlank Symq2:Stw:SymhM:M q s = some (some q2, { symbol := w, dir := Dir.left })x:Symlw2:List Symh:runR M f q2 lw2 (x :: w :: rw) = some (q', lw')⊢ cfgOf q true ((x :: lw2) +> L) ((s :: rw) +> R) [M]⊢ cfgOf q2 true (lw2 +> L) ((x :: w :: rw) +> R) All goals completed! 🐙-- local simulation inside one block, head entering from the right (moving left) def runL (M : TM) : ℕ → St → List Sym → List Sym → Option (St × List Sym) | _, q, rw, [] => some (q, rw) | 0, _, _, _ :: _ => none | f + 1, q, rw, s :: lw => match M q s with | some (some q', Stmt.write w Dir.left) => runL M f q' (w :: rw) lw | some (some q', Stmt.write w Dir.right) => match rw with | [] => none | x :: rw' => runL M f q' rw' (x :: w :: lw) | _ => nonetheorem runL_sound (M : TM) : ∀ (f : ℕ) (q : St) (rw lw : List Sym) (q' : St) (rw' : List Sym), runL M f q rw lw = some (q', rw') → ∀ (L R : ListBlank Sym), ReachesStar M (cfgOf q false (ListBlank.append lw L) (ListBlank.append rw R)) (cfgOf q' false L (ListBlank.append rw' R)) M:TMf:ℕq:Strw:List Symq':Strw':List Symh:runL M f q rw [] = some (q', rw')L:ListBlank SymR:ListBlank Sym⊢ cfgOf q false ([] +> L) (rw +> R) [M]⊢* cfgOf q' false L (rw' +> R) M:TMf:ℕq:Strw:List Symq':Strw':List Symh:runL M f q rw [] = some (q', rw')L:ListBlank SymR:ListBlank Sym⊢ cfgOf q false ([] +> L) (rw +> R) [M]⊢* cfgOf q' false L (rw' +> R) M:TMf:ℕq:Strw:List Symq':Strw':List Symh:runL M f q rw [] = some (q', rw')L:ListBlank SymR:ListBlank Symh':q = q' ∧ rw = rw'⊢ cfgOf q false ([] +> L) (rw +> R) [M]⊢* cfgOf q' false L (rw' +> R) M:TMf:ℕq:Strw:List Symq':Strw':List Symh:runL M f q rw [] = some (q', rw')L:ListBlank SymR:ListBlank Symh':q = q' ∧ rw = rw'⊢ cfgOf q false ([] +> L) (rw +> R) [M]⊢* cfgOf q false L (rw +> R); All goals completed! 🐙 M:TMq:Strw:List Syms:Symlw:List Symq':Strw':List Symh:runL M 0 q rw (s :: lw) = some (q', rw')L:ListBlank SymR:ListBlank Sym⊢ cfgOf q false ((s :: lw) +> L) (rw +> R) [M]⊢* cfgOf q' false L (rw' +> R) M:TMq:Strw:List Syms:Symlw:List Symq':Strw':List Symh:runL M 0 q rw (s :: lw) = some (q', rw')L:ListBlank SymR:ListBlank Sym⊢ cfgOf q false ((s :: lw) +> L) (rw +> R) [M]⊢* cfgOf q' false L (rw' +> R) All goals completed! 🐙 M:TMf:ℕq:Strw:List Syms:Symlw:List Symq':Strw':List Symh:runL M (f + 1) q rw (s :: lw) = some (q', rw')L:ListBlank SymR:ListBlank Sym⊢ cfgOf q false ((s :: lw) +> L) (rw +> R) [M]⊢* cfgOf q' false L (rw' +> R) M:TMf:ℕq:Strw:List Syms:Symlw:List Symq':Strw':List Symh:runL M (f + 1) q rw (s :: lw) = some (q', rw')L:ListBlank SymR:ListBlank Sym⊢ cfgOf q false ((s :: lw) +> L) (rw +> R) [M]⊢* cfgOf q' false L (rw' +> R) M:TMf:ℕq:Strw:List Syms:Symlw:List Symq':Strw':List Symh:(match M q s with | some (some q', { symbol := w, dir := Dir.left }) => runL M f q' (w :: rw) lw | some (some q', { symbol := w, dir := Dir.right }) => match rw with | [] => none | x :: rw' => runL M f q' rw' (x :: w :: lw) | x => none) = some (q', rw')L:ListBlank SymR:ListBlank Sym⊢ cfgOf q false ((s :: lw) +> L) (rw +> R) [M]⊢* cfgOf q' false L (rw' +> R) cases hM : M q s with M:TMf:ℕq:Strw:List Syms:Symlw:List Symq':Strw':List Symh:(match M q s with | some (some q', { symbol := w, dir := Dir.left }) => runL M f q' (w :: rw) lw | some (some q', { symbol := w, dir := Dir.right }) => match rw with | [] => none | x :: rw' => runL M f q' rw' (x :: w :: lw) | x => none) = some (q', rw')L:ListBlank SymR:ListBlank SymhM:M q s = none⊢ cfgOf q false ((s :: lw) +> L) (rw +> R) [M]⊢* cfgOf q' false L (rw' +> R) All goals completed! 🐙 M:TMf:ℕq:Strw:List Syms:Symlw:List Symq':Strw':List Symh:(match M q s with | some (some q', { symbol := w, dir := Dir.left }) => runL M f q' (w :: rw) lw | some (some q', { symbol := w, dir := Dir.right }) => match rw with | [] => none | x :: rw' => runL M f q' rw' (x :: w :: lw) | x => none) = some (q', rw')L:ListBlank SymR:ListBlank Symo:Option St × Stmt SymhM:M q s = some o⊢ cfgOf q false ((s :: lw) +> L) (rw +> R) [M]⊢* cfgOf q' false L (rw' +> R) M:TMf:ℕq:Strw:List Syms:Symlw:List Symq':Strw':List Symh:(match M q s with | some (some q', { symbol := w, dir := Dir.left }) => runL M f q' (w :: rw) lw | some (some q', { symbol := w, dir := Dir.right }) => match rw with | [] => none | x :: rw' => runL M f q' rw' (x :: w :: lw) | x => none) = some (q', rw')L:ListBlank SymR:ListBlank Symw:Symd:DirhM:M q s = some (none, { symbol := w, dir := d })⊢ cfgOf q false ((s :: lw) +> L) (rw +> R) [M]⊢* cfgOf q' false L (rw' +> R)M:TMf:ℕq:Strw:List Syms:Symlw:List Symq':Strw':List Symh:(match M q s with | some (some q', { symbol := w, dir := Dir.left }) => runL M f q' (w :: rw) lw | some (some q', { symbol := w, dir := Dir.right }) => match rw with | [] => none | x :: rw' => runL M f q' rw' (x :: w :: lw) | x => none) = some (q', rw')L:ListBlank SymR:ListBlank Symq2:Stw:Symd:DirhM:M q s = some (some q2, { symbol := w, dir := d })⊢ cfgOf q false ((s :: lw) +> L) (rw +> R) [M]⊢* cfgOf q' false L (rw' +> R) M:TMf:ℕq:Strw:List Syms:Symlw:List Symq':Strw':List Symh:(match M q s with | some (some q', { symbol := w, dir := Dir.left }) => runL M f q' (w :: rw) lw | some (some q', { symbol := w, dir := Dir.right }) => match rw with | [] => none | x :: rw' => runL M f q' rw' (x :: w :: lw) | x => none) = some (q', rw')L:ListBlank SymR:ListBlank Symw:Symd:DirhM:M q s = some (none, { symbol := w, dir := d })⊢ cfgOf q false ((s :: lw) +> L) (rw +> R) [M]⊢* cfgOf q' false L (rw' +> R) All goals completed! 🐙 M:TMf:ℕq:Strw:List Syms:Symlw:List Symq':Strw':List Symh:(match M q s with | some (some q', { symbol := w, dir := Dir.left }) => runL M f q' (w :: rw) lw | some (some q', { symbol := w, dir := Dir.right }) => match rw with | [] => none | x :: rw' => runL M f q' rw' (x :: w :: lw) | x => none) = some (q', rw')L:ListBlank SymR:ListBlank Symq2:Stw:Symd:DirhM:M q s = some (some q2, { symbol := w, dir := d })⊢ cfgOf q false ((s :: lw) +> L) (rw +> R) [M]⊢* cfgOf q' false L (rw' +> R) cases d with M:TMf:ℕq:Strw:List Syms:Symlw:List Symq':Strw':List Symh:(match M q s with | some (some q', { symbol := w, dir := Dir.left }) => runL M f q' (w :: rw) lw | some (some q', { symbol := w, dir := Dir.right }) => match rw with | [] => none | x :: rw' => runL M f q' rw' (x :: w :: lw) | x => none) = some (q', rw')L:ListBlank SymR:ListBlank Symq2:Stw:SymhM:M q s = some (some q2, { symbol := w, dir := Dir.left })⊢ cfgOf q false ((s :: lw) +> L) (rw +> R) [M]⊢* cfgOf q' false L (rw' +> R) M:TMf:ℕq:Strw:List Syms:Symlw:List Symq':Strw':List SymL:ListBlank SymR:ListBlank Symq2:Stw:SymhM:M q s = some (some q2, { symbol := w, dir := Dir.left })h:runL M f q2 (w :: rw) lw = some (q', rw')⊢ cfgOf q false ((s :: lw) +> L) (rw +> R) [M]⊢* cfgOf q' false L (rw' +> R) M:TMf:ℕq:Strw:List Syms:Symlw:List Symq':Strw':List SymL:ListBlank SymR:ListBlank Symq2:Stw:SymhM:M q s = some (some q2, { symbol := w, dir := Dir.left })h:runL M f q2 (w :: rw) lw = some (q', rw')⊢ cfgOf q false ((s :: lw) +> L) (rw +> R) [M]⊢ cfgOf q2 false (lw +> L) ((w :: rw) +> R) All goals completed! 🐙 M:TMf:ℕq:Strw:List Syms:Symlw:List Symq':Strw':List Symh:(match M q s with | some (some q', { symbol := w, dir := Dir.left }) => runL M f q' (w :: rw) lw | some (some q', { symbol := w, dir := Dir.right }) => match rw with | [] => none | x :: rw' => runL M f q' rw' (x :: w :: lw) | x => none) = some (q', rw')L:ListBlank SymR:ListBlank Symq2:Stw:SymhM:M q s = some (some q2, { symbol := w, dir := Dir.right })⊢ cfgOf q false ((s :: lw) +> L) (rw +> R) [M]⊢* cfgOf q' false L (rw' +> R) M:TMf:ℕq:Strw:List Syms:Symlw:List Symq':Strw':List SymL:ListBlank SymR:ListBlank Symq2:Stw:SymhM:M q s = some (some q2, { symbol := w, dir := Dir.right })h:(match rw with | [] => none | x :: rw' => runL M f q2 rw' (x :: w :: lw)) = some (q', rw')⊢ cfgOf q false ((s :: lw) +> L) (rw +> R) [M]⊢* cfgOf q' false L (rw' +> R) M:TMf:ℕq:Sts:Symlw:List Symq':Strw':List SymL:ListBlank SymR:ListBlank Symq2:Stw:SymhM:M q s = some (some q2, { symbol := w, dir := Dir.right })h:(match [] with | [] => none | x :: rw' => runL M f q2 rw' (x :: w :: lw)) = some (q', rw')⊢ cfgOf q false ((s :: lw) +> L) ([] +> R) [M]⊢* cfgOf q' false L (rw' +> R)M:TMf:ℕq:Sts:Symlw:List Symq':Strw':List SymL:ListBlank SymR:ListBlank Symq2:Stw:SymhM:M q s = some (some q2, { symbol := w, dir := Dir.right })x:Symrw2:List Symh:(match x :: rw2 with | [] => none | x :: rw' => runL M f q2 rw' (x :: w :: lw)) = some (q', rw')⊢ cfgOf q false ((s :: lw) +> L) ((x :: rw2) +> R) [M]⊢* cfgOf q' false L (rw' +> R) M:TMf:ℕq:Sts:Symlw:List Symq':Strw':List SymL:ListBlank SymR:ListBlank Symq2:Stw:SymhM:M q s = some (some q2, { symbol := w, dir := Dir.right })h:(match [] with | [] => none | x :: rw' => runL M f q2 rw' (x :: w :: lw)) = some (q', rw')⊢ cfgOf q false ((s :: lw) +> L) ([] +> R) [M]⊢* cfgOf q' false L (rw' +> R) All goals completed! 🐙 M:TMf:ℕq:Sts:Symlw:List Symq':Strw':List SymL:ListBlank SymR:ListBlank Symq2:Stw:SymhM:M q s = some (some q2, { symbol := w, dir := Dir.right })x:Symrw2:List Symh:(match x :: rw2 with | [] => none | x :: rw' => runL M f q2 rw' (x :: w :: lw)) = some (q', rw')⊢ cfgOf q false ((s :: lw) +> L) ((x :: rw2) +> R) [M]⊢* cfgOf q' false L (rw' +> R) M:TMf:ℕq:Sts:Symlw:List Symq':Strw':List SymL:ListBlank SymR:ListBlank Symq2:Stw:SymhM:M q s = some (some q2, { symbol := w, dir := Dir.right })x:Symrw2:List Symh:runL M f q2 rw2 (x :: w :: lw) = some (q', rw')⊢ cfgOf q false ((s :: lw) +> L) ((x :: rw2) +> R) [M]⊢* cfgOf q' false L (rw' +> R) M:TMf:ℕq:Sts:Symlw:List Symq':Strw':List SymL:ListBlank SymR:ListBlank Symq2:Stw:SymhM:M q s = some (some q2, { symbol := w, dir := Dir.right })x:Symrw2:List Symh:runL M f q2 rw2 (x :: w :: lw) = some (q', rw')⊢ cfgOf q false ((s :: lw) +> L) ((x :: rw2) +> R) [M]⊢ cfgOf q2 false ((x :: w :: lw) +> L) (rw2 +> R) All goals completed! 🐙theorem shiftR_sound (M : TM) (f : ℕ) (q : St) (b lw' : List Sym) (h : runR M f q [] b = some (q, lw')) : ∀ (n : ℕ) (L R : ListBlank Sym), ReachesStar M (cfgOf q true L (ListBlank.append (b ^ n) R)) (cfgOf q true (ListBlank.append (lw' ^ n) L) R) | 0, L, R => ReachesStar.refl M _ M:TMf:ℕq:Stb:List Symlw':List Symh:runR M f q [] b = some (q, lw')n:ℕL:ListBlank SymR:ListBlank Sym⊢ cfgOf q true L (b ^ (n + 1) +> R) [M]⊢* cfgOf q true (lw' ^ (n + 1) +> L) R M:TMf:ℕq:Stb:List Symlw':List Symh:runR M f q [] b = some (q, lw')n:ℕL:ListBlank SymR:ListBlank Sym⊢ cfgOf q true L (b ^ (n + 1) +> R) [M]⊢* cfgOf q true (lw' ^ (n + 1) +> L) R M:TMf:ℕq:Stb:List Symlw':List Symh:runR M f q [] b = some (q, lw')n:ℕL:ListBlank SymR:ListBlank Symh1:cfgOf q true ([] +> L) (b +> b ^ n +> R) [M]⊢* cfgOf q true (lw' +> L) (b ^ n +> R)⊢ cfgOf q true L (b ^ (n + 1) +> R) [M]⊢* cfgOf q true (lw' ^ (n + 1) +> L) R M:TMf:ℕq:Stb:List Symlw':List Symh:runR M f q [] b = some (q, lw')n:ℕL:ListBlank SymR:ListBlank Symh1:cfgOf q true ([] +> L) (b +> b ^ n +> R) [M]⊢* cfgOf q true (lw' +> L) (b ^ n +> R)h2:cfgOf q true (lw' +> L) (b ^ n +> R) [M]⊢* cfgOf q true (lw' ^ n +> lw' +> L) R⊢ cfgOf q true L (b ^ (n + 1) +> R) [M]⊢* cfgOf q true (lw' ^ (n + 1) +> L) R M:TMf:ℕq:Stb:List Symlw':List Symh:runR M f q [] b = some (q, lw')n:ℕL:ListBlank SymR:ListBlank Symh1:cfgOf q true ([] +> L) (b +> b ^ n +> R) [M]⊢* cfgOf q true (lw' +> L) (b ^ n +> R)h2:cfgOf q true (lw' +> L) (b ^ n +> R) [M]⊢* cfgOf q true (lw' ^ n +> lw' +> L) R⊢ cfgOf q true L (b +> b ^ n +> R) [M]⊢* cfgOf q true (lw' ^ (n + 1) +> L) R M:TMf:ℕq:Stb:List Symlw':List Symh:runR M f q [] b = some (q, lw')n:ℕL:ListBlank SymR:ListBlank Symh1:cfgOf q true ([] +> L) (b +> b ^ n +> R) [M]⊢* cfgOf q true (lw' +> L) (b ^ n +> R)h2:cfgOf q true (lw' +> L) (b ^ n +> R) [M]⊢* cfgOf q true (lw' ^ n +> lw' +> L) R⊢ cfgOf q true L (b +> b ^ n +> R) [M]⊢* cfgOf q true (lw' ^ n +> lw' +> L) R All goals completed! 🐙theorem shiftL_sound (M : TM) (f : ℕ) (q : St) (b rw' : List Sym) (h : runL M f q [] b = some (q, rw')) : ∀ (n : ℕ) (L R : ListBlank Sym), ReachesStar M (cfgOf q false (ListBlank.append (b ^ n) L) R) (cfgOf q false L (ListBlank.append (rw' ^ n) R)) | 0, L, R => ReachesStar.refl M _ M:TMf:ℕq:Stb:List Symrw':List Symh:runL M f q [] b = some (q, rw')n:ℕL:ListBlank SymR:ListBlank Sym⊢ cfgOf q false (b ^ (n + 1) +> L) R [M]⊢* cfgOf q false L (rw' ^ (n + 1) +> R) M:TMf:ℕq:Stb:List Symrw':List Symh:runL M f q [] b = some (q, rw')n:ℕL:ListBlank SymR:ListBlank Sym⊢ cfgOf q false (b ^ (n + 1) +> L) R [M]⊢* cfgOf q false L (rw' ^ (n + 1) +> R) M:TMf:ℕq:Stb:List Symrw':List Symh:runL M f q [] b = some (q, rw')n:ℕL:ListBlank SymR:ListBlank Symh1:cfgOf q false (b +> b ^ n +> L) ([] +> R) [M]⊢* cfgOf q false (b ^ n +> L) (rw' +> R)⊢ cfgOf q false (b ^ (n + 1) +> L) R [M]⊢* cfgOf q false L (rw' ^ (n + 1) +> R) M:TMf:ℕq:Stb:List Symrw':List Symh:runL M f q [] b = some (q, rw')n:ℕL:ListBlank SymR:ListBlank Symh1:cfgOf q false (b +> b ^ n +> L) ([] +> R) [M]⊢* cfgOf q false (b ^ n +> L) (rw' +> R)h2:cfgOf q false (b ^ n +> L) (rw' +> R) [M]⊢* cfgOf q false L (rw' ^ n +> rw' +> R)⊢ cfgOf q false (b ^ (n + 1) +> L) R [M]⊢* cfgOf q false L (rw' ^ (n + 1) +> R) M:TMf:ℕq:Stb:List Symrw':List Symh:runL M f q [] b = some (q, rw')n:ℕL:ListBlank SymR:ListBlank Symh1:cfgOf q false (b +> b ^ n +> L) ([] +> R) [M]⊢* cfgOf q false (b ^ n +> L) (rw' +> R)h2:cfgOf q false (b ^ n +> L) (rw' +> R) [M]⊢* cfgOf q false L (rw' ^ n +> rw' +> R)⊢ cfgOf q false (b +> b ^ n +> L) R [M]⊢* cfgOf q false L (rw' ^ (n + 1) +> R) M:TMf:ℕq:Stb:List Symrw':List Symh:runL M f q [] b = some (q, rw')n:ℕL:ListBlank SymR:ListBlank Symh1:cfgOf q false (b +> b ^ n +> L) ([] +> R) [M]⊢* cfgOf q false (b ^ n +> L) (rw' +> R)h2:cfgOf q false (b ^ n +> L) (rw' +> R) [M]⊢* cfgOf q false L (rw' ^ n +> rw' +> R)⊢ cfgOf q false (b +> b ^ n +> L) R [M]⊢* cfgOf q false L (rw' ^ n +> rw' +> R) All goals completed! 🐙def shiftFuel : ℕ := 512def shiftOp (M : TM) (c : SC) : Option SC := if c.dr then match c.R with | s :: r => match runR M shiftFuel c.q [] s.b with | some (q', lw') => if q' == c.q then some ⟨c.q, true, ⟨lw', s.e⟩ :: c.L, r⟩ else none | none => none | [] => none else match c.L with | s :: l => match runL M shiftFuel c.q [] s.b with | some (q', rw') => if q' == c.q then some ⟨c.q, false, l, ⟨rw', s.e⟩ :: c.R⟩ else none | none => none | [] => nonetheorem shiftOp_sound (M : TM) (c c' : SC) (h : shiftOp M c = some c') (v : ℕ → ℕ) (tl tr : ListBlank Sym) : ReachesStar M (c.den v tl tr) (c'.den v tl tr) := M:TMc:SCc':SCh:shiftOp M c = some c'v:ℕ → ℕtl:ListBlank Symtr:ListBlank Sym⊢ c.den v tl tr [M]⊢* c'.den v tl tr M:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symq:Stdr:BoolL:List SegR:List Segh:shiftOp M { q := q, dr := dr, L := L, R := R } = some c'⊢ { q := q, dr := dr, L := L, R := R }.den v tl tr [M]⊢* c'.den v tl tr cases dr with M:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symq:StL:List SegR:List Segh:shiftOp M { q := q, dr := true, L := L, R := R } = some c'⊢ { q := q, dr := true, L := L, R := R }.den v tl tr [M]⊢* c'.den v tl tr M:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symq:StL:List SegR:List Segh:(match R with | s :: r => match runR M shiftFuel q [] s.b with | some (q', lw') => if (q' == q) = true then some { q := q, dr := true, L := { b := lw', e := s.e } :: L, R := r } else none | none => none | [] => none) = some c'⊢ { q := q, dr := true, L := L, R := R }.den v tl tr [M]⊢* c'.den v tl tr M:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symq:StL:List Segh:(match [] with | s :: r => match runR M shiftFuel q [] s.b with | some (q', lw') => if (q' == q) = true then some { q := q, dr := true, L := { b := lw', e := s.e } :: L, R := r } else none | none => none | [] => none) = some c'⊢ { q := q, dr := true, L := L, R := [] }.den v tl tr [M]⊢* c'.den v tl trM:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symq:StL:List Segs:Segr:List Segh:(match s :: r with | s :: r => match runR M shiftFuel q [] s.b with | some (q', lw') => if (q' == q) = true then some { q := q, dr := true, L := { b := lw', e := s.e } :: L, R := r } else none | none => none | [] => none) = some c'⊢ { q := q, dr := true, L := L, R := s :: r }.den v tl tr [M]⊢* c'.den v tl tr M:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symq:StL:List Segh:(match [] with | s :: r => match runR M shiftFuel q [] s.b with | some (q', lw') => if (q' == q) = true then some { q := q, dr := true, L := { b := lw', e := s.e } :: L, R := r } else none | none => none | [] => none) = some c'⊢ { q := q, dr := true, L := L, R := [] }.den v tl tr [M]⊢* c'.den v tl tr All goals completed! 🐙 M:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symq:StL:List Segs:Segr:List Segh:(match s :: r with | s :: r => match runR M shiftFuel q [] s.b with | some (q', lw') => if (q' == q) = true then some { q := q, dr := true, L := { b := lw', e := s.e } :: L, R := r } else none | none => none | [] => none) = some c'⊢ { q := q, dr := true, L := L, R := s :: r }.den v tl tr [M]⊢* c'.den v tl tr M:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symq:StL:List Segs:Segr:List Segh:(match runR M shiftFuel q [] s.b with | some (q', lw') => if (q' == q) = true then some { q := q, dr := true, L := { b := lw', e := s.e } :: L, R := r } else none | none => none) = some c'⊢ { q := q, dr := true, L := L, R := s :: r }.den v tl tr [M]⊢* c'.den v tl tr cases hr : runR M shiftFuel q [] s.b with M:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symq:StL:List Segs:Segr:List Segh:(match runR M shiftFuel q [] s.b with | some (q', lw') => if (q' == q) = true then some { q := q, dr := true, L := { b := lw', e := s.e } :: L, R := r } else none | none => none) = some c'hr:runR M shiftFuel q [] s.b = none⊢ { q := q, dr := true, L := L, R := s :: r }.den v tl tr [M]⊢* c'.den v tl tr All goals completed! 🐙 M:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symq:StL:List Segs:Segr:List Segh:(match runR M shiftFuel q [] s.b with | some (q', lw') => if (q' == q) = true then some { q := q, dr := true, L := { b := lw', e := s.e } :: L, R := r } else none | none => none) = some c'p:St × List Symhr:runR M shiftFuel q [] s.b = some p⊢ { q := q, dr := true, L := L, R := s :: r }.den v tl tr [M]⊢* c'.den v tl tr M:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symq:StL:List Segs:Segr:List Segh:(match runR M shiftFuel q [] s.b with | some (q', lw') => if (q' == q) = true then some { q := q, dr := true, L := { b := lw', e := s.e } :: L, R := r } else none | none => none) = some c'q':Stlw':List Symhr:runR M shiftFuel q [] s.b = some (q', lw')⊢ { q := q, dr := true, L := L, R := s :: r }.den v tl tr [M]⊢* c'.den v tl tr M:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symq:StL:List Segs:Segr:List Segq':Stlw':List Symhr:runR M shiftFuel q [] s.b = some (q', lw')h:(if (q' == q) = true then some { q := q, dr := true, L := { b := lw', e := s.e } :: L, R := r } else none) = some c'⊢ { q := q, dr := true, L := L, R := s :: r }.den v tl tr [M]⊢* c'.den v tl tr M:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symq:StL:List Segs:Segr:List Segq':Stlw':List Symhr:runR M shiftFuel q [] s.b = some (q', lw')h✝:(q' == q) = trueh:some { q := q, dr := true, L := { b := lw', e := s.e } :: L, R := r } = some c'⊢ { q := q, dr := true, L := L, R := s :: r }.den v tl tr [M]⊢* c'.den v tl trM:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symq:StL:List Segs:Segr:List Segq':Stlw':List Symhr:runR M shiftFuel q [] s.b = some (q', lw')h✝:¬(q' == q) = trueh:none = some c'⊢ { q := q, dr := true, L := L, R := s :: r }.den v tl tr [M]⊢* c'.den v tl tr M:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symq:StL:List Segs:Segr:List Segq':Stlw':List Symhr:runR M shiftFuel q [] s.b = some (q', lw')h✝:(q' == q) = trueh:some { q := q, dr := true, L := { b := lw', e := s.e } :: L, R := r } = some c'⊢ { q := q, dr := true, L := L, R := s :: r }.den v tl tr [M]⊢* c'.den v tl tr M:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symq:StL:List Segs:Segr:List Segq':Stlw':List Symhr:runR M shiftFuel q [] s.b = some (q', lw')hq:(q' == q) = trueh:some { q := q, dr := true, L := { b := lw', e := s.e } :: L, R := r } = some c'⊢ { q := q, dr := true, L := L, R := s :: r }.den v tl tr [M]⊢* c'.den v tl tr M:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symq:StL:List Segs:Segr:List Segq':Stlw':List Symhr:runR M shiftFuel q [] s.b = some (q', lw')h:some { q := q, dr := true, L := { b := lw', e := s.e } :: L, R := r } = some c'hq:q' = q⊢ { q := q, dr := true, L := L, R := s :: r }.den v tl tr [M]⊢* c'.den v tl tr M:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank SymL:List Segs:Segr:List Segq':Stlw':List Symhr:runR M shiftFuel q' [] s.b = some (q', lw')h:some { q := q', dr := true, L := { b := lw', e := s.e } :: L, R := r } = some c'⊢ { q := q', dr := true, L := L, R := s :: r }.den v tl tr [M]⊢* c'.den v tl tr M:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank SymL:List Segs:Segr:List Segq':Stlw':List Symhr:runR M shiftFuel q' [] s.b = some (q', lw')h:{ q := q', dr := true, L := { b := lw', e := s.e } :: L, R := r } = c'⊢ { q := q', dr := true, L := L, R := s :: r }.den v tl tr [M]⊢* c'.den v tl tr; M:TMv:ℕ → ℕtl:ListBlank Symtr:ListBlank SymL:List Segs:Segr:List Segq':Stlw':List Symhr:runR M shiftFuel q' [] s.b = some (q', lw')⊢ { q := q', dr := true, L := L, R := s :: r }.den v tl tr [M]⊢* { q := q', dr := true, L := { b := lw', e := s.e } :: L, R := r }.den v tl tr All goals completed! 🐙 M:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symq:StL:List Segs:Segr:List Segq':Stlw':List Symhr:runR M shiftFuel q [] s.b = some (q', lw')h✝:¬(q' == q) = trueh:none = some c'⊢ { q := q, dr := true, L := L, R := s :: r }.den v tl tr [M]⊢* c'.den v tl tr All goals completed! 🐙 M:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symq:StL:List SegR:List Segh:shiftOp M { q := q, dr := false, L := L, R := R } = some c'⊢ { q := q, dr := false, L := L, R := R }.den v tl tr [M]⊢* c'.den v tl tr M:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symq:StL:List SegR:List Segh:(match L with | s :: l => match runL M shiftFuel q [] s.b with | some (q', rw') => if (q' == q) = true then some { q := q, dr := false, L := l, R := { b := rw', e := s.e } :: R } else none | none => none | [] => none) = some c'⊢ { q := q, dr := false, L := L, R := R }.den v tl tr [M]⊢* c'.den v tl tr M:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symq:StR:List Segh:(match [] with | s :: l => match runL M shiftFuel q [] s.b with | some (q', rw') => if (q' == q) = true then some { q := q, dr := false, L := l, R := { b := rw', e := s.e } :: R } else none | none => none | [] => none) = some c'⊢ { q := q, dr := false, L := [], R := R }.den v tl tr [M]⊢* c'.den v tl trM:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symq:StR:List Segs:Segl:List Segh:(match s :: l with | s :: l => match runL M shiftFuel q [] s.b with | some (q', rw') => if (q' == q) = true then some { q := q, dr := false, L := l, R := { b := rw', e := s.e } :: R } else none | none => none | [] => none) = some c'⊢ { q := q, dr := false, L := s :: l, R := R }.den v tl tr [M]⊢* c'.den v tl tr M:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symq:StR:List Segh:(match [] with | s :: l => match runL M shiftFuel q [] s.b with | some (q', rw') => if (q' == q) = true then some { q := q, dr := false, L := l, R := { b := rw', e := s.e } :: R } else none | none => none | [] => none) = some c'⊢ { q := q, dr := false, L := [], R := R }.den v tl tr [M]⊢* c'.den v tl tr All goals completed! 🐙 M:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symq:StR:List Segs:Segl:List Segh:(match s :: l with | s :: l => match runL M shiftFuel q [] s.b with | some (q', rw') => if (q' == q) = true then some { q := q, dr := false, L := l, R := { b := rw', e := s.e } :: R } else none | none => none | [] => none) = some c'⊢ { q := q, dr := false, L := s :: l, R := R }.den v tl tr [M]⊢* c'.den v tl tr M:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symq:StR:List Segs:Segl:List Segh:(match runL M shiftFuel q [] s.b with | some (q', rw') => if (q' == q) = true then some { q := q, dr := false, L := l, R := { b := rw', e := s.e } :: R } else none | none => none) = some c'⊢ { q := q, dr := false, L := s :: l, R := R }.den v tl tr [M]⊢* c'.den v tl tr cases hr : runL M shiftFuel q [] s.b with M:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symq:StR:List Segs:Segl:List Segh:(match runL M shiftFuel q [] s.b with | some (q', rw') => if (q' == q) = true then some { q := q, dr := false, L := l, R := { b := rw', e := s.e } :: R } else none | none => none) = some c'hr:runL M shiftFuel q [] s.b = none⊢ { q := q, dr := false, L := s :: l, R := R }.den v tl tr [M]⊢* c'.den v tl tr All goals completed! 🐙 M:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symq:StR:List Segs:Segl:List Segh:(match runL M shiftFuel q [] s.b with | some (q', rw') => if (q' == q) = true then some { q := q, dr := false, L := l, R := { b := rw', e := s.e } :: R } else none | none => none) = some c'p:St × List Symhr:runL M shiftFuel q [] s.b = some p⊢ { q := q, dr := false, L := s :: l, R := R }.den v tl tr [M]⊢* c'.den v tl tr M:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symq:StR:List Segs:Segl:List Segh:(match runL M shiftFuel q [] s.b with | some (q', rw') => if (q' == q) = true then some { q := q, dr := false, L := l, R := { b := rw', e := s.e } :: R } else none | none => none) = some c'q':Strw':List Symhr:runL M shiftFuel q [] s.b = some (q', rw')⊢ { q := q, dr := false, L := s :: l, R := R }.den v tl tr [M]⊢* c'.den v tl tr M:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symq:StR:List Segs:Segl:List Segq':Strw':List Symhr:runL M shiftFuel q [] s.b = some (q', rw')h:(if (q' == q) = true then some { q := q, dr := false, L := l, R := { b := rw', e := s.e } :: R } else none) = some c'⊢ { q := q, dr := false, L := s :: l, R := R }.den v tl tr [M]⊢* c'.den v tl tr M:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symq:StR:List Segs:Segl:List Segq':Strw':List Symhr:runL M shiftFuel q [] s.b = some (q', rw')h✝:(q' == q) = trueh:some { q := q, dr := false, L := l, R := { b := rw', e := s.e } :: R } = some c'⊢ { q := q, dr := false, L := s :: l, R := R }.den v tl tr [M]⊢* c'.den v tl trM:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symq:StR:List Segs:Segl:List Segq':Strw':List Symhr:runL M shiftFuel q [] s.b = some (q', rw')h✝:¬(q' == q) = trueh:none = some c'⊢ { q := q, dr := false, L := s :: l, R := R }.den v tl tr [M]⊢* c'.den v tl tr M:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symq:StR:List Segs:Segl:List Segq':Strw':List Symhr:runL M shiftFuel q [] s.b = some (q', rw')h✝:(q' == q) = trueh:some { q := q, dr := false, L := l, R := { b := rw', e := s.e } :: R } = some c'⊢ { q := q, dr := false, L := s :: l, R := R }.den v tl tr [M]⊢* c'.den v tl tr M:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symq:StR:List Segs:Segl:List Segq':Strw':List Symhr:runL M shiftFuel q [] s.b = some (q', rw')hq:(q' == q) = trueh:some { q := q, dr := false, L := l, R := { b := rw', e := s.e } :: R } = some c'⊢ { q := q, dr := false, L := s :: l, R := R }.den v tl tr [M]⊢* c'.den v tl tr M:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symq:StR:List Segs:Segl:List Segq':Strw':List Symhr:runL M shiftFuel q [] s.b = some (q', rw')h:some { q := q, dr := false, L := l, R := { b := rw', e := s.e } :: R } = some c'hq:q' = q⊢ { q := q, dr := false, L := s :: l, R := R }.den v tl tr [M]⊢* c'.den v tl tr M:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank SymR:List Segs:Segl:List Segq':Strw':List Symhr:runL M shiftFuel q' [] s.b = some (q', rw')h:some { q := q', dr := false, L := l, R := { b := rw', e := s.e } :: R } = some c'⊢ { q := q', dr := false, L := s :: l, R := R }.den v tl tr [M]⊢* c'.den v tl tr M:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank SymR:List Segs:Segl:List Segq':Strw':List Symhr:runL M shiftFuel q' [] s.b = some (q', rw')h:{ q := q', dr := false, L := l, R := { b := rw', e := s.e } :: R } = c'⊢ { q := q', dr := false, L := s :: l, R := R }.den v tl tr [M]⊢* c'.den v tl tr; M:TMv:ℕ → ℕtl:ListBlank Symtr:ListBlank SymR:List Segs:Segl:List Segq':Strw':List Symhr:runL M shiftFuel q' [] s.b = some (q', rw')⊢ { q := q', dr := false, L := s :: l, R := R }.den v tl tr [M]⊢* { q := q', dr := false, L := l, R := { b := rw', e := s.e } :: R }.den v tl tr All goals completed! 🐙 M:TMc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symq:StR:List Segs:Segl:List Segq':Strw':List Symhr:runL M shiftFuel q [] s.b = some (q', rw')h✝:¬(q' == q) = trueh:none = some c'⊢ { q := q, dr := false, L := s :: l, R := R }.den v tl tr [M]⊢* c'.den v tl tr All goals completed! 🐙

Macro Rules (Proved by Sub-Certificates) and Their Application

structure Rule where lhs : SC rhs : SC plus : Bool dflt : Bool

A rule is valid if, for all parameter values and all (arbitrary) tape tails, the left-hand side reaches the right-hand side (in ≥ 1 steps if plus).

def RuleOK (M : TM) (r : Rule) : Prop := ∀ v tl tr, (r.dflt = true → tl = default ∧ tr = default) → ReachesStar M (r.lhs.den v tl tr) (r.rhs.den v tl tr) ∧ (r.plus = true → ReachesPlus M (r.lhs.den v tl tr) (r.rhs.den v tl tr))def matchPre (σ : List Lin) : List Seg → List Seg → Option (List Seg) | [], A => some A | p :: P, a :: A => if p.b == a.b && (p.e.substAll σ).beq a.e then matchPre σ P A else none | _ :: _, [] => nonetheorem matchPre_sound (σ : List Lin) : ∀ (P A Rst : List Seg), matchPre σ P A = some Rst → ∀ v t, hden v A t = hden (sem σ v) P (hden v Rst t) σ:List LinA:List SegRst:List Segh:matchPre σ [] A = some Rstv:ℕ → ℕt:ListBlank Sym⊢ hden v A t = hden (sem σ v) [] (hden v Rst t) σ:List LinA:List SegRst:List Segh:matchPre σ [] A = some Rstv:ℕ → ℕt:ListBlank Sym⊢ hden v A t = hden (sem σ v) [] (hden v Rst t) σ:List LinA:List SegRst:List Segv:ℕ → ℕt:ListBlank Symh:A = Rst⊢ hden v A t = hden (sem σ v) [] (hden v Rst t); σ:List LinA:List Segv:ℕ → ℕt:ListBlank Sym⊢ hden v A t = hden (sem σ v) [] (hden v A t); All goals completed! 🐙 σ:List Linp:SegP:List SegRst:List Segh:matchPre σ (p :: P) [] = some Rstv:ℕ → ℕt:ListBlank Sym⊢ hden v [] t = hden (sem σ v) (p :: P) (hden v Rst t) σ:List Linp:SegP:List SegRst:List Segh:matchPre σ (p :: P) [] = some Rstv:ℕ → ℕt:ListBlank Sym⊢ hden v [] t = hden (sem σ v) (p :: P) (hden v Rst t) All goals completed! 🐙 σ:List Linp:SegP:List Sega:SegA:List SegRst:List Segh:matchPre σ (p :: P) (a :: A) = some Rstv:ℕ → ℕt:ListBlank Sym⊢ hden v (a :: A) t = hden (sem σ v) (p :: P) (hden v Rst t) σ:List Linp:SegP:List Sega:SegA:List SegRst:List Segh:matchPre σ (p :: P) (a :: A) = some Rstv:ℕ → ℕt:ListBlank Sym⊢ hden v (a :: A) t = hden (sem σ v) (p :: P) (hden v Rst t) σ:List Linp:SegP:List Sega:SegA:List SegRst:List Segh:(if (p.b == a.b && (Lin.substAll σ p.e).beq a.e) = true then matchPre σ P A else none) = some Rstv:ℕ → ℕt:ListBlank Sym⊢ hden v (a :: A) t = hden (sem σ v) (p :: P) (hden v Rst t) σ:List Linp:SegP:List Sega:SegA:List SegRst:List Segv:ℕ → ℕt:ListBlank Symh✝:(p.b == a.b && (Lin.substAll σ p.e).beq a.e) = trueh:matchPre σ P A = some Rst⊢ hden v (a :: A) t = hden (sem σ v) (p :: P) (hden v Rst t)σ:List Linp:SegP:List Sega:SegA:List SegRst:List Segv:ℕ → ℕt:ListBlank Symh✝:¬(p.b == a.b && (Lin.substAll σ p.e).beq a.e) = trueh:none = some Rst⊢ hden v (a :: A) t = hden (sem σ v) (p :: P) (hden v Rst t) σ:List Linp:SegP:List Sega:SegA:List SegRst:List Segv:ℕ → ℕt:ListBlank Symh✝:(p.b == a.b && (Lin.substAll σ p.e).beq a.e) = trueh:matchPre σ P A = some Rst⊢ hden v (a :: A) t = hden (sem σ v) (p :: P) (hden v Rst t) σ:List Linp:SegP:List Sega:SegA:List SegRst:List Segv:ℕ → ℕt:ListBlank Symhc:(p.b == a.b && (Lin.substAll σ p.e).beq a.e) = trueh:matchPre σ P A = some Rst⊢ hden v (a :: A) t = hden (sem σ v) (p :: P) (hden v Rst t) σ:List Linp:SegP:List Sega:SegA:List SegRst:List Segv:ℕ → ℕt:ListBlank Symh:matchPre σ P A = some Rsthc:p.b = a.b ∧ (Lin.substAll σ p.e).beq a.e = true⊢ hden v (a :: A) t = hden (sem σ v) (p :: P) (hden v Rst t) σ:List Linp:SegP:List Sega:SegA:List SegRst:List Segv:ℕ → ℕt:ListBlank Symh:matchPre σ P A = some Rsthc:p.b = a.b ∧ (Lin.substAll σ p.e).beq a.e = truehe:Lin.eval v (Lin.substAll σ p.e) = Lin.eval v a.e⊢ hden v (a :: A) t = hden (sem σ v) (p :: P) (hden v Rst t) σ:List Linp:SegP:List Sega:SegA:List SegRst:List Segv:ℕ → ℕt:ListBlank Symh:matchPre σ P A = some Rsthc:p.b = a.b ∧ (Lin.substAll σ p.e).beq a.e = truehe:Lin.eval (sem σ v) p.e = Lin.eval v a.e⊢ hden v (a :: A) t = hden (sem σ v) (p :: P) (hden v Rst t) All goals completed! 🐙 σ:List Linp:SegP:List Sega:SegA:List SegRst:List Segv:ℕ → ℕt:ListBlank Symh✝:¬(p.b == a.b && (Lin.substAll σ p.e).beq a.e) = trueh:none = some Rst⊢ hden v (a :: A) t = hden (sem σ v) (p :: P) (hden v Rst t) All goals completed! 🐙def applyRule (r : Rule) (σ : List Lin) (c : SC) : Option SC := if r.lhs.q == c.q && r.lhs.dr == c.dr then match matchPre σ r.lhs.L c.L, matchPre σ r.lhs.R c.R with | some rl, some rr => if !r.dflt || (rl.isEmpty && rr.isEmpty) then some ⟨r.rhs.q, r.rhs.dr, sideSubstAll σ r.rhs.L ++ rl, sideSubstAll σ r.rhs.R ++ rr⟩ else none | _, _ => none else nonetheorem applyRule_sound (M : TM) (r : Rule) (hr : RuleOK M r) (σ : List Lin) (c c' : SC) (h : applyRule r σ c = some c') (v : ℕ → ℕ) (tl tr : ListBlank Sym) (ht : r.dflt = true → tl = default ∧ tr = default) : ReachesStar M (c.den v tl tr) (c'.den v tl tr) ∧ (r.plus = true → ReachesPlus M (c.den v tl tr) (c'.den v tl tr)) := M:TMr:Rulehr:RuleOK M rσ:List Linc:SCc':SCh:applyRule r σ c = some c'v:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:r.dflt = true → tl = default ∧ tr = default⊢ (c.den v tl tr [M]⊢* c'.den v tl tr) ∧ (r.plus = true → c.den v tl tr [M]⊢⁺ c'.den v tl tr) M:TMr:Rulehr:RuleOK M rσ:List Linc:SCc':SCh:(if (r.lhs.q == c.q && r.lhs.dr == c.dr) = true then match matchPre σ r.lhs.L c.L, matchPre σ r.lhs.R c.R with | some rl, some rr => if (!r.dflt || rl.isEmpty && rr.isEmpty) = true then some { q := r.rhs.q, dr := r.rhs.dr, L := sideSubstAll σ r.rhs.L ++ rl, R := sideSubstAll σ r.rhs.R ++ rr } else none | x, x_1 => none else none) = some c'v:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:r.dflt = true → tl = default ∧ tr = default⊢ (c.den v tl tr [M]⊢* c'.den v tl tr) ∧ (r.plus = true → c.den v tl tr [M]⊢⁺ c'.den v tl tr) M:TMr:Rulehr:RuleOK M rσ:List Linc:SCc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:r.dflt = true → tl = default ∧ tr = defaulth✝:(r.lhs.q == c.q && r.lhs.dr == c.dr) = trueh:(match matchPre σ r.lhs.L c.L, matchPre σ r.lhs.R c.R with | some rl, some rr => if (!r.dflt || rl.isEmpty && rr.isEmpty) = true then some { q := r.rhs.q, dr := r.rhs.dr, L := sideSubstAll σ r.rhs.L ++ rl, R := sideSubstAll σ r.rhs.R ++ rr } else none | x, x_1 => none) = some c'⊢ (c.den v tl tr [M]⊢* c'.den v tl tr) ∧ (r.plus = true → c.den v tl tr [M]⊢⁺ c'.den v tl tr)M:TMr:Rulehr:RuleOK M rσ:List Linc:SCc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:r.dflt = true → tl = default ∧ tr = defaulth✝:¬(r.lhs.q == c.q && r.lhs.dr == c.dr) = trueh:none = some c'⊢ (c.den v tl tr [M]⊢* c'.den v tl tr) ∧ (r.plus = true → c.den v tl tr [M]⊢⁺ c'.den v tl tr) M:TMr:Rulehr:RuleOK M rσ:List Linc:SCc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:r.dflt = true → tl = default ∧ tr = defaulth✝:(r.lhs.q == c.q && r.lhs.dr == c.dr) = trueh:(match matchPre σ r.lhs.L c.L, matchPre σ r.lhs.R c.R with | some rl, some rr => if (!r.dflt || rl.isEmpty && rr.isEmpty) = true then some { q := r.rhs.q, dr := r.rhs.dr, L := sideSubstAll σ r.rhs.L ++ rl, R := sideSubstAll σ r.rhs.R ++ rr } else none | x, x_1 => none) = some c'⊢ (c.den v tl tr [M]⊢* c'.den v tl tr) ∧ (r.plus = true → c.den v tl tr [M]⊢⁺ c'.den v tl tr) M:TMr:Rulehr:RuleOK M rσ:List Linc:SCc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:r.dflt = true → tl = default ∧ tr = defaulthq:(r.lhs.q == c.q && r.lhs.dr == c.dr) = trueh:(match matchPre σ r.lhs.L c.L, matchPre σ r.lhs.R c.R with | some rl, some rr => if (!r.dflt || rl.isEmpty && rr.isEmpty) = true then some { q := r.rhs.q, dr := r.rhs.dr, L := sideSubstAll σ r.rhs.L ++ rl, R := sideSubstAll σ r.rhs.R ++ rr } else none | x, x_1 => none) = some c'⊢ (c.den v tl tr [M]⊢* c'.den v tl tr) ∧ (r.plus = true → c.den v tl tr [M]⊢⁺ c'.den v tl tr) M:TMr:Rulehr:RuleOK M rσ:List Linc:SCc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:r.dflt = true → tl = default ∧ tr = defaulth:(match matchPre σ r.lhs.L c.L, matchPre σ r.lhs.R c.R with | some rl, some rr => if (!r.dflt || rl.isEmpty && rr.isEmpty) = true then some { q := r.rhs.q, dr := r.rhs.dr, L := sideSubstAll σ r.rhs.L ++ rl, R := sideSubstAll σ r.rhs.R ++ rr } else none | x, x_1 => none) = some c'hq:r.lhs.q = c.q ∧ r.lhs.dr = c.dr⊢ (c.den v tl tr [M]⊢* c'.den v tl tr) ∧ (r.plus = true → c.den v tl tr [M]⊢⁺ c'.den v tl tr) cases hl : matchPre σ r.lhs.L c.L with M:TMr:Rulehr:RuleOK M rσ:List Linc:SCc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:r.dflt = true → tl = default ∧ tr = defaulth:(match matchPre σ r.lhs.L c.L, matchPre σ r.lhs.R c.R with | some rl, some rr => if (!r.dflt || rl.isEmpty && rr.isEmpty) = true then some { q := r.rhs.q, dr := r.rhs.dr, L := sideSubstAll σ r.rhs.L ++ rl, R := sideSubstAll σ r.rhs.R ++ rr } else none | x, x_1 => none) = some c'hq:r.lhs.q = c.q ∧ r.lhs.dr = c.drhl:matchPre σ r.lhs.L c.L = none⊢ (c.den v tl tr [M]⊢* c'.den v tl tr) ∧ (r.plus = true → c.den v tl tr [M]⊢⁺ c'.den v tl tr) All goals completed! 🐙 M:TMr:Rulehr:RuleOK M rσ:List Linc:SCc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:r.dflt = true → tl = default ∧ tr = defaulth:(match matchPre σ r.lhs.L c.L, matchPre σ r.lhs.R c.R with | some rl, some rr => if (!r.dflt || rl.isEmpty && rr.isEmpty) = true then some { q := r.rhs.q, dr := r.rhs.dr, L := sideSubstAll σ r.rhs.L ++ rl, R := sideSubstAll σ r.rhs.R ++ rr } else none | x, x_1 => none) = some c'hq:r.lhs.q = c.q ∧ r.lhs.dr = c.drrl:List Seghl:matchPre σ r.lhs.L c.L = some rl⊢ (c.den v tl tr [M]⊢* c'.den v tl tr) ∧ (r.plus = true → c.den v tl tr [M]⊢⁺ c'.den v tl tr) cases hrr : matchPre σ r.lhs.R c.R with M:TMr:Rulehr:RuleOK M rσ:List Linc:SCc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:r.dflt = true → tl = default ∧ tr = defaulth:(match matchPre σ r.lhs.L c.L, matchPre σ r.lhs.R c.R with | some rl, some rr => if (!r.dflt || rl.isEmpty && rr.isEmpty) = true then some { q := r.rhs.q, dr := r.rhs.dr, L := sideSubstAll σ r.rhs.L ++ rl, R := sideSubstAll σ r.rhs.R ++ rr } else none | x, x_1 => none) = some c'hq:r.lhs.q = c.q ∧ r.lhs.dr = c.drrl:List Seghl:matchPre σ r.lhs.L c.L = some rlhrr:matchPre σ r.lhs.R c.R = none⊢ (c.den v tl tr [M]⊢* c'.den v tl tr) ∧ (r.plus = true → c.den v tl tr [M]⊢⁺ c'.den v tl tr) All goals completed! 🐙 M:TMr:Rulehr:RuleOK M rσ:List Linc:SCc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:r.dflt = true → tl = default ∧ tr = defaulth:(match matchPre σ r.lhs.L c.L, matchPre σ r.lhs.R c.R with | some rl, some rr => if (!r.dflt || rl.isEmpty && rr.isEmpty) = true then some { q := r.rhs.q, dr := r.rhs.dr, L := sideSubstAll σ r.rhs.L ++ rl, R := sideSubstAll σ r.rhs.R ++ rr } else none | x, x_1 => none) = some c'hq:r.lhs.q = c.q ∧ r.lhs.dr = c.drrl:List Seghl:matchPre σ r.lhs.L c.L = some rlrr:List Seghrr:matchPre σ r.lhs.R c.R = some rr⊢ (c.den v tl tr [M]⊢* c'.den v tl tr) ∧ (r.plus = true → c.den v tl tr [M]⊢⁺ c'.den v tl tr) M:TMr:Rulehr:RuleOK M rσ:List Linc:SCc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:r.dflt = true → tl = default ∧ tr = defaulthq:r.lhs.q = c.q ∧ r.lhs.dr = c.drrl:List Seghl:matchPre σ r.lhs.L c.L = some rlrr:List Seghrr:matchPre σ r.lhs.R c.R = some rrh:(if (!r.dflt || rl.isEmpty && rr.isEmpty) = true then some { q := r.rhs.q, dr := r.rhs.dr, L := sideSubstAll σ r.rhs.L ++ rl, R := sideSubstAll σ r.rhs.R ++ rr } else none) = some c'⊢ (c.den v tl tr [M]⊢* c'.den v tl tr) ∧ (r.plus = true → c.den v tl tr [M]⊢⁺ c'.den v tl tr) M:TMr:Rulehr:RuleOK M rσ:List Linc:SCc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:r.dflt = true → tl = default ∧ tr = defaulthq:r.lhs.q = c.q ∧ r.lhs.dr = c.drrl:List Seghl:matchPre σ r.lhs.L c.L = some rlrr:List Seghrr:matchPre σ r.lhs.R c.R = some rrh✝:(!r.dflt || rl.isEmpty && rr.isEmpty) = trueh:some { q := r.rhs.q, dr := r.rhs.dr, L := sideSubstAll σ r.rhs.L ++ rl, R := sideSubstAll σ r.rhs.R ++ rr } = some c'⊢ (c.den v tl tr [M]⊢* c'.den v tl tr) ∧ (r.plus = true → c.den v tl tr [M]⊢⁺ c'.den v tl tr)M:TMr:Rulehr:RuleOK M rσ:List Linc:SCc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:r.dflt = true → tl = default ∧ tr = defaulthq:r.lhs.q = c.q ∧ r.lhs.dr = c.drrl:List Seghl:matchPre σ r.lhs.L c.L = some rlrr:List Seghrr:matchPre σ r.lhs.R c.R = some rrh✝:¬(!r.dflt || rl.isEmpty && rr.isEmpty) = trueh:none = some c'⊢ (c.den v tl tr [M]⊢* c'.den v tl tr) ∧ (r.plus = true → c.den v tl tr [M]⊢⁺ c'.den v tl tr) M:TMr:Rulehr:RuleOK M rσ:List Linc:SCc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:r.dflt = true → tl = default ∧ tr = defaulthq:r.lhs.q = c.q ∧ r.lhs.dr = c.drrl:List Seghl:matchPre σ r.lhs.L c.L = some rlrr:List Seghrr:matchPre σ r.lhs.R c.R = some rrh✝:(!r.dflt || rl.isEmpty && rr.isEmpty) = trueh:some { q := r.rhs.q, dr := r.rhs.dr, L := sideSubstAll σ r.rhs.L ++ rl, R := sideSubstAll σ r.rhs.R ++ rr } = some c'⊢ (c.den v tl tr [M]⊢* c'.den v tl tr) ∧ (r.plus = true → c.den v tl tr [M]⊢⁺ c'.den v tl tr) M:TMr:Rulehr:RuleOK M rσ:List Linc:SCc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:r.dflt = true → tl = default ∧ tr = defaulthq:r.lhs.q = c.q ∧ r.lhs.dr = c.drrl:List Seghl:matchPre σ r.lhs.L c.L = some rlrr:List Seghrr:matchPre σ r.lhs.R c.R = some rrhdf:(!r.dflt || rl.isEmpty && rr.isEmpty) = trueh:some { q := r.rhs.q, dr := r.rhs.dr, L := sideSubstAll σ r.rhs.L ++ rl, R := sideSubstAll σ r.rhs.R ++ rr } = some c'⊢ (c.den v tl tr [M]⊢* c'.den v tl tr) ∧ (r.plus = true → c.den v tl tr [M]⊢⁺ c'.den v tl tr) M:TMr:Rulehr:RuleOK M rσ:List Linc:SCc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:r.dflt = true → tl = default ∧ tr = defaulthq:r.lhs.q = c.q ∧ r.lhs.dr = c.drrl:List Seghl:matchPre σ r.lhs.L c.L = some rlrr:List Seghrr:matchPre σ r.lhs.R c.R = some rrhdf:(!r.dflt || rl.isEmpty && rr.isEmpty) = trueh:{ q := r.rhs.q, dr := r.rhs.dr, L := sideSubstAll σ r.rhs.L ++ rl, R := sideSubstAll σ r.rhs.R ++ rr } = c'⊢ (c.den v tl tr [M]⊢* c'.den v tl tr) ∧ (r.plus = true → c.den v tl tr [M]⊢⁺ c'.den v tl tr) M:TMr:Rulehr:RuleOK M rσ:List Linc:SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:r.dflt = true → tl = default ∧ tr = defaulthq:r.lhs.q = c.q ∧ r.lhs.dr = c.drrl:List Seghl:matchPre σ r.lhs.L c.L = some rlrr:List Seghrr:matchPre σ r.lhs.R c.R = some rrhdf:(!r.dflt || rl.isEmpty && rr.isEmpty) = true⊢ (c.den v tl tr [M]⊢* { q := r.rhs.q, dr := r.rhs.dr, L := sideSubstAll σ r.rhs.L ++ rl, R := sideSubstAll σ r.rhs.R ++ rr }.den v tl tr) ∧ (r.plus = true → c.den v tl tr [M]⊢⁺ { q := r.rhs.q, dr := r.rhs.dr, L := sideSubstAll σ r.rhs.L ++ rl, R := sideSubstAll σ r.rhs.R ++ rr }.den v tl tr) M:TMr:Rulehr:RuleOK M rσ:List Linc:SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:r.dflt = true → tl = default ∧ tr = defaulthq:r.lhs.q = c.q ∧ r.lhs.dr = c.drrl:List Seghl:matchPre σ r.lhs.L c.L = some rlrr:List Seghrr:matchPre σ r.lhs.R c.R = some rrhdf:(!r.dflt || rl.isEmpty && rr.isEmpty) = truehrest:r.dflt = true → hden v rl tl = default ∧ hden v rr tr = default⊢ (c.den v tl tr [M]⊢* { q := r.rhs.q, dr := r.rhs.dr, L := sideSubstAll σ r.rhs.L ++ rl, R := sideSubstAll σ r.rhs.R ++ rr }.den v tl tr) ∧ (r.plus = true → c.den v tl tr [M]⊢⁺ { q := r.rhs.q, dr := r.rhs.dr, L := sideSubstAll σ r.rhs.L ++ rl, R := sideSubstAll σ r.rhs.R ++ rr }.den v tl tr) M:TMr:Rulehr:RuleOK M rσ:List Linc:SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:r.dflt = true → tl = default ∧ tr = defaulthq:r.lhs.q = c.q ∧ r.lhs.dr = c.drrl:List Seghl:matchPre σ r.lhs.L c.L = some rlrr:List Seghrr:matchPre σ r.lhs.R c.R = some rrhdf:(!r.dflt || rl.isEmpty && rr.isEmpty) = truehrest:r.dflt = true → hden v rl tl = default ∧ hden v rr tr = defaulte1:c.den v tl tr = r.lhs.den (sem σ v) (hden v rl tl) (hden v rr tr)⊢ (c.den v tl tr [M]⊢* { q := r.rhs.q, dr := r.rhs.dr, L := sideSubstAll σ r.rhs.L ++ rl, R := sideSubstAll σ r.rhs.R ++ rr }.den v tl tr) ∧ (r.plus = true → c.den v tl tr [M]⊢⁺ { q := r.rhs.q, dr := r.rhs.dr, L := sideSubstAll σ r.rhs.L ++ rl, R := sideSubstAll σ r.rhs.R ++ rr }.den v tl tr) M:TMr:Rulehr:RuleOK M rσ:List Linc:SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:r.dflt = true → tl = default ∧ tr = defaulthq:r.lhs.q = c.q ∧ r.lhs.dr = c.drrl:List Seghl:matchPre σ r.lhs.L c.L = some rlrr:List Seghrr:matchPre σ r.lhs.R c.R = some rrhdf:(!r.dflt || rl.isEmpty && rr.isEmpty) = truehrest:r.dflt = true → hden v rl tl = default ∧ hden v rr tr = defaulte1:c.den v tl tr = r.lhs.den (sem σ v) (hden v rl tl) (hden v rr tr)e2:{ q := r.rhs.q, dr := r.rhs.dr, L := sideSubstAll σ r.rhs.L ++ rl, R := sideSubstAll σ r.rhs.R ++ rr }.den v tl tr = r.rhs.den (sem σ v) (hden v rl tl) (hden v rr tr)⊢ (c.den v tl tr [M]⊢* { q := r.rhs.q, dr := r.rhs.dr, L := sideSubstAll σ r.rhs.L ++ rl, R := sideSubstAll σ r.rhs.R ++ rr }.den v tl tr) ∧ (r.plus = true → c.den v tl tr [M]⊢⁺ { q := r.rhs.q, dr := r.rhs.dr, L := sideSubstAll σ r.rhs.L ++ rl, R := sideSubstAll σ r.rhs.R ++ rr }.den v tl tr) M:TMr:Rulehr:RuleOK M rσ:List Linc:SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:r.dflt = true → tl = default ∧ tr = defaulthq:r.lhs.q = c.q ∧ r.lhs.dr = c.drrl:List Seghl:matchPre σ r.lhs.L c.L = some rlrr:List Seghrr:matchPre σ r.lhs.R c.R = some rrhdf:(!r.dflt || rl.isEmpty && rr.isEmpty) = truehrest:r.dflt = true → hden v rl tl = default ∧ hden v rr tr = defaulte1:c.den v tl tr = r.lhs.den (sem σ v) (hden v rl tl) (hden v rr tr)e2:{ q := r.rhs.q, dr := r.rhs.dr, L := sideSubstAll σ r.rhs.L ++ rl, R := sideSubstAll σ r.rhs.R ++ rr }.den v tl tr = r.rhs.den (sem σ v) (hden v rl tl) (hden v rr tr)⊢ (r.lhs.den (sem σ v) (hden v rl tl) (hden v rr tr) [M]⊢* r.rhs.den (sem σ v) (hden v rl tl) (hden v rr tr)) ∧ (r.plus = true → r.lhs.den (sem σ v) (hden v rl tl) (hden v rr tr) [M]⊢⁺ r.rhs.den (sem σ v) (hden v rl tl) (hden v rr tr)) All goals completed! 🐙 M:TMr:Rulehr:RuleOK M rσ:List Linc:SCc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:r.dflt = true → tl = default ∧ tr = defaulthq:r.lhs.q = c.q ∧ r.lhs.dr = c.drrl:List Seghl:matchPre σ r.lhs.L c.L = some rlrr:List Seghrr:matchPre σ r.lhs.R c.R = some rrh✝:¬(!r.dflt || rl.isEmpty && rr.isEmpty) = trueh:none = some c'⊢ (c.den v tl tr [M]⊢* c'.den v tl tr) ∧ (r.plus = true → c.den v tl tr [M]⊢⁺ c'.den v tl tr) All goals completed! 🐙 M:TMr:Rulehr:RuleOK M rσ:List Linc:SCc':SCv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:r.dflt = true → tl = default ∧ tr = defaulth✝:¬(r.lhs.q == c.q && r.lhs.dr == c.dr) = trueh:none = some c'⊢ (c.den v tl tr [M]⊢* c'.den v tl tr) ∧ (r.plus = true → c.den v tl tr [M]⊢⁺ c'.den v tl tr) All goals completed! 🐙

Hub Patterns

def segsExpr : List Seg → TapeExpr Sym | [] => .default | s :: r => match s.e.asVar with | some k => .rep s.b k (segsExpr r) | none => s.b.foldr TapeExpr.sym (segsExpr r)def segsOK : List Seg → Bool | [] => true | s :: r => (s.e.asVar.isSome || s.e.isConst 1) && segsOK rtheorem evalTapeExpr_foldr (b : List Sym) (rest : TapeExpr Sym) (v : ℕ → ℕ) : evalTapeExpr (b.foldr TapeExpr.sym rest) v = ListBlank.append b (evalTapeExpr rest v) := b:List Symrest:TapeExpr Symv:ℕ → ℕ⊢ evalTapeExpr (List.foldr TapeExpr.sym rest b) v = b +> evalTapeExpr rest v induction b with rest:TapeExpr Symv:ℕ → ℕ⊢ evalTapeExpr (List.foldr TapeExpr.sym rest []) v = [] +> evalTapeExpr rest v All goals completed! 🐙 rest:TapeExpr Symv:ℕ → ℕx:Symb:List Symih:evalTapeExpr (List.foldr TapeExpr.sym rest b) v = b +> evalTapeExpr rest v⊢ evalTapeExpr (List.foldr TapeExpr.sym rest (x :: b)) v = (x :: b) +> evalTapeExpr rest v All goals completed! 🐙theorem segsExpr_eval : ∀ (A : List Seg), segsOK A = true → ∀ v, evalTapeExpr (segsExpr A) v = hden v A default | [], _, v => rfl s:SegA:List Segh:segsOK (s :: A) = truev:ℕ → ℕ⊢ evalTapeExpr (segsExpr (s :: A)) v = hden v (s :: A) default s:SegA:List Segh:segsOK (s :: A) = truev:ℕ → ℕ⊢ evalTapeExpr (segsExpr (s :: A)) v = hden v (s :: A) default s:SegA:List Segv:ℕ → ℕh:(s.e.asVar.isSome = true ∨ s.e.isConst 1 = true) ∧ segsOK A = true⊢ evalTapeExpr (segsExpr (s :: A)) v = hden v (s :: A) default s:SegA:List Segv:ℕ → ℕh:(s.e.asVar.isSome = true ∨ s.e.isConst 1 = true) ∧ segsOK A = true⊢ evalTapeExpr (match s.e.asVar with | some k => TapeExpr.rep s.b k (segsExpr A) | none => List.foldr TapeExpr.sym (segsExpr A) s.b) v = hden v (s :: A) default cases hv : s.e.asVar with s:SegA:List Segv:ℕ → ℕh:(s.e.asVar.isSome = true ∨ s.e.isConst 1 = true) ∧ segsOK A = truek:ℕhv:s.e.asVar = some k⊢ evalTapeExpr (match some k with | some k => TapeExpr.rep s.b k (segsExpr A) | none => List.foldr TapeExpr.sym (segsExpr A) s.b) v = hden v (s :: A) default All goals completed! 🐙 s:SegA:List Segv:ℕ → ℕh:(s.e.asVar.isSome = true ∨ s.e.isConst 1 = true) ∧ segsOK A = truehv:s.e.asVar = none⊢ evalTapeExpr (match none with | some k => TapeExpr.rep s.b k (segsExpr A) | none => List.foldr TapeExpr.sym (segsExpr A) s.b) v = hden v (s :: A) default s:SegA:List Segv:ℕ → ℕh:(s.e.asVar.isSome = true ∨ s.e.isConst 1 = true) ∧ segsOK A = truehv:s.e.asVar = nonehc:s.e.isConst 1 = true⊢ evalTapeExpr (match none with | some k => TapeExpr.rep s.b k (segsExpr A) | none => List.foldr TapeExpr.sym (segsExpr A) s.b) v = hden v (s :: A) default All goals completed! 🐙def hubOK (h : SC) : Bool := h.dr && segsOK h.L && segsOK h.Rdef toPat (h : SC) : TapePattern Sym St := ⟨segsExpr h.L, some h.q, segsExpr h.R⟩def hubsPS (hubs : List SC) : TapePatternSet Sym St := hubs.map (fun h => (toPat h, VarCond.true))theorem toPat_eval (h : SC) (hok : hubOK h = true) (v : ℕ → ℕ) : evalTapePattern (toPat h) v = h.den v default default := h:SChok:hubOK h = truev:ℕ → ℕ⊢ evalTapePattern (toPat h) v = h.den v default default h:SCv:ℕ → ℕhok:(h.dr = true ∧ segsOK h.L = true) ∧ segsOK h.R = true⊢ evalTapePattern (toPat h) v = h.den v default default v:ℕ → ℕq:Stdr:BoolL:List SegR:List Seghok:({ q := q, dr := dr, L := L, R := R }.dr = true ∧ segsOK { q := q, dr := dr, L := L, R := R }.L = true) ∧ segsOK { q := q, dr := dr, L := L, R := R }.R = true⊢ evalTapePattern (toPat { q := q, dr := dr, L := L, R := R }) v = { q := q, dr := dr, L := L, R := R }.den v default default v:ℕ → ℕq:Stdr:BoolL:List SegR:List Seghok:(dr = true ∧ segsOK L = true) ∧ segsOK R = true⊢ evalTapePattern (toPat { q := q, dr := dr, L := L, R := R }) v = { q := q, dr := dr, L := L, R := R }.den v default default v:ℕ → ℕq:Stdr:BoolL:List SegR:List Seghok:(dr = true ∧ segsOK L = true) ∧ segsOK R = true⊢ evalTapePattern (toPat { q := q, dr := true, L := L, R := R }) v = { q := q, dr := true, L := L, R := R }.den v default default All goals completed! 🐙theorem in_hubsPS (hubs : List SC) (hh : ∀ h ∈ hubs, hubOK h = true) (h : SC) (hm : h ∈ hubs) (v : ℕ → ℕ) : IsInPatternSet (hubsPS hubs) (h.den v default default) := ⟨(toPat h, VarCond.true), List.mem_map.mpr ⟨h, hm, rfl⟩, v, (toPat_eval h (hh h hm) v).symm, trivial⟩

Goals, Instructions and the Checker

inductive Tgt | hubs | ps | cfg (c : SC)def Tgt.subst (i : ℕ) (f : Lin) : Tgt → Tgt | .cfg c => .cfg (c.subst i f) | t => tdef Tgt.isHub : Tgt → Bool | .cfg _ => false | _ => truestructure Goal where cur : SC np : Bool tgt : Tgtinductive Ins | step | shift | rw (left : Bool) (p : ℕ) (r : RW) | dropTail (left : Bool) | app (j : ℕ) (σ : List Lin) | splitZ (i : ℕ) | splitM (i m : ℕ) | hub (j : ℕ) (σ : List Lin) | halt | donedef Goal.subst (i : ℕ) (f : Lin) (g : Goal) : Goal := ⟨g.cur.subst i f, g.np, g.tgt.subst i f⟩def modBranch (i m r : ℕ) : Lin := (Lin.const r).add ((Lin.var i).scale m)def exec (M : TM) (hubs : List SC) (rules : List Rule) (dflt : Bool) (g : Goal) : Ins → Option (List Goal) | .step => (symStep M dflt g.cur).map (fun c' => [⟨c', false, g.tgt⟩]) | .shift => (shiftOp M g.cur).map (fun c' => [⟨c', g.np, g.tgt⟩]) | .rw left p r => if left then (rwAt r p g.cur.L).map (fun L' => [⟨⟨g.cur.q, g.cur.dr, L', g.cur.R⟩, g.np, g.tgt⟩]) else (rwAt r p g.cur.R).map (fun R' => [⟨⟨g.cur.q, g.cur.dr, g.cur.L, R'⟩, g.np, g.tgt⟩]) | .dropTail left => if dflt then if left then (dropTail g.cur.L).map (fun L' => [⟨⟨g.cur.q, g.cur.dr, L', g.cur.R⟩, g.np, g.tgt⟩]) else (dropTail g.cur.R).map (fun R' => [⟨⟨g.cur.q, g.cur.dr, g.cur.L, R'⟩, g.np, g.tgt⟩]) else none | .app j σ => match rules[j]? with | some r => if !r.dflt || dflt then (applyRule r σ g.cur).map (fun c' => [⟨c', g.np && !r.plus, g.tgt⟩]) else none | none => none | .splitZ i => some [g.subst i (Lin.const 0), g.subst i ((Lin.var i).add (Lin.const 1))] | .splitM i m => if 1 ≤ m then some ((List.range m).map (fun r => g.subst i (modBranch i m r))) else none | .hub j σ => match hubs[j]? with | some h => if dflt && !g.np && g.tgt.isHub && (h.substAll σ).beq g.cur then some [] else none | none => none | .halt => match g.tgt with | .hubs => if !g.np && isHalt M dflt g.cur then some [] else none | _ => none | .done => match g.tgt with | .cfg d => if !g.np && g.cur.beq d then some [] else none | _ => nonedef run (M : TM) (hubs : List SC) (rules : List Rule) (dflt : Bool) : List Ins → List Goal → Bool | [], gs => gs.isEmpty | _ :: _, [] => false | i :: is, g :: gs => match exec M hubs rules dflt g i with | some new => run M hubs rules dflt is (new ++ gs) | none => falsedef Final (M : TM) (ps : TapePatternSet Sym St) (t : Tgt) (v : ℕ → ℕ) (tl tr : ListBlank Sym) (c' : Cfg Sym St) : Prop := match t with | .hubs => IsInPatternSet ps c' ∨ (step M c').isNone | .ps => IsInPatternSet ps c' | .cfg d => c' = d.den v tl trdef Good (M : TM) (ps : TapePatternSet Sym St) (dflt : Bool) (g : Goal) : Prop := ∀ v tl tr, (dflt = true → tl = default ∧ tr = default) → ∃ c', ReachesStar M (g.cur.den v tl tr) c' ∧ (g.np = true → ReachesPlus M (g.cur.den v tl tr) c') ∧ Final M ps g.tgt v tl tr c'theorem Final_subst (M : TM) (ps : TapePatternSet Sym St) (t : Tgt) (i : ℕ) (f : Lin) (v : ℕ → ℕ) (tl tr : ListBlank Sym) (c' : Cfg Sym St) : Final M ps (t.subst i f) v tl tr c' ↔ Final M ps t (Function.update v i (f.eval v)) tl tr c' := M:TMps:TapePatternSet Sym Stt:Tgti:ℕf:Linv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symc':Cfg Sym St⊢ Final M ps (Tgt.subst i f t) v tl tr c' ↔ Final M ps t (Function.update v i (Lin.eval v f)) tl tr c' cases t with M:TMps:TapePatternSet Sym Sti:ℕf:Linv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symc':Cfg Sym St⊢ Final M ps (Tgt.subst i f Tgt.hubs) v tl tr c' ↔ Final M ps Tgt.hubs (Function.update v i (Lin.eval v f)) tl tr c' All goals completed! 🐙 M:TMps:TapePatternSet Sym Sti:ℕf:Linv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symc':Cfg Sym St⊢ Final M ps (Tgt.subst i f Tgt.ps) v tl tr c' ↔ Final M ps Tgt.ps (Function.update v i (Lin.eval v f)) tl tr c' All goals completed! 🐙 M:TMps:TapePatternSet Sym Sti:ℕf:Linv:ℕ → ℕtl:ListBlank Symtr:ListBlank Symc':Cfg Sym Std:SC⊢ Final M ps (Tgt.subst i f (Tgt.cfg d)) v tl tr c' ↔ Final M ps (Tgt.cfg d) (Function.update v i (Lin.eval v f)) tl tr c' All goals completed! 🐙

Instantiating a split branch: if the substituted goal is good, the original goal holds at every valuation v with v i = f.eval v' for v' = update v i k.

theorem Good_subst_at (M : TM) (ps : TapePatternSet Sym St) (dflt : Bool) (g : Goal) (i : ℕ) (f : Lin) (hg : Good M ps dflt (g.subst i f)) (v : ℕ → ℕ) (k : ℕ) (hk : f.eval (Function.update v i k) = v i) (tl tr : ListBlank Sym) (ht : dflt = true → tl = default ∧ tr = default) : ∃ c', ReachesStar M (g.cur.den v tl tr) c' ∧ (g.np = true → ReachesPlus M (g.cur.den v tl tr) c') ∧ Final M ps g.tgt v tl tr c' := M:TMps:TapePatternSet Sym Stdflt:Boolg:Goali:ℕf:Linhg:Good M ps dflt (Goal.subst i f g)v:ℕ → ℕk:ℕhk:Lin.eval (Function.update v i k) f = v itl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = default⊢ ∃ c', (g.cur.den v tl tr [M]⊢* c') ∧ (g.np = true → g.cur.den v tl tr [M]⊢⁺ c') ∧ Final M ps g.tgt v tl tr c' M:TMps:TapePatternSet Sym Stdflt:Boolg:Goali:ℕf:Linhg:Good M ps dflt (Goal.subst i f g)v:ℕ → ℕk:ℕhk:Lin.eval (Function.update v i k) f = v itl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultc':Cfg Sym Sth1:(Goal.subst i f g).cur.den (Function.update v i k) tl tr [M]⊢* c'h2:(Goal.subst i f g).np = true → (Goal.subst i f g).cur.den (Function.update v i k) tl tr [M]⊢⁺ c'h3:Final M ps (Goal.subst i f g).tgt (Function.update v i k) tl tr c'⊢ ∃ c', (g.cur.den v tl tr [M]⊢* c') ∧ (g.np = true → g.cur.den v tl tr [M]⊢⁺ c') ∧ Final M ps g.tgt v tl tr c' M:TMps:TapePatternSet Sym Stdflt:Boolg:Goali:ℕf:Linhg:Good M ps dflt (Goal.subst i f g)v:ℕ → ℕk:ℕhk:Lin.eval (Function.update v i k) f = v itl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultc':Cfg Sym Sth1:(Goal.subst i f g).cur.den (Function.update v i k) tl tr [M]⊢* c'h2:(Goal.subst i f g).np = true → (Goal.subst i f g).cur.den (Function.update v i k) tl tr [M]⊢⁺ c'h3:Final M ps (Goal.subst i f g).tgt (Function.update v i k) tl tr c'hv:Function.update (Function.update v i k) i (Lin.eval (Function.update v i k) f) = v⊢ ∃ c', (g.cur.den v tl tr [M]⊢* c') ∧ (g.np = true → g.cur.den v tl tr [M]⊢⁺ c') ∧ Final M ps g.tgt v tl tr c' M:TMps:TapePatternSet Sym Stdflt:Boolg:Goali:ℕf:Linhg:Good M ps dflt (Goal.subst i f g)v:ℕ → ℕk:ℕhk:Lin.eval (Function.update v i k) f = v itl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultc':Cfg Sym Sth3:Final M ps (Tgt.subst i f g.tgt) (Function.update v i k) tl tr c'hv:Function.update (Function.update v i k) i (Lin.eval (Function.update v i k) f) = vh1:g.cur.den v tl tr [M]⊢* c'h2:g.np = true → g.cur.den v tl tr [M]⊢⁺ c'⊢ ∃ c', (g.cur.den v tl tr [M]⊢* c') ∧ (g.np = true → g.cur.den v tl tr [M]⊢⁺ c') ∧ Final M ps g.tgt v tl tr c' M:TMps:TapePatternSet Sym Stdflt:Boolg:Goali:ℕf:Linhg:Good M ps dflt (Goal.subst i f g)v:ℕ → ℕk:ℕhk:Lin.eval (Function.update v i k) f = v itl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultc':Cfg Sym Sth3:Final M ps g.tgt v tl tr c'hv:Function.update (Function.update v i k) i (Lin.eval (Function.update v i k) f) = vh1:g.cur.den v tl tr [M]⊢* c'h2:g.np = true → g.cur.den v tl tr [M]⊢⁺ c'⊢ ∃ c', (g.cur.den v tl tr [M]⊢* c') ∧ (g.np = true → g.cur.den v tl tr [M]⊢⁺ c') ∧ Final M ps g.tgt v tl tr c' All goals completed! 🐙theorem Good_of_star (M : TM) (ps : TapePatternSet Sym St) (dflt : Bool) (g g' : Goal) (htg : g'.tgt = g.tgt) (hnp : g'.np = g.np) (hs : ∀ v tl tr, (dflt = true → tl = default ∧ tr = default) → ReachesStar M (g.cur.den v tl tr) (g'.cur.den v tl tr)) (hg : Good M ps dflt g') : Good M ps dflt g := M:TMps:TapePatternSet Sym Stdflt:Boolg:Goalg':Goalhtg:g'.tgt = g.tgthnp:g'.np = g.nphs:∀ (v : ℕ → ℕ) (tl tr : ListBlank Sym), (dflt = true → tl = default ∧ tr = default) → g.cur.den v tl tr [M]⊢* g'.cur.den v tl trhg:Good M ps dflt g'⊢ Good M ps dflt g M:TMps:TapePatternSet Sym Stdflt:Boolg:Goalg':Goalhtg:g'.tgt = g.tgthnp:g'.np = g.nphs:∀ (v : ℕ → ℕ) (tl tr : ListBlank Sym), (dflt = true → tl = default ∧ tr = default) → g.cur.den v tl tr [M]⊢* g'.cur.den v tl trhg:Good M ps dflt g'v:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = default⊢ ∃ c', (g.cur.den v tl tr [M]⊢* c') ∧ (g.np = true → g.cur.den v tl tr [M]⊢⁺ c') ∧ Final M ps g.tgt v tl tr c' M:TMps:TapePatternSet Sym Stdflt:Boolg:Goalg':Goalhtg:g'.tgt = g.tgthnp:g'.np = g.nphs:∀ (v : ℕ → ℕ) (tl tr : ListBlank Sym), (dflt = true → tl = default ∧ tr = default) → g.cur.den v tl tr [M]⊢* g'.cur.den v tl trhg:Good M ps dflt g'v:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultc':Cfg Sym Sth1:g'.cur.den v tl tr [M]⊢* c'h2:g'.np = true → g'.cur.den v tl tr [M]⊢⁺ c'h3:Final M ps g'.tgt v tl tr c'⊢ ∃ c', (g.cur.den v tl tr [M]⊢* c') ∧ (g.np = true → g.cur.den v tl tr [M]⊢⁺ c') ∧ Final M ps g.tgt v tl tr c' M:TMps:TapePatternSet Sym Stdflt:Boolg:Goalg':Goalhtg:g'.tgt = g.tgthnp:g'.np = g.nphs:∀ (v : ℕ → ℕ) (tl tr : ListBlank Sym), (dflt = true → tl = default ∧ tr = default) → g.cur.den v tl tr [M]⊢* g'.cur.den v tl trhg:Good M ps dflt g'v:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultc':Cfg Sym Sth1:g'.cur.den v tl tr [M]⊢* c'h2:g'.np = true → g'.cur.den v tl tr [M]⊢⁺ c'h3:Final M ps g'.tgt v tl tr c'hn:g.np = true⊢ g.cur.den v tl tr [M]⊢⁺ c' All goals completed! 🐙theorem Good_of_plus (M : TM) (ps : TapePatternSet Sym St) (dflt : Bool) (g g' : Goal) (htg : g'.tgt = g.tgt) (hs : ∀ v tl tr, (dflt = true → tl = default ∧ tr = default) → ReachesPlus M (g.cur.den v tl tr) (g'.cur.den v tl tr)) (hg : Good M ps dflt g') : Good M ps dflt g := M:TMps:TapePatternSet Sym Stdflt:Boolg:Goalg':Goalhtg:g'.tgt = g.tgths:∀ (v : ℕ → ℕ) (tl tr : ListBlank Sym), (dflt = true → tl = default ∧ tr = default) → g.cur.den v tl tr [M]⊢⁺ g'.cur.den v tl trhg:Good M ps dflt g'⊢ Good M ps dflt g M:TMps:TapePatternSet Sym Stdflt:Boolg:Goalg':Goalhtg:g'.tgt = g.tgths:∀ (v : ℕ → ℕ) (tl tr : ListBlank Sym), (dflt = true → tl = default ∧ tr = default) → g.cur.den v tl tr [M]⊢⁺ g'.cur.den v tl trhg:Good M ps dflt g'v:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = default⊢ ∃ c', (g.cur.den v tl tr [M]⊢* c') ∧ (g.np = true → g.cur.den v tl tr [M]⊢⁺ c') ∧ Final M ps g.tgt v tl tr c' M:TMps:TapePatternSet Sym Stdflt:Boolg:Goalg':Goalhtg:g'.tgt = g.tgths:∀ (v : ℕ → ℕ) (tl tr : ListBlank Sym), (dflt = true → tl = default ∧ tr = default) → g.cur.den v tl tr [M]⊢⁺ g'.cur.den v tl trhg:Good M ps dflt g'v:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultc':Cfg Sym Sth1:g'.cur.den v tl tr [M]⊢* c'h2:g'.np = true → g'.cur.den v tl tr [M]⊢⁺ c'h3:Final M ps g'.tgt v tl tr c'⊢ ∃ c', (g.cur.den v tl tr [M]⊢* c') ∧ (g.np = true → g.cur.den v tl tr [M]⊢⁺ c') ∧ Final M ps g.tgt v tl tr c' M:TMps:TapePatternSet Sym Stdflt:Boolg:Goalg':Goalhtg:g'.tgt = g.tgths:∀ (v : ℕ → ℕ) (tl tr : ListBlank Sym), (dflt = true → tl = default ∧ tr = default) → g.cur.den v tl tr [M]⊢⁺ g'.cur.den v tl trhg:Good M ps dflt g'v:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultc':Cfg Sym Sth1:g'.cur.den v tl tr [M]⊢* c'h2:g'.np = true → g'.cur.den v tl tr [M]⊢⁺ c'h3:Final M ps g'.tgt v tl tr c'hp:g.cur.den v tl tr [M]⊢⁺ c'⊢ ∃ c', (g.cur.den v tl tr [M]⊢* c') ∧ (g.np = true → g.cur.den v tl tr [M]⊢⁺ c') ∧ Final M ps g.tgt v tl tr c' All goals completed! 🐙theorem exec_sound (M : TM) (hubs : List SC) (hh : ∀ h ∈ hubs, hubOK h = true) (rules : List Rule) (hr : ∀ r ∈ rules, RuleOK M r) (dflt : Bool) (g : Goal) (i : Ins) (new : List Goal) (he : exec M hubs rules dflt g i = some new) (hn : ∀ g' ∈ new, Good M (hubsPS hubs) dflt g') : Good M (hubsPS hubs) dflt g := M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goali:Insnew:List Goalhe:exec M hubs rules dflt g i = some newhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'⊢ Good M (hubsPS hubs) dflt g cases i with M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'he:exec M hubs rules dflt g Ins.step = some new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'he:Option.map (fun c' ↦ [{ cur := c', np := false, tgt := g.tgt }]) (symStep M dflt g.cur) = some new⊢ Good M (hubsPS hubs) dflt g cases hs : symStep M dflt g.cur with M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'he:Option.map (fun c' ↦ [{ cur := c', np := false, tgt := g.tgt }]) (symStep M dflt g.cur) = some newhs:symStep M dflt g.cur = none⊢ Good M (hubsPS hubs) dflt g All goals completed! 🐙 M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'he:Option.map (fun c' ↦ [{ cur := c', np := false, tgt := g.tgt }]) (symStep M dflt g.cur) = some newc':SChs:symStep M dflt g.cur = some c'⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'c':SChs:symStep M dflt g.cur = some c'he:[{ cur := c', np := false, tgt := g.tgt }] = new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalc':SChs:symStep M dflt g.cur = some c'hn:∀ g' ∈ [{ cur := c', np := false, tgt := g.tgt }], Good M (hubsPS hubs) dflt g'⊢ Good M (hubsPS hubs) dflt g refine Good_of_plus M _ dflt g ⟨c', false, g.tgt⟩ rfl (fun v tl tr ht => ?_) (hn _ (M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalc':SChs:symStep M dflt g.cur = some c'hn:∀ g' ∈ [{ cur := c', np := false, tgt := g.tgt }], Good M (hubsPS hubs) dflt g'⊢ { cur := c', np := false, tgt := g.tgt } ∈ [{ cur := c', np := false, tgt := g.tgt }] All goals completed! 🐙)) All goals completed! 🐙 M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'he:exec M hubs rules dflt g Ins.shift = some new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'he:Option.map (fun c' ↦ [{ cur := c', np := g.np, tgt := g.tgt }]) (shiftOp M g.cur) = some new⊢ Good M (hubsPS hubs) dflt g cases hs : shiftOp M g.cur with M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'he:Option.map (fun c' ↦ [{ cur := c', np := g.np, tgt := g.tgt }]) (shiftOp M g.cur) = some newhs:shiftOp M g.cur = none⊢ Good M (hubsPS hubs) dflt g All goals completed! 🐙 M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'he:Option.map (fun c' ↦ [{ cur := c', np := g.np, tgt := g.tgt }]) (shiftOp M g.cur) = some newc':SChs:shiftOp M g.cur = some c'⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'c':SChs:shiftOp M g.cur = some c'he:[{ cur := c', np := g.np, tgt := g.tgt }] = new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalc':SChs:shiftOp M g.cur = some c'hn:∀ g' ∈ [{ cur := c', np := g.np, tgt := g.tgt }], Good M (hubsPS hubs) dflt g'⊢ Good M (hubsPS hubs) dflt g exact Good_of_star M _ dflt g ⟨c', g.np, g.tgt⟩ rfl rfl (fun v tl tr _ => shiftOp_sound M g.cur c' hs v tl tr) (hn _ (M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalc':SChs:shiftOp M g.cur = some c'hn:∀ g' ∈ [{ cur := c', np := g.np, tgt := g.tgt }], Good M (hubsPS hubs) dflt g'⊢ { cur := c', np := g.np, tgt := g.tgt } ∈ [{ cur := c', np := g.np, tgt := g.tgt }] All goals completed! 🐙)) M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'left:Boolp:ℕr:RWhe:exec M hubs rules dflt g (Ins.rw left p r) = some new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'left:Boolp:ℕr:RWhe:(if left = true then Option.map (fun L' ↦ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := L', R := g.cur.R }, np := g.np, tgt := g.tgt }]) (rwAt r p g.cur.L) else Option.map (fun R' ↦ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := g.cur.L, R := R' }, np := g.np, tgt := g.tgt }]) (rwAt r p g.cur.R)) = some new⊢ Good M (hubsPS hubs) dflt g cases left with M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'p:ℕr:RWhe:(if true = true then Option.map (fun L' ↦ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := L', R := g.cur.R }, np := g.np, tgt := g.tgt }]) (rwAt r p g.cur.L) else Option.map (fun R' ↦ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := g.cur.L, R := R' }, np := g.np, tgt := g.tgt }]) (rwAt r p g.cur.R)) = some new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'p:ℕr:RWhe:Option.map (fun L' ↦ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := L', R := g.cur.R }, np := g.np, tgt := g.tgt }]) (rwAt r p g.cur.L) = some new⊢ Good M (hubsPS hubs) dflt g cases hs : rwAt r p g.cur.L with M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'p:ℕr:RWhe:Option.map (fun L' ↦ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := L', R := g.cur.R }, np := g.np, tgt := g.tgt }]) (rwAt r p g.cur.L) = some newhs:rwAt r p g.cur.L = none⊢ Good M (hubsPS hubs) dflt g All goals completed! 🐙 M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'p:ℕr:RWhe:Option.map (fun L' ↦ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := L', R := g.cur.R }, np := g.np, tgt := g.tgt }]) (rwAt r p g.cur.L) = some newL':List Seghs:rwAt r p g.cur.L = some L'⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'p:ℕr:RWL':List Seghs:rwAt r p g.cur.L = some L'he:[{ cur := { q := g.cur.q, dr := g.cur.dr, L := L', R := g.cur.R }, np := g.np, tgt := g.tgt }] = new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalp:ℕr:RWL':List Seghs:rwAt r p g.cur.L = some L'hn:∀ g' ∈ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := L', R := g.cur.R }, np := g.np, tgt := g.tgt }], Good M (hubsPS hubs) dflt g'⊢ Good M (hubsPS hubs) dflt g refine Good_of_star M _ dflt g ⟨⟨g.cur.q, g.cur.dr, L', g.cur.R⟩, g.np, g.tgt⟩ rfl rfl (fun v tl tr _ => ?_) (hn _ (M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalp:ℕr:RWL':List Seghs:rwAt r p g.cur.L = some L'hn:∀ g' ∈ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := L', R := g.cur.R }, np := g.np, tgt := g.tgt }], Good M (hubsPS hubs) dflt g'⊢ { cur := { q := g.cur.q, dr := g.cur.dr, L := L', R := g.cur.R }, np := g.np, tgt := g.tgt } ∈ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := L', R := g.cur.R }, np := g.np, tgt := g.tgt }] All goals completed! 🐙)) M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalp:ℕr:RWL':List Seghs:rwAt r p g.cur.L = some L'hn:∀ g' ∈ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := L', R := g.cur.R }, np := g.np, tgt := g.tgt }], Good M (hubsPS hubs) dflt g'v:ℕ → ℕtl:ListBlank Symtr:ListBlank Symx✝:dflt = true → tl = default ∧ tr = default⊢ cfgOf g.cur.q g.cur.dr (hden v L' tl) (hden v g.cur.R tr) [M]⊢* cfgOf g.cur.q g.cur.dr (hden v L' tl) (hden v g.cur.R tr) All goals completed! 🐙 M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'p:ℕr:RWhe:(if false = true then Option.map (fun L' ↦ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := L', R := g.cur.R }, np := g.np, tgt := g.tgt }]) (rwAt r p g.cur.L) else Option.map (fun R' ↦ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := g.cur.L, R := R' }, np := g.np, tgt := g.tgt }]) (rwAt r p g.cur.R)) = some new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'p:ℕr:RWhe:Option.map (fun R' ↦ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := g.cur.L, R := R' }, np := g.np, tgt := g.tgt }]) (rwAt r p g.cur.R) = some new⊢ Good M (hubsPS hubs) dflt g cases hs : rwAt r p g.cur.R with M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'p:ℕr:RWhe:Option.map (fun R' ↦ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := g.cur.L, R := R' }, np := g.np, tgt := g.tgt }]) (rwAt r p g.cur.R) = some newhs:rwAt r p g.cur.R = none⊢ Good M (hubsPS hubs) dflt g All goals completed! 🐙 M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'p:ℕr:RWhe:Option.map (fun R' ↦ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := g.cur.L, R := R' }, np := g.np, tgt := g.tgt }]) (rwAt r p g.cur.R) = some newR':List Seghs:rwAt r p g.cur.R = some R'⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'p:ℕr:RWR':List Seghs:rwAt r p g.cur.R = some R'he:[{ cur := { q := g.cur.q, dr := g.cur.dr, L := g.cur.L, R := R' }, np := g.np, tgt := g.tgt }] = new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalp:ℕr:RWR':List Seghs:rwAt r p g.cur.R = some R'hn:∀ g' ∈ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := g.cur.L, R := R' }, np := g.np, tgt := g.tgt }], Good M (hubsPS hubs) dflt g'⊢ Good M (hubsPS hubs) dflt g refine Good_of_star M _ dflt g ⟨⟨g.cur.q, g.cur.dr, g.cur.L, R'⟩, g.np, g.tgt⟩ rfl rfl (fun v tl tr _ => ?_) (hn _ (M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalp:ℕr:RWR':List Seghs:rwAt r p g.cur.R = some R'hn:∀ g' ∈ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := g.cur.L, R := R' }, np := g.np, tgt := g.tgt }], Good M (hubsPS hubs) dflt g'⊢ { cur := { q := g.cur.q, dr := g.cur.dr, L := g.cur.L, R := R' }, np := g.np, tgt := g.tgt } ∈ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := g.cur.L, R := R' }, np := g.np, tgt := g.tgt }] All goals completed! 🐙)) M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalp:ℕr:RWR':List Seghs:rwAt r p g.cur.R = some R'hn:∀ g' ∈ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := g.cur.L, R := R' }, np := g.np, tgt := g.tgt }], Good M (hubsPS hubs) dflt g'v:ℕ → ℕtl:ListBlank Symtr:ListBlank Symx✝:dflt = true → tl = default ∧ tr = default⊢ cfgOf g.cur.q g.cur.dr (hden v g.cur.L tl) (hden v R' tr) [M]⊢* cfgOf g.cur.q g.cur.dr (hden v g.cur.L tl) (hden v R' tr) All goals completed! 🐙 M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'left:Boolhe:exec M hubs rules dflt g (Ins.dropTail left) = some new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'left:Boolhe:(if dflt = true then if left = true then Option.map (fun L' ↦ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := L', R := g.cur.R }, np := g.np, tgt := g.tgt }]) (dropTail g.cur.L) else Option.map (fun R' ↦ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := g.cur.L, R := R' }, np := g.np, tgt := g.tgt }]) (dropTail g.cur.R) else none) = some new⊢ Good M (hubsPS hubs) dflt g cases hd : dflt with M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'left:Boolhe:(if dflt = true then if left = true then Option.map (fun L' ↦ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := L', R := g.cur.R }, np := g.np, tgt := g.tgt }]) (dropTail g.cur.L) else Option.map (fun R' ↦ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := g.cur.L, R := R' }, np := g.np, tgt := g.tgt }]) (dropTail g.cur.R) else none) = some newhd:dflt = false⊢ Good M (hubsPS hubs) false g All goals completed! 🐙 M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'left:Boolhe:(if dflt = true then if left = true then Option.map (fun L' ↦ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := L', R := g.cur.R }, np := g.np, tgt := g.tgt }]) (dropTail g.cur.L) else Option.map (fun R' ↦ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := g.cur.L, R := R' }, np := g.np, tgt := g.tgt }]) (dropTail g.cur.R) else none) = some newhd:dflt = true⊢ Good M (hubsPS hubs) true g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'left:Boolhd:dflt = truehe:(if left = true then Option.map (fun L' ↦ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := L', R := g.cur.R }, np := g.np, tgt := g.tgt }]) (dropTail g.cur.L) else Option.map (fun R' ↦ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := g.cur.L, R := R' }, np := g.np, tgt := g.tgt }]) (dropTail g.cur.R)) = some new⊢ Good M (hubsPS hubs) true g cases left with M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'hd:dflt = truehe:(if true = true then Option.map (fun L' ↦ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := L', R := g.cur.R }, np := g.np, tgt := g.tgt }]) (dropTail g.cur.L) else Option.map (fun R' ↦ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := g.cur.L, R := R' }, np := g.np, tgt := g.tgt }]) (dropTail g.cur.R)) = some new⊢ Good M (hubsPS hubs) true g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'hd:dflt = truehe:Option.map (fun L' ↦ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := L', R := g.cur.R }, np := g.np, tgt := g.tgt }]) (dropTail g.cur.L) = some new⊢ Good M (hubsPS hubs) true g cases hs : dropTail g.cur.L with M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'hd:dflt = truehe:Option.map (fun L' ↦ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := L', R := g.cur.R }, np := g.np, tgt := g.tgt }]) (dropTail g.cur.L) = some newhs:dropTail g.cur.L = none⊢ Good M (hubsPS hubs) true g All goals completed! 🐙 M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'hd:dflt = truehe:Option.map (fun L' ↦ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := L', R := g.cur.R }, np := g.np, tgt := g.tgt }]) (dropTail g.cur.L) = some newL':List Seghs:dropTail g.cur.L = some L'⊢ Good M (hubsPS hubs) true g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'hd:dflt = trueL':List Seghs:dropTail g.cur.L = some L'he:[{ cur := { q := g.cur.q, dr := g.cur.dr, L := L', R := g.cur.R }, np := g.np, tgt := g.tgt }] = new⊢ Good M (hubsPS hubs) true g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalhd:dflt = trueL':List Seghs:dropTail g.cur.L = some L'hn:∀ g' ∈ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := L', R := g.cur.R }, np := g.np, tgt := g.tgt }], Good M (hubsPS hubs) dflt g'⊢ Good M (hubsPS hubs) true g refine Good_of_star M _ true g ⟨⟨g.cur.q, g.cur.dr, L', g.cur.R⟩, g.np, g.tgt⟩ rfl rfl (fun v tl tr ht => ?_) (hd ▸ hn _ (M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalhd:dflt = trueL':List Seghs:dropTail g.cur.L = some L'hn:∀ g' ∈ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := L', R := g.cur.R }, np := g.np, tgt := g.tgt }], Good M (hubsPS hubs) dflt g'⊢ { cur := { q := g.cur.q, dr := g.cur.dr, L := L', R := g.cur.R }, np := g.np, tgt := g.tgt } ∈ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := L', R := g.cur.R }, np := g.np, tgt := g.tgt }] All goals completed! 🐙)) M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalhd:dflt = trueL':List Seghs:dropTail g.cur.L = some L'hn:∀ g' ∈ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := L', R := g.cur.R }, np := g.np, tgt := g.tgt }], Good M (hubsPS hubs) dflt g'v:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:true = true → tl = default ∧ tr = defaulth1:tl = defaulth2:tr = default⊢ g.cur.den v tl tr [M]⊢* { cur := { q := g.cur.q, dr := g.cur.dr, L := L', R := g.cur.R }, np := g.np, tgt := g.tgt }.cur.den v tl tr M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalhd:dflt = trueL':List Seghs:dropTail g.cur.L = some L'hn:∀ g' ∈ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := L', R := g.cur.R }, np := g.np, tgt := g.tgt }], Good M (hubsPS hubs) dflt g'v:ℕ → ℕtr:ListBlank Symh2:tr = defaultht:true = true → default = default ∧ tr = default⊢ g.cur.den v default tr [M]⊢* { cur := { q := g.cur.q, dr := g.cur.dr, L := L', R := g.cur.R }, np := g.np, tgt := g.tgt }.cur.den v default tr; M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalhd:dflt = trueL':List Seghs:dropTail g.cur.L = some L'hn:∀ g' ∈ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := L', R := g.cur.R }, np := g.np, tgt := g.tgt }], Good M (hubsPS hubs) dflt g'v:ℕ → ℕht:true = true → default = default ∧ default = default⊢ g.cur.den v default default [M]⊢* { cur := { q := g.cur.q, dr := g.cur.dr, L := L', R := g.cur.R }, np := g.np, tgt := g.tgt }.cur.den v default default M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalhd:dflt = trueL':List Seghs:dropTail g.cur.L = some L'hn:∀ g' ∈ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := L', R := g.cur.R }, np := g.np, tgt := g.tgt }], Good M (hubsPS hubs) dflt g'v:ℕ → ℕht:true = true → default = default ∧ default = default⊢ cfgOf g.cur.q g.cur.dr (hden v L' default) (hden v g.cur.R default) [M]⊢* cfgOf g.cur.q g.cur.dr (hden v L' default) (hden v g.cur.R default) All goals completed! 🐙 M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'hd:dflt = truehe:(if false = true then Option.map (fun L' ↦ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := L', R := g.cur.R }, np := g.np, tgt := g.tgt }]) (dropTail g.cur.L) else Option.map (fun R' ↦ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := g.cur.L, R := R' }, np := g.np, tgt := g.tgt }]) (dropTail g.cur.R)) = some new⊢ Good M (hubsPS hubs) true g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'hd:dflt = truehe:Option.map (fun R' ↦ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := g.cur.L, R := R' }, np := g.np, tgt := g.tgt }]) (dropTail g.cur.R) = some new⊢ Good M (hubsPS hubs) true g cases hs : dropTail g.cur.R with M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'hd:dflt = truehe:Option.map (fun R' ↦ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := g.cur.L, R := R' }, np := g.np, tgt := g.tgt }]) (dropTail g.cur.R) = some newhs:dropTail g.cur.R = none⊢ Good M (hubsPS hubs) true g All goals completed! 🐙 M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'hd:dflt = truehe:Option.map (fun R' ↦ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := g.cur.L, R := R' }, np := g.np, tgt := g.tgt }]) (dropTail g.cur.R) = some newR':List Seghs:dropTail g.cur.R = some R'⊢ Good M (hubsPS hubs) true g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'hd:dflt = trueR':List Seghs:dropTail g.cur.R = some R'he:[{ cur := { q := g.cur.q, dr := g.cur.dr, L := g.cur.L, R := R' }, np := g.np, tgt := g.tgt }] = new⊢ Good M (hubsPS hubs) true g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalhd:dflt = trueR':List Seghs:dropTail g.cur.R = some R'hn:∀ g' ∈ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := g.cur.L, R := R' }, np := g.np, tgt := g.tgt }], Good M (hubsPS hubs) dflt g'⊢ Good M (hubsPS hubs) true g refine Good_of_star M _ true g ⟨⟨g.cur.q, g.cur.dr, g.cur.L, R'⟩, g.np, g.tgt⟩ rfl rfl (fun v tl tr ht => ?_) (hd ▸ hn _ (M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalhd:dflt = trueR':List Seghs:dropTail g.cur.R = some R'hn:∀ g' ∈ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := g.cur.L, R := R' }, np := g.np, tgt := g.tgt }], Good M (hubsPS hubs) dflt g'⊢ { cur := { q := g.cur.q, dr := g.cur.dr, L := g.cur.L, R := R' }, np := g.np, tgt := g.tgt } ∈ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := g.cur.L, R := R' }, np := g.np, tgt := g.tgt }] All goals completed! 🐙)) M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalhd:dflt = trueR':List Seghs:dropTail g.cur.R = some R'hn:∀ g' ∈ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := g.cur.L, R := R' }, np := g.np, tgt := g.tgt }], Good M (hubsPS hubs) dflt g'v:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:true = true → tl = default ∧ tr = defaulth1:tl = defaulth2:tr = default⊢ g.cur.den v tl tr [M]⊢* { cur := { q := g.cur.q, dr := g.cur.dr, L := g.cur.L, R := R' }, np := g.np, tgt := g.tgt }.cur.den v tl tr M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalhd:dflt = trueR':List Seghs:dropTail g.cur.R = some R'hn:∀ g' ∈ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := g.cur.L, R := R' }, np := g.np, tgt := g.tgt }], Good M (hubsPS hubs) dflt g'v:ℕ → ℕtr:ListBlank Symh2:tr = defaultht:true = true → default = default ∧ tr = default⊢ g.cur.den v default tr [M]⊢* { cur := { q := g.cur.q, dr := g.cur.dr, L := g.cur.L, R := R' }, np := g.np, tgt := g.tgt }.cur.den v default tr; M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalhd:dflt = trueR':List Seghs:dropTail g.cur.R = some R'hn:∀ g' ∈ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := g.cur.L, R := R' }, np := g.np, tgt := g.tgt }], Good M (hubsPS hubs) dflt g'v:ℕ → ℕht:true = true → default = default ∧ default = default⊢ g.cur.den v default default [M]⊢* { cur := { q := g.cur.q, dr := g.cur.dr, L := g.cur.L, R := R' }, np := g.np, tgt := g.tgt }.cur.den v default default M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalhd:dflt = trueR':List Seghs:dropTail g.cur.R = some R'hn:∀ g' ∈ [{ cur := { q := g.cur.q, dr := g.cur.dr, L := g.cur.L, R := R' }, np := g.np, tgt := g.tgt }], Good M (hubsPS hubs) dflt g'v:ℕ → ℕht:true = true → default = default ∧ default = default⊢ cfgOf g.cur.q g.cur.dr (hden v g.cur.L default) (hden v R' default) [M]⊢* cfgOf g.cur.q g.cur.dr (hden v g.cur.L default) (hden v R' default) All goals completed! 🐙 M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linhe:exec M hubs rules dflt g (Ins.app j σ) = some new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linhe:(match rules[j]? with | some r => if (!r.dflt || dflt) = true then Option.map (fun c' ↦ [{ cur := c', np := g.np && !r.plus, tgt := g.tgt }]) (applyRule r σ g.cur) else none | none => none) = some new⊢ Good M (hubsPS hubs) dflt g cases hj : rules[j]? with M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linhe:(match rules[j]? with | some r => if (!r.dflt || dflt) = true then Option.map (fun c' ↦ [{ cur := c', np := g.np && !r.plus, tgt := g.tgt }]) (applyRule r σ g.cur) else none | none => none) = some newhj:rules[j]? = none⊢ Good M (hubsPS hubs) dflt g All goals completed! 🐙 M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linhe:(match rules[j]? with | some r => if (!r.dflt || dflt) = true then Option.map (fun c' ↦ [{ cur := c', np := g.np && !r.plus, tgt := g.tgt }]) (applyRule r σ g.cur) else none | none => none) = some newr:Rulehj:rules[j]? = some r⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linr:Rulehj:rules[j]? = some rhe:(if (!r.dflt || dflt) = true then Option.map (fun c' ↦ [{ cur := c', np := g.np && !r.plus, tgt := g.tgt }]) (applyRule r σ g.cur) else none) = some new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linr:Rulehj:rules[j]? = some rhe:(if (!r.dflt || dflt) = true then Option.map (fun c' ↦ [{ cur := c', np := g.np && !r.plus, tgt := g.tgt }]) (applyRule r σ g.cur) else none) = some newhrok:RuleOK M r⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linr:Rulehj:rules[j]? = some rhrok:RuleOK M rh✝:(!r.dflt || dflt) = truehe:Option.map (fun c' ↦ [{ cur := c', np := g.np && !r.plus, tgt := g.tgt }]) (applyRule r σ g.cur) = some new⊢ Good M (hubsPS hubs) dflt gM:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linr:Rulehj:rules[j]? = some rhrok:RuleOK M rh✝:¬(!r.dflt || dflt) = truehe:none = some new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linr:Rulehj:rules[j]? = some rhrok:RuleOK M rh✝:¬(!r.dflt || dflt) = truehe:none = some new⊢ Good M (hubsPS hubs) dflt gM:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linr:Rulehj:rules[j]? = some rhrok:RuleOK M rh✝:(!r.dflt || dflt) = truehe:Option.map (fun c' ↦ [{ cur := c', np := g.np && !r.plus, tgt := g.tgt }]) (applyRule r σ g.cur) = some new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linr:Rulehj:rules[j]? = some rhrok:RuleOK M rh✝:¬(!r.dflt || dflt) = truehe:none = some new⊢ Good M (hubsPS hubs) dflt g All goals completed! 🐙 M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linr:Rulehj:rules[j]? = some rhrok:RuleOK M rhdf:(!r.dflt || dflt) = truehe:Option.map (fun c' ↦ [{ cur := c', np := g.np && !r.plus, tgt := g.tgt }]) (applyRule r σ g.cur) = some new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linr:Rulehj:rules[j]? = some rhrok:RuleOK M rhdf:(!r.dflt || dflt) = truehe:Option.map (fun c' ↦ [{ cur := c', np := g.np && !r.plus, tgt := g.tgt }]) (applyRule r σ g.cur) = some newhtl:∀ (tl tr : ListBlank Sym), (dflt = true → tl = default ∧ tr = default) → r.dflt = true → tl = default ∧ tr = default⊢ Good M (hubsPS hubs) dflt g cases ha : applyRule r σ g.cur with M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linr:Rulehj:rules[j]? = some rhrok:RuleOK M rhdf:(!r.dflt || dflt) = truehe:Option.map (fun c' ↦ [{ cur := c', np := g.np && !r.plus, tgt := g.tgt }]) (applyRule r σ g.cur) = some newhtl:∀ (tl tr : ListBlank Sym), (dflt = true → tl = default ∧ tr = default) → r.dflt = true → tl = default ∧ tr = defaultha:applyRule r σ g.cur = none⊢ Good M (hubsPS hubs) dflt g All goals completed! 🐙 M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linr:Rulehj:rules[j]? = some rhrok:RuleOK M rhdf:(!r.dflt || dflt) = truehe:Option.map (fun c' ↦ [{ cur := c', np := g.np && !r.plus, tgt := g.tgt }]) (applyRule r σ g.cur) = some newhtl:∀ (tl tr : ListBlank Sym), (dflt = true → tl = default ∧ tr = default) → r.dflt = true → tl = default ∧ tr = defaultc':SCha:applyRule r σ g.cur = some c'⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linr:Rulehj:rules[j]? = some rhrok:RuleOK M rhdf:(!r.dflt || dflt) = truehtl:∀ (tl tr : ListBlank Sym), (dflt = true → tl = default ∧ tr = default) → r.dflt = true → tl = default ∧ tr = defaultc':SCha:applyRule r σ g.cur = some c'he:[{ cur := c', np := g.np && !r.plus, tgt := g.tgt }] = new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalj:ℕσ:List Linr:Rulehj:rules[j]? = some rhrok:RuleOK M rhdf:(!r.dflt || dflt) = truehtl:∀ (tl tr : ListBlank Sym), (dflt = true → tl = default ∧ tr = default) → r.dflt = true → tl = default ∧ tr = defaultc':SCha:applyRule r σ g.cur = some c'hn:∀ g' ∈ [{ cur := c', np := g.np && !r.plus, tgt := g.tgt }], Good M (hubsPS hubs) dflt g'⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalj:ℕσ:List Linr:Rulehj:rules[j]? = some rhrok:RuleOK M rhdf:(!r.dflt || dflt) = truehtl:∀ (tl tr : ListBlank Sym), (dflt = true → tl = default ∧ tr = default) → r.dflt = true → tl = default ∧ tr = defaultc':SCha:applyRule r σ g.cur = some c'hn:∀ g' ∈ [{ cur := c', np := g.np && !r.plus, tgt := g.tgt }], Good M (hubsPS hubs) dflt g'hg':Good M (hubsPS hubs) dflt { cur := c', np := g.np && !r.plus, tgt := g.tgt }⊢ Good M (hubsPS hubs) dflt g cases hp : r.plus with M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalj:ℕσ:List Linr:Rulehj:rules[j]? = some rhrok:RuleOK M rhdf:(!r.dflt || dflt) = truehtl:∀ (tl tr : ListBlank Sym), (dflt = true → tl = default ∧ tr = default) → r.dflt = true → tl = default ∧ tr = defaultc':SCha:applyRule r σ g.cur = some c'hn:∀ g' ∈ [{ cur := c', np := g.np && !r.plus, tgt := g.tgt }], Good M (hubsPS hubs) dflt g'hg':Good M (hubsPS hubs) dflt { cur := c', np := g.np && !r.plus, tgt := g.tgt }hp:r.plus = true⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalj:ℕσ:List Linr:Rulehj:rules[j]? = some rhrok:RuleOK M rhdf:(!r.dflt || dflt) = truehtl:∀ (tl tr : ListBlank Sym), (dflt = true → tl = default ∧ tr = default) → r.dflt = true → tl = default ∧ tr = defaultc':SCha:applyRule r σ g.cur = some c'hn:∀ g' ∈ [{ cur := c', np := g.np && !r.plus, tgt := g.tgt }], Good M (hubsPS hubs) dflt g'hg':Good M (hubsPS hubs) dflt { cur := c', np := g.np && !r.plus, tgt := g.tgt }hp:r.plus = truev:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = default⊢ g.cur.den v tl tr [M]⊢⁺ { cur := c', np := g.np && !r.plus, tgt := g.tgt }.cur.den v tl tr All goals completed! 🐙 M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalj:ℕσ:List Linr:Rulehj:rules[j]? = some rhrok:RuleOK M rhdf:(!r.dflt || dflt) = truehtl:∀ (tl tr : ListBlank Sym), (dflt = true → tl = default ∧ tr = default) → r.dflt = true → tl = default ∧ tr = defaultc':SCha:applyRule r σ g.cur = some c'hn:∀ g' ∈ [{ cur := c', np := g.np && !r.plus, tgt := g.tgt }], Good M (hubsPS hubs) dflt g'hg':Good M (hubsPS hubs) dflt { cur := c', np := g.np && !r.plus, tgt := g.tgt }hp:r.plus = false⊢ Good M (hubsPS hubs) dflt g refine Good_of_star M _ dflt g ⟨c', g.np && !r.plus, g.tgt⟩ rfl (M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalj:ℕσ:List Linr:Rulehj:rules[j]? = some rhrok:RuleOK M rhdf:(!r.dflt || dflt) = truehtl:∀ (tl tr : ListBlank Sym), (dflt = true → tl = default ∧ tr = default) → r.dflt = true → tl = default ∧ tr = defaultc':SCha:applyRule r σ g.cur = some c'hn:∀ g' ∈ [{ cur := c', np := g.np && !r.plus, tgt := g.tgt }], Good M (hubsPS hubs) dflt g'hg':Good M (hubsPS hubs) dflt { cur := c', np := g.np && !r.plus, tgt := g.tgt }hp:r.plus = false⊢ { cur := c', np := g.np && !r.plus, tgt := g.tgt }.np = g.np All goals completed! 🐙) (fun v tl tr ht => ?_) hg' All goals completed! 🐙 M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'i:ℕhe:exec M hubs rules dflt g (Ins.splitZ i) = some new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'i:ℕhe:[Goal.subst i (Lin.const 0) g, Goal.subst i ((Lin.var i).add (Lin.const 1)) g] = new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goali:ℕhn:∀ g' ∈ [Goal.subst i (Lin.const 0) g, Goal.subst i ((Lin.var i).add (Lin.const 1)) g], Good M (hubsPS hubs) dflt g'⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goali:ℕhn:∀ g' ∈ [Goal.subst i (Lin.const 0) g, Goal.subst i ((Lin.var i).add (Lin.const 1)) g], Good M (hubsPS hubs) dflt g'v:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = default⊢ ∃ c', (g.cur.den v tl tr [M]⊢* c') ∧ (g.np = true → g.cur.den v tl tr [M]⊢⁺ c') ∧ Final M (hubsPS hubs) g.tgt v tl tr c' cases hvi : v i with M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goali:ℕhn:∀ g' ∈ [Goal.subst i (Lin.const 0) g, Goal.subst i ((Lin.var i).add (Lin.const 1)) g], Good M (hubsPS hubs) dflt g'v:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaulthvi:v i = 0⊢ ∃ c', (g.cur.den v tl tr [M]⊢* c') ∧ (g.np = true → g.cur.den v tl tr [M]⊢⁺ c') ∧ Final M (hubsPS hubs) g.tgt v tl tr c' refine Good_subst_at M _ dflt g i (Lin.const 0) (hn _ (M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goali:ℕhn:∀ g' ∈ [Goal.subst i (Lin.const 0) g, Goal.subst i ((Lin.var i).add (Lin.const 1)) g], Good M (hubsPS hubs) dflt g'v:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaulthvi:v i = 0⊢ Goal.subst i (Lin.const 0) g ∈ [Goal.subst i (Lin.const 0) g, Goal.subst i ((Lin.var i).add (Lin.const 1)) g] All goals completed! 🐙)) v 0 ?_ tl tr ht All goals completed! 🐙 M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goali:ℕhn:∀ g' ∈ [Goal.subst i (Lin.const 0) g, Goal.subst i ((Lin.var i).add (Lin.const 1)) g], Good M (hubsPS hubs) dflt g'v:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultk:ℕhvi:v i = k + 1⊢ ∃ c', (g.cur.den v tl tr [M]⊢* c') ∧ (g.np = true → g.cur.den v tl tr [M]⊢⁺ c') ∧ Final M (hubsPS hubs) g.tgt v tl tr c' refine Good_subst_at M _ dflt g i ((Lin.var i).add (Lin.const 1)) (hn _ (M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goali:ℕhn:∀ g' ∈ [Goal.subst i (Lin.const 0) g, Goal.subst i ((Lin.var i).add (Lin.const 1)) g], Good M (hubsPS hubs) dflt g'v:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaultk:ℕhvi:v i = k + 1⊢ Goal.subst i ((Lin.var i).add (Lin.const 1)) g ∈ [Goal.subst i (Lin.const 0) g, Goal.subst i ((Lin.var i).add (Lin.const 1)) g] All goals completed! 🐙)) v k ?_ tl tr ht All goals completed! 🐙 M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'i:ℕm:ℕhe:exec M hubs rules dflt g (Ins.splitM i m) = some new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'i:ℕm:ℕhe:(if 1 ≤ m then some (List.map (fun r ↦ Goal.subst i (modBranch i m r) g) (List.range m)) else none) = some new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'i:ℕm:ℕh✝:1 ≤ mhe:some (List.map (fun r ↦ Goal.subst i (modBranch i m r) g) (List.range m)) = some new⊢ Good M (hubsPS hubs) dflt gM:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'i:ℕm:ℕh✝:¬1 ≤ mhe:none = some new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'i:ℕm:ℕh✝:1 ≤ mhe:some (List.map (fun r ↦ Goal.subst i (modBranch i m r) g) (List.range m)) = some new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'i:ℕm:ℕhm:1 ≤ mhe:some (List.map (fun r ↦ Goal.subst i (modBranch i m r) g) (List.range m)) = some new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'i:ℕm:ℕhm:1 ≤ mhe:List.map (fun r ↦ Goal.subst i (modBranch i m r) g) (List.range m) = new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goali:ℕm:ℕhm:1 ≤ mhn:∀ g' ∈ List.map (fun r ↦ Goal.subst i (modBranch i m r) g) (List.range m), Good M (hubsPS hubs) dflt g'⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goali:ℕm:ℕhm:1 ≤ mhn:∀ g' ∈ List.map (fun r ↦ Goal.subst i (modBranch i m r) g) (List.range m), Good M (hubsPS hubs) dflt g'v:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = default⊢ ∃ c', (g.cur.den v tl tr [M]⊢* c') ∧ (g.np = true → g.cur.den v tl tr [M]⊢⁺ c') ∧ Final M (hubsPS hubs) g.tgt v tl tr c' M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goali:ℕm:ℕhm:1 ≤ mhn:∀ g' ∈ List.map (fun r ↦ Goal.subst i (modBranch i m r) g) (List.range m), Good M (hubsPS hubs) dflt g'v:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaulthmem:Goal.subst i (modBranch i m (v i % m)) g ∈ List.map (fun r ↦ Goal.subst i (modBranch i m r) g) (List.range m)⊢ ∃ c', (g.cur.den v tl tr [M]⊢* c') ∧ (g.np = true → g.cur.den v tl tr [M]⊢⁺ c') ∧ Final M (hubsPS hubs) g.tgt v tl tr c' M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goali:ℕm:ℕhm:1 ≤ mhn:∀ g' ∈ List.map (fun r ↦ Goal.subst i (modBranch i m r) g) (List.range m), Good M (hubsPS hubs) dflt g'v:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaulthmem:Goal.subst i (modBranch i m (v i % m)) g ∈ List.map (fun r ↦ Goal.subst i (modBranch i m r) g) (List.range m)⊢ Lin.eval (Function.update v i (v i / m)) (modBranch i m (v i % m)) = v i M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goali:ℕm:ℕhm:1 ≤ mhn:∀ g' ∈ List.map (fun r ↦ Goal.subst i (modBranch i m r) g) (List.range m), Good M (hubsPS hubs) dflt g'v:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaulthmem:Goal.subst i (modBranch i m (v i % m)) g ∈ List.map (fun r ↦ Goal.subst i (modBranch i m r) g) (List.range m)⊢ v i % m + m * (v i / m) = v i All goals completed! 🐙 M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'i:ℕm:ℕh✝:¬1 ≤ mhe:none = some new⊢ Good M (hubsPS hubs) dflt g All goals completed! 🐙 M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linhe:exec M hubs rules dflt g (Ins.hub j σ) = some new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linhe:(match hubs[j]? with | some h => if (dflt && !g.np && g.tgt.isHub && (SC.substAll σ h).beq g.cur) = true then some [] else none | none => none) = some new⊢ Good M (hubsPS hubs) dflt g cases hj : hubs[j]? with M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linhe:(match hubs[j]? with | some h => if (dflt && !g.np && g.tgt.isHub && (SC.substAll σ h).beq g.cur) = true then some [] else none | none => none) = some newhj:hubs[j]? = none⊢ Good M (hubsPS hubs) dflt g All goals completed! 🐙 M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linhe:(match hubs[j]? with | some h => if (dflt && !g.np && g.tgt.isHub && (SC.substAll σ h).beq g.cur) = true then some [] else none | none => none) = some newh:SChj:hubs[j]? = some h⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linh:SChj:hubs[j]? = some hhe:(if (dflt && !g.np && g.tgt.isHub && (SC.substAll σ h).beq g.cur) = true then some [] else none) = some new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linh:SChj:hubs[j]? = some hh✝:(dflt && !g.np && g.tgt.isHub && (SC.substAll σ h).beq g.cur) = truehe:some [] = some new⊢ Good M (hubsPS hubs) dflt gM:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linh:SChj:hubs[j]? = some hh✝:¬(dflt && !g.np && g.tgt.isHub && (SC.substAll σ h).beq g.cur) = truehe:none = some new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linh:SChj:hubs[j]? = some hh✝:(dflt && !g.np && g.tgt.isHub && (SC.substAll σ h).beq g.cur) = truehe:some [] = some new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linh:SChj:hubs[j]? = some hhc:(dflt && !g.np && g.tgt.isHub && (SC.substAll σ h).beq g.cur) = truehe:some [] = some new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linh:SChj:hubs[j]? = some hhe:some [] = some newhc:((dflt = true ∧ g.np = false) ∧ g.tgt.isHub = true) ∧ (SC.substAll σ h).beq g.cur = true⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linh:SChj:hubs[j]? = some hhe:some [] = some newhb:(SC.substAll σ h).beq g.cur = trueht:g.tgt.isHub = truehd:dflt = truehnp:g.np = false⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linh:SChj:hubs[j]? = some hhe:some [] = some newhb:(SC.substAll σ h).beq g.cur = trueht:g.tgt.isHub = truehd:dflt = truehnp:g.np = falsev:ℕ → ℕtl:ListBlank Symtr:ListBlank Symhtl:dflt = true → tl = default ∧ tr = default⊢ ∃ c', (g.cur.den v tl tr [M]⊢* c') ∧ (g.np = true → g.cur.den v tl tr [M]⊢⁺ c') ∧ Final M (hubsPS hubs) g.tgt v tl tr c' M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linh:SChj:hubs[j]? = some hhe:some [] = some newhb:(SC.substAll σ h).beq g.cur = trueht:g.tgt.isHub = truehd:dflt = truehnp:g.np = falsev:ℕ → ℕtl:ListBlank Symtr:ListBlank Symhtl:dflt = true → tl = default ∧ tr = defaulth1:tl = defaulth2:tr = default⊢ ∃ c', (g.cur.den v tl tr [M]⊢* c') ∧ (g.np = true → g.cur.den v tl tr [M]⊢⁺ c') ∧ Final M (hubsPS hubs) g.tgt v tl tr c' M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linh:SChj:hubs[j]? = some hhe:some [] = some newhb:(SC.substAll σ h).beq g.cur = trueht:g.tgt.isHub = truehd:dflt = truehnp:g.np = falsev:ℕ → ℕtr:ListBlank Symh2:tr = defaulthtl:dflt = true → default = default ∧ tr = default⊢ ∃ c', (g.cur.den v default tr [M]⊢* c') ∧ (g.np = true → g.cur.den v default tr [M]⊢⁺ c') ∧ Final M (hubsPS hubs) g.tgt v default tr c'; M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linh:SChj:hubs[j]? = some hhe:some [] = some newhb:(SC.substAll σ h).beq g.cur = trueht:g.tgt.isHub = truehd:dflt = truehnp:g.np = falsev:ℕ → ℕhtl:dflt = true → default = default ∧ default = default⊢ ∃ c', (g.cur.den v default default [M]⊢* c') ∧ (g.np = true → g.cur.den v default default [M]⊢⁺ c') ∧ Final M (hubsPS hubs) g.tgt v default default c' refine ⟨g.cur.den v default default, ReachesStar.refl M _, fun h => M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linh✝:SChj:hubs[j]? = some hhe:some [] = some newhb:(SC.substAll σ h).beq g.cur = trueht:g.tgt.isHub = truehd:dflt = truehnp:g.np = falsev:ℕ → ℕhtl:dflt = true → default = default ∧ default = defaulth:g.np = true⊢ g.cur.den v default default [M]⊢⁺ g.cur.den v default default All goals completed! 🐙, ?_⟩ M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linh:SChj:hubs[j]? = some hhe:some [] = some newhb:(SC.substAll σ h).beq g.cur = trueht:g.tgt.isHub = truehd:dflt = truehnp:g.np = falsev:ℕ → ℕhtl:dflt = true → default = default ∧ default = defaulthin:IsInPatternSet (hubsPS hubs) (h.den (sem σ v) default default)⊢ Final M (hubsPS hubs) g.tgt v default default (g.cur.den v default default) M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linh:SChj:hubs[j]? = some hhe:some [] = some newhb:(SC.substAll σ h).beq g.cur = trueht:g.tgt.isHub = truehd:dflt = truehnp:g.np = falsev:ℕ → ℕhtl:dflt = true → default = default ∧ default = defaulthin:IsInPatternSet (hubsPS hubs) (g.cur.den v default default)⊢ Final M (hubsPS hubs) g.tgt v default default (g.cur.den v default default) cases htg : g.tgt with M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linh:SChj:hubs[j]? = some hhe:some [] = some newhb:(SC.substAll σ h).beq g.cur = trueht:g.tgt.isHub = truehd:dflt = truehnp:g.np = falsev:ℕ → ℕhtl:dflt = true → default = default ∧ default = defaulthin:IsInPatternSet (hubsPS hubs) (g.cur.den v default default)htg:g.tgt = Tgt.hubs⊢ Final M (hubsPS hubs) Tgt.hubs v default default (g.cur.den v default default) All goals completed! 🐙 M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linh:SChj:hubs[j]? = some hhe:some [] = some newhb:(SC.substAll σ h).beq g.cur = trueht:g.tgt.isHub = truehd:dflt = truehnp:g.np = falsev:ℕ → ℕhtl:dflt = true → default = default ∧ default = defaulthin:IsInPatternSet (hubsPS hubs) (g.cur.den v default default)htg:g.tgt = Tgt.ps⊢ Final M (hubsPS hubs) Tgt.ps v default default (g.cur.den v default default) All goals completed! 🐙 M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linh:SChj:hubs[j]? = some hhe:some [] = some newhb:(SC.substAll σ h).beq g.cur = trueht:g.tgt.isHub = truehd:dflt = truehnp:g.np = falsev:ℕ → ℕhtl:dflt = true → default = default ∧ default = defaulthin:IsInPatternSet (hubsPS hubs) (g.cur.den v default default)d:SChtg:g.tgt = Tgt.cfg d⊢ Final M (hubsPS hubs) (Tgt.cfg d) v default default (g.cur.den v default default) All goals completed! 🐙 M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'j:ℕσ:List Linh:SChj:hubs[j]? = some hh✝:¬(dflt && !g.np && g.tgt.isHub && (SC.substAll σ h).beq g.cur) = truehe:none = some new⊢ Good M (hubsPS hubs) dflt g All goals completed! 🐙 M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'he:exec M hubs rules dflt g Ins.halt = some new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'he:(match g.tgt with | Tgt.hubs => if (!g.np && isHalt M dflt g.cur) = true then some [] else none | x => none) = some new⊢ Good M (hubsPS hubs) dflt g cases htg : g.tgt with M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'he:(match g.tgt with | Tgt.hubs => if (!g.np && isHalt M dflt g.cur) = true then some [] else none | x => none) = some newhtg:g.tgt = Tgt.hubs⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'htg:g.tgt = Tgt.hubshe:(if (!g.np && isHalt M dflt g.cur) = true then some [] else none) = some new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'htg:g.tgt = Tgt.hubsh✝:(!g.np && isHalt M dflt g.cur) = truehe:some [] = some new⊢ Good M (hubsPS hubs) dflt gM:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'htg:g.tgt = Tgt.hubsh✝:¬(!g.np && isHalt M dflt g.cur) = truehe:none = some new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'htg:g.tgt = Tgt.hubsh✝:(!g.np && isHalt M dflt g.cur) = truehe:some [] = some new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'htg:g.tgt = Tgt.hubshc:(!g.np && isHalt M dflt g.cur) = truehe:some [] = some new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'htg:g.tgt = Tgt.hubshe:some [] = some newhc:g.np = false ∧ isHalt M dflt g.cur = true⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'htg:g.tgt = Tgt.hubshe:some [] = some newhc:g.np = false ∧ isHalt M dflt g.cur = truev:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = default⊢ ∃ c', (g.cur.den v tl tr [M]⊢* c') ∧ (g.np = true → g.cur.den v tl tr [M]⊢⁺ c') ∧ Final M (hubsPS hubs) g.tgt v tl tr c' refine ⟨g.cur.den v tl tr, ReachesStar.refl M _, fun h => M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'htg:g.tgt = Tgt.hubshe:some [] = some newhc:g.np = false ∧ isHalt M dflt g.cur = truev:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaulth:g.np = true⊢ g.cur.den v tl tr [M]⊢⁺ g.cur.den v tl tr All goals completed! 🐙, ?_⟩ M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'htg:g.tgt = Tgt.hubshe:some [] = some newhc:g.np = false ∧ isHalt M dflt g.cur = truev:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = default⊢ Final M (hubsPS hubs) Tgt.hubs v tl tr (g.cur.den v tl tr) All goals completed! 🐙 M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'htg:g.tgt = Tgt.hubsh✝:¬(!g.np && isHalt M dflt g.cur) = truehe:none = some new⊢ Good M (hubsPS hubs) dflt g All goals completed! 🐙 M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'he:(match g.tgt with | Tgt.hubs => if (!g.np && isHalt M dflt g.cur) = true then some [] else none | x => none) = some newhtg:g.tgt = Tgt.ps⊢ Good M (hubsPS hubs) dflt g All goals completed! 🐙 M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'he:(match g.tgt with | Tgt.hubs => if (!g.np && isHalt M dflt g.cur) = true then some [] else none | x => none) = some newd:SChtg:g.tgt = Tgt.cfg d⊢ Good M (hubsPS hubs) dflt g All goals completed! 🐙 M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'he:exec M hubs rules dflt g Ins.done = some new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'he:(match g.tgt with | Tgt.cfg d => if (!g.np && g.cur.beq d) = true then some [] else none | x => none) = some new⊢ Good M (hubsPS hubs) dflt g cases htg : g.tgt with M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'he:(match g.tgt with | Tgt.cfg d => if (!g.np && g.cur.beq d) = true then some [] else none | x => none) = some newd:SChtg:g.tgt = Tgt.cfg d⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'd:SChtg:g.tgt = Tgt.cfg dhe:(if (!g.np && g.cur.beq d) = true then some [] else none) = some new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'd:SChtg:g.tgt = Tgt.cfg dh✝:(!g.np && g.cur.beq d) = truehe:some [] = some new⊢ Good M (hubsPS hubs) dflt gM:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'd:SChtg:g.tgt = Tgt.cfg dh✝:¬(!g.np && g.cur.beq d) = truehe:none = some new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'd:SChtg:g.tgt = Tgt.cfg dh✝:(!g.np && g.cur.beq d) = truehe:some [] = some new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'd:SChtg:g.tgt = Tgt.cfg dhc:(!g.np && g.cur.beq d) = truehe:some [] = some new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'd:SChtg:g.tgt = Tgt.cfg dhe:some [] = some newhc:g.np = false ∧ g.cur.beq d = true⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'd:SChtg:g.tgt = Tgt.cfg dhe:some [] = some newhc:g.np = false ∧ g.cur.beq d = truev:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = default⊢ ∃ c', (g.cur.den v tl tr [M]⊢* c') ∧ (g.np = true → g.cur.den v tl tr [M]⊢⁺ c') ∧ Final M (hubsPS hubs) g.tgt v tl tr c' refine ⟨g.cur.den v tl tr, ReachesStar.refl M _, fun h => M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'd:SChtg:g.tgt = Tgt.cfg dhe:some [] = some newhc:g.np = false ∧ g.cur.beq d = truev:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = defaulth:g.np = true⊢ g.cur.den v tl tr [M]⊢⁺ g.cur.den v tl tr All goals completed! 🐙, ?_⟩ M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'd:SChtg:g.tgt = Tgt.cfg dhe:some [] = some newhc:g.np = false ∧ g.cur.beq d = truev:ℕ → ℕtl:ListBlank Symtr:ListBlank Symht:dflt = true → tl = default ∧ tr = default⊢ Final M (hubsPS hubs) (Tgt.cfg d) v tl tr (g.cur.den v tl tr) All goals completed! 🐙 M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'd:SChtg:g.tgt = Tgt.cfg dh✝:¬(!g.np && g.cur.beq d) = truehe:none = some new⊢ Good M (hubsPS hubs) dflt g All goals completed! 🐙 M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'he:(match g.tgt with | Tgt.cfg d => if (!g.np && g.cur.beq d) = true then some [] else none | x => none) = some newhtg:g.tgt = Tgt.hubs⊢ Good M (hubsPS hubs) dflt g All goals completed! 🐙 M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalnew:List Goalhn:∀ g' ∈ new, Good M (hubsPS hubs) dflt g'he:(match g.tgt with | Tgt.cfg d => if (!g.np && g.cur.beq d) = true then some [] else none | x => none) = some newhtg:g.tgt = Tgt.ps⊢ Good M (hubsPS hubs) dflt g All goals completed! 🐙theorem run_sound (M : TM) (hubs : List SC) (hh : ∀ h ∈ hubs, hubOK h = true) (rules : List Rule) (hr : ∀ r ∈ rules, RuleOK M r) (dflt : Bool) : ∀ (is : List Ins) (gs : List Goal), run M hubs rules dflt is gs = true → ∀ g ∈ gs, Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolgs:List Goalh:run M hubs rules dflt [] gs = trueg:Goalhg:g ∈ gs⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolgs:List Goalh:run M hubs rules dflt [] gs = trueg:Goalhg:g ∈ gs⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolgs:List Goalg:Goalhg:g ∈ gsh:gs = []⊢ Good M (hubsPS hubs) dflt g; M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Boolg:Goalhg:g ∈ []⊢ Good M (hubsPS hubs) dflt g; All goals completed! 🐙 M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Booli:Insis:List Insh:run M hubs rules dflt (i :: is) [] = trueg:Goalhg:g ∈ []⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Booli:Insis:List Insh:run M hubs rules dflt (i :: is) [] = trueg:Goalhg:g ∈ []⊢ Good M (hubsPS hubs) dflt g All goals completed! 🐙 M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Booli:Insis:List Insg0:Goalgs:List Goalh:run M hubs rules dflt (i :: is) (g0 :: gs) = trueg:Goalhg:g ∈ g0 :: gs⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Booli:Insis:List Insg0:Goalgs:List Goalh:run M hubs rules dflt (i :: is) (g0 :: gs) = trueg:Goalhg:g ∈ g0 :: gs⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Booli:Insis:List Insg0:Goalgs:List Goalh:(match exec M hubs rules dflt g0 i with | some new => run M hubs rules dflt is (new ++ gs) | none => false) = trueg:Goalhg:g ∈ g0 :: gs⊢ Good M (hubsPS hubs) dflt g cases he : exec M hubs rules dflt g0 i with M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Booli:Insis:List Insg0:Goalgs:List Goalh:(match exec M hubs rules dflt g0 i with | some new => run M hubs rules dflt is (new ++ gs) | none => false) = trueg:Goalhg:g ∈ g0 :: gshe:exec M hubs rules dflt g0 i = none⊢ Good M (hubsPS hubs) dflt g All goals completed! 🐙 M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Booli:Insis:List Insg0:Goalgs:List Goalh:(match exec M hubs rules dflt g0 i with | some new => run M hubs rules dflt is (new ++ gs) | none => false) = trueg:Goalhg:g ∈ g0 :: gsnew:List Goalhe:exec M hubs rules dflt g0 i = some new⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Booli:Insis:List Insg0:Goalgs:List Goalg:Goalhg:g ∈ g0 :: gsnew:List Goalhe:exec M hubs rules dflt g0 i = some newh:run M hubs rules dflt is (new ++ gs) = true⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Booli:Insis:List Insg0:Goalgs:List Goalg:Goalhg:g ∈ g0 :: gsnew:List Goalhe:exec M hubs rules dflt g0 i = some newh:run M hubs rules dflt is (new ++ gs) = trueih:∀ g ∈ new ++ gs, Good M (hubsPS hubs) dflt g⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Booli:Insis:List Insgs:List Goalg:Goalnew:List Goalh:run M hubs rules dflt is (new ++ gs) = trueih:∀ g ∈ new ++ gs, Good M (hubsPS hubs) dflt ghg:g ∈ g :: gshe:exec M hubs rules dflt g i = some new⊢ Good M (hubsPS hubs) dflt gM:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Booli:Insis:List Insg0:Goalgs:List Goalg:Goalhg:g ∈ g0 :: gsnew:List Goalhe:exec M hubs rules dflt g0 i = some newh:run M hubs rules dflt is (new ++ gs) = trueih:∀ g ∈ new ++ gs, Good M (hubsPS hubs) dflt ghg':g ∈ gs⊢ Good M (hubsPS hubs) dflt g M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Booli:Insis:List Insgs:List Goalg:Goalnew:List Goalh:run M hubs rules dflt is (new ++ gs) = trueih:∀ g ∈ new ++ gs, Good M (hubsPS hubs) dflt ghg:g ∈ g :: gshe:exec M hubs rules dflt g i = some new⊢ Good M (hubsPS hubs) dflt g exact exec_sound M hubs hh rules hr dflt g i new he (fun g' hg' => ih g' (M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Booli:Insis:List Insgs:List Goalg:Goalnew:List Goalh:run M hubs rules dflt is (new ++ gs) = trueih:∀ g ∈ new ++ gs, Good M (hubsPS hubs) dflt ghg:g ∈ g :: gshe:exec M hubs rules dflt g i = some newg':Goalhg':g' ∈ new⊢ g' ∈ new ++ gs All goals completed! 🐙)) M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Booli:Insis:List Insg0:Goalgs:List Goalg:Goalhg:g ∈ g0 :: gsnew:List Goalhe:exec M hubs rules dflt g0 i = some newh:run M hubs rules dflt is (new ++ gs) = trueih:∀ g ∈ new ++ gs, Good M (hubsPS hubs) dflt ghg':g ∈ gs⊢ Good M (hubsPS hubs) dflt g exact ih g (M:TMhubs:List SChh:∀ h ∈ hubs, hubOK h = truerules:List Rulehr:∀ r ∈ rules, RuleOK M rdflt:Booli:Insis:List Insg0:Goalgs:List Goalg:Goalhg:g ∈ g0 :: gsnew:List Goalhe:exec M hubs rules dflt g0 i = some newh:run M hubs rules dflt is (new ++ gs) = trueih:∀ g ∈ new ++ gs, Good M (hubsPS hubs) dflt ghg':g ∈ gs⊢ g ∈ new ++ gs All goals completed! 🐙)

Rule Definitions: Proved Rules and Iterated (Inductive) Rules

inductive RDef | prove (r : Rule) (pf : List Ins) | iter (j : ℕ) (S : SC) (k : ℕ) (ds : List ℕ)

x_i ↦ x_i + d_i for i ≠ k, x_k ↦ x_k.

def iterL (k : ℕ) (ds : List ℕ) : List Lin := (List.range ds.length).map (fun i => if i == k then Lin.var i else (Lin.var i).add (Lin.const (ds.getD i 0)))

x_i ↦ x_i + d_i * x_k for i ≠ k, x_k ↦ 0.

def iterR (k : ℕ) (ds : List ℕ) : List Lin := (List.range ds.length).map (fun i => if i == k then Lin.const 0 else (Lin.var i).add ((Lin.var k).scale (ds.getD i 0)))theorem getD_map_range (n : ℕ) (f : ℕ → Lin) (i : ℕ) (d : Lin) : ((List.range n).map f).getD i d = if i < n then f i else d := n:ℕf:ℕ → Lini:ℕd:Lin⊢ (List.map f (List.range n)).getD i d = if i < n then f i else d n:ℕf:ℕ → Lini:ℕd:Linh:i < n⊢ (List.map f (List.range n)).getD i d = if i < n then f i else dn:ℕf:ℕ → Lini:ℕd:Linh:¬i < n⊢ (List.map f (List.range n)).getD i d = if i < n then f i else d n:ℕf:ℕ → Lini:ℕd:Linh:i < n⊢ (List.map f (List.range n)).getD i d = if i < n then f i else d All goals completed! 🐙 n:ℕf:ℕ → Lini:ℕd:Linh:¬i < n⊢ (List.map f (List.range n)).getD i d = if i < n then f i else d All goals completed! 🐙theorem sem_iterL (k : ℕ) (ds : List ℕ) (v : ℕ → ℕ) (i : ℕ) : sem (iterL k ds) v i = if i < ds.length ∧ i ≠ k then v i + ds.getD i 0 else v i := k:ℕds:List ℕv:ℕ → ℕi:ℕ⊢ sem (iterL k ds) v i = if i < ds.length ∧ i ≠ k then v i + ds.getD i 0 else v i k:ℕds:List ℕv:ℕ → ℕi:ℕ⊢ Lin.eval v (if i < ds.length then if (i == k) = true then Lin.var i else (Lin.var i).add (Lin.const (ds.getD i 0)) else Lin.var i) = if i < ds.length ∧ i ≠ k then v i + ds.getD i 0 else v i k:ℕds:List ℕv:ℕ → ℕi:ℕh1:i < ds.length⊢ Lin.eval v (if i < ds.length then if (i == k) = true then Lin.var i else (Lin.var i).add (Lin.const (ds.getD i 0)) else Lin.var i) = if i < ds.length ∧ i ≠ k then v i + ds.getD i 0 else v ik:ℕds:List ℕv:ℕ → ℕi:ℕh1:¬i < ds.length⊢ Lin.eval v (if i < ds.length then if (i == k) = true then Lin.var i else (Lin.var i).add (Lin.const (ds.getD i 0)) else Lin.var i) = if i < ds.length ∧ i ≠ k then v i + ds.getD i 0 else v i k:ℕds:List ℕv:ℕ → ℕi:ℕh1:i < ds.length⊢ Lin.eval v (if i < ds.length then if (i == k) = true then Lin.var i else (Lin.var i).add (Lin.const (ds.getD i 0)) else Lin.var i) = if i < ds.length ∧ i ≠ k then v i + ds.getD i 0 else v i k:ℕds:List ℕv:ℕ → ℕi:ℕh1:i < ds.lengthh2:i = k⊢ Lin.eval v (if i < ds.length then if (i == k) = true then Lin.var i else (Lin.var i).add (Lin.const (ds.getD i 0)) else Lin.var i) = if i < ds.length ∧ i ≠ k then v i + ds.getD i 0 else v ik:ℕds:List ℕv:ℕ → ℕi:ℕh1:i < ds.lengthh2:¬i = k⊢ Lin.eval v (if i < ds.length then if (i == k) = true then Lin.var i else (Lin.var i).add (Lin.const (ds.getD i 0)) else Lin.var i) = if i < ds.length ∧ i ≠ k then v i + ds.getD i 0 else v i k:ℕds:List ℕv:ℕ → ℕi:ℕh1:i < ds.lengthh2:i = k⊢ Lin.eval v (if i < ds.length then if (i == k) = true then Lin.var i else (Lin.var i).add (Lin.const (ds.getD i 0)) else Lin.var i) = if i < ds.length ∧ i ≠ k then v i + ds.getD i 0 else v i ds:List ℕv:ℕ → ℕi:ℕh1:i < ds.length⊢ Lin.eval v (if i < ds.length then if (i == i) = true then Lin.var i else (Lin.var i).add (Lin.const (ds.getD i 0)) else Lin.var i) = if i < ds.length ∧ i ≠ i then v i + ds.getD i 0 else v i; All goals completed! 🐙 k:ℕds:List ℕv:ℕ → ℕi:ℕh1:i < ds.lengthh2:¬i = k⊢ Lin.eval v (if i < ds.length then if (i == k) = true then Lin.var i else (Lin.var i).add (Lin.const (ds.getD i 0)) else Lin.var i) = if i < ds.length ∧ i ≠ k then v i + ds.getD i 0 else v i All goals completed! 🐙 k:ℕds:List ℕv:ℕ → ℕi:ℕh1:¬i < ds.length⊢ Lin.eval v (if i < ds.length then if (i == k) = true then Lin.var i else (Lin.var i).add (Lin.const (ds.getD i 0)) else Lin.var i) = if i < ds.length ∧ i ≠ k then v i + ds.getD i 0 else v i All goals completed! 🐙theorem sem_iterR (k : ℕ) (ds : List ℕ) (v : ℕ → ℕ) (i : ℕ) : sem (iterR k ds) v i = if i < ds.length then (if i = k then 0 else v i + v k * ds.getD i 0) else v i := k:ℕds:List ℕv:ℕ → ℕi:ℕ⊢ sem (iterR k ds) v i = if i < ds.length then if i = k then 0 else v i + v k * ds.getD i 0 else v i k:ℕds:List ℕv:ℕ → ℕi:ℕ⊢ Lin.eval v (if i < ds.length then if (i == k) = true then Lin.const 0 else (Lin.var i).add (Lin.scale (ds.getD i 0) (Lin.var k)) else Lin.var i) = if i < ds.length then if i = k then 0 else v i + v k * ds.getD i 0 else v i k:ℕds:List ℕv:ℕ → ℕi:ℕh1:i < ds.length⊢ Lin.eval v (if i < ds.length then if (i == k) = true then Lin.const 0 else (Lin.var i).add (Lin.scale (ds.getD i 0) (Lin.var k)) else Lin.var i) = if i < ds.length then if i = k then 0 else v i + v k * ds.getD i 0 else v ik:ℕds:List ℕv:ℕ → ℕi:ℕh1:¬i < ds.length⊢ Lin.eval v (if i < ds.length then if (i == k) = true then Lin.const 0 else (Lin.var i).add (Lin.scale (ds.getD i 0) (Lin.var k)) else Lin.var i) = if i < ds.length then if i = k then 0 else v i + v k * ds.getD i 0 else v i k:ℕds:List ℕv:ℕ → ℕi:ℕh1:i < ds.length⊢ Lin.eval v (if i < ds.length then if (i == k) = true then Lin.const 0 else (Lin.var i).add (Lin.scale (ds.getD i 0) (Lin.var k)) else Lin.var i) = if i < ds.length then if i = k then 0 else v i + v k * ds.getD i 0 else v i k:ℕds:List ℕv:ℕ → ℕi:ℕh1:i < ds.lengthh2:i = k⊢ Lin.eval v (if i < ds.length then if (i == k) = true then Lin.const 0 else (Lin.var i).add (Lin.scale (ds.getD i 0) (Lin.var k)) else Lin.var i) = if i < ds.length then if i = k then 0 else v i + v k * ds.getD i 0 else v ik:ℕds:List ℕv:ℕ → ℕi:ℕh1:i < ds.lengthh2:¬i = k⊢ Lin.eval v (if i < ds.length then if (i == k) = true then Lin.const 0 else (Lin.var i).add (Lin.scale (ds.getD i 0) (Lin.var k)) else Lin.var i) = if i < ds.length then if i = k then 0 else v i + v k * ds.getD i 0 else v i k:ℕds:List ℕv:ℕ → ℕi:ℕh1:i < ds.lengthh2:i = k⊢ Lin.eval v (if i < ds.length then if (i == k) = true then Lin.const 0 else (Lin.var i).add (Lin.scale (ds.getD i 0) (Lin.var k)) else Lin.var i) = if i < ds.length then if i = k then 0 else v i + v k * ds.getD i 0 else v i ds:List ℕv:ℕ → ℕi:ℕh1:i < ds.length⊢ Lin.eval v (if i < ds.length then if (i == i) = true then Lin.const 0 else (Lin.var i).add (Lin.scale (ds.getD i 0) (Lin.var i)) else Lin.var i) = if i < ds.length then if i = i then 0 else v i + v i * ds.getD i 0 else v i; All goals completed! 🐙 k:ℕds:List ℕv:ℕ → ℕi:ℕh1:i < ds.lengthh2:¬i = k⊢ Lin.eval v (if i < ds.length then if (i == k) = true then Lin.const 0 else (Lin.var i).add (Lin.scale (ds.getD i 0) (Lin.var k)) else Lin.var i) = if i < ds.length then if i = k then 0 else v i + v k * ds.getD i 0 else v i All goals completed! 🐙 k:ℕds:List ℕv:ℕ → ℕi:ℕh1:¬i < ds.length⊢ Lin.eval v (if i < ds.length then if (i == k) = true then Lin.const 0 else (Lin.var i).add (Lin.scale (ds.getD i 0) (Lin.var k)) else Lin.var i) = if i < ds.length then if i = k then 0 else v i + v k * ds.getD i 0 else v i All goals completed! 🐙theorem iter_sound (M : TM) (S : SC) (k : ℕ) (ds : List ℕ) (hk : k < ds.length) (r : Rule) (hr : RuleOK M r) (hl : r.lhs.beq (S.subst k ((Lin.var k).add (Lin.const 1))) = true) (hrr : r.rhs.beq (S.substAll (iterL k ds)) = true) : RuleOK M ⟨S, S.substAll (iterR k ds), false, r.dflt⟩ := M:TMS:SCk:ℕds:List ℕhk:k < ds.lengthr:Rulehr:RuleOK M rhl:r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) = truehrr:r.rhs.beq (SC.substAll (iterL k ds) S) = true⊢ RuleOK M { lhs := S, rhs := SC.substAll (iterR k ds) S, plus := false, dflt := r.dflt } M:TMS:SCk:ℕds:List ℕhk:k < ds.lengthr:Rulehr:RuleOK M rhl:r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) = truehrr:r.rhs.beq (SC.substAll (iterL k ds) S) = truev:ℕ → ℕtl:ListBlank Symtr:ListBlank Symhtd:{ lhs := S, rhs := SC.substAll (iterR k ds) S, plus := false, dflt := r.dflt }.dflt = true → tl = default ∧ tr = default⊢ ({ lhs := S, rhs := SC.substAll (iterR k ds) S, plus := false, dflt := r.dflt }.lhs.den v tl tr [M]⊢* { lhs := S, rhs := SC.substAll (iterR k ds) S, plus := false, dflt := r.dflt }.rhs.den v tl tr) ∧ ({ lhs := S, rhs := SC.substAll (iterR k ds) S, plus := false, dflt := r.dflt }.plus = true → { lhs := S, rhs := SC.substAll (iterR k ds) S, plus := false, dflt := r.dflt }.lhs.den v tl tr [M]⊢⁺ { lhs := S, rhs := SC.substAll (iterR k ds) S, plus := false, dflt := r.dflt }.rhs.den v tl tr) refine ⟨?_, fun h => M:TMS:SCk:ℕds:List ℕhk:k < ds.lengthr:Rulehr:RuleOK M rhl:r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) = truehrr:r.rhs.beq (SC.substAll (iterL k ds) S) = truev:ℕ → ℕtl:ListBlank Symtr:ListBlank Symhtd:{ lhs := S, rhs := SC.substAll (iterR k ds) S, plus := false, dflt := r.dflt }.dflt = true → tl = default ∧ tr = defaulth:{ lhs := S, rhs := SC.substAll (iterR k ds) S, plus := false, dflt := r.dflt }.plus = true⊢ { lhs := S, rhs := SC.substAll (iterR k ds) S, plus := false, dflt := r.dflt }.lhs.den v tl tr [M]⊢⁺ { lhs := S, rhs := SC.substAll (iterR k ds) S, plus := false, dflt := r.dflt }.rhs.den v tl tr All goals completed! 🐙⟩ M:TMS:SCk:ℕds:List ℕhk:k < ds.lengthr:Rulehr:RuleOK M rhl:r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) = truehrr:r.rhs.beq (SC.substAll (iterL k ds) S) = truev:ℕ → ℕtl:ListBlank Symtr:ListBlank Symhtd:{ lhs := S, rhs := SC.substAll (iterR k ds) S, plus := false, dflt := r.dflt }.dflt = true → tl = default ∧ tr = default⊢ S.den v tl tr [M]⊢* S.den (sem (iterR k ds) v) tl tr -- induction on the counter value M:TMS:SCk:ℕds:List ℕhk:k < ds.lengthr:Rulehr:RuleOK M rhl:r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) = truehrr:r.rhs.beq (SC.substAll (iterL k ds) S) = truev:ℕ → ℕtl:ListBlank Symtr:ListBlank Symhtd:{ lhs := S, rhs := SC.substAll (iterR k ds) S, plus := false, dflt := r.dflt }.dflt = true → tl = default ∧ tr = default⊢ ∀ (n : ℕ) (v : ℕ → ℕ), v k = n → S.den v tl tr [M]⊢* S.den (sem (iterR k ds) v) tl tr M:TMS:SCk:ℕds:List ℕhk:k < ds.lengthr:Rulehr:RuleOK M rhl:r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) = truehrr:r.rhs.beq (SC.substAll (iterL k ds) S) = truev:ℕ → ℕtl:ListBlank Symtr:ListBlank Symhtd:{ lhs := S, rhs := SC.substAll (iterR k ds) S, plus := false, dflt := r.dflt }.dflt = true → tl = default ∧ tr = defaultn:ℕ⊢ ∀ (v : ℕ → ℕ), v k = n → S.den v tl tr [M]⊢* S.den (sem (iterR k ds) v) tl tr induction n with M:TMS:SCk:ℕds:List ℕhk:k < ds.lengthr:Rulehr:RuleOK M rhl:r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) = truehrr:r.rhs.beq (SC.substAll (iterL k ds) S) = truev:ℕ → ℕtl:ListBlank Symtr:ListBlank Symhtd:{ lhs := S, rhs := SC.substAll (iterR k ds) S, plus := false, dflt := r.dflt }.dflt = true → tl = default ∧ tr = default⊢ ∀ (v : ℕ → ℕ), v k = 0 → S.den v tl tr [M]⊢* S.den (sem (iterR k ds) v) tl tr M:TMS:SCk:ℕds:List ℕhk:k < ds.lengthr:Rulehr:RuleOK M rhl:r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) = truehrr:r.rhs.beq (SC.substAll (iterL k ds) S) = truev✝:ℕ → ℕtl:ListBlank Symtr:ListBlank Symhtd:{ lhs := S, rhs := SC.substAll (iterR k ds) S, plus := false, dflt := r.dflt }.dflt = true → tl = default ∧ tr = defaultv:ℕ → ℕhv:v k = 0⊢ S.den v tl tr [M]⊢* S.den (sem (iterR k ds) v) tl tr M:TMS:SCk:ℕds:List ℕhk:k < ds.lengthr:Rulehr:RuleOK M rhl:r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) = truehrr:r.rhs.beq (SC.substAll (iterL k ds) S) = truev✝:ℕ → ℕtl:ListBlank Symtr:ListBlank Symhtd:{ lhs := S, rhs := SC.substAll (iterR k ds) S, plus := false, dflt := r.dflt }.dflt = true → tl = default ∧ tr = defaultv:ℕ → ℕhv:v k = 0this:sem (iterR k ds) v = v⊢ S.den v tl tr [M]⊢* S.den (sem (iterR k ds) v) tl tr All goals completed! 🐙 M:TMS:SCk:ℕds:List ℕhk:k < ds.lengthr:Rulehr:RuleOK M rhl:r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) = truehrr:r.rhs.beq (SC.substAll (iterL k ds) S) = truev:ℕ → ℕtl:ListBlank Symtr:ListBlank Symhtd:{ lhs := S, rhs := SC.substAll (iterR k ds) S, plus := false, dflt := r.dflt }.dflt = true → tl = default ∧ tr = defaultn:ℕih:∀ (v : ℕ → ℕ), v k = n → S.den v tl tr [M]⊢* S.den (sem (iterR k ds) v) tl tr⊢ ∀ (v : ℕ → ℕ), v k = n + 1 → S.den v tl tr [M]⊢* S.den (sem (iterR k ds) v) tl tr M:TMS:SCk:ℕds:List ℕhk:k < ds.lengthr:Rulehr:RuleOK M rhl:r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) = truehrr:r.rhs.beq (SC.substAll (iterL k ds) S) = truev✝:ℕ → ℕtl:ListBlank Symtr:ListBlank Symhtd:{ lhs := S, rhs := SC.substAll (iterR k ds) S, plus := false, dflt := r.dflt }.dflt = true → tl = default ∧ tr = defaultn:ℕih:∀ (v : ℕ → ℕ), v k = n → S.den v tl tr [M]⊢* S.den (sem (iterR k ds) v) tl trv:ℕ → ℕhv:v k = n + 1⊢ S.den v tl tr [M]⊢* S.den (sem (iterR k ds) v) tl tr M:TMS:SCk:ℕds:List ℕhk:k < ds.lengthr:Rulehr:RuleOK M rhl:r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) = truehrr:r.rhs.beq (SC.substAll (iterL k ds) S) = truev✝:ℕ → ℕtl:ListBlank Symtr:ListBlank Symhtd:{ lhs := S, rhs := SC.substAll (iterR k ds) S, plus := false, dflt := r.dflt }.dflt = true → tl = default ∧ tr = defaultn:ℕih:∀ (v : ℕ → ℕ), v k = n → S.den v tl tr [M]⊢* S.den (sem (iterR k ds) v) tl trv:ℕ → ℕhv:v k = n + 1u:ℕ → ℕ := Function.update v k n⊢ S.den v tl tr [M]⊢* S.den (sem (iterR k ds) v) tl tr M:TMS:SCk:ℕds:List ℕhk:k < ds.lengthr:Rulehr:RuleOK M rhl:r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) = truehrr:r.rhs.beq (SC.substAll (iterL k ds) S) = truev✝:ℕ → ℕtl:ListBlank Symtr:ListBlank Symhtd:{ lhs := S, rhs := SC.substAll (iterR k ds) S, plus := false, dflt := r.dflt }.dflt = true → tl = default ∧ tr = defaultn:ℕih:∀ (v : ℕ → ℕ), v k = n → S.den v tl tr [M]⊢* S.den (sem (iterR k ds) v) tl trv:ℕ → ℕhv:v k = n + 1u:ℕ → ℕ := Function.update v k ne1:S.den v tl tr = r.lhs.den u tl tr⊢ S.den v tl tr [M]⊢* S.den (sem (iterR k ds) v) tl tr M:TMS:SCk:ℕds:List ℕhk:k < ds.lengthr:Rulehr:RuleOK M rhl:r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) = truehrr:r.rhs.beq (SC.substAll (iterL k ds) S) = truev✝:ℕ → ℕtl:ListBlank Symtr:ListBlank Symhtd:{ lhs := S, rhs := SC.substAll (iterR k ds) S, plus := false, dflt := r.dflt }.dflt = true → tl = default ∧ tr = defaultn:ℕih:∀ (v : ℕ → ℕ), v k = n → S.den v tl tr [M]⊢* S.den (sem (iterR k ds) v) tl trv:ℕ → ℕhv:v k = n + 1u:ℕ → ℕ := Function.update v k ne1:S.den v tl tr = r.lhs.den u tl tre2:r.rhs.den u tl tr = S.den (sem (iterL k ds) u) tl tr⊢ S.den v tl tr [M]⊢* S.den (sem (iterR k ds) v) tl tr M:TMS:SCk:ℕds:List ℕhk:k < ds.lengthr:Rulehr:RuleOK M rhl:r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) = truehrr:r.rhs.beq (SC.substAll (iterL k ds) S) = truev✝:ℕ → ℕtl:ListBlank Symtr:ListBlank Symhtd:{ lhs := S, rhs := SC.substAll (iterR k ds) S, plus := false, dflt := r.dflt }.dflt = true → tl = default ∧ tr = defaultn:ℕih:∀ (v : ℕ → ℕ), v k = n → S.den v tl tr [M]⊢* S.den (sem (iterR k ds) v) tl trv:ℕ → ℕhv:v k = n + 1u:ℕ → ℕ := Function.update v k ne1:S.den v tl tr = r.lhs.den u tl tre2:r.rhs.den u tl tr = S.den (sem (iterL k ds) u) tl trw:ℕ → ℕ := sem (iterL k ds) u⊢ S.den v tl tr [M]⊢* S.den (sem (iterR k ds) v) tl tr M:TMS:SCk:ℕds:List ℕhk:k < ds.lengthr:Rulehr:RuleOK M rhl:r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) = truehrr:r.rhs.beq (SC.substAll (iterL k ds) S) = truev✝:ℕ → ℕtl:ListBlank Symtr:ListBlank Symhtd:{ lhs := S, rhs := SC.substAll (iterR k ds) S, plus := false, dflt := r.dflt }.dflt = true → tl = default ∧ tr = defaultn:ℕih:∀ (v : ℕ → ℕ), v k = n → S.den v tl tr [M]⊢* S.den (sem (iterR k ds) v) tl trv:ℕ → ℕhv:v k = n + 1u:ℕ → ℕ := Function.update v k ne1:S.den v tl tr = r.lhs.den u tl tre2:r.rhs.den u tl tr = S.den (sem (iterL k ds) u) tl trw:ℕ → ℕ := sem (iterL k ds) uhw:w k = n⊢ S.den v tl tr [M]⊢* S.den (sem (iterR k ds) v) tl tr M:TMS:SCk:ℕds:List ℕhk:k < ds.lengthr:Rulehr:RuleOK M rhl:r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) = truehrr:r.rhs.beq (SC.substAll (iterL k ds) S) = truev✝:ℕ → ℕtl:ListBlank Symtr:ListBlank Symhtd:{ lhs := S, rhs := SC.substAll (iterR k ds) S, plus := false, dflt := r.dflt }.dflt = true → tl = default ∧ tr = defaultn:ℕih:∀ (v : ℕ → ℕ), v k = n → S.den v tl tr [M]⊢* S.den (sem (iterR k ds) v) tl trv:ℕ → ℕhv:v k = n + 1u:ℕ → ℕ := Function.update v k ne1:S.den v tl tr = r.lhs.den u tl tre2:r.rhs.den u tl tr = S.den (sem (iterL k ds) u) tl trw:ℕ → ℕ := sem (iterL k ds) uhw:w k = ne3:sem (iterR k ds) w = sem (iterR k ds) v⊢ S.den v tl tr [M]⊢* S.den (sem (iterR k ds) v) tl tr M:TMS:SCk:ℕds:List ℕhk:k < ds.lengthr:Rulehr:RuleOK M rhl:r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) = truehrr:r.rhs.beq (SC.substAll (iterL k ds) S) = truev✝:ℕ → ℕtl:ListBlank Symtr:ListBlank Symhtd:{ lhs := S, rhs := SC.substAll (iterR k ds) S, plus := false, dflt := r.dflt }.dflt = true → tl = default ∧ tr = defaultn:ℕih:∀ (v : ℕ → ℕ), v k = n → S.den v tl tr [M]⊢* S.den (sem (iterR k ds) v) tl trv:ℕ → ℕhv:v k = n + 1u:ℕ → ℕ := Function.update v k ne1:S.den v tl tr = r.lhs.den u tl tre2:r.rhs.den u tl tr = S.den (sem (iterL k ds) u) tl trw:ℕ → ℕ := sem (iterL k ds) uhw:w k = ne3:sem (iterR k ds) w = sem (iterR k ds) vh1:r.lhs.den u tl tr [M]⊢* r.rhs.den u tl tr⊢ S.den v tl tr [M]⊢* S.den (sem (iterR k ds) v) tl tr M:TMS:SCk:ℕds:List ℕhk:k < ds.lengthr:Rulehr:RuleOK M rhl:r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) = truehrr:r.rhs.beq (SC.substAll (iterL k ds) S) = truev✝:ℕ → ℕtl:ListBlank Symtr:ListBlank Symhtd:{ lhs := S, rhs := SC.substAll (iterR k ds) S, plus := false, dflt := r.dflt }.dflt = true → tl = default ∧ tr = defaultn:ℕih:∀ (v : ℕ → ℕ), v k = n → S.den v tl tr [M]⊢* S.den (sem (iterR k ds) v) tl trv:ℕ → ℕhv:v k = n + 1u:ℕ → ℕ := Function.update v k ne1:S.den v tl tr = r.lhs.den u tl tre2:r.rhs.den u tl tr = S.den (sem (iterL k ds) u) tl trw:ℕ → ℕ := sem (iterL k ds) uhw:w k = ne3:sem (iterR k ds) w = sem (iterR k ds) vh1:S.den v tl tr [M]⊢* S.den (sem (iterL k ds) u) tl tr⊢ S.den v tl tr [M]⊢* S.den (sem (iterR k ds) v) tl tr M:TMS:SCk:ℕds:List ℕhk:k < ds.lengthr:Rulehr:RuleOK M rhl:r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) = truehrr:r.rhs.beq (SC.substAll (iterL k ds) S) = truev✝:ℕ → ℕtl:ListBlank Symtr:ListBlank Symhtd:{ lhs := S, rhs := SC.substAll (iterR k ds) S, plus := false, dflt := r.dflt }.dflt = true → tl = default ∧ tr = defaultn:ℕih:∀ (v : ℕ → ℕ), v k = n → S.den v tl tr [M]⊢* S.den (sem (iterR k ds) v) tl trv:ℕ → ℕhv:v k = n + 1u:ℕ → ℕ := Function.update v k ne1:S.den v tl tr = r.lhs.den u tl tre2:r.rhs.den u tl tr = S.den (sem (iterL k ds) u) tl trw:ℕ → ℕ := sem (iterL k ds) uhw:w k = ne3:sem (iterR k ds) w = sem (iterR k ds) vh1:S.den v tl tr [M]⊢* S.den (sem (iterL k ds) u) tl trh2:S.den w tl tr [M]⊢* S.den (sem (iterR k ds) w) tl tr⊢ S.den v tl tr [M]⊢* S.den (sem (iterR k ds) v) tl tr M:TMS:SCk:ℕds:List ℕhk:k < ds.lengthr:Rulehr:RuleOK M rhl:r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) = truehrr:r.rhs.beq (SC.substAll (iterL k ds) S) = truev✝:ℕ → ℕtl:ListBlank Symtr:ListBlank Symhtd:{ lhs := S, rhs := SC.substAll (iterR k ds) S, plus := false, dflt := r.dflt }.dflt = true → tl = default ∧ tr = defaultn:ℕih:∀ (v : ℕ → ℕ), v k = n → S.den v tl tr [M]⊢* S.den (sem (iterR k ds) v) tl trv:ℕ → ℕhv:v k = n + 1u:ℕ → ℕ := Function.update v k ne1:S.den v tl tr = r.lhs.den u tl tre2:r.rhs.den u tl tr = S.den (sem (iterL k ds) u) tl trw:ℕ → ℕ := sem (iterL k ds) uhw:w k = ne3:sem (iterR k ds) w = sem (iterR k ds) vh1:S.den v tl tr [M]⊢* S.den (sem (iterL k ds) u) tl trh2:S.den w tl tr [M]⊢* S.den (sem (iterR k ds) v) tl tr⊢ S.den v tl tr [M]⊢* S.den (sem (iterR k ds) v) tl tr All goals completed! 🐙def buildRules (M : TM) : List Rule → List RDef → Option (List Rule) | done, [] => some done | done, .prove r pf :: ds => if run M [] done r.dflt pf [⟨r.lhs, r.plus, .cfg r.rhs⟩] then buildRules M (done ++ [r]) ds else none | done, .iter j S k dl :: ds => match done[j]? with | some r => if decide (k < dl.length) && r.lhs.beq (S.subst k ((Lin.var k).add (Lin.const 1))) && r.rhs.beq (S.substAll (iterL k dl)) then buildRules M (done ++ [⟨S, S.substAll (iterR k dl), false, r.dflt⟩]) ds else none | none => nonetheorem buildRules_sound (M : TM) : ∀ (ds : List RDef) (done rs : List Rule), (∀ r ∈ done, RuleOK M r) → buildRules M done ds = some rs → ∀ r ∈ rs, RuleOK M r M:TMdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rh:buildRules M done [] = some rs⊢ ∀ r ∈ rs, RuleOK M r M:TMdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rh:buildRules M done [] = some rs⊢ ∀ r ∈ rs, RuleOK M r M:TMdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rh:done = rs⊢ ∀ r ∈ rs, RuleOK M r; M:TMdone:List Rulehd:∀ r ∈ done, RuleOK M r⊢ ∀ r ∈ done, RuleOK M r; All goals completed! 🐙 M:TMr:Rulepf:List Insds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rh:buildRules M done (RDef.prove r pf :: ds) = some rs⊢ ∀ r ∈ rs, RuleOK M r M:TMr:Rulepf:List Insds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rh:buildRules M done (RDef.prove r pf :: ds) = some rs⊢ ∀ r ∈ rs, RuleOK M r M:TMr:Rulepf:List Insds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rh:(if run M [] done r.dflt pf [{ cur := r.lhs, np := r.plus, tgt := Tgt.cfg r.rhs }] = true then buildRules M (done ++ [r]) ds else none) = some rs⊢ ∀ r ∈ rs, RuleOK M r M:TMr:Rulepf:List Insds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rh✝:run M [] done r.dflt pf [{ cur := r.lhs, np := r.plus, tgt := Tgt.cfg r.rhs }] = trueh:buildRules M (done ++ [r]) ds = some rs⊢ ∀ r ∈ rs, RuleOK M rM:TMr:Rulepf:List Insds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rh✝:¬run M [] done r.dflt pf [{ cur := r.lhs, np := r.plus, tgt := Tgt.cfg r.rhs }] = trueh:none = some rs⊢ ∀ r ∈ rs, RuleOK M r M:TMr:Rulepf:List Insds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rh✝:run M [] done r.dflt pf [{ cur := r.lhs, np := r.plus, tgt := Tgt.cfg r.rhs }] = trueh:buildRules M (done ++ [r]) ds = some rs⊢ ∀ r ∈ rs, RuleOK M r M:TMr:Rulepf:List Insds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rhrun:run M [] done r.dflt pf [{ cur := r.lhs, np := r.plus, tgt := Tgt.cfg r.rhs }] = trueh:buildRules M (done ++ [r]) ds = some rs⊢ ∀ r ∈ rs, RuleOK M r M:TMr:Rulepf:List Insds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rhrun:run M [] done r.dflt pf [{ cur := r.lhs, np := r.plus, tgt := Tgt.cfg r.rhs }] = trueh:buildRules M (done ++ [r]) ds = some rs⊢ ∀ r_1 ∈ done ++ [r], RuleOK M r_1 M:TMr:Rulepf:List Insds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rhrun:run M [] done r.dflt pf [{ cur := r.lhs, np := r.plus, tgt := Tgt.cfg r.rhs }] = trueh:buildRules M (done ++ [r]) ds = some rsr':Rulehr':r' ∈ done ++ [r]⊢ RuleOK M r' M:TMr:Rulepf:List Insds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rhrun:run M [] done r.dflt pf [{ cur := r.lhs, np := r.plus, tgt := Tgt.cfg r.rhs }] = trueh:buildRules M (done ++ [r]) ds = some rsr':Rulehr'✝:r' ∈ done ++ [r]hr':r' ∈ done⊢ RuleOK M r'M:TMr:Rulepf:List Insds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rhrun:run M [] done r.dflt pf [{ cur := r.lhs, np := r.plus, tgt := Tgt.cfg r.rhs }] = trueh:buildRules M (done ++ [r]) ds = some rsr':Rulehr'✝:r' ∈ done ++ [r]hr':r' ∈ [r]⊢ RuleOK M r' M:TMr:Rulepf:List Insds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rhrun:run M [] done r.dflt pf [{ cur := r.lhs, np := r.plus, tgt := Tgt.cfg r.rhs }] = trueh:buildRules M (done ++ [r]) ds = some rsr':Rulehr'✝:r' ∈ done ++ [r]hr':r' ∈ done⊢ RuleOK M r' All goals completed! 🐙 M:TMr:Rulepf:List Insds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rhrun:run M [] done r.dflt pf [{ cur := r.lhs, np := r.plus, tgt := Tgt.cfg r.rhs }] = trueh:buildRules M (done ++ [r]) ds = some rsr':Rulehr'✝:r' ∈ done ++ [r]hr':r' ∈ [r]⊢ RuleOK M r' M:TMr:Rulepf:List Insds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rhrun:run M [] done r.dflt pf [{ cur := r.lhs, np := r.plus, tgt := Tgt.cfg r.rhs }] = trueh:buildRules M (done ++ [r]) ds = some rsr':Rulehr'✝:r' ∈ done ++ [r]hr':r' = r⊢ RuleOK M r'; M:TMpf:List Insds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rr':Rulehrun:run M [] done r'.dflt pf [{ cur := r'.lhs, np := r'.plus, tgt := Tgt.cfg r'.rhs }] = trueh:buildRules M (done ++ [r']) ds = some rshr':r' ∈ done ++ [r']⊢ RuleOK M r' M:TMpf:List Insds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rr':Rulehrun:run M [] done r'.dflt pf [{ cur := r'.lhs, np := r'.plus, tgt := Tgt.cfg r'.rhs }] = trueh:buildRules M (done ++ [r']) ds = some rshr':r' ∈ done ++ [r']hg:Good M (hubsPS []) r'.dflt { cur := r'.lhs, np := r'.plus, tgt := Tgt.cfg r'.rhs }⊢ RuleOK M r' M:TMpf:List Insds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rr':Rulehrun:run M [] done r'.dflt pf [{ cur := r'.lhs, np := r'.plus, tgt := Tgt.cfg r'.rhs }] = trueh:buildRules M (done ++ [r']) ds = some rshr':r' ∈ done ++ [r']hg:Good M (hubsPS []) r'.dflt { cur := r'.lhs, np := r'.plus, tgt := Tgt.cfg r'.rhs }v:ℕ → ℕtl:ListBlank Symtr:ListBlank Symhtd:r'.dflt = true → tl = default ∧ tr = default⊢ (r'.lhs.den v tl tr [M]⊢* r'.rhs.den v tl tr) ∧ (r'.plus = true → r'.lhs.den v tl tr [M]⊢⁺ r'.rhs.den v tl tr) M:TMpf:List Insds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rr':Rulehrun:run M [] done r'.dflt pf [{ cur := r'.lhs, np := r'.plus, tgt := Tgt.cfg r'.rhs }] = trueh:buildRules M (done ++ [r']) ds = some rshr':r' ∈ done ++ [r']hg:Good M (hubsPS []) r'.dflt { cur := r'.lhs, np := r'.plus, tgt := Tgt.cfg r'.rhs }v:ℕ → ℕtl:ListBlank Symtr:ListBlank Symhtd:r'.dflt = true → tl = default ∧ tr = defaultc':Cfg Sym Sth1:{ cur := r'.lhs, np := r'.plus, tgt := Tgt.cfg r'.rhs }.cur.den v tl tr [M]⊢* c'h2:{ cur := r'.lhs, np := r'.plus, tgt := Tgt.cfg r'.rhs }.np = true → { cur := r'.lhs, np := r'.plus, tgt := Tgt.cfg r'.rhs }.cur.den v tl tr [M]⊢⁺ c'h3:Final M (hubsPS []) { cur := r'.lhs, np := r'.plus, tgt := Tgt.cfg r'.rhs }.tgt v tl tr c'⊢ (r'.lhs.den v tl tr [M]⊢* r'.rhs.den v tl tr) ∧ (r'.plus = true → r'.lhs.den v tl tr [M]⊢⁺ r'.rhs.den v tl tr) M:TMpf:List Insds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rr':Rulehrun:run M [] done r'.dflt pf [{ cur := r'.lhs, np := r'.plus, tgt := Tgt.cfg r'.rhs }] = trueh:buildRules M (done ++ [r']) ds = some rshr':r' ∈ done ++ [r']hg:Good M (hubsPS []) r'.dflt { cur := r'.lhs, np := r'.plus, tgt := Tgt.cfg r'.rhs }v:ℕ → ℕtl:ListBlank Symtr:ListBlank Symhtd:r'.dflt = true → tl = default ∧ tr = defaultc':Cfg Sym Sth1:{ cur := r'.lhs, np := r'.plus, tgt := Tgt.cfg r'.rhs }.cur.den v tl tr [M]⊢* c'h2:{ cur := r'.lhs, np := r'.plus, tgt := Tgt.cfg r'.rhs }.np = true → { cur := r'.lhs, np := r'.plus, tgt := Tgt.cfg r'.rhs }.cur.den v tl tr [M]⊢⁺ c'h3:c' = r'.rhs.den v tl tr⊢ (r'.lhs.den v tl tr [M]⊢* r'.rhs.den v tl tr) ∧ (r'.plus = true → r'.lhs.den v tl tr [M]⊢⁺ r'.rhs.den v tl tr) M:TMpf:List Insds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rr':Rulehrun:run M [] done r'.dflt pf [{ cur := r'.lhs, np := r'.plus, tgt := Tgt.cfg r'.rhs }] = trueh:buildRules M (done ++ [r']) ds = some rshr':r' ∈ done ++ [r']hg:Good M (hubsPS []) r'.dflt { cur := r'.lhs, np := r'.plus, tgt := Tgt.cfg r'.rhs }v:ℕ → ℕtl:ListBlank Symtr:ListBlank Symhtd:r'.dflt = true → tl = default ∧ tr = defaulth1:{ cur := r'.lhs, np := r'.plus, tgt := Tgt.cfg r'.rhs }.cur.den v tl tr [M]⊢* r'.rhs.den v tl trh2:{ cur := r'.lhs, np := r'.plus, tgt := Tgt.cfg r'.rhs }.np = true → { cur := r'.lhs, np := r'.plus, tgt := Tgt.cfg r'.rhs }.cur.den v tl tr [M]⊢⁺ r'.rhs.den v tl tr⊢ (r'.lhs.den v tl tr [M]⊢* r'.rhs.den v tl tr) ∧ (r'.plus = true → r'.lhs.den v tl tr [M]⊢⁺ r'.rhs.den v tl tr) All goals completed! 🐙 M:TMr:Rulepf:List Insds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rh✝:¬run M [] done r.dflt pf [{ cur := r.lhs, np := r.plus, tgt := Tgt.cfg r.rhs }] = trueh:none = some rs⊢ ∀ r ∈ rs, RuleOK M r All goals completed! 🐙 M:TMj:ℕS:SCk:ℕdl:List ℕds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rh:buildRules M done (RDef.iter j S k dl :: ds) = some rs⊢ ∀ r ∈ rs, RuleOK M r M:TMj:ℕS:SCk:ℕdl:List ℕds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rh:buildRules M done (RDef.iter j S k dl :: ds) = some rs⊢ ∀ r ∈ rs, RuleOK M r M:TMj:ℕS:SCk:ℕdl:List ℕds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rh:(match done[j]? with | some r => if (decide (k < dl.length) && r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) && r.rhs.beq (SC.substAll (iterL k dl) S)) = true then buildRules M (done ++ [{ lhs := S, rhs := SC.substAll (iterR k dl) S, plus := false, dflt := r.dflt }]) ds else none | none => none) = some rs⊢ ∀ r ∈ rs, RuleOK M r cases hj : done[j]? with M:TMj:ℕS:SCk:ℕdl:List ℕds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rh:(match done[j]? with | some r => if (decide (k < dl.length) && r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) && r.rhs.beq (SC.substAll (iterL k dl) S)) = true then buildRules M (done ++ [{ lhs := S, rhs := SC.substAll (iterR k dl) S, plus := false, dflt := r.dflt }]) ds else none | none => none) = some rshj:done[j]? = none⊢ ∀ r ∈ rs, RuleOK M r All goals completed! 🐙 M:TMj:ℕS:SCk:ℕdl:List ℕds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rh:(match done[j]? with | some r => if (decide (k < dl.length) && r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) && r.rhs.beq (SC.substAll (iterL k dl) S)) = true then buildRules M (done ++ [{ lhs := S, rhs := SC.substAll (iterR k dl) S, plus := false, dflt := r.dflt }]) ds else none | none => none) = some rsr:Rulehj:done[j]? = some r⊢ ∀ r ∈ rs, RuleOK M r M:TMj:ℕS:SCk:ℕdl:List ℕds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rr:Rulehj:done[j]? = some rh:(if (decide (k < dl.length) && r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) && r.rhs.beq (SC.substAll (iterL k dl) S)) = true then buildRules M (done ++ [{ lhs := S, rhs := SC.substAll (iterR k dl) S, plus := false, dflt := r.dflt }]) ds else none) = some rs⊢ ∀ r ∈ rs, RuleOK M r M:TMj:ℕS:SCk:ℕdl:List ℕds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rr:Rulehj:done[j]? = some rh✝:(decide (k < dl.length) && r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) && r.rhs.beq (SC.substAll (iterL k dl) S)) = trueh:buildRules M (done ++ [{ lhs := S, rhs := SC.substAll (iterR k dl) S, plus := false, dflt := r.dflt }]) ds = some rs⊢ ∀ r ∈ rs, RuleOK M rM:TMj:ℕS:SCk:ℕdl:List ℕds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rr:Rulehj:done[j]? = some rh✝:¬(decide (k < dl.length) && r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) && r.rhs.beq (SC.substAll (iterL k dl) S)) = trueh:none = some rs⊢ ∀ r ∈ rs, RuleOK M r M:TMj:ℕS:SCk:ℕdl:List ℕds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rr:Rulehj:done[j]? = some rh✝:(decide (k < dl.length) && r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) && r.rhs.beq (SC.substAll (iterL k dl) S)) = trueh:buildRules M (done ++ [{ lhs := S, rhs := SC.substAll (iterR k dl) S, plus := false, dflt := r.dflt }]) ds = some rs⊢ ∀ r ∈ rs, RuleOK M r M:TMj:ℕS:SCk:ℕdl:List ℕds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rr:Rulehj:done[j]? = some rhc:(decide (k < dl.length) && r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) && r.rhs.beq (SC.substAll (iterL k dl) S)) = trueh:buildRules M (done ++ [{ lhs := S, rhs := SC.substAll (iterR k dl) S, plus := false, dflt := r.dflt }]) ds = some rs⊢ ∀ r ∈ rs, RuleOK M r M:TMj:ℕS:SCk:ℕdl:List ℕds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rr:Rulehj:done[j]? = some rh:buildRules M (done ++ [{ lhs := S, rhs := SC.substAll (iterR k dl) S, plus := false, dflt := r.dflt }]) ds = some rshc:(k < dl.length ∧ r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) = true) ∧ r.rhs.beq (SC.substAll (iterL k dl) S) = true⊢ ∀ r ∈ rs, RuleOK M r M:TMj:ℕS:SCk:ℕdl:List ℕds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rr:Rulehj:done[j]? = some rh:buildRules M (done ++ [{ lhs := S, rhs := SC.substAll (iterR k dl) S, plus := false, dflt := r.dflt }]) ds = some rshc:(k < dl.length ∧ r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) = true) ∧ r.rhs.beq (SC.substAll (iterL k dl) S) = true⊢ ∀ r_1 ∈ done ++ [{ lhs := S, rhs := SC.substAll (iterR k dl) S, plus := false, dflt := r.dflt }], RuleOK M r_1 M:TMj:ℕS:SCk:ℕdl:List ℕds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rr:Rulehj:done[j]? = some rh:buildRules M (done ++ [{ lhs := S, rhs := SC.substAll (iterR k dl) S, plus := false, dflt := r.dflt }]) ds = some rshc:(k < dl.length ∧ r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) = true) ∧ r.rhs.beq (SC.substAll (iterL k dl) S) = truer':Rulehr':r' ∈ done ++ [{ lhs := S, rhs := SC.substAll (iterR k dl) S, plus := false, dflt := r.dflt }]⊢ RuleOK M r' M:TMj:ℕS:SCk:ℕdl:List ℕds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rr:Rulehj:done[j]? = some rh:buildRules M (done ++ [{ lhs := S, rhs := SC.substAll (iterR k dl) S, plus := false, dflt := r.dflt }]) ds = some rshc:(k < dl.length ∧ r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) = true) ∧ r.rhs.beq (SC.substAll (iterL k dl) S) = truer':Rulehr'✝:r' ∈ done ++ [{ lhs := S, rhs := SC.substAll (iterR k dl) S, plus := false, dflt := r.dflt }]hr':r' ∈ done⊢ RuleOK M r'M:TMj:ℕS:SCk:ℕdl:List ℕds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rr:Rulehj:done[j]? = some rh:buildRules M (done ++ [{ lhs := S, rhs := SC.substAll (iterR k dl) S, plus := false, dflt := r.dflt }]) ds = some rshc:(k < dl.length ∧ r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) = true) ∧ r.rhs.beq (SC.substAll (iterL k dl) S) = truer':Rulehr'✝:r' ∈ done ++ [{ lhs := S, rhs := SC.substAll (iterR k dl) S, plus := false, dflt := r.dflt }]hr':r' ∈ [{ lhs := S, rhs := SC.substAll (iterR k dl) S, plus := false, dflt := r.dflt }]⊢ RuleOK M r' M:TMj:ℕS:SCk:ℕdl:List ℕds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rr:Rulehj:done[j]? = some rh:buildRules M (done ++ [{ lhs := S, rhs := SC.substAll (iterR k dl) S, plus := false, dflt := r.dflt }]) ds = some rshc:(k < dl.length ∧ r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) = true) ∧ r.rhs.beq (SC.substAll (iterL k dl) S) = truer':Rulehr'✝:r' ∈ done ++ [{ lhs := S, rhs := SC.substAll (iterR k dl) S, plus := false, dflt := r.dflt }]hr':r' ∈ done⊢ RuleOK M r' All goals completed! 🐙 M:TMj:ℕS:SCk:ℕdl:List ℕds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rr:Rulehj:done[j]? = some rh:buildRules M (done ++ [{ lhs := S, rhs := SC.substAll (iterR k dl) S, plus := false, dflt := r.dflt }]) ds = some rshc:(k < dl.length ∧ r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) = true) ∧ r.rhs.beq (SC.substAll (iterL k dl) S) = truer':Rulehr'✝:r' ∈ done ++ [{ lhs := S, rhs := SC.substAll (iterR k dl) S, plus := false, dflt := r.dflt }]hr':r' ∈ [{ lhs := S, rhs := SC.substAll (iterR k dl) S, plus := false, dflt := r.dflt }]⊢ RuleOK M r' M:TMj:ℕS:SCk:ℕdl:List ℕds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rr:Rulehj:done[j]? = some rh:buildRules M (done ++ [{ lhs := S, rhs := SC.substAll (iterR k dl) S, plus := false, dflt := r.dflt }]) ds = some rshc:(k < dl.length ∧ r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) = true) ∧ r.rhs.beq (SC.substAll (iterL k dl) S) = truer':Rulehr'✝:r' ∈ done ++ [{ lhs := S, rhs := SC.substAll (iterR k dl) S, plus := false, dflt := r.dflt }]hr':r' = { lhs := S, rhs := SC.substAll (iterR k dl) S, plus := false, dflt := r.dflt }⊢ RuleOK M r'; M:TMj:ℕS:SCk:ℕdl:List ℕds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rr:Rulehj:done[j]? = some rh:buildRules M (done ++ [{ lhs := S, rhs := SC.substAll (iterR k dl) S, plus := false, dflt := r.dflt }]) ds = some rshc:(k < dl.length ∧ r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) = true) ∧ r.rhs.beq (SC.substAll (iterL k dl) S) = truehr':{ lhs := S, rhs := SC.substAll (iterR k dl) S, plus := false, dflt := r.dflt } ∈ done ++ [{ lhs := S, rhs := SC.substAll (iterR k dl) S, plus := false, dflt := r.dflt }]⊢ RuleOK M { lhs := S, rhs := SC.substAll (iterR k dl) S, plus := false, dflt := r.dflt } All goals completed! 🐙 M:TMj:ℕS:SCk:ℕdl:List ℕds:List RDefdone:List Rulers:List Rulehd:∀ r ∈ done, RuleOK M rr:Rulehj:done[j]? = some rh✝:¬(decide (k < dl.length) && r.lhs.beq (SC.subst k ((Lin.var k).add (Lin.const 1)) S) && r.rhs.beq (SC.substAll (iterL k dl) S)) = trueh:none = some rs⊢ ∀ r ∈ rs, RuleOK M r All goals completed! 🐙

Certificate Checks and Their Soundness

def initSC : SC := ⟨0, true, [], []⟩def checkTrans (M : TM) (rules : List RDef) (lhs rhs : SC) (pf : List Ins) : Bool := match buildRules M [] rules with | some rs => run M [] rs true pf [⟨lhs, true, .cfg rhs⟩] | none => falsetheorem checkTrans_sound (M : TM) (rules : List RDef) (lhs rhs : SC) (pf : List Ins) (h : checkTrans M rules lhs rhs pf = true) (v : ℕ → ℕ) : (lhs.den v default default) [M]⊢⁺ (rhs.den v default default) := M:TMrules:List RDeflhs:SCrhs:SCpf:List Insh:checkTrans M rules lhs rhs pf = truev:ℕ → ℕ⊢ lhs.den v default default [M]⊢⁺ rhs.den v default default M:TMrules:List RDeflhs:SCrhs:SCpf:List Insh:(match buildRules M [] rules with | some rs => run M [] rs true pf [{ cur := lhs, np := true, tgt := Tgt.cfg rhs }] | none => false) = truev:ℕ → ℕ⊢ lhs.den v default default [M]⊢⁺ rhs.den v default default cases hrs : buildRules M [] rules with M:TMrules:List RDeflhs:SCrhs:SCpf:List Insh:(match buildRules M [] rules with | some rs => run M [] rs true pf [{ cur := lhs, np := true, tgt := Tgt.cfg rhs }] | none => false) = truev:ℕ → ℕhrs:buildRules M [] rules = none⊢ lhs.den v default default [M]⊢⁺ rhs.den v default default All goals completed! 🐙 M:TMrules:List RDeflhs:SCrhs:SCpf:List Insh:(match buildRules M [] rules with | some rs => run M [] rs true pf [{ cur := lhs, np := true, tgt := Tgt.cfg rhs }] | none => false) = truev:ℕ → ℕrs:List Rulehrs:buildRules M [] rules = some rs⊢ lhs.den v default default [M]⊢⁺ rhs.den v default default M:TMrules:List RDeflhs:SCrhs:SCpf:List Insv:ℕ → ℕrs:List Rulehrs:buildRules M [] rules = some rsh:run M [] rs true pf [{ cur := lhs, np := true, tgt := Tgt.cfg rhs }] = true⊢ lhs.den v default default [M]⊢⁺ rhs.den v default default M:TMrules:List RDeflhs:SCrhs:SCpf:List Insv:ℕ → ℕrs:List Rulehrs:buildRules M [] rules = some rsh:run M [] rs true pf [{ cur := lhs, np := true, tgt := Tgt.cfg rhs }] = truehr:∀ r ∈ rs, RuleOK M r⊢ lhs.den v default default [M]⊢⁺ rhs.den v default default M:TMrules:List RDeflhs:SCrhs:SCpf:List Insv:ℕ → ℕrs:List Rulehrs:buildRules M [] rules = some rsh:run M [] rs true pf [{ cur := lhs, np := true, tgt := Tgt.cfg rhs }] = truehr:∀ r ∈ rs, RuleOK M rhg:Good M (hubsPS []) true { cur := lhs, np := true, tgt := Tgt.cfg rhs }⊢ lhs.den v default default [M]⊢⁺ rhs.den v default default M:TMrules:List RDeflhs:SCrhs:SCpf:List Insv:ℕ → ℕrs:List Rulehrs:buildRules M [] rules = some rsh:run M [] rs true pf [{ cur := lhs, np := true, tgt := Tgt.cfg rhs }] = truehr:∀ r ∈ rs, RuleOK M rhg:Good M (hubsPS []) true { cur := lhs, np := true, tgt := Tgt.cfg rhs }c':Cfg Sym Stleft✝:{ cur := lhs, np := true, tgt := Tgt.cfg rhs }.cur.den v default default [M]⊢* c'h2:{ cur := lhs, np := true, tgt := Tgt.cfg rhs }.np = true → { cur := lhs, np := true, tgt := Tgt.cfg rhs }.cur.den v default default [M]⊢⁺ c'h3:Final M (hubsPS []) { cur := lhs, np := true, tgt := Tgt.cfg rhs }.tgt v default default c'⊢ lhs.den v default default [M]⊢⁺ rhs.den v default default M:TMrules:List RDeflhs:SCrhs:SCpf:List Insv:ℕ → ℕrs:List Rulehrs:buildRules M [] rules = some rsh:run M [] rs true pf [{ cur := lhs, np := true, tgt := Tgt.cfg rhs }] = truehr:∀ r ∈ rs, RuleOK M rhg:Good M (hubsPS []) true { cur := lhs, np := true, tgt := Tgt.cfg rhs }c':Cfg Sym Stleft✝:{ cur := lhs, np := true, tgt := Tgt.cfg rhs }.cur.den v default default [M]⊢* c'h2:{ cur := lhs, np := true, tgt := Tgt.cfg rhs }.np = true → { cur := lhs, np := true, tgt := Tgt.cfg rhs }.cur.den v default default [M]⊢⁺ c'h3:c' = rhs.den v default default⊢ lhs.den v default default [M]⊢⁺ rhs.den v default default; M:TMrules:List RDeflhs:SCrhs:SCpf:List Insv:ℕ → ℕrs:List Rulehrs:buildRules M [] rules = some rsh:run M [] rs true pf [{ cur := lhs, np := true, tgt := Tgt.cfg rhs }] = truehr:∀ r ∈ rs, RuleOK M rhg:Good M (hubsPS []) true { cur := lhs, np := true, tgt := Tgt.cfg rhs }left✝:{ cur := lhs, np := true, tgt := Tgt.cfg rhs }.cur.den v default default [M]⊢* rhs.den v default defaulth2:{ cur := lhs, np := true, tgt := Tgt.cfg rhs }.np = true → { cur := lhs, np := true, tgt := Tgt.cfg rhs }.cur.den v default default [M]⊢⁺ rhs.den v default default⊢ lhs.den v default default [M]⊢⁺ rhs.den v default default All goals completed! 🐙def checkHaltTrans (M : TM) (rules : List RDef) (lhs rhs : SC) (pf : List Ins) : Bool := isHalt M true rhs && match buildRules M [] rules with | some rs => run M [] rs true pf [⟨lhs, true, .cfg rhs⟩] | none => falsetheorem checkHaltTrans_sound (M : TM) (rules : List RDef) (lhs rhs : SC) (pf : List Ins) (h : checkHaltTrans M rules lhs rhs pf = true) (v : ℕ → ℕ) : ((lhs.den v default default) [M]⊢⁺ (rhs.den v default default)) ∧ (step M (rhs.den v default default)).isNone := M:TMrules:List RDeflhs:SCrhs:SCpf:List Insh:checkHaltTrans M rules lhs rhs pf = truev:ℕ → ℕ⊢ (lhs.den v default default [M]⊢⁺ rhs.den v default default) ∧ (step M (rhs.den v default default)).isNone = true M:TMrules:List RDeflhs:SCrhs:SCpf:List Insv:ℕ → ℕh:isHalt M true rhs = true ∧ (match buildRules M [] rules with | some rs => run M [] rs true pf [{ cur := lhs, np := true, tgt := Tgt.cfg rhs }] | none => false) = true⊢ (lhs.den v default default [M]⊢⁺ rhs.den v default default) ∧ (step M (rhs.den v default default)).isNone = true M:TMrules:List RDeflhs:SCrhs:SCpf:List Insv:ℕ → ℕh:isHalt M true rhs = true ∧ (match buildRules M [] rules with | some rs => run M [] rs true pf [{ cur := lhs, np := true, tgt := Tgt.cfg rhs }] | none => false) = true⊢ (step M (rhs.den v default default)).isNone = true All goals completed! 🐙def checkHub (M : TM) (hubs : List SC) (rules : List RDef) (hub : SC) (pf : List Ins) : Bool := hubs.all hubOK && match buildRules M [] rules with | some rs => run M hubs rs true pf [⟨hub, true, .hubs⟩] | none => falsetheorem checkHub_sound (M : TM) (hubs : List SC) (rules : List RDef) (hub : SC) (pf : List Ins) (h : checkHub M hubs rules hub pf = true) (v : ℕ → ℕ) : ∃ cfg', ((hub.den v default default) [M]⊢⁺ cfg') ∧ (IsInPatternSet (hubsPS hubs) cfg' ∨ (step M cfg').isNone) := M:TMhubs:List SCrules:List RDefhub:SCpf:List Insh:checkHub M hubs rules hub pf = truev:ℕ → ℕ⊢ ∃ cfg', (hub.den v default default [M]⊢⁺ cfg') ∧ (IsInPatternSet (hubsPS hubs) cfg' ∨ (step M cfg').isNone = true) M:TMhubs:List SCrules:List RDefhub:SCpf:List Insv:ℕ → ℕh:(∀ x ∈ hubs, hubOK x = true) ∧ (match buildRules M [] rules with | some rs => run M hubs rs true pf [{ cur := hub, np := true, tgt := Tgt.hubs }] | none => false) = true⊢ ∃ cfg', (hub.den v default default [M]⊢⁺ cfg') ∧ (IsInPatternSet (hubsPS hubs) cfg' ∨ (step M cfg').isNone = true) M:TMhubs:List SCrules:List RDefhub:SCpf:List Insv:ℕ → ℕhh:∀ x ∈ hubs, hubOK x = truehb:(match buildRules M [] rules with | some rs => run M hubs rs true pf [{ cur := hub, np := true, tgt := Tgt.hubs }] | none => false) = true⊢ ∃ cfg', (hub.den v default default [M]⊢⁺ cfg') ∧ (IsInPatternSet (hubsPS hubs) cfg' ∨ (step M cfg').isNone = true) cases hrs : buildRules M [] rules with M:TMhubs:List SCrules:List RDefhub:SCpf:List Insv:ℕ → ℕhh:∀ x ∈ hubs, hubOK x = truehb:(match buildRules M [] rules with | some rs => run M hubs rs true pf [{ cur := hub, np := true, tgt := Tgt.hubs }] | none => false) = truehrs:buildRules M [] rules = none⊢ ∃ cfg', (hub.den v default default [M]⊢⁺ cfg') ∧ (IsInPatternSet (hubsPS hubs) cfg' ∨ (step M cfg').isNone = true) All goals completed! 🐙 M:TMhubs:List SCrules:List RDefhub:SCpf:List Insv:ℕ → ℕhh:∀ x ∈ hubs, hubOK x = truehb:(match buildRules M [] rules with | some rs => run M hubs rs true pf [{ cur := hub, np := true, tgt := Tgt.hubs }] | none => false) = truers:List Rulehrs:buildRules M [] rules = some rs⊢ ∃ cfg', (hub.den v default default [M]⊢⁺ cfg') ∧ (IsInPatternSet (hubsPS hubs) cfg' ∨ (step M cfg').isNone = true) M:TMhubs:List SCrules:List RDefhub:SCpf:List Insv:ℕ → ℕhh:∀ x ∈ hubs, hubOK x = truers:List Rulehrs:buildRules M [] rules = some rshb:run M hubs rs true pf [{ cur := hub, np := true, tgt := Tgt.hubs }] = true⊢ ∃ cfg', (hub.den v default default [M]⊢⁺ cfg') ∧ (IsInPatternSet (hubsPS hubs) cfg' ∨ (step M cfg').isNone = true) M:TMhubs:List SCrules:List RDefhub:SCpf:List Insv:ℕ → ℕhh:∀ x ∈ hubs, hubOK x = truers:List Rulehrs:buildRules M [] rules = some rshb:run M hubs rs true pf [{ cur := hub, np := true, tgt := Tgt.hubs }] = truehr:∀ r ∈ rs, RuleOK M r⊢ ∃ cfg', (hub.den v default default [M]⊢⁺ cfg') ∧ (IsInPatternSet (hubsPS hubs) cfg' ∨ (step M cfg').isNone = true) M:TMhubs:List SCrules:List RDefhub:SCpf:List Insv:ℕ → ℕhh:∀ x ∈ hubs, hubOK x = truers:List Rulehrs:buildRules M [] rules = some rshb:run M hubs rs true pf [{ cur := hub, np := true, tgt := Tgt.hubs }] = truehr:∀ r ∈ rs, RuleOK M rhg:Good M (hubsPS hubs) true { cur := hub, np := true, tgt := Tgt.hubs }⊢ ∃ cfg', (hub.den v default default [M]⊢⁺ cfg') ∧ (IsInPatternSet (hubsPS hubs) cfg' ∨ (step M cfg').isNone = true) M:TMhubs:List SCrules:List RDefhub:SCpf:List Insv:ℕ → ℕhh:∀ x ∈ hubs, hubOK x = truers:List Rulehrs:buildRules M [] rules = some rshb:run M hubs rs true pf [{ cur := hub, np := true, tgt := Tgt.hubs }] = truehr:∀ r ∈ rs, RuleOK M rhg:Good M (hubsPS hubs) true { cur := hub, np := true, tgt := Tgt.hubs }c':Cfg Sym Stleft✝:{ cur := hub, np := true, tgt := Tgt.hubs }.cur.den v default default [M]⊢* c'h2:{ cur := hub, np := true, tgt := Tgt.hubs }.np = true → { cur := hub, np := true, tgt := Tgt.hubs }.cur.den v default default [M]⊢⁺ c'h3:Final M (hubsPS hubs) { cur := hub, np := true, tgt := Tgt.hubs }.tgt v default default c'⊢ ∃ cfg', (hub.den v default default [M]⊢⁺ cfg') ∧ (IsInPatternSet (hubsPS hubs) cfg' ∨ (step M cfg').isNone = true) All goals completed! 🐙def checkInit (M : TM) (rules : List RDef) (rhs : SC) (pf : List Ins) : Bool := match buildRules M [] rules with | some rs => run M [] rs true pf [⟨initSC, false, .cfg rhs⟩] | none => falsetheorem checkInit_sound (M : TM) (rules : List RDef) (rhs : SC) (pf : List Ins) (h : checkInit M rules rhs pf = true) (v : ℕ → ℕ) : (init []) [M]⊢* (rhs.den v default default) := M:TMrules:List RDefrhs:SCpf:List Insh:checkInit M rules rhs pf = truev:ℕ → ℕ⊢ init [] [M]⊢* rhs.den v default default M:TMrules:List RDefrhs:SCpf:List Insh:(match buildRules M [] rules with | some rs => run M [] rs true pf [{ cur := initSC, np := false, tgt := Tgt.cfg rhs }] | none => false) = truev:ℕ → ℕ⊢ init [] [M]⊢* rhs.den v default default cases hrs : buildRules M [] rules with M:TMrules:List RDefrhs:SCpf:List Insh:(match buildRules M [] rules with | some rs => run M [] rs true pf [{ cur := initSC, np := false, tgt := Tgt.cfg rhs }] | none => false) = truev:ℕ → ℕhrs:buildRules M [] rules = none⊢ init [] [M]⊢* rhs.den v default default All goals completed! 🐙 M:TMrules:List RDefrhs:SCpf:List Insh:(match buildRules M [] rules with | some rs => run M [] rs true pf [{ cur := initSC, np := false, tgt := Tgt.cfg rhs }] | none => false) = truev:ℕ → ℕrs:List Rulehrs:buildRules M [] rules = some rs⊢ init [] [M]⊢* rhs.den v default default M:TMrules:List RDefrhs:SCpf:List Insv:ℕ → ℕrs:List Rulehrs:buildRules M [] rules = some rsh:run M [] rs true pf [{ cur := initSC, np := false, tgt := Tgt.cfg rhs }] = true⊢ init [] [M]⊢* rhs.den v default default M:TMrules:List RDefrhs:SCpf:List Insv:ℕ → ℕrs:List Rulehrs:buildRules M [] rules = some rsh:run M [] rs true pf [{ cur := initSC, np := false, tgt := Tgt.cfg rhs }] = truehr:∀ r ∈ rs, RuleOK M r⊢ init [] [M]⊢* rhs.den v default default M:TMrules:List RDefrhs:SCpf:List Insv:ℕ → ℕrs:List Rulehrs:buildRules M [] rules = some rsh:run M [] rs true pf [{ cur := initSC, np := false, tgt := Tgt.cfg rhs }] = truehr:∀ r ∈ rs, RuleOK M rhg:Good M (hubsPS []) true { cur := initSC, np := false, tgt := Tgt.cfg rhs }⊢ init [] [M]⊢* rhs.den v default default M:TMrules:List RDefrhs:SCpf:List Insv:ℕ → ℕrs:List Rulehrs:buildRules M [] rules = some rsh:run M [] rs true pf [{ cur := initSC, np := false, tgt := Tgt.cfg rhs }] = truehr:∀ r ∈ rs, RuleOK M rhg:Good M (hubsPS []) true { cur := initSC, np := false, tgt := Tgt.cfg rhs }c':Cfg Sym Sth1:{ cur := initSC, np := false, tgt := Tgt.cfg rhs }.cur.den v default default [M]⊢* c'left✝:{ cur := initSC, np := false, tgt := Tgt.cfg rhs }.np = true → { cur := initSC, np := false, tgt := Tgt.cfg rhs }.cur.den v default default [M]⊢⁺ c'h3:Final M (hubsPS []) { cur := initSC, np := false, tgt := Tgt.cfg rhs }.tgt v default default c'⊢ init [] [M]⊢* rhs.den v default default M:TMrules:List RDefrhs:SCpf:List Insv:ℕ → ℕrs:List Rulehrs:buildRules M [] rules = some rsh:run M [] rs true pf [{ cur := initSC, np := false, tgt := Tgt.cfg rhs }] = truehr:∀ r ∈ rs, RuleOK M rhg:Good M (hubsPS []) true { cur := initSC, np := false, tgt := Tgt.cfg rhs }c':Cfg Sym Sth1:{ cur := initSC, np := false, tgt := Tgt.cfg rhs }.cur.den v default default [M]⊢* c'left✝:{ cur := initSC, np := false, tgt := Tgt.cfg rhs }.np = true → { cur := initSC, np := false, tgt := Tgt.cfg rhs }.cur.den v default default [M]⊢⁺ c'h3:c' = rhs.den v default default⊢ init [] [M]⊢* rhs.den v default default; M:TMrules:List RDefrhs:SCpf:List Insv:ℕ → ℕrs:List Rulehrs:buildRules M [] rules = some rsh:run M [] rs true pf [{ cur := initSC, np := false, tgt := Tgt.cfg rhs }] = truehr:∀ r ∈ rs, RuleOK M rhg:Good M (hubsPS []) true { cur := initSC, np := false, tgt := Tgt.cfg rhs }h1:{ cur := initSC, np := false, tgt := Tgt.cfg rhs }.cur.den v default default [M]⊢* rhs.den v default defaultleft✝:{ cur := initSC, np := false, tgt := Tgt.cfg rhs }.np = true → { cur := initSC, np := false, tgt := Tgt.cfg rhs }.cur.den v default default [M]⊢⁺ rhs.den v default default⊢ init [] [M]⊢* rhs.den v default default All goals completed! 🐙end Certend BusyBeaver