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.Elias.MachineSteps
public import Geb.Prototypes.Computability.BitTree.Elias.Counter
public import Geb.Prototypes.Computability.TreeScanner.Stepsset_option doc.verso trueExecution of binary countdowns
The countdown enters its least significant digit from the blank on the right. Borrowing and the following leftward scan visit the digit positions once; the return scan visits them once more, retaining whether the decremented counter contains a one.
Main statements
-
configs_decrementgives the exact countdown result and transition count. -
configs_decrement_headBoundbounds every intermediate work-tape head.
Tags
Turing machine, binary counter, decrement, simulation
@[expose] public sectionnamespace Geb.BitTree.Elias.Machineopen Turing MultiTapeTMopen Geb.TreeScanner (step_of_state)A stationary-input counter action with no write changes only its selected head and state.
theorem counterAction_none_run {input : List (Fin 3)} (cfg : Cfg 4 (Fin 3) Control input)
(v : Bool) (bs : List Bool) (q q' : Control) (p p' : ℕ) (d : SignType)
(htr : machine.tr q (counterCfg cfg v bs q p).inputSymbol
(counterCfg cfg v bs q p).workTapeSymbols = counterAction v none d q')
(hp : (p : ℤ) + d = p') :
machine.step (counterCfg cfg v bs q p) = counterCfg cfg v bs q' p' ∧
machine.outputSymbol (counterCfg cfg v bs q p) = none := input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypehtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols = counterAction v none d q'hp:↑p + ↑d = ↑p'⊢ step (counterCfg cfg v bs q p) = counterCfg cfg v bs q' p' ∧ outputSymbol (counterCfg cfg v bs q p) = none
input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypehtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols = counterAction v none d q'hp:↑p + ↑d = ↑p'⊢ step (counterCfg cfg v bs q p) = counterCfg cfg v bs q' p'input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypehtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols = counterAction v none d q'hp:↑p + ↑d = ↑p'⊢ outputSymbol (counterCfg cfg v bs q p) = none
input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypehtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols = counterAction v none d q'hp:↑p + ↑d = ↑p'⊢ step (counterCfg cfg v bs q p) = counterCfg cfg v bs q' p' left input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypehtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols = counterAction v none d q'hp:↑p + ↑d = ↑p'⊢ { state := (counterAction v none d q').q',
inputPos := moveInputPos (counterCfg cfg v bs q p).inputPos (counterAction v none d q').inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3)) ((counterAction v none d q').workActions i).1 with
| none => (counterCfg cfg v bs q p).workTapes i
| some s => Function.update ((counterCfg cfg v bs q p).workTapes i) ((counterCfg cfg v bs q p).workTapePos i) s,
workTapePos := fun i ↦ (counterCfg cfg v bs q p).workTapePos i + ↑((counterAction v none d q').workActions i).2 } =
counterCfg cfg v bs q' p'
refine Cfg.ext rfl (moveInputPos_zero _) ?_ ?_ left.refine_1 input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypehtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols = counterAction v none d q'hp:↑p + ↑d = ↑p'⊢ { state := (counterAction v none d q').q',
inputPos := moveInputPos (counterCfg cfg v bs q p).inputPos (counterAction v none d q').inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v none d q').workActions i).1 with
| none => (counterCfg cfg v bs q p).workTapes i
| some s => Function.update ((counterCfg cfg v bs q p).workTapes i) ((counterCfg cfg v bs q p).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs q p).workTapePos i + ↑((counterAction v none d q').workActions i).2 }.workTapes =
(counterCfg cfg v bs q' p').workTapesleft.refine_2 input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypehtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols = counterAction v none d q'hp:↑p + ↑d = ↑p'⊢ { state := (counterAction v none d q').q',
inputPos := moveInputPos (counterCfg cfg v bs q p).inputPos (counterAction v none d q').inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v none d q').workActions i).1 with
| none => (counterCfg cfg v bs q p).workTapes i
| some s => Function.update ((counterCfg cfg v bs q p).workTapes i) ((counterCfg cfg v bs q p).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs q p).workTapePos i + ↑((counterAction v none d q').workActions i).2 }.workTapePos =
(counterCfg cfg v bs q' p').workTapePos
· left.refine_1 input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypehtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols = counterAction v none d q'hp:↑p + ↑d = ↑p'⊢ { state := (counterAction v none d q').q',
inputPos := moveInputPos (counterCfg cfg v bs q p).inputPos (counterAction v none d q').inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v none d q').workActions i).1 with
| none => (counterCfg cfg v bs q p).workTapes i
| some s => Function.update ((counterCfg cfg v bs q p).workTapes i) ((counterCfg cfg v bs q p).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs q p).workTapePos i + ↑((counterAction v none d q').workActions i).2 }.workTapes =
(counterCfg cfg v bs q' p').workTapes funext i z left.refine_1 input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypehtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols = counterAction v none d q'hp:↑p + ↑d = ↑p'i:Fin 4z:ℤ⊢ { state := (counterAction v none d q').q',
inputPos := moveInputPos (counterCfg cfg v bs q p).inputPos (counterAction v none d q').inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v none d q').workActions i).1 with
| none => (counterCfg cfg v bs q p).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs q p).workTapes i) ((counterCfg cfg v bs q p).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs q p).workTapePos i + ↑((counterAction v none d q').workActions i).2 }.workTapes
i z =
(counterCfg cfg v bs q' p').workTapes i z
by_cases hi : i = counterTape v pos input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypehtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols = counterAction v none d q'hp:↑p + ↑d = ↑p'i:Fin 4z:ℤhi:i = counterTape v⊢ { state := (counterAction v none d q').q',
inputPos := moveInputPos (counterCfg cfg v bs q p).inputPos (counterAction v none d q').inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v none d q').workActions i).1 with
| none => (counterCfg cfg v bs q p).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs q p).workTapes i) ((counterCfg cfg v bs q p).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs q p).workTapePos i + ↑((counterAction v none d q').workActions i).2 }.workTapes
i z =
(counterCfg cfg v bs q' p').workTapes i zneg input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypehtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols = counterAction v none d q'hp:↑p + ↑d = ↑p'i:Fin 4z:ℤhi:¬i = counterTape v⊢ { state := (counterAction v none d q').q',
inputPos := moveInputPos (counterCfg cfg v bs q p).inputPos (counterAction v none d q').inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v none d q').workActions i).1 with
| none => (counterCfg cfg v bs q p).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs q p).workTapes i) ((counterCfg cfg v bs q p).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs q p).workTapePos i + ↑((counterAction v none d q').workActions i).2 }.workTapes
i z =
(counterCfg cfg v bs q' p').workTapes i z <;> pos input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypehtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols = counterAction v none d q'hp:↑p + ↑d = ↑p'i:Fin 4z:ℤhi:i = counterTape v⊢ { state := (counterAction v none d q').q',
inputPos := moveInputPos (counterCfg cfg v bs q p).inputPos (counterAction v none d q').inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v none d q').workActions i).1 with
| none => (counterCfg cfg v bs q p).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs q p).workTapes i) ((counterCfg cfg v bs q p).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs q p).workTapePos i + ↑((counterAction v none d q').workActions i).2 }.workTapes
i z =
(counterCfg cfg v bs q' p').workTapes i zneg input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypehtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols = counterAction v none d q'hp:↑p + ↑d = ↑p'i:Fin 4z:ℤhi:¬i = counterTape v⊢ { state := (counterAction v none d q').q',
inputPos := moveInputPos (counterCfg cfg v bs q p).inputPos (counterAction v none d q').inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v none d q').workActions i).1 with
| none => (counterCfg cfg v bs q p).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs q p).workTapes i) ((counterCfg cfg v bs q p).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs q p).workTapePos i + ↑((counterAction v none d q').workActions i).2 }.workTapes
i z =
(counterCfg cfg v bs q' p').workTapes i z simp [counterAction, counterCfg, jump, hi] All goals completed! 🐙
· left.refine_2 input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypehtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols = counterAction v none d q'hp:↑p + ↑d = ↑p'⊢ { state := (counterAction v none d q').q',
inputPos := moveInputPos (counterCfg cfg v bs q p).inputPos (counterAction v none d q').inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v none d q').workActions i).1 with
| none => (counterCfg cfg v bs q p).workTapes i
| some s => Function.update ((counterCfg cfg v bs q p).workTapes i) ((counterCfg cfg v bs q p).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs q p).workTapePos i + ↑((counterAction v none d q').workActions i).2 }.workTapePos =
(counterCfg cfg v bs q' p').workTapePos funext i left.refine_2 input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypehtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols = counterAction v none d q'hp:↑p + ↑d = ↑p'i:Fin 4⊢ { state := (counterAction v none d q').q',
inputPos := moveInputPos (counterCfg cfg v bs q p).inputPos (counterAction v none d q').inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v none d q').workActions i).1 with
| none => (counterCfg cfg v bs q p).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs q p).workTapes i) ((counterCfg cfg v bs q p).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs q p).workTapePos i + ↑((counterAction v none d q').workActions i).2 }.workTapePos
i =
(counterCfg cfg v bs q' p').workTapePos i
by_cases hi : i = counterTape v pos input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypehtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols = counterAction v none d q'hp:↑p + ↑d = ↑p'i:Fin 4hi:i = counterTape v⊢ { state := (counterAction v none d q').q',
inputPos := moveInputPos (counterCfg cfg v bs q p).inputPos (counterAction v none d q').inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v none d q').workActions i).1 with
| none => (counterCfg cfg v bs q p).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs q p).workTapes i) ((counterCfg cfg v bs q p).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs q p).workTapePos i + ↑((counterAction v none d q').workActions i).2 }.workTapePos
i =
(counterCfg cfg v bs q' p').workTapePos ineg input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypehtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols = counterAction v none d q'hp:↑p + ↑d = ↑p'i:Fin 4hi:¬i = counterTape v⊢ { state := (counterAction v none d q').q',
inputPos := moveInputPos (counterCfg cfg v bs q p).inputPos (counterAction v none d q').inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v none d q').workActions i).1 with
| none => (counterCfg cfg v bs q p).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs q p).workTapes i) ((counterCfg cfg v bs q p).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs q p).workTapePos i + ↑((counterAction v none d q').workActions i).2 }.workTapePos
i =
(counterCfg cfg v bs q' p').workTapePos i <;> pos input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypehtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols = counterAction v none d q'hp:↑p + ↑d = ↑p'i:Fin 4hi:i = counterTape v⊢ { state := (counterAction v none d q').q',
inputPos := moveInputPos (counterCfg cfg v bs q p).inputPos (counterAction v none d q').inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v none d q').workActions i).1 with
| none => (counterCfg cfg v bs q p).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs q p).workTapes i) ((counterCfg cfg v bs q p).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs q p).workTapePos i + ↑((counterAction v none d q').workActions i).2 }.workTapePos
i =
(counterCfg cfg v bs q' p').workTapePos ineg input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypehtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols = counterAction v none d q'hp:↑p + ↑d = ↑p'i:Fin 4hi:¬i = counterTape v⊢ { state := (counterAction v none d q').q',
inputPos := moveInputPos (counterCfg cfg v bs q p).inputPos (counterAction v none d q').inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v none d q').workActions i).1 with
| none => (counterCfg cfg v bs q p).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs q p).workTapes i) ((counterCfg cfg v bs q p).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs q p).workTapePos i + ↑((counterAction v none d q').workActions i).2 }.workTapePos
i =
(counterCfg cfg v bs q' p').workTapePos i simp [counterAction, counterCfg, jump, hi, hp] All goals completed! 🐙
· right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypehtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols = counterAction v none d q'hp:↑p + ↑d = ↑p'⊢ outputSymbol (counterCfg cfg v bs q p) = none change (machine.tr q _ _).outS = none right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypehtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols = counterAction v none d q'hp:↑p + ↑d = ↑p'⊢ (machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols).outS = none
rw [htr right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypehtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols = counterAction v none d q'hp:↑p + ↑d = ↑p'⊢ (counterAction v none d q').outS = none] right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypehtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols = counterAction v none d q'hp:↑p + ↑d = ↑p'⊢ (counterAction v none d q').outS = none
rfl All goals completed! 🐙A writing counter action realizes a prescribed change of the finite digit word.
theorem counterAction_write_run {input : List (Fin 3)} (cfg : Cfg 4 (Fin 3) Control input)
(v : Bool) (bs bs' : List Bool) (q q' : Control) (p p' : ℕ) (d : SignType) (b : Bool)
(htr : machine.tr q (counterCfg cfg v bs q p).inputSymbol
(counterCfg cfg v bs q p).workTapeSymbols =
counterAction v (some (some (boolEmb b))) d q')
(hp : (p : ℤ) + d = p')
(hw : Function.update (wordTape bs) (p : ℤ) (some (boolEmb b)) = wordTape bs') :
machine.step (counterCfg cfg v bs q p) = counterCfg cfg v bs' q' p' ∧
machine.outputSymbol (counterCfg cfg v bs q p) = none := by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolbs':List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypeb:Boolhtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols =
counterAction v (some (some (boolEmb b))) d q'hp:↑p + ↑d = ↑p'hw:Function.update (wordTape bs) (↑p) (some (boolEmb b)) = wordTape bs'⊢ step (counterCfg cfg v bs q p) = counterCfg cfg v bs' q' p' ∧ outputSymbol (counterCfg cfg v bs q p) = none
constructor left input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolbs':List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypeb:Boolhtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols =
counterAction v (some (some (boolEmb b))) d q'hp:↑p + ↑d = ↑p'hw:Function.update (wordTape bs) (↑p) (some (boolEmb b)) = wordTape bs'⊢ step (counterCfg cfg v bs q p) = counterCfg cfg v bs' q' p'right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolbs':List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypeb:Boolhtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols =
counterAction v (some (some (boolEmb b))) d q'hp:↑p + ↑d = ↑p'hw:Function.update (wordTape bs) (↑p) (some (boolEmb b)) = wordTape bs'⊢ outputSymbol (counterCfg cfg v bs q p) = none
· left input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolbs':List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypeb:Boolhtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols =
counterAction v (some (some (boolEmb b))) d q'hp:↑p + ↑d = ↑p'hw:Function.update (wordTape bs) (↑p) (some (boolEmb b)) = wordTape bs'⊢ step (counterCfg cfg v bs q p) = counterCfg cfg v bs' q' p' rw [step_of_state _ _ q rfl, left input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolbs':List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypeb:Boolhtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols =
counterAction v (some (some (boolEmb b))) d q'hp:↑p + ↑d = ↑p'hw:Function.update (wordTape bs) (↑p) (some (boolEmb b)) = wordTape bs'⊢ { state := (machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols).q',
inputPos :=
moveInputPos (counterCfg cfg v bs q p).inputPos
(machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols).inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols).workActions
i).1 with
| none => (counterCfg cfg v bs q p).workTapes i
| some s => Function.update ((counterCfg cfg v bs q p).workTapes i) ((counterCfg cfg v bs q p).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs q p).workTapePos i +
↑((machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols).workActions
i).2 } =
counterCfg cfg v bs' q' p' htr left input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolbs':List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypeb:Boolhtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols =
counterAction v (some (some (boolEmb b))) d q'hp:↑p + ↑d = ↑p'hw:Function.update (wordTape bs) (↑p) (some (boolEmb b)) = wordTape bs'⊢ { state := (counterAction v (some (some (boolEmb b))) d q').q',
inputPos :=
moveInputPos (counterCfg cfg v bs q p).inputPos (counterAction v (some (some (boolEmb b))) d q').inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v (some (some (boolEmb b))) d q').workActions i).1 with
| none => (counterCfg cfg v bs q p).workTapes i
| some s => Function.update ((counterCfg cfg v bs q p).workTapes i) ((counterCfg cfg v bs q p).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs q p).workTapePos i + ↑((counterAction v (some (some (boolEmb b))) d q').workActions i).2 } =
counterCfg cfg v bs' q' p'] left input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolbs':List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypeb:Boolhtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols =
counterAction v (some (some (boolEmb b))) d q'hp:↑p + ↑d = ↑p'hw:Function.update (wordTape bs) (↑p) (some (boolEmb b)) = wordTape bs'⊢ { state := (counterAction v (some (some (boolEmb b))) d q').q',
inputPos :=
moveInputPos (counterCfg cfg v bs q p).inputPos (counterAction v (some (some (boolEmb b))) d q').inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v (some (some (boolEmb b))) d q').workActions i).1 with
| none => (counterCfg cfg v bs q p).workTapes i
| some s => Function.update ((counterCfg cfg v bs q p).workTapes i) ((counterCfg cfg v bs q p).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs q p).workTapePos i + ↑((counterAction v (some (some (boolEmb b))) d q').workActions i).2 } =
counterCfg cfg v bs' q' p'
refine Cfg.ext rfl (moveInputPos_zero _) ?_ ?_ left.refine_1 input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolbs':List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypeb:Boolhtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols =
counterAction v (some (some (boolEmb b))) d q'hp:↑p + ↑d = ↑p'hw:Function.update (wordTape bs) (↑p) (some (boolEmb b)) = wordTape bs'⊢ { state := (counterAction v (some (some (boolEmb b))) d q').q',
inputPos :=
moveInputPos (counterCfg cfg v bs q p).inputPos (counterAction v (some (some (boolEmb b))) d q').inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v (some (some (boolEmb b))) d q').workActions i).1 with
| none => (counterCfg cfg v bs q p).workTapes i
| some s => Function.update ((counterCfg cfg v bs q p).workTapes i) ((counterCfg cfg v bs q p).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs q p).workTapePos i +
↑((counterAction v (some (some (boolEmb b))) d q').workActions i).2 }.workTapes =
(counterCfg cfg v bs' q' p').workTapesleft.refine_2 input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolbs':List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypeb:Boolhtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols =
counterAction v (some (some (boolEmb b))) d q'hp:↑p + ↑d = ↑p'hw:Function.update (wordTape bs) (↑p) (some (boolEmb b)) = wordTape bs'⊢ { state := (counterAction v (some (some (boolEmb b))) d q').q',
inputPos :=
moveInputPos (counterCfg cfg v bs q p).inputPos (counterAction v (some (some (boolEmb b))) d q').inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v (some (some (boolEmb b))) d q').workActions i).1 with
| none => (counterCfg cfg v bs q p).workTapes i
| some s => Function.update ((counterCfg cfg v bs q p).workTapes i) ((counterCfg cfg v bs q p).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs q p).workTapePos i +
↑((counterAction v (some (some (boolEmb b))) d q').workActions i).2 }.workTapePos =
(counterCfg cfg v bs' q' p').workTapePos
· left.refine_1 input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolbs':List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypeb:Boolhtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols =
counterAction v (some (some (boolEmb b))) d q'hp:↑p + ↑d = ↑p'hw:Function.update (wordTape bs) (↑p) (some (boolEmb b)) = wordTape bs'⊢ { state := (counterAction v (some (some (boolEmb b))) d q').q',
inputPos :=
moveInputPos (counterCfg cfg v bs q p).inputPos (counterAction v (some (some (boolEmb b))) d q').inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v (some (some (boolEmb b))) d q').workActions i).1 with
| none => (counterCfg cfg v bs q p).workTapes i
| some s => Function.update ((counterCfg cfg v bs q p).workTapes i) ((counterCfg cfg v bs q p).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs q p).workTapePos i +
↑((counterAction v (some (some (boolEmb b))) d q').workActions i).2 }.workTapes =
(counterCfg cfg v bs' q' p').workTapes funext i z left.refine_1 input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolbs':List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypeb:Boolhtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols =
counterAction v (some (some (boolEmb b))) d q'hp:↑p + ↑d = ↑p'hw:Function.update (wordTape bs) (↑p) (some (boolEmb b)) = wordTape bs'i:Fin 4z:ℤ⊢ { state := (counterAction v (some (some (boolEmb b))) d q').q',
inputPos :=
moveInputPos (counterCfg cfg v bs q p).inputPos (counterAction v (some (some (boolEmb b))) d q').inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v (some (some (boolEmb b))) d q').workActions i).1 with
| none => (counterCfg cfg v bs q p).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs q p).workTapes i) ((counterCfg cfg v bs q p).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs q p).workTapePos i +
↑((counterAction v (some (some (boolEmb b))) d q').workActions i).2 }.workTapes
i z =
(counterCfg cfg v bs' q' p').workTapes i z
by_cases hi : i = counterTape v pos input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolbs':List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypeb:Boolhtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols =
counterAction v (some (some (boolEmb b))) d q'hp:↑p + ↑d = ↑p'hw:Function.update (wordTape bs) (↑p) (some (boolEmb b)) = wordTape bs'i:Fin 4z:ℤhi:i = counterTape v⊢ { state := (counterAction v (some (some (boolEmb b))) d q').q',
inputPos :=
moveInputPos (counterCfg cfg v bs q p).inputPos (counterAction v (some (some (boolEmb b))) d q').inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v (some (some (boolEmb b))) d q').workActions i).1 with
| none => (counterCfg cfg v bs q p).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs q p).workTapes i) ((counterCfg cfg v bs q p).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs q p).workTapePos i +
↑((counterAction v (some (some (boolEmb b))) d q').workActions i).2 }.workTapes
i z =
(counterCfg cfg v bs' q' p').workTapes i zneg input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolbs':List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypeb:Boolhtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols =
counterAction v (some (some (boolEmb b))) d q'hp:↑p + ↑d = ↑p'hw:Function.update (wordTape bs) (↑p) (some (boolEmb b)) = wordTape bs'i:Fin 4z:ℤhi:¬i = counterTape v⊢ { state := (counterAction v (some (some (boolEmb b))) d q').q',
inputPos :=
moveInputPos (counterCfg cfg v bs q p).inputPos (counterAction v (some (some (boolEmb b))) d q').inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v (some (some (boolEmb b))) d q').workActions i).1 with
| none => (counterCfg cfg v bs q p).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs q p).workTapes i) ((counterCfg cfg v bs q p).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs q p).workTapePos i +
↑((counterAction v (some (some (boolEmb b))) d q').workActions i).2 }.workTapes
i z =
(counterCfg cfg v bs' q' p').workTapes i z
· pos input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolbs':List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypeb:Boolhtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols =
counterAction v (some (some (boolEmb b))) d q'hp:↑p + ↑d = ↑p'hw:Function.update (wordTape bs) (↑p) (some (boolEmb b)) = wordTape bs'i:Fin 4z:ℤhi:i = counterTape v⊢ { state := (counterAction v (some (some (boolEmb b))) d q').q',
inputPos :=
moveInputPos (counterCfg cfg v bs q p).inputPos (counterAction v (some (some (boolEmb b))) d q').inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v (some (some (boolEmb b))) d q').workActions i).1 with
| none => (counterCfg cfg v bs q p).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs q p).workTapes i) ((counterCfg cfg v bs q p).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs q p).workTapePos i +
↑((counterAction v (some (some (boolEmb b))) d q').workActions i).2 }.workTapes
i z =
(counterCfg cfg v bs' q' p').workTapes i z simp only [counterAction, counterCfg, jump, hi, ↓reduceIte] pos input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolbs':List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypeb:Boolhtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols =
counterAction v (some (some (boolEmb b))) d q'hp:↑p + ↑d = ↑p'hw:Function.update (wordTape bs) (↑p) (some (boolEmb b)) = wordTape bs'i:Fin 4z:ℤhi:i = counterTape v⊢ Function.update (wordTape bs) (↑p) (some (boolEmb b)) z = wordTape bs' z
exact congrFun hw z All goals completed! 🐙
· neg input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolbs':List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypeb:Boolhtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols =
counterAction v (some (some (boolEmb b))) d q'hp:↑p + ↑d = ↑p'hw:Function.update (wordTape bs) (↑p) (some (boolEmb b)) = wordTape bs'i:Fin 4z:ℤhi:¬i = counterTape v⊢ { state := (counterAction v (some (some (boolEmb b))) d q').q',
inputPos :=
moveInputPos (counterCfg cfg v bs q p).inputPos (counterAction v (some (some (boolEmb b))) d q').inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v (some (some (boolEmb b))) d q').workActions i).1 with
| none => (counterCfg cfg v bs q p).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs q p).workTapes i) ((counterCfg cfg v bs q p).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs q p).workTapePos i +
↑((counterAction v (some (some (boolEmb b))) d q').workActions i).2 }.workTapes
i z =
(counterCfg cfg v bs' q' p').workTapes i z simp [counterAction, counterCfg, jump, hi] All goals completed! 🐙
· left.refine_2 input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolbs':List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypeb:Boolhtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols =
counterAction v (some (some (boolEmb b))) d q'hp:↑p + ↑d = ↑p'hw:Function.update (wordTape bs) (↑p) (some (boolEmb b)) = wordTape bs'⊢ { state := (counterAction v (some (some (boolEmb b))) d q').q',
inputPos :=
moveInputPos (counterCfg cfg v bs q p).inputPos (counterAction v (some (some (boolEmb b))) d q').inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v (some (some (boolEmb b))) d q').workActions i).1 with
| none => (counterCfg cfg v bs q p).workTapes i
| some s => Function.update ((counterCfg cfg v bs q p).workTapes i) ((counterCfg cfg v bs q p).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs q p).workTapePos i +
↑((counterAction v (some (some (boolEmb b))) d q').workActions i).2 }.workTapePos =
(counterCfg cfg v bs' q' p').workTapePos funext i left.refine_2 input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolbs':List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypeb:Boolhtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols =
counterAction v (some (some (boolEmb b))) d q'hp:↑p + ↑d = ↑p'hw:Function.update (wordTape bs) (↑p) (some (boolEmb b)) = wordTape bs'i:Fin 4⊢ { state := (counterAction v (some (some (boolEmb b))) d q').q',
inputPos :=
moveInputPos (counterCfg cfg v bs q p).inputPos (counterAction v (some (some (boolEmb b))) d q').inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v (some (some (boolEmb b))) d q').workActions i).1 with
| none => (counterCfg cfg v bs q p).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs q p).workTapes i) ((counterCfg cfg v bs q p).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs q p).workTapePos i +
↑((counterAction v (some (some (boolEmb b))) d q').workActions i).2 }.workTapePos
i =
(counterCfg cfg v bs' q' p').workTapePos i
by_cases hi : i = counterTape v pos input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolbs':List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypeb:Boolhtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols =
counterAction v (some (some (boolEmb b))) d q'hp:↑p + ↑d = ↑p'hw:Function.update (wordTape bs) (↑p) (some (boolEmb b)) = wordTape bs'i:Fin 4hi:i = counterTape v⊢ { state := (counterAction v (some (some (boolEmb b))) d q').q',
inputPos :=
moveInputPos (counterCfg cfg v bs q p).inputPos (counterAction v (some (some (boolEmb b))) d q').inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v (some (some (boolEmb b))) d q').workActions i).1 with
| none => (counterCfg cfg v bs q p).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs q p).workTapes i) ((counterCfg cfg v bs q p).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs q p).workTapePos i +
↑((counterAction v (some (some (boolEmb b))) d q').workActions i).2 }.workTapePos
i =
(counterCfg cfg v bs' q' p').workTapePos ineg input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolbs':List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypeb:Boolhtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols =
counterAction v (some (some (boolEmb b))) d q'hp:↑p + ↑d = ↑p'hw:Function.update (wordTape bs) (↑p) (some (boolEmb b)) = wordTape bs'i:Fin 4hi:¬i = counterTape v⊢ { state := (counterAction v (some (some (boolEmb b))) d q').q',
inputPos :=
moveInputPos (counterCfg cfg v bs q p).inputPos (counterAction v (some (some (boolEmb b))) d q').inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v (some (some (boolEmb b))) d q').workActions i).1 with
| none => (counterCfg cfg v bs q p).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs q p).workTapes i) ((counterCfg cfg v bs q p).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs q p).workTapePos i +
↑((counterAction v (some (some (boolEmb b))) d q').workActions i).2 }.workTapePos
i =
(counterCfg cfg v bs' q' p').workTapePos i <;> pos input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolbs':List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypeb:Boolhtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols =
counterAction v (some (some (boolEmb b))) d q'hp:↑p + ↑d = ↑p'hw:Function.update (wordTape bs) (↑p) (some (boolEmb b)) = wordTape bs'i:Fin 4hi:i = counterTape v⊢ { state := (counterAction v (some (some (boolEmb b))) d q').q',
inputPos :=
moveInputPos (counterCfg cfg v bs q p).inputPos (counterAction v (some (some (boolEmb b))) d q').inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v (some (some (boolEmb b))) d q').workActions i).1 with
| none => (counterCfg cfg v bs q p).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs q p).workTapes i) ((counterCfg cfg v bs q p).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs q p).workTapePos i +
↑((counterAction v (some (some (boolEmb b))) d q').workActions i).2 }.workTapePos
i =
(counterCfg cfg v bs' q' p').workTapePos ineg input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolbs':List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypeb:Boolhtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols =
counterAction v (some (some (boolEmb b))) d q'hp:↑p + ↑d = ↑p'hw:Function.update (wordTape bs) (↑p) (some (boolEmb b)) = wordTape bs'i:Fin 4hi:¬i = counterTape v⊢ { state := (counterAction v (some (some (boolEmb b))) d q').q',
inputPos :=
moveInputPos (counterCfg cfg v bs q p).inputPos (counterAction v (some (some (boolEmb b))) d q').inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v (some (some (boolEmb b))) d q').workActions i).1 with
| none => (counterCfg cfg v bs q p).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs q p).workTapes i) ((counterCfg cfg v bs q p).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs q p).workTapePos i +
↑((counterAction v (some (some (boolEmb b))) d q').workActions i).2 }.workTapePos
i =
(counterCfg cfg v bs' q' p').workTapePos i simp [counterAction, counterCfg, jump, hi, hp] All goals completed! 🐙
· right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolbs':List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypeb:Boolhtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols =
counterAction v (some (some (boolEmb b))) d q'hp:↑p + ↑d = ↑p'hw:Function.update (wordTape bs) (↑p) (some (boolEmb b)) = wordTape bs'⊢ outputSymbol (counterCfg cfg v bs q p) = none change (machine.tr q _ _).outS = none right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolbs':List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypeb:Boolhtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols =
counterAction v (some (some (boolEmb b))) d q'hp:↑p + ↑d = ↑p'hw:Function.update (wordTape bs) (↑p) (some (boolEmb b)) = wordTape bs'⊢ (machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols).outS = none
rw [htr right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolbs':List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypeb:Boolhtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols =
counterAction v (some (some (boolEmb b))) d q'hp:↑p + ↑d = ↑p'hw:Function.update (wordTape bs) (↑p) (some (boolEmb b)) = wordTape bs'⊢ (counterAction v (some (some (boolEmb b))) d q').outS = none] right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolbs':List Boolq:Controlq':Controlp:ℕp':ℕd:SignTypeb:Boolhtr:machine.tr q (counterCfg cfg v bs q p).inputSymbol (counterCfg cfg v bs q p).workTapeSymbols =
counterAction v (some (some (boolEmb b))) d q'hp:↑p + ↑d = ↑p'hw:Function.update (wordTape bs) (↑p) (some (boolEmb b)) = wordTape bs'⊢ (counterAction v (some (some (boolEmb b))) d q').outS = none
rfl All goals completed! 🐙Countdown entry moves left from the right-hand blank without writing.
theorem step_decrement {input : List (Fin 3)} (cfg : Cfg 4 (Fin 3) Control input)
(v : Bool) (bs : List Bool) :
machine.step (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) =
counterCfg cfg v bs (stBorrow v false) bs.length := by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Bool⊢ step (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) = counterCfg cfg v bs (stBorrow v false) bs.length
rw [step_of_state _ _ (stDecrement v) rfl, input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Bool⊢ {
state :=
(machine.tr (stDecrement v) (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).inputSymbol
(counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapeSymbols).q',
inputPos :=
moveInputPos (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).inputPos
(machine.tr (stDecrement v) (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).inputSymbol
(counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapeSymbols).inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((machine.tr (stDecrement v) (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).inputSymbol
(counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapeSymbols).workActions
i).1 with
| none => (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapes i)
((counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapePos i +
↑((machine.tr (stDecrement v) (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).inputSymbol
(counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapeSymbols).workActions
i).2 } =
counterCfg cfg v bs (stBorrow v false) bs.length tr_decrement input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Bool⊢ { state := (counterAction v none (-1) (stBorrow v false)).q',
inputPos :=
moveInputPos (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).inputPos
(counterAction v none (-1) (stBorrow v false)).inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v none (-1) (stBorrow v false)).workActions i).1 with
| none => (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapes i)
((counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapePos i +
↑((counterAction v none (-1) (stBorrow v false)).workActions i).2 } =
counterCfg cfg v bs (stBorrow v false) bs.length] input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Bool⊢ { state := (counterAction v none (-1) (stBorrow v false)).q',
inputPos :=
moveInputPos (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).inputPos
(counterAction v none (-1) (stBorrow v false)).inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v none (-1) (stBorrow v false)).workActions i).1 with
| none => (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapes i)
((counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapePos i +
↑((counterAction v none (-1) (stBorrow v false)).workActions i).2 } =
counterCfg cfg v bs (stBorrow v false) bs.length
refine Cfg.ext rfl (moveInputPos_zero _) ?_ ?_ refine_1 input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Bool⊢ { state := (counterAction v none (-1) (stBorrow v false)).q',
inputPos :=
moveInputPos (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).inputPos
(counterAction v none (-1) (stBorrow v false)).inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v none (-1) (stBorrow v false)).workActions i).1 with
| none => (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapes i)
((counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapePos i +
↑((counterAction v none (-1) (stBorrow v false)).workActions i).2 }.workTapes =
(counterCfg cfg v bs (stBorrow v false) bs.length).workTapesrefine_2 input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Bool⊢ { state := (counterAction v none (-1) (stBorrow v false)).q',
inputPos :=
moveInputPos (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).inputPos
(counterAction v none (-1) (stBorrow v false)).inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v none (-1) (stBorrow v false)).workActions i).1 with
| none => (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapes i)
((counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapePos i +
↑((counterAction v none (-1) (stBorrow v false)).workActions i).2 }.workTapePos =
(counterCfg cfg v bs (stBorrow v false) bs.length).workTapePos
· refine_1 input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Bool⊢ { state := (counterAction v none (-1) (stBorrow v false)).q',
inputPos :=
moveInputPos (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).inputPos
(counterAction v none (-1) (stBorrow v false)).inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v none (-1) (stBorrow v false)).workActions i).1 with
| none => (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapes i)
((counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapePos i +
↑((counterAction v none (-1) (stBorrow v false)).workActions i).2 }.workTapes =
(counterCfg cfg v bs (stBorrow v false) bs.length).workTapes funext i z refine_1 input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Booli:Fin 4z:ℤ⊢ { state := (counterAction v none (-1) (stBorrow v false)).q',
inputPos :=
moveInputPos (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).inputPos
(counterAction v none (-1) (stBorrow v false)).inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v none (-1) (stBorrow v false)).workActions i).1 with
| none => (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapes i)
((counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapePos i +
↑((counterAction v none (-1) (stBorrow v false)).workActions i).2 }.workTapes
i z =
(counterCfg cfg v bs (stBorrow v false) bs.length).workTapes i z
by_cases hi : i = counterTape v pos input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Booli:Fin 4z:ℤhi:i = counterTape v⊢ { state := (counterAction v none (-1) (stBorrow v false)).q',
inputPos :=
moveInputPos (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).inputPos
(counterAction v none (-1) (stBorrow v false)).inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v none (-1) (stBorrow v false)).workActions i).1 with
| none => (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapes i)
((counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapePos i +
↑((counterAction v none (-1) (stBorrow v false)).workActions i).2 }.workTapes
i z =
(counterCfg cfg v bs (stBorrow v false) bs.length).workTapes i zneg input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Booli:Fin 4z:ℤhi:¬i = counterTape v⊢ { state := (counterAction v none (-1) (stBorrow v false)).q',
inputPos :=
moveInputPos (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).inputPos
(counterAction v none (-1) (stBorrow v false)).inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v none (-1) (stBorrow v false)).workActions i).1 with
| none => (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapes i)
((counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapePos i +
↑((counterAction v none (-1) (stBorrow v false)).workActions i).2 }.workTapes
i z =
(counterCfg cfg v bs (stBorrow v false) bs.length).workTapes i z <;> pos input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Booli:Fin 4z:ℤhi:i = counterTape v⊢ { state := (counterAction v none (-1) (stBorrow v false)).q',
inputPos :=
moveInputPos (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).inputPos
(counterAction v none (-1) (stBorrow v false)).inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v none (-1) (stBorrow v false)).workActions i).1 with
| none => (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapes i)
((counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapePos i +
↑((counterAction v none (-1) (stBorrow v false)).workActions i).2 }.workTapes
i z =
(counterCfg cfg v bs (stBorrow v false) bs.length).workTapes i zneg input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Booli:Fin 4z:ℤhi:¬i = counterTape v⊢ { state := (counterAction v none (-1) (stBorrow v false)).q',
inputPos :=
moveInputPos (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).inputPos
(counterAction v none (-1) (stBorrow v false)).inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v none (-1) (stBorrow v false)).workActions i).1 with
| none => (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapes i)
((counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapePos i +
↑((counterAction v none (-1) (stBorrow v false)).workActions i).2 }.workTapes
i z =
(counterCfg cfg v bs (stBorrow v false) bs.length).workTapes i z simp [counterAction, counterCfg, jump, hi] All goals completed! 🐙
· refine_2 input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Bool⊢ { state := (counterAction v none (-1) (stBorrow v false)).q',
inputPos :=
moveInputPos (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).inputPos
(counterAction v none (-1) (stBorrow v false)).inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v none (-1) (stBorrow v false)).workActions i).1 with
| none => (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapes i)
((counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapePos i +
↑((counterAction v none (-1) (stBorrow v false)).workActions i).2 }.workTapePos =
(counterCfg cfg v bs (stBorrow v false) bs.length).workTapePos funext i refine_2 input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Booli:Fin 4⊢ { state := (counterAction v none (-1) (stBorrow v false)).q',
inputPos :=
moveInputPos (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).inputPos
(counterAction v none (-1) (stBorrow v false)).inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v none (-1) (stBorrow v false)).workActions i).1 with
| none => (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapes i)
((counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapePos i +
↑((counterAction v none (-1) (stBorrow v false)).workActions i).2 }.workTapePos
i =
(counterCfg cfg v bs (stBorrow v false) bs.length).workTapePos i
by_cases hi : i = counterTape v pos input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Booli:Fin 4hi:i = counterTape v⊢ { state := (counterAction v none (-1) (stBorrow v false)).q',
inputPos :=
moveInputPos (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).inputPos
(counterAction v none (-1) (stBorrow v false)).inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v none (-1) (stBorrow v false)).workActions i).1 with
| none => (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapes i)
((counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapePos i +
↑((counterAction v none (-1) (stBorrow v false)).workActions i).2 }.workTapePos
i =
(counterCfg cfg v bs (stBorrow v false) bs.length).workTapePos ineg input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Booli:Fin 4hi:¬i = counterTape v⊢ { state := (counterAction v none (-1) (stBorrow v false)).q',
inputPos :=
moveInputPos (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).inputPos
(counterAction v none (-1) (stBorrow v false)).inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v none (-1) (stBorrow v false)).workActions i).1 with
| none => (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapes i)
((counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapePos i +
↑((counterAction v none (-1) (stBorrow v false)).workActions i).2 }.workTapePos
i =
(counterCfg cfg v bs (stBorrow v false) bs.length).workTapePos i <;> pos input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Booli:Fin 4hi:i = counterTape v⊢ { state := (counterAction v none (-1) (stBorrow v false)).q',
inputPos :=
moveInputPos (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).inputPos
(counterAction v none (-1) (stBorrow v false)).inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v none (-1) (stBorrow v false)).workActions i).1 with
| none => (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapes i)
((counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapePos i +
↑((counterAction v none (-1) (stBorrow v false)).workActions i).2 }.workTapePos
i =
(counterCfg cfg v bs (stBorrow v false) bs.length).workTapePos ineg input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Booli:Fin 4hi:¬i = counterTape v⊢ { state := (counterAction v none (-1) (stBorrow v false)).q',
inputPos :=
moveInputPos (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).inputPos
(counterAction v none (-1) (stBorrow v false)).inputMove,
workTapes := fun i ↦
match (motive := Option (Option (Fin 3)) → ℤ → Option (Fin 3))
((counterAction v none (-1) (stBorrow v false)).workActions i).1 with
| none => (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapes i
| some s =>
Function.update ((counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapes i)
((counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapePos i) s,
workTapePos := fun i ↦
(counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapePos i +
↑((counterAction v none (-1) (stBorrow v false)).workActions i).2 }.workTapePos
i =
(counterCfg cfg v bs (stBorrow v false) bs.length).workTapePos i simp [counterAction, counterCfg, jump, hi] All goals completed! 🐙Countdown entry emits no output.
theorem outputSymbol_decrement {input : List (Fin 3)} (cfg : Cfg 4 (Fin 3) Control input)
(v : Bool) (bs : List Bool) :
machine.outputSymbol (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) = none := by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Bool⊢ outputSymbol (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) = none
change (machine.tr (stDecrement v) _ _).outS = none input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Bool⊢ (machine.tr (stDecrement v) (counterCfg cfg v bs (stDecrement v) (bs.length + 1)).inputSymbol
(counterCfg cfg v bs (stDecrement v) (bs.length + 1)).workTapeSymbols).outS =
none
rw [tr_decrement input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Bool⊢ (counterAction v none (-1) (stBorrow v false)).outS = none] input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Bool⊢ (counterAction v none (-1) (stBorrow v false)).outS = none
rfl All goals completed! 🐙The leftward scan inspects the next higher digit and preserves the stored word.
theorem left_cons_run {input : List (Fin 3)} (cfg : Cfg 4 (Fin 3) Control input)
(v seen b : Bool) (lower higher : List Bool) :
machine.step (counterCfg cfg v (lower ++ b :: higher)
(stLeft v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length ∧
machine.outputSymbol (counterCfg cfg v (lower ++ b :: higher)
(stLeft v seen) (higher.length + 1)) = none := by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolb:Boollower:List Boolhigher:List Bool⊢ step (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length ∧
outputSymbol (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) = none
apply counterAction_none_run htr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolb:Boollower:List Boolhigher:List Bool⊢ machine.tr (stLeft v seen) (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)).inputSymbol
(counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)).workTapeSymbols =
counterAction v none ?d (stLeft v (seen || b))hp input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolb:Boollower:List Boolhigher:List Bool⊢ ↑(higher.length + 1) + ↑?d = ↑higher.lengthd input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolb:Boollower:List Boolhigher:List Bool⊢ SignType
· htr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolb:Boollower:List Boolhigher:List Bool⊢ machine.tr (stLeft v seen) (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)).inputSymbol
(counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)).workTapeSymbols =
counterAction v none ?d (stLeft v (seen || b)) rw [tr_left htr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolb:Boollower:List Boolhigher:List Bool⊢ sweepLeft v seen (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)).workTapeSymbols =
counterAction v none ?d (stLeft v (seen || b))] htr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolb:Boollower:List Boolhigher:List Bool⊢ sweepLeft v seen (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)).workTapeSymbols =
counterAction v none ?d (stLeft v (seen || b))
have hr : (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen)
(higher.length + 1)).workTapeSymbols (counterTape v) = some (boolEmb b) := by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolb:Boollower:List Boolhigher:List Bool⊢ step (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length ∧
outputSymbol (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) = none
simpa only [Cfg.workTapeSymbols, counterCfg, ite_true] using wordTape_split lower higher b htr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolb:Boollower:List Boolhigher:List Boolhr:(counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)).workTapeSymbols (counterTape v) =
some (boolEmb b)⊢ sweepLeft v seen (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)).workTapeSymbols =
counterAction v none ?d (stLeft v (seen || b))
simp only [sweepLeft, hr] htr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolb:Boollower:List Boolhigher:List Boolhr:(counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)).workTapeSymbols (counterTape v) =
some (boolEmb b)⊢ (if (some (boolEmb b) == some 2) = true then counterAction v none 1 (stRight v seen)
else counterAction v none (-1) (stLeft v (seen || some (boolEmb b) == some 1))) =
counterAction v none ?d (stLeft v (seen || b))
cases b htr.false input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boollower:List Boolhigher:List Boolhr:(counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) (higher.length + 1)).workTapeSymbols (counterTape v) =
some (boolEmb false)⊢ (if (some (boolEmb false) == some 2) = true then counterAction v none 1 (stRight v seen)
else counterAction v none (-1) (stLeft v (seen || some (boolEmb false) == some 1))) =
counterAction v none (?m.109 false) (stLeft v (seen || false))htr.true input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boollower:List Boolhigher:List Boolhr:(counterCfg cfg v (lower ++ true :: higher) (stLeft v seen) (higher.length + 1)).workTapeSymbols (counterTape v) =
some (boolEmb true)⊢ (if (some (boolEmb true) == some 2) = true then counterAction v none 1 (stRight v seen)
else counterAction v none (-1) (stLeft v (seen || some (boolEmb true) == some 1))) =
counterAction v none (?m.109 true) (stLeft v (seen || true)) <;> htr.false input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boollower:List Boolhigher:List Boolhr:(counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) (higher.length + 1)).workTapeSymbols (counterTape v) =
some (boolEmb false)⊢ (if (some (boolEmb false) == some 2) = true then counterAction v none 1 (stRight v seen)
else counterAction v none (-1) (stLeft v (seen || some (boolEmb false) == some 1))) =
counterAction v none (?m.109 false) (stLeft v (seen || false))htr.true input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boollower:List Boolhigher:List Boolhr:(counterCfg cfg v (lower ++ true :: higher) (stLeft v seen) (higher.length + 1)).workTapeSymbols (counterTape v) =
some (boolEmb true)⊢ (if (some (boolEmb true) == some 2) = true then counterAction v none 1 (stRight v seen)
else counterAction v none (-1) (stLeft v (seen || some (boolEmb true) == some 1))) =
counterAction v none (?m.109 true) (stLeft v (seen || true)) cases seen htr.true.false input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boollower:List Boolhigher:List Boolhr:(counterCfg cfg v (lower ++ true :: higher) (stLeft v false) (higher.length + 1)).workTapeSymbols (counterTape v) =
some (boolEmb true)⊢ (if (some (boolEmb true) == some 2) = true then counterAction v none 1 (stRight v false)
else counterAction v none (-1) (stLeft v (false || some (boolEmb true) == some 1))) =
counterAction v none (?m.139 false true) (stLeft v (false || true))htr.true.true input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boollower:List Boolhigher:List Boolhr:(counterCfg cfg v (lower ++ true :: higher) (stLeft v true) (higher.length + 1)).workTapeSymbols (counterTape v) =
some (boolEmb true)⊢ (if (some (boolEmb true) == some 2) = true then counterAction v none 1 (stRight v true)
else counterAction v none (-1) (stLeft v (true || some (boolEmb true) == some 1))) =
counterAction v none (?m.139 true true) (stLeft v (true || true)) <;> htr.false.false input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boollower:List Boolhigher:List Boolhr:(counterCfg cfg v (lower ++ false :: higher) (stLeft v false) (higher.length + 1)).workTapeSymbols (counterTape v) =
some (boolEmb false)⊢ (if (some (boolEmb false) == some 2) = true then counterAction v none 1 (stRight v false)
else counterAction v none (-1) (stLeft v (false || some (boolEmb false) == some 1))) =
counterAction v none (?m.139 false false) (stLeft v (false || false))htr.false.true input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boollower:List Boolhigher:List Boolhr:(counterCfg cfg v (lower ++ false :: higher) (stLeft v true) (higher.length + 1)).workTapeSymbols (counterTape v) =
some (boolEmb false)⊢ (if (some (boolEmb false) == some 2) = true then counterAction v none 1 (stRight v true)
else counterAction v none (-1) (stLeft v (true || some (boolEmb false) == some 1))) =
counterAction v none (?m.139 true false) (stLeft v (true || false))htr.true.false input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boollower:List Boolhigher:List Boolhr:(counterCfg cfg v (lower ++ true :: higher) (stLeft v false) (higher.length + 1)).workTapeSymbols (counterTape v) =
some (boolEmb true)⊢ (if (some (boolEmb true) == some 2) = true then counterAction v none 1 (stRight v false)
else counterAction v none (-1) (stLeft v (false || some (boolEmb true) == some 1))) =
counterAction v none (?m.139 false true) (stLeft v (false || true))htr.true.true input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boollower:List Boolhigher:List Boolhr:(counterCfg cfg v (lower ++ true :: higher) (stLeft v true) (higher.length + 1)).workTapeSymbols (counterTape v) =
some (boolEmb true)⊢ (if (some (boolEmb true) == some 2) = true then counterAction v none 1 (stRight v true)
else counterAction v none (-1) (stLeft v (true || some (boolEmb true) == some 1))) =
counterAction v none (?m.139 true true) (stLeft v (true || true)) rfl All goals completed! 🐙
· hp input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolb:Boollower:List Boolhigher:List Bool⊢ ↑(higher.length + 1) + ↑(-1) = ↑higher.length simp All goals completed! 🐙At the origin, the leftward scan turns right with its accumulated zero-test flag.
theorem left_zero_run {input : List (Fin 3)} (cfg : Cfg 4 (Fin 3) Control input)
(v seen : Bool) (bs : List Bool) :
machine.step (counterCfg cfg v bs (stLeft v seen) 0) =
counterCfg cfg v bs (stRight v seen) 1 ∧
machine.outputSymbol (counterCfg cfg v bs (stLeft v seen) 0) = none := by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Bool⊢ step (counterCfg cfg v bs (stLeft v seen) 0) = counterCfg cfg v bs (stRight v seen) 1 ∧
outputSymbol (counterCfg cfg v bs (stLeft v seen) 0) = none
apply counterAction_none_run (d := 1) htr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Bool⊢ machine.tr (stLeft v seen) (counterCfg cfg v bs (stLeft v seen) 0).inputSymbol
(counterCfg cfg v bs (stLeft v seen) 0).workTapeSymbols =
counterAction v none 1 (stRight v seen)hp input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Bool⊢ ↑0 + ↑1 = ↑1
· htr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Bool⊢ machine.tr (stLeft v seen) (counterCfg cfg v bs (stLeft v seen) 0).inputSymbol
(counterCfg cfg v bs (stLeft v seen) 0).workTapeSymbols =
counterAction v none 1 (stRight v seen) rw [tr_left htr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Bool⊢ sweepLeft v seen (counterCfg cfg v bs (stLeft v seen) 0).workTapeSymbols = counterAction v none 1 (stRight v seen)] htr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Bool⊢ sweepLeft v seen (counterCfg cfg v bs (stLeft v seen) 0).workTapeSymbols = counterAction v none 1 (stRight v seen)
have hr : (counterCfg cfg v bs (stLeft v seen) 0).workTapeSymbols (counterTape v) =
some 2 := by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Bool⊢ step (counterCfg cfg v bs (stLeft v seen) 0) = counterCfg cfg v bs (stRight v seen) 1 ∧
outputSymbol (counterCfg cfg v bs (stLeft v seen) 0) = none simp [counterCfg, Cfg.workTapeSymbols, wordTape_zero] htr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolhr:(counterCfg cfg v bs (stLeft v seen) 0).workTapeSymbols (counterTape v) = some 2⊢ sweepLeft v seen (counterCfg cfg v bs (stLeft v seen) 0).workTapeSymbols = counterAction v none 1 (stRight v seen)
simp only [sweepLeft, hr, beq_self_eq_true, ↓reduceIte] All goals completed! 🐙
· hp input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Bool⊢ ↑0 + ↑1 = ↑1 rfl All goals completed! 🐙The leftward scan accumulates the disjunction of all unvisited higher digits.
theorem configs_left {input : List (Fin 3)} (cfg : Cfg 4 (Fin 3) Control input)
(v : Bool) (higher : List Bool) : ∀ lower seen,
machine.configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length)
higher.length =
counterCfg cfg v (lower ++ higher) (stLeft v (seen || higher.any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length)
higher.length = [] := by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Bool⊢ ∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ higher) (stLeft v (seen || higher.any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length = []
apply List.rec (motive := fun higher ↦ ∀ lower seen,
machine.configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length)
higher.length =
counterCfg cfg v (lower ++ higher) (stLeft v (seen || higher.any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length)
higher.length = []) ?_ ?_ higher input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Bool⊢ ∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ []) (stLeft v seen) [].length) [].length =
counterCfg cfg v (lower ++ []) (stLeft v (seen || [].any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ []) (stLeft v seen) [].length) [].length = []input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Bool⊢ ∀ (head : Bool) (tail : List Bool),
(∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ tail) (stLeft v seen) tail.length) tail.length =
counterCfg cfg v (lower ++ tail) (stLeft v (seen || tail.any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ tail) (stLeft v seen) tail.length) tail.length = []) →
∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ head :: tail) (stLeft v seen) (head :: tail).length) (head :: tail).length =
counterCfg cfg v (lower ++ head :: tail) (stLeft v (seen || (head :: tail).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ head :: tail) (stLeft v seen) (head :: tail).length)
(head :: tail).length =
[]
· input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Bool⊢ ∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ []) (stLeft v seen) [].length) [].length =
counterCfg cfg v (lower ++ []) (stLeft v (seen || [].any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ []) (stLeft v seen) [].length) [].length = [] intro lower seen input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Boollower:List Boolseen:Bool⊢ configs (counterCfg cfg v (lower ++ []) (stLeft v seen) [].length) [].length =
counterCfg cfg v (lower ++ []) (stLeft v (seen || [].any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ []) (stLeft v seen) [].length) [].length = []
simp only [List.length_nil, configs_zero, List.any_nil, Bool.or_false] input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Boollower:List Boolseen:Bool⊢ True ∧ machine.outputString (counterCfg cfg v (lower ++ []) (stLeft v seen) 0) 0 = []
exact ⟨trivial, rfl⟩ All goals completed! 🐙
· input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Bool⊢ ∀ (head : Bool) (tail : List Bool),
(∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ tail) (stLeft v seen) tail.length) tail.length =
counterCfg cfg v (lower ++ tail) (stLeft v (seen || tail.any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ tail) (stLeft v seen) tail.length) tail.length = []) →
∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ head :: tail) (stLeft v seen) (head :: tail).length) (head :: tail).length =
counterCfg cfg v (lower ++ head :: tail) (stLeft v (seen || (head :: tail).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ head :: tail) (stLeft v seen) (head :: tail).length)
(head :: tail).length =
[] intro b higher ih lower seen input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ higher) (stLeft v (seen || higher.any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length = []lower:List Boolseen:Bool⊢ configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (b :: higher).length) (b :: higher).length =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || (b :: higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (b :: higher).length)
(b :: higher).length =
[]
obtain ⟨hs, ho⟩ := left_cons_run cfg v seen b lower higher input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ higher) (stLeft v (seen || higher.any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length = []lower:List Boolseen:Boolhs:step (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) = none⊢ configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (b :: higher).length) (b :: higher).length =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || (b :: higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (b :: higher).length)
(b :: higher).length =
[]
obtain ⟨hc, hout⟩ := ih (lower ++ [b]) (seen || b) input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ higher) (stLeft v (seen || higher.any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length = []lower:List Boolseen:Boolhs:step (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ [b] ++ higher) (stLeft v (seen || b)) higher.length) higher.length =
counterCfg cfg v (lower ++ [b] ++ higher) (stLeft v (seen || b || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ [b] ++ higher) (stLeft v (seen || b)) higher.length) higher.length = []⊢ configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (b :: higher).length) (b :: higher).length =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || (b :: higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (b :: higher).length)
(b :: higher).length =
[]
simp only [List.append_assoc, List.singleton_append] at hc hout input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ higher) (stLeft v (seen || higher.any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length = []lower:List Boolseen:Boolhs:step (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length = []⊢ configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (b :: higher).length) (b :: higher).length =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || (b :: higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (b :: higher).length)
(b :: higher).length =
[]
constructor left input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ higher) (stLeft v (seen || higher.any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length = []lower:List Boolseen:Boolhs:step (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length = []⊢ configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (b :: higher).length) (b :: higher).length =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || (b :: higher).any id)) 0right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ higher) (stLeft v (seen || higher.any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length = []lower:List Boolseen:Boolhs:step (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length = []⊢ machine.outputString (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (b :: higher).length)
(b :: higher).length =
[]
· left input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ higher) (stLeft v (seen || higher.any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length = []lower:List Boolseen:Boolhs:step (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length = []⊢ configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (b :: higher).length) (b :: higher).length =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || (b :: higher).any id)) 0 rw [List.length_cons, left input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ higher) (stLeft v (seen || higher.any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length = []lower:List Boolseen:Boolhs:step (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length = []⊢ configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) (higher.length + 1) =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || (b :: higher).any id)) 0 configs_succ_eq_step, left input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ higher) (stLeft v (seen || higher.any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length = []lower:List Boolseen:Boolhs:step (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length = []⊢ configs (step (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1))) higher.length =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || (b :: higher).any id)) 0 hs, left input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ higher) (stLeft v (seen || higher.any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length = []lower:List Boolseen:Boolhs:step (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length = []⊢ configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || (b :: higher).any id)) 0 hc left input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ higher) (stLeft v (seen || higher.any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length = []lower:List Boolseen:Boolhs:step (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length = []⊢ counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b || higher.any id)) 0 =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || (b :: higher).any id)) 0] left input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ higher) (stLeft v (seen || higher.any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length = []lower:List Boolseen:Boolhs:step (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length = []⊢ counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b || higher.any id)) 0 =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || (b :: higher).any id)) 0
simp only [List.any_cons, id_eq, Bool.or_assoc] All goals completed! 🐙
· right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ higher) (stLeft v (seen || higher.any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length = []lower:List Boolseen:Boolhs:step (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length = []⊢ machine.outputString (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (b :: higher).length)
(b :: higher).length =
[] let current := counterCfg cfg v (lower ++ b :: higher)
(stLeft v seen) (higher.length + 1) right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ higher) (stLeft v (seen || higher.any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length = []lower:List Boolseen:Boolhs:step (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)⊢ machine.outputString (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (b :: higher).length)
(b :: higher).length =
[]
change machine.outputString current (higher.length + 1) = [] right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ higher) (stLeft v (seen || higher.any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length = []lower:List Boolseen:Boolhs:step (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)⊢ machine.outputString current (higher.length + 1) = []
rw [show higher.length + 1 = 1 + higher.length by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Bool⊢ ∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ higher) (stLeft v (seen || higher.any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length = [] omega All goals completed! 🐙, outputString_add_eq_append right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ higher) (stLeft v (seen || higher.any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length = []lower:List Boolseen:Boolhs:step (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)⊢ machine.outputString current 1 ++ machine.outputString (configs current 1) higher.length = []] right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ higher) (stLeft v (seen || higher.any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length = []lower:List Boolseen:Boolhs:step (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)⊢ machine.outputString current 1 ++ machine.outputString (configs current 1) higher.length = []
have hone : machine.outputString current 1 = [] := by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Bool⊢ ∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ higher) (stLeft v (seen || higher.any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length = []
rw [show 1 = 0 + 1 from rfl, input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ higher) (stLeft v (seen || higher.any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length = []lower:List Boolseen:Boolhs:step (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)⊢ machine.outputString current (0 + 1) = [] outputString_succ, input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ higher) (stLeft v (seen || higher.any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length = []lower:List Boolseen:Boolhs:step (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)⊢ machine.outputString current 0 ++ (outputSymbol (configs current 0)).toList = [] configs_zero, input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ higher) (stLeft v (seen || higher.any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length = []lower:List Boolseen:Boolhs:step (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)⊢ machine.outputString current 0 ++ (outputSymbol current).toList = [] ho input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ higher) (stLeft v (seen || higher.any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length = []lower:List Boolseen:Boolhs:step (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)⊢ machine.outputString current 0 ++ none.toList = []] input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ higher) (stLeft v (seen || higher.any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length = []lower:List Boolseen:Boolhs:step (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)⊢ machine.outputString current 0 ++ none.toList = []
rfl right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ higher) (stLeft v (seen || higher.any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length = []lower:List Boolseen:Boolhs:step (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)hone:machine.outputString current 1 = []⊢ machine.outputString current 1 ++ machine.outputString (configs current 1) higher.length = []
rw [hone right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ higher) (stLeft v (seen || higher.any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length = []lower:List Boolseen:Boolhs:step (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)hone:machine.outputString current 1 = []⊢ [] ++ machine.outputString (configs current 1) higher.length = []] right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ higher) (stLeft v (seen || higher.any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length = []lower:List Boolseen:Boolhs:step (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)hone:machine.outputString current 1 = []⊢ [] ++ machine.outputString (configs current 1) higher.length = []
change [] ++ machine.outputString (machine.step current) higher.length = [] right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ higher) (stLeft v (seen || higher.any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length = []lower:List Boolseen:Boolhs:step (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)hone:machine.outputString current 1 = []⊢ [] ++ machine.outputString (step current) higher.length = []
rw [hs, right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ higher) (stLeft v (seen || higher.any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length = []lower:List Boolseen:Boolhs:step (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)hone:machine.outputString current 1 = []⊢ [] ++
machine.outputString (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length =
[] hout right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ higher) (stLeft v (seen || higher.any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length = []lower:List Boolseen:Boolhs:step (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)hone:machine.outputString current 1 = []⊢ [] ++ [] = []] right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ higher) (stLeft v (seen || higher.any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) higher.length = []lower:List Boolseen:Boolhs:step (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length =
counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1)hone:machine.outputString current 1 = []⊢ [] ++ [] = []
rfl All goals completed! 🐙The rightward scan crosses every represented digit without inspecting its value.
theorem right_pos_run {input : List (Fin 3)} (cfg : Cfg 4 (Fin 3) Control input)
(v seen : Bool) (bs : List Bool) (j : ℕ) (hj : j < bs.length) :
machine.step (counterCfg cfg v bs (stRight v seen) (j + 1)) =
counterCfg cfg v bs (stRight v seen) (j + 2) ∧
machine.outputSymbol (counterCfg cfg v bs (stRight v seen) (j + 1)) = none := by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolj:ℕhj:j < bs.length⊢ step (counterCfg cfg v bs (stRight v seen) (j + 1)) = counterCfg cfg v bs (stRight v seen) (j + 2) ∧
outputSymbol (counterCfg cfg v bs (stRight v seen) (j + 1)) = none
apply counterAction_none_run (d := 1) htr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolj:ℕhj:j < bs.length⊢ machine.tr (stRight v seen) (counterCfg cfg v bs (stRight v seen) (j + 1)).inputSymbol
(counterCfg cfg v bs (stRight v seen) (j + 1)).workTapeSymbols =
counterAction v none 1 (stRight v seen)hp input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolj:ℕhj:j < bs.length⊢ ↑(j + 1) + ↑1 = ↑(j + 2)
· htr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolj:ℕhj:j < bs.length⊢ machine.tr (stRight v seen) (counterCfg cfg v bs (stRight v seen) (j + 1)).inputSymbol
(counterCfg cfg v bs (stRight v seen) (j + 1)).workTapeSymbols =
counterAction v none 1 (stRight v seen) rw [tr_right htr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolj:ℕhj:j < bs.length⊢ sweepRight v seen (counterCfg cfg v bs (stRight v seen) (j + 1)).workTapeSymbols =
counterAction v none 1 (stRight v seen)] htr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolj:ℕhj:j < bs.length⊢ sweepRight v seen (counterCfg cfg v bs (stRight v seen) (j + 1)).workTapeSymbols =
counterAction v none 1 (stRight v seen)
have hr : (counterCfg cfg v bs (stRight v seen) (j + 1)).workTapeSymbols
(counterTape v) ≠ none := by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolj:ℕhj:j < bs.length⊢ step (counterCfg cfg v bs (stRight v seen) (j + 1)) = counterCfg cfg v bs (stRight v seen) (j + 2) ∧
outputSymbol (counterCfg cfg v bs (stRight v seen) (j + 1)) = none
simp only [Cfg.workTapeSymbols, counterCfg, ite_true, wordTape_succ] input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolj:ℕhj:j < bs.length⊢ Option.map (⇑boolEmb) bs.reverse[j]? ≠ none
rw [List.getElem?_eq_getElem (by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolj:ℕhj:j < bs.length⊢ j < bs.reverse.length simpa only [List.length_reverse] using hj All goals completed! 🐙)] input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolj:ℕhj:j < bs.length⊢ Option.map (⇑boolEmb) (some bs.reverse[j]) ≠ none
simp htr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolj:ℕhj:j < bs.lengthhr:(counterCfg cfg v bs (stRight v seen) (j + 1)).workTapeSymbols (counterTape v) ≠ none⊢ sweepRight v seen (counterCfg cfg v bs (stRight v seen) (j + 1)).workTapeSymbols =
counterAction v none 1 (stRight v seen)
simp only [sweepRight, beq_iff_eq, hr, ↓reduceIte] All goals completed! 🐙
· hp input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolj:ℕhj:j < bs.length⊢ ↑(j + 1) + ↑1 = ↑(j + 2) simp hp input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolj:ℕhj:j < bs.length⊢ ↑j + 1 + 1 = ↑j + 2
omega All goals completed! 🐙Reaching the right-hand blank completes the countdown.
theorem right_end_run {input : List (Fin 3)} (cfg : Cfg 4 (Fin 3) Control input)
(v seen : Bool) (bs : List Bool) :
machine.step (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputSymbol (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) = none := by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Bool⊢ step (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
outputSymbol (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) = none
apply counterAction_none_run (d := 0) htr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Bool⊢ machine.tr (stRight v seen) (counterCfg cfg v bs (stRight v seen) (bs.length + 1)).inputSymbol
(counterCfg cfg v bs (stRight v seen) (bs.length + 1)).workTapeSymbols =
counterAction v none 0 (afterDecrement v seen)hp input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Bool⊢ ↑(bs.length + 1) + ↑0 = ↑(bs.length + 1)
· htr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Bool⊢ machine.tr (stRight v seen) (counterCfg cfg v bs (stRight v seen) (bs.length + 1)).inputSymbol
(counterCfg cfg v bs (stRight v seen) (bs.length + 1)).workTapeSymbols =
counterAction v none 0 (afterDecrement v seen) rw [tr_right htr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Bool⊢ sweepRight v seen (counterCfg cfg v bs (stRight v seen) (bs.length + 1)).workTapeSymbols =
counterAction v none 0 (afterDecrement v seen)] htr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Bool⊢ sweepRight v seen (counterCfg cfg v bs (stRight v seen) (bs.length + 1)).workTapeSymbols =
counterAction v none 0 (afterDecrement v seen)
have hr : (counterCfg cfg v bs (stRight v seen) (bs.length + 1)).workTapeSymbols
(counterTape v) = none := by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Bool⊢ step (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
outputSymbol (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) = none
simpa only [Cfg.workTapeSymbols, counterCfg, ite_true] using wordTape_end bs htr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolhr:(counterCfg cfg v bs (stRight v seen) (bs.length + 1)).workTapeSymbols (counterTape v) = none⊢ sweepRight v seen (counterCfg cfg v bs (stRight v seen) (bs.length + 1)).workTapeSymbols =
counterAction v none 0 (afterDecrement v seen)
simp [sweepRight, hr, counterAction, jump] All goals completed! 🐙
· hp input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Bool⊢ ↑(bs.length + 1) + ↑0 = ↑(bs.length + 1) simp All goals completed! 🐙Starting inside the word, the rightward scan reaches its blank and resumes decoding.
theorem configs_right {input : List (Fin 3)} (cfg : Cfg 4 (Fin 3) Control input)
(v seen : Bool) (bs : List Bool) (t : ℕ) : ∀ p, 0 < p → p + t = bs.length + 1 →
machine.configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = [] := by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt:ℕ⊢ ∀ (p : ℕ),
0 < p →
p + t = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = []
apply Nat.rec (motive := fun t ↦ ∀ p, 0 < p → p + t = bs.length + 1 →
machine.configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = []) ?_ ?_ t input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt:ℕ⊢ ∀ (p : ℕ),
0 < p →
p + Nat.zero = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (Nat.zero + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (Nat.zero + 1) = []input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt:ℕ⊢ ∀ (n : ℕ),
(∀ (p : ℕ),
0 < p →
p + n = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (n + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (n + 1) = []) →
∀ (p : ℕ),
0 < p →
p + n.succ = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (n.succ + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (n.succ + 1) = []
· input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt:ℕ⊢ ∀ (p : ℕ),
0 < p →
p + Nat.zero = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (Nat.zero + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (Nat.zero + 1) = [] intro p _ hp input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt:ℕp:ℕa✝:0 < php:p + Nat.zero = bs.length + 1⊢ configs (counterCfg cfg v bs (stRight v seen) p) (Nat.zero + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (Nat.zero + 1) = []
have he : p = bs.length + 1 := by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt:ℕ⊢ ∀ (p : ℕ),
0 < p →
p + t = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = [] omega input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt:ℕp:ℕa✝:0 < php:p + Nat.zero = bs.length + 1he:p = bs.length + 1⊢ configs (counterCfg cfg v bs (stRight v seen) p) (Nat.zero + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (Nat.zero + 1) = []
subst p input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt:ℕa✝:0 < bs.length + 1hp:bs.length + 1 + Nat.zero = bs.length + 1⊢ configs (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) (Nat.zero + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) (Nat.zero + 1) = []
obtain ⟨hs, ho⟩ := right_end_run cfg v seen bs input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt:ℕa✝:0 < bs.length + 1hp:bs.length + 1 + Nat.zero = bs.length + 1hs:step (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1)ho:outputSymbol (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) = none⊢ configs (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) (Nat.zero + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) (Nat.zero + 1) = []
constructor left input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt:ℕa✝:0 < bs.length + 1hp:bs.length + 1 + Nat.zero = bs.length + 1hs:step (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1)ho:outputSymbol (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) = none⊢ configs (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) (Nat.zero + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1)right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt:ℕa✝:0 < bs.length + 1hp:bs.length + 1 + Nat.zero = bs.length + 1hs:step (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1)ho:outputSymbol (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) = none⊢ machine.outputString (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) (Nat.zero + 1) = []
· left input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt:ℕa✝:0 < bs.length + 1hp:bs.length + 1 + Nat.zero = bs.length + 1hs:step (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1)ho:outputSymbol (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) = none⊢ configs (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) (Nat.zero + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) exact hs All goals completed! 🐙
· right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt:ℕa✝:0 < bs.length + 1hp:bs.length + 1 + Nat.zero = bs.length + 1hs:step (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1)ho:outputSymbol (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) = none⊢ machine.outputString (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) (Nat.zero + 1) = [] rw [outputString_succ, right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt:ℕa✝:0 < bs.length + 1hp:bs.length + 1 + Nat.zero = bs.length + 1hs:step (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1)ho:outputSymbol (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) = none⊢ machine.outputString (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) Nat.zero ++
(outputSymbol (configs (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) Nat.zero)).toList =
[] configs_zero, right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt:ℕa✝:0 < bs.length + 1hp:bs.length + 1 + Nat.zero = bs.length + 1hs:step (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1)ho:outputSymbol (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) = none⊢ machine.outputString (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) Nat.zero ++
(outputSymbol (counterCfg cfg v bs (stRight v seen) (bs.length + 1))).toList =
[] ho right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt:ℕa✝:0 < bs.length + 1hp:bs.length + 1 + Nat.zero = bs.length + 1hs:step (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1)ho:outputSymbol (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) = none⊢ machine.outputString (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) Nat.zero ++ none.toList = []] right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt:ℕa✝:0 < bs.length + 1hp:bs.length + 1 + Nat.zero = bs.length + 1hs:step (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1)ho:outputSymbol (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) = none⊢ machine.outputString (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) Nat.zero ++ none.toList = []
rfl All goals completed! 🐙
· input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt:ℕ⊢ ∀ (n : ℕ),
(∀ (p : ℕ),
0 < p →
p + n = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (n + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (n + 1) = []) →
∀ (p : ℕ),
0 < p →
p + n.succ = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (n.succ + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (n.succ + 1) = [] intro t ih p hp hpt input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt✝:ℕt:ℕih:∀ (p : ℕ),
0 < p →
p + t = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = []p:ℕhp:0 < phpt:p + t.succ = bs.length + 1⊢ configs (counterCfg cfg v bs (stRight v seen) p) (t.succ + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t.succ + 1) = []
cases p with
| zero => zero input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt✝:ℕt:ℕih:∀ (p : ℕ),
0 < p →
p + t = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = []hp:0 < 0hpt:0 + t.succ = bs.length + 1⊢ configs (counterCfg cfg v bs (stRight v seen) 0) (t.succ + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) 0) (t.succ + 1) = [] omega All goals completed! 🐙
| succ j => succ input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt✝:ℕt:ℕih:∀ (p : ℕ),
0 < p →
p + t = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = []j:ℕhp:0 < j + 1hpt:j + 1 + t.succ = bs.length + 1⊢ configs (counterCfg cfg v bs (stRight v seen) (j + 1)) (t.succ + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) (j + 1)) (t.succ + 1) = []
obtain ⟨hs, ho⟩ := right_pos_run cfg v seen bs j (by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt✝:ℕt:ℕih:∀ (p : ℕ),
0 < p →
p + t = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = []j:ℕhp:0 < j + 1hpt:j + 1 + t.succ = bs.length + 1⊢ j < bs.length omega All goals completed! 🐙) succ input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt✝:ℕt:ℕih:∀ (p : ℕ),
0 < p →
p + t = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = []j:ℕhp:0 < j + 1hpt:j + 1 + t.succ = bs.length + 1hs:step (counterCfg cfg v bs (stRight v seen) (j + 1)) = counterCfg cfg v bs (stRight v seen) (j + 2)ho:outputSymbol (counterCfg cfg v bs (stRight v seen) (j + 1)) = none⊢ configs (counterCfg cfg v bs (stRight v seen) (j + 1)) (t.succ + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) (j + 1)) (t.succ + 1) = []
obtain ⟨hc, hout⟩ := ih (j + 2) (by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt✝:ℕt:ℕih:∀ (p : ℕ),
0 < p →
p + t = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = []j:ℕhp:0 < j + 1hpt:j + 1 + t.succ = bs.length + 1hs:step (counterCfg cfg v bs (stRight v seen) (j + 1)) = counterCfg cfg v bs (stRight v seen) (j + 2)ho:outputSymbol (counterCfg cfg v bs (stRight v seen) (j + 1)) = none⊢ 0 < j + 2 omega All goals completed! 🐙) (by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt✝:ℕt:ℕih:∀ (p : ℕ),
0 < p →
p + t = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = []j:ℕhp:0 < j + 1hpt:j + 1 + t.succ = bs.length + 1hs:step (counterCfg cfg v bs (stRight v seen) (j + 1)) = counterCfg cfg v bs (stRight v seen) (j + 2)ho:outputSymbol (counterCfg cfg v bs (stRight v seen) (j + 1)) = none⊢ j + 2 + t = bs.length + 1 omega All goals completed! 🐙) succ input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt✝:ℕt:ℕih:∀ (p : ℕ),
0 < p →
p + t = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = []j:ℕhp:0 < j + 1hpt:j + 1 + t.succ = bs.length + 1hs:step (counterCfg cfg v bs (stRight v seen) (j + 1)) = counterCfg cfg v bs (stRight v seen) (j + 2)ho:outputSymbol (counterCfg cfg v bs (stRight v seen) (j + 1)) = nonehc:configs (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1)hout:machine.outputString (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) = []⊢ configs (counterCfg cfg v bs (stRight v seen) (j + 1)) (t.succ + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) (j + 1)) (t.succ + 1) = []
constructor succ.left input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt✝:ℕt:ℕih:∀ (p : ℕ),
0 < p →
p + t = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = []j:ℕhp:0 < j + 1hpt:j + 1 + t.succ = bs.length + 1hs:step (counterCfg cfg v bs (stRight v seen) (j + 1)) = counterCfg cfg v bs (stRight v seen) (j + 2)ho:outputSymbol (counterCfg cfg v bs (stRight v seen) (j + 1)) = nonehc:configs (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1)hout:machine.outputString (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) = []⊢ configs (counterCfg cfg v bs (stRight v seen) (j + 1)) (t.succ + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1)succ.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt✝:ℕt:ℕih:∀ (p : ℕ),
0 < p →
p + t = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = []j:ℕhp:0 < j + 1hpt:j + 1 + t.succ = bs.length + 1hs:step (counterCfg cfg v bs (stRight v seen) (j + 1)) = counterCfg cfg v bs (stRight v seen) (j + 2)ho:outputSymbol (counterCfg cfg v bs (stRight v seen) (j + 1)) = nonehc:configs (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1)hout:machine.outputString (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) = []⊢ machine.outputString (counterCfg cfg v bs (stRight v seen) (j + 1)) (t.succ + 1) = []
· succ.left input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt✝:ℕt:ℕih:∀ (p : ℕ),
0 < p →
p + t = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = []j:ℕhp:0 < j + 1hpt:j + 1 + t.succ = bs.length + 1hs:step (counterCfg cfg v bs (stRight v seen) (j + 1)) = counterCfg cfg v bs (stRight v seen) (j + 2)ho:outputSymbol (counterCfg cfg v bs (stRight v seen) (j + 1)) = nonehc:configs (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1)hout:machine.outputString (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) = []⊢ configs (counterCfg cfg v bs (stRight v seen) (j + 1)) (t.succ + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) rw [configs_succ_eq_step, succ.left input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt✝:ℕt:ℕih:∀ (p : ℕ),
0 < p →
p + t = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = []j:ℕhp:0 < j + 1hpt:j + 1 + t.succ = bs.length + 1hs:step (counterCfg cfg v bs (stRight v seen) (j + 1)) = counterCfg cfg v bs (stRight v seen) (j + 2)ho:outputSymbol (counterCfg cfg v bs (stRight v seen) (j + 1)) = nonehc:configs (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1)hout:machine.outputString (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) = []⊢ configs (step (counterCfg cfg v bs (stRight v seen) (j + 1))) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) hs, succ.left input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt✝:ℕt:ℕih:∀ (p : ℕ),
0 < p →
p + t = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = []j:ℕhp:0 < j + 1hpt:j + 1 + t.succ = bs.length + 1hs:step (counterCfg cfg v bs (stRight v seen) (j + 1)) = counterCfg cfg v bs (stRight v seen) (j + 2)ho:outputSymbol (counterCfg cfg v bs (stRight v seen) (j + 1)) = nonehc:configs (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1)hout:machine.outputString (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) = []⊢ configs (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) hc succ.left input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt✝:ℕt:ℕih:∀ (p : ℕ),
0 < p →
p + t = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = []j:ℕhp:0 < j + 1hpt:j + 1 + t.succ = bs.length + 1hs:step (counterCfg cfg v bs (stRight v seen) (j + 1)) = counterCfg cfg v bs (stRight v seen) (j + 2)ho:outputSymbol (counterCfg cfg v bs (stRight v seen) (j + 1)) = nonehc:configs (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1)hout:machine.outputString (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) = []⊢ counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1)] All goals completed! 🐙
· succ.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt✝:ℕt:ℕih:∀ (p : ℕ),
0 < p →
p + t = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = []j:ℕhp:0 < j + 1hpt:j + 1 + t.succ = bs.length + 1hs:step (counterCfg cfg v bs (stRight v seen) (j + 1)) = counterCfg cfg v bs (stRight v seen) (j + 2)ho:outputSymbol (counterCfg cfg v bs (stRight v seen) (j + 1)) = nonehc:configs (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1)hout:machine.outputString (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) = []⊢ machine.outputString (counterCfg cfg v bs (stRight v seen) (j + 1)) (t.succ + 1) = [] let current := counterCfg cfg v bs (stRight v seen) (j + 1) succ.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt✝:ℕt:ℕih:∀ (p : ℕ),
0 < p →
p + t = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = []j:ℕhp:0 < j + 1hpt:j + 1 + t.succ = bs.length + 1hs:step (counterCfg cfg v bs (stRight v seen) (j + 1)) = counterCfg cfg v bs (stRight v seen) (j + 2)ho:outputSymbol (counterCfg cfg v bs (stRight v seen) (j + 1)) = nonehc:configs (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1)hout:machine.outputString (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v bs (stRight v seen) (j + 1)⊢ machine.outputString (counterCfg cfg v bs (stRight v seen) (j + 1)) (t.succ + 1) = []
change machine.outputString current (t + 1 + 1) = [] succ.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt✝:ℕt:ℕih:∀ (p : ℕ),
0 < p →
p + t = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = []j:ℕhp:0 < j + 1hpt:j + 1 + t.succ = bs.length + 1hs:step (counterCfg cfg v bs (stRight v seen) (j + 1)) = counterCfg cfg v bs (stRight v seen) (j + 2)ho:outputSymbol (counterCfg cfg v bs (stRight v seen) (j + 1)) = nonehc:configs (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1)hout:machine.outputString (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v bs (stRight v seen) (j + 1)⊢ machine.outputString current (t + 1 + 1) = []
rw [show t + 1 + 1 = 1 + (t + 1) by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt:ℕ⊢ ∀ (p : ℕ),
0 < p →
p + t = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = [] omega All goals completed! 🐙, outputString_add_eq_append succ.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt✝:ℕt:ℕih:∀ (p : ℕ),
0 < p →
p + t = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = []j:ℕhp:0 < j + 1hpt:j + 1 + t.succ = bs.length + 1hs:step (counterCfg cfg v bs (stRight v seen) (j + 1)) = counterCfg cfg v bs (stRight v seen) (j + 2)ho:outputSymbol (counterCfg cfg v bs (stRight v seen) (j + 1)) = nonehc:configs (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1)hout:machine.outputString (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v bs (stRight v seen) (j + 1)⊢ machine.outputString current 1 ++ machine.outputString (configs current 1) (t + 1) = []] succ.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt✝:ℕt:ℕih:∀ (p : ℕ),
0 < p →
p + t = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = []j:ℕhp:0 < j + 1hpt:j + 1 + t.succ = bs.length + 1hs:step (counterCfg cfg v bs (stRight v seen) (j + 1)) = counterCfg cfg v bs (stRight v seen) (j + 2)ho:outputSymbol (counterCfg cfg v bs (stRight v seen) (j + 1)) = nonehc:configs (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1)hout:machine.outputString (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v bs (stRight v seen) (j + 1)⊢ machine.outputString current 1 ++ machine.outputString (configs current 1) (t + 1) = []
have hone : machine.outputString current 1 = [] := by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt:ℕ⊢ ∀ (p : ℕ),
0 < p →
p + t = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = []
rw [show 1 = 0 + 1 from rfl, input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt✝:ℕt:ℕih:∀ (p : ℕ),
0 < p →
p + t = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = []j:ℕhp:0 < j + 1hpt:j + 1 + t.succ = bs.length + 1hs:step (counterCfg cfg v bs (stRight v seen) (j + 1)) = counterCfg cfg v bs (stRight v seen) (j + 2)ho:outputSymbol (counterCfg cfg v bs (stRight v seen) (j + 1)) = nonehc:configs (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1)hout:machine.outputString (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v bs (stRight v seen) (j + 1)⊢ machine.outputString current (0 + 1) = [] outputString_succ, input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt✝:ℕt:ℕih:∀ (p : ℕ),
0 < p →
p + t = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = []j:ℕhp:0 < j + 1hpt:j + 1 + t.succ = bs.length + 1hs:step (counterCfg cfg v bs (stRight v seen) (j + 1)) = counterCfg cfg v bs (stRight v seen) (j + 2)ho:outputSymbol (counterCfg cfg v bs (stRight v seen) (j + 1)) = nonehc:configs (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1)hout:machine.outputString (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v bs (stRight v seen) (j + 1)⊢ machine.outputString current 0 ++ (outputSymbol (configs current 0)).toList = [] configs_zero, input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt✝:ℕt:ℕih:∀ (p : ℕ),
0 < p →
p + t = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = []j:ℕhp:0 < j + 1hpt:j + 1 + t.succ = bs.length + 1hs:step (counterCfg cfg v bs (stRight v seen) (j + 1)) = counterCfg cfg v bs (stRight v seen) (j + 2)ho:outputSymbol (counterCfg cfg v bs (stRight v seen) (j + 1)) = nonehc:configs (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1)hout:machine.outputString (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v bs (stRight v seen) (j + 1)⊢ machine.outputString current 0 ++ (outputSymbol current).toList = [] ho input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt✝:ℕt:ℕih:∀ (p : ℕ),
0 < p →
p + t = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = []j:ℕhp:0 < j + 1hpt:j + 1 + t.succ = bs.length + 1hs:step (counterCfg cfg v bs (stRight v seen) (j + 1)) = counterCfg cfg v bs (stRight v seen) (j + 2)ho:outputSymbol (counterCfg cfg v bs (stRight v seen) (j + 1)) = nonehc:configs (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1)hout:machine.outputString (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v bs (stRight v seen) (j + 1)⊢ machine.outputString current 0 ++ none.toList = []] input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt✝:ℕt:ℕih:∀ (p : ℕ),
0 < p →
p + t = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = []j:ℕhp:0 < j + 1hpt:j + 1 + t.succ = bs.length + 1hs:step (counterCfg cfg v bs (stRight v seen) (j + 1)) = counterCfg cfg v bs (stRight v seen) (j + 2)ho:outputSymbol (counterCfg cfg v bs (stRight v seen) (j + 1)) = nonehc:configs (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1)hout:machine.outputString (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v bs (stRight v seen) (j + 1)⊢ machine.outputString current 0 ++ none.toList = []
rfl succ.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt✝:ℕt:ℕih:∀ (p : ℕ),
0 < p →
p + t = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = []j:ℕhp:0 < j + 1hpt:j + 1 + t.succ = bs.length + 1hs:step (counterCfg cfg v bs (stRight v seen) (j + 1)) = counterCfg cfg v bs (stRight v seen) (j + 2)ho:outputSymbol (counterCfg cfg v bs (stRight v seen) (j + 1)) = nonehc:configs (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1)hout:machine.outputString (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v bs (stRight v seen) (j + 1)hone:machine.outputString current 1 = []⊢ machine.outputString current 1 ++ machine.outputString (configs current 1) (t + 1) = []
rw [hone succ.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt✝:ℕt:ℕih:∀ (p : ℕ),
0 < p →
p + t = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = []j:ℕhp:0 < j + 1hpt:j + 1 + t.succ = bs.length + 1hs:step (counterCfg cfg v bs (stRight v seen) (j + 1)) = counterCfg cfg v bs (stRight v seen) (j + 2)ho:outputSymbol (counterCfg cfg v bs (stRight v seen) (j + 1)) = nonehc:configs (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1)hout:machine.outputString (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v bs (stRight v seen) (j + 1)hone:machine.outputString current 1 = []⊢ [] ++ machine.outputString (configs current 1) (t + 1) = []] succ.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt✝:ℕt:ℕih:∀ (p : ℕ),
0 < p →
p + t = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = []j:ℕhp:0 < j + 1hpt:j + 1 + t.succ = bs.length + 1hs:step (counterCfg cfg v bs (stRight v seen) (j + 1)) = counterCfg cfg v bs (stRight v seen) (j + 2)ho:outputSymbol (counterCfg cfg v bs (stRight v seen) (j + 1)) = nonehc:configs (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1)hout:machine.outputString (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v bs (stRight v seen) (j + 1)hone:machine.outputString current 1 = []⊢ [] ++ machine.outputString (configs current 1) (t + 1) = []
change [] ++ machine.outputString (machine.step current) (t + 1) = [] succ.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt✝:ℕt:ℕih:∀ (p : ℕ),
0 < p →
p + t = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = []j:ℕhp:0 < j + 1hpt:j + 1 + t.succ = bs.length + 1hs:step (counterCfg cfg v bs (stRight v seen) (j + 1)) = counterCfg cfg v bs (stRight v seen) (j + 2)ho:outputSymbol (counterCfg cfg v bs (stRight v seen) (j + 1)) = nonehc:configs (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1)hout:machine.outputString (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v bs (stRight v seen) (j + 1)hone:machine.outputString current 1 = []⊢ [] ++ machine.outputString (step current) (t + 1) = []
rw [hs, succ.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt✝:ℕt:ℕih:∀ (p : ℕ),
0 < p →
p + t = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = []j:ℕhp:0 < j + 1hpt:j + 1 + t.succ = bs.length + 1hs:step (counterCfg cfg v bs (stRight v seen) (j + 1)) = counterCfg cfg v bs (stRight v seen) (j + 2)ho:outputSymbol (counterCfg cfg v bs (stRight v seen) (j + 1)) = nonehc:configs (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1)hout:machine.outputString (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v bs (stRight v seen) (j + 1)hone:machine.outputString current 1 = []⊢ [] ++ machine.outputString (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) = [] hout succ.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt✝:ℕt:ℕih:∀ (p : ℕ),
0 < p →
p + t = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = []j:ℕhp:0 < j + 1hpt:j + 1 + t.succ = bs.length + 1hs:step (counterCfg cfg v bs (stRight v seen) (j + 1)) = counterCfg cfg v bs (stRight v seen) (j + 2)ho:outputSymbol (counterCfg cfg v bs (stRight v seen) (j + 1)) = nonehc:configs (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1)hout:machine.outputString (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v bs (stRight v seen) (j + 1)hone:machine.outputString current 1 = []⊢ [] ++ [] = []] succ.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolt✝:ℕt:ℕih:∀ (p : ℕ),
0 < p →
p + t = bs.length + 1 →
configs (counterCfg cfg v bs (stRight v seen) p) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stRight v seen) p) (t + 1) = []j:ℕhp:0 < j + 1hpt:j + 1 + t.succ = bs.length + 1hs:step (counterCfg cfg v bs (stRight v seen) (j + 1)) = counterCfg cfg v bs (stRight v seen) (j + 2)ho:outputSymbol (counterCfg cfg v bs (stRight v seen) (j + 1)) = nonehc:configs (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) =
counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1)hout:machine.outputString (counterCfg cfg v bs (stRight v seen) (j + 2)) (t + 1) = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v bs (stRight v seen) (j + 1)hone:machine.outputString current 1 = []⊢ [] ++ [] = []
rfl All goals completed! 🐙Borrowing across a zero sets that digit and continues toward the origin.
theorem borrow_false_run {input : List (Fin 3)} (cfg : Cfg 4 (Fin 3) Control input)
(v seen : Bool) (lower higher : List Bool) :
machine.step (counterCfg cfg v (lower ++ false :: higher)
(stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length ∧
machine.outputSymbol (counterCfg cfg v (lower ++ false :: higher)
(stBorrow v seen) (higher.length + 1)) = none := by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boollower:List Boolhigher:List Bool⊢ step (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length ∧
outputSymbol (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) = none
apply counterAction_write_run (d := -1) (b := true) htr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boollower:List Boolhigher:List Bool⊢ machine.tr (stBorrow v seen)
(counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)).inputSymbol
(counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)).workTapeSymbols =
counterAction v (some (some (boolEmb true))) (-1) (stBorrow v true)hp input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boollower:List Boolhigher:List Bool⊢ ↑(higher.length + 1) + ↑(-1) = ↑higher.lengthhw input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boollower:List Boolhigher:List Bool⊢ Function.update (wordTape (lower ++ false :: higher)) (↑(higher.length + 1)) (some (boolEmb true)) =
wordTape (lower ++ true :: higher)
· htr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boollower:List Boolhigher:List Bool⊢ machine.tr (stBorrow v seen)
(counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)).inputSymbol
(counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)).workTapeSymbols =
counterAction v (some (some (boolEmb true))) (-1) (stBorrow v true) rw [tr_borrow htr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boollower:List Boolhigher:List Bool⊢ borrow v seen (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)).workTapeSymbols =
counterAction v (some (some (boolEmb true))) (-1) (stBorrow v true)] htr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boollower:List Boolhigher:List Bool⊢ borrow v seen (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)).workTapeSymbols =
counterAction v (some (some (boolEmb true))) (-1) (stBorrow v true)
have hr : (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen)
(higher.length + 1)).workTapeSymbols (counterTape v) = some (boolEmb false) := by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boollower:List Boolhigher:List Bool⊢ step (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length ∧
outputSymbol (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) = none
simpa only [Cfg.workTapeSymbols, counterCfg, ite_true] using wordTape_split lower higher false htr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boollower:List Boolhigher:List Boolhr:(counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)).workTapeSymbols (counterTape v) =
some (boolEmb false)⊢ borrow v seen (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)).workTapeSymbols =
counterAction v (some (some (boolEmb true))) (-1) (stBorrow v true)
simp only [borrow, hr] htr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boollower:List Boolhigher:List Boolhr:(counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)).workTapeSymbols (counterTape v) =
some (boolEmb false)⊢ (if (some (boolEmb false) == some 2) = true then finish false
else
if (some (boolEmb false) == some 1) = true then counterAction v (some (some 0)) (-1) (stLeft v seen)
else counterAction v (some (some 1)) (-1) (stBorrow v true)) =
counterAction v (some (some (boolEmb true))) (-1) (stBorrow v true)
rfl All goals completed! 🐙
· hp input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boollower:List Boolhigher:List Bool⊢ ↑(higher.length + 1) + ↑(-1) = ↑higher.length simp All goals completed! 🐙
· hw input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boollower:List Boolhigher:List Bool⊢ Function.update (wordTape (lower ++ false :: higher)) (↑(higher.length + 1)) (some (boolEmb true)) =
wordTape (lower ++ true :: higher) exact wordTape_update_split lower higher false true All goals completed! 🐙Borrowing stops at the first one, clearing it before the leftward scan.
theorem borrow_true_run {input : List (Fin 3)} (cfg : Cfg 4 (Fin 3) Control input)
(v seen : Bool) (lower higher : List Bool) :
machine.step (counterCfg cfg v (lower ++ true :: higher)
(stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length ∧
machine.outputSymbol (counterCfg cfg v (lower ++ true :: higher)
(stBorrow v seen) (higher.length + 1)) = none := by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boollower:List Boolhigher:List Bool⊢ step (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length ∧
outputSymbol (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) = none
apply counterAction_write_run (d := -1) (b := false) htr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boollower:List Boolhigher:List Bool⊢ machine.tr (stBorrow v seen)
(counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)).inputSymbol
(counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)).workTapeSymbols =
counterAction v (some (some (boolEmb false))) (-1) (stLeft v seen)hp input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boollower:List Boolhigher:List Bool⊢ ↑(higher.length + 1) + ↑(-1) = ↑higher.lengthhw input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boollower:List Boolhigher:List Bool⊢ Function.update (wordTape (lower ++ true :: higher)) (↑(higher.length + 1)) (some (boolEmb false)) =
wordTape (lower ++ false :: higher)
· htr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boollower:List Boolhigher:List Bool⊢ machine.tr (stBorrow v seen)
(counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)).inputSymbol
(counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)).workTapeSymbols =
counterAction v (some (some (boolEmb false))) (-1) (stLeft v seen) rw [tr_borrow htr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boollower:List Boolhigher:List Bool⊢ borrow v seen (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)).workTapeSymbols =
counterAction v (some (some (boolEmb false))) (-1) (stLeft v seen)] htr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boollower:List Boolhigher:List Bool⊢ borrow v seen (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)).workTapeSymbols =
counterAction v (some (some (boolEmb false))) (-1) (stLeft v seen)
have hr : (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen)
(higher.length + 1)).workTapeSymbols (counterTape v) = some (boolEmb true) := by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boollower:List Boolhigher:List Bool⊢ step (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length ∧
outputSymbol (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) = none
simpa only [Cfg.workTapeSymbols, counterCfg, ite_true] using wordTape_split lower higher true htr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boollower:List Boolhigher:List Boolhr:(counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)).workTapeSymbols (counterTape v) =
some (boolEmb true)⊢ borrow v seen (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)).workTapeSymbols =
counterAction v (some (some (boolEmb false))) (-1) (stLeft v seen)
simp only [borrow, hr] htr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boollower:List Boolhigher:List Boolhr:(counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)).workTapeSymbols (counterTape v) =
some (boolEmb true)⊢ (if (some (boolEmb true) == some 2) = true then finish false
else
if (some (boolEmb true) == some 1) = true then counterAction v (some (some 0)) (-1) (stLeft v seen)
else counterAction v (some (some 1)) (-1) (stBorrow v true)) =
counterAction v (some (some (boolEmb false))) (-1) (stLeft v seen)
rfl All goals completed! 🐙
· hp input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boollower:List Boolhigher:List Bool⊢ ↑(higher.length + 1) + ↑(-1) = ↑higher.length simp All goals completed! 🐙
· hw input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boollower:List Boolhigher:List Bool⊢ Function.update (wordTape (lower ++ true :: higher)) (↑(higher.length + 1)) (some (boolEmb false)) =
wordTape (lower ++ false :: higher) exact wordTape_update_split lower higher true false All goals completed! 🐙Borrowing and the subsequent scan together visit each remaining digit exactly once.
theorem configs_borrow {input : List (Fin 3)} (cfg : Cfg 4 (Fin 3) Control input)
(v : Bool) (higher : List Bool) : ∀ lower seen, 0 < Counter.value higher →
machine.configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length)
higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher)
(stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length)
higher.length = [] := by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Bool⊢ ∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []
apply List.rec (motive := fun higher ↦ ∀ lower seen, 0 < Counter.value higher →
machine.configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length)
higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher)
(stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length)
higher.length = []) ?_ ?_ higher input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Bool⊢ ∀ (lower : List Bool) (seen : Bool),
0 < Counter.value [] →
configs (counterCfg cfg v (lower ++ []) (stBorrow v seen) [].length) [].length =
counterCfg cfg v (lower ++ Counter.decrement []) (stLeft v (seen || (Counter.decrement []).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ []) (stBorrow v seen) [].length) [].length = []input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Bool⊢ ∀ (head : Bool) (tail : List Bool),
(∀ (lower : List Bool) (seen : Bool),
0 < Counter.value tail →
configs (counterCfg cfg v (lower ++ tail) (stBorrow v seen) tail.length) tail.length =
counterCfg cfg v (lower ++ Counter.decrement tail) (stLeft v (seen || (Counter.decrement tail).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ tail) (stBorrow v seen) tail.length) tail.length = []) →
∀ (lower : List Bool) (seen : Bool),
0 < Counter.value (head :: tail) →
configs (counterCfg cfg v (lower ++ head :: tail) (stBorrow v seen) (head :: tail).length)
(head :: tail).length =
counterCfg cfg v (lower ++ Counter.decrement (head :: tail))
(stLeft v (seen || (Counter.decrement (head :: tail)).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ head :: tail) (stBorrow v seen) (head :: tail).length)
(head :: tail).length =
[]
· input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Bool⊢ ∀ (lower : List Bool) (seen : Bool),
0 < Counter.value [] →
configs (counterCfg cfg v (lower ++ []) (stBorrow v seen) [].length) [].length =
counterCfg cfg v (lower ++ Counter.decrement []) (stLeft v (seen || (Counter.decrement []).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ []) (stBorrow v seen) [].length) [].length = [] intro lower seen h input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Boollower:List Boolseen:Boolh:0 < Counter.value []⊢ configs (counterCfg cfg v (lower ++ []) (stBorrow v seen) [].length) [].length =
counterCfg cfg v (lower ++ Counter.decrement []) (stLeft v (seen || (Counter.decrement []).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ []) (stBorrow v seen) [].length) [].length = []
simp [Counter.value] at h All goals completed! 🐙
· input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Bool⊢ ∀ (head : Bool) (tail : List Bool),
(∀ (lower : List Bool) (seen : Bool),
0 < Counter.value tail →
configs (counterCfg cfg v (lower ++ tail) (stBorrow v seen) tail.length) tail.length =
counterCfg cfg v (lower ++ Counter.decrement tail) (stLeft v (seen || (Counter.decrement tail).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ tail) (stBorrow v seen) tail.length) tail.length = []) →
∀ (lower : List Bool) (seen : Bool),
0 < Counter.value (head :: tail) →
configs (counterCfg cfg v (lower ++ head :: tail) (stBorrow v seen) (head :: tail).length)
(head :: tail).length =
counterCfg cfg v (lower ++ Counter.decrement (head :: tail))
(stLeft v (seen || (Counter.decrement (head :: tail)).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ head :: tail) (stBorrow v seen) (head :: tail).length)
(head :: tail).length =
[] intro b higher ih lower seen h input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (b :: higher)⊢ configs (counterCfg cfg v (lower ++ b :: higher) (stBorrow v seen) (b :: higher).length) (b :: higher).length =
counterCfg cfg v (lower ++ Counter.decrement (b :: higher))
(stLeft v (seen || (Counter.decrement (b :: higher)).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ b :: higher) (stBorrow v seen) (b :: higher).length)
(b :: higher).length =
[]
cases b with
| false => false input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (false :: higher)⊢ configs (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (false :: higher).length)
(false :: higher).length =
counterCfg cfg v (lower ++ Counter.decrement (false :: higher))
(stLeft v (seen || (Counter.decrement (false :: higher)).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (false :: higher).length)
(false :: higher).length =
[]
have hh : 0 < Counter.value higher := by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Bool⊢ ∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []
rw [Counter.value_cons input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < 2 * Counter.value higher + false.toNat⊢ 0 < Counter.value higher] at h input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < 2 * Counter.value higher + false.toNat⊢ 0 < Counter.value higher
simp only [Bool.toNat_false] at h input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < 2 * Counter.value higher + 0⊢ 0 < Counter.value higher
omega false input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (false :: higher)hh:0 < Counter.value higher⊢ configs (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (false :: higher).length)
(false :: higher).length =
counterCfg cfg v (lower ++ Counter.decrement (false :: higher))
(stLeft v (seen || (Counter.decrement (false :: higher)).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (false :: higher).length)
(false :: higher).length =
[]
obtain ⟨hs, ho⟩ := borrow_false_run cfg v seen lower higher false input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (false :: higher)hh:0 < Counter.value higherhs:step (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) = none⊢ configs (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (false :: higher).length)
(false :: higher).length =
counterCfg cfg v (lower ++ Counter.decrement (false :: higher))
(stLeft v (seen || (Counter.decrement (false :: higher)).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (false :: higher).length)
(false :: higher).length =
[]
obtain ⟨hc, hout⟩ := ih (lower ++ [true]) true hh false input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (false :: higher)hh:0 < Counter.value higherhs:step (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ [true] ++ higher) (stBorrow v true) higher.length) higher.length =
counterCfg cfg v (lower ++ [true] ++ Counter.decrement higher) (stLeft v (true || (Counter.decrement higher).any id))
0hout:machine.outputString (counterCfg cfg v (lower ++ [true] ++ higher) (stBorrow v true) higher.length) higher.length = []⊢ configs (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (false :: higher).length)
(false :: higher).length =
counterCfg cfg v (lower ++ Counter.decrement (false :: higher))
(stLeft v (seen || (Counter.decrement (false :: higher)).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (false :: higher).length)
(false :: higher).length =
[]
simp only [List.append_assoc, List.singleton_append, Bool.true_or] at hc hout false input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (false :: higher)hh:0 < Counter.value higherhs:step (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length =
counterCfg cfg v (lower ++ true :: Counter.decrement higher) (stLeft v true) 0hout:machine.outputString (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length = []⊢ configs (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (false :: higher).length)
(false :: higher).length =
counterCfg cfg v (lower ++ Counter.decrement (false :: higher))
(stLeft v (seen || (Counter.decrement (false :: higher)).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (false :: higher).length)
(false :: higher).length =
[]
constructor false.left input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (false :: higher)hh:0 < Counter.value higherhs:step (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length =
counterCfg cfg v (lower ++ true :: Counter.decrement higher) (stLeft v true) 0hout:machine.outputString (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length = []⊢ configs (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (false :: higher).length)
(false :: higher).length =
counterCfg cfg v (lower ++ Counter.decrement (false :: higher))
(stLeft v (seen || (Counter.decrement (false :: higher)).any id)) 0false.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (false :: higher)hh:0 < Counter.value higherhs:step (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length =
counterCfg cfg v (lower ++ true :: Counter.decrement higher) (stLeft v true) 0hout:machine.outputString (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length = []⊢ machine.outputString (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (false :: higher).length)
(false :: higher).length =
[]
· false.left input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (false :: higher)hh:0 < Counter.value higherhs:step (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length =
counterCfg cfg v (lower ++ true :: Counter.decrement higher) (stLeft v true) 0hout:machine.outputString (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length = []⊢ configs (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (false :: higher).length)
(false :: higher).length =
counterCfg cfg v (lower ++ Counter.decrement (false :: higher))
(stLeft v (seen || (Counter.decrement (false :: higher)).any id)) 0 rw [List.length_cons, false.left input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (false :: higher)hh:0 < Counter.value higherhs:step (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length =
counterCfg cfg v (lower ++ true :: Counter.decrement higher) (stLeft v true) 0hout:machine.outputString (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length = []⊢ configs (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) (higher.length + 1) =
counterCfg cfg v (lower ++ Counter.decrement (false :: higher))
(stLeft v (seen || (Counter.decrement (false :: higher)).any id)) 0 configs_succ_eq_step, false.left input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (false :: higher)hh:0 < Counter.value higherhs:step (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length =
counterCfg cfg v (lower ++ true :: Counter.decrement higher) (stLeft v true) 0hout:machine.outputString (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length = []⊢ configs (step (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1))) higher.length =
counterCfg cfg v (lower ++ Counter.decrement (false :: higher))
(stLeft v (seen || (Counter.decrement (false :: higher)).any id)) 0 hs, false.left input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (false :: higher)hh:0 < Counter.value higherhs:step (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length =
counterCfg cfg v (lower ++ true :: Counter.decrement higher) (stLeft v true) 0hout:machine.outputString (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length = []⊢ configs (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement (false :: higher))
(stLeft v (seen || (Counter.decrement (false :: higher)).any id)) 0 hc false.left input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (false :: higher)hh:0 < Counter.value higherhs:step (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length =
counterCfg cfg v (lower ++ true :: Counter.decrement higher) (stLeft v true) 0hout:machine.outputString (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length = []⊢ counterCfg cfg v (lower ++ true :: Counter.decrement higher) (stLeft v true) 0 =
counterCfg cfg v (lower ++ Counter.decrement (false :: higher))
(stLeft v (seen || (Counter.decrement (false :: higher)).any id)) 0] false.left input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (false :: higher)hh:0 < Counter.value higherhs:step (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length =
counterCfg cfg v (lower ++ true :: Counter.decrement higher) (stLeft v true) 0hout:machine.outputString (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length = []⊢ counterCfg cfg v (lower ++ true :: Counter.decrement higher) (stLeft v true) 0 =
counterCfg cfg v (lower ++ Counter.decrement (false :: higher))
(stLeft v (seen || (Counter.decrement (false :: higher)).any id)) 0
simp [Counter.decrement] All goals completed! 🐙
· false.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (false :: higher)hh:0 < Counter.value higherhs:step (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length =
counterCfg cfg v (lower ++ true :: Counter.decrement higher) (stLeft v true) 0hout:machine.outputString (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length = []⊢ machine.outputString (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (false :: higher).length)
(false :: higher).length =
[] let current := counterCfg cfg v (lower ++ false :: higher)
(stBorrow v seen) (higher.length + 1) false.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (false :: higher)hh:0 < Counter.value higherhs:step (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length =
counterCfg cfg v (lower ++ true :: Counter.decrement higher) (stLeft v true) 0hout:machine.outputString (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)⊢ machine.outputString (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (false :: higher).length)
(false :: higher).length =
[]
change machine.outputString current (higher.length + 1) = [] false.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (false :: higher)hh:0 < Counter.value higherhs:step (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length =
counterCfg cfg v (lower ++ true :: Counter.decrement higher) (stLeft v true) 0hout:machine.outputString (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)⊢ machine.outputString current (higher.length + 1) = []
rw [show higher.length + 1 = 1 + higher.length by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Bool⊢ ∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = [] omega All goals completed! 🐙, outputString_add_eq_append false.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (false :: higher)hh:0 < Counter.value higherhs:step (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length =
counterCfg cfg v (lower ++ true :: Counter.decrement higher) (stLeft v true) 0hout:machine.outputString (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)⊢ machine.outputString current 1 ++ machine.outputString (configs current 1) higher.length = []] false.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (false :: higher)hh:0 < Counter.value higherhs:step (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length =
counterCfg cfg v (lower ++ true :: Counter.decrement higher) (stLeft v true) 0hout:machine.outputString (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)⊢ machine.outputString current 1 ++ machine.outputString (configs current 1) higher.length = []
have hone : machine.outputString current 1 = [] := by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Bool⊢ ∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []
rw [show 1 = 0 + 1 from rfl, input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (false :: higher)hh:0 < Counter.value higherhs:step (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length =
counterCfg cfg v (lower ++ true :: Counter.decrement higher) (stLeft v true) 0hout:machine.outputString (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)⊢ machine.outputString current (0 + 1) = [] outputString_succ, input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (false :: higher)hh:0 < Counter.value higherhs:step (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length =
counterCfg cfg v (lower ++ true :: Counter.decrement higher) (stLeft v true) 0hout:machine.outputString (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)⊢ machine.outputString current 0 ++ (outputSymbol (configs current 0)).toList = [] configs_zero, input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (false :: higher)hh:0 < Counter.value higherhs:step (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length =
counterCfg cfg v (lower ++ true :: Counter.decrement higher) (stLeft v true) 0hout:machine.outputString (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)⊢ machine.outputString current 0 ++ (outputSymbol current).toList = [] ho input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (false :: higher)hh:0 < Counter.value higherhs:step (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length =
counterCfg cfg v (lower ++ true :: Counter.decrement higher) (stLeft v true) 0hout:machine.outputString (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)⊢ machine.outputString current 0 ++ none.toList = []] input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (false :: higher)hh:0 < Counter.value higherhs:step (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length =
counterCfg cfg v (lower ++ true :: Counter.decrement higher) (stLeft v true) 0hout:machine.outputString (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)⊢ machine.outputString current 0 ++ none.toList = []
rfl false.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (false :: higher)hh:0 < Counter.value higherhs:step (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length =
counterCfg cfg v (lower ++ true :: Counter.decrement higher) (stLeft v true) 0hout:machine.outputString (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)hone:machine.outputString current 1 = []⊢ machine.outputString current 1 ++ machine.outputString (configs current 1) higher.length = []
rw [hone false.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (false :: higher)hh:0 < Counter.value higherhs:step (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length =
counterCfg cfg v (lower ++ true :: Counter.decrement higher) (stLeft v true) 0hout:machine.outputString (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)hone:machine.outputString current 1 = []⊢ [] ++ machine.outputString (configs current 1) higher.length = []] false.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (false :: higher)hh:0 < Counter.value higherhs:step (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length =
counterCfg cfg v (lower ++ true :: Counter.decrement higher) (stLeft v true) 0hout:machine.outputString (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)hone:machine.outputString current 1 = []⊢ [] ++ machine.outputString (configs current 1) higher.length = []
change [] ++ machine.outputString (machine.step current) higher.length = [] false.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (false :: higher)hh:0 < Counter.value higherhs:step (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length =
counterCfg cfg v (lower ++ true :: Counter.decrement higher) (stLeft v true) 0hout:machine.outputString (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)hone:machine.outputString current 1 = []⊢ [] ++ machine.outputString (step current) higher.length = []
rw [hs, false.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (false :: higher)hh:0 < Counter.value higherhs:step (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length =
counterCfg cfg v (lower ++ true :: Counter.decrement higher) (stLeft v true) 0hout:machine.outputString (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)hone:machine.outputString current 1 = []⊢ [] ++ machine.outputString (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length =
[] hout false.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (false :: higher)hh:0 < Counter.value higherhs:step (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length =
counterCfg cfg v (lower ++ true :: Counter.decrement higher) (stLeft v true) 0hout:machine.outputString (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)hone:machine.outputString current 1 = []⊢ [] ++ [] = []] false.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (false :: higher)hh:0 < Counter.value higherhs:step (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length =
counterCfg cfg v (lower ++ true :: Counter.decrement higher) (stLeft v true) 0hout:machine.outputString (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1)hone:machine.outputString current 1 = []⊢ [] ++ [] = []
rfl All goals completed! 🐙
| true => true input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (true :: higher)⊢ configs (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (true :: higher).length) (true :: higher).length =
counterCfg cfg v (lower ++ Counter.decrement (true :: higher))
(stLeft v (seen || (Counter.decrement (true :: higher)).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (true :: higher).length)
(true :: higher).length =
[]
obtain ⟨hs, ho⟩ := borrow_true_run cfg v seen lower higher true input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (true :: higher)hs:step (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) = none⊢ configs (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (true :: higher).length) (true :: higher).length =
counterCfg cfg v (lower ++ Counter.decrement (true :: higher))
(stLeft v (seen || (Counter.decrement (true :: higher)).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (true :: higher).length)
(true :: higher).length =
[]
obtain ⟨hc, hout⟩ := configs_left cfg v higher (lower ++ [false]) seen true input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (true :: higher)hs:step (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ [false] ++ higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ [false] ++ higher) (stLeft v (seen || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ [false] ++ higher) (stLeft v seen) higher.length) higher.length = []⊢ configs (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (true :: higher).length) (true :: higher).length =
counterCfg cfg v (lower ++ Counter.decrement (true :: higher))
(stLeft v (seen || (Counter.decrement (true :: higher)).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (true :: higher).length)
(true :: higher).length =
[]
simp only [List.append_assoc, List.singleton_append] at hc hout true input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (true :: higher)hs:step (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ false :: higher) (stLeft v (seen || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length = []⊢ configs (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (true :: higher).length) (true :: higher).length =
counterCfg cfg v (lower ++ Counter.decrement (true :: higher))
(stLeft v (seen || (Counter.decrement (true :: higher)).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (true :: higher).length)
(true :: higher).length =
[]
constructor true.left input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (true :: higher)hs:step (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ false :: higher) (stLeft v (seen || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length = []⊢ configs (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (true :: higher).length) (true :: higher).length =
counterCfg cfg v (lower ++ Counter.decrement (true :: higher))
(stLeft v (seen || (Counter.decrement (true :: higher)).any id)) 0true.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (true :: higher)hs:step (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ false :: higher) (stLeft v (seen || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length = []⊢ machine.outputString (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (true :: higher).length)
(true :: higher).length =
[]
· true.left input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (true :: higher)hs:step (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ false :: higher) (stLeft v (seen || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length = []⊢ configs (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (true :: higher).length) (true :: higher).length =
counterCfg cfg v (lower ++ Counter.decrement (true :: higher))
(stLeft v (seen || (Counter.decrement (true :: higher)).any id)) 0 rw [List.length_cons, true.left input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (true :: higher)hs:step (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ false :: higher) (stLeft v (seen || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length = []⊢ configs (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) (higher.length + 1) =
counterCfg cfg v (lower ++ Counter.decrement (true :: higher))
(stLeft v (seen || (Counter.decrement (true :: higher)).any id)) 0 configs_succ_eq_step, true.left input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (true :: higher)hs:step (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ false :: higher) (stLeft v (seen || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length = []⊢ configs (step (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1))) higher.length =
counterCfg cfg v (lower ++ Counter.decrement (true :: higher))
(stLeft v (seen || (Counter.decrement (true :: higher)).any id)) 0 hs, true.left input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (true :: higher)hs:step (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ false :: higher) (stLeft v (seen || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length = []⊢ configs (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement (true :: higher))
(stLeft v (seen || (Counter.decrement (true :: higher)).any id)) 0 hc true.left input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (true :: higher)hs:step (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ false :: higher) (stLeft v (seen || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length = []⊢ counterCfg cfg v (lower ++ false :: higher) (stLeft v (seen || higher.any id)) 0 =
counterCfg cfg v (lower ++ Counter.decrement (true :: higher))
(stLeft v (seen || (Counter.decrement (true :: higher)).any id)) 0] true.left input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (true :: higher)hs:step (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ false :: higher) (stLeft v (seen || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length = []⊢ counterCfg cfg v (lower ++ false :: higher) (stLeft v (seen || higher.any id)) 0 =
counterCfg cfg v (lower ++ Counter.decrement (true :: higher))
(stLeft v (seen || (Counter.decrement (true :: higher)).any id)) 0
simp [Counter.decrement] All goals completed! 🐙
· true.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (true :: higher)hs:step (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ false :: higher) (stLeft v (seen || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length = []⊢ machine.outputString (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (true :: higher).length)
(true :: higher).length =
[] let current := counterCfg cfg v (lower ++ true :: higher)
(stBorrow v seen) (higher.length + 1) true.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (true :: higher)hs:step (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ false :: higher) (stLeft v (seen || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)⊢ machine.outputString (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (true :: higher).length)
(true :: higher).length =
[]
change machine.outputString current (higher.length + 1) = [] true.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (true :: higher)hs:step (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ false :: higher) (stLeft v (seen || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)⊢ machine.outputString current (higher.length + 1) = []
rw [show higher.length + 1 = 1 + higher.length by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Bool⊢ ∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = [] omega All goals completed! 🐙, outputString_add_eq_append true.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (true :: higher)hs:step (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ false :: higher) (stLeft v (seen || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)⊢ machine.outputString current 1 ++ machine.outputString (configs current 1) higher.length = []] true.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (true :: higher)hs:step (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ false :: higher) (stLeft v (seen || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)⊢ machine.outputString current 1 ++ machine.outputString (configs current 1) higher.length = []
have hone : machine.outputString current 1 = [] := by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Bool⊢ ∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []
rw [show 1 = 0 + 1 from rfl, input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (true :: higher)hs:step (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ false :: higher) (stLeft v (seen || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)⊢ machine.outputString current (0 + 1) = [] outputString_succ, input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (true :: higher)hs:step (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ false :: higher) (stLeft v (seen || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)⊢ machine.outputString current 0 ++ (outputSymbol (configs current 0)).toList = [] configs_zero, input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (true :: higher)hs:step (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ false :: higher) (stLeft v (seen || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)⊢ machine.outputString current 0 ++ (outputSymbol current).toList = [] ho input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (true :: higher)hs:step (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ false :: higher) (stLeft v (seen || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)⊢ machine.outputString current 0 ++ none.toList = []] input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (true :: higher)hs:step (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ false :: higher) (stLeft v (seen || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)⊢ machine.outputString current 0 ++ none.toList = []
rfl true.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (true :: higher)hs:step (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ false :: higher) (stLeft v (seen || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)hone:machine.outputString current 1 = []⊢ machine.outputString current 1 ++ machine.outputString (configs current 1) higher.length = []
rw [hone true.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (true :: higher)hs:step (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ false :: higher) (stLeft v (seen || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)hone:machine.outputString current 1 = []⊢ [] ++ machine.outputString (configs current 1) higher.length = []] true.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (true :: higher)hs:step (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ false :: higher) (stLeft v (seen || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)hone:machine.outputString current 1 = []⊢ [] ++ machine.outputString (configs current 1) higher.length = []
change [] ++ machine.outputString (machine.step current) higher.length = [] true.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (true :: higher)hs:step (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ false :: higher) (stLeft v (seen || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)hone:machine.outputString current 1 = []⊢ [] ++ machine.outputString (step current) higher.length = []
rw [hs, true.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (true :: higher)hs:step (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ false :: higher) (stLeft v (seen || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)hone:machine.outputString current 1 = []⊢ [] ++ machine.outputString (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length =
[] hout true.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (true :: higher)hs:step (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ false :: higher) (stLeft v (seen || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)hone:machine.outputString current 1 = []⊢ [] ++ [] = []] true.right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ Counter.decrement higher) (stLeft v (seen || (Counter.decrement higher).any id)) 0 ∧
machine.outputString (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) higher.length = []lower:List Boolseen:Boolh:0 < Counter.value (true :: higher)hs:step (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) =
counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.lengthho:outputSymbol (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)) = nonehc:configs (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length =
counterCfg cfg v (lower ++ false :: higher) (stLeft v (seen || higher.any id)) 0hout:machine.outputString (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) higher.length = []current:Cfg 4 (Fin 3) Control input := counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1)hone:machine.outputString current 1 = []⊢ [] ++ [] = []
rfl All goals completed! 🐙A single silent transition is a one-step execution with empty output.
theorem configs_output_one {input : List (Fin 3)}
(cfg next : Cfg 4 (Fin 3) Control input)
(hs : machine.step cfg = next) (ho : machine.outputSymbol cfg = none) :
machine.configs cfg 1 = next ∧ machine.outputString cfg 1 = [] := by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputnext:Cfg 4 (Fin 3) Control inpuths:step cfg = nextho:outputSymbol cfg = none⊢ configs cfg 1 = next ∧ machine.outputString cfg 1 = []
constructor left input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputnext:Cfg 4 (Fin 3) Control inpuths:step cfg = nextho:outputSymbol cfg = none⊢ configs cfg 1 = nextright input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputnext:Cfg 4 (Fin 3) Control inpuths:step cfg = nextho:outputSymbol cfg = none⊢ machine.outputString cfg 1 = []
· left input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputnext:Cfg 4 (Fin 3) Control inpuths:step cfg = nextho:outputSymbol cfg = none⊢ configs cfg 1 = next exact hs All goals completed! 🐙
· right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputnext:Cfg 4 (Fin 3) Control inpuths:step cfg = nextho:outputSymbol cfg = none⊢ machine.outputString cfg 1 = [] rw [show 1 = 0 + 1 from rfl, right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputnext:Cfg 4 (Fin 3) Control inpuths:step cfg = nextho:outputSymbol cfg = none⊢ machine.outputString cfg (0 + 1) = [] outputString_succ, right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputnext:Cfg 4 (Fin 3) Control inpuths:step cfg = nextho:outputSymbol cfg = none⊢ machine.outputString cfg 0 ++ (outputSymbol (configs cfg 0)).toList = [] configs_zero, right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputnext:Cfg 4 (Fin 3) Control inpuths:step cfg = nextho:outputSymbol cfg = none⊢ machine.outputString cfg 0 ++ (outputSymbol cfg).toList = [] ho right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputnext:Cfg 4 (Fin 3) Control inpuths:step cfg = nextho:outputSymbol cfg = none⊢ machine.outputString cfg 0 ++ none.toList = []] right input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputnext:Cfg 4 (Fin 3) Control inpuths:step cfg = nextho:outputSymbol cfg = none⊢ machine.outputString cfg 0 ++ none.toList = []
rfl All goals completed! 🐙A positive fixed-width counter decrements and tests its result in twice its width plus three transitions, preserving the input and all other tapes and emitting nothing.
theorem configs_decrement {input : List (Fin 3)} (cfg : Cfg 4 (Fin 3) Control input)
(v : Bool) (bs : List Bool) (hbs : 0 < Counter.value bs) :
machine.configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1))
(2 * bs.length + 3) =
counterCfg cfg v (Counter.decrement bs)
(afterDecrement v ((Counter.decrement bs).any id)) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stDecrement v) (bs.length + 1))
(2 * bs.length + 3) = [] := by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolhbs:0 < Counter.value bs⊢ configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (2 * bs.length + 3) =
counterCfg cfg v (Counter.decrement bs) (afterDecrement v ((Counter.decrement bs).any id)) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (2 * bs.length + 3) = []
have hentry := configs_output_one _ _ (step_decrement cfg v bs)
(outputSymbol_decrement cfg v bs) input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolhbs:0 < Counter.value bshentry:configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) 1 = counterCfg cfg v bs (stBorrow v false) bs.length ∧
machine.outputString (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) 1 = []⊢ configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (2 * bs.length + 3) =
counterCfg cfg v (Counter.decrement bs) (afterDecrement v ((Counter.decrement bs).any id)) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (2 * bs.length + 3) = []
have hborrow := configs_borrow cfg v bs [] false hbs input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolhbs:0 < Counter.value bshentry:configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) 1 = counterCfg cfg v bs (stBorrow v false) bs.length ∧
machine.outputString (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) 1 = []hborrow:configs (counterCfg cfg v ([] ++ bs) (stBorrow v false) bs.length) bs.length =
counterCfg cfg v ([] ++ Counter.decrement bs) (stLeft v (false || (Counter.decrement bs).any id)) 0 ∧
machine.outputString (counterCfg cfg v ([] ++ bs) (stBorrow v false) bs.length) bs.length = []⊢ configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (2 * bs.length + 3) =
counterCfg cfg v (Counter.decrement bs) (afterDecrement v ((Counter.decrement bs).any id)) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (2 * bs.length + 3) = []
simp only [List.nil_append, Bool.false_or] at hborrow input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolhbs:0 < Counter.value bshentry:configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) 1 = counterCfg cfg v bs (stBorrow v false) bs.length ∧
machine.outputString (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) 1 = []hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0 ∧
machine.outputString (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length = []⊢ configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (2 * bs.length + 3) =
counterCfg cfg v (Counter.decrement bs) (afterDecrement v ((Counter.decrement bs).any id)) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (2 * bs.length + 3) = []
obtain ⟨hz, hoz⟩ := left_zero_run cfg v ((Counter.decrement bs).any id)
(Counter.decrement bs) input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolhbs:0 < Counter.value bshentry:configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) 1 = counterCfg cfg v bs (stBorrow v false) bs.length ∧
machine.outputString (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) 1 = []hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0 ∧
machine.outputString (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length = []hz:step (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) =
counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1hoz:outputSymbol (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) = none⊢ configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (2 * bs.length + 3) =
counterCfg cfg v (Counter.decrement bs) (afterDecrement v ((Counter.decrement bs).any id)) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (2 * bs.length + 3) = []
have hturn := configs_output_one _ _ hz hoz input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolhbs:0 < Counter.value bshentry:configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) 1 = counterCfg cfg v bs (stBorrow v false) bs.length ∧
machine.outputString (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) 1 = []hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0 ∧
machine.outputString (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length = []hz:step (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) =
counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1hoz:outputSymbol (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) = nonehturn:configs (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) 1 =
counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1 ∧
machine.outputString (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) 1 = []⊢ configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (2 * bs.length + 3) =
counterCfg cfg v (Counter.decrement bs) (afterDecrement v ((Counter.decrement bs).any id)) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (2 * bs.length + 3) = []
have hright := configs_right cfg v ((Counter.decrement bs).any id)
(Counter.decrement bs) bs.length 1 (by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolhbs:0 < Counter.value bshentry:configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) 1 = counterCfg cfg v bs (stBorrow v false) bs.length ∧
machine.outputString (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) 1 = []hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0 ∧
machine.outputString (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length = []hz:step (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) =
counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1hoz:outputSymbol (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) = nonehturn:configs (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) 1 =
counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1 ∧
machine.outputString (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) 1 = []⊢ 0 < 1 omega All goals completed! 🐙) (by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolhbs:0 < Counter.value bshentry:configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) 1 = counterCfg cfg v bs (stBorrow v false) bs.length ∧
machine.outputString (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) 1 = []hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0 ∧
machine.outputString (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length = []hz:step (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) =
counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1hoz:outputSymbol (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) = nonehturn:configs (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) 1 =
counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1 ∧
machine.outputString (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) 1 = []⊢ 1 + bs.length = (Counter.decrement bs).length + 1 rw [Counter.length_decrement input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolhbs:0 < Counter.value bshentry:configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) 1 = counterCfg cfg v bs (stBorrow v false) bs.length ∧
machine.outputString (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) 1 = []hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0 ∧
machine.outputString (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length = []hz:step (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) =
counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1hoz:outputSymbol (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) = nonehturn:configs (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) 1 =
counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1 ∧
machine.outputString (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) 1 = []⊢ 1 + bs.length = bs.length + 1] input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolhbs:0 < Counter.value bshentry:configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) 1 = counterCfg cfg v bs (stBorrow v false) bs.length ∧
machine.outputString (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) 1 = []hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0 ∧
machine.outputString (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length = []hz:step (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) =
counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1hoz:outputSymbol (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) = nonehturn:configs (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) 1 =
counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1 ∧
machine.outputString (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) 1 = []⊢ 1 + bs.length = bs.length + 1; omega All goals completed! 🐙) input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolhbs:0 < Counter.value bshentry:configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) 1 = counterCfg cfg v bs (stBorrow v false) bs.length ∧
machine.outputString (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) 1 = []hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0 ∧
machine.outputString (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length = []hz:step (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) =
counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1hoz:outputSymbol (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) = nonehturn:configs (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) 1 =
counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1 ∧
machine.outputString (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) 1 = []hright:configs (counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1) (bs.length + 1) =
counterCfg cfg v (Counter.decrement bs) (afterDecrement v ((Counter.decrement bs).any id))
((Counter.decrement bs).length + 1) ∧
machine.outputString (counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1)
(bs.length + 1) =
[]⊢ configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (2 * bs.length + 3) =
counterCfg cfg v (Counter.decrement bs) (afterDecrement v ((Counter.decrement bs).any id)) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (2 * bs.length + 3) = []
rw [Counter.length_decrement input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolhbs:0 < Counter.value bshentry:configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) 1 = counterCfg cfg v bs (stBorrow v false) bs.length ∧
machine.outputString (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) 1 = []hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0 ∧
machine.outputString (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length = []hz:step (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) =
counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1hoz:outputSymbol (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) = nonehturn:configs (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) 1 =
counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1 ∧
machine.outputString (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) 1 = []hright:configs (counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1) (bs.length + 1) =
counterCfg cfg v (Counter.decrement bs) (afterDecrement v ((Counter.decrement bs).any id)) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1)
(bs.length + 1) =
[]⊢ configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (2 * bs.length + 3) =
counterCfg cfg v (Counter.decrement bs) (afterDecrement v ((Counter.decrement bs).any id)) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (2 * bs.length + 3) = []] at hright input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolhbs:0 < Counter.value bshentry:configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) 1 = counterCfg cfg v bs (stBorrow v false) bs.length ∧
machine.outputString (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) 1 = []hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0 ∧
machine.outputString (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length = []hz:step (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) =
counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1hoz:outputSymbol (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) = nonehturn:configs (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) 1 =
counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1 ∧
machine.outputString (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) 1 = []hright:configs (counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1) (bs.length + 1) =
counterCfg cfg v (Counter.decrement bs) (afterDecrement v ((Counter.decrement bs).any id)) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1)
(bs.length + 1) =
[]⊢ configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (2 * bs.length + 3) =
counterCfg cfg v (Counter.decrement bs) (afterDecrement v ((Counter.decrement bs).any id)) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (2 * bs.length + 3) = []
have hfirst := configs_output_add _ _ _ 1 bs.length hentry hborrow input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolhbs:0 < Counter.value bshentry:configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) 1 = counterCfg cfg v bs (stBorrow v false) bs.length ∧
machine.outputString (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) 1 = []hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0 ∧
machine.outputString (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length = []hz:step (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) =
counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1hoz:outputSymbol (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) = nonehturn:configs (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) 1 =
counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1 ∧
machine.outputString (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) 1 = []hright:configs (counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1) (bs.length + 1) =
counterCfg cfg v (Counter.decrement bs) (afterDecrement v ((Counter.decrement bs).any id)) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1)
(bs.length + 1) =
[]hfirst:configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (1 + bs.length) =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0 ∧
machine.outputString (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (1 + bs.length) = []⊢ configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (2 * bs.length + 3) =
counterCfg cfg v (Counter.decrement bs) (afterDecrement v ((Counter.decrement bs).any id)) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (2 * bs.length + 3) = []
have hsecond := configs_output_add _ _ _ (1 + bs.length) 1 hfirst hturn input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolhbs:0 < Counter.value bshentry:configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) 1 = counterCfg cfg v bs (stBorrow v false) bs.length ∧
machine.outputString (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) 1 = []hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0 ∧
machine.outputString (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length = []hz:step (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) =
counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1hoz:outputSymbol (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) = nonehturn:configs (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) 1 =
counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1 ∧
machine.outputString (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) 1 = []hright:configs (counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1) (bs.length + 1) =
counterCfg cfg v (Counter.decrement bs) (afterDecrement v ((Counter.decrement bs).any id)) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1)
(bs.length + 1) =
[]hfirst:configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (1 + bs.length) =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0 ∧
machine.outputString (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (1 + bs.length) = []hsecond:configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (1 + bs.length + 1) =
counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1 ∧
machine.outputString (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (1 + bs.length + 1) = []⊢ configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (2 * bs.length + 3) =
counterCfg cfg v (Counter.decrement bs) (afterDecrement v ((Counter.decrement bs).any id)) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (2 * bs.length + 3) = []
have hall := configs_output_add _ _ _ (1 + bs.length + 1) (bs.length + 1) hsecond hright input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolhbs:0 < Counter.value bshentry:configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) 1 = counterCfg cfg v bs (stBorrow v false) bs.length ∧
machine.outputString (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) 1 = []hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0 ∧
machine.outputString (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length = []hz:step (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) =
counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1hoz:outputSymbol (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) = nonehturn:configs (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) 1 =
counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1 ∧
machine.outputString (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) 1 = []hright:configs (counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1) (bs.length + 1) =
counterCfg cfg v (Counter.decrement bs) (afterDecrement v ((Counter.decrement bs).any id)) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1)
(bs.length + 1) =
[]hfirst:configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (1 + bs.length) =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0 ∧
machine.outputString (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (1 + bs.length) = []hsecond:configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (1 + bs.length + 1) =
counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1 ∧
machine.outputString (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (1 + bs.length + 1) = []hall:configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (1 + bs.length + 1 + (bs.length + 1)) =
counterCfg cfg v (Counter.decrement bs) (afterDecrement v ((Counter.decrement bs).any id)) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (1 + bs.length + 1 + (bs.length + 1)) = []⊢ configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (2 * bs.length + 3) =
counterCfg cfg v (Counter.decrement bs) (afterDecrement v ((Counter.decrement bs).any id)) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (2 * bs.length + 3) = []
simpa only [show 1 + bs.length + 1 + (bs.length + 1) = 2 * bs.length + 3 by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolhbs:0 < Counter.value bs⊢ configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (2 * bs.length + 3) =
counterCfg cfg v (Counter.decrement bs) (afterDecrement v ((Counter.decrement bs).any id)) (bs.length + 1) ∧
machine.outputString (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) (2 * bs.length + 3) = [] omega All goals completed! 🐙] using hallA bounded starting configuration followed by a bounded tail gives a bounded successor run.
theorem headBound_succ {input : List (Fin 3)} (cfg : Cfg 4 (Fin 3) Control input)
(n width : ℕ) (hcfg : HeadBound width cfg)
(hnext : ∀ t ≤ n, HeadBound width (machine.configs (machine.step cfg) t))
(t : ℕ) (ht : t ≤ n + 1) : HeadBound width (machine.configs cfg t) := by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputn:ℕwidth:ℕhcfg:HeadBound width cfghnext:∀ t ≤ n, HeadBound width (configs (step cfg) t)t:ℕht:t ≤ n + 1⊢ HeadBound width (configs cfg t)
cases t with
| zero => zero input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputn:ℕwidth:ℕhcfg:HeadBound width cfghnext:∀ t ≤ n, HeadBound width (configs (step cfg) t)ht:0 ≤ n + 1⊢ HeadBound width (configs cfg 0) exact hcfg All goals completed! 🐙
| succ t => succ input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputn:ℕwidth:ℕhcfg:HeadBound width cfghnext:∀ t ≤ n, HeadBound width (configs (step cfg) t)t:ℕht:t + 1 ≤ n + 1⊢ HeadBound width (configs cfg (t + 1))
rw [configs_succ_eq_step succ input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputn:ℕwidth:ℕhcfg:HeadBound width cfghnext:∀ t ≤ n, HeadBound width (configs (step cfg) t)t:ℕht:t + 1 ≤ n + 1⊢ HeadBound width (configs (step cfg) t)] succ input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputn:ℕwidth:ℕhcfg:HeadBound width cfghnext:∀ t ≤ n, HeadBound width (configs (step cfg) t)t:ℕht:t + 1 ≤ n + 1⊢ HeadBound width (configs (step cfg) t)
exact hnext t (by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputn:ℕwidth:ℕhcfg:HeadBound width cfghnext:∀ t ≤ n, HeadBound width (configs (step cfg) t)t:ℕht:t + 1 ≤ n + 1⊢ t ≤ n omega All goals completed! 🐙)Every prefix of the leftward scan stays between the origin and its starting head.
theorem configs_left_headBound {input : List (Fin 3)} (cfg : Cfg 4 (Fin 3) Control input)
(v : Bool) (higher : List Bool) (width : ℕ) (hcfg : HeadBound width cfg) :
∀ lower seen, higher.length ≤ width → ∀ t ≤ higher.length,
HeadBound width (machine.configs
(counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) t) := by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Boolwidth:ℕhcfg:HeadBound width cfg⊢ ∀ (lower : List Bool) (seen : Bool),
higher.length ≤ width →
∀ t ≤ higher.length, HeadBound width (configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) t)
apply List.rec (motive := fun higher ↦ ∀ lower seen, higher.length ≤ width →
∀ t ≤ higher.length, HeadBound width (machine.configs
(counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) t)) ?_ ?_ higher input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Boolwidth:ℕhcfg:HeadBound width cfg⊢ ∀ (lower : List Bool) (seen : Bool),
[].length ≤ width →
∀ t ≤ [].length, HeadBound width (configs (counterCfg cfg v (lower ++ []) (stLeft v seen) [].length) t)input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Boolwidth:ℕhcfg:HeadBound width cfg⊢ ∀ (head : Bool) (tail : List Bool),
(∀ (lower : List Bool) (seen : Bool),
tail.length ≤ width →
∀ t ≤ tail.length, HeadBound width (configs (counterCfg cfg v (lower ++ tail) (stLeft v seen) tail.length) t)) →
∀ (lower : List Bool) (seen : Bool),
(head :: tail).length ≤ width →
∀ t ≤ (head :: tail).length,
HeadBound width (configs (counterCfg cfg v (lower ++ head :: tail) (stLeft v seen) (head :: tail).length) t)
· input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Boolwidth:ℕhcfg:HeadBound width cfg⊢ ∀ (lower : List Bool) (seen : Bool),
[].length ≤ width →
∀ t ≤ [].length, HeadBound width (configs (counterCfg cfg v (lower ++ []) (stLeft v seen) [].length) t) intro lower seen hw t ht input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Boolwidth:ℕhcfg:HeadBound width cfglower:List Boolseen:Boolhw:[].length ≤ widtht:ℕht:t ≤ [].length⊢ HeadBound width (configs (counterCfg cfg v (lower ++ []) (stLeft v seen) [].length) t)
have he : t = 0 := by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Boolwidth:ℕhcfg:HeadBound width cfg⊢ ∀ (lower : List Bool) (seen : Bool),
higher.length ≤ width →
∀ t ≤ higher.length, HeadBound width (configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) t) simpa using ht input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Boolwidth:ℕhcfg:HeadBound width cfglower:List Boolseen:Boolhw:[].length ≤ widtht:ℕht:t ≤ [].lengthhe:t = 0⊢ HeadBound width (configs (counterCfg cfg v (lower ++ []) (stLeft v seen) [].length) t)
subst t input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Boolwidth:ℕhcfg:HeadBound width cfglower:List Boolseen:Boolhw:[].length ≤ widthht:0 ≤ [].length⊢ HeadBound width (configs (counterCfg cfg v (lower ++ []) (stLeft v seen) [].length) 0)
exact headBound_counterCfg cfg v _ _ _ width hcfg hw All goals completed! 🐙
· input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Boolwidth:ℕhcfg:HeadBound width cfg⊢ ∀ (head : Bool) (tail : List Bool),
(∀ (lower : List Bool) (seen : Bool),
tail.length ≤ width →
∀ t ≤ tail.length, HeadBound width (configs (counterCfg cfg v (lower ++ tail) (stLeft v seen) tail.length) t)) →
∀ (lower : List Bool) (seen : Bool),
(head :: tail).length ≤ width →
∀ t ≤ (head :: tail).length,
HeadBound width (configs (counterCfg cfg v (lower ++ head :: tail) (stLeft v seen) (head :: tail).length) t) intro b higher ih lower seen hw t ht input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolwidth:ℕhcfg:HeadBound width cfgb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
higher.length ≤ width →
∀ t ≤ higher.length, HeadBound width (configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) t)lower:List Boolseen:Boolhw:(b :: higher).length ≤ widtht:ℕht:t ≤ (b :: higher).length⊢ HeadBound width (configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (b :: higher).length) t)
apply headBound_succ _ higher.length width
(headBound_counterCfg cfg v _ _ _ width hcfg hw) ?_ t ht input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolwidth:ℕhcfg:HeadBound width cfgb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
higher.length ≤ width →
∀ t ≤ higher.length, HeadBound width (configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) t)lower:List Boolseen:Boolhw:(b :: higher).length ≤ widtht:ℕht:t ≤ (b :: higher).length⊢ ∀ t ≤ higher.length,
HeadBound width (configs (step (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (b :: higher).length)) t)
intro r hr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolwidth:ℕhcfg:HeadBound width cfgb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
higher.length ≤ width →
∀ t ≤ higher.length, HeadBound width (configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) t)lower:List Boolseen:Boolhw:(b :: higher).length ≤ widtht:ℕht:t ≤ (b :: higher).lengthr:ℕhr:r ≤ higher.length⊢ HeadBound width (configs (step (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (b :: higher).length)) r)
rw [List.length_cons, input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolwidth:ℕhcfg:HeadBound width cfgb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
higher.length ≤ width →
∀ t ≤ higher.length, HeadBound width (configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) t)lower:List Boolseen:Boolhw:(b :: higher).length ≤ widtht:ℕht:t ≤ (b :: higher).lengthr:ℕhr:r ≤ higher.length⊢ HeadBound width (configs (step (counterCfg cfg v (lower ++ b :: higher) (stLeft v seen) (higher.length + 1))) r) (left_cons_run cfg v seen b lower higher).1 input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolwidth:ℕhcfg:HeadBound width cfgb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
higher.length ≤ width →
∀ t ≤ higher.length, HeadBound width (configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) t)lower:List Boolseen:Boolhw:(b :: higher).length ≤ widtht:ℕht:t ≤ (b :: higher).lengthr:ℕhr:r ≤ higher.length⊢ HeadBound width (configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) r)] input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolwidth:ℕhcfg:HeadBound width cfgb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
higher.length ≤ width →
∀ t ≤ higher.length, HeadBound width (configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) t)lower:List Boolseen:Boolhw:(b :: higher).length ≤ widtht:ℕht:t ≤ (b :: higher).lengthr:ℕhr:r ≤ higher.length⊢ HeadBound width (configs (counterCfg cfg v (lower ++ b :: higher) (stLeft v (seen || b)) higher.length) r)
simpa only [List.append_assoc, List.singleton_append] using
ih (lower ++ [b]) (seen || b) (by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolwidth:ℕhcfg:HeadBound width cfgb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
higher.length ≤ width →
∀ t ≤ higher.length, HeadBound width (configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) t)lower:List Boolseen:Boolhw:(b :: higher).length ≤ widtht:ℕht:t ≤ (b :: higher).lengthr:ℕhr:r ≤ higher.length⊢ higher.length ≤ width simp only [List.length_cons] at hw input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolwidth:ℕhcfg:HeadBound width cfgb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
higher.length ≤ width →
∀ t ≤ higher.length, HeadBound width (configs (counterCfg cfg v (lower ++ higher) (stLeft v seen) higher.length) t)lower:List Boolseen:Boolhw:higher.length + 1 ≤ widtht:ℕht:t ≤ (b :: higher).lengthr:ℕhr:r ≤ higher.length⊢ higher.length ≤ width; omega All goals completed! 🐙) r hrBorrowing and its leftward scan stay in the initial head interval.
theorem configs_borrow_headBound {input : List (Fin 3)} (cfg : Cfg 4 (Fin 3) Control input)
(v : Bool) (higher : List Bool) (width : ℕ) (hcfg : HeadBound width cfg) :
∀ lower seen, 0 < Counter.value higher → higher.length ≤ width → ∀ t ≤ higher.length,
HeadBound width (machine.configs
(counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) t) := by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Boolwidth:ℕhcfg:HeadBound width cfg⊢ ∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
higher.length ≤ width →
∀ t ≤ higher.length,
HeadBound width (configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) t)
apply List.rec (motive := fun higher ↦ ∀ lower seen, 0 < Counter.value higher →
higher.length ≤ width → ∀ t ≤ higher.length, HeadBound width (machine.configs
(counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) t)) ?_ ?_ higher input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Boolwidth:ℕhcfg:HeadBound width cfg⊢ ∀ (lower : List Bool) (seen : Bool),
0 < Counter.value [] →
[].length ≤ width →
∀ t ≤ [].length, HeadBound width (configs (counterCfg cfg v (lower ++ []) (stBorrow v seen) [].length) t)input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Boolwidth:ℕhcfg:HeadBound width cfg⊢ ∀ (head : Bool) (tail : List Bool),
(∀ (lower : List Bool) (seen : Bool),
0 < Counter.value tail →
tail.length ≤ width →
∀ t ≤ tail.length,
HeadBound width (configs (counterCfg cfg v (lower ++ tail) (stBorrow v seen) tail.length) t)) →
∀ (lower : List Bool) (seen : Bool),
0 < Counter.value (head :: tail) →
(head :: tail).length ≤ width →
∀ t ≤ (head :: tail).length,
HeadBound width
(configs (counterCfg cfg v (lower ++ head :: tail) (stBorrow v seen) (head :: tail).length) t)
· input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Boolwidth:ℕhcfg:HeadBound width cfg⊢ ∀ (lower : List Bool) (seen : Bool),
0 < Counter.value [] →
[].length ≤ width →
∀ t ≤ [].length, HeadBound width (configs (counterCfg cfg v (lower ++ []) (stBorrow v seen) [].length) t) intro lower seen h input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Boolwidth:ℕhcfg:HeadBound width cfglower:List Boolseen:Boolh:0 < Counter.value []⊢ [].length ≤ width →
∀ t ≤ [].length, HeadBound width (configs (counterCfg cfg v (lower ++ []) (stBorrow v seen) [].length) t)
simp [Counter.value] at h All goals completed! 🐙
· input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Boolwidth:ℕhcfg:HeadBound width cfg⊢ ∀ (head : Bool) (tail : List Bool),
(∀ (lower : List Bool) (seen : Bool),
0 < Counter.value tail →
tail.length ≤ width →
∀ t ≤ tail.length,
HeadBound width (configs (counterCfg cfg v (lower ++ tail) (stBorrow v seen) tail.length) t)) →
∀ (lower : List Bool) (seen : Bool),
0 < Counter.value (head :: tail) →
(head :: tail).length ≤ width →
∀ t ≤ (head :: tail).length,
HeadBound width
(configs (counterCfg cfg v (lower ++ head :: tail) (stBorrow v seen) (head :: tail).length) t) intro b higher ih lower seen h hw t ht input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolwidth:ℕhcfg:HeadBound width cfgb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
higher.length ≤ width →
∀ t ≤ higher.length,
HeadBound width (configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) t)lower:List Boolseen:Boolh:0 < Counter.value (b :: higher)hw:(b :: higher).length ≤ widtht:ℕht:t ≤ (b :: higher).length⊢ HeadBound width (configs (counterCfg cfg v (lower ++ b :: higher) (stBorrow v seen) (b :: higher).length) t)
apply headBound_succ _ higher.length width
(headBound_counterCfg cfg v _ _ _ width hcfg hw) ?_ t ht input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolwidth:ℕhcfg:HeadBound width cfgb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
higher.length ≤ width →
∀ t ≤ higher.length,
HeadBound width (configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) t)lower:List Boolseen:Boolh:0 < Counter.value (b :: higher)hw:(b :: higher).length ≤ widtht:ℕht:t ≤ (b :: higher).length⊢ ∀ t ≤ higher.length,
HeadBound width (configs (step (counterCfg cfg v (lower ++ b :: higher) (stBorrow v seen) (b :: higher).length)) t)
intro r hr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolwidth:ℕhcfg:HeadBound width cfgb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
higher.length ≤ width →
∀ t ≤ higher.length,
HeadBound width (configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) t)lower:List Boolseen:Boolh:0 < Counter.value (b :: higher)hw:(b :: higher).length ≤ widtht:ℕht:t ≤ (b :: higher).lengthr:ℕhr:r ≤ higher.length⊢ HeadBound width (configs (step (counterCfg cfg v (lower ++ b :: higher) (stBorrow v seen) (b :: higher).length)) r)
have hwidth : higher.length ≤ width := by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Boolwidth:ℕhcfg:HeadBound width cfg⊢ ∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
higher.length ≤ width →
∀ t ≤ higher.length,
HeadBound width (configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) t) simp only [List.length_cons] at hw input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolwidth:ℕhcfg:HeadBound width cfgb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
higher.length ≤ width →
∀ t ≤ higher.length,
HeadBound width (configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) t)lower:List Boolseen:Boolh:0 < Counter.value (b :: higher)hw:higher.length + 1 ≤ widtht:ℕht:t ≤ (b :: higher).lengthr:ℕhr:r ≤ higher.length⊢ higher.length ≤ width; omega input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolwidth:ℕhcfg:HeadBound width cfgb:Boolhigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
higher.length ≤ width →
∀ t ≤ higher.length,
HeadBound width (configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) t)lower:List Boolseen:Boolh:0 < Counter.value (b :: higher)hw:(b :: higher).length ≤ widtht:ℕht:t ≤ (b :: higher).lengthr:ℕhr:r ≤ higher.lengthhwidth:higher.length ≤ width⊢ HeadBound width (configs (step (counterCfg cfg v (lower ++ b :: higher) (stBorrow v seen) (b :: higher).length)) r)
cases b with
| false => false input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolwidth:ℕhcfg:HeadBound width cfghigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
higher.length ≤ width →
∀ t ≤ higher.length,
HeadBound width (configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) t)lower:List Boolseen:Boolt:ℕr:ℕhr:r ≤ higher.lengthhwidth:higher.length ≤ widthh:0 < Counter.value (false :: higher)hw:(false :: higher).length ≤ widthht:t ≤ (false :: higher).length⊢ HeadBound width
(configs (step (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (false :: higher).length)) r)
have hh : 0 < Counter.value higher := by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher:List Boolwidth:ℕhcfg:HeadBound width cfg⊢ ∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
higher.length ≤ width →
∀ t ≤ higher.length,
HeadBound width (configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) t)
rw [Counter.value_cons input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolwidth:ℕhcfg:HeadBound width cfghigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
higher.length ≤ width →
∀ t ≤ higher.length,
HeadBound width (configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) t)lower:List Boolseen:Boolt:ℕr:ℕhr:r ≤ higher.lengthhwidth:higher.length ≤ widthh:0 < 2 * Counter.value higher + false.toNathw:(false :: higher).length ≤ widthht:t ≤ (false :: higher).length⊢ 0 < Counter.value higher] at h input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolwidth:ℕhcfg:HeadBound width cfghigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
higher.length ≤ width →
∀ t ≤ higher.length,
HeadBound width (configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) t)lower:List Boolseen:Boolt:ℕr:ℕhr:r ≤ higher.lengthhwidth:higher.length ≤ widthh:0 < 2 * Counter.value higher + false.toNathw:(false :: higher).length ≤ widthht:t ≤ (false :: higher).length⊢ 0 < Counter.value higher
simp only [Bool.toNat_false] at h input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolwidth:ℕhcfg:HeadBound width cfghigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
higher.length ≤ width →
∀ t ≤ higher.length,
HeadBound width (configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) t)lower:List Boolseen:Boolt:ℕr:ℕhr:r ≤ higher.lengthhwidth:higher.length ≤ widthh:0 < 2 * Counter.value higher + 0hw:(false :: higher).length ≤ widthht:t ≤ (false :: higher).length⊢ 0 < Counter.value higher
omega false input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolwidth:ℕhcfg:HeadBound width cfghigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
higher.length ≤ width →
∀ t ≤ higher.length,
HeadBound width (configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) t)lower:List Boolseen:Boolt:ℕr:ℕhr:r ≤ higher.lengthhwidth:higher.length ≤ widthh:0 < Counter.value (false :: higher)hw:(false :: higher).length ≤ widthht:t ≤ (false :: higher).lengthhh:0 < Counter.value higher⊢ HeadBound width
(configs (step (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (false :: higher).length)) r)
rw [List.length_cons, false input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolwidth:ℕhcfg:HeadBound width cfghigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
higher.length ≤ width →
∀ t ≤ higher.length,
HeadBound width (configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) t)lower:List Boolseen:Boolt:ℕr:ℕhr:r ≤ higher.lengthhwidth:higher.length ≤ widthh:0 < Counter.value (false :: higher)hw:(false :: higher).length ≤ widthht:t ≤ (false :: higher).lengthhh:0 < Counter.value higher⊢ HeadBound width (configs (step (counterCfg cfg v (lower ++ false :: higher) (stBorrow v seen) (higher.length + 1))) r) (borrow_false_run cfg v seen lower higher).1 false input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolwidth:ℕhcfg:HeadBound width cfghigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
higher.length ≤ width →
∀ t ≤ higher.length,
HeadBound width (configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) t)lower:List Boolseen:Boolt:ℕr:ℕhr:r ≤ higher.lengthhwidth:higher.length ≤ widthh:0 < Counter.value (false :: higher)hw:(false :: higher).length ≤ widthht:t ≤ (false :: higher).lengthhh:0 < Counter.value higher⊢ HeadBound width (configs (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) r)] false input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolwidth:ℕhcfg:HeadBound width cfghigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
higher.length ≤ width →
∀ t ≤ higher.length,
HeadBound width (configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) t)lower:List Boolseen:Boolt:ℕr:ℕhr:r ≤ higher.lengthhwidth:higher.length ≤ widthh:0 < Counter.value (false :: higher)hw:(false :: higher).length ≤ widthht:t ≤ (false :: higher).lengthhh:0 < Counter.value higher⊢ HeadBound width (configs (counterCfg cfg v (lower ++ true :: higher) (stBorrow v true) higher.length) r)
simpa only [List.append_assoc, List.singleton_append] using
ih (lower ++ [true]) true hh hwidth r hr All goals completed! 🐙
| true => true input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolwidth:ℕhcfg:HeadBound width cfghigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
higher.length ≤ width →
∀ t ≤ higher.length,
HeadBound width (configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) t)lower:List Boolseen:Boolt:ℕr:ℕhr:r ≤ higher.lengthhwidth:higher.length ≤ widthh:0 < Counter.value (true :: higher)hw:(true :: higher).length ≤ widthht:t ≤ (true :: higher).length⊢ HeadBound width
(configs (step (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (true :: higher).length)) r)
rw [List.length_cons, true input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolwidth:ℕhcfg:HeadBound width cfghigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
higher.length ≤ width →
∀ t ≤ higher.length,
HeadBound width (configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) t)lower:List Boolseen:Boolt:ℕr:ℕhr:r ≤ higher.lengthhwidth:higher.length ≤ widthh:0 < Counter.value (true :: higher)hw:(true :: higher).length ≤ widthht:t ≤ (true :: higher).length⊢ HeadBound width (configs (step (counterCfg cfg v (lower ++ true :: higher) (stBorrow v seen) (higher.length + 1))) r) (borrow_true_run cfg v seen lower higher).1 true input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolwidth:ℕhcfg:HeadBound width cfghigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
higher.length ≤ width →
∀ t ≤ higher.length,
HeadBound width (configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) t)lower:List Boolseen:Boolt:ℕr:ℕhr:r ≤ higher.lengthhwidth:higher.length ≤ widthh:0 < Counter.value (true :: higher)hw:(true :: higher).length ≤ widthht:t ≤ (true :: higher).length⊢ HeadBound width (configs (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) r)] true input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolhigher✝:List Boolwidth:ℕhcfg:HeadBound width cfghigher:List Boolih:∀ (lower : List Bool) (seen : Bool),
0 < Counter.value higher →
higher.length ≤ width →
∀ t ≤ higher.length,
HeadBound width (configs (counterCfg cfg v (lower ++ higher) (stBorrow v seen) higher.length) t)lower:List Boolseen:Boolt:ℕr:ℕhr:r ≤ higher.lengthhwidth:higher.length ≤ widthh:0 < Counter.value (true :: higher)hw:(true :: higher).length ≤ widthht:t ≤ (true :: higher).length⊢ HeadBound width (configs (counterCfg cfg v (lower ++ false :: higher) (stLeft v seen) higher.length) r)
simpa only [List.append_assoc, List.singleton_append] using
configs_left_headBound cfg v higher width hcfg (lower ++ [false]) seen hwidth r hr All goals completed! 🐙Every prefix of the rightward scan stays at or before the right-hand blank.
theorem configs_right_headBound {input : List (Fin 3)} (cfg : Cfg 4 (Fin 3) Control input)
(v seen : Bool) (bs : List Bool) (width : ℕ) (hcfg : HeadBound width cfg)
(hw : bs.length + 1 ≤ width) (n : ℕ) : ∀ p, 0 < p → p + n = bs.length + 1 →
∀ t ≤ n + 1, HeadBound width
(machine.configs (counterCfg cfg v bs (stRight v seen) p) t) := by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthn:ℕ⊢ ∀ (p : ℕ),
0 < p → p + n = bs.length + 1 → ∀ t ≤ n + 1, HeadBound width (configs (counterCfg cfg v bs (stRight v seen) p) t)
apply Nat.rec (motive := fun n ↦ ∀ p, 0 < p → p + n = bs.length + 1 →
∀ t ≤ n + 1, HeadBound width
(machine.configs (counterCfg cfg v bs (stRight v seen) p) t)) ?_ ?_ n input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthn:ℕ⊢ ∀ (p : ℕ),
0 < p →
p + Nat.zero = bs.length + 1 →
∀ t ≤ Nat.zero + 1, HeadBound width (configs (counterCfg cfg v bs (stRight v seen) p) t)input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthn:ℕ⊢ ∀ (n : ℕ),
(∀ (p : ℕ),
0 < p →
p + n = bs.length + 1 → ∀ t ≤ n + 1, HeadBound width (configs (counterCfg cfg v bs (stRight v seen) p) t)) →
∀ (p : ℕ),
0 < p →
p + n.succ = bs.length + 1 →
∀ t ≤ n.succ + 1, HeadBound width (configs (counterCfg cfg v bs (stRight v seen) p) t)
· input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthn:ℕ⊢ ∀ (p : ℕ),
0 < p →
p + Nat.zero = bs.length + 1 →
∀ t ≤ Nat.zero + 1, HeadBound width (configs (counterCfg cfg v bs (stRight v seen) p) t) intro p _ hp t ht input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthn:ℕp:ℕa✝:0 < php:p + Nat.zero = bs.length + 1t:ℕht:t ≤ Nat.zero + 1⊢ HeadBound width (configs (counterCfg cfg v bs (stRight v seen) p) t)
have he : p = bs.length + 1 := by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthn:ℕ⊢ ∀ (p : ℕ),
0 < p → p + n = bs.length + 1 → ∀ t ≤ n + 1, HeadBound width (configs (counterCfg cfg v bs (stRight v seen) p) t) omega input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthn:ℕp:ℕa✝:0 < php:p + Nat.zero = bs.length + 1t:ℕht:t ≤ Nat.zero + 1he:p = bs.length + 1⊢ HeadBound width (configs (counterCfg cfg v bs (stRight v seen) p) t)
subst p input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthn:ℕt:ℕht:t ≤ Nat.zero + 1a✝:0 < bs.length + 1hp:bs.length + 1 + Nat.zero = bs.length + 1⊢ HeadBound width (configs (counterCfg cfg v bs (stRight v seen) (bs.length + 1)) t)
apply headBound_succ _ 0 width (headBound_counterCfg cfg v _ _ _ width hcfg hw) ?_ t ht input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthn:ℕt:ℕht:t ≤ Nat.zero + 1a✝:0 < bs.length + 1hp:bs.length + 1 + Nat.zero = bs.length + 1⊢ ∀ t ≤ 0, HeadBound width (configs (step (counterCfg cfg v bs (stRight v seen) (bs.length + 1))) t)
intro r hr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthn:ℕt:ℕht:t ≤ Nat.zero + 1a✝:0 < bs.length + 1hp:bs.length + 1 + Nat.zero = bs.length + 1r:ℕhr:r ≤ 0⊢ HeadBound width (configs (step (counterCfg cfg v bs (stRight v seen) (bs.length + 1))) r)
have he : r = 0 := by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthn:ℕ⊢ ∀ (p : ℕ),
0 < p → p + n = bs.length + 1 → ∀ t ≤ n + 1, HeadBound width (configs (counterCfg cfg v bs (stRight v seen) p) t) omega input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthn:ℕt:ℕht:t ≤ Nat.zero + 1a✝:0 < bs.length + 1hp:bs.length + 1 + Nat.zero = bs.length + 1r:ℕhr:r ≤ 0he:r = 0⊢ HeadBound width (configs (step (counterCfg cfg v bs (stRight v seen) (bs.length + 1))) r)
subst r input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthn:ℕt:ℕht:t ≤ Nat.zero + 1a✝:0 < bs.length + 1hp:bs.length + 1 + Nat.zero = bs.length + 1hr:0 ≤ 0⊢ HeadBound width (configs (step (counterCfg cfg v bs (stRight v seen) (bs.length + 1))) 0)
rw [configs_zero, input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthn:ℕt:ℕht:t ≤ Nat.zero + 1a✝:0 < bs.length + 1hp:bs.length + 1 + Nat.zero = bs.length + 1hr:0 ≤ 0⊢ HeadBound width (step (counterCfg cfg v bs (stRight v seen) (bs.length + 1))) (right_end_run cfg v seen bs).1 input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthn:ℕt:ℕht:t ≤ Nat.zero + 1a✝:0 < bs.length + 1hp:bs.length + 1 + Nat.zero = bs.length + 1hr:0 ≤ 0⊢ HeadBound width (counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1))] input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthn:ℕt:ℕht:t ≤ Nat.zero + 1a✝:0 < bs.length + 1hp:bs.length + 1 + Nat.zero = bs.length + 1hr:0 ≤ 0⊢ HeadBound width (counterCfg cfg v bs (afterDecrement v seen) (bs.length + 1))
exact headBound_counterCfg cfg v _ _ _ width hcfg hw All goals completed! 🐙
· input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthn:ℕ⊢ ∀ (n : ℕ),
(∀ (p : ℕ),
0 < p →
p + n = bs.length + 1 → ∀ t ≤ n + 1, HeadBound width (configs (counterCfg cfg v bs (stRight v seen) p) t)) →
∀ (p : ℕ),
0 < p →
p + n.succ = bs.length + 1 →
∀ t ≤ n.succ + 1, HeadBound width (configs (counterCfg cfg v bs (stRight v seen) p) t) intro n ih p hp hn t ht input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthn✝:ℕn:ℕih:∀ (p : ℕ),
0 < p → p + n = bs.length + 1 → ∀ t ≤ n + 1, HeadBound width (configs (counterCfg cfg v bs (stRight v seen) p) t)p:ℕhp:0 < phn:p + n.succ = bs.length + 1t:ℕht:t ≤ n.succ + 1⊢ HeadBound width (configs (counterCfg cfg v bs (stRight v seen) p) t)
cases p with
| zero => zero input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthn✝:ℕn:ℕih:∀ (p : ℕ),
0 < p → p + n = bs.length + 1 → ∀ t ≤ n + 1, HeadBound width (configs (counterCfg cfg v bs (stRight v seen) p) t)t:ℕht:t ≤ n.succ + 1hp:0 < 0hn:0 + n.succ = bs.length + 1⊢ HeadBound width (configs (counterCfg cfg v bs (stRight v seen) 0) t) omega All goals completed! 🐙
| succ j => succ input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthn✝:ℕn:ℕih:∀ (p : ℕ),
0 < p → p + n = bs.length + 1 → ∀ t ≤ n + 1, HeadBound width (configs (counterCfg cfg v bs (stRight v seen) p) t)t:ℕht:t ≤ n.succ + 1j:ℕhp:0 < j + 1hn:j + 1 + n.succ = bs.length + 1⊢ HeadBound width (configs (counterCfg cfg v bs (stRight v seen) (j + 1)) t)
apply headBound_succ _ (n + 1) width
(headBound_counterCfg cfg v _ _ _ width hcfg (by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthn✝:ℕn:ℕih:∀ (p : ℕ),
0 < p → p + n = bs.length + 1 → ∀ t ≤ n + 1, HeadBound width (configs (counterCfg cfg v bs (stRight v seen) p) t)t:ℕht:t ≤ n.succ + 1j:ℕhp:0 < j + 1hn:j + 1 + n.succ = bs.length + 1⊢ j + 1 ≤ width omega All goals completed! 🐙)) ?_ t ht
intro r hr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthn✝:ℕn:ℕih:∀ (p : ℕ),
0 < p → p + n = bs.length + 1 → ∀ t ≤ n + 1, HeadBound width (configs (counterCfg cfg v bs (stRight v seen) p) t)t:ℕht:t ≤ n.succ + 1j:ℕhp:0 < j + 1hn:j + 1 + n.succ = bs.length + 1r:ℕhr:r ≤ n + 1⊢ HeadBound width (configs (step (counterCfg cfg v bs (stRight v seen) (j + 1))) r)
rw [(right_pos_run cfg v seen bs j (by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthn✝:ℕn:ℕih:∀ (p : ℕ),
0 < p → p + n = bs.length + 1 → ∀ t ≤ n + 1, HeadBound width (configs (counterCfg cfg v bs (stRight v seen) p) t)t:ℕht:t ≤ n.succ + 1j:ℕhp:0 < j + 1hn:j + 1 + n.succ = bs.length + 1r:ℕhr:r ≤ n + 1⊢ j < bs.length omega All goals completed! 🐙)).1] input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthn✝:ℕn:ℕih:∀ (p : ℕ),
0 < p → p + n = bs.length + 1 → ∀ t ≤ n + 1, HeadBound width (configs (counterCfg cfg v bs (stRight v seen) p) t)t:ℕht:t ≤ n.succ + 1j:ℕhp:0 < j + 1hn:j + 1 + n.succ = bs.length + 1r:ℕhr:r ≤ n + 1⊢ HeadBound width (configs (counterCfg cfg v bs (stRight v seen) (j + 2)) r)
exact ih (j + 2) (by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthn✝:ℕn:ℕih:∀ (p : ℕ),
0 < p → p + n = bs.length + 1 → ∀ t ≤ n + 1, HeadBound width (configs (counterCfg cfg v bs (stRight v seen) p) t)t:ℕht:t ≤ n.succ + 1j:ℕhp:0 < j + 1hn:j + 1 + n.succ = bs.length + 1r:ℕhr:r ≤ n + 1⊢ 0 < j + 2 omega All goals completed! 🐙) (by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolseen:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthn✝:ℕn:ℕih:∀ (p : ℕ),
0 < p → p + n = bs.length + 1 → ∀ t ≤ n + 1, HeadBound width (configs (counterCfg cfg v bs (stRight v seen) p) t)t:ℕht:t ≤ n.succ + 1j:ℕhp:0 < j + 1hn:j + 1 + n.succ = bs.length + 1r:ℕhr:r ≤ n + 1⊢ j + 2 + n = bs.length + 1 omega All goals completed! 🐙) r hrAll countdown prefixes preserve any nonnegative head bound containing the represented word and its right-hand blank.
theorem configs_decrement_headBound {input : List (Fin 3)}
(cfg : Cfg 4 (Fin 3) Control input) (v : Bool) (bs : List Bool) (width : ℕ)
(hcfg : HeadBound width cfg) (hw : bs.length + 1 ≤ width)
(hbs : 0 < Counter.value bs) (t : ℕ) (ht : t ≤ 2 * bs.length + 3) :
HeadBound width (machine.configs
(counterCfg cfg v bs (stDecrement v) (bs.length + 1)) t) := by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthhbs:0 < Counter.value bst:ℕht:t ≤ 2 * bs.length + 3⊢ HeadBound width (configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) t)
have hborrow := (configs_borrow cfg v bs [] false hbs).1 input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthhbs:0 < Counter.value bst:ℕht:t ≤ 2 * bs.length + 3hborrow:configs (counterCfg cfg v ([] ++ bs) (stBorrow v false) bs.length) bs.length =
counterCfg cfg v ([] ++ Counter.decrement bs) (stLeft v (false || (Counter.decrement bs).any id)) 0⊢ HeadBound width (configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) t)
simp only [List.nil_append, Bool.false_or] at hborrow input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthhbs:0 < Counter.value bst:ℕht:t ≤ 2 * bs.length + 3hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0⊢ HeadBound width (configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) t)
have hright : ∀ r ≤ bs.length + 1, HeadBound width (machine.configs
(counterCfg cfg v (Counter.decrement bs)
(stRight v ((Counter.decrement bs).any id)) 1) r) := by
apply configs_right_headBound cfg v _ _ width hcfg
(by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthhbs:0 < Counter.value bst:ℕht:t ≤ 2 * bs.length + 3hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0⊢ (Counter.decrement bs).length + 1 ≤ width simpa only [Counter.length_decrement] using hw All goals completed! 🐙) bs.length 1 (by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthhbs:0 < Counter.value bst:ℕht:t ≤ 2 * bs.length + 3hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0⊢ 0 < 1 omega All goals completed! 🐙)
rw [Counter.length_decrement input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthhbs:0 < Counter.value bst:ℕht:t ≤ 2 * bs.length + 3hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0⊢ 1 + bs.length = bs.length + 1] input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthhbs:0 < Counter.value bst:ℕht:t ≤ 2 * bs.length + 3hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0⊢ 1 + bs.length = bs.length + 1
omega input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthhbs:0 < Counter.value bst:ℕht:t ≤ 2 * bs.length + 3hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0hright:∀ r ≤ bs.length + 1,
HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1) r)⊢ HeadBound width (configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) t)
have hturn : ∀ r ≤ 1 + (bs.length + 1), HeadBound width (machine.configs
(counterCfg cfg v (Counter.decrement bs)
(stLeft v ((Counter.decrement bs).any id)) 0) r) := by
intro r hr input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthhbs:0 < Counter.value bst:ℕht:t ≤ 2 * bs.length + 3hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0hright:∀ r ≤ bs.length + 1,
HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1) r)r:ℕhr:r ≤ 1 + (bs.length + 1)⊢ HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) r)
apply headBound_succ _ (bs.length + 1) width
(headBound_counterCfg cfg v _ _ 0 width hcfg (by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthhbs:0 < Counter.value bst:ℕht:t ≤ 2 * bs.length + 3hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0hright:∀ r ≤ bs.length + 1,
HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1) r)r:ℕhr:r ≤ 1 + (bs.length + 1)⊢ 0 ≤ width omega All goals completed! 🐙)) ?_ r (by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthhbs:0 < Counter.value bst:ℕht:t ≤ 2 * bs.length + 3hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0hright:∀ r ≤ bs.length + 1,
HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1) r)r:ℕhr:r ≤ 1 + (bs.length + 1)⊢ r ≤ bs.length + 1 + 1 omega All goals completed! 🐙)
rw [(left_zero_run cfg v ((Counter.decrement bs).any id) (Counter.decrement bs)).1 input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthhbs:0 < Counter.value bst:ℕht:t ≤ 2 * bs.length + 3hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0hright:∀ r ≤ bs.length + 1,
HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1) r)r:ℕhr:r ≤ 1 + (bs.length + 1)⊢ ∀ r ≤ bs.length + 1,
HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1) r)] input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthhbs:0 < Counter.value bst:ℕht:t ≤ 2 * bs.length + 3hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0hright:∀ r ≤ bs.length + 1,
HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1) r)r:ℕhr:r ≤ 1 + (bs.length + 1)⊢ ∀ r ≤ bs.length + 1,
HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1) r)
exact hright input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthhbs:0 < Counter.value bst:ℕht:t ≤ 2 * bs.length + 3hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0hright:∀ r ≤ bs.length + 1,
HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1) r)hturn:∀ r ≤ 1 + (bs.length + 1),
HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) r)⊢ HeadBound width (configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) t)
have htail : ∀ r ≤ bs.length + (1 + (bs.length + 1)), HeadBound width (machine.configs
(counterCfg cfg v bs (stBorrow v false) bs.length) r) := by
apply headBound_add _ bs.length (1 + (bs.length + 1)) width ha input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthhbs:0 < Counter.value bst:ℕht:t ≤ 2 * bs.length + 3hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0hright:∀ r ≤ bs.length + 1,
HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1) r)hturn:∀ r ≤ 1 + (bs.length + 1),
HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) r)⊢ ∀ t ≤ bs.length, HeadBound width (configs (counterCfg cfg v bs (stBorrow v false) bs.length) t)hb input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthhbs:0 < Counter.value bst:ℕht:t ≤ 2 * bs.length + 3hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0hright:∀ r ≤ bs.length + 1,
HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1) r)hturn:∀ r ≤ 1 + (bs.length + 1),
HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) r)⊢ ∀ t ≤ 1 + (bs.length + 1),
HeadBound width (configs (configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length) t)
· ha input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthhbs:0 < Counter.value bst:ℕht:t ≤ 2 * bs.length + 3hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0hright:∀ r ≤ bs.length + 1,
HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1) r)hturn:∀ r ≤ 1 + (bs.length + 1),
HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) r)⊢ ∀ t ≤ bs.length, HeadBound width (configs (counterCfg cfg v bs (stBorrow v false) bs.length) t) intro r hr ha input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthhbs:0 < Counter.value bst:ℕht:t ≤ 2 * bs.length + 3hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0hright:∀ r ≤ bs.length + 1,
HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1) r)hturn:∀ r ≤ 1 + (bs.length + 1),
HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) r)r:ℕhr:r ≤ bs.length⊢ HeadBound width (configs (counterCfg cfg v bs (stBorrow v false) bs.length) r)
simpa only [List.nil_append] using
configs_borrow_headBound cfg v bs width hcfg [] false hbs (by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthhbs:0 < Counter.value bst:ℕht:t ≤ 2 * bs.length + 3hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0hright:∀ r ≤ bs.length + 1,
HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1) r)hturn:∀ r ≤ 1 + (bs.length + 1),
HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) r)r:ℕhr:r ≤ bs.length⊢ bs.length ≤ width omega All goals completed! 🐙) r hr
· hb input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthhbs:0 < Counter.value bst:ℕht:t ≤ 2 * bs.length + 3hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0hright:∀ r ≤ bs.length + 1,
HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1) r)hturn:∀ r ≤ 1 + (bs.length + 1),
HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) r)⊢ ∀ t ≤ 1 + (bs.length + 1),
HeadBound width (configs (configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length) t) rw [hborrow hb input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthhbs:0 < Counter.value bst:ℕht:t ≤ 2 * bs.length + 3hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0hright:∀ r ≤ bs.length + 1,
HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1) r)hturn:∀ r ≤ 1 + (bs.length + 1),
HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) r)⊢ ∀ r ≤ 1 + (bs.length + 1),
HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) r)] hb input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthhbs:0 < Counter.value bst:ℕht:t ≤ 2 * bs.length + 3hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0hright:∀ r ≤ bs.length + 1,
HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1) r)hturn:∀ r ≤ 1 + (bs.length + 1),
HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) r)⊢ ∀ r ≤ 1 + (bs.length + 1),
HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) r)
exact hturn input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthhbs:0 < Counter.value bst:ℕht:t ≤ 2 * bs.length + 3hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0hright:∀ r ≤ bs.length + 1,
HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1) r)hturn:∀ r ≤ 1 + (bs.length + 1),
HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) r)htail:∀ r ≤ bs.length + (1 + (bs.length + 1)), HeadBound width (configs (counterCfg cfg v bs (stBorrow v false) bs.length) r)⊢ HeadBound width (configs (counterCfg cfg v bs (stDecrement v) (bs.length + 1)) t)
apply headBound_succ _ (bs.length + (1 + (bs.length + 1))) width
(headBound_counterCfg cfg v _ _ _ width hcfg hw) ?_ t (by input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthhbs:0 < Counter.value bst:ℕht:t ≤ 2 * bs.length + 3hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0hright:∀ r ≤ bs.length + 1,
HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1) r)hturn:∀ r ≤ 1 + (bs.length + 1),
HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) r)htail:∀ r ≤ bs.length + (1 + (bs.length + 1)), HeadBound width (configs (counterCfg cfg v bs (stBorrow v false) bs.length) r)⊢ t ≤ bs.length + (1 + (bs.length + 1)) + 1 omega All goals completed! 🐙)
rw [step_decrement input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthhbs:0 < Counter.value bst:ℕht:t ≤ 2 * bs.length + 3hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0hright:∀ r ≤ bs.length + 1,
HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1) r)hturn:∀ r ≤ 1 + (bs.length + 1),
HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) r)htail:∀ r ≤ bs.length + (1 + (bs.length + 1)), HeadBound width (configs (counterCfg cfg v bs (stBorrow v false) bs.length) r)⊢ ∀ r ≤ bs.length + (1 + (bs.length + 1)), HeadBound width (configs (counterCfg cfg v bs (stBorrow v false) bs.length) r)] input:List (Fin 3)cfg:Cfg 4 (Fin 3) Control inputv:Boolbs:List Boolwidth:ℕhcfg:HeadBound width cfghw:bs.length + 1 ≤ widthhbs:0 < Counter.value bst:ℕht:t ≤ 2 * bs.length + 3hborrow:configs (counterCfg cfg v bs (stBorrow v false) bs.length) bs.length =
counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0hright:∀ r ≤ bs.length + 1,
HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stRight v ((Counter.decrement bs).any id)) 1) r)hturn:∀ r ≤ 1 + (bs.length + 1),
HeadBound width (configs (counterCfg cfg v (Counter.decrement bs) (stLeft v ((Counter.decrement bs).any id)) 0) r)htail:∀ r ≤ bs.length + (1 + (bs.length + 1)), HeadBound width (configs (counterCfg cfg v bs (stBorrow v false) bs.length) r)⊢ ∀ r ≤ bs.length + (1 + (bs.length + 1)), HeadBound width (configs (counterCfg cfg v bs (stBorrow v false) bs.length) r)
exact htail All goals completed! 🐙end Geb.BitTree.Elias.Machine