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.MachineHeaderset_option doc.verso trueWork space throughout the delta-header macros
Appending a header bit needs one additional binary cell. The following countdown sweeps stay between their marked origin and right-hand blank. Composing these bounds controls every intermediate configuration of both header phases.
Implementation notes
These Cslib execution statements inherit Classical.choice from its input reader.
Tags
Elias delta code, Turing machine, space complexity
@[expose] public sectionnamespace Geb.BitTree.Elias.Machineopen Turing MultiTapeTMThe first binary counter's decrement stays within a boundary configuration's head bound.
theorem decrement_false_scan_headBound (input : List (Fin 3))
(pos : Fin (input.length + 2)) (pending zeros : ℕ) (bs cs : List Bool) (width : ℕ)
(hcfg : HeadBound width (scanCfg input pos (stDecrement false) pending zeros bs cs))
(hw : bs.length + 1 ≤ width) (hb : 0 < Counter.value bs)
(t : ℕ) (ht : t ≤ 2 * bs.length + 3) :
HeadBound width (machine.configs
(scanCfg input pos (stDecrement false) pending zeros bs cs) t) := input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕzeros:ℕbs:List Boolcs:List Boolwidth:ℕhcfg:HeadBound width (scanCfg input pos (stDecrement false) pending zeros bs cs)hw:bs.length + 1 ≤ widthhb:0 < Counter.value bst:ℕht:t ≤ 2 * bs.length + 3⊢ HeadBound width (configs (scanCfg input pos (stDecrement false) pending zeros bs cs) t)
input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕzeros:ℕbs:List Boolcs:List Boolwidth:ℕhcfg:HeadBound width (scanCfg input pos (stDecrement false) pending zeros bs cs)hw:bs.length + 1 ≤ widthhb:0 < Counter.value bst:ℕht:t ≤ 2 * bs.length + 3h:HeadBound width
(configs
(counterCfg (scanCfg input pos (stDecrement false) pending zeros bs cs) false bs (stDecrement false)
(bs.length + 1))
t)⊢ HeadBound width (configs (scanCfg input pos (stDecrement false) pending zeros bs cs) t)
rwa [input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕzeros:ℕbs:List Boolcs:List Boolwidth:ℕhcfg:HeadBound width (scanCfg input pos (stDecrement false) pending zeros bs cs)hw:bs.length + 1 ≤ widthhb:0 < Counter.value bst:ℕht:t ≤ 2 * bs.length + 3h:HeadBound width (configs (scanCfg input pos (stDecrement false) pending zeros bs cs) t)⊢ HeadBound width (configs (scanCfg input pos (stDecrement false) pending zeros bs cs) t)input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕzeros:ℕbs:List Boolcs:List Boolwidth:ℕhcfg:HeadBound width (scanCfg input pos (stDecrement false) pending zeros bs cs)hw:bs.length + 1 ≤ widthhb:0 < Counter.value bst:ℕht:t ≤ 2 * bs.length + 3h:HeadBound width (configs (scanCfg input pos (stDecrement false) pending zeros bs cs) t)⊢ HeadBound width (configs (scanCfg input pos (stDecrement false) pending zeros bs cs) t) at hThe second binary counter's decrement stays within its boundary head bound.
theorem decrement_true_scan_headBound (input : List (Fin 3))
(pos : Fin (input.length + 2)) (pending zeros : ℕ) (bs cs : List Bool) (width : ℕ)
(hcfg : HeadBound width (scanCfg input pos (stDecrement true) pending zeros bs cs))
(hw : cs.length + 1 ≤ width) (hc : 0 < Counter.value cs)
(t : ℕ) (ht : t ≤ 2 * cs.length + 3) :
HeadBound width (machine.configs
(scanCfg input pos (stDecrement true) pending zeros bs cs) t) := input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕzeros:ℕbs:List Boolcs:List Boolwidth:ℕhcfg:HeadBound width (scanCfg input pos (stDecrement true) pending zeros bs cs)hw:cs.length + 1 ≤ widthhc:0 < Counter.value cst:ℕht:t ≤ 2 * cs.length + 3⊢ HeadBound width (configs (scanCfg input pos (stDecrement true) pending zeros bs cs) t)
input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕzeros:ℕbs:List Boolcs:List Boolwidth:ℕhcfg:HeadBound width (scanCfg input pos (stDecrement true) pending zeros bs cs)hw:cs.length + 1 ≤ widthhc:0 < Counter.value cst:ℕht:t ≤ 2 * cs.length + 3h:HeadBound width
(configs
(counterCfg (scanCfg input pos (stDecrement true) pending zeros bs cs) true cs (stDecrement true) (cs.length + 1))
t)⊢ HeadBound width (configs (scanCfg input pos (stDecrement true) pending zeros bs cs) t)
rwa [input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕzeros:ℕbs:List Boolcs:List Boolwidth:ℕhcfg:HeadBound width (scanCfg input pos (stDecrement true) pending zeros bs cs)hw:cs.length + 1 ≤ widthhc:0 < Counter.value cst:ℕht:t ≤ 2 * cs.length + 3h:HeadBound width (configs (scanCfg input pos (stDecrement true) pending zeros bs cs) t)⊢ HeadBound width (configs (scanCfg input pos (stDecrement true) pending zeros bs cs) t)input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕzeros:ℕbs:List Boolcs:List Boolwidth:ℕhcfg:HeadBound width (scanCfg input pos (stDecrement true) pending zeros bs cs)hw:cs.length + 1 ≤ widthhc:0 < Counter.value cst:ℕht:t ≤ 2 * cs.length + 3h:HeadBound width (configs (scanCfg input pos (stDecrement true) pending zeros bs cs) t)⊢ HeadBound width (configs (scanCfg input pos (stDecrement true) pending zeros bs cs) t) at hEvery width-field macro prefix stays within the available unary and binary widths.
theorem configs_size_headBound (input : List (Fin 3)) (pos : Fin (input.length + 2))
(pending remaining : ℕ) (bs cs : List Bool) (b : Bool)
(hr : 0 < remaining) (hb : 0 < Counter.value bs)
(hin : (scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b))
(width : ℕ) (hp : pending + 1 ≤ width) (hz : remaining + 1 ≤ width)
(hbs : bs.length + 2 ≤ width) (hcs : cs.length + 2 ≤ width)
(t : ℕ) (ht : t ≤ if remaining = 1 then 2 * bs.length + 7 else 2) :
HeadBound width (machine.configs
(scanCfg input pos stSizeBit pending remaining bs cs) t) := input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2⊢ HeadBound width (configs (scanCfg input pos stSizeBit pending remaining bs cs) t)
input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending (remaining - 1 + 1) bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending (remaining - 1 + 1) bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs⊢ HeadBound width (configs (scanCfg input pos stSizeBit pending remaining bs cs) t)
input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs⊢ HeadBound width (configs (scanCfg input pos stSizeBit pending remaining bs cs) t)
have hinit := scanCfg_headBound input pos stSizeBit pending remaining bs cs width
(by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs⊢ pending ≤ width omega All goals completed! 🐙) (by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs⊢ remaining ≤ width omega All goals completed! 🐙) (by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs⊢ bs.length + 1 ≤ width omega All goals completed! 🐙) (by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs⊢ cs.length + 1 ≤ width omega All goals completed! 🐙) input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)⊢ HeadBound width (configs (scanCfg input pos stSizeBit pending remaining bs cs) t)
have hcheck := scanCfg_headBound input (moveInputPos pos 1) stSizeCheck pending
(remaining - 1) (b :: bs) cs width (by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)⊢ pending ≤ width omega All goals completed! 🐙) (by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)⊢ remaining - 1 ≤ width omega All goals completed! 🐙)
(by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)⊢ (b :: bs).length + 1 ≤ width simp only [List.length_cons] input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)⊢ bs.length + 1 + 1 ≤ width; omega All goals completed! 🐙) (by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)⊢ cs.length + 1 ≤ width omega All goals completed! 🐙) input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)⊢ HeadBound width (configs (scanCfg input pos stSizeBit pending remaining bs cs) t)
have htwo : machine.configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1)
(if remaining - 1 = 0 then stDecrement false else stSizeBit)
pending (remaining - 1) (b :: bs) cs := by
rw [configs_succ_eq_step, input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)⊢ configs (step (scanCfg input pos stSizeBit pending remaining bs cs)) 1 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) cs hs hin, input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)⊢ configs (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs) 1 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) cs configs_succ_eq_step, input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)⊢ configs (step (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)) 0 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) cs configs_zero, input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)⊢ step (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs) =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) cs step_sizeCheck input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)⊢ scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending (remaining - 1)
(b :: bs) cs =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) cs] input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) cs⊢ HeadBound width (configs (scanCfg input pos stSizeBit pending remaining bs cs) t)
have hfirst : ∀ u ≤ 2, HeadBound width (machine.configs
(scanCfg input pos stSizeBit pending remaining bs cs) u) := by
apply headBound_succ _ 1 width hinit input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) cs⊢ ∀ t ≤ 1, HeadBound width (configs (step (scanCfg input pos stSizeBit pending remaining bs cs)) t)
rw [hs hin input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) cs⊢ ∀ t ≤ 1,
HeadBound width (configs (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs) t)] input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) cs⊢ ∀ t ≤ 1,
HeadBound width (configs (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs) t)
intro u hu input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) csu:ℕhu:u ≤ 1⊢ HeadBound width (configs (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs) u)
apply headBound_succ _ 0 width hcheck ?_ u hu input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) csu:ℕhu:u ≤ 1⊢ ∀ t ≤ 0,
HeadBound width
(configs (step (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)) t)
intro v hv input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) csu:ℕhu:u ≤ 1v:ℕhv:v ≤ 0⊢ HeadBound width (configs (step (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)) v)
have he : v = 0 := by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2⊢ HeadBound width (configs (scanCfg input pos stSizeBit pending remaining bs cs) t) omega input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) csu:ℕhu:u ≤ 1v:ℕhv:v ≤ 0he:v = 0⊢ HeadBound width (configs (step (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)) v)
subst v input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) csu:ℕhu:u ≤ 1hv:0 ≤ 0⊢ HeadBound width (configs (step (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)) 0)
rw [configs_zero, input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) csu:ℕhu:u ≤ 1hv:0 ≤ 0⊢ HeadBound width (step (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)) step_sizeCheck input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) csu:ℕhu:u ≤ 1hv:0 ≤ 0⊢ HeadBound width
(scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) cs)] input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) csu:ℕhu:u ≤ 1hv:0 ≤ 0⊢ HeadBound width
(scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) cs)
exact scanCfg_headBound input (moveInputPos pos 1) _ pending (remaining - 1)
(b :: bs) cs width (by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) csu:ℕhu:u ≤ 1hv:0 ≤ 0⊢ pending ≤ width omega All goals completed! 🐙) (by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) csu:ℕhu:u ≤ 1hv:0 ≤ 0⊢ remaining - 1 ≤ width omega All goals completed! 🐙)
(by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) csu:ℕhu:u ≤ 1hv:0 ≤ 0⊢ (b :: bs).length + 1 ≤ width simp only [List.length_cons] input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) csu:ℕhu:u ≤ 1hv:0 ≤ 0⊢ bs.length + 1 + 1 ≤ width; omega All goals completed! 🐙) (by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) csu:ℕhu:u ≤ 1hv:0 ≤ 0⊢ cs.length + 1 ≤ width omega All goals completed! 🐙) input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) cshfirst:∀ u ≤ 2, HeadBound width (configs (scanCfg input pos stSizeBit pending remaining bs cs) u)⊢ HeadBound width (configs (scanCfg input pos stSizeBit pending remaining bs cs) t)
by_cases he : remaining = 1 pos input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) cshfirst:∀ u ≤ 2, HeadBound width (configs (scanCfg input pos stSizeBit pending remaining bs cs) u)he:remaining = 1⊢ HeadBound width (configs (scanCfg input pos stSizeBit pending remaining bs cs) t)neg input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) cshfirst:∀ u ≤ 2, HeadBound width (configs (scanCfg input pos stSizeBit pending remaining bs cs) u)he:¬remaining = 1⊢ HeadBound width (configs (scanCfg input pos stSizeBit pending remaining bs cs) t)
· pos input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) cshfirst:∀ u ≤ 2, HeadBound width (configs (scanCfg input pos stSizeBit pending remaining bs cs) u)he:remaining = 1⊢ HeadBound width (configs (scanCfg input pos stSizeBit pending remaining bs cs) t) have hv : 0 < Counter.value (b :: bs) := by rw [Counter.value_cons input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) cshfirst:∀ u ≤ 2, HeadBound width (configs (scanCfg input pos stSizeBit pending remaining bs cs) u)he:remaining = 1⊢ 0 < 2 * Counter.value bs + b.toNat] input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) cshfirst:∀ u ≤ 2, HeadBound width (configs (scanCfg input pos stSizeBit pending remaining bs cs) u)he:remaining = 1⊢ 0 < 2 * Counter.value bs + b.toNat; omega pos input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) cshfirst:∀ u ≤ 2, HeadBound width (configs (scanCfg input pos stSizeBit pending remaining bs cs) u)he:remaining = 1hv:0 < Counter.value (b :: bs)⊢ HeadBound width (configs (scanCfg input pos stSizeBit pending remaining bs cs) t)
apply headBound_add _ 2 (2 * (b :: bs).length + 3) width hfirst ?_ t
(by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) cshfirst:∀ u ≤ 2, HeadBound width (configs (scanCfg input pos stSizeBit pending remaining bs cs) u)he:remaining = 1hv:0 < Counter.value (b :: bs)⊢ t ≤ 2 + (2 * (b :: bs).length + 3) simp only [he, ↓reduceIte, List.length_cons] at ht ⊢ input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕhs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) cshfirst:∀ u ≤ 2, HeadBound width (configs (scanCfg input pos stSizeBit pending remaining bs cs) u)he:remaining = 1hv:0 < Counter.value (b :: bs)ht:t ≤ 2 * bs.length + 7⊢ t ≤ 2 + (2 * (bs.length + 1) + 3); omega All goals completed! 🐙)
rw [htwo input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) cshfirst:∀ u ≤ 2, HeadBound width (configs (scanCfg input pos stSizeBit pending remaining bs cs) u)he:remaining = 1hv:0 < Counter.value (b :: bs)⊢ ∀ t ≤ 2 * (b :: bs).length + 3,
HeadBound width
(configs
(scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) cs)
t)] input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) cshfirst:∀ u ≤ 2, HeadBound width (configs (scanCfg input pos stSizeBit pending remaining bs cs) u)he:remaining = 1hv:0 < Counter.value (b :: bs)⊢ ∀ t ≤ 2 * (b :: bs).length + 3,
HeadBound width
(configs
(scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) cs)
t)
simp only [he, Nat.sub_self, ↓reduceIte] input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) cshfirst:∀ u ≤ 2, HeadBound width (configs (scanCfg input pos stSizeBit pending remaining bs cs) u)he:remaining = 1hv:0 < Counter.value (b :: bs)⊢ ∀ t ≤ 2 * (b :: bs).length + 3,
HeadBound width (configs (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 (b :: bs) cs) t)
intro u hu input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) cshfirst:∀ u ≤ 2, HeadBound width (configs (scanCfg input pos stSizeBit pending remaining bs cs) u)he:remaining = 1hv:0 < Counter.value (b :: bs)u:ℕhu:u ≤ 2 * (b :: bs).length + 3⊢ HeadBound width (configs (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 (b :: bs) cs) u)
exact decrement_false_scan_headBound input (moveInputPos pos 1) pending 0 (b :: bs) cs
width (scanCfg_headBound input (moveInputPos pos 1) _ pending 0 (b :: bs) cs width
(by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) cshfirst:∀ u ≤ 2, HeadBound width (configs (scanCfg input pos stSizeBit pending remaining bs cs) u)he:remaining = 1hv:0 < Counter.value (b :: bs)u:ℕhu:u ≤ 2 * (b :: bs).length + 3⊢ pending ≤ width omega All goals completed! 🐙) (by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) cshfirst:∀ u ≤ 2, HeadBound width (configs (scanCfg input pos stSizeBit pending remaining bs cs) u)he:remaining = 1hv:0 < Counter.value (b :: bs)u:ℕhu:u ≤ 2 * (b :: bs).length + 3⊢ 0 ≤ width omega All goals completed! 🐙) (by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) cshfirst:∀ u ≤ 2, HeadBound width (configs (scanCfg input pos stSizeBit pending remaining bs cs) u)he:remaining = 1hv:0 < Counter.value (b :: bs)u:ℕhu:u ≤ 2 * (b :: bs).length + 3⊢ (b :: bs).length + 1 ≤ width simp only [List.length_cons] input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) cshfirst:∀ u ≤ 2, HeadBound width (configs (scanCfg input pos stSizeBit pending remaining bs cs) u)he:remaining = 1hv:0 < Counter.value (b :: bs)u:ℕhu:u ≤ 2 * (b :: bs).length + 3⊢ bs.length + 1 + 1 ≤ width; omega All goals completed! 🐙) (by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) cshfirst:∀ u ≤ 2, HeadBound width (configs (scanCfg input pos stSizeBit pending remaining bs cs) u)he:remaining = 1hv:0 < Counter.value (b :: bs)u:ℕhu:u ≤ 2 * (b :: bs).length + 3⊢ cs.length + 1 ≤ width omega All goals completed! 🐙))
(by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) cshfirst:∀ u ≤ 2, HeadBound width (configs (scanCfg input pos stSizeBit pending remaining bs cs) u)he:remaining = 1hv:0 < Counter.value (b :: bs)u:ℕhu:u ≤ 2 * (b :: bs).length + 3⊢ (b :: bs).length + 1 ≤ width simp only [List.length_cons] input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) cshfirst:∀ u ≤ 2, HeadBound width (configs (scanCfg input pos stSizeBit pending remaining bs cs) u)he:remaining = 1hv:0 < Counter.value (b :: bs)u:ℕhu:u ≤ 2 * (b :: bs).length + 3⊢ bs.length + 1 + 1 ≤ width; omega All goals completed! 🐙) hv u hu
· neg input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) cshfirst:∀ u ≤ 2, HeadBound width (configs (scanCfg input pos stSizeBit pending remaining bs cs) u)he:¬remaining = 1⊢ HeadBound width (configs (scanCfg input pos stSizeBit pending remaining bs cs) t) exact hfirst t (by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:0 < Counter.value bshin:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:remaining + 1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 7 else 2hs:(scanCfg input pos stSizeBit pending remaining bs cs).inputSymbol = some (boolEmb b) →
step (scanCfg input pos stSizeBit pending remaining bs cs) =
scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cshinit:HeadBound width (scanCfg input pos stSizeBit pending remaining bs cs)hcheck:HeadBound width (scanCfg input (moveInputPos pos 1) stSizeCheck pending (remaining - 1) (b :: bs) cs)htwo:configs (scanCfg input pos stSizeBit pending remaining bs cs) 2 =
scanCfg input (moveInputPos pos 1) (if remaining - 1 = 0 then stDecrement false else stSizeBit) pending
(remaining - 1) (b :: bs) cshfirst:∀ u ≤ 2, HeadBound width (configs (scanCfg input pos stSizeBit pending remaining bs cs) u)he:¬remaining = 1⊢ t ≤ 2 simpa only [he, ↓reduceIte] using ht All goals completed! 🐙)Every length-field macro prefix is bounded by word widths, regardless of decoded value.
theorem configs_length_headBound (input : List (Fin 3)) (pos : Fin (input.length + 2))
(pending remaining : ℕ) (bs cs : List Bool) (b : Bool)
(hr : 0 < remaining) (hb : Counter.value bs = remaining) (hc : 0 < Counter.value cs)
(hin : (scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b))
(width : ℕ) (hp : pending + 1 ≤ width) (hz : 1 ≤ width)
(hbs : bs.length + 2 ≤ width) (hcs : cs.length + 2 ≤ width)
(t : ℕ)
(ht : t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9
else 2 * bs.length + 4) :
HeadBound width (machine.configs
(scanCfg input pos stLengthBit pending 0 bs cs) t) := by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4⊢ HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) t)
have hinit := scanCfg_headBound input pos stLengthBit pending 0 bs cs width
(by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4⊢ pending ≤ width omega All goals completed! 🐙) (by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4⊢ 0 ≤ width omega All goals completed! 🐙) (by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4⊢ bs.length + 1 ≤ width omega All goals completed! 🐙) (by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4⊢ cs.length + 1 ≤ width omega All goals completed! 🐙) input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)⊢ HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) t)
have hdec := scanCfg_headBound input (moveInputPos pos 1) (stDecrement false) pending
0 bs (b :: cs) width (by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)⊢ pending ≤ width omega All goals completed! 🐙) (by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)⊢ 0 ≤ width omega All goals completed! 🐙) (by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)⊢ bs.length + 1 ≤ width omega All goals completed! 🐙)
(by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)⊢ (b :: cs).length + 1 ≤ width simp only [List.length_cons] input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)⊢ cs.length + 1 + 1 ≤ width; omega All goals completed! 🐙) input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))⊢ HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) t)
have hbpos : 0 < Counter.value bs := by omega input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bs⊢ HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) t)
have hfirst : ∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (machine.configs
(scanCfg input pos stLengthBit pending 0 bs cs) u) := by
intro u hu input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bsu:ℕhu:u ≤ 1 + (2 * bs.length + 3)⊢ HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)
apply headBound_succ _ (2 * bs.length + 3) width hinit ?_ u (by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bsu:ℕhu:u ≤ 1 + (2 * bs.length + 3)⊢ u ≤ 2 * bs.length + 3 + 1 omega All goals completed! 🐙)
rw [step_length input pos pending 0 bs cs b hin input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bsu:ℕhu:u ≤ 1 + (2 * bs.length + 3)⊢ ∀ t ≤ 2 * bs.length + 3,
HeadBound width (configs (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs)) t)] input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bsu:ℕhu:u ≤ 1 + (2 * bs.length + 3)⊢ ∀ t ≤ 2 * bs.length + 3,
HeadBound width (configs (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs)) t)
exact decrement_false_scan_headBound input (moveInputPos pos 1) pending 0 bs (b :: cs)
width hdec (by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bsu:ℕhu:u ≤ 1 + (2 * bs.length + 3)⊢ bs.length + 1 ≤ width omega All goals completed! 🐙) hbpos input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bshfirst:∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)⊢ HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) t)
by_cases he : remaining = 1 pos input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bshfirst:∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)he:remaining = 1⊢ HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) t)neg input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bshfirst:∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)he:¬remaining = 1⊢ HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) t)
· pos input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bshfirst:∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)he:remaining = 1⊢ HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) t) have hzero : (Counter.decrement bs).any id = false := by
apply (Counter.any_eq_false_iff _).mpr input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bshfirst:∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)he:remaining = 1⊢ Counter.value (Counter.decrement bs) = 0
rw [Counter.value_decrement _ hbpos, input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bshfirst:∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)he:remaining = 1⊢ Counter.value bs - 1 = 0 hb, input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bshfirst:∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)he:remaining = 1⊢ remaining - 1 = 0 he input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bshfirst:∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)he:remaining = 1⊢ 1 - 1 = 0] pos input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bshfirst:∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)he:remaining = 1hzero:(Counter.decrement bs).any id = false⊢ HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) t)
have hend : machine.configs (scanCfg input pos stLengthBit pending 0 bs cs)
(1 + (2 * bs.length + 3)) =
scanCfg input (moveInputPos pos 1) (stDecrement true) pending 0
(Counter.decrement bs) (b :: cs) := by
rw [Nat.add_comm 1, input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bshfirst:∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)he:remaining = 1hzero:(Counter.decrement bs).any id = false⊢ configs (scanCfg input pos stLengthBit pending 0 bs cs) (2 * bs.length + 3 + 1) =
scanCfg input (moveInputPos pos 1) (stDecrement true) pending 0 (Counter.decrement bs) (b :: cs) configs_succ_eq_step, input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bshfirst:∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)he:remaining = 1hzero:(Counter.decrement bs).any id = false⊢ configs (step (scanCfg input pos stLengthBit pending 0 bs cs)) (2 * bs.length + 3) =
scanCfg input (moveInputPos pos 1) (stDecrement true) pending 0 (Counter.decrement bs) (b :: cs) step_length input pos pending 0 bs cs b hin, input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bshfirst:∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)he:remaining = 1hzero:(Counter.decrement bs).any id = false⊢ configs (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs)) (2 * bs.length + 3) =
scanCfg input (moveInputPos pos 1) (stDecrement true) pending 0 (Counter.decrement bs) (b :: cs)
(configs_decrement_false_scan input (moveInputPos pos 1) pending 0 bs (b :: cs) hbpos).1, input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bshfirst:∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)he:remaining = 1hzero:(Counter.decrement bs).any id = false⊢ scanCfg input (moveInputPos pos 1) (afterDecrement false ((Counter.decrement bs).any id)) pending 0
(Counter.decrement bs) (b :: cs) =
scanCfg input (moveInputPos pos 1) (stDecrement true) pending 0 (Counter.decrement bs) (b :: cs)
hzero input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bshfirst:∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)he:remaining = 1hzero:(Counter.decrement bs).any id = false⊢ scanCfg input (moveInputPos pos 1) (afterDecrement false false) pending 0 (Counter.decrement bs) (b :: cs) =
scanCfg input (moveInputPos pos 1) (stDecrement true) pending 0 (Counter.decrement bs) (b :: cs)] input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bshfirst:∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)he:remaining = 1hzero:(Counter.decrement bs).any id = false⊢ scanCfg input (moveInputPos pos 1) (afterDecrement false false) pending 0 (Counter.decrement bs) (b :: cs) =
scanCfg input (moveInputPos pos 1) (stDecrement true) pending 0 (Counter.decrement bs) (b :: cs)
rfl pos input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bshfirst:∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)he:remaining = 1hzero:(Counter.decrement bs).any id = falsehend:configs (scanCfg input pos stLengthBit pending 0 bs cs) (1 + (2 * bs.length + 3)) =
scanCfg input (moveInputPos pos 1) (stDecrement true) pending 0 (Counter.decrement bs) (b :: cs)⊢ HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) t)
have hv : 0 < Counter.value (b :: cs) := by rw [Counter.value_cons input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bshfirst:∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)he:remaining = 1hzero:(Counter.decrement bs).any id = falsehend:configs (scanCfg input pos stLengthBit pending 0 bs cs) (1 + (2 * bs.length + 3)) =
scanCfg input (moveInputPos pos 1) (stDecrement true) pending 0 (Counter.decrement bs) (b :: cs)⊢ 0 < 2 * Counter.value cs + b.toNat] input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bshfirst:∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)he:remaining = 1hzero:(Counter.decrement bs).any id = falsehend:configs (scanCfg input pos stLengthBit pending 0 bs cs) (1 + (2 * bs.length + 3)) =
scanCfg input (moveInputPos pos 1) (stDecrement true) pending 0 (Counter.decrement bs) (b :: cs)⊢ 0 < 2 * Counter.value cs + b.toNat; omega pos input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bshfirst:∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)he:remaining = 1hzero:(Counter.decrement bs).any id = falsehend:configs (scanCfg input pos stLengthBit pending 0 bs cs) (1 + (2 * bs.length + 3)) =
scanCfg input (moveInputPos pos 1) (stDecrement true) pending 0 (Counter.decrement bs) (b :: cs)hv:0 < Counter.value (b :: cs)⊢ HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) t)
apply headBound_add _ (1 + (2 * bs.length + 3)) (2 * (b :: cs).length + 3)
width hfirst ?_ t (by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bshfirst:∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)he:remaining = 1hzero:(Counter.decrement bs).any id = falsehend:configs (scanCfg input pos stLengthBit pending 0 bs cs) (1 + (2 * bs.length + 3)) =
scanCfg input (moveInputPos pos 1) (stDecrement true) pending 0 (Counter.decrement bs) (b :: cs)hv:0 < Counter.value (b :: cs)⊢ t ≤ 1 + (2 * bs.length + 3) + (2 * (b :: cs).length + 3) simp only [he, ↓reduceIte, List.length_cons] at ht ⊢ input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕhinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bshfirst:∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)he:remaining = 1hzero:(Counter.decrement bs).any id = falsehend:configs (scanCfg input pos stLengthBit pending 0 bs cs) (1 + (2 * bs.length + 3)) =
scanCfg input (moveInputPos pos 1) (stDecrement true) pending 0 (Counter.decrement bs) (b :: cs)hv:0 < Counter.value (b :: cs)ht:t ≤ 2 * bs.length + 2 * cs.length + 9⊢ t ≤ 1 + (2 * bs.length + 3) + (2 * (cs.length + 1) + 3); omega All goals completed! 🐙)
rw [hend input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bshfirst:∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)he:remaining = 1hzero:(Counter.decrement bs).any id = falsehend:configs (scanCfg input pos stLengthBit pending 0 bs cs) (1 + (2 * bs.length + 3)) =
scanCfg input (moveInputPos pos 1) (stDecrement true) pending 0 (Counter.decrement bs) (b :: cs)hv:0 < Counter.value (b :: cs)⊢ ∀ t ≤ 2 * (b :: cs).length + 3,
HeadBound width
(configs (scanCfg input (moveInputPos pos 1) (stDecrement true) pending 0 (Counter.decrement bs) (b :: cs)) t)] input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bshfirst:∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)he:remaining = 1hzero:(Counter.decrement bs).any id = falsehend:configs (scanCfg input pos stLengthBit pending 0 bs cs) (1 + (2 * bs.length + 3)) =
scanCfg input (moveInputPos pos 1) (stDecrement true) pending 0 (Counter.decrement bs) (b :: cs)hv:0 < Counter.value (b :: cs)⊢ ∀ t ≤ 2 * (b :: cs).length + 3,
HeadBound width
(configs (scanCfg input (moveInputPos pos 1) (stDecrement true) pending 0 (Counter.decrement bs) (b :: cs)) t)
intro u hu input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bshfirst:∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)he:remaining = 1hzero:(Counter.decrement bs).any id = falsehend:configs (scanCfg input pos stLengthBit pending 0 bs cs) (1 + (2 * bs.length + 3)) =
scanCfg input (moveInputPos pos 1) (stDecrement true) pending 0 (Counter.decrement bs) (b :: cs)hv:0 < Counter.value (b :: cs)u:ℕhu:u ≤ 2 * (b :: cs).length + 3⊢ HeadBound width
(configs (scanCfg input (moveInputPos pos 1) (stDecrement true) pending 0 (Counter.decrement bs) (b :: cs)) u)
exact decrement_true_scan_headBound input (moveInputPos pos 1) pending 0
(Counter.decrement bs) (b :: cs) width
(scanCfg_headBound input (moveInputPos pos 1) _ pending 0
(Counter.decrement bs) (b :: cs) width (by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bshfirst:∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)he:remaining = 1hzero:(Counter.decrement bs).any id = falsehend:configs (scanCfg input pos stLengthBit pending 0 bs cs) (1 + (2 * bs.length + 3)) =
scanCfg input (moveInputPos pos 1) (stDecrement true) pending 0 (Counter.decrement bs) (b :: cs)hv:0 < Counter.value (b :: cs)u:ℕhu:u ≤ 2 * (b :: cs).length + 3⊢ pending ≤ width omega All goals completed! 🐙) (by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bshfirst:∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)he:remaining = 1hzero:(Counter.decrement bs).any id = falsehend:configs (scanCfg input pos stLengthBit pending 0 bs cs) (1 + (2 * bs.length + 3)) =
scanCfg input (moveInputPos pos 1) (stDecrement true) pending 0 (Counter.decrement bs) (b :: cs)hv:0 < Counter.value (b :: cs)u:ℕhu:u ≤ 2 * (b :: cs).length + 3⊢ 0 ≤ width omega All goals completed! 🐙)
(by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bshfirst:∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)he:remaining = 1hzero:(Counter.decrement bs).any id = falsehend:configs (scanCfg input pos stLengthBit pending 0 bs cs) (1 + (2 * bs.length + 3)) =
scanCfg input (moveInputPos pos 1) (stDecrement true) pending 0 (Counter.decrement bs) (b :: cs)hv:0 < Counter.value (b :: cs)u:ℕhu:u ≤ 2 * (b :: cs).length + 3⊢ (Counter.decrement bs).length + 1 ≤ width rw [Counter.length_decrement input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bshfirst:∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)he:remaining = 1hzero:(Counter.decrement bs).any id = falsehend:configs (scanCfg input pos stLengthBit pending 0 bs cs) (1 + (2 * bs.length + 3)) =
scanCfg input (moveInputPos pos 1) (stDecrement true) pending 0 (Counter.decrement bs) (b :: cs)hv:0 < Counter.value (b :: cs)u:ℕhu:u ≤ 2 * (b :: cs).length + 3⊢ bs.length + 1 ≤ width] input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bshfirst:∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)he:remaining = 1hzero:(Counter.decrement bs).any id = falsehend:configs (scanCfg input pos stLengthBit pending 0 bs cs) (1 + (2 * bs.length + 3)) =
scanCfg input (moveInputPos pos 1) (stDecrement true) pending 0 (Counter.decrement bs) (b :: cs)hv:0 < Counter.value (b :: cs)u:ℕhu:u ≤ 2 * (b :: cs).length + 3⊢ bs.length + 1 ≤ width; omega All goals completed! 🐙) (by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bshfirst:∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)he:remaining = 1hzero:(Counter.decrement bs).any id = falsehend:configs (scanCfg input pos stLengthBit pending 0 bs cs) (1 + (2 * bs.length + 3)) =
scanCfg input (moveInputPos pos 1) (stDecrement true) pending 0 (Counter.decrement bs) (b :: cs)hv:0 < Counter.value (b :: cs)u:ℕhu:u ≤ 2 * (b :: cs).length + 3⊢ (b :: cs).length + 1 ≤ width simp only [List.length_cons] input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bshfirst:∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)he:remaining = 1hzero:(Counter.decrement bs).any id = falsehend:configs (scanCfg input pos stLengthBit pending 0 bs cs) (1 + (2 * bs.length + 3)) =
scanCfg input (moveInputPos pos 1) (stDecrement true) pending 0 (Counter.decrement bs) (b :: cs)hv:0 < Counter.value (b :: cs)u:ℕhu:u ≤ 2 * (b :: cs).length + 3⊢ cs.length + 1 + 1 ≤ width; omega All goals completed! 🐙))
(by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bshfirst:∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)he:remaining = 1hzero:(Counter.decrement bs).any id = falsehend:configs (scanCfg input pos stLengthBit pending 0 bs cs) (1 + (2 * bs.length + 3)) =
scanCfg input (moveInputPos pos 1) (stDecrement true) pending 0 (Counter.decrement bs) (b :: cs)hv:0 < Counter.value (b :: cs)u:ℕhu:u ≤ 2 * (b :: cs).length + 3⊢ (b :: cs).length + 1 ≤ width simp only [List.length_cons] input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bshfirst:∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)he:remaining = 1hzero:(Counter.decrement bs).any id = falsehend:configs (scanCfg input pos stLengthBit pending 0 bs cs) (1 + (2 * bs.length + 3)) =
scanCfg input (moveInputPos pos 1) (stDecrement true) pending 0 (Counter.decrement bs) (b :: cs)hv:0 < Counter.value (b :: cs)u:ℕhu:u ≤ 2 * (b :: cs).length + 3⊢ cs.length + 1 + 1 ≤ width; omega All goals completed! 🐙) hv u hu
· neg input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bshfirst:∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)he:¬remaining = 1⊢ HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) t) exact hfirst t (by input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕht:t ≤ if remaining = 1 then 2 * bs.length + 2 * cs.length + 9 else 2 * bs.length + 4hinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bshfirst:∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)he:¬remaining = 1⊢ t ≤ 1 + (2 * bs.length + 3) simp only [he, ↓reduceIte] at ht input:List (Fin 3)pos:Fin (input.length + 2)pending:ℕremaining:ℕbs:List Boolcs:List Boolb:Boolhr:0 < remaininghb:Counter.value bs = remaininghc:0 < Counter.value cshin:(scanCfg input pos stLengthBit pending 0 bs cs).inputSymbol = some (boolEmb b)width:ℕhp:pending + 1 ≤ widthhz:1 ≤ widthhbs:bs.length + 2 ≤ widthhcs:cs.length + 2 ≤ widtht:ℕhinit:HeadBound width (scanCfg input pos stLengthBit pending 0 bs cs)hdec:HeadBound width (scanCfg input (moveInputPos pos 1) (stDecrement false) pending 0 bs (b :: cs))hbpos:0 < Counter.value bshfirst:∀ u ≤ 1 + (2 * bs.length + 3), HeadBound width (configs (scanCfg input pos stLengthBit pending 0 bs cs) u)he:¬remaining = 1ht:t ≤ 2 * bs.length + 4⊢ t ≤ 1 + (2 * bs.length + 3); omega All goals completed! 🐙)end Geb.BitTree.Elias.Machine