Imports
/-
Copyright (c) 2026 Terence Rokop. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Terence Rokop
-/
module
public import Geb.Prototypes.Computability.BitTree.BinaryMachine.Steps
public import Geb.Prototypes.Computability.BitTree.Counterset_option doc.verso trueBinary carry execution
An initial sequence of one-bits is reset while both binary heads advance. The first zero-bit ends the carry after being set to one. The statements here follow the actual machine steps.
Main statements
-
configs_carry_prefixdescribes every intermediate carry configuration. -
configs_carry_bitsidentifies the terminal counter with binary-list increment. -
configs_carry_bits_posgives both binary head positions throughout the carry.
Implementation notes
The module relates list-level increment to CSLib's configuration sequence. Its machine statements inherit the axioms of CSLib's input-symbol access through the step function.
Tags
Turing machine, binary counter, carry propagation
@[expose] public sectionnamespace Geb.BitTree.BinaryMachineopen Turing MultiTapeTMResetting an initial sequence of ones preserves the carry state and advances both heads.
theorem configs_carry_prefix {input : List (Fin 4)}
(cfg : Cfg 3 (Fin 4) (Fin 10) input) (leaf : Bool) (p k : ℕ)
(hq : cfg.state = some (if leaf then stCarryLeaf else stCarryFork))
(hp0 : cfg.workTapePos 0 = p) (hp1 : cfg.workTapePos 1 = p)
(hones : ∀ j < k, digits cfg (if leaf then 1 else 0) (p + j) = true)
(t : ℕ) (ht : t ≤ k) :
let now := machine.configs cfg t
now.state = some (if leaf then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = (p + t : ℕ) ∧ now.workTapePos 1 = (p + t : ℕ) ∧
now.inputPos = cfg.inputPos ∧
digits now (if leaf then 1 else 0) =
(fun j ↦ if p ≤ j ∧ j < p + t then false else digits cfg (if leaf then 1 else 0) j) ∧
digits now (if leaf then 0 else 1) = digits cfg (if leaf then 0 else 1) := input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet:ℕht:t ≤ k⊢ let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)
input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet:ℕ⊢ t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)
input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet:ℕ⊢ Nat.zero ≤ k →
let now := configs cfg Nat.zero;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + Nat.zero) ∧
now.workTapePos 1 = ↑(p + Nat.zero) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + Nat.zero then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet:ℕ⊢ ∀ (n : ℕ),
(n ≤ k →
let now := configs cfg n;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + n) ∧
now.workTapePos 1 = ↑(p + n) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + n then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)) →
n.succ ≤ k →
let now := configs cfg n.succ;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + n.succ) ∧
now.workTapePos 1 = ↑(p + n.succ) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + n.succ then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)
input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet:ℕ⊢ Nat.zero ≤ k →
let now := configs cfg Nat.zero;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + Nat.zero) ∧
now.workTapePos 1 = ↑(p + Nat.zero) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + Nat.zero then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1) input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet:ℕa✝:Nat.zero ≤ k⊢ let now := configs cfg Nat.zero;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + Nat.zero) ∧
now.workTapePos 1 = ↑(p + Nat.zero) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + Nat.zero then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)
input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet:ℕa✝:Nat.zero ≤ k⊢ digits (configs cfg Nat.zero) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + Nat.zero then false else digits cfg (if leaf = true then 1 else 0) j
input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet:ℕa✝:Nat.zero ≤ kj:ℕ⊢ digits (configs cfg Nat.zero) (if leaf = true then 1 else 0) j =
if p ≤ j ∧ j < p + Nat.zero then false else digits cfg (if leaf = true then 1 else 0) j
input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet:ℕa✝:Nat.zero ≤ kj:ℕhj:¬(p ≤ j ∧ j < p + 0)⊢ digits (configs cfg Nat.zero) (if leaf = true then 1 else 0) j =
if p ≤ j ∧ j < p + Nat.zero then false else digits cfg (if leaf = true then 1 else 0) j
simp only [configs_zero, hj, ↓reduceIte] All goals completed! 🐙
· input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet:ℕ⊢ ∀ (n : ℕ),
(n ≤ k →
let now := configs cfg n;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + n) ∧
now.workTapePos 1 = ↑(p + n) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + n then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)) →
n.succ ≤ k →
let now := configs cfg n.succ;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + n.succ) ∧
now.workTapePos 1 = ↑(p + n.succ) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + n.succ then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1) intro t ih ht input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ k⊢ let now := configs cfg t.succ;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t.succ) ∧
now.workTapePos 1 = ↑(p + t.succ) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t.succ then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)
obtain ⟨hstate, hpos0, hpos1, hin, hselected, hother⟩ := ih (by input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ k⊢ t ≤ k omega All goals completed! 🐙) input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)⊢ let now := configs cfg t.succ;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t.succ) ∧
now.workTapePos 1 = ↑(p + t.succ) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t.succ then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)
let now := machine.configs cfg t input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg t⊢ let now := configs cfg t.succ;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t.succ) ∧
now.workTapePos 1 = ↑(p + t.succ) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t.succ then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)
have hp : now.workTapePos (if leaf then 1 else 0) = (p + t : ℕ) := by input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet:ℕht:t ≤ k⊢ let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)
cases leaf false input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputp:ℕk:ℕhp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑pt✝:ℕt:ℕht:t.succ ≤ khpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPosnow:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thq:cfg.state = some (if false = true then stCarryLeaf else stCarryFork)hones:∀ j < k, digits cfg (if false = true then 1 else 0) (p + j) = trueih:t ≤ k →
let now := configs cfg t;
now.state = some (if false = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if false = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if false = true then 1 else 0) j) ∧
digits now (if false = true then 0 else 1) = digits cfg (if false = true then 0 else 1)hstate:(configs cfg t).state = some (if false = true then stCarryLeaf else stCarryFork)hselected:digits (configs cfg t) (if false = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if false = true then 1 else 0) jhother:digits (configs cfg t) (if false = true then 0 else 1) = digits cfg (if false = true then 0 else 1)⊢ now.workTapePos (if false = true then 1 else 0) = ↑(p + t)true input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputp:ℕk:ℕhp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑pt✝:ℕt:ℕht:t.succ ≤ khpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPosnow:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thq:cfg.state = some (if true = true then stCarryLeaf else stCarryFork)hones:∀ j < k, digits cfg (if true = true then 1 else 0) (p + j) = trueih:t ≤ k →
let now := configs cfg t;
now.state = some (if true = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if true = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if true = true then 1 else 0) j) ∧
digits now (if true = true then 0 else 1) = digits cfg (if true = true then 0 else 1)hstate:(configs cfg t).state = some (if true = true then stCarryLeaf else stCarryFork)hselected:digits (configs cfg t) (if true = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if true = true then 1 else 0) jhother:digits (configs cfg t) (if true = true then 0 else 1) = digits cfg (if true = true then 0 else 1)⊢ now.workTapePos (if true = true then 1 else 0) = ↑(p + t)
· false input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputp:ℕk:ℕhp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑pt✝:ℕt:ℕht:t.succ ≤ khpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPosnow:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thq:cfg.state = some (if false = true then stCarryLeaf else stCarryFork)hones:∀ j < k, digits cfg (if false = true then 1 else 0) (p + j) = trueih:t ≤ k →
let now := configs cfg t;
now.state = some (if false = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if false = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if false = true then 1 else 0) j) ∧
digits now (if false = true then 0 else 1) = digits cfg (if false = true then 0 else 1)hstate:(configs cfg t).state = some (if false = true then stCarryLeaf else stCarryFork)hselected:digits (configs cfg t) (if false = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if false = true then 1 else 0) jhother:digits (configs cfg t) (if false = true then 0 else 1) = digits cfg (if false = true then 0 else 1)⊢ now.workTapePos (if false = true then 1 else 0) = ↑(p + t) exact hpos0 All goals completed! 🐙
· true input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputp:ℕk:ℕhp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑pt✝:ℕt:ℕht:t.succ ≤ khpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPosnow:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thq:cfg.state = some (if true = true then stCarryLeaf else stCarryFork)hones:∀ j < k, digits cfg (if true = true then 1 else 0) (p + j) = trueih:t ≤ k →
let now := configs cfg t;
now.state = some (if true = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if true = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if true = true then 1 else 0) j) ∧
digits now (if true = true then 0 else 1) = digits cfg (if true = true then 0 else 1)hstate:(configs cfg t).state = some (if true = true then stCarryLeaf else stCarryFork)hselected:digits (configs cfg t) (if true = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if true = true then 1 else 0) jhother:digits (configs cfg t) (if true = true then 0 else 1) = digits cfg (if true = true then 0 else 1)⊢ now.workTapePos (if true = true then 1 else 0) = ↑(p + t) exact hpos1 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)⊢ let now := configs cfg t.succ;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t.succ) ∧
now.workTapePos 1 = ↑(p + t.succ) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t.succ then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)
have hone := hones t (by input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)⊢ t < k omega All goals completed! 🐙) input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = true⊢ let now := configs cfg t.succ;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t.succ) ∧
now.workTapePos 1 = ↑(p + t.succ) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t.succ then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)
have hd : digit (now.workTapeSymbols (if leaf then 1 else 0)) = true := by input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet:ℕht:t ≤ k⊢ let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)
change digit (now.workTapes (if leaf then 1 else 0)
(now.workTapePos (if leaf then 1 else 0))) = true input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = true⊢ digit (now.workTapes (if leaf = true then 1 else 0) (now.workTapePos (if leaf = true then 1 else 0))) = true
rw [hp input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = true⊢ digit (now.workTapes (if leaf = true then 1 else 0) ↑(p + t)) = true] input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = true⊢ digit (now.workTapes (if leaf = true then 1 else 0) ↑(p + t)) = true
change digits now (if leaf then 1 else 0) (p + t) = true input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = true⊢ digits now (if leaf = true then 1 else 0) (p + t) = true
rw [hselected input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = true⊢ (fun j ↦ if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) (p + t) = true] input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = true⊢ (fun j ↦ if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) (p + t) = true
simp only [Nat.lt_irrefl, and_false, ↓reduceIte] input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = true⊢ digits cfg (if leaf = true then 1 else 0) (p + t) = true
exact hone input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = true⊢ let now := configs cfg t.succ;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t.succ) ∧
now.workTapePos 1 = ↑(p + t.succ) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t.succ then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)
rw [configs_succ_eq_step' input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = true⊢ let now := MultiTapeTM.step (configs cfg t);
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t.succ) ∧
now.workTapePos 1 = ↑(p + t.succ) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t.succ then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)] input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = true⊢ let now := MultiTapeTM.step (configs cfg t);
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t.succ) ∧
now.workTapePos 1 = ↑(p + t.succ) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t.succ then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)
refine ⟨?_, ?_, ?_, ?_, ?_, ?_⟩ refine_1 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = true⊢ (MultiTapeTM.step (configs cfg t)).state = some (if leaf = true then stCarryLeaf else stCarryFork)refine_2 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = true⊢ (MultiTapeTM.step (configs cfg t)).workTapePos 0 = ↑(p + t.succ)refine_3 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = true⊢ (MultiTapeTM.step (configs cfg t)).workTapePos 1 = ↑(p + t.succ)refine_4 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = true⊢ (MultiTapeTM.step (configs cfg t)).inputPos = cfg.inputPosrefine_5 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = true⊢ digits (MultiTapeTM.step (configs cfg t)) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t.succ then false else digits cfg (if leaf = true then 1 else 0) jrefine_6 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = true⊢ digits (MultiTapeTM.step (configs cfg t)) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)
· refine_1 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = true⊢ (MultiTapeTM.step (configs cfg t)).state = some (if leaf = true then stCarryLeaf else stCarryFork) rw [step_carry_state now leaf hstate, refine_1 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = true⊢ some
(if digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = true then
if leaf = true then stCarryLeaf else stCarryFork
else stReturn) =
some (if leaf = true then stCarryLeaf else stCarryFork) hd refine_1 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = true⊢ some (if true = true then if leaf = true then stCarryLeaf else stCarryFork else stReturn) =
some (if leaf = true then stCarryLeaf else stCarryFork)] refine_1 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = true⊢ some (if true = true then if leaf = true then stCarryLeaf else stCarryFork else stReturn) =
some (if leaf = true then stCarryLeaf else stCarryFork)
rfl All goals completed! 🐙
· refine_2 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = true⊢ (MultiTapeTM.step (configs cfg t)).workTapePos 0 = ↑(p + t.succ) rw [step_carry_binaryPos now leaf 0 (by input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = true⊢ 0 ≠ 2 decide All goals completed! 🐙) hstate, hpos0 refine_2 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = true⊢ ↑(p + t) + 1 = ↑(p + t.succ)] refine_2 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = true⊢ ↑(p + t) + 1 = ↑(p + t.succ)
simp [Int.add_assoc] All goals completed! 🐙
· refine_3 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = true⊢ (MultiTapeTM.step (configs cfg t)).workTapePos 1 = ↑(p + t.succ) rw [step_carry_binaryPos now leaf 1 (by input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = true⊢ 1 ≠ 2 decide All goals completed! 🐙) hstate, hpos1 refine_3 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = true⊢ ↑(p + t) + 1 = ↑(p + t.succ)] refine_3 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = true⊢ ↑(p + t) + 1 = ↑(p + t.succ)
simp [Int.add_assoc] All goals completed! 🐙
· refine_4 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = true⊢ (MultiTapeTM.step (configs cfg t)).inputPos = cfg.inputPos rw [step_carry_inputPos now leaf hstate, refine_4 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = true⊢ now.inputPos = cfg.inputPos hin refine_4 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = true⊢ cfg.inputPos = cfg.inputPos] All goals completed! 🐙
· refine_5 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = true⊢ digits (MultiTapeTM.step (configs cfg t)) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t.succ then false else digits cfg (if leaf = true then 1 else 0) j rw [step_carry_digits now leaf (p + t) hstate hp, refine_5 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = true⊢ (Function.update (digits now (if leaf = true then 1 else 0)) (p + t)
!digits now (if leaf = true then 1 else 0) (p + t)) =
fun j ↦ if p ≤ j ∧ j < p + t.succ then false else digits cfg (if leaf = true then 1 else 0) j hselected refine_5 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = true⊢ (Function.update (fun j ↦ if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) (p + t)
!(fun j ↦ if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) (p + t)) =
fun j ↦ if p ≤ j ∧ j < p + t.succ then false else digits cfg (if leaf = true then 1 else 0) j] refine_5 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = true⊢ (Function.update (fun j ↦ if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) (p + t)
!(fun j ↦ if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) (p + t)) =
fun j ↦ if p ≤ j ∧ j < p + t.succ then false else digits cfg (if leaf = true then 1 else 0) j
funext j refine_5 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = truej:ℕ⊢ Function.update (fun j ↦ if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) (p + t)
(!(fun j ↦ if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) (p + t)) j =
if p ≤ j ∧ j < p + t.succ then false else digits cfg (if leaf = true then 1 else 0) j
by_cases hj : j = p + t pos input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = truej:ℕhj:j = p + t⊢ Function.update (fun j ↦ if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) (p + t)
(!(fun j ↦ if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) (p + t)) j =
if p ≤ j ∧ j < p + t.succ then false else digits cfg (if leaf = true then 1 else 0) jneg input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = truej:ℕhj:¬j = p + t⊢ Function.update (fun j ↦ if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) (p + t)
(!(fun j ↦ if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) (p + t)) j =
if p ≤ j ∧ j < p + t.succ then false else digits cfg (if leaf = true then 1 else 0) j
· pos input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = truej:ℕhj:j = p + t⊢ Function.update (fun j ↦ if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) (p + t)
(!(fun j ↦ if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) (p + t)) j =
if p ≤ j ∧ j < p + t.succ then false else digits cfg (if leaf = true then 1 else 0) j subst j pos input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = true⊢ Function.update (fun j ↦ if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) (p + t)
(!(fun j ↦ if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) (p + t)) (p + t) =
if p ≤ p + t ∧ p + t < p + t.succ then false else digits cfg (if leaf = true then 1 else 0) (p + t)
simp [Function.update_self, hone] All goals completed! 🐙
· neg input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = truej:ℕhj:¬j = p + t⊢ Function.update (fun j ↦ if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) (p + t)
(!(fun j ↦ if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) (p + t)) j =
if p ≤ j ∧ j < p + t.succ then false else digits cfg (if leaf = true then 1 else 0) j rw [Function.update_of_ne hj neg input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = truej:ℕhj:¬j = p + t⊢ (if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) =
if p ≤ j ∧ j < p + t.succ then false else digits cfg (if leaf = true then 1 else 0) j] neg input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = truej:ℕhj:¬j = p + t⊢ (if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) =
if p ≤ j ∧ j < p + t.succ then false else digits cfg (if leaf = true then 1 else 0) j
have he : (p ≤ j ∧ j < p + t) ↔ (p ≤ j ∧ j < p + (t + 1)) := by input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet:ℕht:t ≤ k⊢ let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1) omega neg input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = truej:ℕhj:¬j = p + the:p ≤ j ∧ j < p + t ↔ p ≤ j ∧ j < p + (t + 1)⊢ (if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) =
if p ≤ j ∧ j < p + t.succ then false else digits cfg (if leaf = true then 1 else 0) j
simp only [he] All goals completed! 🐙
· refine_6 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = true⊢ digits (MultiTapeTM.step (configs cfg t)) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1) rw [step_carry_other_digits now leaf hstate, refine_6 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = true⊢ digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1) hother refine_6 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet✝:ℕt:ℕih:t ≤ k →
let now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(p + t) ∧
now.workTapePos 1 = ↑(p + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)ht:t.succ ≤ khstate:(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg t).workTapePos 0 = ↑(p + t)hpos1:(configs cfg t).workTapePos 1 = ↑(p + t)hin:(configs cfg t).inputPos = cfg.inputPoshselected:digits (configs cfg t) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + t then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg t) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg thp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + t)hone:digits cfg (if leaf = true then 1 else 0) (p + t) = truehd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = true⊢ digits cfg (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)] All goals completed! 🐙The first zero ends carry propagation after being changed to one.
theorem configs_carry_terminal {input : List (Fin 4)}
(cfg : Cfg 3 (Fin 4) (Fin 10) input) (leaf : Bool) (p k : ℕ)
(hq : cfg.state = some (if leaf then stCarryLeaf else stCarryFork))
(hp0 : cfg.workTapePos 0 = p) (hp1 : cfg.workTapePos 1 = p)
(hones : ∀ j < k, digits cfg (if leaf then 1 else 0) (p + j) = true)
(hzero : digits cfg (if leaf then 1 else 0) (p + k) = false) :
let now := machine.configs cfg (k + 1)
now.state = some stReturn ∧
now.workTapePos 0 = (p + (k + 1) : ℕ) ∧
now.workTapePos 1 = (p + (k + 1) : ℕ) ∧ now.inputPos = cfg.inputPos ∧
digits now (if leaf then 1 else 0) =
(fun j ↦ if j = p + k then true else
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf then 1 else 0) j) ∧
digits now (if leaf then 0 else 1) = digits cfg (if leaf then 0 else 1) := by input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = false⊢ let now := configs cfg (k + 1);
now.state = some stReturn ∧
now.workTapePos 0 = ↑(p + (k + 1)) ∧
now.workTapePos 1 = ↑(p + (k + 1)) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if j = p + k then true
else if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)
obtain ⟨hstate, hpos0, hpos1, hin, hselected, hother⟩ :=
configs_carry_prefix cfg leaf p k hq hp0 hp1 hones k (Nat.le_refl _) input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)⊢ let now := configs cfg (k + 1);
now.state = some stReturn ∧
now.workTapePos 0 = ↑(p + (k + 1)) ∧
now.workTapePos 1 = ↑(p + (k + 1)) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if j = p + k then true
else if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)
let now := machine.configs cfg k input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg k⊢ let now := configs cfg (k + 1);
now.state = some stReturn ∧
now.workTapePos 0 = ↑(p + (k + 1)) ∧
now.workTapePos 1 = ↑(p + (k + 1)) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if j = p + k then true
else if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)
have hp : now.workTapePos (if leaf then 1 else 0) = (p + k : ℕ) := by
cases leaf false input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputp:ℕk:ℕhp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPosnow:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khq:cfg.state = some (if false = true then stCarryLeaf else stCarryFork)hones:∀ j < k, digits cfg (if false = true then 1 else 0) (p + j) = truehzero:digits cfg (if false = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if false = true then stCarryLeaf else stCarryFork)hselected:digits (configs cfg k) (if false = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if false = true then 1 else 0) jhother:digits (configs cfg k) (if false = true then 0 else 1) = digits cfg (if false = true then 0 else 1)⊢ now.workTapePos (if false = true then 1 else 0) = ↑(p + k)true input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputp:ℕk:ℕhp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPosnow:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khq:cfg.state = some (if true = true then stCarryLeaf else stCarryFork)hones:∀ j < k, digits cfg (if true = true then 1 else 0) (p + j) = truehzero:digits cfg (if true = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if true = true then stCarryLeaf else stCarryFork)hselected:digits (configs cfg k) (if true = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if true = true then 1 else 0) jhother:digits (configs cfg k) (if true = true then 0 else 1) = digits cfg (if true = true then 0 else 1)⊢ now.workTapePos (if true = true then 1 else 0) = ↑(p + k)
· false input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputp:ℕk:ℕhp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPosnow:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khq:cfg.state = some (if false = true then stCarryLeaf else stCarryFork)hones:∀ j < k, digits cfg (if false = true then 1 else 0) (p + j) = truehzero:digits cfg (if false = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if false = true then stCarryLeaf else stCarryFork)hselected:digits (configs cfg k) (if false = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if false = true then 1 else 0) jhother:digits (configs cfg k) (if false = true then 0 else 1) = digits cfg (if false = true then 0 else 1)⊢ now.workTapePos (if false = true then 1 else 0) = ↑(p + k) exact hpos0 All goals completed! 🐙
· true input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputp:ℕk:ℕhp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPosnow:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khq:cfg.state = some (if true = true then stCarryLeaf else stCarryFork)hones:∀ j < k, digits cfg (if true = true then 1 else 0) (p + j) = truehzero:digits cfg (if true = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if true = true then stCarryLeaf else stCarryFork)hselected:digits (configs cfg k) (if true = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if true = true then 1 else 0) jhother:digits (configs cfg k) (if true = true then 0 else 1) = digits cfg (if true = true then 0 else 1)⊢ now.workTapePos (if true = true then 1 else 0) = ↑(p + k) exact hpos1 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)⊢ let now := configs cfg (k + 1);
now.state = some stReturn ∧
now.workTapePos 0 = ↑(p + (k + 1)) ∧
now.workTapePos 1 = ↑(p + (k + 1)) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if j = p + k then true
else if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)
have hd : digit (now.workTapeSymbols (if leaf then 1 else 0)) = false := by
change digit (now.workTapes (if leaf then 1 else 0)
(now.workTapePos (if leaf then 1 else 0))) = false input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)⊢ digit (now.workTapes (if leaf = true then 1 else 0) (now.workTapePos (if leaf = true then 1 else 0))) = false
rw [hp input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)⊢ digit (now.workTapes (if leaf = true then 1 else 0) ↑(p + k)) = false] input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)⊢ digit (now.workTapes (if leaf = true then 1 else 0) ↑(p + k)) = false
change digits now (if leaf then 1 else 0) (p + k) = false input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)⊢ digits now (if leaf = true then 1 else 0) (p + k) = false
rw [hselected input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)⊢ (fun j ↦ if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) j) (p + k) = false] input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)⊢ (fun j ↦ if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) j) (p + k) = false
simp only [Nat.lt_irrefl, and_false, ↓reduceIte] input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)⊢ digits cfg (if leaf = true then 1 else 0) (p + k) = false
exact hzero input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = false⊢ let now := configs cfg (k + 1);
now.state = some stReturn ∧
now.workTapePos 0 = ↑(p + (k + 1)) ∧
now.workTapePos 1 = ↑(p + (k + 1)) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if j = p + k then true
else if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)
rw [configs_succ_eq_step' input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = false⊢ let now := MultiTapeTM.step (configs cfg k);
now.state = some stReturn ∧
now.workTapePos 0 = ↑(p + (k + 1)) ∧
now.workTapePos 1 = ↑(p + (k + 1)) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if j = p + k then true
else if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)] input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = false⊢ let now := MultiTapeTM.step (configs cfg k);
now.state = some stReturn ∧
now.workTapePos 0 = ↑(p + (k + 1)) ∧
now.workTapePos 1 = ↑(p + (k + 1)) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if j = p + k then true
else if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)
refine ⟨?_, ?_, ?_, ?_, ?_, ?_⟩ refine_1 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = false⊢ (MultiTapeTM.step (configs cfg k)).state = some stReturnrefine_2 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = false⊢ (MultiTapeTM.step (configs cfg k)).workTapePos 0 = ↑(p + (k + 1))refine_3 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = false⊢ (MultiTapeTM.step (configs cfg k)).workTapePos 1 = ↑(p + (k + 1))refine_4 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = false⊢ (MultiTapeTM.step (configs cfg k)).inputPos = cfg.inputPosrefine_5 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = false⊢ digits (MultiTapeTM.step (configs cfg k)) (if leaf = true then 1 else 0) = fun j ↦
if j = p + k then true else if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jrefine_6 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = false⊢ digits (MultiTapeTM.step (configs cfg k)) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)
· refine_1 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = false⊢ (MultiTapeTM.step (configs cfg k)).state = some stReturn rw [step_carry_state now leaf hstate, refine_1 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = false⊢ some
(if digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = true then
if leaf = true then stCarryLeaf else stCarryFork
else stReturn) =
some stReturn hd refine_1 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = false⊢ some (if false = true then if leaf = true then stCarryLeaf else stCarryFork else stReturn) = some stReturn] refine_1 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = false⊢ some (if false = true then if leaf = true then stCarryLeaf else stCarryFork else stReturn) = some stReturn
rfl All goals completed! 🐙
· refine_2 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = false⊢ (MultiTapeTM.step (configs cfg k)).workTapePos 0 = ↑(p + (k + 1)) rw [step_carry_binaryPos now leaf 0 (by input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = false⊢ 0 ≠ 2 decide All goals completed! 🐙) hstate, hpos0 refine_2 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = false⊢ ↑(p + k) + 1 = ↑(p + (k + 1))] refine_2 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = false⊢ ↑(p + k) + 1 = ↑(p + (k + 1))
simp [Int.add_assoc] All goals completed! 🐙
· refine_3 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = false⊢ (MultiTapeTM.step (configs cfg k)).workTapePos 1 = ↑(p + (k + 1)) rw [step_carry_binaryPos now leaf 1 (by input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = false⊢ 1 ≠ 2 decide All goals completed! 🐙) hstate, hpos1 refine_3 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = false⊢ ↑(p + k) + 1 = ↑(p + (k + 1))] refine_3 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = false⊢ ↑(p + k) + 1 = ↑(p + (k + 1))
simp [Int.add_assoc] All goals completed! 🐙
· refine_4 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = false⊢ (MultiTapeTM.step (configs cfg k)).inputPos = cfg.inputPos rw [step_carry_inputPos now leaf hstate, refine_4 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = false⊢ now.inputPos = cfg.inputPos hin refine_4 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = false⊢ cfg.inputPos = cfg.inputPos] All goals completed! 🐙
· refine_5 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = false⊢ digits (MultiTapeTM.step (configs cfg k)) (if leaf = true then 1 else 0) = fun j ↦
if j = p + k then true else if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) j rw [step_carry_digits now leaf (p + k) hstate hp, refine_5 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = false⊢ (Function.update (digits now (if leaf = true then 1 else 0)) (p + k)
!digits now (if leaf = true then 1 else 0) (p + k)) =
fun j ↦ if j = p + k then true else if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) j hselected refine_5 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = false⊢ (Function.update (fun j ↦ if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) j) (p + k)
!(fun j ↦ if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) j) (p + k)) =
fun j ↦ if j = p + k then true else if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) j] refine_5 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = false⊢ (Function.update (fun j ↦ if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) j) (p + k)
!(fun j ↦ if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) j) (p + k)) =
fun j ↦ if j = p + k then true else if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) j
funext j refine_5 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = falsej:ℕ⊢ Function.update (fun j ↦ if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) j) (p + k)
(!(fun j ↦ if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) j) (p + k)) j =
if j = p + k then true else if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) j
by_cases hj : j = p + k pos input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = falsej:ℕhj:j = p + k⊢ Function.update (fun j ↦ if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) j) (p + k)
(!(fun j ↦ if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) j) (p + k)) j =
if j = p + k then true else if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jneg input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = falsej:ℕhj:¬j = p + k⊢ Function.update (fun j ↦ if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) j) (p + k)
(!(fun j ↦ if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) j) (p + k)) j =
if j = p + k then true else if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) j
· pos input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = falsej:ℕhj:j = p + k⊢ Function.update (fun j ↦ if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) j) (p + k)
(!(fun j ↦ if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) j) (p + k)) j =
if j = p + k then true else if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) j subst j pos input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = false⊢ Function.update (fun j ↦ if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) j) (p + k)
(!(fun j ↦ if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) j) (p + k)) (p + k) =
if p + k = p + k then true
else if p ≤ p + k ∧ p + k < p + k then false else digits cfg (if leaf = true then 1 else 0) (p + k)
simp [Function.update_self, hzero] All goals completed! 🐙
· neg input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = falsej:ℕhj:¬j = p + k⊢ Function.update (fun j ↦ if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) j) (p + k)
(!(fun j ↦ if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) j) (p + k)) j =
if j = p + k then true else if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) j simp only [Function.update_of_ne hj, hj, ↓reduceIte] All goals completed! 🐙
· refine_6 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = false⊢ digits (MultiTapeTM.step (configs cfg k)) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1) rw [step_carry_other_digits now leaf hstate, refine_6 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = false⊢ digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1) hother refine_6 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (p + k) = falsehstate:(configs cfg k).state = some (if leaf = true then stCarryLeaf else stCarryFork)hpos0:(configs cfg k).workTapePos 0 = ↑(p + k)hpos1:(configs cfg k).workTapePos 1 = ↑(p + k)hin:(configs cfg k).inputPos = cfg.inputPoshselected:digits (configs cfg k) (if leaf = true then 1 else 0) = fun j ↦
if p ≤ j ∧ j < p + k then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg k) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)now:Cfg 3 (Fin 4) (Fin 10) input := configs cfg khp:now.workTapePos (if leaf = true then 1 else 0) = ↑(p + k)hd:digit (now.workTapeSymbols (if leaf = true then 1 else 0)) = false⊢ digits cfg (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)] All goals completed! 🐙Carry propagation emits nothing, including the step that ends the carry.
theorem outputString_carry {input : List (Fin 4)}
(cfg : Cfg 3 (Fin 4) (Fin 10) input) (leaf : Bool) (p k : ℕ)
(hq : cfg.state = some (if leaf then stCarryLeaf else stCarryFork))
(hp0 : cfg.workTapePos 0 = p) (hp1 : cfg.workTapePos 1 = p)
(hones : ∀ j < k, digits cfg (if leaf then 1 else 0) (p + j) = true) :
machine.outputString cfg (k + 1) = [] := by input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = true⊢ machine.outputString cfg (k + 1) = []
apply List.flatMap_eq_nil_iff.mpr input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = true⊢ ∀ x ∈ List.range (k + 1), (outputSymbol (configs cfg x)).toList = []
intro t ht input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet:ℕht:t ∈ List.range (k + 1)⊢ (outputSymbol (configs cfg t)).toList = []
have hq' := (configs_carry_prefix cfg leaf p k hq hp0 hp1 hones t
(by input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet:ℕht:t ∈ List.range (k + 1)⊢ t ≤ k have h := List.mem_range.mp ht input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet:ℕht:t ∈ List.range (k + 1)h:t < k + 1⊢ t ≤ k; omega All goals completed! 🐙)).1 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet:ℕht:t ∈ List.range (k + 1)hq':(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)⊢ (outputSymbol (configs cfg t)).toList = []
rw [outputSymbol_carry _ leaf hq' input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet:ℕht:t ∈ List.range (k + 1)hq':(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)⊢ none.toList = []] input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolp:ℕk:ℕhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = ↑php1:cfg.workTapePos 1 = ↑phones:∀ j < k, digits cfg (if leaf = true then 1 else 0) (p + j) = truet:ℕht:t ∈ List.range (k + 1)hq':(configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork)⊢ none.toList = []
rfl All goals completed! 🐙Carry from the origin implements binary-list increment in exactly its bit-change count.
theorem configs_carry_bits {input : List (Fin 4)}
(cfg : Cfg 3 (Fin 4) (Fin 10) input) (leaf : Bool) (bs : List Bool)
(hq : cfg.state = some (if leaf then stCarryLeaf else stCarryFork))
(hp0 : cfg.workTapePos 0 = 0) (hp1 : cfg.workTapePos 1 = 0)
(hbits : ∀ j, digits cfg (if leaf then 1 else 0) j = bs[j]?.getD false) :
let now := machine.configs cfg (Counter.flips bs)
now.state = some stReturn ∧
now.workTapePos 0 = Counter.flips bs ∧ now.workTapePos 1 = Counter.flips bs ∧
now.inputPos = cfg.inputPos ∧
digits now (if leaf then 1 else 0) = (fun j ↦ (Counter.increment bs)[j]?.getD false) ∧
digits now (if leaf then 0 else 1) = digits cfg (if leaf then 0 else 1) ∧
machine.outputString cfg (Counter.flips bs) = [] := by input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD false⊢ let now := configs cfg (Counter.flips bs);
now.state = some stReturn ∧
now.workTapePos 0 = ↑(Counter.flips bs) ∧
now.workTapePos 1 = ↑(Counter.flips bs) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦ (Counter.increment bs)[j]?.getD false) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1) ∧
machine.outputString cfg (Counter.flips bs) = []
have hf := Counter.flips_pos bs input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bs⊢ let now := configs cfg (Counter.flips bs);
now.state = some stReturn ∧
now.workTapePos 0 = ↑(Counter.flips bs) ∧
now.workTapePos 1 = ↑(Counter.flips bs) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦ (Counter.increment bs)[j]?.getD false) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1) ∧
machine.outputString cfg (Counter.flips bs) = []
have he : Counter.flips bs - 1 + 1 = Counter.flips bs := by omega input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bs⊢ let now := configs cfg (Counter.flips bs);
now.state = some stReturn ∧
now.workTapePos 0 = ↑(Counter.flips bs) ∧
now.workTapePos 1 = ↑(Counter.flips bs) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦ (Counter.increment bs)[j]?.getD false) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1) ∧
machine.outputString cfg (Counter.flips bs) = []
have hones : ∀ j < Counter.flips bs - 1,
digits cfg (if leaf then 1 else 0) (0 + j) = true := by
intro j hj input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bsj:ℕhj:j < Counter.flips bs - 1⊢ digits cfg (if leaf = true then 1 else 0) (0 + j) = true
rw [Nat.zero_add, input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bsj:ℕhj:j < Counter.flips bs - 1⊢ digits cfg (if leaf = true then 1 else 0) j = true hbits input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bsj:ℕhj:j < Counter.flips bs - 1⊢ bs[j]?.getD false = true] input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bsj:ℕhj:j < Counter.flips bs - 1⊢ bs[j]?.getD false = true
exact Counter.getD_eq_true_of_lt_flips bs j (by input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bsj:ℕhj:j < Counter.flips bs - 1⊢ j + 1 < Counter.flips bs omega All goals completed! 🐙) input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = true⊢ let now := configs cfg (Counter.flips bs);
now.state = some stReturn ∧
now.workTapePos 0 = ↑(Counter.flips bs) ∧
now.workTapePos 1 = ↑(Counter.flips bs) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦ (Counter.increment bs)[j]?.getD false) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1) ∧
machine.outputString cfg (Counter.flips bs) = []
have hzero : digits cfg (if leaf then 1 else 0) (0 + (Counter.flips bs - 1)) = false := by
rw [Nat.zero_add, input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = true⊢ digits cfg (if leaf = true then 1 else 0) (Counter.flips bs - 1) = false hbits input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = true⊢ bs[Counter.flips bs - 1]?.getD false = false] input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = true⊢ bs[Counter.flips bs - 1]?.getD false = false
exact Counter.getD_last_flip bs input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (0 + (Counter.flips bs - 1)) = false⊢ let now := configs cfg (Counter.flips bs);
now.state = some stReturn ∧
now.workTapePos 0 = ↑(Counter.flips bs) ∧
now.workTapePos 1 = ↑(Counter.flips bs) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦ (Counter.increment bs)[j]?.getD false) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1) ∧
machine.outputString cfg (Counter.flips bs) = []
have hterm := configs_carry_terminal cfg leaf 0 (Counter.flips bs - 1)
hq hp0 hp1 hones hzero input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (0 + (Counter.flips bs - 1)) = falsehterm:have now := configs cfg (Counter.flips bs - 1 + 1);
now.state = some stReturn ∧
now.workTapePos 0 = ↑(0 + (Counter.flips bs - 1 + 1)) ∧
now.workTapePos 1 = ↑(0 + (Counter.flips bs - 1 + 1)) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if j = 0 + (Counter.flips bs - 1) then true
else
if 0 ≤ j ∧ j < 0 + (Counter.flips bs - 1) then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)⊢ let now := configs cfg (Counter.flips bs);
now.state = some stReturn ∧
now.workTapePos 0 = ↑(Counter.flips bs) ∧
now.workTapePos 1 = ↑(Counter.flips bs) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦ (Counter.increment bs)[j]?.getD false) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1) ∧
machine.outputString cfg (Counter.flips bs) = []
simp only [he, Nat.zero_add, Nat.zero_le, true_and] at hterm input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (0 + (Counter.flips bs - 1)) = falsehterm:(configs cfg (Counter.flips bs)).state = some stReturn ∧
(configs cfg (Counter.flips bs)).workTapePos 0 = ↑(Counter.flips bs) ∧
(configs cfg (Counter.flips bs)).workTapePos 1 = ↑(Counter.flips bs) ∧
(configs cfg (Counter.flips bs)).inputPos = cfg.inputPos ∧
(digits (configs cfg (Counter.flips bs)) (if leaf = true then 1 else 0) = fun j ↦
if j = Counter.flips bs - 1 then true
else if j < Counter.flips bs - 1 then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits (configs cfg (Counter.flips bs)) (if leaf = true then 0 else 1) =
digits cfg (if leaf = true then 0 else 1)⊢ let now := configs cfg (Counter.flips bs);
now.state = some stReturn ∧
now.workTapePos 0 = ↑(Counter.flips bs) ∧
now.workTapePos 1 = ↑(Counter.flips bs) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦ (Counter.increment bs)[j]?.getD false) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1) ∧
machine.outputString cfg (Counter.flips bs) = []
obtain ⟨hstate, hpos0, hpos1, hin, hselected, hother⟩ := hterm input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (0 + (Counter.flips bs - 1)) = falsehstate:(configs cfg (Counter.flips bs)).state = some stReturnhpos0:(configs cfg (Counter.flips bs)).workTapePos 0 = ↑(Counter.flips bs)hpos1:(configs cfg (Counter.flips bs)).workTapePos 1 = ↑(Counter.flips bs)hin:(configs cfg (Counter.flips bs)).inputPos = cfg.inputPoshselected:digits (configs cfg (Counter.flips bs)) (if leaf = true then 1 else 0) = fun j ↦
if j = Counter.flips bs - 1 then true
else if j < Counter.flips bs - 1 then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg (Counter.flips bs)) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)⊢ let now := configs cfg (Counter.flips bs);
now.state = some stReturn ∧
now.workTapePos 0 = ↑(Counter.flips bs) ∧
now.workTapePos 1 = ↑(Counter.flips bs) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦ (Counter.increment bs)[j]?.getD false) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1) ∧
machine.outputString cfg (Counter.flips bs) = []
refine ⟨hstate, hpos0, hpos1, hin, ?_, hother, ?_⟩ refine_1 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (0 + (Counter.flips bs - 1)) = falsehstate:(configs cfg (Counter.flips bs)).state = some stReturnhpos0:(configs cfg (Counter.flips bs)).workTapePos 0 = ↑(Counter.flips bs)hpos1:(configs cfg (Counter.flips bs)).workTapePos 1 = ↑(Counter.flips bs)hin:(configs cfg (Counter.flips bs)).inputPos = cfg.inputPoshselected:digits (configs cfg (Counter.flips bs)) (if leaf = true then 1 else 0) = fun j ↦
if j = Counter.flips bs - 1 then true
else if j < Counter.flips bs - 1 then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg (Counter.flips bs)) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)⊢ digits (configs cfg (Counter.flips bs)) (if leaf = true then 1 else 0) = fun j ↦ (Counter.increment bs)[j]?.getD falserefine_2 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (0 + (Counter.flips bs - 1)) = falsehstate:(configs cfg (Counter.flips bs)).state = some stReturnhpos0:(configs cfg (Counter.flips bs)).workTapePos 0 = ↑(Counter.flips bs)hpos1:(configs cfg (Counter.flips bs)).workTapePos 1 = ↑(Counter.flips bs)hin:(configs cfg (Counter.flips bs)).inputPos = cfg.inputPoshselected:digits (configs cfg (Counter.flips bs)) (if leaf = true then 1 else 0) = fun j ↦
if j = Counter.flips bs - 1 then true
else if j < Counter.flips bs - 1 then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg (Counter.flips bs)) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)⊢ machine.outputString cfg (Counter.flips bs) = []
· refine_1 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (0 + (Counter.flips bs - 1)) = falsehstate:(configs cfg (Counter.flips bs)).state = some stReturnhpos0:(configs cfg (Counter.flips bs)).workTapePos 0 = ↑(Counter.flips bs)hpos1:(configs cfg (Counter.flips bs)).workTapePos 1 = ↑(Counter.flips bs)hin:(configs cfg (Counter.flips bs)).inputPos = cfg.inputPoshselected:digits (configs cfg (Counter.flips bs)) (if leaf = true then 1 else 0) = fun j ↦
if j = Counter.flips bs - 1 then true
else if j < Counter.flips bs - 1 then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg (Counter.flips bs)) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)⊢ digits (configs cfg (Counter.flips bs)) (if leaf = true then 1 else 0) = fun j ↦ (Counter.increment bs)[j]?.getD false funext j refine_1 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (0 + (Counter.flips bs - 1)) = falsehstate:(configs cfg (Counter.flips bs)).state = some stReturnhpos0:(configs cfg (Counter.flips bs)).workTapePos 0 = ↑(Counter.flips bs)hpos1:(configs cfg (Counter.flips bs)).workTapePos 1 = ↑(Counter.flips bs)hin:(configs cfg (Counter.flips bs)).inputPos = cfg.inputPoshselected:digits (configs cfg (Counter.flips bs)) (if leaf = true then 1 else 0) = fun j ↦
if j = Counter.flips bs - 1 then true
else if j < Counter.flips bs - 1 then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg (Counter.flips bs)) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)j:ℕ⊢ digits (configs cfg (Counter.flips bs)) (if leaf = true then 1 else 0) j = (Counter.increment bs)[j]?.getD false
rw [hselected, refine_1 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (0 + (Counter.flips bs - 1)) = falsehstate:(configs cfg (Counter.flips bs)).state = some stReturnhpos0:(configs cfg (Counter.flips bs)).workTapePos 0 = ↑(Counter.flips bs)hpos1:(configs cfg (Counter.flips bs)).workTapePos 1 = ↑(Counter.flips bs)hin:(configs cfg (Counter.flips bs)).inputPos = cfg.inputPoshselected:digits (configs cfg (Counter.flips bs)) (if leaf = true then 1 else 0) = fun j ↦
if j = Counter.flips bs - 1 then true
else if j < Counter.flips bs - 1 then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg (Counter.flips bs)) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)j:ℕ⊢ (fun j ↦
if j = Counter.flips bs - 1 then true
else if j < Counter.flips bs - 1 then false else digits cfg (if leaf = true then 1 else 0) j)
j =
(Counter.increment bs)[j]?.getD false Counter.getD_increment refine_1 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (0 + (Counter.flips bs - 1)) = falsehstate:(configs cfg (Counter.flips bs)).state = some stReturnhpos0:(configs cfg (Counter.flips bs)).workTapePos 0 = ↑(Counter.flips bs)hpos1:(configs cfg (Counter.flips bs)).workTapePos 1 = ↑(Counter.flips bs)hin:(configs cfg (Counter.flips bs)).inputPos = cfg.inputPoshselected:digits (configs cfg (Counter.flips bs)) (if leaf = true then 1 else 0) = fun j ↦
if j = Counter.flips bs - 1 then true
else if j < Counter.flips bs - 1 then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg (Counter.flips bs)) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)j:ℕ⊢ (fun j ↦
if j = Counter.flips bs - 1 then true
else if j < Counter.flips bs - 1 then false else digits cfg (if leaf = true then 1 else 0) j)
j =
if j + 1 < Counter.flips bs then false else if j + 1 = Counter.flips bs then true else bs[j]?.getD false] refine_1 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (0 + (Counter.flips bs - 1)) = falsehstate:(configs cfg (Counter.flips bs)).state = some stReturnhpos0:(configs cfg (Counter.flips bs)).workTapePos 0 = ↑(Counter.flips bs)hpos1:(configs cfg (Counter.flips bs)).workTapePos 1 = ↑(Counter.flips bs)hin:(configs cfg (Counter.flips bs)).inputPos = cfg.inputPoshselected:digits (configs cfg (Counter.flips bs)) (if leaf = true then 1 else 0) = fun j ↦
if j = Counter.flips bs - 1 then true
else if j < Counter.flips bs - 1 then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg (Counter.flips bs)) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)j:ℕ⊢ (fun j ↦
if j = Counter.flips bs - 1 then true
else if j < Counter.flips bs - 1 then false else digits cfg (if leaf = true then 1 else 0) j)
j =
if j + 1 < Counter.flips bs then false else if j + 1 = Counter.flips bs then true else bs[j]?.getD false
dsimp only refine_1 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (0 + (Counter.flips bs - 1)) = falsehstate:(configs cfg (Counter.flips bs)).state = some stReturnhpos0:(configs cfg (Counter.flips bs)).workTapePos 0 = ↑(Counter.flips bs)hpos1:(configs cfg (Counter.flips bs)).workTapePos 1 = ↑(Counter.flips bs)hin:(configs cfg (Counter.flips bs)).inputPos = cfg.inputPoshselected:digits (configs cfg (Counter.flips bs)) (if leaf = true then 1 else 0) = fun j ↦
if j = Counter.flips bs - 1 then true
else if j < Counter.flips bs - 1 then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg (Counter.flips bs)) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)j:ℕ⊢ (if j = Counter.flips bs - 1 then true
else if j < Counter.flips bs - 1 then false else digits cfg (if leaf = true then 1 else 0) j) =
if j + 1 < Counter.flips bs then false else if j + 1 = Counter.flips bs then true else bs[j]?.getD false
rw [hbits refine_1 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (0 + (Counter.flips bs - 1)) = falsehstate:(configs cfg (Counter.flips bs)).state = some stReturnhpos0:(configs cfg (Counter.flips bs)).workTapePos 0 = ↑(Counter.flips bs)hpos1:(configs cfg (Counter.flips bs)).workTapePos 1 = ↑(Counter.flips bs)hin:(configs cfg (Counter.flips bs)).inputPos = cfg.inputPoshselected:digits (configs cfg (Counter.flips bs)) (if leaf = true then 1 else 0) = fun j ↦
if j = Counter.flips bs - 1 then true
else if j < Counter.flips bs - 1 then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg (Counter.flips bs)) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)j:ℕ⊢ (if j = Counter.flips bs - 1 then true else if j < Counter.flips bs - 1 then false else bs[j]?.getD false) =
if j + 1 < Counter.flips bs then false else if j + 1 = Counter.flips bs then true else bs[j]?.getD false] refine_1 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (0 + (Counter.flips bs - 1)) = falsehstate:(configs cfg (Counter.flips bs)).state = some stReturnhpos0:(configs cfg (Counter.flips bs)).workTapePos 0 = ↑(Counter.flips bs)hpos1:(configs cfg (Counter.flips bs)).workTapePos 1 = ↑(Counter.flips bs)hin:(configs cfg (Counter.flips bs)).inputPos = cfg.inputPoshselected:digits (configs cfg (Counter.flips bs)) (if leaf = true then 1 else 0) = fun j ↦
if j = Counter.flips bs - 1 then true
else if j < Counter.flips bs - 1 then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg (Counter.flips bs)) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)j:ℕ⊢ (if j = Counter.flips bs - 1 then true else if j < Counter.flips bs - 1 then false else bs[j]?.getD false) =
if j + 1 < Counter.flips bs then false else if j + 1 = Counter.flips bs then true else bs[j]?.getD false
split_ifs pos input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (0 + (Counter.flips bs - 1)) = falsehstate:(configs cfg (Counter.flips bs)).state = some stReturnhpos0:(configs cfg (Counter.flips bs)).workTapePos 0 = ↑(Counter.flips bs)hpos1:(configs cfg (Counter.flips bs)).workTapePos 1 = ↑(Counter.flips bs)hin:(configs cfg (Counter.flips bs)).inputPos = cfg.inputPoshselected:digits (configs cfg (Counter.flips bs)) (if leaf = true then 1 else 0) = fun j ↦
if j = Counter.flips bs - 1 then true
else if j < Counter.flips bs - 1 then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg (Counter.flips bs)) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)j:ℕh✝¹:j = Counter.flips bs - 1h✝:j + 1 < Counter.flips bs⊢ Falsepos input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (0 + (Counter.flips bs - 1)) = falsehstate:(configs cfg (Counter.flips bs)).state = some stReturnhpos0:(configs cfg (Counter.flips bs)).workTapePos 0 = ↑(Counter.flips bs)hpos1:(configs cfg (Counter.flips bs)).workTapePos 1 = ↑(Counter.flips bs)hin:(configs cfg (Counter.flips bs)).inputPos = cfg.inputPoshselected:digits (configs cfg (Counter.flips bs)) (if leaf = true then 1 else 0) = fun j ↦
if j = Counter.flips bs - 1 then true
else if j < Counter.flips bs - 1 then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg (Counter.flips bs)) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)j:ℕh✝²:j = Counter.flips bs - 1h✝¹:¬j + 1 < Counter.flips bsh✝:j + 1 = Counter.flips bs⊢ true = trueneg input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (0 + (Counter.flips bs - 1)) = falsehstate:(configs cfg (Counter.flips bs)).state = some stReturnhpos0:(configs cfg (Counter.flips bs)).workTapePos 0 = ↑(Counter.flips bs)hpos1:(configs cfg (Counter.flips bs)).workTapePos 1 = ↑(Counter.flips bs)hin:(configs cfg (Counter.flips bs)).inputPos = cfg.inputPoshselected:digits (configs cfg (Counter.flips bs)) (if leaf = true then 1 else 0) = fun j ↦
if j = Counter.flips bs - 1 then true
else if j < Counter.flips bs - 1 then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg (Counter.flips bs)) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)j:ℕh✝²:j = Counter.flips bs - 1h✝¹:¬j + 1 < Counter.flips bsh✝:¬j + 1 = Counter.flips bs⊢ true = bs[j]?.getD falsepos input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (0 + (Counter.flips bs - 1)) = falsehstate:(configs cfg (Counter.flips bs)).state = some stReturnhpos0:(configs cfg (Counter.flips bs)).workTapePos 0 = ↑(Counter.flips bs)hpos1:(configs cfg (Counter.flips bs)).workTapePos 1 = ↑(Counter.flips bs)hin:(configs cfg (Counter.flips bs)).inputPos = cfg.inputPoshselected:digits (configs cfg (Counter.flips bs)) (if leaf = true then 1 else 0) = fun j ↦
if j = Counter.flips bs - 1 then true
else if j < Counter.flips bs - 1 then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg (Counter.flips bs)) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)j:ℕh✝²:¬j = Counter.flips bs - 1h✝¹:j < Counter.flips bs - 1h✝:j + 1 < Counter.flips bs⊢ false = falsepos input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (0 + (Counter.flips bs - 1)) = falsehstate:(configs cfg (Counter.flips bs)).state = some stReturnhpos0:(configs cfg (Counter.flips bs)).workTapePos 0 = ↑(Counter.flips bs)hpos1:(configs cfg (Counter.flips bs)).workTapePos 1 = ↑(Counter.flips bs)hin:(configs cfg (Counter.flips bs)).inputPos = cfg.inputPoshselected:digits (configs cfg (Counter.flips bs)) (if leaf = true then 1 else 0) = fun j ↦
if j = Counter.flips bs - 1 then true
else if j < Counter.flips bs - 1 then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg (Counter.flips bs)) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)j:ℕh✝³:¬j = Counter.flips bs - 1h✝²:j < Counter.flips bs - 1h✝¹:¬j + 1 < Counter.flips bsh✝:j + 1 = Counter.flips bs⊢ Falseneg input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (0 + (Counter.flips bs - 1)) = falsehstate:(configs cfg (Counter.flips bs)).state = some stReturnhpos0:(configs cfg (Counter.flips bs)).workTapePos 0 = ↑(Counter.flips bs)hpos1:(configs cfg (Counter.flips bs)).workTapePos 1 = ↑(Counter.flips bs)hin:(configs cfg (Counter.flips bs)).inputPos = cfg.inputPoshselected:digits (configs cfg (Counter.flips bs)) (if leaf = true then 1 else 0) = fun j ↦
if j = Counter.flips bs - 1 then true
else if j < Counter.flips bs - 1 then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg (Counter.flips bs)) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)j:ℕh✝³:¬j = Counter.flips bs - 1h✝²:j < Counter.flips bs - 1h✝¹:¬j + 1 < Counter.flips bsh✝:¬j + 1 = Counter.flips bs⊢ false = bs[j]?.getD falsepos input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (0 + (Counter.flips bs - 1)) = falsehstate:(configs cfg (Counter.flips bs)).state = some stReturnhpos0:(configs cfg (Counter.flips bs)).workTapePos 0 = ↑(Counter.flips bs)hpos1:(configs cfg (Counter.flips bs)).workTapePos 1 = ↑(Counter.flips bs)hin:(configs cfg (Counter.flips bs)).inputPos = cfg.inputPoshselected:digits (configs cfg (Counter.flips bs)) (if leaf = true then 1 else 0) = fun j ↦
if j = Counter.flips bs - 1 then true
else if j < Counter.flips bs - 1 then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg (Counter.flips bs)) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)j:ℕh✝²:¬j = Counter.flips bs - 1h✝¹:¬j < Counter.flips bs - 1h✝:j + 1 < Counter.flips bs⊢ bs[j]?.getD false = falsepos input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (0 + (Counter.flips bs - 1)) = falsehstate:(configs cfg (Counter.flips bs)).state = some stReturnhpos0:(configs cfg (Counter.flips bs)).workTapePos 0 = ↑(Counter.flips bs)hpos1:(configs cfg (Counter.flips bs)).workTapePos 1 = ↑(Counter.flips bs)hin:(configs cfg (Counter.flips bs)).inputPos = cfg.inputPoshselected:digits (configs cfg (Counter.flips bs)) (if leaf = true then 1 else 0) = fun j ↦
if j = Counter.flips bs - 1 then true
else if j < Counter.flips bs - 1 then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg (Counter.flips bs)) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)j:ℕh✝³:¬j = Counter.flips bs - 1h✝²:¬j < Counter.flips bs - 1h✝¹:¬j + 1 < Counter.flips bsh✝:j + 1 = Counter.flips bs⊢ bs[j]?.getD false = trueneg input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (0 + (Counter.flips bs - 1)) = falsehstate:(configs cfg (Counter.flips bs)).state = some stReturnhpos0:(configs cfg (Counter.flips bs)).workTapePos 0 = ↑(Counter.flips bs)hpos1:(configs cfg (Counter.flips bs)).workTapePos 1 = ↑(Counter.flips bs)hin:(configs cfg (Counter.flips bs)).inputPos = cfg.inputPoshselected:digits (configs cfg (Counter.flips bs)) (if leaf = true then 1 else 0) = fun j ↦
if j = Counter.flips bs - 1 then true
else if j < Counter.flips bs - 1 then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg (Counter.flips bs)) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)j:ℕh✝³:¬j = Counter.flips bs - 1h✝²:¬j < Counter.flips bs - 1h✝¹:¬j + 1 < Counter.flips bsh✝:¬j + 1 = Counter.flips bs⊢ bs[j]?.getD false = bs[j]?.getD false <;> pos input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (0 + (Counter.flips bs - 1)) = falsehstate:(configs cfg (Counter.flips bs)).state = some stReturnhpos0:(configs cfg (Counter.flips bs)).workTapePos 0 = ↑(Counter.flips bs)hpos1:(configs cfg (Counter.flips bs)).workTapePos 1 = ↑(Counter.flips bs)hin:(configs cfg (Counter.flips bs)).inputPos = cfg.inputPoshselected:digits (configs cfg (Counter.flips bs)) (if leaf = true then 1 else 0) = fun j ↦
if j = Counter.flips bs - 1 then true
else if j < Counter.flips bs - 1 then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg (Counter.flips bs)) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)j:ℕh✝¹:j = Counter.flips bs - 1h✝:j + 1 < Counter.flips bs⊢ Falsepos input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (0 + (Counter.flips bs - 1)) = falsehstate:(configs cfg (Counter.flips bs)).state = some stReturnhpos0:(configs cfg (Counter.flips bs)).workTapePos 0 = ↑(Counter.flips bs)hpos1:(configs cfg (Counter.flips bs)).workTapePos 1 = ↑(Counter.flips bs)hin:(configs cfg (Counter.flips bs)).inputPos = cfg.inputPoshselected:digits (configs cfg (Counter.flips bs)) (if leaf = true then 1 else 0) = fun j ↦
if j = Counter.flips bs - 1 then true
else if j < Counter.flips bs - 1 then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg (Counter.flips bs)) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)j:ℕh✝²:j = Counter.flips bs - 1h✝¹:¬j + 1 < Counter.flips bsh✝:j + 1 = Counter.flips bs⊢ true = trueneg input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (0 + (Counter.flips bs - 1)) = falsehstate:(configs cfg (Counter.flips bs)).state = some stReturnhpos0:(configs cfg (Counter.flips bs)).workTapePos 0 = ↑(Counter.flips bs)hpos1:(configs cfg (Counter.flips bs)).workTapePos 1 = ↑(Counter.flips bs)hin:(configs cfg (Counter.flips bs)).inputPos = cfg.inputPoshselected:digits (configs cfg (Counter.flips bs)) (if leaf = true then 1 else 0) = fun j ↦
if j = Counter.flips bs - 1 then true
else if j < Counter.flips bs - 1 then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg (Counter.flips bs)) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)j:ℕh✝²:j = Counter.flips bs - 1h✝¹:¬j + 1 < Counter.flips bsh✝:¬j + 1 = Counter.flips bs⊢ true = bs[j]?.getD falsepos input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (0 + (Counter.flips bs - 1)) = falsehstate:(configs cfg (Counter.flips bs)).state = some stReturnhpos0:(configs cfg (Counter.flips bs)).workTapePos 0 = ↑(Counter.flips bs)hpos1:(configs cfg (Counter.flips bs)).workTapePos 1 = ↑(Counter.flips bs)hin:(configs cfg (Counter.flips bs)).inputPos = cfg.inputPoshselected:digits (configs cfg (Counter.flips bs)) (if leaf = true then 1 else 0) = fun j ↦
if j = Counter.flips bs - 1 then true
else if j < Counter.flips bs - 1 then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg (Counter.flips bs)) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)j:ℕh✝²:¬j = Counter.flips bs - 1h✝¹:j < Counter.flips bs - 1h✝:j + 1 < Counter.flips bs⊢ false = falsepos input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (0 + (Counter.flips bs - 1)) = falsehstate:(configs cfg (Counter.flips bs)).state = some stReturnhpos0:(configs cfg (Counter.flips bs)).workTapePos 0 = ↑(Counter.flips bs)hpos1:(configs cfg (Counter.flips bs)).workTapePos 1 = ↑(Counter.flips bs)hin:(configs cfg (Counter.flips bs)).inputPos = cfg.inputPoshselected:digits (configs cfg (Counter.flips bs)) (if leaf = true then 1 else 0) = fun j ↦
if j = Counter.flips bs - 1 then true
else if j < Counter.flips bs - 1 then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg (Counter.flips bs)) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)j:ℕh✝³:¬j = Counter.flips bs - 1h✝²:j < Counter.flips bs - 1h✝¹:¬j + 1 < Counter.flips bsh✝:j + 1 = Counter.flips bs⊢ Falseneg input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (0 + (Counter.flips bs - 1)) = falsehstate:(configs cfg (Counter.flips bs)).state = some stReturnhpos0:(configs cfg (Counter.flips bs)).workTapePos 0 = ↑(Counter.flips bs)hpos1:(configs cfg (Counter.flips bs)).workTapePos 1 = ↑(Counter.flips bs)hin:(configs cfg (Counter.flips bs)).inputPos = cfg.inputPoshselected:digits (configs cfg (Counter.flips bs)) (if leaf = true then 1 else 0) = fun j ↦
if j = Counter.flips bs - 1 then true
else if j < Counter.flips bs - 1 then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg (Counter.flips bs)) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)j:ℕh✝³:¬j = Counter.flips bs - 1h✝²:j < Counter.flips bs - 1h✝¹:¬j + 1 < Counter.flips bsh✝:¬j + 1 = Counter.flips bs⊢ false = bs[j]?.getD falsepos input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (0 + (Counter.flips bs - 1)) = falsehstate:(configs cfg (Counter.flips bs)).state = some stReturnhpos0:(configs cfg (Counter.flips bs)).workTapePos 0 = ↑(Counter.flips bs)hpos1:(configs cfg (Counter.flips bs)).workTapePos 1 = ↑(Counter.flips bs)hin:(configs cfg (Counter.flips bs)).inputPos = cfg.inputPoshselected:digits (configs cfg (Counter.flips bs)) (if leaf = true then 1 else 0) = fun j ↦
if j = Counter.flips bs - 1 then true
else if j < Counter.flips bs - 1 then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg (Counter.flips bs)) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)j:ℕh✝²:¬j = Counter.flips bs - 1h✝¹:¬j < Counter.flips bs - 1h✝:j + 1 < Counter.flips bs⊢ bs[j]?.getD false = falsepos input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (0 + (Counter.flips bs - 1)) = falsehstate:(configs cfg (Counter.flips bs)).state = some stReturnhpos0:(configs cfg (Counter.flips bs)).workTapePos 0 = ↑(Counter.flips bs)hpos1:(configs cfg (Counter.flips bs)).workTapePos 1 = ↑(Counter.flips bs)hin:(configs cfg (Counter.flips bs)).inputPos = cfg.inputPoshselected:digits (configs cfg (Counter.flips bs)) (if leaf = true then 1 else 0) = fun j ↦
if j = Counter.flips bs - 1 then true
else if j < Counter.flips bs - 1 then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg (Counter.flips bs)) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)j:ℕh✝³:¬j = Counter.flips bs - 1h✝²:¬j < Counter.flips bs - 1h✝¹:¬j + 1 < Counter.flips bsh✝:j + 1 = Counter.flips bs⊢ bs[j]?.getD false = trueneg input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (0 + (Counter.flips bs - 1)) = falsehstate:(configs cfg (Counter.flips bs)).state = some stReturnhpos0:(configs cfg (Counter.flips bs)).workTapePos 0 = ↑(Counter.flips bs)hpos1:(configs cfg (Counter.flips bs)).workTapePos 1 = ↑(Counter.flips bs)hin:(configs cfg (Counter.flips bs)).inputPos = cfg.inputPoshselected:digits (configs cfg (Counter.flips bs)) (if leaf = true then 1 else 0) = fun j ↦
if j = Counter.flips bs - 1 then true
else if j < Counter.flips bs - 1 then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg (Counter.flips bs)) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)j:ℕh✝³:¬j = Counter.flips bs - 1h✝²:¬j < Counter.flips bs - 1h✝¹:¬j + 1 < Counter.flips bsh✝:¬j + 1 = Counter.flips bs⊢ bs[j]?.getD false = bs[j]?.getD false first | rfl All goals completed! 🐙 | omega All goals completed! 🐙
· refine_2 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (0 + (Counter.flips bs - 1)) = falsehstate:(configs cfg (Counter.flips bs)).state = some stReturnhpos0:(configs cfg (Counter.flips bs)).workTapePos 0 = ↑(Counter.flips bs)hpos1:(configs cfg (Counter.flips bs)).workTapePos 1 = ↑(Counter.flips bs)hin:(configs cfg (Counter.flips bs)).inputPos = cfg.inputPoshselected:digits (configs cfg (Counter.flips bs)) (if leaf = true then 1 else 0) = fun j ↦
if j = Counter.flips bs - 1 then true
else if j < Counter.flips bs - 1 then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg (Counter.flips bs)) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)⊢ machine.outputString cfg (Counter.flips bs) = [] have hout := outputString_carry cfg leaf 0 (Counter.flips bs - 1) hq hp0 hp1 hones refine_2 input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falsehf:0 < Counter.flips bshe:Counter.flips bs - 1 + 1 = Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = truehzero:digits cfg (if leaf = true then 1 else 0) (0 + (Counter.flips bs - 1)) = falsehstate:(configs cfg (Counter.flips bs)).state = some stReturnhpos0:(configs cfg (Counter.flips bs)).workTapePos 0 = ↑(Counter.flips bs)hpos1:(configs cfg (Counter.flips bs)).workTapePos 1 = ↑(Counter.flips bs)hin:(configs cfg (Counter.flips bs)).inputPos = cfg.inputPoshselected:digits (configs cfg (Counter.flips bs)) (if leaf = true then 1 else 0) = fun j ↦
if j = Counter.flips bs - 1 then true
else if j < Counter.flips bs - 1 then false else digits cfg (if leaf = true then 1 else 0) jhother:digits (configs cfg (Counter.flips bs)) (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)hout:machine.outputString cfg (Counter.flips bs - 1 + 1) = []⊢ machine.outputString cfg (Counter.flips bs) = []
simpa only [he] using hout All goals completed! 🐙Every configuration before the final carry step remains in the carry state.
theorem configs_carry_bits_state {input : List (Fin 4)}
(cfg : Cfg 3 (Fin 4) (Fin 10) input) (leaf : Bool) (bs : List Bool)
(hq : cfg.state = some (if leaf then stCarryLeaf else stCarryFork))
(hp0 : cfg.workTapePos 0 = 0) (hp1 : cfg.workTapePos 1 = 0)
(hbits : ∀ j, digits cfg (if leaf then 1 else 0) j = bs[j]?.getD false)
(t : ℕ) (ht : t < Counter.flips bs) :
(machine.configs cfg t).state = some (if leaf then stCarryLeaf else stCarryFork) ∧
(machine.configs cfg t).workTapePos 0 = t ∧
(machine.configs cfg t).workTapePos 1 = t := by input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falset:ℕht:t < Counter.flips bs⊢ (configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
(configs cfg t).workTapePos 0 = ↑t ∧ (configs cfg t).workTapePos 1 = ↑t
have hones : ∀ j < Counter.flips bs - 1,
digits cfg (if leaf then 1 else 0) (0 + j) = true := by
intro j hj input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falset:ℕht:t < Counter.flips bsj:ℕhj:j < Counter.flips bs - 1⊢ digits cfg (if leaf = true then 1 else 0) (0 + j) = true
rw [Nat.zero_add, input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falset:ℕht:t < Counter.flips bsj:ℕhj:j < Counter.flips bs - 1⊢ digits cfg (if leaf = true then 1 else 0) j = true hbits input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falset:ℕht:t < Counter.flips bsj:ℕhj:j < Counter.flips bs - 1⊢ bs[j]?.getD false = true] input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falset:ℕht:t < Counter.flips bsj:ℕhj:j < Counter.flips bs - 1⊢ bs[j]?.getD false = true
exact Counter.getD_eq_true_of_lt_flips bs j (by input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falset:ℕht:t < Counter.flips bsj:ℕhj:j < Counter.flips bs - 1⊢ j + 1 < Counter.flips bs omega All goals completed! 🐙) input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falset:ℕht:t < Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = true⊢ (configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
(configs cfg t).workTapePos 0 = ↑t ∧ (configs cfg t).workTapePos 1 = ↑t
have h := configs_carry_prefix cfg leaf 0 (Counter.flips bs - 1) hq hp0 hp1 hones t
(by input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falset:ℕht:t < Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = true⊢ t ≤ Counter.flips bs - 1 omega All goals completed! 🐙) input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falset:ℕht:t < Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = trueh:have now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(0 + t) ∧
now.workTapePos 1 = ↑(0 + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if 0 ≤ j ∧ j < 0 + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)⊢ (configs cfg t).state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
(configs cfg t).workTapePos 0 = ↑t ∧ (configs cfg t).workTapePos 1 = ↑t
exact ⟨h.1, by input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falset:ℕht:t < Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = trueh:have now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(0 + t) ∧
now.workTapePos 1 = ↑(0 + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if 0 ≤ j ∧ j < 0 + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)⊢ (configs cfg t).workTapePos 0 = ↑t simpa only [Nat.zero_add] using h.2.1 All goals completed! 🐙,
by input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falset:ℕht:t < Counter.flips bshones:∀ j < Counter.flips bs - 1, digits cfg (if leaf = true then 1 else 0) (0 + j) = trueh:have now := configs cfg t;
now.state = some (if leaf = true then stCarryLeaf else stCarryFork) ∧
now.workTapePos 0 = ↑(0 + t) ∧
now.workTapePos 1 = ↑(0 + t) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦
if 0 ≤ j ∧ j < 0 + t then false else digits cfg (if leaf = true then 1 else 0) j) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1)⊢ (configs cfg t).workTapePos 1 = ↑t simpa only [Nat.zero_add] using h.2.2.1 All goals completed! 🐙⟩The binary heads equal elapsed time throughout a carry, including its terminal state.
theorem configs_carry_bits_pos {input : List (Fin 4)}
(cfg : Cfg 3 (Fin 4) (Fin 10) input) (leaf : Bool) (bs : List Bool)
(hq : cfg.state = some (if leaf then stCarryLeaf else stCarryFork))
(hp0 : cfg.workTapePos 0 = 0) (hp1 : cfg.workTapePos 1 = 0)
(hbits : ∀ j, digits cfg (if leaf then 1 else 0) j = bs[j]?.getD false)
(t : ℕ) (ht : t ≤ Counter.flips bs) :
(machine.configs cfg t).workTapePos 0 = t ∧
(machine.configs cfg t).workTapePos 1 = t := by input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falset:ℕht:t ≤ Counter.flips bs⊢ (configs cfg t).workTapePos 0 = ↑t ∧ (configs cfg t).workTapePos 1 = ↑t
by_cases he : t = Counter.flips bs pos input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falset:ℕht:t ≤ Counter.flips bshe:t = Counter.flips bs⊢ (configs cfg t).workTapePos 0 = ↑t ∧ (configs cfg t).workTapePos 1 = ↑tneg input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falset:ℕht:t ≤ Counter.flips bshe:¬t = Counter.flips bs⊢ (configs cfg t).workTapePos 0 = ↑t ∧ (configs cfg t).workTapePos 1 = ↑t
· pos input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falset:ℕht:t ≤ Counter.flips bshe:t = Counter.flips bs⊢ (configs cfg t).workTapePos 0 = ↑t ∧ (configs cfg t).workTapePos 1 = ↑t subst t pos input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falseht:Counter.flips bs ≤ Counter.flips bs⊢ (configs cfg (Counter.flips bs)).workTapePos 0 = ↑(Counter.flips bs) ∧
(configs cfg (Counter.flips bs)).workTapePos 1 = ↑(Counter.flips bs)
have h := configs_carry_bits cfg leaf bs hq hp0 hp1 hbits pos input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falseht:Counter.flips bs ≤ Counter.flips bsh:have now := configs cfg (Counter.flips bs);
now.state = some stReturn ∧
now.workTapePos 0 = ↑(Counter.flips bs) ∧
now.workTapePos 1 = ↑(Counter.flips bs) ∧
now.inputPos = cfg.inputPos ∧
(digits now (if leaf = true then 1 else 0) = fun j ↦ (Counter.increment bs)[j]?.getD false) ∧
digits now (if leaf = true then 0 else 1) = digits cfg (if leaf = true then 0 else 1) ∧
machine.outputString cfg (Counter.flips bs) = []⊢ (configs cfg (Counter.flips bs)).workTapePos 0 = ↑(Counter.flips bs) ∧
(configs cfg (Counter.flips bs)).workTapePos 1 = ↑(Counter.flips bs)
exact ⟨h.2.1, h.2.2.1⟩ All goals completed! 🐙
· neg input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falset:ℕht:t ≤ Counter.flips bshe:¬t = Counter.flips bs⊢ (configs cfg t).workTapePos 0 = ↑t ∧ (configs cfg t).workTapePos 1 = ↑t exact (configs_carry_bits_state cfg leaf bs hq hp0 hp1 hbits t (by input:List (Fin 4)cfg:Cfg 3 (Fin 4) (Fin 10) inputleaf:Boolbs:List Boolhq:cfg.state = some (if leaf = true then stCarryLeaf else stCarryFork)hp0:cfg.workTapePos 0 = 0hp1:cfg.workTapePos 1 = 0hbits:∀ (j : ℕ), digits cfg (if leaf = true then 1 else 0) j = bs[j]?.getD falset:ℕht:t ≤ Counter.flips bshe:¬t = Counter.flips bs⊢ t < Counter.flips bs omega All goals completed! 🐙)).2end Geb.BitTree.BinaryMachine