Imports
/- Copyright (c) 2026 Google LLC. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. -/ module public import Mathlib.Computability.TuringMachine.PostTuringMachine public import Mathlib.Data.Nat.Prime.Basic public import Mathlib.Algebra.GCDMonoid.Finset public import Mathlib.Order.Interval.Finset.Nat public import Mathlib.Order.SuccPred.Basic public import Mathlib.Algebra.Order.SuccPred public import Mathlib.NumberTheory.LSeries.RiemannZeta public import Mathlib.SetTheory.ZFC.Basic meta import Lean.Elab.Term

Turing Machine Definitions (Cryptids.Machines)

Machines with states states and symbols symbols, over Mathlib's tape, together with the elaboration-time table loader load_machine_rows% and all baseline and candidate machines in ConjectureMachines.Machines.

meta sectionnamespace ConjectureMachines.Machinesopen Lean Elab Termprivate def parseCellStx (numStates : Nat) (cell : String) : TermElabM (TSyntax `term) := do if cell == "---" then `(none) else match cell.toList with | wChar :: dChar :: rest => if wChar != '0' && wChar != '1' then throwError "Invalid write symbol in transition cell: {cell}" let some state := (String.ofList rest).toNat? | throwError "Invalid destination state in transition cell: {cell}" if state >= numStates then throwError "Out-of-range destination state in transition cell: {cell}" let wLit := Syntax.mkNumLit (String.singleton wChar) let dirStx ← match dChar with | 'L' => `(Turing.Dir.left) | 'R' => `(Turing.Dir.right) | _ => throwError "Invalid direction in transition cell: {cell}" `(some ($wLit, $dirStx, $(Syntax.mkNumLit (toString state)))) | _ => throwError "Malformed transition cell: {cell}"elab "load_machine_rows% " path:str : term <= expectedType? => do let contents ← liftM (m := IO) (IO.FS.readFile path.getString) let lines := (contents.splitOn "\n").filterMap fun rawLine => let line := ((rawLine.splitOn "#").headD "").trimAscii.toString if line.isEmpty then none else some line if lines.isEmpty then throwError "Empty transition table" let mut rowStxs : Array (TSyntax `term) := #[] for line in lines do match (line.splitOn " ").filter (fun s => !s.isEmpty) with | [c0, c1] => rowStxs := rowStxs.push (← `([$(← parseCellStx lines.length c0), $(← parseCellStx lines.length c1)])) | _ => throwError "Expected 2 columns in transition table line: {line}" let states := Syntax.mkNumLit (toString lines.length) elabTerm (← `(([$rowStxs,*] : List (List (Option (Fin 2 × Turing.Dir × Fin $states)))))) expectedType?end ConjectureMachines.Machinesend@[expose] public sectionnamespace ConjectureMachinesopen Turing (Dir)open StateTransitionexport Turing (Dir)scoped instance (priority := 10000) instZeroNatConstructive : Zero ℕ := ⟨0⟩scoped instance (priority := 10000) instLTNatConstructive : LT ℕ := instLTNatscoped instance (priority := 10000) instLENatConstructive : LE ℕ := instLENatscoped instance (priority := 10000) instDecidableLTNatConstructive : DecidableLT ℕ := fun a b => Nat.decLt a bscoped instance (priority := 10000) instDecidableLENatConstructive : DecidableLE ℕ := fun a b => Nat.decLe a btheorem pos_of_neZero (n : ℕ) [h : NeZero n] : 0 < n := Nat.casesOn (motive := fun k => NeZero k → 0 < k) n (fun h0 => False.elim (h0.out rfl)) (fun k _ => Nat.zero_lt_succ k) hscoped instance (priority := 10000) instNeZeroSuccConstructive (n : ℕ) : NeZero (n + 1) := ⟨fun h => Nat.noConfusion h⟩scoped instance (priority := 10000) instOfNatFinConstructive (n : ℕ) [NeZero n] (i : ℕ) : OfNat (Fin n) i := ⟨⟨i % n, Nat.mod_lt i (pos_of_neZero n)⟩⟩scoped instance (priority := 10000) instInhabitedFinConstructive (n : ℕ) [NeZero n] : Inhabited (Fin n) := ⟨0⟩scoped instance (priority := 10000) instLTFinConstructive (n : ℕ) : LT (Fin n) := instLTFinscoped instance (priority := 10000) instLEFinConstructive (n : ℕ) : LE (Fin n) := instLEFinscoped instance (priority := 10000) instDecidableEqFinConstructive (n : ℕ) : DecidableEq (Fin n) := instDecidableEqFin nscoped instance (priority := 10000) instDecidableLTFinConstructive (n : ℕ) : DecidableLT (Fin n) := fun a b => Fin.decLt a bscoped instance (priority := 10000) instDecidableLEFinConstructive (n : ℕ) : DecidableLE (Fin n) := fun a b => Fin.decLe a bscoped instance (priority := 10000) instLinearOrderFinConstructive (n : ℕ) : LinearOrder (Fin n) where le := instLEFin.le lt := instLTFin.lt le_refl := Fin.le_refl le_trans := @Fin.le_trans n lt_iff_le_not_ge _ _ := Nat.lt_iff_le_and_not_ge le_antisymm := @Fin.le_antisymm n le_total := @Fin.le_total n toDecidableLE := fun a b => Fin.decLe a b toDecidableEq := instDecidableEqFin n toDecidableLT := fun a b => Fin.decLt a b min a b := if a ≤ b then a else b max a b := if a ≤ b then b else a min_def _ _ := rfl max_def _ _ := rfl compare a b := compareOfLessAndEq a b compare_eq_compareOfLessAndEq _ _ := rfl

Predicate that a List Γ has no trailing blank (default) symbol.

def ListBlank.IsTrimmed {Γ : Type*} [Inhabited Γ] : List Γ → Prop | [] => True | [a] => a ≠ default | _ :: b :: xs => ListBlank.IsTrimmed (b :: xs)

Prepend a onto a blank-trimmed List Γ, dropping a iff a = default on [].

def ListBlank.trimCons {Γ : Type*} [Inhabited Γ] [DecidableEq Γ] (a : Γ) : List Γ → List Γ | [] => if a = default then [] else [a] | b :: xs => a :: b :: xs

Half-tape of a Turing machine, represented concretely as a List Γ in canonical blank-trimmed normal form (no trailing default symbols) so ListBlank, Tape, and Halts require zero axioms (Quot, Quot.sound, propext, and Classical.choice are all avoided).

structure ListBlank (Γ : Type*) [Inhabited Γ] where ofTrimmed :: toList : List Γ isTrimmed : ListBlank.IsTrimmed toListinstance ListBlank.inhabited {Γ : Type*} [Inhabited Γ] : Inhabited (ListBlank Γ) := ⟨⟨[], trivial⟩⟩

Lift a blank-extension-invariant function from List Γ to ListBlank Γ.

protected abbrev ListBlank.liftOn {Γ : Type*} [Inhabited Γ] {α : Sort*} (l : ListBlank Γ) (f : List Γ → α) (_H : ∀ a b, Turing.BlankExtends a b → f a = f b) : α := f l.toList

Head symbol of a ListBlank.

def ListBlank.head {Γ : Type*} [Inhabited Γ] (l : ListBlank Γ) : Γ := l.toList.headItheorem ListBlank.isTrimmed_tail {Γ : Type*} [Inhabited Γ] {l : List Γ} : ListBlank.IsTrimmed l → ListBlank.IsTrimmed l.tail := List.casesOn (motive := fun xs => ListBlank.IsTrimmed xs → ListBlank.IsTrimmed xs.tail) l (fun _ => trivial) (fun a tl => List.casesOn (motive := fun ys => ListBlank.IsTrimmed (a :: ys) → ListBlank.IsTrimmed ys) tl (fun _ => trivial) (fun _ _ h => h))

Tail of a ListBlank.

def ListBlank.tail {Γ : Type*} [Inhabited Γ] (l : ListBlank Γ) : ListBlank Γ := ⟨l.toList.tail, ListBlank.isTrimmed_tail l.isTrimmed⟩theorem ListBlank.isTrimmed_trimCons {Γ : Type*} [Inhabited Γ] [DecidableEq Γ] (a : Γ) {l : List Γ} : ListBlank.IsTrimmed l → ListBlank.IsTrimmed (ListBlank.trimCons a l) := List.casesOn (motive := fun xs => ListBlank.IsTrimmed xs → ListBlank.IsTrimmed (ListBlank.trimCons a xs)) l (fun _ => Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γl:List Γx✝:IsTrimmed []⊢ IsTrimmed (trimCons a []) Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γl:List Γx✝:IsTrimmed []⊢ IsTrimmed (if a = default then [] else [a]) Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γl:List Γx✝:IsTrimmed []h:a = default⊢ IsTrimmed (if a = default then [] else [a])Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γl:List Γx✝:IsTrimmed []h:¬a = default⊢ IsTrimmed (if a = default then [] else [a]) Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γl:List Γx✝:IsTrimmed []h:a = default⊢ IsTrimmed (if a = default then [] else [a]) Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γl:List Γx✝:IsTrimmed []h:a = default⊢ IsTrimmed []; All goals completed! 🐙 Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γl:List Γx✝:IsTrimmed []h:¬a = default⊢ IsTrimmed (if a = default then [] else [a]) Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γl:List Γx✝:IsTrimmed []h:¬a = default⊢ IsTrimmed [a]; All goals completed! 🐙) (fun b tl => List.casesOn (motive := fun ys => ListBlank.IsTrimmed (b :: ys) → ListBlank.IsTrimmed (a :: b :: ys)) tl (fun h => h) (fun _ _ h => h))

Prepend a symbol onto a ListBlank.

def ListBlank.cons {Γ : Type*} [Inhabited Γ] [DecidableEq Γ] (a : Γ) (l : ListBlank Γ) : ListBlank Γ := ⟨ListBlank.trimCons a l.toList, ListBlank.isTrimmed_trimCons a l.isTrimmed⟩

Prepend a finite List of symbols onto a ListBlank.

@[simp] def ListBlank.append {Γ : Type*} [Inhabited Γ] [DecidableEq Γ] : List Γ → ListBlank Γ → ListBlank Γ | [], L => L | a :: l, L => ListBlank.cons a (ListBlank.append l L)

Canonical map turning a List Γ into a ListBlank Γ by trimming trailing blanks.

def ListBlank.mk {Γ : Type*} [Inhabited Γ] [DecidableEq Γ] (l : List Γ) : ListBlank Γ := ListBlank.append l default

Bidirectional Turing machine tape over alphabet Γ.

structure Tape (Γ : Type*) [Inhabited Γ] where head : Γ left : ListBlank Γ right : ListBlank Γinstance Tape.inhabited {Γ : Type*} [Inhabited Γ] : Inhabited (Tape Γ) := ⟨⟨default, default, default⟩⟩

Shift the tape in response to a head movement Dir.left or Dir.right.

def Tape.move {Γ : Type*} [Inhabited Γ] [DecidableEq Γ] : Dir → Tape Γ → Tape Γ | Dir.left, ⟨a, L, R⟩ => ⟨L.head, L.tail, R.cons a⟩ | Dir.right, ⟨a, L, R⟩ => ⟨R.head, L.cons a, R.tail⟩

Replace the symbol under the head.

def Tape.write {Γ : Type*} [Inhabited Γ] (b : Γ) (T : Tape Γ) : Tape Γ := { T with head := b }

Construct a tape from a left half-tape and an inclusive right half-tape.

def Tape.mk' {Γ : Type*} [Inhabited Γ] (L R : ListBlank Γ) : Tape Γ := ⟨R.head, L, R.tail⟩

Construct a tape from left and inclusive-right Lists.

def Tape.mk₂ {Γ : Type*} [Inhabited Γ] [DecidableEq Γ] (L R : List Γ) : Tape Γ := Tape.mk' (ListBlank.mk L) (ListBlank.mk R)

Construct a tape with l starting at the head and blanks to the left.

def Tape.mk₁ {Γ : Type*} [Inhabited Γ] [DecidableEq Γ] (l : List Γ) : Tape Γ := Tape.mk₂ [] l@[simp] def listGetD {α : Type*} : List α → ℕ → α → α | [], _, d => d | a :: _, 0, _ => a | _ :: xs, n + 1, d => listGetD xs n d

A transition table: for a state and the symbol under the head, either the symbol to write, the direction to move and the state to enter, or none to halt.

structure Machine (states symbols : ℕ) where transition : Fin states → Fin symbols → Option (Fin symbols × Dir × Fin states)variable {states symbols : ℕ} [NeZero states] [NeZero symbols]

A configuration: the current state and the tape, whose head is the symbol under the head.

structure Cfg (states symbols : ℕ) [NeZero symbols] where state : Fin states tape : Tape (Fin symbols)

One step, or none when the transition is missing.

def step (M : Machine states symbols) : Cfg states symbols → Option (Cfg states symbols) | ⟨q, T⟩ => (M.transition q T.head).map fun ⟨a, d, q'⟩ => ⟨q', (T.write a).move d⟩

The start state on the all-blank tape.

def init : Cfg states symbols := ⟨0, Tape.mk₁ []⟩

M halts when started in state 0 on the all-blank tape.

def Halts (M : Machine states symbols) : Prop := (StateTransition.eval (step M) init).Dom

Build a Machine states symbols from a list of per-state transition rows.

def Machine.ofRows (rows : List (List (Option (Fin symbols × Dir × Fin states)))) : Machine states symbols := ⟨fun q a => listGetD (listGetD rows q.val []) a.val none⟩

A Turing machine over symbols tape symbols bundled with its non-zero state count.

structure BundledMachine (symbols : ℕ) where states : ℕ [neZeroStates : NeZero states] toMachine : Machine states symbolsattribute [instance] BundledMachine.neZeroStates

Bundle a Machine (states + 1) symbols into a BundledMachine symbols.

abbrev Machine.bundle {states symbols : ℕ} (M : Machine (states + 1) symbols) : BundledMachine symbols := { states := states + 1 neZeroStates := ⟨fun h => Nat.noConfusion h⟩ toMachine := M }

M halts when started in state 0 on the all-blank tape.

abbrev BundledMachine.Halts {symbols : ℕ} [NeZero symbols] (M : BundledMachine symbols) : Prop := ConjectureMachines.Halts M.toMachineexport BundledMachine (Halts)

info: 'ConjectureMachines.BundledMachine.Halts' does not depend on any axioms

#guard_msgs in #print axioms ConjectureMachines.BundledMachine.Haltsnamespace Machines

Rows of goldbach25.

def goldbach25Rows : List (List (Option (Fin 2 × Dir × Fin 25))) := load_machine_rows% "baselines/tables/goldbach_25.txt"

25-state Goldbach baseline.

def goldbach25 : Machine 25 2 := Machine.ofRows goldbach25Rows

Rows of goldbach21.

def goldbach21Rows : List (List (Option (Fin 2 × Dir × Fin 21))) := load_machine_rows% "artifacts/goldbach_21/machine.txt"

21-state Goldbach candidate.

def goldbach21 : Machine 21 2 := Machine.ofRows goldbach21Rows

Rows of zf432.

def zf432Rows : List (List (Option (Fin 2 × Dir × Fin 432))) := load_machine_rows% "baselines/tables/zf_432.txt"

432-state ZF baseline.

def zf432 : Machine 432 2 := Machine.ofRows zf432Rows

Rows of zf393.

def zf393Rows : List (List (Option (Fin 2 × Dir × Fin 393))) := load_machine_rows% "baselines/tables/zf_393.txt"

393-state ZF machine.

def zf393 : Machine 393 2 := Machine.ofRows zf393Rows

Rows of zf380.

def zf380Rows : List (List (Option (Fin 2 × Dir × Fin 380))) := load_machine_rows% "artifacts/zf_380/machine.txt"

380-state ZF candidate.

def zf380 : Machine 380 2 := Machine.ofRows zf380Rows

Rows of riemann744.

def riemann744Rows : List (List (Option (Fin 2 × Dir × Fin 744))) := load_machine_rows% "baselines/tables/riemann_744.txt"

744-state RH baseline.

def riemann744 : Machine 744 2 := Machine.ofRows riemann744Rows

Rows of riemann120.

def riemann120Rows : List (List (Option (Fin 2 × Dir × Fin 120))) := load_machine_rows% "baselines/tables/riemann_120.txt"

120-state RH machine.

def riemann120 : Machine 120 2 := Machine.ofRows riemann120Rows

Rows of riemann104.

def riemann104Rows : List (List (Option (Fin 2 × Dir × Fin 104))) := load_machine_rows% "artifacts/riemann_104/machine.txt"

104-state RH candidate.

def riemann104 : Machine 104 2 := Machine.ofRows riemann104Rows

Rows of riemann95.

def riemann95Rows : List (List (Option (Fin 2 × Dir × Fin 95))) := load_machine_rows% "artifacts/riemann_95/machine.txt"

95-state RH candidate.

def riemann95 : Machine 95 2 := Machine.ofRows riemann95Rows

Rows of erdosTernary15.

def erdosTernary15Rows : List (List (Option (Fin 2 × Dir × Fin 15))) := load_machine_rows% "baselines/tables/erdos_ternary_15.txt"

15-state Erdős machine.

def erdosTernary15 : Machine 15 2 := Machine.ofRows erdosTernary15Rows

Rows of erdosTernary14.

def erdosTernary14Rows : List (List (Option (Fin 2 × Dir × Fin 14))) := load_machine_rows% "artifacts/erdos_ternary_14/machine.txt"

14-state Erdős candidate.

def erdosTernary14 : Machine 14 2 := Machine.ofRows erdosTernary14Rows

Rows of brocard27.

def brocard27Rows : List (List (Option (Fin 2 × Dir × Fin 27))) := load_machine_rows% "artifacts/brocard_27/machine.txt"

27-state Brocard machine.

def brocard27 : Machine 27 2 := Machine.ofRows brocard27Rows

Rows of weakCollatz75.

def weakCollatz75Rows : List (List (Option (Fin 2 × Dir × Fin 75))) := load_machine_rows% "artifacts/weak_collatz_75/machine.txt"

75-state Weak Collatz machine.

def weakCollatz75 : Machine 75 2 := Machine.ofRows weakCollatz75Rows

Rows of weakCollatz41.

def weakCollatz41Rows : List (List (Option (Fin 2 × Dir × Fin 41))) := load_machine_rows% "artifacts/weak_collatz_41/machine.txt"

41-state Weak Collatz candidate.

def weakCollatz41 : Machine 41 2 := Machine.ofRows weakCollatz41Rows

Rows of weakCollatz27.

def weakCollatz27Rows : List (List (Option (Fin 2 × Dir × Fin 27))) := load_machine_rows% "artifacts/weak_collatz_27/machine.txt"

27-state Weak Collatz candidate.

def weakCollatz27 : Machine 27 2 := Machine.ofRows weakCollatz27Rows

Rows of weakCollatz17.

def weakCollatz17Rows : List (List (Option (Fin 2 × Dir × Fin 17))) := load_machine_rows% "artifacts/weak_collatz_17/machine.txt"

17-state Weak Collatz candidate.

def weakCollatz17 : Machine 17 2 := Machine.ofRows weakCollatz17Rows

Rows of weakCollatz16.

def weakCollatz16Rows : List (List (Option (Fin 2 × Dir × Fin 16))) := load_machine_rows% "artifacts/weak_collatz_16/machine.txt"

16-state Weak Collatz candidate.

def weakCollatz16 : Machine 16 2 := Machine.ofRows weakCollatz16Rows

Rows of legendre21.

def legendre21Rows : List (List (Option (Fin 2 × Dir × Fin 21))) := load_machine_rows% "artifacts/legendre_21/machine.txt"

21-state Legendre machine.

def legendre21 : Machine 21 2 := Machine.ofRows legendre21Rowsend Machinesattribute [-simp] Nat.add_eq_right Order.add_one_le_iff Order.lt_add_one_iff@[simp high] theorem nat_add_one_le_iff {x y : ℕ} : x + no_index 1 ≤ y ↔ x < y := x:ℕy:ℕ⊢ x + 1 ≤ y ↔ x < y x:ℕy:ℕ⊢ x + 1 ≤ y → x < yx:ℕy:ℕ⊢ x < y → x + 1 ≤ y x:ℕy:ℕ⊢ x + 1 ≤ y → x < yx:ℕy:ℕ⊢ x < y → x + 1 ≤ y x:ℕy:ℕh:x < y⊢ x + 1 ≤ y x:ℕy:ℕh:x + 1 ≤ y⊢ x < yx:ℕy:ℕh:x < y⊢ x + 1 ≤ y All goals completed! 🐙@[simp high] theorem nat_lt_add_one_iff {x y : ℕ} : x < y + no_index 1 ↔ x ≤ y := x:ℕy:ℕ⊢ x < y + 1 ↔ x ≤ y x:ℕy:ℕ⊢ x < y + 1 → x ≤ yx:ℕy:ℕ⊢ x ≤ y → x < y + 1 x:ℕy:ℕ⊢ x < y + 1 → x ≤ yx:ℕy:ℕ⊢ x ≤ y → x < y + 1 x:ℕy:ℕh:x ≤ y⊢ x < y + 1 x:ℕy:ℕh:x < y + 1⊢ x ≤ yx:ℕy:ℕh:x ≤ y⊢ x < y + 1 All goals completed! 🐙@[simp high] theorem nat_add_eq_left {n m : ℕ} : n + m = m ↔ n = 0 := n:ℕm:ℕ⊢ n + m = m ↔ n = 0 n:ℕm:ℕ⊢ n + m = m → n = 0n:ℕm:ℕ⊢ n = 0 → n + m = m n:ℕm:ℕ⊢ n + m = m → n = 0n:ℕm:ℕ⊢ n = 0 → n + m = m n:ℕm:ℕh:n = 0⊢ n + m = m n:ℕm:ℕh:n + m = m⊢ n = 0n:ℕm:ℕh:n = 0⊢ n + m = m All goals completed! 🐙instance (priority := 10000) instBEqFinConstructive (n : ℕ) : BEq (Fin n) := instBEqOfDecidableEqinstance (priority := 10000) instLawfulBEqFinConstructive (n : ℕ) : LawfulBEq (Fin n) where eq_of_beq h := of_decide_eq_true h rfl := decide_eq_true rflinstance (priority := 10000) instReflBEqFinConstructive (n : ℕ) : ReflBEq (Fin n) := (instLawfulBEqFinConstructive n).toReflBEqinstance (priority := 10000) instEquivBEqFinConstructive (n : ℕ) : EquivBEq (Fin n) where symm h := decide_eq_true (of_decide_eq_true h).symm trans h1 h2 := decide_eq_true ((of_decide_eq_true h1).trans (of_decide_eq_true h2))instance (priority := 10000) instPreorderFinConstructive (n : ℕ) : Preorder (Fin n) := (instLinearOrderFinConstructive n).toPreorderinstance (priority := 10000) instPartialOrderFinConstructive (n : ℕ) : PartialOrder (Fin n) := (instLinearOrderFinConstructive n).toPartialOrderinstance (priority := 10000) instLinearOrderNatConstructive : LinearOrder ℕ where le := Nat.le lt := Nat.lt le_refl := Nat.le_refl le_trans := @Nat.le_trans lt_iff_le_not_ge _ _ := Nat.lt_iff_le_and_not_ge le_antisymm := @Nat.le_antisymm le_total := @Nat.le_total toDecidableLE := Nat.decLe toDecidableEq := instDecidableEqNat toDecidableLT := Nat.decLt min a b := if a ≤ b then a else b max a b := if a ≤ b then b else a min_def _ _ := rfl max_def _ _ := rfl compare a b := compareOfLessAndEq a b compare_eq_compareOfLessAndEq _ _ := rflinstance (priority := 10000) instPreorderNatConstructive : Preorder ℕ := instLinearOrderNatConstructive.toPreorderinstance (priority := 10000) instPartialOrderNatConstructive : PartialOrder ℕ := instLinearOrderNatConstructive.toPartialOrderinstance (priority := 10000) instAddLeftReflectLENatConstructive : AddLeftReflectLE ℕ := ⟨@Nat.le_of_add_le_add_left⟩instance (priority := 10000) instAddRightReflectLENatConstructive : AddRightReflectLE ℕ := ⟨fun {_ _ _} h => Nat.le_of_add_le_add_right h⟩instance (priority := 10000) instSuccOrderNatConstructive : SuccOrder ℕ where succ n := n + 1 le_succ := Nat.le_succ max_of_succ_le {a} h := absurd h (Nat.not_succ_le_self a) succ_le_of_lt := idinstance (priority := 10000) instSuccAddOrderNatConstructive : SuccAddOrder ℕ := ⟨fun _ => rfl⟩@[simp high] theorem nat_lt_one_iff (n : ℕ) : n < 1 ↔ n = 0 := n:ℕ⊢ n < 1 ↔ n = 0 n:ℕ⊢ n < 1 → n = 0n:ℕ⊢ n = 0 → n < 1 n:ℕ⊢ n < 1 → n = 0n:ℕ⊢ n = 0 → n < 1 n:ℕh:n = 0⊢ n < 1 n:ℕh:n < 1⊢ n = 0n:ℕh:n = 0⊢ n < 1 All goals completed! 🐙@[simp high] theorem nat_lt_two_iff (n : ℕ) : n < 2 ↔ n = 0 ∨ n = 1 := ⟨fun h => match n with | 0 => Or.inl rfl | 1 => Or.inr rfl n:ℕn✝:ℕh:n✝ + 2 < 2⊢ n✝ + 2 = 0 ∨ n✝ + 2 = 1 n:ℕn✝:ℕh:n✝ + 2 < 2⊢ n✝ + 2 = 0 ∨ n✝ + 2 = 1 All goals completed! 🐙, fun h => h.elim (fun _ => n:ℕh:n = 0 ∨ n = 1x✝:n = 0⊢ n < 2 All goals completed! 🐙) (fun _ => n:ℕh:n = 0 ∨ n = 1x✝:n = 1⊢ n < 2 All goals completed! 🐙)⟩@[simp high] theorem nat_lt_succ_self (n : ℕ) : n < n + 1 := Nat.lt_succ_self n@[simp high] theorem nat_add_lt_add_left (a b c : ℕ) : a + b < a + c ↔ b < c := a:ℕb:ℕc:ℕ⊢ a + b < a + c ↔ b < c a:ℕb:ℕc:ℕ⊢ a + b < a + c → b < ca:ℕb:ℕc:ℕ⊢ b < c → a + b < a + c a:ℕb:ℕc:ℕ⊢ a + b < a + c → b < ca:ℕb:ℕc:ℕ⊢ b < c → a + b < a + c a:ℕb:ℕc:ℕh:b < c⊢ a + b < a + c a:ℕb:ℕc:ℕh:a + b < a + c⊢ b < ca:ℕb:ℕc:ℕh:b < c⊢ a + b < a + c All goals completed! 🐙@[simp high] theorem nat_add_lt_add_right (a b c : ℕ) : a + c < b + c ↔ a < b := a:ℕb:ℕc:ℕ⊢ a + c < b + c ↔ a < b a:ℕb:ℕc:ℕ⊢ a + c < b + c → a < ba:ℕb:ℕc:ℕ⊢ a < b → a + c < b + c a:ℕb:ℕc:ℕ⊢ a + c < b + c → a < ba:ℕb:ℕc:ℕ⊢ a < b → a + c < b + c a:ℕb:ℕc:ℕh:a < b⊢ a + c < b + c a:ℕb:ℕc:ℕh:a + c < b + c⊢ a < ba:ℕb:ℕc:ℕh:a < b⊢ a + c < b + c All goals completed! 🐙@[simp high] theorem nat_add_le_add_left (a b c : ℕ) : a + b ≤ a + c ↔ b ≤ c := a:ℕb:ℕc:ℕ⊢ a + b ≤ a + c ↔ b ≤ c a:ℕb:ℕc:ℕ⊢ a + b ≤ a + c → b ≤ ca:ℕb:ℕc:ℕ⊢ b ≤ c → a + b ≤ a + c a:ℕb:ℕc:ℕ⊢ a + b ≤ a + c → b ≤ ca:ℕb:ℕc:ℕ⊢ b ≤ c → a + b ≤ a + c a:ℕb:ℕc:ℕh:b ≤ c⊢ a + b ≤ a + c a:ℕb:ℕc:ℕh:a + b ≤ a + c⊢ b ≤ ca:ℕb:ℕc:ℕh:b ≤ c⊢ a + b ≤ a + c All goals completed! 🐙@[simp high] theorem nat_add_le_add_right (a b c : ℕ) : a + c ≤ b + c ↔ a ≤ b := a:ℕb:ℕc:ℕ⊢ a + c ≤ b + c ↔ a ≤ b a:ℕb:ℕc:ℕ⊢ a + c ≤ b + c → a ≤ ba:ℕb:ℕc:ℕ⊢ a ≤ b → a + c ≤ b + c a:ℕb:ℕc:ℕ⊢ a + c ≤ b + c → a ≤ ba:ℕb:ℕc:ℕ⊢ a ≤ b → a + c ≤ b + c a:ℕb:ℕc:ℕh:a ≤ b⊢ a + c ≤ b + c a:ℕb:ℕc:ℕh:a + c ≤ b + c⊢ a ≤ ba:ℕb:ℕc:ℕh:a ≤ b⊢ a + c ≤ b + c All goals completed! 🐙@[simp high] theorem nat_add_pos_iff (a b : ℕ) : 0 < a + b ↔ 0 < a ∨ 0 < b := ⟨fun h => match a with | 0 => Or.inr (a:ℕb:ℕh:0 < 0 + b⊢ 0 < b All goals completed! 🐙) | _ + 1 => Or.inl (a:ℕb:ℕn✝:ℕh:0 < n✝ + 1 + b⊢ 0 < n✝ + 1 All goals completed! 🐙), fun h => h.elim (fun _ => a:ℕb:ℕh:0 < a ∨ 0 < bx✝:0 < a⊢ 0 < a + b All goals completed! 🐙) (fun _ => a:ℕb:ℕh:0 < a ∨ 0 < bx✝:0 < b⊢ 0 < a + b All goals completed! 🐙)⟩@[simp high] theorem nat_add_eq_right {n m : ℕ} : n + m = n ↔ m = 0 := n:ℕm:ℕ⊢ n + m = n ↔ m = 0 n:ℕm:ℕ⊢ n + m = n → m = 0n:ℕm:ℕ⊢ m = 0 → n + m = n n:ℕm:ℕ⊢ n + m = n → m = 0n:ℕm:ℕ⊢ m = 0 → n + m = n n:ℕm:ℕh:m = 0⊢ n + m = n n:ℕm:ℕh:n + m = n⊢ m = 0n:ℕm:ℕh:m = 0⊢ n + m = n All goals completed! 🐙@[simp high] theorem nat_zero_le (n : ℕ) : 0 ≤ n := Nat.zero_le n@[simp high] theorem nat_ofNat_pos {n : ℕ} [h : n.AtLeastTwo] : 0 < (no_index (OfNat.ofNat n : ℕ)) := Nat.zero_lt_of_lt h.1@[simp high] theorem nat_one_lt_ofNat {n : ℕ} [h : n.AtLeastTwo] : 1 < (no_index (OfNat.ofNat n : ℕ)) := h.1@[simp high] theorem list_take_eq_self_iff {α : Type*} (x : List α) {n : ℕ} : x.take n = x ↔ x.length ≤ n := α:Type u_1x:List αn:ℕ⊢ List.take n x = x ↔ x.length ≤ n induction x generalizing n with α:Type u_1n:ℕ⊢ List.take n [] = [] ↔ [].length ≤ n All goals completed! 🐙 α:Type u_1head✝:αtail✝:List αih:∀ {n : ℕ}, List.take n tail✝ = tail✝ ↔ tail✝.length ≤ nn:ℕ⊢ List.take n (head✝ :: tail✝) = head✝ :: tail✝ ↔ (head✝ :: tail✝).length ≤ n α:Type u_1head✝:αtail✝:List αih:∀ {n : ℕ}, List.take n tail✝ = tail✝ ↔ tail✝.length ≤ n⊢ List.take 0 (head✝ :: tail✝) = head✝ :: tail✝ ↔ (head✝ :: tail✝).length ≤ 0α:Type u_1head✝:αtail✝:List αih:∀ {n : ℕ}, List.take n tail✝ = tail✝ ↔ tail✝.length ≤ nn✝:ℕ⊢ List.take (n✝ + 1) (head✝ :: tail✝) = head✝ :: tail✝ ↔ (head✝ :: tail✝).length ≤ n✝ + 1 α:Type u_1head✝:αtail✝:List αih:∀ {n : ℕ}, List.take n tail✝ = tail✝ ↔ tail✝.length ≤ n⊢ List.take 0 (head✝ :: tail✝) = head✝ :: tail✝ ↔ (head✝ :: tail✝).length ≤ 0α:Type u_1head✝:αtail✝:List αih:∀ {n : ℕ}, List.take n tail✝ = tail✝ ↔ tail✝.length ≤ nn✝:ℕ⊢ List.take (n✝ + 1) (head✝ :: tail✝) = head✝ :: tail✝ ↔ (head✝ :: tail✝).length ≤ n✝ + 1 All goals completed! 🐙

The configuration n steps in from init, or none once M has halted.

def run (M : Machine states symbols) (n : ℕ) : Option (Cfg states symbols) := (fun c => c.bind (step M))^[n] (some init)

M, started in state 0 on the all-blank tape, has not halted within n steps.

def Runs (M : Machine states symbols) (n : ℕ) : Prop := (run M n).isSomeinstance (M : Machine states symbols) (n : ℕ) : Decidable (Runs M n) := inferInstanceAs (Decidable ((run M n).isSome = true))@[ext] theorem ListBlank.ext {Γ : Type*} [Inhabited Γ] {l₁ l₂ : ListBlank Γ} (h : l₁.toList = l₂.toList) : l₁ = l₂ := Γ:Type u_1inst✝:Inhabited Γl₁:ListBlank Γl₂:ListBlank Γh:l₁.toList = l₂.toList⊢ l₁ = l₂ Γ:Type u_1inst✝:Inhabited Γl₂:ListBlank ΓtoList✝:List ΓisTrimmed✝:IsTrimmed toList✝h:{ toList := toList✝, isTrimmed := isTrimmed✝ }.toList = l₂.toList⊢ { toList := toList✝, isTrimmed := isTrimmed✝ } = l₂; Γ:Type u_1inst✝:Inhabited ΓtoList✝¹:List ΓisTrimmed✝¹:IsTrimmed toList✝toList✝:List ΓisTrimmed✝:IsTrimmed toList✝h:{ toList := toList✝¹, isTrimmed := isTrimmed✝¹ }.toList = { toList := toList✝, isTrimmed := isTrimmed✝ }.toList⊢ { toList := toList✝¹, isTrimmed := isTrimmed✝¹ } = { toList := toList✝, isTrimmed := isTrimmed✝ }; Γ:Type u_1inst✝:Inhabited ΓtoList✝:List ΓisTrimmed✝¹:IsTrimmed toList✝isTrimmed✝:IsTrimmed toList✝⊢ { toList := toList✝, isTrimmed := isTrimmed✝¹ } = { toList := toList✝, isTrimmed := isTrimmed✝ }; All goals completed! 🐙@[simp] theorem ListBlank.cons_default_default {Γ : Type*} [Inhabited Γ] [DecidableEq Γ] : (default : ListBlank Γ).cons default = default := Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γ⊢ cons default default = default Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γ⊢ (cons default default).toList = default.toList All goals completed! 🐙@[simp] theorem ListBlank.head_cons {Γ : Type*} [Inhabited Γ] [DecidableEq Γ] (a : Γ) (l : ListBlank Γ) : (l.cons a).head = a := Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γl:ListBlank Γ⊢ (cons a l).head = a Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []⊢ (cons a { toList := [], isTrimmed := isTrimmed✝ }).head = aΓ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γb:Γxs:List ΓisTrimmed✝:IsTrimmed (b :: xs)⊢ (cons a { toList := b :: xs, isTrimmed := isTrimmed✝ }).head = a Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []⊢ (cons a { toList := [], isTrimmed := isTrimmed✝ }).head = a Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []⊢ (if a = default then [] else [a]).headI = a Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []h:a = default⊢ (if a = default then [] else [a]).headI = aΓ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []h:¬a = default⊢ (if a = default then [] else [a]).headI = a Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []h:a = default⊢ (if a = default then [] else [a]).headI = a Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []h:a = default⊢ [].headI = a; All goals completed! 🐙 Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []h:¬a = default⊢ (if a = default then [] else [a]).headI = a Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []h:¬a = default⊢ [a].headI = a; All goals completed! 🐙 Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γb:Γxs:List ΓisTrimmed✝:IsTrimmed (b :: xs)⊢ (cons a { toList := b :: xs, isTrimmed := isTrimmed✝ }).head = a All goals completed! 🐙@[simp] theorem ListBlank.tail_cons {Γ : Type*} [Inhabited Γ] [DecidableEq Γ] (a : Γ) (l : ListBlank Γ) : (l.cons a).tail = l := Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γl:ListBlank Γ⊢ (cons a l).tail = l Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γl:ListBlank Γ⊢ (cons a l).tail.toList = l.toList Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []⊢ (cons a { toList := [], isTrimmed := isTrimmed✝ }).tail.toList = { toList := [], isTrimmed := isTrimmed✝ }.toListΓ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γb:Γxs:List ΓisTrimmed✝:IsTrimmed (b :: xs)⊢ (cons a { toList := b :: xs, isTrimmed := isTrimmed✝ }).tail.toList = { toList := b :: xs, isTrimmed := isTrimmed✝ }.toList Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []⊢ (cons a { toList := [], isTrimmed := isTrimmed✝ }).tail.toList = { toList := [], isTrimmed := isTrimmed✝ }.toList Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []⊢ (if a = default then [] else [a]).tail = [] Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []h:a = default⊢ (if a = default then [] else [a]).tail = []Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []h:¬a = default⊢ (if a = default then [] else [a]).tail = [] Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []h:a = default⊢ (if a = default then [] else [a]).tail = [] Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []h:a = default⊢ [].tail = []; All goals completed! 🐙 Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []h:¬a = default⊢ (if a = default then [] else [a]).tail = [] Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []h:¬a = default⊢ [a].tail = []; All goals completed! 🐙 Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γb:Γxs:List ΓisTrimmed✝:IsTrimmed (b :: xs)⊢ (cons a { toList := b :: xs, isTrimmed := isTrimmed✝ }).tail.toList = { toList := b :: xs, isTrimmed := isTrimmed✝ }.toList All goals completed! 🐙@[simp] theorem ListBlank.cons_head_tail {Γ : Type*} [Inhabited Γ] [DecidableEq Γ] (l : ListBlank Γ) : l.tail.cons l.head = l := Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl:ListBlank Γ⊢ cons l.head l.tail = l Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl:ListBlank Γ⊢ (cons l.head l.tail).toList = l.toList Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γh:IsTrimmed []⊢ (cons { toList := [], isTrimmed := h }.head { toList := [], isTrimmed := h }.tail).toList = { toList := [], isTrimmed := h }.toListΓ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γh:IsTrimmed [a]⊢ (cons { toList := [a], isTrimmed := h }.head { toList := [a], isTrimmed := h }.tail).toList = { toList := [a], isTrimmed := h }.toListΓ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γb:Γxs:List Γh:IsTrimmed (a :: b :: xs)⊢ (cons { toList := a :: b :: xs, isTrimmed := h }.head { toList := a :: b :: xs, isTrimmed := h }.tail).toList = { toList := a :: b :: xs, isTrimmed := h }.toList Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γh:IsTrimmed []⊢ (cons { toList := [], isTrimmed := h }.head { toList := [], isTrimmed := h }.tail).toList = { toList := [], isTrimmed := h }.toList All goals completed! 🐙 Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γh:IsTrimmed [a]⊢ (cons { toList := [a], isTrimmed := h }.head { toList := [a], isTrimmed := h }.tail).toList = { toList := [a], isTrimmed := h }.toList All goals completed! 🐙 Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γb:Γxs:List Γh:IsTrimmed (a :: b :: xs)⊢ (cons { toList := a :: b :: xs, isTrimmed := h }.head { toList := a :: b :: xs, isTrimmed := h }.tail).toList = { toList := a :: b :: xs, isTrimmed := h }.toList All goals completed! 🐙@[simp] theorem ListBlank.cons_mk {Γ : Type*} [Inhabited Γ] [DecidableEq Γ] (a : Γ) (l : List Γ) : ListBlank.cons a (ListBlank.mk l) = ListBlank.mk (a :: l) := rfl@[simp] theorem ListBlank.head_mk {Γ : Type*} [Inhabited Γ] [DecidableEq Γ] (l : List Γ) : ListBlank.head (ListBlank.mk l) = l.headI := Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl:List Γ⊢ (mk l).head = l.headI cases l with Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γ⊢ (mk []).head = [].headI All goals completed! 🐙 Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γxs:List Γ⊢ (mk (a :: xs)).head = (a :: xs).headI All goals completed! 🐙@[simp] theorem ListBlank.tail_mk {Γ : Type*} [Inhabited Γ] [DecidableEq Γ] (l : List Γ) : ListBlank.tail (ListBlank.mk l) = ListBlank.mk l.tail := Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl:List Γ⊢ (mk l).tail = mk l.tail cases l with Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γ⊢ (mk []).tail = mk [].tail All goals completed! 🐙 Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γxs:List Γ⊢ (mk (a :: xs)).tail = mk (a :: xs).tail All goals completed! 🐙private theorem ListBlank.mk_list_aux {Γ : Type*} [Inhabited Γ] [DecidableEq Γ] : ∀ (xs : List Γ) (h : ListBlank.IsTrimmed xs), ListBlank.mk xs = ⟨xs, h⟩ | [], _ => rfl Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γh:IsTrimmed [a]⊢ mk [a] = { toList := [a], isTrimmed := h } Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γh:IsTrimmed [a]⊢ mk [a] = { toList := [a], isTrimmed := h } Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γh:IsTrimmed [a]⊢ (mk [a]).toList = { toList := [a], isTrimmed := h }.toList All goals completed! 🐙 Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γb:Γxs:List Γh:IsTrimmed (a :: b :: xs)⊢ mk (a :: b :: xs) = { toList := a :: b :: xs, isTrimmed := h } Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γb:Γxs:List Γh:IsTrimmed (a :: b :: xs)⊢ mk (a :: b :: xs) = { toList := a :: b :: xs, isTrimmed := h } Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γb:Γxs:List Γh:IsTrimmed (a :: b :: xs)⊢ cons a (mk (b :: xs)) = { toList := a :: b :: xs, isTrimmed := h } Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γb:Γxs:List Γh:IsTrimmed (a :: b :: xs)⊢ cons a { toList := b :: xs, isTrimmed := h } = { toList := a :: b :: xs, isTrimmed := h } All goals completed! 🐙@[simp] theorem ListBlank.mk_toList {Γ : Type*} [Inhabited Γ] [DecidableEq Γ] (l : ListBlank Γ) : ListBlank.mk l.toList = l := ListBlank.mk_list_aux l.toList l.isTrimmed@[elab_as_elim] protected theorem ListBlank.induction_on {Γ : Type*} [Inhabited Γ] [DecidableEq Γ] {p : ListBlank Γ → Prop} (q : ListBlank Γ) (h : ∀ a, p (ListBlank.mk a)) : p q := q.mk_toList ▸ h q.toListtheorem ListBlank.blankExtends_toList_mk {Γ : Type*} [Inhabited Γ] [DecidableEq Γ] (l : List Γ) : Turing.BlankExtends (ListBlank.mk l).toList l := Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl:List Γ⊢ Turing.BlankExtends (mk l).toList l induction l with Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γ⊢ Turing.BlankExtends (mk []).toList [] All goals completed! 🐙 Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γxs:List Γih:Turing.BlankExtends (mk xs).toList xs⊢ Turing.BlankExtends (mk (a :: xs)).toList (a :: xs) Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γxs:List Γi:ℕhi:xs = (mk xs).toList ++ List.replicate i default⊢ Turing.BlankExtends (mk (a :: xs)).toList (a :: xs) Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γxs:List Γi:ℕhi:xs = (mk xs).toList ++ List.replicate i default⊢ Turing.BlankExtends (trimCons a (mk xs).toList) (a :: xs) Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γxs:List Γi:ℕhi:xs = (mk xs).toList ++ List.replicate i defaulthmk:(mk xs).toList = []⊢ Turing.BlankExtends (trimCons a []) (a :: xs)Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γxs:List Γi:ℕhi:xs = (mk xs).toList ++ List.replicate i defaultb:Γys:List Γhmk:(mk xs).toList = b :: ys⊢ Turing.BlankExtends (trimCons a (b :: ys)) (a :: xs) Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γxs:List Γi:ℕhi:xs = (mk xs).toList ++ List.replicate i defaulthmk:(mk xs).toList = []⊢ Turing.BlankExtends (trimCons a []) (a :: xs) Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γxs:List Γi:ℕhi:xs = List.replicate i defaulthmk:(mk xs).toList = []⊢ Turing.BlankExtends (trimCons a []) (a :: xs) Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γxs:List Γi:ℕhi:xs = List.replicate i defaulthmk:(mk xs).toList = []⊢ Turing.BlankExtends (if a = default then [] else [a]) (a :: xs) Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γxs:List Γi:ℕhi:xs = List.replicate i defaulthmk:(mk xs).toList = []ha:a = default⊢ Turing.BlankExtends (if a = default then [] else [a]) (a :: xs)Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γxs:List Γi:ℕhi:xs = List.replicate i defaulthmk:(mk xs).toList = []ha:¬a = default⊢ Turing.BlankExtends (if a = default then [] else [a]) (a :: xs) Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γxs:List Γi:ℕhi:xs = List.replicate i defaulthmk:(mk xs).toList = []ha:a = default⊢ Turing.BlankExtends (if a = default then [] else [a]) (a :: xs) Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γxs:List Γi:ℕhi:xs = List.replicate i defaulthmk:(mk xs).toList = []ha:a = default⊢ a :: xs = (if a = default then [] else [a]) ++ List.replicate (i + 1) default All goals completed! 🐙 Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γxs:List Γi:ℕhi:xs = List.replicate i defaulthmk:(mk xs).toList = []ha:¬a = default⊢ Turing.BlankExtends (if a = default then [] else [a]) (a :: xs) exact ⟨i, Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γxs:List Γi:ℕhi:xs = List.replicate i defaulthmk:(mk xs).toList = []ha:¬a = default⊢ a :: xs = (if a = default then [] else [a]) ++ List.replicate i default Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γxs:List Γi:ℕhi:xs = List.replicate i defaulthmk:(mk xs).toList = []ha:¬a = default⊢ a :: List.replicate i default = [a] ++ List.replicate i default; All goals completed! 🐙⟩ Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γxs:List Γi:ℕhi:xs = (mk xs).toList ++ List.replicate i defaultb:Γys:List Γhmk:(mk xs).toList = b :: ys⊢ Turing.BlankExtends (trimCons a (b :: ys)) (a :: xs) Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γxs:List Γi:ℕb:Γys:List Γhi:xs = b :: ys ++ List.replicate i defaulthmk:(mk xs).toList = b :: ys⊢ Turing.BlankExtends (trimCons a (b :: ys)) (a :: xs) exact ⟨i, Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γxs:List Γi:ℕb:Γys:List Γhi:xs = b :: ys ++ List.replicate i defaulthmk:(mk xs).toList = b :: ys⊢ a :: xs = trimCons a (b :: ys) ++ List.replicate i default Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γxs:List Γi:ℕb:Γys:List Γhi:xs = b :: ys ++ List.replicate i defaulthmk:(mk xs).toList = b :: ys⊢ a :: (b :: ys ++ List.replicate i default) = trimCons a (b :: ys) ++ List.replicate i default; All goals completed! 🐙⟩theorem ListBlank.liftOn_mk {Γ : Type*} [Inhabited Γ] [DecidableEq Γ] {α : Sort*} (l : List Γ) (f : List Γ → α) (H : ∀ a b, Turing.BlankExtends a b → f a = f b) : (ListBlank.mk l).liftOn f H = f l := H _ _ (ListBlank.blankExtends_toList_mk l)

The n-th symbol of a ListBlank.

def ListBlank.nth {Γ : Type*} [Inhabited Γ] : ListBlank Γ → ℕ → Γ | l, 0 => l.head | l, n + 1 => l.tail.nth n@[simp] theorem ListBlank.nth_zero {Γ : Type*} [Inhabited Γ] (l : ListBlank Γ) : l.nth 0 = l.head := rfl@[simp] theorem ListBlank.nth_succ {Γ : Type*} [Inhabited Γ] (l : ListBlank Γ) (n : ℕ) : l.nth (n + 1) = l.tail.nth n := rfl@[simp] theorem ListBlank.append_mk {Γ : Type*} [Inhabited Γ] [DecidableEq Γ] (l₁ l₂ : List Γ) : ListBlank.append l₁ (ListBlank.mk l₂) = ListBlank.mk (l₁ ++ l₂) := Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl₁:List Γl₂:List Γ⊢ append l₁ (mk l₂) = mk (l₁ ++ l₂) Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl₂:List Γ⊢ append [] (mk l₂) = mk ([] ++ l₂)Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl₂:List Γhead✝:Γtail✝:List Γtail_ih✝:append tail✝ (mk l₂) = mk (tail✝ ++ l₂)⊢ append (head✝ :: tail✝) (mk l₂) = mk (head✝ :: tail✝ ++ l₂) Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl₂:List Γ⊢ append [] (mk l₂) = mk ([] ++ l₂)Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl₂:List Γhead✝:Γtail✝:List Γtail_ih✝:append tail✝ (mk l₂) = mk (tail✝ ++ l₂)⊢ append (head✝ :: tail✝) (mk l₂) = mk (head✝ :: tail✝ ++ l₂) All goals completed! 🐙theorem ListBlank.append_assoc {Γ : Type*} [Inhabited Γ] [DecidableEq Γ] (l₁ l₂ : List Γ) (l₃ : ListBlank Γ) : ListBlank.append (l₁ ++ l₂) l₃ = ListBlank.append l₁ (ListBlank.append l₂ l₃) := Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl₁:List Γl₂:List Γl₃:ListBlank Γ⊢ append (l₁ ++ l₂) l₃ = append l₁ (append l₂ l₃) induction l₁ with Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl₂:List Γl₃:ListBlank Γ⊢ append ([] ++ l₂) l₃ = append [] (append l₂ l₃) All goals completed! 🐙 Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl₂:List Γl₃:ListBlank Γa:Γxs:List Γih:append (xs ++ l₂) l₃ = append xs (append l₂ l₃)⊢ append (a :: xs ++ l₂) l₃ = append (a :: xs) (append l₂ l₃) All goals completed! 🐙theorem ListBlank.mk_append_replicate_default {Γ : Type*} [Inhabited Γ] [DecidableEq Γ] (l : List Γ) (n : ℕ) : ListBlank.mk (l ++ List.replicate n default) = ListBlank.mk l := Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl:List Γn:ℕ⊢ mk (l ++ List.replicate n default) = mk l Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl:List Γn:ℕhrep:mk (List.replicate n default) = default⊢ mk (l ++ List.replicate n default) = mk l Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl:List Γn:ℕhrep:mk (List.replicate n default) = default⊢ append l default = mk l All goals completed! 🐙@[simp] theorem Tape.write_self {Γ : Type*} [Inhabited Γ] : ∀ T : Tape Γ, T.write T.1 = T | ⟨_, _, _⟩ => rfl@[simp] theorem Tape.write_mk {Γ : Type*} [Inhabited Γ] (a b : Γ) (L R : ListBlank Γ) : (Tape.mk a L R).write b = Tape.mk b L R := rfl@[simp] theorem Tape.mk'_left {Γ : Type*} [Inhabited Γ] (L R : ListBlank Γ) : (Tape.mk' L R).left = L := rfl@[simp] theorem Tape.mk'_head {Γ : Type*} [Inhabited Γ] (L R : ListBlank Γ) : (Tape.mk' L R).head = R.head := rfl@[simp] theorem Tape.mk'_right {Γ : Type*} [Inhabited Γ] (L R : ListBlank Γ) : (Tape.mk' L R).right = R.tail := rfl@[simp] theorem Tape.move_left_mk' {Γ : Type*} [Inhabited Γ] [DecidableEq Γ] (L R : ListBlank Γ) : (Tape.mk' L R).move Dir.left = Tape.mk' L.tail (R.cons L.head) := Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq ΓL:ListBlank ΓR:ListBlank Γ⊢ move Dir.left (mk' L R) = mk' L.tail (ListBlank.cons L.head R) All goals completed! 🐙@[simp] theorem Tape.move_right_mk' {Γ : Type*} [Inhabited Γ] [DecidableEq Γ] (L R : ListBlank Γ) : (Tape.mk' L R).move Dir.right = Tape.mk' (L.cons R.head) R.tail := rfl@[simp] theorem Tape.write_mk' {Γ : Type*} [Inhabited Γ] [DecidableEq Γ] (b : Γ) (L R : ListBlank Γ) : (Tape.mk' L R).write b = Tape.mk' L (R.tail.cons b) := Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γb:ΓL:ListBlank ΓR:ListBlank Γ⊢ write b (mk' L R) = mk' L (ListBlank.cons b R.tail) All goals completed! 🐙

Constructive (Classical.choice-free) StateTransition Lemmas

private theorem pfun_mem_fix_iff {α β : Type*} {f : α →. β ⊕ α} {a : α} {b : β} : b ∈ f.fix a ↔ Sum.inl b ∈ f a ∨ ∃ a', Sum.inr a' ∈ f a ∧ b ∈ f.fix a' := ⟨fun h => α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βh:b ∈ f.fix a⊢ Sum.inl b ∈ f a ∨ ∃ a', Sum.inr a' ∈ f a ∧ b ∈ f.fix a' α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βh:b ∈ f.fix ah₁:Acc (fun x y ↦ Sum.inr x ∈ f y) ah₂:b ∈ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) a h₁⊢ Sum.inl b ∈ f a ∨ ∃ a', Sum.inr a' ∈ f a ∧ b ∈ f.fix a' α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βh:b ∈ f.fix ah₁:Acc (fun x y ↦ Sum.inr x ∈ f y) ah₂:b ∈ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => (fun y p ↦ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) y ⋯) a' ⋯⊢ Sum.inl b ∈ f a ∨ ∃ a', Sum.inr a' ∈ f a ∧ b ∈ f.fix a' α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βh:b ∈ f.fix ah₁:Acc (fun x y ↦ Sum.inr x ∈ f y) ah₂✝:b ∈ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => (fun y p ↦ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) y ⋯) a' ⋯h₂:(f a).Domh₃:b ∈ match e : (f a).get h₂ with | Sum.inl b => Part.some b | Sum.inr a' => (fun y p ↦ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) y ⋯) a' ⋯⊢ Sum.inl b ∈ f a ∨ ∃ a', Sum.inr a' ∈ f a ∧ b ∈ f.fix a' α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βh:b ∈ f.fix ah₁:Acc (fun x y ↦ Sum.inr x ∈ f y) ah₂✝:b ∈ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => (fun y p ↦ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) y ⋯) a' ⋯h₂:(f a).Domb✝:βheq✝:(f a).get h₂ = Sum.inl b✝h₃:b ∈ Part.some b✝⊢ Sum.inl b ∈ f a ∨ ∃ a', Sum.inr a' ∈ f a ∧ b ∈ f.fix a'α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βh:b ∈ f.fix ah₁:Acc (fun x y ↦ Sum.inr x ∈ f y) ah₂✝:b ∈ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => (fun y p ↦ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) y ⋯) a' ⋯h₂:(f a).Doma'✝:αheq✝:(f a).get h₂ = Sum.inr a'✝h₃:b ∈ (fun y p ↦ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) y ⋯) a'✝ ⋯⊢ Sum.inl b ∈ f a ∨ ∃ a', Sum.inr a' ∈ f a ∧ b ∈ f.fix a' next e α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βh:b ∈ f.fix ah₁:Acc (fun x y ↦ Sum.inr x ∈ f y) ah₂✝:b ∈ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => (fun y p ↦ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) y ⋯) a' ⋯h₂:(f a).Domb✝:βe:(f a).get h₂ = Sum.inl b✝h₃:b ∈ Part.some b✝⊢ Sum.inl b ∈ f a ∨ ∃ a', Sum.inr a' ∈ f a ∧ b ∈ f.fix a' α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βh:b ∈ f.fix ah₁:Acc (fun x y ↦ Sum.inr x ∈ f y) ah₂✝:b ∈ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => (fun y p ↦ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) y ⋯) a' ⋯h₂:(f a).Dome:(f a).get h₂ = Sum.inl bh₃:b ∈ Part.some b⊢ Sum.inl b ∈ f a ∨ ∃ a', Sum.inr a' ∈ f a ∧ b ∈ f.fix a'; All goals completed! 🐙 next e α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βh:b ∈ f.fix ah₁:Acc (fun x y ↦ Sum.inr x ∈ f y) ah₂✝:b ∈ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => (fun y p ↦ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) y ⋯) a' ⋯h₂:(f a).Doma'✝:αe:(f a).get h₂ = Sum.inr a'✝h₃:b ∈ (fun y p ↦ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) y ⋯) a'✝ ⋯⊢ Sum.inl b ∈ f a ∨ ∃ a', Sum.inr a' ∈ f a ∧ b ∈ f.fix a' All goals completed! 🐙, fun h => α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βh:Sum.inl b ∈ f a ∨ ∃ a', Sum.inr a' ∈ f a ∧ b ∈ f.fix a'⊢ b ∈ f.fix a α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βh₁:(f a).Domh₂:(f a).get h₁ = Sum.inl b⊢ b ∈ f.fix aα:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βa':αh₃:b ∈ f.fix a'h₁:(f a).Domh₂:(f a).get h₁ = Sum.inr a'⊢ b ∈ f.fix a α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βh₁:(f a).Domh₂:(f a).get h₁ = Sum.inl b⊢ b ∈ f.fix a α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βh₁:(f a).Domh₂:(f a).get h₁ = Sum.inl by:αhy:Sum.inr y ∈ f a⊢ Acc (fun x y ↦ Sum.inr x ∈ f y) yα:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βh₁:(f a).Domh₂:(f a).get h₁ = Sum.inl b⊢ b ∈ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) a ⋯ α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βh₁:(f a).Domh₂:(f a).get h₁ = Sum.inl by:αhy:Sum.inr y ∈ f a⊢ Acc (fun x y ↦ Sum.inr x ∈ f y) y All goals completed! 🐙 α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βh₁:(f a).Domh₂:(f a).get h₁ = Sum.inl b⊢ b ∈ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) a ⋯ α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βh₁:(f a).Domh₂:(f a).get h₁ = Sum.inl b⊢ b ∈ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => (fun y p ↦ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) y ⋯) a' ⋯ α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βh₁:(f a).Domh₂:(f a).get h₁ = Sum.inl b⊢ b ∈ match e : (f a).get h₁ with | Sum.inl b => Part.some b | Sum.inr a' => (fun y p ↦ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) y ⋯) a' ⋯ α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βh₁:(f a).Domh₂:(f a).get h₁ = Sum.inl bb✝:βheq✝:(f a).get h₁ = Sum.inl b✝⊢ b ∈ Part.some b✝α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βh₁:(f a).Domh₂:(f a).get h₁ = Sum.inl ba'✝:αheq✝:(f a).get h₁ = Sum.inr a'✝⊢ b ∈ (fun y p ↦ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) y ⋯) a'✝ ⋯ next e α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βh₁:(f a).Domh₂:(f a).get h₁ = Sum.inl bb✝:βe:(f a).get h₁ = Sum.inl b✝⊢ b ∈ Part.some b✝ α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βh₁:(f a).Domh₂:(f a).get h₁ = Sum.inl bb✝:βe:(f a).get h₁ = Sum.inl b✝h':b = b✝⊢ b ∈ Part.some b✝; All goals completed! 🐙 next e α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βh₁:(f a).Domh₂:(f a).get h₁ = Sum.inl ba'✝:αe:(f a).get h₁ = Sum.inr a'✝⊢ b ∈ (fun y p ↦ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) y ⋯) a'✝ ⋯ All goals completed! 🐙 α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βa':αh₃:b ∈ f.fix a'h₁:(f a).Domh₂:(f a).get h₁ = Sum.inr a'⊢ b ∈ f.fix a α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βa':αh₃:b ∈ f.fix a'h₁:(f a).Domh₂:(f a).get h₁ = Sum.inr a'hacc:Acc (fun x y ↦ Sum.inr x ∈ f y) a'h₄:b ∈ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) a' hacc⊢ b ∈ f.fix a α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βa':αh₃:b ∈ f.fix a'h₁:(f a).Domh₂:(f a).get h₁ = Sum.inr a'hacc:Acc (fun x y ↦ Sum.inr x ∈ f y) a'h₄:b ∈ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) a' haccy:αhy:Sum.inr y ∈ f a⊢ Acc (fun x y ↦ Sum.inr x ∈ f y) yα:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βa':αh₃:b ∈ f.fix a'h₁:(f a).Domh₂:(f a).get h₁ = Sum.inr a'hacc:Acc (fun x y ↦ Sum.inr x ∈ f y) a'h₄:b ∈ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) a' hacc⊢ b ∈ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) a ⋯ α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βa':αh₃:b ∈ f.fix a'h₁:(f a).Domh₂:(f a).get h₁ = Sum.inr a'hacc:Acc (fun x y ↦ Sum.inr x ∈ f y) a'h₄:b ∈ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) a' haccy:αhy:Sum.inr y ∈ f a⊢ Acc (fun x y ↦ Sum.inr x ∈ f y) y α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βa':αh₃:b ∈ f.fix a'h₁:(f a).Domh₂:(f a).get h₁ = Sum.inr a'hacc:Acc (fun x y ↦ Sum.inr x ∈ f y) a'h₄:b ∈ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) a' haccy:αhy:Sum.inr y ∈ f ae:a' = y⊢ Acc (fun x y ↦ Sum.inr x ∈ f y) y All goals completed! 🐙 α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βa':αh₃:b ∈ f.fix a'h₁:(f a).Domh₂:(f a).get h₁ = Sum.inr a'hacc:Acc (fun x y ↦ Sum.inr x ∈ f y) a'h₄:b ∈ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) a' hacc⊢ b ∈ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) a ⋯ α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βa':αh₃:b ∈ f.fix a'h₁:(f a).Domh₂:(f a).get h₁ = Sum.inr a'hacc:Acc (fun x y ↦ Sum.inr x ∈ f y) a'h₄:b ∈ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) a' hacc⊢ b ∈ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a'_1 => (fun y p ↦ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) y ⋯) a'_1 ⋯ α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βa':αh₃:b ∈ f.fix a'h₁:(f a).Domh₂:(f a).get h₁ = Sum.inr a'hacc:Acc (fun x y ↦ Sum.inr x ∈ f y) a'h₄:b ∈ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) a' hacc⊢ b ∈ match e : (f a).get h₁ with | Sum.inl b => Part.some b | Sum.inr a'_1 => (fun y p ↦ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) y ⋯) a'_1 ⋯ α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βa':αh₃:b ∈ f.fix a'h₁:(f a).Domh₂:(f a).get h₁ = Sum.inr a'hacc:Acc (fun x y ↦ Sum.inr x ∈ f y) a'h₄:b ∈ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) a' haccb✝:βheq✝:(f a).get h₁ = Sum.inl b✝⊢ b ∈ Part.some b✝α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βa':αh₃:b ∈ f.fix a'h₁:(f a).Domh₂:(f a).get h₁ = Sum.inr a'hacc:Acc (fun x y ↦ Sum.inr x ∈ f y) a'h₄:b ∈ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) a' hacca'✝:αheq✝:(f a).get h₁ = Sum.inr a'✝⊢ b ∈ (fun y p ↦ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) y ⋯) a'✝ ⋯ next e α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βa':αh₃:b ∈ f.fix a'h₁:(f a).Domh₂:(f a).get h₁ = Sum.inr a'hacc:Acc (fun x y ↦ Sum.inr x ∈ f y) a'h₄:b ∈ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) a' haccb✝:βe:(f a).get h₁ = Sum.inl b✝⊢ b ∈ Part.some b✝ All goals completed! 🐙 next e α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βa':αh₃:b ∈ f.fix a'h₁:(f a).Domh₂:(f a).get h₁ = Sum.inr a'hacc:Acc (fun x y ↦ Sum.inr x ∈ f y) a'h₄:b ∈ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) a' hacca'✝:αe:(f a).get h₁ = Sum.inr a'✝⊢ b ∈ (fun y p ↦ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) y ⋯) a'✝ ⋯ α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βa':αh₃:b ∈ f.fix a'h₁:(f a).Domh₂:(f a).get h₁ = Sum.inr a'hacc:Acc (fun x y ↦ Sum.inr x ∈ f y) a'h₄:b ∈ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) a' hacca'✝:αe:(f a).get h₁ = Sum.inr a'✝h':a' = a'✝⊢ b ∈ (fun y p ↦ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) y ⋯) a'✝ ⋯; α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βa':αh₃:b ∈ f.fix a'h₁:(f a).Domh₂:(f a).get h₁ = Sum.inr a'hacc:Acc (fun x y ↦ Sum.inr x ∈ f y) a'h₄:b ∈ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) a' hacce:(f a).get h₁ = Sum.inr a'⊢ b ∈ (fun y p ↦ WellFounded.fixF (fun a IH ↦ Part.assert (f a).Dom fun hf ↦ match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) y ⋯) a' ⋯; All goals completed! 🐙⟩private theorem pfun_fix_fwd {α β : Type*} {f : α →. β ⊕ α} {b : β} {a a' : α} (hb : b ∈ f.fix a) (ha' : Sum.inr a' ∈ f a) : b ∈ f.fix a' := α:Type u_1β:Type u_2f:α →. β ⊕ αb:βa:αa':αhb:b ∈ f.fix aha':Sum.inr a' ∈ f a⊢ b ∈ f.fix a' α:Type u_1β:Type u_2f:α →. β ⊕ αb:βa:αa':αhb:b ∈ f.fix aha':Sum.inr a' ∈ f ah':Sum.inl b ∈ f a⊢ b ∈ f.fix a'α:Type u_1β:Type u_2f:α →. β ⊕ αb:βa:αa':αhb:b ∈ f.fix aha':Sum.inr a' ∈ f aw✝:αh':Sum.inr w✝ ∈ f ae':b ∈ f.fix w✝⊢ b ∈ f.fix a' α:Type u_1β:Type u_2f:α →. β ⊕ αb:βa:αa':αhb:b ∈ f.fix aha':Sum.inr a' ∈ f ah':Sum.inl b ∈ f a⊢ b ∈ f.fix a'α:Type u_1β:Type u_2f:α →. β ⊕ αb:βa:αa':αhb:b ∈ f.fix aha':Sum.inr a' ∈ f aw✝:αh':Sum.inr w✝ ∈ f ae':b ∈ f.fix w✝⊢ b ∈ f.fix a' α:Type u_1β:Type u_2f:α →. β ⊕ αb:βa:αa':αhb:b ∈ f.fix aha':Sum.inr a' ∈ f ah':Sum.inr a' ∈ f ae':b ∈ f.fix a'⊢ b ∈ f.fix a' All goals completed! 🐙@[elab_as_elim] theorem evalInduction' {σ : Type*} {f : σ → Option σ} {b : σ} {C : σ → Prop} {a : σ} (h : b ∈ eval f a) (H : ∀ a, b ∈ eval f a → (∀ a', f a = some a' → C a') → C a) : C a := σ:Type u_1f:σ → Option σb:σC:σ → Propa:σh:b ∈ eval f aH:∀ (a : σ), b ∈ eval f a → (∀ (a' : σ), f a = some a' → C a') → C a⊢ C a σ:Type u_1f:σ → Option σb:σC:σ → Propa:σh:b ∈ eval f aH:∀ (a : σ), b ∈ eval f a → (∀ (a' : σ), f a = some a' → C a') → C ag:σ →. σ ⊕ σ := fun s ↦ Part.some ((f s).elim (Sum.inl s) Sum.inr)⊢ C a σ:Type u_1f:σ → Option σb:σC:σ → Propa:σh:b ∈ eval f aH:∀ (a : σ), b ∈ eval f a → (∀ (a' : σ), f a = some a' → C a') → C ag:σ →. σ ⊕ σ := fun s ↦ Part.some ((f s).elim (Sum.inl s) Sum.inr)hmem:b ∈ g.fix a⊢ C a σ:Type u_1f:σ → Option σb:σC:σ → Propa:σh:b ∈ eval f aH:∀ (a : σ), b ∈ eval f a → (∀ (a' : σ), f a = some a' → C a') → C ag:σ →. σ ⊕ σ := fun s ↦ Part.some ((f s).elim (Sum.inl s) Sum.inr)hmem:b ∈ g.fix ahacc:Acc (fun x y ↦ Sum.inr x ∈ g y) ah₂:b ∈ WellFounded.fixF (fun a IH ↦ Part.assert (g a).Dom fun hf ↦ match e : (g a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) a hacc⊢ C a σ:Type u_1f:σ → Option σb:σC:σ → Propa:σH:∀ (a : σ), b ∈ eval f a → (∀ (a' : σ), f a = some a' → C a') → C ag:σ →. σ ⊕ σ := fun s ↦ Part.some ((f s).elim (Sum.inl s) Sum.inr)hacc:Acc (fun x y ↦ Sum.inr x ∈ g y) ah₂:b ∈ WellFounded.fixF (fun a IH ↦ Part.assert (g a).Dom fun hf ↦ match e : (g a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) a hacc⊢ C a induction hacc with σ:Type u_1f:σ → Option σb:σC:σ → Propa:σH:∀ (a : σ), b ∈ eval f a → (∀ (a' : σ), f a = some a' → C a') → C ag:σ →. σ ⊕ σ := fun s ↦ Part.some ((f s).elim (Sum.inl s) Sum.inr)x:σhx:∀ (y : σ), Sum.inr y ∈ g x → Acc (fun x y ↦ Sum.inr x ∈ g y) yIH:∀ (y : σ) (a : Sum.inr y ∈ g x), b ∈ WellFounded.fixF (fun a IH ↦ Part.assert (g a).Dom fun hf ↦ match e : (g a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) y ⋯ → C yh₂:b ∈ WellFounded.fixF (fun a IH ↦ Part.assert (g a).Dom fun hf ↦ match e : (g a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) x ⋯⊢ C x σ:Type u_1f:σ → Option σb:σC:σ → Propa:σH:∀ (a : σ), b ∈ eval f a → (∀ (a' : σ), f a = some a' → C a') → C ag:σ →. σ ⊕ σ := fun s ↦ Part.some ((f s).elim (Sum.inl s) Sum.inr)x:σhx:∀ (y : σ), Sum.inr y ∈ g x → Acc (fun x y ↦ Sum.inr x ∈ g y) yIH:∀ (y : σ) (a : Sum.inr y ∈ g x), b ∈ WellFounded.fixF (fun a IH ↦ Part.assert (g a).Dom fun hf ↦ match e : (g a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) y ⋯ → C yh₂:b ∈ WellFounded.fixF (fun a IH ↦ Part.assert (g a).Dom fun hf ↦ match e : (g a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) x ⋯hxmem:b ∈ g.fix x⊢ C x σ:Type u_1f:σ → Option σb:σC:σ → Propa:σH:∀ (a : σ), b ∈ eval f a → (∀ (a' : σ), f a = some a' → C a') → C ag:σ →. σ ⊕ σ := fun s ↦ Part.some ((f s).elim (Sum.inl s) Sum.inr)x:σhx:∀ (y : σ), Sum.inr y ∈ g x → Acc (fun x y ↦ Sum.inr x ∈ g y) yIH:∀ (y : σ) (a : Sum.inr y ∈ g x), b ∈ WellFounded.fixF (fun a IH ↦ Part.assert (g a).Dom fun hf ↦ match e : (g a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) y ⋯ → C yh₂:b ∈ WellFounded.fixF (fun a IH ↦ Part.assert (g a).Dom fun hf ↦ match e : (g a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) x ⋯hxmem:b ∈ g.fix xx':σex':f x = some x'⊢ C x' σ:Type u_1f:σ → Option σb:σC:σ → Propa:σH:∀ (a : σ), b ∈ eval f a → (∀ (a' : σ), f a = some a' → C a') → C ag:σ →. σ ⊕ σ := fun s ↦ Part.some ((f s).elim (Sum.inl s) Sum.inr)x:σhx:∀ (y : σ), Sum.inr y ∈ g x → Acc (fun x y ↦ Sum.inr x ∈ g y) yIH:∀ (y : σ) (a : Sum.inr y ∈ g x), b ∈ WellFounded.fixF (fun a IH ↦ Part.assert (g a).Dom fun hf ↦ match e : (g a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) y ⋯ → C yh₂:b ∈ WellFounded.fixF (fun a IH ↦ Part.assert (g a).Dom fun hf ↦ match e : (g a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⋯) x ⋯hxmem:b ∈ g.fix xx':σex':f x = some x'hinr:Sum.inr x' ∈ g x⊢ C x' All goals completed! 🐙theorem mem_eval' {σ : Type*} {f : σ → Option σ} {a b : σ} : b ∈ eval f a ↔ Reaches f a b ∧ f b = none := σ:Type u_1f:σ → Option σa:σb:σ⊢ b ∈ eval f a ↔ Reaches f a b ∧ f b = none σ:Type u_1f:σ → Option σa:σb:σh:b ∈ eval f a⊢ Reaches f a b ∧ f b = noneσ:Type u_1f:σ → Option σa:σb:σx✝:Reaches f a b ∧ f b = noneh₁:Reaches f a bh₂:f b = none⊢ b ∈ eval f a σ:Type u_1f:σ → Option σa:σb:σh:b ∈ eval f a⊢ Reaches f a b ∧ f b = none σ:Type u_1f:σ → Option σa✝:σb:σh✝:b ∈ eval f aa:σh:b ∈ eval f aIH:∀ (a' : σ), f a = some a' → Reaches f a' b ∧ f b = none⊢ Reaches f a b ∧ f b = none σ:Type u_1f:σ → Option σa✝:σb:σh✝:b ∈ eval f aa:σh:b ∈ eval f aIH:∀ (a' : σ), f a = some a' → Reaches f a' b ∧ f b = nonee:f a = none⊢ Reaches f a b ∧ f b = noneσ:Type u_1f:σ → Option σa✝:σb:σh✝:b ∈ eval f aa:σh:b ∈ eval f aIH:∀ (a' : σ), f a = some a' → Reaches f a' b ∧ f b = nonea':σe:f a = some a'⊢ Reaches f a b ∧ f b = none σ:Type u_1f:σ → Option σa✝:σb:σh✝:b ∈ eval f aa:σh:b ∈ eval f aIH:∀ (a' : σ), f a = some a' → Reaches f a' b ∧ f b = nonee:f a = none⊢ Reaches f a b ∧ f b = none σ:Type u_1f:σ → Option σa✝:σb:σh✝:b ∈ eval f aa:σh:b ∈ eval f aIH:∀ (a' : σ), f a = some a' → Reaches f a' b ∧ f b = nonee:f a = none⊢ Reaches f a a ∧ f a = none All goals completed! 🐙 σ:Type u_1f:σ → Option σa✝:σb:σh✝:b ∈ eval f aa:σh:b ∈ eval f aIH:∀ (a' : σ), f a = some a' → Reaches f a' b ∧ f b = nonea':σe:f a = some a'⊢ Reaches f a b ∧ f b = none σ:Type u_1f:σ → Option σa✝:σb:σh✝¹:b ∈ eval f aa:σh✝:b ∈ eval f aIH:∀ (a' : σ), f a = some a' → Reaches f a' b ∧ f b = nonea':σe:f a = some a'h:Sum.inl b ∈ Part.some ((f a).elim (Sum.inl a) Sum.inr)⊢ Reaches f a b ∧ f b = noneσ:Type u_1f:σ → Option σa✝:σb:σh✝¹:b ∈ eval f aa:σh✝:b ∈ eval f aIH:∀ (a' : σ), f a = some a' → Reaches f a' b ∧ f b = nonea':σe:f a = some a'w✝:σh:Sum.inr w✝ ∈ Part.some ((f a).elim (Sum.inl a) Sum.inr)right✝:b ∈ PFun.fix (fun s ↦ Part.some ((f s).elim (Sum.inl s) Sum.inr)) w✝⊢ Reaches f a b ∧ f b = none σ:Type u_1f:σ → Option σa✝:σb:σh✝¹:b ∈ eval f aa:σh✝:b ∈ eval f aIH:∀ (a' : σ), f a = some a' → Reaches f a' b ∧ f b = nonea':σe:f a = some a'h:Sum.inl b ∈ Part.some ((f a).elim (Sum.inl a) Sum.inr)⊢ Reaches f a b ∧ f b = noneσ:Type u_1f:σ → Option σa✝:σb:σh✝¹:b ∈ eval f aa:σh✝:b ∈ eval f aIH:∀ (a' : σ), f a = some a' → Reaches f a' b ∧ f b = nonea':σe:f a = some a'w✝:σh:Sum.inr w✝ ∈ Part.some ((f a).elim (Sum.inl a) Sum.inr)right✝:b ∈ PFun.fix (fun s ↦ Part.some ((f s).elim (Sum.inl s) Sum.inr)) w✝⊢ Reaches f a b ∧ f b = none σ:Type u_1f:σ → Option σa✝:σb:σh✝¹:b ∈ eval f aa:σh✝:b ∈ eval f aIH:∀ (a' : σ), f a = some a' → Reaches f a' b ∧ f b = nonea':σe:f a = some a'w✝:σh:Sum.inr w✝ ∈ Part.some ((some a').elim (Sum.inl a) Sum.inr)right✝:b ∈ PFun.fix (fun s ↦ Part.some ((f s).elim (Sum.inl s) Sum.inr)) w✝⊢ Reaches f a b ∧ f b = none σ:Type u_1f:σ → Option σa✝:σb:σh✝¹:b ∈ eval f aa:σh✝:b ∈ eval f aIH:∀ (a' : σ), f a = some a' → Reaches f a' b ∧ f b = nonea':σe:f a = some a'h:Sum.inl b ∈ Part.some ((some a').elim (Sum.inl a) Sum.inr)⊢ Reaches f a b ∧ f b = noneσ:Type u_1f:σ → Option σa✝:σb:σh✝¹:b ∈ eval f aa:σh✝:b ∈ eval f aIH:∀ (a' : σ), f a = some a' → Reaches f a' b ∧ f b = nonea':σe:f a = some a'w✝:σh:Sum.inr w✝ ∈ Part.some ((some a').elim (Sum.inl a) Sum.inr)right✝:b ∈ PFun.fix (fun s ↦ Part.some ((f s).elim (Sum.inl s) Sum.inr)) w✝⊢ Reaches f a b ∧ f b = none σ:Type u_1f:σ → Option σa✝:σb:σh✝¹:b ∈ eval f aa:σh✝:b ∈ eval f aIH:∀ (a' : σ), f a = some a' → Reaches f a' b ∧ f b = nonea':σe:f a = some a'h:Sum.inr a' ∈ Part.some ((some a').elim (Sum.inl a) Sum.inr)right✝:b ∈ PFun.fix (fun s ↦ Part.some ((f s).elim (Sum.inl s) Sum.inr)) a'⊢ Reaches f a b ∧ f b = none σ:Type u_1f:σ → Option σa✝:σb:σh✝¹:b ∈ eval f aa:σh✝:b ∈ eval f aIH:∀ (a' : σ), f a = some a' → Reaches f a' b ∧ f b = nonea':σe:f a = some a'h:Sum.inr a' ∈ Part.some ((some a').elim (Sum.inl a) Sum.inr)right✝:b ∈ PFun.fix (fun s ↦ Part.some ((f s).elim (Sum.inl s) Sum.inr)) a'h₁:Reaches f a' bh₂:f b = none⊢ Reaches f a b ∧ f b = none All goals completed! 🐙 σ:Type u_1f:σ → Option σa:σb:σx✝:Reaches f a b ∧ f b = noneh₁:Reaches f a bh₂:f b = none⊢ b ∈ eval f a σ:Type u_1f:σ → Option σa:σb:σx✝:Reaches f a b ∧ f b = noneh₁:Reaches f a bh₂:f b = none⊢ b ∈ eval f bσ:Type u_1f:σ → Option σa:σb:σx✝¹:Reaches f a b ∧ f b = noneh₁:Reaches f a bh₂:f b = nonea✝:σc✝:σh:c✝ ∈ f a✝x✝:Relation.ReflTransGen (fun a b ↦ b ∈ f a) c✝ bIH:b ∈ eval f c✝⊢ b ∈ eval f a✝ σ:Type u_1f:σ → Option σa:σb:σx✝:Reaches f a b ∧ f b = noneh₁:Reaches f a bh₂:f b = none⊢ b ∈ eval f b exact pfun_mem_fix_iff.2 (Or.inl (Part.mem_some_iff.2 (σ:Type u_1f:σ → Option σa:σb:σx✝:Reaches f a b ∧ f b = noneh₁:Reaches f a bh₂:f b = none⊢ Sum.inl b = (f b).elim (Sum.inl b) Sum.inr σ:Type u_1f:σ → Option σa:σb:σx✝:Reaches f a b ∧ f b = noneh₁:Reaches f a bh₂:f b = none⊢ Sum.inl b = none.elim (Sum.inl b) Sum.inr; All goals completed! 🐙))) σ:Type u_1f:σ → Option σa:σb:σx✝¹:Reaches f a b ∧ f b = noneh₁:Reaches f a bh₂:f b = nonea✝:σc✝:σh:c✝ ∈ f a✝x✝:Relation.ReflTransGen (fun a b ↦ b ∈ f a) c✝ bIH:b ∈ eval f c✝⊢ b ∈ eval f a✝ exact pfun_mem_fix_iff.2 (Or.inr ⟨_, Part.mem_some_iff.2 (σ:Type u_1f:σ → Option σa:σb:σx✝¹:Reaches f a b ∧ f b = noneh₁:Reaches f a bh₂:f b = nonea✝:σc✝:σh:c✝ ∈ f a✝x✝:Relation.ReflTransGen (fun a b ↦ b ∈ f a) c✝ bIH:b ∈ eval f c✝⊢ Sum.inr c✝ = (f a✝).elim (Sum.inl a✝) Sum.inr σ:Type u_1f:σ → Option σa:σb:σx✝¹:Reaches f a b ∧ f b = noneh₁:Reaches f a bh₂:f b = nonea✝:σc✝:σh:c✝ ∈ f a✝x✝:Relation.ReflTransGen (fun a b ↦ b ∈ f a) c✝ bIH:b ∈ eval f c✝⊢ Sum.inr c✝ = (some c✝).elim (Sum.inl a✝) Sum.inr; All goals completed! 🐙), IH⟩)private theorem rtg_cases_head {α : Type*} {r : α → α → Prop} {a b : α} (h : Relation.ReflTransGen r a b) : a = b ∨ ∃ c, r a c ∧ Relation.ReflTransGen r c b := α:Type u_1r:α → α → Propa:αb:αh:Relation.ReflTransGen r a b⊢ a = b ∨ ∃ c, r a c ∧ Relation.ReflTransGen r c b induction h with α:Type u_1r:α → α → Propa:αb:α⊢ a = a ∨ ∃ c, r a c ∧ Relation.ReflTransGen r c a All goals completed! 🐙 α:Type u_1r:α → α → Propa:αb:αx:αy:αa✝:Relation.ReflTransGen r a xhxy:r x yih:a = x ∨ ∃ c, r a c ∧ Relation.ReflTransGen r c x⊢ a = y ∨ ∃ c, r a c ∧ Relation.ReflTransGen r c y α:Type u_1r:α → α → Propa:αb:αy:αa✝:Relation.ReflTransGen r a ahxy:r a y⊢ a = y ∨ ∃ c, r a c ∧ Relation.ReflTransGen r c yα:Type u_1r:α → α → Propa:αb:αx:αy:αa✝:Relation.ReflTransGen r a xhxy:r x yc:αhac:r a chcx:Relation.ReflTransGen r c x⊢ a = y ∨ ∃ c, r a c ∧ Relation.ReflTransGen r c y α:Type u_1r:α → α → Propa:αb:αy:αa✝:Relation.ReflTransGen r a ahxy:r a y⊢ a = y ∨ ∃ c, r a c ∧ Relation.ReflTransGen r c y All goals completed! 🐙 α:Type u_1r:α → α → Propa:αb:αx:αy:αa✝:Relation.ReflTransGen r a xhxy:r x yc:αhac:r a chcx:Relation.ReflTransGen r c x⊢ a = y ∨ ∃ c, r a c ∧ Relation.ReflTransGen r c y All goals completed! 🐙theorem reaches_total_det {σ : Type*} {f : σ → Option σ} {a b c : σ} (hab : Reaches f a b) (hac : Reaches f a c) : Reaches f b c ∨ Reaches f c b := σ:Type u_1f:σ → Option σa:σb:σc:σhab:Reaches f a bhac:Reaches f a c⊢ Reaches f b c ∨ Reaches f c b induction hab using Relation.ReflTransGen.head_induction_on generalizing c with σ:Type u_1f:σ → Option σa:σb:σc:σhac:Reaches f b c⊢ Reaches f b c ∨ Reaches f c b All goals completed! 🐙 σ:Type u_1f:σ → Option σa:σb:σx:σx₁:σhx₁:x₁ ∈ f xhxb:Relation.ReflTransGen (fun a b ↦ b ∈ f a) x₁ bih:∀ {c : σ}, Reaches f x₁ c → Reaches f b c ∨ Reaches f c bc:σhac:Reaches f x c⊢ Reaches f b c ∨ Reaches f c b σ:Type u_1f:σ → Option σa:σb:σx:σx₁:σhx₁:x₁ ∈ f xhxb:Relation.ReflTransGen (fun a b ↦ b ∈ f a) x₁ bih:∀ {c : σ}, Reaches f x₁ c → Reaches f b c ∨ Reaches f c bhac:Reaches f x x⊢ Reaches f b x ∨ Reaches f x bσ:Type u_1f:σ → Option σa:σb:σx:σx₁:σhx₁:x₁ ∈ f xhxb:Relation.ReflTransGen (fun a b ↦ b ∈ f a) x₁ bih:∀ {c : σ}, Reaches f x₁ c → Reaches f b c ∨ Reaches f c bc:σhac:Reaches f x cc₁:σhc₁:c₁ ∈ f xhc₁c:Relation.ReflTransGen (fun a b ↦ b ∈ f a) c₁ c⊢ Reaches f b c ∨ Reaches f c b σ:Type u_1f:σ → Option σa:σb:σx:σx₁:σhx₁:x₁ ∈ f xhxb:Relation.ReflTransGen (fun a b ↦ b ∈ f a) x₁ bih:∀ {c : σ}, Reaches f x₁ c → Reaches f b c ∨ Reaches f c bhac:Reaches f x x⊢ Reaches f b x ∨ Reaches f x b All goals completed! 🐙 σ:Type u_1f:σ → Option σa:σb:σx:σx₁:σhx₁:x₁ ∈ f xhxb:Relation.ReflTransGen (fun a b ↦ b ∈ f a) x₁ bih:∀ {c : σ}, Reaches f x₁ c → Reaches f b c ∨ Reaches f c bc:σhac:Reaches f x cc₁:σhc₁:c₁ ∈ f xhc₁c:Relation.ReflTransGen (fun a b ↦ b ∈ f a) c₁ c⊢ Reaches f b c ∨ Reaches f c b σ:Type u_1f:σ → Option σa:σb:σx:σx₁:σhx₁:x₁ ∈ f xhxb:Relation.ReflTransGen (fun a b ↦ b ∈ f a) x₁ bih:∀ {c : σ}, Reaches f x₁ c → Reaches f b c ∨ Reaches f c bc:σhac:Reaches f x chc₁:x₁ ∈ f xhc₁c:Relation.ReflTransGen (fun a b ↦ b ∈ f a) x₁ c⊢ Reaches f b c ∨ Reaches f c b All goals completed! 🐙theorem reaches_of_none {σ : Type*} {f : σ → Option σ} {b c : σ} (hb : f b = none) (hbc : Reaches f b c) : b = c := σ:Type u_1f:σ → Option σb:σc:σhb:f b = nonehbc:Reaches f b c⊢ b = c σ:Type u_1f:σ → Option σb:σhb:f b = nonehbc:Reaches f b b⊢ b = bσ:Type u_1f:σ → Option σb:σc:σhb:f b = nonehbc:Reaches f b cd:σhbd:d ∈ f bright✝:Relation.ReflTransGen (fun a b ↦ b ∈ f a) d c⊢ b = c σ:Type u_1f:σ → Option σb:σhb:f b = nonehbc:Reaches f b b⊢ b = b All goals completed! 🐙 σ:Type u_1f:σ → Option σb:σc:σhb:f b = nonehbc:Reaches f b cd:σhbd:d ∈ f bright✝:Relation.ReflTransGen (fun a b ↦ b ∈ f a) d c⊢ b = c All goals completed! 🐙theorem list_length_five {α : Type*} : ∀ (l : List α), l.length = 5 → ∃ a b c d e, l = [a, b, c, d, e] | [a, b, c, d, e], _ => ⟨a, b, c, d, e, rfl⟩ | [], h | [_], h | [_, _], h | [_, _, _], h | [_, _, _, _], h | _ :: _ :: _ :: _ :: _ :: _ :: _, h => nomatch htheorem reaches_eval' {σ : Type*} {f : σ → Option σ} {a b : σ} (ab : Reaches f a b) : eval f a = eval f b := σ:Type u_1f:σ → Option σa:σb:σab:Reaches f a b⊢ eval f a = eval f b σ:Type u_1f:σ → Option σa:σb:σab:Reaches f a bc:σh:c ∈ eval f a⊢ c ∈ eval f bσ:Type u_1f:σ → Option σa:σb:σab:Reaches f a bc:σh:c ∈ eval f b⊢ c ∈ eval f a σ:Type u_1f:σ → Option σa:σb:σab:Reaches f a bc:σh:c ∈ eval f a⊢ c ∈ eval f b σ:Type u_1f:σ → Option σa:σb:σab:Reaches f a bc:σh:c ∈ eval f aac:Reaches f a cc0:f c = none⊢ c ∈ eval f b σ:Type u_1f:σ → Option σa:σb:σab:Reaches f a bc:σh:c ∈ eval f aac:Reaches f a cc0:f c = none⊢ Reaches f b c σ:Type u_1f:σ → Option σa:σb:σab:Reaches f a bc:σh:c ∈ eval f aac:Reaches f a cc0:f c = nonebc:Reaches f b c⊢ Reaches f b cσ:Type u_1f:σ → Option σa:σb:σab:Reaches f a bc:σh:c ∈ eval f aac:Reaches f a cc0:f c = nonecb:Reaches f c b⊢ Reaches f b c σ:Type u_1f:σ → Option σa:σb:σab:Reaches f a bc:σh:c ∈ eval f aac:Reaches f a cc0:f c = nonebc:Reaches f b c⊢ Reaches f b c All goals completed! 🐙 σ:Type u_1f:σ → Option σa:σb:σab:Reaches f a bc:σh:c ∈ eval f aac:Reaches f a cc0:f c = nonecb:Reaches f c b⊢ Reaches f b c All goals completed! 🐙 σ:Type u_1f:σ → Option σa:σb:σab:Reaches f a bc:σh:c ∈ eval f b⊢ c ∈ eval f a σ:Type u_1f:σ → Option σa:σb:σab:Reaches f a bc:σh:c ∈ eval f bbc:Reaches f b cc0:f c = none⊢ c ∈ eval f a All goals completed! 🐙private theorem tr_reaches' {σ₁ σ₂ : Type*} {f₁ : σ₁ → Option σ₁} {f₂ : σ₂ → Option σ₂} {tr : σ₁ → σ₂ → Prop} (H : Respects f₁ f₂ tr) {a₁ : σ₁} {a₂ : σ₂} (aa : tr a₁ a₂) {b₁ : σ₁} (ab : Reaches f₁ a₁ b₁) : ∃ b₂, tr b₁ b₂ ∧ Reaches f₂ a₂ b₂ := σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁a₂:σ₂aa:tr a₁ a₂b₁:σ₁ab:Reaches f₁ a₁ b₁⊢ ∃ b₂, tr b₁ b₂ ∧ Reaches f₂ a₂ b₂ induction ab with σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁a₂:σ₂aa:tr a₁ a₂b₁:σ₁⊢ ∃ b₂, tr a₁ b₂ ∧ Reaches f₂ a₂ b₂ All goals completed! 🐙 σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁a₂:σ₂aa:tr a₁ a₂b₁:σ₁c₁:σ₁d₁:σ₁a✝:Relation.ReflTransGen (fun a b ↦ b ∈ f₁ a) a₁ c₁cd:d₁ ∈ f₁ c₁IH:∃ b₂, tr c₁ b₂ ∧ Reaches f₂ a₂ b₂⊢ ∃ b₂, tr d₁ b₂ ∧ Reaches f₂ a₂ b₂ σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁a₂:σ₂aa:tr a₁ a₂b₁:σ₁c₁:σ₁d₁:σ₁a✝:Relation.ReflTransGen (fun a b ↦ b ∈ f₁ a) a₁ c₁cd:d₁ ∈ f₁ c₁c₂:σ₂cc:tr c₁ c₂ac₂:Reaches f₂ a₂ c₂⊢ ∃ b₂, tr d₁ b₂ ∧ Reaches f₂ a₂ b₂ σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁a₂:σ₂aa:tr a₁ a₂b₁:σ₁c₁:σ₁d₁:σ₁a✝:Relation.ReflTransGen (fun a b ↦ b ∈ f₁ a) a₁ c₁cd:d₁ ∈ f₁ c₁c₂:σ₂cc:tr c₁ c₂ac₂:Reaches f₂ a₂ c₂this:match f₁ c₁ with | some b₁ => ∃ b₂, tr b₁ b₂ ∧ Reaches₁ f₂ c₂ b₂ | none => f₂ c₂ = none⊢ ∃ b₂, tr d₁ b₂ ∧ Reaches f₂ a₂ b₂ σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁a₂:σ₂aa:tr a₁ a₂b₁:σ₁c₁:σ₁d₁:σ₁a✝:Relation.ReflTransGen (fun a b ↦ b ∈ f₁ a) a₁ c₁cd:d₁ ∈ f₁ c₁c₂:σ₂cc:tr c₁ c₂ac₂:Reaches f₂ a₂ c₂this:match some d₁ with | some b₁ => ∃ b₂, tr b₁ b₂ ∧ Reaches₁ f₂ c₂ b₂ | none => f₂ c₂ = none⊢ ∃ b₂, tr d₁ b₂ ∧ Reaches f₂ a₂ b₂ σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁a₂:σ₂aa:tr a₁ a₂b₁:σ₁c₁:σ₁d₁:σ₁a✝:Relation.ReflTransGen (fun a b ↦ b ∈ f₁ a) a₁ c₁cd:d₁ ∈ f₁ c₁c₂:σ₂cc:tr c₁ c₂ac₂:Reaches f₂ a₂ c₂d₂:σ₂dd:tr d₁ d₂cd₂:Reaches₁ f₂ c₂ d₂⊢ ∃ b₂, tr d₁ b₂ ∧ Reaches f₂ a₂ b₂ All goals completed! 🐙private theorem tr_reaches_rev' {σ₁ σ₂ : Type*} {f₁ : σ₁ → Option σ₁} {f₂ : σ₂ → Option σ₂} {tr : σ₁ → σ₂ → Prop} (H : Respects f₁ f₂ tr) {a₁ : σ₁} {a₂ b₂ : σ₂} (aa : tr a₁ a₂) (ab : Reaches f₂ a₂ b₂) : ∃ c₁ c₂, Reaches f₂ b₂ c₂ ∧ tr c₁ c₂ ∧ Reaches f₁ a₁ c₁ := σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁a₂:σ₂b₂:σ₂aa:tr a₁ a₂ab:Reaches f₂ a₂ b₂⊢ ∃ c₁ c₂, Reaches f₂ b₂ c₂ ∧ tr c₁ c₂ ∧ Reaches f₁ a₁ c₁ induction ab with σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁a₂:σ₂b₂:σ₂aa:tr a₁ a₂⊢ ∃ c₁ c₂, Reaches f₂ a₂ c₂ ∧ tr c₁ c₂ ∧ Reaches f₁ a₁ c₁ All goals completed! 🐙 σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁a₂:σ₂b₂:σ₂aa:tr a₁ a₂c₂:σ₂d₂:σ₂a✝:Relation.ReflTransGen (fun a b ↦ b ∈ f₂ a) a₂ c₂cd:d₂ ∈ f₂ c₂IH:∃ c₁ c₂_1, Reaches f₂ c₂ c₂_1 ∧ tr c₁ c₂_1 ∧ Reaches f₁ a₁ c₁⊢ ∃ c₁ c₂, Reaches f₂ d₂ c₂ ∧ tr c₁ c₂ ∧ Reaches f₁ a₁ c₁ σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁a₂:σ₂b₂:σ₂aa:tr a₁ a₂c₂:σ₂d₂:σ₂a✝:Relation.ReflTransGen (fun a b ↦ b ∈ f₂ a) a₂ c₂cd:d₂ ∈ f₂ c₂e₁:σ₁e₂:σ₂ce:Reaches f₂ c₂ e₂ee:tr e₁ e₂ae:Reaches f₁ a₁ e₁⊢ ∃ c₁ c₂, Reaches f₂ d₂ c₂ ∧ tr c₁ c₂ ∧ Reaches f₁ a₁ c₁ σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁a₂:σ₂b₂:σ₂aa:tr a₁ a₂c₂:σ₂d₂:σ₂a✝:Relation.ReflTransGen (fun a b ↦ b ∈ f₂ a) a₂ c₂cd:d₂ ∈ f₂ c₂e₁:σ₁ae:Reaches f₁ a₁ e₁ce:Reaches f₂ c₂ c₂ee:tr e₁ c₂⊢ ∃ c₁ c₂, Reaches f₂ d₂ c₂ ∧ tr c₁ c₂ ∧ Reaches f₁ a₁ c₁σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁a₂:σ₂b₂:σ₂aa:tr a₁ a₂c₂:σ₂d₂:σ₂a✝:Relation.ReflTransGen (fun a b ↦ b ∈ f₂ a) a₂ c₂cd:d₂ ∈ f₂ c₂e₁:σ₁e₂:σ₂ce:Reaches f₂ c₂ e₂ee:tr e₁ e₂ae:Reaches f₁ a₁ e₁d':σ₂cd':d' ∈ f₂ c₂de:Relation.ReflTransGen (fun a b ↦ b ∈ f₂ a) d' e₂⊢ ∃ c₁ c₂, Reaches f₂ d₂ c₂ ∧ tr c₁ c₂ ∧ Reaches f₁ a₁ c₁ σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁a₂:σ₂b₂:σ₂aa:tr a₁ a₂c₂:σ₂d₂:σ₂a✝:Relation.ReflTransGen (fun a b ↦ b ∈ f₂ a) a₂ c₂cd:d₂ ∈ f₂ c₂e₁:σ₁ae:Reaches f₁ a₁ e₁ce:Reaches f₂ c₂ c₂ee:tr e₁ c₂⊢ ∃ c₁ c₂, Reaches f₂ d₂ c₂ ∧ tr c₁ c₂ ∧ Reaches f₁ a₁ c₁ σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁a₂:σ₂b₂:σ₂aa:tr a₁ a₂c₂:σ₂d₂:σ₂a✝:Relation.ReflTransGen (fun a b ↦ b ∈ f₂ a) a₂ c₂cd:d₂ ∈ f₂ c₂e₁:σ₁ae:Reaches f₁ a₁ e₁ce:Reaches f₂ c₂ c₂ee:tr e₁ c₂this:match f₁ e₁ with | some b₁ => ∃ b₂, tr b₁ b₂ ∧ Reaches₁ f₂ c₂ b₂ | none => f₂ c₂ = none⊢ ∃ c₁ c₂, Reaches f₂ d₂ c₂ ∧ tr c₁ c₂ ∧ Reaches f₁ a₁ c₁ σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁a₂:σ₂b₂:σ₂aa:tr a₁ a₂c₂:σ₂d₂:σ₂a✝:Relation.ReflTransGen (fun a b ↦ b ∈ f₂ a) a₂ c₂cd:d₂ ∈ f₂ c₂e₁:σ₁ae:Reaches f₁ a₁ e₁ce:Reaches f₂ c₂ c₂ee:tr e₁ c₂this:match f₁ e₁ with | some b₁ => ∃ b₂, tr b₁ b₂ ∧ Reaches₁ f₂ c₂ b₂ | none => f₂ c₂ = noneeg:f₁ e₁ = none⊢ ∃ c₁ c₂, Reaches f₂ d₂ c₂ ∧ tr c₁ c₂ ∧ Reaches f₁ a₁ c₁σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁a₂:σ₂b₂:σ₂aa:tr a₁ a₂c₂:σ₂d₂:σ₂a✝:Relation.ReflTransGen (fun a b ↦ b ∈ f₂ a) a₂ c₂cd:d₂ ∈ f₂ c₂e₁:σ₁ae:Reaches f₁ a₁ e₁ce:Reaches f₂ c₂ c₂ee:tr e₁ c₂this:match f₁ e₁ with | some b₁ => ∃ b₂, tr b₁ b₂ ∧ Reaches₁ f₂ c₂ b₂ | none => f₂ c₂ = noneg₁:σ₁eg:f₁ e₁ = some g₁⊢ ∃ c₁ c₂, Reaches f₂ d₂ c₂ ∧ tr c₁ c₂ ∧ Reaches f₁ a₁ c₁ σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁a₂:σ₂b₂:σ₂aa:tr a₁ a₂c₂:σ₂d₂:σ₂a✝:Relation.ReflTransGen (fun a b ↦ b ∈ f₂ a) a₂ c₂cd:d₂ ∈ f₂ c₂e₁:σ₁ae:Reaches f₁ a₁ e₁ce:Reaches f₂ c₂ c₂ee:tr e₁ c₂this:match f₁ e₁ with | some b₁ => ∃ b₂, tr b₁ b₂ ∧ Reaches₁ f₂ c₂ b₂ | none => f₂ c₂ = noneeg:f₁ e₁ = none⊢ ∃ c₁ c₂, Reaches f₂ d₂ c₂ ∧ tr c₁ c₂ ∧ Reaches f₁ a₁ c₁ σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁a₂:σ₂b₂:σ₂aa:tr a₁ a₂c₂:σ₂d₂:σ₂a✝:Relation.ReflTransGen (fun a b ↦ b ∈ f₂ a) a₂ c₂cd:d₂ ∈ f₂ c₂e₁:σ₁ae:Reaches f₁ a₁ e₁ce:Reaches f₂ c₂ c₂ee:tr e₁ c₂this:match none with | some b₁ => ∃ b₂, tr b₁ b₂ ∧ Reaches₁ f₂ c₂ b₂ | none => f₂ c₂ = noneeg:f₁ e₁ = none⊢ ∃ c₁ c₂, Reaches f₂ d₂ c₂ ∧ tr c₁ c₂ ∧ Reaches f₁ a₁ c₁ All goals completed! 🐙 σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁a₂:σ₂b₂:σ₂aa:tr a₁ a₂c₂:σ₂d₂:σ₂a✝:Relation.ReflTransGen (fun a b ↦ b ∈ f₂ a) a₂ c₂cd:d₂ ∈ f₂ c₂e₁:σ₁ae:Reaches f₁ a₁ e₁ce:Reaches f₂ c₂ c₂ee:tr e₁ c₂this:match f₁ e₁ with | some b₁ => ∃ b₂, tr b₁ b₂ ∧ Reaches₁ f₂ c₂ b₂ | none => f₂ c₂ = noneg₁:σ₁eg:f₁ e₁ = some g₁⊢ ∃ c₁ c₂, Reaches f₂ d₂ c₂ ∧ tr c₁ c₂ ∧ Reaches f₁ a₁ c₁ σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁a₂:σ₂b₂:σ₂aa:tr a₁ a₂c₂:σ₂d₂:σ₂a✝:Relation.ReflTransGen (fun a b ↦ b ∈ f₂ a) a₂ c₂cd:d₂ ∈ f₂ c₂e₁:σ₁ae:Reaches f₁ a₁ e₁ce:Reaches f₂ c₂ c₂ee:tr e₁ c₂g₁:σ₁this:match some g₁ with | some b₁ => ∃ b₂, tr b₁ b₂ ∧ Reaches₁ f₂ c₂ b₂ | none => f₂ c₂ = noneeg:f₁ e₁ = some g₁⊢ ∃ c₁ c₂, Reaches f₂ d₂ c₂ ∧ tr c₁ c₂ ∧ Reaches f₁ a₁ c₁ σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁a₂:σ₂b₂:σ₂aa:tr a₁ a₂c₂:σ₂d₂:σ₂a✝:Relation.ReflTransGen (fun a b ↦ b ∈ f₂ a) a₂ c₂cd:d₂ ∈ f₂ c₂e₁:σ₁ae:Reaches f₁ a₁ e₁ce:Reaches f₂ c₂ c₂ee:tr e₁ c₂g₁:σ₁eg:f₁ e₁ = some g₁g₂:σ₂gg:tr g₁ g₂cg:Reaches₁ f₂ c₂ g₂⊢ ∃ c₁ c₂, Reaches f₂ d₂ c₂ ∧ tr c₁ c₂ ∧ Reaches f₁ a₁ c₁ σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁a₂:σ₂b₂:σ₂aa:tr a₁ a₂c₂:σ₂d₂:σ₂a✝:Relation.ReflTransGen (fun a b ↦ b ∈ f₂ a) a₂ c₂cd:d₂ ∈ f₂ c₂e₁:σ₁ae:Reaches f₁ a₁ e₁ce:Reaches f₂ c₂ c₂ee:tr e₁ c₂g₁:σ₁eg:f₁ e₁ = some g₁g₂:σ₂gg:tr g₁ g₂cg:Reaches₁ f₂ c₂ g₂d':σ₂cd':d' ∈ f₂ c₂dg:Relation.ReflTransGen (fun a b ↦ b ∈ f₂ a) d' g₂⊢ ∃ c₁ c₂, Reaches f₂ d₂ c₂ ∧ tr c₁ c₂ ∧ Reaches f₁ a₁ c₁ σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁a₂:σ₂b₂:σ₂aa:tr a₁ a₂c₂:σ₂d₂:σ₂a✝:Relation.ReflTransGen (fun a b ↦ b ∈ f₂ a) a₂ c₂cd:d₂ ∈ f₂ c₂e₁:σ₁ae:Reaches f₁ a₁ e₁ce:Reaches f₂ c₂ c₂ee:tr e₁ c₂g₁:σ₁eg:f₁ e₁ = some g₁g₂:σ₂gg:tr g₁ g₂cg:Reaches₁ f₂ c₂ g₂cd':d₂ ∈ f₂ c₂dg:Relation.ReflTransGen (fun a b ↦ b ∈ f₂ a) d₂ g₂⊢ ∃ c₁ c₂, Reaches f₂ d₂ c₂ ∧ tr c₁ c₂ ∧ Reaches f₁ a₁ c₁ All goals completed! 🐙 σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁a₂:σ₂b₂:σ₂aa:tr a₁ a₂c₂:σ₂d₂:σ₂a✝:Relation.ReflTransGen (fun a b ↦ b ∈ f₂ a) a₂ c₂cd:d₂ ∈ f₂ c₂e₁:σ₁e₂:σ₂ce:Reaches f₂ c₂ e₂ee:tr e₁ e₂ae:Reaches f₁ a₁ e₁d':σ₂cd':d' ∈ f₂ c₂de:Relation.ReflTransGen (fun a b ↦ b ∈ f₂ a) d' e₂⊢ ∃ c₁ c₂, Reaches f₂ d₂ c₂ ∧ tr c₁ c₂ ∧ Reaches f₁ a₁ c₁ σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁a₂:σ₂b₂:σ₂aa:tr a₁ a₂c₂:σ₂d₂:σ₂a✝:Relation.ReflTransGen (fun a b ↦ b ∈ f₂ a) a₂ c₂cd:d₂ ∈ f₂ c₂e₁:σ₁e₂:σ₂ce:Reaches f₂ c₂ e₂ee:tr e₁ e₂ae:Reaches f₁ a₁ e₁cd':d₂ ∈ f₂ c₂de:Relation.ReflTransGen (fun a b ↦ b ∈ f₂ a) d₂ e₂⊢ ∃ c₁ c₂, Reaches f₂ d₂ c₂ ∧ tr c₁ c₂ ∧ Reaches f₁ a₁ c₁ All goals completed! 🐙theorem tr_eval' {σ₁ σ₂ : Type*} {f₁ : σ₁ → Option σ₁} {f₂ : σ₂ → Option σ₂} {tr : σ₁ → σ₂ → Prop} (H : Respects f₁ f₂ tr) {a₁ b₁ : σ₁} {a₂ : σ₂} (aa : tr a₁ a₂) (ab : b₁ ∈ eval f₁ a₁) : ∃ b₂, tr b₁ b₂ ∧ b₂ ∈ eval f₂ a₂ := σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁b₁:σ₁a₂:σ₂aa:tr a₁ a₂ab:b₁ ∈ eval f₁ a₁⊢ ∃ b₂, tr b₁ b₂ ∧ b₂ ∈ eval f₂ a₂ σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁b₁:σ₁a₂:σ₂aa:tr a₁ a₂ab✝:b₁ ∈ eval f₁ a₁ab:Reaches f₁ a₁ b₁b0:f₁ b₁ = none⊢ ∃ b₂, tr b₁ b₂ ∧ b₂ ∈ eval f₂ a₂ σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁b₁:σ₁a₂:σ₂aa:tr a₁ a₂ab✝¹:b₁ ∈ eval f₁ a₁ab✝:Reaches f₁ a₁ b₁b0:f₁ b₁ = noneb₂:σ₂bb:tr b₁ b₂ab:Reaches f₂ a₂ b₂⊢ ∃ b₂, tr b₁ b₂ ∧ b₂ ∈ eval f₂ a₂ σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁b₁:σ₁a₂:σ₂aa:tr a₁ a₂ab✝¹:b₁ ∈ eval f₁ a₁ab✝:Reaches f₁ a₁ b₁b0:f₁ b₁ = noneb₂:σ₂bb:tr b₁ b₂ab:Reaches f₂ a₂ b₂⊢ f₂ b₂ = none σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁b₁:σ₁a₂:σ₂aa:tr a₁ a₂ab✝¹:b₁ ∈ eval f₁ a₁ab✝:Reaches f₁ a₁ b₁b0:f₁ b₁ = noneb₂:σ₂bb:tr b₁ b₂ab:Reaches f₂ a₂ b₂this:match f₁ b₁ with | some b₁ => ∃ b₂_1, tr b₁ b₂_1 ∧ Reaches₁ f₂ b₂ b₂_1 | none => f₂ b₂ = none⊢ f₂ b₂ = none; All goals completed! 🐙theorem tr_eval_rev' {σ₁ σ₂ : Type*} {f₁ : σ₁ → Option σ₁} {f₂ : σ₂ → Option σ₂} {tr : σ₁ → σ₂ → Prop} (H : Respects f₁ f₂ tr) {a₁ : σ₁} {b₂ a₂ : σ₂} (aa : tr a₁ a₂) (ab : b₂ ∈ eval f₂ a₂) : ∃ b₁, tr b₁ b₂ ∧ b₁ ∈ eval f₁ a₁ := σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁b₂:σ₂a₂:σ₂aa:tr a₁ a₂ab:b₂ ∈ eval f₂ a₂⊢ ∃ b₁, tr b₁ b₂ ∧ b₁ ∈ eval f₁ a₁ σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁b₂:σ₂a₂:σ₂aa:tr a₁ a₂ab✝:b₂ ∈ eval f₂ a₂ab:Reaches f₂ a₂ b₂b0:f₂ b₂ = none⊢ ∃ b₁, tr b₁ b₂ ∧ b₁ ∈ eval f₁ a₁ σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁b₂:σ₂a₂:σ₂aa:tr a₁ a₂ab✝:b₂ ∈ eval f₂ a₂ab:Reaches f₂ a₂ b₂b0:f₂ b₂ = nonec₁:σ₁c₂:σ₂bc:Reaches f₂ b₂ c₂cc:tr c₁ c₂ac:Reaches f₁ a₁ c₁⊢ ∃ b₁, tr b₁ b₂ ∧ b₁ ∈ eval f₁ a₁ σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁b₂:σ₂a₂:σ₂aa:tr a₁ a₂ab✝:b₂ ∈ eval f₂ a₂ab:Reaches f₂ a₂ b₂b0:f₂ b₂ = nonec₁:σ₁ac:Reaches f₁ a₁ c₁bc:Reaches f₂ b₂ b₂cc:tr c₁ b₂⊢ ∃ b₁, tr b₁ b₂ ∧ b₁ ∈ eval f₁ a₁ σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁b₂:σ₂a₂:σ₂aa:tr a₁ a₂ab✝:b₂ ∈ eval f₂ a₂ab:Reaches f₂ a₂ b₂b0:f₂ b₂ = nonec₁:σ₁ac:Reaches f₁ a₁ c₁bc:Reaches f₂ b₂ b₂cc:tr c₁ b₂⊢ f₁ c₁ = none σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁b₂:σ₂a₂:σ₂aa:tr a₁ a₂ab✝:b₂ ∈ eval f₂ a₂ab:Reaches f₂ a₂ b₂b0:f₂ b₂ = nonec₁:σ₁ac:Reaches f₁ a₁ c₁bc:Reaches f₂ b₂ b₂cc:tr c₁ b₂this:match f₁ c₁ with | some b₁ => ∃ b₂_1, tr b₁ b₂_1 ∧ Reaches₁ f₂ b₂ b₂_1 | none => f₂ b₂ = none⊢ f₁ c₁ = none σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁b₂:σ₂a₂:σ₂aa:tr a₁ a₂ab✝:b₂ ∈ eval f₂ a₂ab:Reaches f₂ a₂ b₂b0:f₂ b₂ = nonec₁:σ₁ac:Reaches f₁ a₁ c₁bc:Reaches f₂ b₂ b₂cc:tr c₁ b₂this:match f₁ c₁ with | some b₁ => ∃ b₂_1, tr b₁ b₂_1 ∧ Reaches₁ f₂ b₂ b₂_1 | none => f₂ b₂ = nonehfc:f₁ c₁ = none⊢ none = noneσ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁b₂:σ₂a₂:σ₂aa:tr a₁ a₂ab✝:b₂ ∈ eval f₂ a₂ab:Reaches f₂ a₂ b₂b0:f₂ b₂ = nonec₁:σ₁ac:Reaches f₁ a₁ c₁bc:Reaches f₂ b₂ b₂cc:tr c₁ b₂this:match f₁ c₁ with | some b₁ => ∃ b₂_1, tr b₁ b₂_1 ∧ Reaches₁ f₂ b₂ b₂_1 | none => f₂ b₂ = noned₁:σ₁hfc:f₁ c₁ = some d₁⊢ some d₁ = none σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁b₂:σ₂a₂:σ₂aa:tr a₁ a₂ab✝:b₂ ∈ eval f₂ a₂ab:Reaches f₂ a₂ b₂b0:f₂ b₂ = nonec₁:σ₁ac:Reaches f₁ a₁ c₁bc:Reaches f₂ b₂ b₂cc:tr c₁ b₂this:match f₁ c₁ with | some b₁ => ∃ b₂_1, tr b₁ b₂_1 ∧ Reaches₁ f₂ b₂ b₂_1 | none => f₂ b₂ = nonehfc:f₁ c₁ = none⊢ none = none All goals completed! 🐙 σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁b₂:σ₂a₂:σ₂aa:tr a₁ a₂ab✝:b₂ ∈ eval f₂ a₂ab:Reaches f₂ a₂ b₂b0:f₂ b₂ = nonec₁:σ₁ac:Reaches f₁ a₁ c₁bc:Reaches f₂ b₂ b₂cc:tr c₁ b₂d₁:σ₁this:match some d₁ with | some b₁ => ∃ b₂_1, tr b₁ b₂_1 ∧ Reaches₁ f₂ b₂ b₂_1 | none => f₂ b₂ = nonehfc:f₁ c₁ = some d₁⊢ some d₁ = none σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁b₂:σ₂a₂:σ₂aa:tr a₁ a₂ab✝:b₂ ∈ eval f₂ a₂ab:Reaches f₂ a₂ b₂b0:f₂ b₂ = nonec₁:σ₁ac:Reaches f₁ a₁ c₁bc:Reaches f₂ b₂ b₂cc:tr c₁ b₂d₁:σ₁hfc:f₁ c₁ = some d₁w✝:σ₂left✝:tr d₁ w✝bd:Reaches₁ f₂ b₂ w✝⊢ some d₁ = none σ₁:Type u_1σ₂:Type u_2f₁:σ₁ → Option σ₁f₂:σ₂ → Option σ₂tr:σ₁ → σ₂ → PropH:Respects f₁ f₂ tra₁:σ₁b₂:σ₂a₂:σ₂aa:tr a₁ a₂ab✝:b₂ ∈ eval f₂ a₂ab:Reaches f₂ a₂ b₂b0:f₂ b₂ = nonec₁:σ₁ac:Reaches f₁ a₁ c₁bc:Reaches f₂ b₂ b₂cc:tr c₁ b₂d₁:σ₁hfc:f₁ c₁ = some d₁w✝¹:σ₂left✝:tr d₁ w✝bd:Reaches₁ f₂ b₂ w✝w✝:σ₂h:w✝ ∈ f₂ b₂right✝:Relation.ReflTransGen (fun a b ↦ b ∈ f₂ a) w✝ w✝¹⊢ some d₁ = none All goals completed! 🐙theorem tr_eval_dom' {σ₁ σ₂ : Type*} {f₁ : σ₁ → Option σ₁} {f₂ : σ₂ → Option σ₂} {tr : σ₁ → σ₂ → Prop} (H : Respects f₁ f₂ tr) {a₁ : σ₁} {a₂ : σ₂} (aa : tr a₁ a₂) : (eval f₂ a₂).Dom ↔ (eval f₁ a₁).Dom := ⟨fun h => let ⟨_, _, h, _⟩ := tr_eval_rev' H aa ⟨h, rfl⟩; h, fun h => let ⟨_, _, h, _⟩ := tr_eval' H aa ⟨h, rfl⟩; h⟩end ConjectureMachines