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]) pos Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γl:List Γx✝:IsTrimmed []h:a = default⊢ IsTrimmed []; exact trivial All goals completed! 🐙
· neg Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γl:List Γx✝:IsTrimmed []h:¬a = default⊢ IsTrimmed (if a = default then [] else [a]) rw [ite_eq_right h neg Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γl:List Γx✝:IsTrimmed []h:¬a = default⊢ IsTrimmed [a]] neg Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γl:List Γx✝:IsTrimmed []h:¬a = default⊢ IsTrimmed [a]; exact h 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 := by x:ℕy:ℕ⊢ x + 1 ≤ y ↔ x < y
constructor mp x:ℕy:ℕ⊢ x + 1 ≤ y → x < ympr x:ℕy:ℕ⊢ x < y → x + 1 ≤ y <;> mp x:ℕy:ℕ⊢ x + 1 ≤ y → x < ympr x:ℕy:ℕ⊢ x < y → x + 1 ≤ y intro h mpr x:ℕy:ℕh:x < y⊢ x + 1 ≤ y <;> mp x:ℕy:ℕh:x + 1 ≤ y⊢ x < ympr x:ℕy:ℕh:x < y⊢ x + 1 ≤ y omega All goals completed! 🐙@[simp high] theorem nat_lt_add_one_iff {x y : ℕ} : x < y + no_index 1 ↔ x ≤ y := by x:ℕy:ℕ⊢ x < y + 1 ↔ x ≤ y
constructor mp x:ℕy:ℕ⊢ x < y + 1 → x ≤ ympr x:ℕy:ℕ⊢ x ≤ y → x < y + 1 <;> mp x:ℕy:ℕ⊢ x < y + 1 → x ≤ ympr x:ℕy:ℕ⊢ x ≤ y → x < y + 1 intro h mpr x:ℕy:ℕh:x ≤ y⊢ x < y + 1 <;> mp x:ℕy:ℕh:x < y + 1⊢ x ≤ ympr x:ℕy:ℕh:x ≤ y⊢ x < y + 1 omega All goals completed! 🐙@[simp high] theorem nat_add_eq_left {n m : ℕ} : n + m = m ↔ n = 0 := by n:ℕm:ℕ⊢ n + m = m ↔ n = 0
constructor mp n:ℕm:ℕ⊢ n + m = m → n = 0mpr n:ℕm:ℕ⊢ n = 0 → n + m = m <;> mp n:ℕm:ℕ⊢ n + m = m → n = 0mpr n:ℕm:ℕ⊢ n = 0 → n + m = m intro h mpr n:ℕm:ℕh:n = 0⊢ n + m = m <;> mp n:ℕm:ℕh:n + m = m⊢ n = 0mpr n:ℕm:ℕh:n = 0⊢ n + m = m omega 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 := by n:ℕ⊢ n < 1 ↔ n = 0 constructor mp n:ℕ⊢ n < 1 → n = 0mpr n:ℕ⊢ n = 0 → n < 1 <;> mp n:ℕ⊢ n < 1 → n = 0mpr n:ℕ⊢ n = 0 → n < 1 intro h mpr n:ℕh:n = 0⊢ n < 1 <;> mp n:ℕh:n < 1⊢ n = 0mpr n:ℕh:n = 0⊢ n < 1 omega 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 | _ + 2 => n:ℕn✝:ℕh:n✝ + 2 < 2⊢ n✝ + 2 = 0 ∨ n✝ + 2 = 1 by n:ℕn✝:ℕh:n✝ + 2 < 2⊢ n✝ + 2 = 0 ∨ n✝ + 2 = 1 omega All goals completed! 🐙,
fun h => h.elim (fun _ => by n:ℕh:n = 0 ∨ n = 1x✝:n = 0⊢ n < 2 omega All goals completed! 🐙) (fun _ => by n:ℕh:n = 0 ∨ n = 1x✝:n = 1⊢ n < 2 omega 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 := by a:ℕb:ℕc:ℕ⊢ a + b < a + c ↔ b < c
constructor mp a:ℕb:ℕc:ℕ⊢ a + b < a + c → b < cmpr a:ℕb:ℕc:ℕ⊢ b < c → a + b < a + c <;> mp a:ℕb:ℕc:ℕ⊢ a + b < a + c → b < cmpr a:ℕb:ℕc:ℕ⊢ b < c → a + b < a + c intro h mpr a:ℕb:ℕc:ℕh:b < c⊢ a + b < a + c <;> mp a:ℕb:ℕc:ℕh:a + b < a + c⊢ b < cmpr a:ℕb:ℕc:ℕh:b < c⊢ a + b < a + c omega All goals completed! 🐙@[simp high] theorem nat_add_lt_add_right (a b c : ℕ) : a + c < b + c ↔ a < b := by a:ℕb:ℕc:ℕ⊢ a + c < b + c ↔ a < b
constructor mp a:ℕb:ℕc:ℕ⊢ a + c < b + c → a < bmpr a:ℕb:ℕc:ℕ⊢ a < b → a + c < b + c <;> mp a:ℕb:ℕc:ℕ⊢ a + c < b + c → a < bmpr a:ℕb:ℕc:ℕ⊢ a < b → a + c < b + c intro h mpr a:ℕb:ℕc:ℕh:a < b⊢ a + c < b + c <;> mp a:ℕb:ℕc:ℕh:a + c < b + c⊢ a < bmpr a:ℕb:ℕc:ℕh:a < b⊢ a + c < b + c omega All goals completed! 🐙@[simp high] theorem nat_add_le_add_left (a b c : ℕ) : a + b ≤ a + c ↔ b ≤ c := by a:ℕb:ℕc:ℕ⊢ a + b ≤ a + c ↔ b ≤ c
constructor mp a:ℕb:ℕc:ℕ⊢ a + b ≤ a + c → b ≤ cmpr a:ℕb:ℕc:ℕ⊢ b ≤ c → a + b ≤ a + c <;> mp a:ℕb:ℕc:ℕ⊢ a + b ≤ a + c → b ≤ cmpr a:ℕb:ℕc:ℕ⊢ b ≤ c → a + b ≤ a + c intro h mpr a:ℕb:ℕc:ℕh:b ≤ c⊢ a + b ≤ a + c <;> mp a:ℕb:ℕc:ℕh:a + b ≤ a + c⊢ b ≤ cmpr a:ℕb:ℕc:ℕh:b ≤ c⊢ a + b ≤ a + c omega All goals completed! 🐙@[simp high] theorem nat_add_le_add_right (a b c : ℕ) : a + c ≤ b + c ↔ a ≤ b := by a:ℕb:ℕc:ℕ⊢ a + c ≤ b + c ↔ a ≤ b
constructor mp a:ℕb:ℕc:ℕ⊢ a + c ≤ b + c → a ≤ bmpr a:ℕb:ℕc:ℕ⊢ a ≤ b → a + c ≤ b + c <;> mp a:ℕb:ℕc:ℕ⊢ a + c ≤ b + c → a ≤ bmpr a:ℕb:ℕc:ℕ⊢ a ≤ b → a + c ≤ b + c intro h mpr a:ℕb:ℕc:ℕh:a ≤ b⊢ a + c ≤ b + c <;> mp a:ℕb:ℕc:ℕh:a + c ≤ b + c⊢ a ≤ bmpr a:ℕb:ℕc:ℕh:a ≤ b⊢ a + c ≤ b + c omega 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 (by a:ℕb:ℕh:0 < 0 + b⊢ 0 < b omega All goals completed! 🐙) | _ + 1 => Or.inl (by a:ℕb:ℕn✝:ℕh:0 < n✝ + 1 + b⊢ 0 < n✝ + 1 omega All goals completed! 🐙),
fun h => h.elim (fun _ => by a:ℕb:ℕh:0 < a ∨ 0 < bx✝:0 < a⊢ 0 < a + b omega All goals completed! 🐙) (fun _ => by a:ℕb:ℕh:0 < a ∨ 0 < bx✝:0 < b⊢ 0 < a + b omega All goals completed! 🐙)⟩@[simp high] theorem nat_add_eq_right {n m : ℕ} : n + m = n ↔ m = 0 := by n:ℕm:ℕ⊢ n + m = n ↔ m = 0
constructor mp n:ℕm:ℕ⊢ n + m = n → m = 0mpr n:ℕm:ℕ⊢ m = 0 → n + m = n <;> mp n:ℕm:ℕ⊢ n + m = n → m = 0mpr n:ℕm:ℕ⊢ m = 0 → n + m = n intro h mpr n:ℕm:ℕh:m = 0⊢ n + m = n <;> mp n:ℕm:ℕh:n + m = n⊢ m = 0mpr n:ℕm:ℕh:m = 0⊢ n + m = n omega 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 := by α:Type u_1x:List αn:ℕ⊢ List.take n x = x ↔ x.length ≤ n
induction x generalizing n with
| nil => nil α:Type u_1n:ℕ⊢ List.take n [] = [] ↔ [].length ≤ n simp All goals completed! 🐙
| cons _ _ ih => cons α: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 cases n cons.zero α: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 ≤ 0cons.succ α: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 <;> cons.zero α: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 ≤ 0cons.succ α: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 simp [ih] 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₂ := by Γ:Type u_1inst✝:Inhabited Γl₁:ListBlank Γl₂:ListBlank Γh:l₁.toList = l₂.toList⊢ l₁ = l₂
cases l₁ ofTrimmed Γ:Type u_1inst✝:Inhabited Γl₂:ListBlank ΓtoList✝:List ΓisTrimmed✝:IsTrimmed toList✝h:{ toList := toList✝, isTrimmed := isTrimmed✝ }.toList = l₂.toList⊢ { toList := toList✝, isTrimmed := isTrimmed✝ } = l₂; cases l₂ ofTrimmed.ofTrimmed Γ: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✝ }; cases h ofTrimmed.ofTrimmed.refl Γ:Type u_1inst✝:Inhabited ΓtoList✝:List ΓisTrimmed✝¹:IsTrimmed toList✝isTrimmed✝:IsTrimmed toList✝⊢ { toList := toList✝, isTrimmed := isTrimmed✝¹ } = { toList := toList✝, isTrimmed := isTrimmed✝ }; rfl All goals completed! 🐙@[simp]
theorem ListBlank.cons_default_default {Γ : Type*} [Inhabited Γ] [DecidableEq Γ] :
(default : ListBlank Γ).cons default = default := by Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γ⊢ cons default default = default
apply ListBlank.ext Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γ⊢ (cons default default).toList = default.toList
exact ite_eq_left rfl All goals completed! 🐙@[simp]
theorem ListBlank.head_cons {Γ : Type*} [Inhabited Γ] [DecidableEq Γ] (a : Γ)
(l : ListBlank Γ) : (l.cons a).head = a := by Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γl:ListBlank Γ⊢ (cons a l).head = a
rcases l with ⟨_ | ⟨b, xs⟩, _⟩ nil Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []⊢ (cons a { toList := [], isTrimmed := isTrimmed✝ }).head = acons Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γb:Γxs:List ΓisTrimmed✝:IsTrimmed (b :: xs)⊢ (cons a { toList := b :: xs, isTrimmed := isTrimmed✝ }).head = a
· nil Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []⊢ (cons a { toList := [], isTrimmed := isTrimmed✝ }).head = a change (if a = default then [] else [a]).headI = a nil Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []⊢ (if a = default then [] else [a]).headI = a
by_cases h : a = default pos Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []h:a = default⊢ (if a = default then [] else [a]).headI = aneg Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []h:¬a = default⊢ (if a = default then [] else [a]).headI = a
· pos Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []h:a = default⊢ (if a = default then [] else [a]).headI = a rw [ite_eq_left h pos Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []h:a = default⊢ [].headI = a] pos Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []h:a = default⊢ [].headI = a; exact h.symm All goals completed! 🐙
· neg Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []h:¬a = default⊢ (if a = default then [] else [a]).headI = a rw [ite_eq_right h neg Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []h:¬a = default⊢ [a].headI = a] neg Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []h:¬a = default⊢ [a].headI = a; rfl All goals completed! 🐙
· cons Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γb:Γxs:List ΓisTrimmed✝:IsTrimmed (b :: xs)⊢ (cons a { toList := b :: xs, isTrimmed := isTrimmed✝ }).head = a rfl All goals completed! 🐙@[simp]
theorem ListBlank.tail_cons {Γ : Type*} [Inhabited Γ] [DecidableEq Γ] (a : Γ)
(l : ListBlank Γ) : (l.cons a).tail = l := by Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γl:ListBlank Γ⊢ (cons a l).tail = l
apply ListBlank.ext Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γl:ListBlank Γ⊢ (cons a l).tail.toList = l.toList
rcases l with ⟨_ | ⟨b, xs⟩, _⟩ nil Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []⊢ (cons a { toList := [], isTrimmed := isTrimmed✝ }).tail.toList = { toList := [], isTrimmed := isTrimmed✝ }.toListcons Γ: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
· nil Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []⊢ (cons a { toList := [], isTrimmed := isTrimmed✝ }).tail.toList = { toList := [], isTrimmed := isTrimmed✝ }.toList change (if a = default then [] else [a]).tail = [] nil Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []⊢ (if a = default then [] else [a]).tail = []
by_cases h : a = default pos Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []h:a = default⊢ (if a = default then [] else [a]).tail = []neg Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []h:¬a = default⊢ (if a = default then [] else [a]).tail = []
· pos Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []h:a = default⊢ (if a = default then [] else [a]).tail = [] rw [ite_eq_left h pos Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []h:a = default⊢ [].tail = []] pos Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []h:a = default⊢ [].tail = []; rfl All goals completed! 🐙
· neg Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []h:¬a = default⊢ (if a = default then [] else [a]).tail = [] rw [ite_eq_right h neg Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []h:¬a = default⊢ [a].tail = []] neg Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:ΓisTrimmed✝:IsTrimmed []h:¬a = default⊢ [a].tail = []; rfl All goals completed! 🐙
· cons Γ: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 rfl All goals completed! 🐙@[simp]
theorem ListBlank.cons_head_tail {Γ : Type*} [Inhabited Γ] [DecidableEq Γ]
(l : ListBlank Γ) : l.tail.cons l.head = l := by Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl:ListBlank Γ⊢ cons l.head l.tail = l
apply ListBlank.ext Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl:ListBlank Γ⊢ (cons l.head l.tail).toList = l.toList
rcases l with ⟨_ | ⟨a, _ | ⟨b, xs⟩⟩, h⟩ nil Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γh:IsTrimmed []⊢ (cons { toList := [], isTrimmed := h }.head { toList := [], isTrimmed := h }.tail).toList =
{ toList := [], isTrimmed := h }.toListcons.nil Γ: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 }.toListcons.cons Γ: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
· nil Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γh:IsTrimmed []⊢ (cons { toList := [], isTrimmed := h }.head { toList := [], isTrimmed := h }.tail).toList =
{ toList := [], isTrimmed := h }.toList exact ite_eq_left rfl All goals completed! 🐙
· cons.nil Γ: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 exact ite_eq_right h All goals completed! 🐙
· cons.cons Γ: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 rfl 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 := by Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl:List Γ⊢ (mk l).head = l.headI
cases l with
| nil => nil Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γ⊢ (mk []).head = [].headI rfl All goals completed! 🐙
| cons a xs => cons Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γxs:List Γ⊢ (mk (a :: xs)).head = (a :: xs).headI exact ListBlank.head_cons a (ListBlank.mk xs) All goals completed! 🐙@[simp]
theorem ListBlank.tail_mk {Γ : Type*} [Inhabited Γ] [DecidableEq Γ] (l : List Γ) :
ListBlank.tail (ListBlank.mk l) = ListBlank.mk l.tail := by Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl:List Γ⊢ (mk l).tail = mk l.tail
cases l with
| nil => nil Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γ⊢ (mk []).tail = mk [].tail rfl All goals completed! 🐙
| cons a xs => cons Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γxs:List Γ⊢ (mk (a :: xs)).tail = mk (a :: xs).tail exact ListBlank.tail_cons a (ListBlank.mk xs) All goals completed! 🐙private theorem ListBlank.mk_list_aux {Γ : Type*} [Inhabited Γ] [DecidableEq Γ] :
∀ (xs : List Γ) (h : ListBlank.IsTrimmed xs), ListBlank.mk xs = ⟨xs, h⟩
| [], _ => rfl
| [a], h => Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γh:IsTrimmed [a]⊢ mk [a] = { toList := [a], isTrimmed := h } by Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γh:IsTrimmed [a]⊢ mk [a] = { toList := [a], isTrimmed := h }
apply ListBlank.ext Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γh:IsTrimmed [a]⊢ (mk [a]).toList = { toList := [a], isTrimmed := h }.toList
exact ite_eq_right h All goals completed! 🐙
| a :: b :: xs, 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 } by Γ: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 }
change ListBlank.cons a (ListBlank.mk (b :: xs)) = ⟨a :: b :: xs, 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 }
rw [ListBlank.mk_list_aux (b :: xs) 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 }] Γ: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 }
rfl 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 := by Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl:List Γ⊢ Turing.BlankExtends (mk l).toList l
induction l with
| nil => nil Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γ⊢ Turing.BlankExtends (mk []).toList [] exact ⟨0, rfl⟩ All goals completed! 🐙
| cons a xs ih => cons Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γxs:List Γih:Turing.BlankExtends (mk xs).toList xs⊢ Turing.BlankExtends (mk (a :: xs)).toList (a :: xs)
obtain ⟨i, hi⟩ := ih cons Γ: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)
change Turing.BlankExtends (ListBlank.trimCons a (ListBlank.mk xs).toList) (a :: xs) cons Γ: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)
rcases hmk : (ListBlank.mk xs).toList with _ | ⟨b, ys⟩ cons.nil Γ: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)cons.cons Γ: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)
· cons.nil Γ: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) rw [hmk, cons.nil Γ: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) List.nil_append cons.nil Γ: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)] at hi cons.nil Γ: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)
dsimp only [ListBlank.trimCons] cons.nil Γ: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)
by_cases ha : a = default pos Γ: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)neg Γ: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)
· pos Γ: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) refine ⟨i + 1, ?_⟩ pos Γ: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
rw [ite_eq_left ha, pos Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γxs:List Γi:ℕhi:xs = List.replicate i defaulthmk:(mk xs).toList = []ha:a = default⊢ a :: xs = [] ++ List.replicate (i + 1) default ha, pos Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γxs:List Γi:ℕhi:xs = List.replicate i defaulthmk:(mk xs).toList = []ha:a = default⊢ default :: xs = [] ++ List.replicate (i + 1) default hi, pos Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γxs:List Γi:ℕhi:xs = List.replicate i defaulthmk:(mk xs).toList = []ha:a = default⊢ default :: List.replicate i default = [] ++ List.replicate (i + 1) default List.nil_append, pos Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γxs:List Γi:ℕhi:xs = List.replicate i defaulthmk:(mk xs).toList = []ha:a = default⊢ default :: List.replicate i default = List.replicate (i + 1) default List.replicate_succ pos Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γxs:List Γi:ℕhi:xs = List.replicate i defaulthmk:(mk xs).toList = []ha:a = default⊢ default :: List.replicate i default = default :: List.replicate i default] All goals completed! 🐙
· neg Γ: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, by Γ: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 rw [ite_eq_right ha, Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γa:Γxs:List Γi:ℕhi:xs = List.replicate i defaulthmk:(mk xs).toList = []ha:¬a = default⊢ a :: xs = [a] ++ List.replicate i default hi Γ: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] Γ: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; rfl All goals completed! 🐙⟩
· cons.cons Γ: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) rw [hmk cons.cons Γ: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)] at hi cons.cons Γ: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, by Γ: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 rw [hi Γ: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] Γ: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; rfl 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₂) := by Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl₁:List Γl₂:List Γ⊢ append l₁ (mk l₂) = mk (l₁ ++ l₂)
induction l₁ nil Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl₂:List Γ⊢ append [] (mk l₂) = mk ([] ++ l₂)cons Γ: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₂) <;> nil Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl₂:List Γ⊢ append [] (mk l₂) = mk ([] ++ l₂)cons Γ: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₂)
simp only [*, ListBlank.append, List.nil_append, List.cons_append, ListBlank.cons_mk] 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₃) := by Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl₁:List Γl₂:List Γl₃:ListBlank Γ⊢ append (l₁ ++ l₂) l₃ = append l₁ (append l₂ l₃)
induction l₁ with
| nil => nil Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl₂:List Γl₃:ListBlank Γ⊢ append ([] ++ l₂) l₃ = append [] (append l₂ l₃) rfl All goals completed! 🐙
| cons a xs ih => cons Γ: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₃) exact congrArg (ListBlank.cons a) ih 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 := by Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl:List Γn:ℕ⊢ mk (l ++ List.replicate n default) = mk l
have hrep : ListBlank.mk (List.replicate n (default : Γ)) = default := by
induction n with
| zero => zero Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl:List Γ⊢ mk (List.replicate 0 default) = default rfl All goals completed! 🐙
| succ n ih => succ Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl:List Γn:ℕih:mk (List.replicate n default) = default⊢ mk (List.replicate (n + 1) default) = default
rw [List.replicate_succ, succ Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl:List Γn:ℕih:mk (List.replicate n default) = default⊢ mk (default :: List.replicate n default) = default ← ListBlank.cons_mk, succ Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl:List Γn:ℕih:mk (List.replicate n default) = default⊢ cons default (mk (List.replicate n default)) = default ih, succ Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl:List Γn:ℕih:mk (List.replicate n default) = default⊢ cons default default = default ListBlank.cons_default_default succ Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl:List Γn:ℕih:mk (List.replicate n default) = default⊢ default = default] Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl:List Γn:ℕhrep:mk (List.replicate n default) = default⊢ mk (l ++ List.replicate n default) = mk l
rw [← ListBlank.append_mk, Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl:List Γn:ℕhrep:mk (List.replicate n default) = default⊢ append l (mk (List.replicate n default)) = mk l hrep Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl:List Γn:ℕhrep:mk (List.replicate n default) = default⊢ append l default = mk l] Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γl:List Γn:ℕhrep:mk (List.replicate n default) = default⊢ append l default = mk l
rfl 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) := by Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq ΓL:ListBlank ΓR:ListBlank Γ⊢ move Dir.left (mk' L R) = mk' L.tail (ListBlank.cons L.head R)
simp only [Tape.move, Tape.mk', ListBlank.head_cons, ListBlank.cons_head_tail,
ListBlank.tail_cons] 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) := by Γ:Type u_1inst✝¹:Inhabited Γinst✝:DecidableEq Γb:ΓL:ListBlank ΓR:ListBlank Γ⊢ write b (mk' L R) = mk' L (ListBlank.cons b R.tail)
simp only [Tape.write, Tape.mk', ListBlank.head_cons, ListBlank.tail_cons] 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 => by α: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'
let ⟨h₁, h₂⟩ := Part.mem_assert_iff.1 h α: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'
rw [WellFounded.fixF_eq α: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'] at h₂ α: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'
obtain ⟨h₂, h₃⟩ := Part.mem_assert_iff.1 h₂ α: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'
split at h₃ h_1 α: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'h_2 α: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' cases Part.mem_some_iff.1 h₃ refl α: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'; exact Or.inl ⟨h₂, e⟩ 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' exact Or.inr ⟨_, ⟨_, e⟩, Part.mem_assert _ h₃⟩ All goals completed! 🐙,
fun h => by α: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
rcases h with (⟨h₁, h₂⟩ | ⟨a', ⟨h₁, h₂⟩, h₃⟩) inl α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βh₁:(f a).Domh₂:(f a).get h₁ = Sum.inl b⊢ b ∈ f.fix ainr α: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
· inl α:Type u_1β:Type u_2f:α →. β ⊕ αa:αb:βh₁:(f a).Domh₂:(f a).get h₁ = Sum.inl b⊢ b ∈ f.fix a refine Part.mem_assert ⟨a, fun y hy => ?_⟩ ?_ inl.refine_1 α: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) yinl.refine_2 α: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 ⋯
· inl.refine_1 α: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 cases (Part.mem_unique ⟨h₁, h₂⟩ hy) All goals completed! 🐙
· inl.refine_2 α: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 ⋯ rw [WellFounded.fixF_eq inl.refine_2 α: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' ⋯] inl.refine_2 α: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' ⋯
refine Part.mem_assert h₁ ?_ inl.refine_2 α: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' ⋯
split h_1 α: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✝h_2 α: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✝ injection h₂.symm.trans e with h' α: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✝; exact Part.mem_some_iff.2 h' 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'✝ ⋯ cases h₂.symm.trans e All goals completed! 🐙
· inr α: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 obtain ⟨hacc, h₄⟩ := Part.mem_assert_iff.1 h₃ inr α: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
refine Part.mem_assert ⟨a, fun y hy => ?_⟩ ?_ inr.refine_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' haccy:αhy:Sum.inr y ∈ f a⊢ Acc (fun x y ↦ Sum.inr x ∈ f y) yinr.refine_2 α: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 ⋯
· inr.refine_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' haccy:αhy:Sum.inr y ∈ f a⊢ Acc (fun x y ↦ Sum.inr x ∈ f y) y injection Part.mem_unique ⟨h₁, h₂⟩ hy with e inr.refine_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' haccy:αhy:Sum.inr y ∈ f ae:a' = y⊢ Acc (fun x y ↦ Sum.inr x ∈ f y) y
exact e ▸ hacc All goals completed! 🐙
· inr.refine_2 α: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 ⋯ rw [WellFounded.fixF_eq inr.refine_2 α: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 ⋯] inr.refine_2 α: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 ⋯
refine Part.mem_assert h₁ ?_ inr.refine_2 α: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 ⋯
split h_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✝h_2 α: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✝ cases h₂.symm.trans e 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'✝ ⋯ injection h₂.symm.trans e with h' α: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'✝ ⋯; subst h' α: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' ⋯; exact h₄ 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' := by α:Type u_1β:Type u_2f:α →. β ⊕ αb:βa:αa':αhb:b ∈ f.fix aha':Sum.inr a' ∈ f a⊢ b ∈ f.fix a'
rcases pfun_mem_fix_iff.1 hb with h' | ⟨_, h', e'⟩ inl α: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'inr α: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' <;> inl α: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'inr α: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' cases Part.mem_unique ha' h' inr.refl α: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'
exact e' 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 := by σ: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
let g : σ →. σ ⊕ σ := fun s => Part.some ((f s).elim (Sum.inl s) Sum.inr) σ: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
have hmem : b ∈ g.fix a := h σ: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
obtain ⟨hacc, h₂⟩ := Part.mem_assert_iff.1 hmem σ: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
clear h hmem σ: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
| intro x hx IH => intro σ: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
have hxmem : b ∈ g.fix x := Part.mem_assert ⟨x, hx⟩ h₂ intro σ: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
refine H x hxmem fun x' ex' => ?_ intro σ: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'
have hinr : Sum.inr x' ∈ g x := Part.mem_some_iff.2 (by σ: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'⊢ Sum.inr x' = (f x).elim (Sum.inl x) Sum.inr rw [ex' σ: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'⊢ Sum.inr x' = (some x').elim (Sum.inl x) Sum.inr] σ: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'⊢ Sum.inr x' = (some x').elim (Sum.inl x) Sum.inr; rfl All goals completed! 🐙) intro σ: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'
exact IH x' hinr (Part.mem_assert_iff.1 (pfun_fix_fwd hxmem hinr)).snd All goals completed! 🐙theorem mem_eval' {σ : Type*} {f : σ → Option σ} {a b : σ} :
b ∈ eval f a ↔ Reaches f a b ∧ f b = none := by σ:Type u_1f:σ → Option σa:σb:σ⊢ b ∈ eval f a ↔ Reaches f a b ∧ f b = none
refine ⟨fun h => ?_, fun ⟨h₁, h₂⟩ => ?_⟩ refine_1 σ:Type u_1f:σ → Option σa:σb:σh:b ∈ eval f a⊢ Reaches f a b ∧ f b = nonerefine_2 σ: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
· refine_1 σ:Type u_1f:σ → Option σa:σb:σh:b ∈ eval f a⊢ Reaches f a b ∧ f b = none refine evalInduction' h fun a h IH => ?_ refine_1 σ: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
rcases e : f a with _ | a' refine_1.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 = nonerefine_1.some σ: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
· refine_1.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 rw [Part.mem_unique h
(pfun_mem_fix_iff.2 <| Or.inl <| Part.mem_some_iff.2 <| by σ: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⊢ Sum.inl ?m.70 = (f a).elim (Sum.inl a) Sum.inr rw [e σ: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⊢ Sum.inl ?m.70 = none.elim (Sum.inl a) Sum.inr] σ: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⊢ Sum.inl ?m.70 = none.elim (Sum.inl a) Sum.inr; rfl All goals completed! 🐙)] refine_1.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
exact ⟨Relation.ReflTransGen.refl, e⟩ All goals completed! 🐙
· refine_1.some σ: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 rcases pfun_mem_fix_iff.1 h with (h | ⟨_, h, _⟩) refine_1.some.inl σ: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 = nonerefine_1.some.inr σ: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 <;> refine_1.some.inl σ: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 = nonerefine_1.some.inr σ: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 rw [e refine_1.some.inl σ: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] refine_1.some.inl σ: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 at h refine_1.some.inr σ: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 <;> refine_1.some.inl σ: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 = nonerefine_1.some.inr σ: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
cases Part.mem_some_iff.1 h refine_1.some.inr.refl σ: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
obtain ⟨h₁, h₂⟩ := IH a' e refine_1.some.inr.refl σ: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
exact ⟨Relation.ReflTransGen.head e h₁, h₂⟩ All goals completed! 🐙
· refine_2 σ: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 refine Relation.ReflTransGen.head_induction_on h₁ ?_ fun h _ IH => ?_ refine_2.refine_1 σ:Type u_1f:σ → Option σa:σb:σx✝:Reaches f a b ∧ f b = noneh₁:Reaches f a bh₂:f b = none⊢ b ∈ eval f brefine_2.refine_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✝⊢ b ∈ eval f a✝
· refine_2.refine_1 σ: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 (by σ: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 rw [h₂ σ: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] σ: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; rfl All goals completed! 🐙)))
· refine_2.refine_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✝⊢ b ∈ eval f a✝ exact pfun_mem_fix_iff.2 (Or.inr ⟨_, Part.mem_some_iff.2 (by σ: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 rw [h σ: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] σ: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; rfl 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 := by α: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
| refl => refl α:Type u_1r:α → α → Propa:αb:α⊢ a = a ∨ ∃ c, r a c ∧ Relation.ReflTransGen r c a exact Or.inl rfl All goals completed! 🐙
| @tail x y _ hxy ih => tail α: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
rcases ih with rfl | ⟨c, hac, hcx⟩ tail.inl α: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 ytail.inr α: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
· tail.inl α: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 exact Or.inr ⟨y, hxy, Relation.ReflTransGen.refl⟩ All goals completed! 🐙
· tail.inr α: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 exact Or.inr ⟨c, hac, Relation.ReflTransGen.tail hcx hxy⟩ 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 := by σ: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
| refl => refl σ:Type u_1f:σ → Option σa:σb:σc:σhac:Reaches f b c⊢ Reaches f b c ∨ Reaches f c b exact Or.inl hac All goals completed! 🐙
| @head x x₁ hx₁ hxb ih => head σ: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
rcases rtg_cases_head hac with rfl | ⟨c₁, hc₁, hc₁c⟩ head.inl σ: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 bhead.inr σ: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
· head.inl σ: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 exact Or.inr (Relation.ReflTransGen.head hx₁ hxb) All goals completed! 🐙
· head.inr σ: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 cases Option.mem_unique hx₁ hc₁ head.inr.refl σ: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
exact ih hc₁c All goals completed! 🐙theorem reaches_of_none {σ : Type*} {f : σ → Option σ} {b c : σ}
(hb : f b = none) (hbc : Reaches f b c) : b = c := by σ:Type u_1f:σ → Option σb:σc:σhb:f b = nonehbc:Reaches f b c⊢ b = c
rcases rtg_cases_head hbc with rfl | ⟨d, hbd, _⟩ inl σ:Type u_1f:σ → Option σb:σhb:f b = nonehbc:Reaches f b b⊢ b = binr σ: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
· inl σ:Type u_1f:σ → Option σb:σhb:f b = nonehbc:Reaches f b b⊢ b = b rfl All goals completed! 🐙
· inr σ: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 cases hb.symm.trans hbd 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 := by σ:Type u_1f:σ → Option σa:σb:σab:Reaches f a b⊢ eval f a = eval f b
refine Part.ext fun c => ⟨fun h => ?_, fun h => ?_⟩ refine_1 σ:Type u_1f:σ → Option σa:σb:σab:Reaches f a bc:σh:c ∈ eval f a⊢ c ∈ eval f brefine_2 σ:Type u_1f:σ → Option σa:σb:σab:Reaches f a bc:σh:c ∈ eval f b⊢ c ∈ eval f a
· refine_1 σ:Type u_1f:σ → Option σa:σb:σab:Reaches f a bc:σh:c ∈ eval f a⊢ c ∈ eval f b obtain ⟨ac, c0⟩ := mem_eval'.1 h refine_1 σ: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
refine mem_eval'.2 ⟨?_, c0⟩ refine_1 σ: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
rcases reaches_total_det ab ac with bc | cb refine_1.inl σ: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 crefine_1.inr σ: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
· refine_1.inl σ: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 exact bc All goals completed! 🐙
· refine_1.inr σ: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 exact reaches_of_none c0 cb ▸ Relation.ReflTransGen.refl All goals completed! 🐙
· refine_2 σ:Type u_1f:σ → Option σa:σb:σab:Reaches f a bc:σh:c ∈ eval f b⊢ c ∈ eval f a obtain ⟨bc, c0⟩ := mem_eval'.1 h refine_2 σ: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
exact mem_eval'.2 ⟨ab.trans bc, c0⟩ 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₂ := by σ₁: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
| refl => refl σ₁: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₂ exact ⟨a₂, aa, Relation.ReflTransGen.refl⟩ All goals completed! 🐙
| @tail c₁ d₁ _ cd IH => tail σ₁: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₂
obtain ⟨c₂, cc, ac₂⟩ := IH tail σ₁: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₂
have := H cc tail σ₁: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₂
rw [show f₁ c₁ = _ from cd tail σ₁: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₂] at this tail σ₁: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₂
obtain ⟨d₂, dd, cd₂⟩ := this tail σ₁: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₂
exact ⟨d₂, dd, ac₂.trans cd₂.to_reflTransGen⟩ 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₁ := by σ₁: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
| refl => refl σ₁: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₁ exact ⟨a₁, a₂, Relation.ReflTransGen.refl, aa, Relation.ReflTransGen.refl⟩ All goals completed! 🐙
| @tail c₂ d₂ _ cd IH => tail σ₁: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₁
obtain ⟨e₁, e₂, ce, ee, ae⟩ := IH tail σ₁: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₁
rcases rtg_cases_head ce with rfl | ⟨d', cd', de⟩ tail.inl σ₁: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₁tail.inr σ₁: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₁
· tail.inl σ₁: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₁ have := H ee tail.inl σ₁: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₁
rcases eg : f₁ e₁ with _ | g₁ tail.inl.none σ₁: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₁tail.inl.some σ₁: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₁
· tail.inl.none σ₁: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₁ rw [eg tail.inl.none σ₁: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₁] at this tail.inl.none σ₁: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₁
cases cd.symm.trans this All goals completed! 🐙
· tail.inl.some σ₁: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₁ rw [eg tail.inl.some σ₁: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₁] at this tail.inl.some σ₁: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₁
obtain ⟨g₂, gg, cg⟩ := this tail.inl.some σ₁: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₁
obtain ⟨d', cd', dg⟩ := Relation.TransGen.head'_iff.1 cg tail.inl.some σ₁: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₁
cases Option.mem_unique cd cd' tail.inl.some.refl σ₁: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₁
exact ⟨g₁, g₂, dg, gg, ae.tail eg⟩ All goals completed! 🐙
· tail.inr σ₁: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₁ cases Option.mem_unique cd cd' tail.inr.refl σ₁: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₁
exact ⟨e₁, e₂, de, ee, ae⟩ 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₂ := by σ₁: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₂
obtain ⟨ab, b0⟩ := mem_eval'.1 ab σ₁: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₂
obtain ⟨b₂, bb, ab⟩ := tr_reaches' H aa ab σ₁: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₂
refine ⟨b₂, bb, mem_eval'.2 ⟨ab, ?_⟩⟩ σ₁: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
have := H bb σ₁: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; rwa [b0] at this 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₁ := by σ₁: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₁
obtain ⟨ab, b0⟩ := mem_eval'.1 ab σ₁: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₁
obtain ⟨c₁, c₂, bc, cc, ac⟩ := tr_reaches_rev' H aa ab σ₁: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₁
cases reaches_of_none b0 bc refl σ₁: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₁
refine ⟨c₁, cc, mem_eval'.2 ⟨ac, ?_⟩⟩ refl σ₁: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
have := H cc refl σ₁: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
rcases hfc : f₁ c₁ with _ | d₁ refl.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 = nonerefl.some σ₁: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
· refl.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 rfl All goals completed! 🐙
rw [hfc refl.some σ₁: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] at this refl.some σ₁: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
obtain ⟨_, _, bd⟩ := this refl.some σ₁: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
obtain ⟨_, h, _⟩ := Relation.TransGen.head'_iff.1 bd refl.some σ₁: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
cases b0.symm.trans h 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