l3lab/ntp-mathlib huggingface dataset:
theorem head_succ' (n m : ℕ) (x : ∀ n, CofixA F n) (Hconsistent : AllAgree x) :
    head' (x (succ n)) = head' (x (succ m)) := by
  suffices ∀ n, head' (x (succ n)) = head' (x 1) by simp [this]
  clear m n
  intro n
  cases' h₀ : x (succ n) with _ i₀ f₀
  cases' h₁ : x 1 with _ i₁ f₁
  dsimp only [head']
  induction' n with n n_ih
  · rw [h₁] at h₀
    cases h₀
    trivial
  · have H := Hconsistent (succ n)
    cases' h₂ : x (succ n) with _ i₂ f₂
    rw [h₀, h₂] at H
    apply n_ih (truncate ∘ f₀)
    rw [h₂]
    cases' H with _ _ _ _ _ _ hagree
    

Proof state:
case intro.intro.succ.intro.intro
F : PFunctor.{u}
X : Type w
f : X → ↑F X
x : (n : ℕ) → CofixA F n
Hconsistent : AllAgree x
i₀ i₁ : F.A
f₁ : B F i₁ → CofixA F 0
h₁ : x 1 = CofixA.intro i₁ f₁
n : ℕ
n_ih : ∀ (f₀ : B F i₀ → CofixA F n), x (succ n) = CofixA.intro i₀ f₀ → i₀ = i₁
f₀ : B F i₀ → CofixA F (succ n)
h₀ : x (succ (succ n)) = CofixA.intro i₀ f₀
f₂ : B F i₀ → CofixA F n
h₂ : x (succ n) = CofixA.intro i₀ f₂
hagree : ∀ (i : B F i₀), Agree (f₂ i) (f₀ i)
⊢ CofixA.intro i₀ f₂ = CofixA.intro i₀ (truncate ∘ f₀)

Next tactic:
congr
theorem head_succ' (n m : ℕ) (x : ∀ n, CofixA F n) (Hconsistent : AllAgree x) :
    head' (x (succ n)) = head' (x (succ m)) := by
  suffices ∀ n, head' (x (succ n)) = head' (x 1) by simp [this]
  clear m n
  intro n
  cases' h₀ : x (succ n) with _ i₀ f₀
  cases' h₁ : x 1 with _ i₁ f₁
  dsimp only [head']
  induction' n with n n_ih
  · rw [h₁] at h₀
    cases h₀
    trivial
  · have H := Hconsistent (succ n)
    cases' h₂ : x (succ n) with _ i₂ f₂
    rw [h₀, h₂] at H
    apply n_ih (truncate ∘ f₀)
    rw [h₂]
    cases' H with _ _ _ _ _ _ hagree
    congr
    

Proof state:
case intro.intro.succ.intro.intro.e_a
F : PFunctor.{u}
X : Type w
f : X → ↑F X
x : (n : ℕ) → CofixA F n
Hconsistent : AllAgree x
i₀ i₁ : F.A
f₁ : B F i₁ → CofixA F 0
h₁ : x 1 = CofixA.intro i₁ f₁
n : ℕ
n_ih : ∀ (f₀ : B F i₀ → CofixA F n), x (succ n) = CofixA.intro i₀ f₀ → i₀ = i₁
f₀ : B F i₀ → CofixA F (succ n)
h₀ : x (succ (succ n)) = CofixA.intro i₀ f₀
f₂ : B F i₀ → CofixA F n
h₂ : x (succ n) = CofixA.intro i₀ f₂
hagree : ∀ (i : B F i₀), Agree (f₂ i) (f₀ i)
⊢ f₂ = truncate ∘ f₀

Next tactic:
funext j
theorem head_succ' (n m : ℕ) (x : ∀ n, CofixA F n) (Hconsistent : AllAgree x) :
    head' (x (succ n)) = head' (x (succ m)) := by
  suffices ∀ n, head' (x (succ n)) = head' (x 1) by simp [this]
  clear m n
  intro n
  cases' h₀ : x (succ n) with _ i₀ f₀
  cases' h₁ : x 1 with _ i₁ f₁
  dsimp only [head']
  induction' n with n n_ih
  · rw [h₁] at h₀
    cases h₀
    trivial
  · have H := Hconsistent (succ n)
    cases' h₂ : x (succ n) with _ i₂ f₂
    rw [h₀, h₂] at H
    apply n_ih (truncate ∘ f₀)
    rw [h₂]
    cases' H with _ _ _ _ _ _ hagree
    congr
    funext j
    

Proof state:
case intro.intro.succ.intro.intro.e_a.h
F : PFunctor.{u}
X : Type w
f : X → ↑F X
x : (n : ℕ) → CofixA F n
Hconsistent : AllAgree x
i₀ i₁ : F.A
f₁ : B F i₁ → CofixA F 0
h₁ : x 1 = CofixA.intro i₁ f₁
n : ℕ
n_ih : ∀ (f₀ : B F i₀ → CofixA F n), x (succ n) = CofixA.intro i₀ f₀ → i₀ = i₁
f₀ : B F i₀ → CofixA F (succ n)
h₀ : x (succ (succ n)) = CofixA.intro i₀ f₀
f₂ : B F i₀ → CofixA F n
h₂ : x (succ n) = CofixA.intro i₀ f₂
hagree : ∀ (i : B F i₀), Agree (f₂ i) (f₀ i)
j : B F i₀
⊢ f₂ j = (truncate ∘ f₀) j

Next tactic:
dsimp only [comp_apply]
theorem head_succ' (n m : ℕ) (x : ∀ n, CofixA F n) (Hconsistent : AllAgree x) :
    head' (x (succ n)) = head' (x (succ m)) := by
  suffices ∀ n, head' (x (succ n)) = head' (x 1) by simp [this]
  clear m n
  intro n
  cases' h₀ : x (succ n) with _ i₀ f₀
  cases' h₁ : x 1 with _ i₁ f₁
  dsimp only [head']
  induction' n with n n_ih
  · rw [h₁] at h₀
    cases h₀
    trivial
  · have H := Hconsistent (succ n)
    cases' h₂ : x (succ n) with _ i₂ f₂
    rw [h₀, h₂] at H
    apply n_ih (truncate ∘ f₀)
    rw [h₂]
    cases' H with _ _ _ _ _ _ hagree
    congr
    funext j
    dsimp only [comp_apply]
    

Proof state:
case intro.intro.succ.intro.intro.e_a.h
F : PFunctor.{u}
X : Type w
f : X → ↑F X
x : (n : ℕ) → CofixA F n
Hconsistent : AllAgree x
i₀ i₁ : F.A
f₁ : B F i₁ → CofixA F 0
h₁ : x 1 = CofixA.intro i₁ f₁
n : ℕ
n_ih : ∀ (f₀ : B F i₀ → CofixA F n), x (succ n) = CofixA.intro i₀ f₀ → i₀ = i₁
f₀ : B F i₀ → CofixA F (succ n)
h₀ : x (succ (succ n)) = CofixA.intro i₀ f₀
f₂ : B F i₀ → CofixA F n
h₂ : x (succ n) = CofixA.intro i₀ f₂
hagree : ∀ (i : B F i₀), Agree (f₂ i) (f₀ i)
j : B F i₀
⊢ f₂ j = truncate (f₀ j)

Next tactic:
rw [truncate_eq_of_agree]
theorem head_succ' (n m : ℕ) (x : ∀ n, CofixA F n) (Hconsistent : AllAgree x) :
    head' (x (succ n)) = head' (x (succ m)) := by
  suffices ∀ n, head' (x (succ n)) = head' (x 1) by simp [this]
  clear m n
  intro n
  cases' h₀ : x (succ n) with _ i₀ f₀
  cases' h₁ : x 1 with _ i₁ f₁
  dsimp only [head']
  induction' n with n n_ih
  · rw [h₁] at h₀
    cases h₀
    trivial
  · have H := Hconsistent (succ n)
    cases' h₂ : x (succ n) with _ i₂ f₂
    rw [h₀, h₂] at H
    apply n_ih (truncate ∘ f₀)
    rw [h₂]
    cases' H with _ _ _ _ _ _ hagree
    congr
    funext j
    dsimp only [comp_apply]
    rw [truncate_eq_of_agree]
    

Proof state:
case intro.intro.succ.intro.intro.e_a.h.h
F : PFunctor.{u}
X : Type w
f : X → ↑F X
x : (n : ℕ) → CofixA F n
Hconsistent : AllAgree x
i₀ i₁ : F.A
f₁ : B F i₁ → CofixA F 0
h₁ : x 1 = CofixA.intro i₁ f₁
n : ℕ
n_ih : ∀ (f₀ : B F i₀ → CofixA F n), x (succ n) = CofixA.intro i₀ f₀ → i₀ = i₁
f₀ : B F i₀ → CofixA F (succ n)
h₀ : x (succ (succ n)) = CofixA.intro i₀ f₀
f₂ : B F i₀ → CofixA F n
h₂ : x (succ n) = CofixA.intro i₀ f₂
hagree : ∀ (i : B F i₀), Agree (f₂ i) (f₀ i)
j : B F i₀
⊢ Agree (f₂ j) (f₀ j)

Next tactic:
apply hagree
instance MIntl.inhabited [Inhabited F.A] : Inhabited (MIntl F) :=
  show Inhabited (M F) by 

Proof state:
F : PFunctor.{u}
inst✝ : Inhabited F.A
⊢ Inhabited (M F)

Next tactic:
infer_instance
theorem ext' (x y : M F) (H : ∀ i : ℕ, x.approx i = y.approx i) : x = y := by
  

Proof state:
F : PFunctor.{u}
x y : M F
H : ∀ (i : ℕ), MIntl.approx x i = MIntl.approx y i
⊢ x = y

Next tactic:
cases x
theorem ext' (x y : M F) (H : ∀ i : ℕ, x.approx i = y.approx i) : x = y := by
  cases x
  

Proof state:
case mk
F : PFunctor.{u}
y : M F
approx✝ : (n : ℕ) → CofixA F n
consistent✝ : AllAgree approx✝
H : ∀ (i : ℕ), MIntl.approx { approx := approx✝, consistent := consistent✝ } i = MIntl.approx y i
⊢ { approx := approx✝, consistent := consistent✝ } = y

Next tactic:
cases y
theorem ext' (x y : M F) (H : ∀ i : ℕ, x.approx i = y.approx i) : x = y := by
  cases x
  cases y
  

Proof state:
case mk.mk
F : PFunctor.{u}
approx✝¹ : (n : ℕ) → CofixA F n
consistent✝¹ : AllAgree approx✝¹
approx✝ : (n : ℕ) → CofixA F n
consistent✝ : AllAgree approx✝
H :
  ∀ (i : ℕ),
    MIntl.approx { approx := approx✝¹, consistent := consistent✝¹ } i =
      MIntl.approx { approx := approx✝, consistent := consistent✝ } i
⊢ { approx := approx✝¹, consistent := consistent✝¹ } = { approx := approx✝, consistent := consistent✝ }

Next tactic:
congr with n
theorem ext' (x y : M F) (H : ∀ i : ℕ, x.approx i = y.approx i) : x = y := by
  cases x
  cases y
  congr with n
  

Proof state:
case mk.mk.e_approx.h
F : PFunctor.{u}
approx✝¹ : (n : ℕ) → CofixA F n
consistent✝¹ : AllAgree approx✝¹
approx✝ : (n : ℕ) → CofixA F n
consistent✝ : AllAgree approx✝
H :
  ∀ (i : ℕ),
    MIntl.approx { approx := approx✝¹, consistent := consistent✝¹ } i =
      MIntl.approx { approx := approx✝, consistent := consistent✝ } i
n : ℕ
⊢ approx✝¹ n = approx✝ n

Next tactic:
apply H
/-- return all the subtrees of the root of a tree `x : M F` -/
def children (x : M F) (i : F.B (head x)) : M F :=
  let H := fun n : ℕ => @head_succ' _ n 0 x.1 x.2
  { approx := fun n => children' (x.1 _) (cast (congr_arg _ <| by 

Proof state:
F : PFunctor.{u}
X : Type u_1
f : X → ↑F X
x : M F
i : B F (head x)
H : ∀ (n : ℕ), head' (MIntl.approx x (succ n)) = head' (MIntl.approx x (succ 0)) :=
  fun n => head_succ' n 0 x.approx x.consistent
n : ℕ
⊢ head x = head' (MIntl.approx x (succ n))

Next tactic:
simp only [head, H]
/-- return all the subtrees of the root of a tree `x : M F` -/
def children (x : M F) (i : F.B (head x)) : M F :=
  let H := fun n : ℕ => @head_succ' _ n 0 x.1 x.2
  { approx := fun n => children' (x.1 _) (cast (congr_arg _ <| by simp only [head, H]) i)
    consistent := by
      

Proof state:
F : PFunctor.{u}
X : Type u_1
f : X → ↑F X
x : M F
i : B F (head x)
H : ∀ (n : ℕ), head' (MIntl.approx x (succ n)) = head' (MIntl.approx x (succ 0)) :=
  fun n => head_succ' n 0 x.approx x.consistent
⊢ AllAgree fun n =>
    children' (MIntl.approx x (succ n)) (cast (_ : B F (head x) = B F (head' (MIntl.approx x (succ n)))) i)

Next tactic:
intro n
/-- return all the subtrees of the root of a tree `x : M F` -/
def children (x : M F) (i : F.B (head x)) : M F :=
  let H := fun n : ℕ => @head_succ' _ n 0 x.1 x.2
  { approx := fun n => children' (x.1 _) (cast (congr_arg _ <| by simp only [head, H]) i)
    consistent := by
      intro n
      

Proof state:
F : PFunctor.{u}
X : Type u_1
f : X → ↑F X
x : M F
i : B F (head x)
H : ∀ (n : ℕ), head' (MIntl.approx x (succ n)) = head' (MIntl.approx x (succ 0)) :=
  fun n => head_succ' n 0 x.approx x.consistent
n : ℕ
⊢ Agree
    ((fun n => children' (MIntl.approx x (succ n)) (cast (_ : B F (head x) = B F (head' (MIntl.approx x (succ n)))) i))
      n)
    ((fun n => children' (MIntl.approx x (succ n)) (cast (_ : B F (head x) = B F (head' (MIntl.approx x (succ n)))) i))
      (succ n))

Next tactic:
have P' := x.2 (succ n)
/-- return all the subtrees of the root of a tree `x : M F` -/
def children (x : M F) (i : F.B (head x)) : M F :=
  let H := fun n : ℕ => @head_succ' _ n 0 x.1 x.2
  { approx := fun n => children' (x.1 _) (cast (congr_arg _ <| by simp only [head, H]) i)
    consistent := by
      intro n
      have P' := x.2 (succ n)
      

Proof state:
F : PFunctor.{u}
X : Type u_1
f : X → ↑F X
x : M F
i : B F (head x)
H : ∀ (n : ℕ), head' (MIntl.approx x (succ n)) = head' (MIntl.approx x (succ 0)) :=
  fun n => head_succ' n 0 x.approx x.consistent
n : ℕ
P' : Agree (MIntl.approx x (succ n)) (MIntl.approx x (succ (succ n)))
⊢ Agree
    ((fun n => children' (MIntl.approx x (succ n)) (cast (_ : B F (head x) = B F (head' (MIntl.approx x (succ n)))) i))
      n)
    ((fun n => children' (MIntl.approx x (succ n)) (cast (_ : B F (head x) = B F (head' (MIntl.approx x (succ n)))) i))
      (succ n))

Next tactic:
apply agree_children _ _ _ P'
/-- return all the subtrees of the root of a tree `x : M F` -/
def children (x : M F) (i : F.B (head x)) : M F :=
  let H := fun n : ℕ => @head_succ' _ n 0 x.1 x.2
  { approx := fun n => children' (x.1 _) (cast (congr_arg _ <| by simp only [head, H]) i)
    consistent := by
      intro n
      have P' := x.2 (succ n)
      apply agree_children _ _ _ P'
      

Proof state:
F : PFunctor.{u}
X : Type u_1
f : X → ↑F X
x : M F
i : B F (head x)
H : ∀ (n : ℕ), head' (MIntl.approx x (succ n)) = head' (MIntl.approx x (succ 0)) :=
  fun n => head_succ' n 0 x.approx x.consistent
n : ℕ
P' : Agree (MIntl.approx x (succ n)) (MIntl.approx x (succ (succ n)))
⊢ HEq (cast (_ : B F (head x) = B F (head' (MIntl.approx x (succ n)))) i)
    (cast (_ : B F (head x) = B F (head' (MIntl.approx x (succ (succ n))))) i)

Next tactic:
trans i
/-- return all the subtrees of the root of a tree `x : M F` -/
def children (x : M F) (i : F.B (head x)) : M F :=
  let H := fun n : ℕ => @head_succ' _ n 0 x.1 x.2
  { approx := fun n => children' (x.1 _) (cast (congr_arg _ <| by simp only [head, H]) i)
    consistent := by
      intro n
      have P' := x.2 (succ n)
      apply agree_children _ _ _ P'
      trans i
      

Proof state:
F : PFunctor.{u}
X : Type u_1
f : X → ↑F X
x : M F
i : B F (head x)
H : ∀ (n : ℕ), head' (MIntl.approx x (succ n)) = head' (MIntl.approx x (succ 0)) :=
  fun n => head_succ' n 0 x.approx x.consistent
n : ℕ
P' : Agree (MIntl.approx x (succ n)) (MIntl.approx x (succ (succ n)))
⊢ HEq (cast (_ : B F (head x) = B F (head' (MIntl.approx x (succ n)))) i) i
F : PFunctor.{u}
X : Type u_1
f : X → ↑F X
x : M F
i : B F (head x)
H : ∀ (n : ℕ), head' (MIntl.approx x (succ n)) = head' (MIntl.approx x (succ 0)) :=
  fun n => head_succ' n 0 x.approx x.consistent
n : ℕ
P' : Agree (MIntl.approx x (succ n)) (MIntl.approx x (succ (succ n)))
⊢ HEq i (cast (_ : B F (head x) = B F (head' (MIntl.approx x (succ (succ n))))) i)

Next tactic:
apply cast_heq
/-- return all the subtrees of the root of a tree `x : M F` -/
def children (x : M F) (i : F.B (head x)) : M F :=
  let H := fun n : ℕ => @head_succ' _ n 0 x.1 x.2
  { approx := fun n => children' (x.1 _) (cast (congr_arg _ <| by simp only [head, H]) i)
    consistent := by
      intro n
      have P' := x.2 (succ n)
      apply agree_children _ _ _ P'
      trans i
      apply cast_heq
      

Proof state:
F : PFunctor.{u}
X : Type u_1
f : X → ↑F X
x : M F
i : B F (head x)
H : ∀ (n : ℕ), head' (MIntl.approx x (succ n)) = head' (MIntl.approx x (succ 0)) :=
  fun n => head_succ' n 0 x.approx x.consistent
n : ℕ
P' : Agree (MIntl.approx x (succ n)) (MIntl.approx x (succ (succ n)))
⊢ HEq i (cast (_ : B F (head x) = B F (head' (MIntl.approx x (succ (succ n))))) i)

Next tactic:
symm
/-- return all the subtrees of the root of a tree `x : M F` -/
def children (x : M F) (i : F.B (head x)) : M F :=
  let H := fun n : ℕ => @head_succ' _ n 0 x.1 x.2
  { approx := fun n => children' (x.1 _) (cast (congr_arg _ <| by simp only [head, H]) i)
    consistent := by
      intro n
      have P' := x.2 (succ n)
      apply agree_children _ _ _ P'
      trans i
      apply cast_heq
      symm
      

Proof state:
F : PFunctor.{u}
X : Type u_1
f : X → ↑F X
x : M F
i : B F (head x)
H : ∀ (n : ℕ), head' (MIntl.approx x (succ n)) = head' (MIntl.approx x (succ 0)) :=
  fun n => head_succ' n 0 x.approx x.consistent
n : ℕ
P' : Agree (MIntl.approx x (succ n)) (MIntl.approx x (succ (succ n)))
⊢ HEq (cast (_ : B F (head x) = B F (head' (MIntl.approx x (succ (succ n))))) i) i

Next tactic:
apply cast_heq
/-- select a subtree using an `i : F.Idx` or return an arbitrary tree if
`i` designates no subtree of `x` -/
def ichildren [Inhabited (M F)] [DecidableEq F.A] (i : F.Idx) (x : M F) : M F :=
  if H' : i.1 = head x then children x (cast (congr_arg _ <| by 

Proof state:
F : PFunctor.{u}
X : Type u_1
f : X → ↑F X
inst✝¹ : Inhabited (M F)
inst✝ : DecidableEq F.A
i : Idx F
x : M F
H' : i.fst = head x
⊢ i.fst = head x

Next tactic:
simp only [head, H']
protected theorem P_mk (x : F (M F)) : AllAgree (Approx.sMk x)
  | 0 => by 

Proof state:
F : PFunctor.{u}
X : Type u_1
f : X → ↑F X
x : ↑F (M F)
⊢ Agree (Approx.sMk x 0) (Approx.sMk x (succ 0))

Next tactic:
constructor
protected theorem P_mk (x : F (M F)) : AllAgree (Approx.sMk x)
  | 0 => by constructor
  | succ n => by
    

Proof state:
F : PFunctor.{u}
X : Type u_1
f : X → ↑F X
x : ↑F (M F)
n : ℕ
⊢ Agree (Approx.sMk x (succ n)) (Approx.sMk x (succ (succ n)))

Next tactic:
constructor
protected theorem P_mk (x : F (M F)) : AllAgree (Approx.sMk x)
  | 0 => by constructor
  | succ n => by
    constructor
    

Proof state:
case a
F : PFunctor.{u}
X : Type u_1
f : X → ↑F X
x : ↑F (M F)
n : ℕ
⊢ ∀ (i : B F x.fst), Agree (MIntl.approx (Sigma.snd x i) n) (MIntl.approx (Sigma.snd x i) (succ n))

Next tactic:
introv
protected theorem P_mk (x : F (M F)) : AllAgree (Approx.sMk x)
  | 0 => by constructor
  | succ n => by
    constructor
    introv
    

Proof state:
case a
F : PFunctor.{u}
X : Type u_1
f : X → ↑F X
x : ↑F (M F)
n : ℕ
i : B F x.fst
⊢ Agree (MIntl.approx (Sigma.snd x i) n) (MIntl.approx (Sigma.snd x i) (succ n))

Next tactic:
apply (x.2 i).consistent
@[simp]
theorem mk_dest (x : M F) : M.mk (dest x) = x := by
  

Proof state:
F : PFunctor.{u}
X : Type u_1
f : X → ↑F X
x : M F
⊢ M.mk (dest x) = x

Next tactic:
apply ext'
@[simp]
theorem mk_dest (x : M F) : M.mk (dest x) = x := by
  apply ext'
  

Proof state:
case H
F : PFunctor.{u}
X : Type u_1
f : X → ↑F X
x : M F
⊢ ∀ (i : ℕ), MIntl.approx (M.mk (dest x)) i = MIntl.approx x i

Next tactic:
intro n
@[simp]
theorem mk_dest (x : M F) : M.mk (dest x) = x := by
  apply ext'
  intro n
  

Proof state:
case H
F : PFunctor.{u}
X : Type u_1
f : X → ↑F X
x : M F
n : ℕ
⊢ MIntl.approx (M.mk (dest x)) n = MIntl.approx x n

Next tactic:
dsimp only [M.mk]
@[simp]
theorem mk_dest (x : M F) : M.mk (dest x) = x := by
  apply ext'
  intro n
  dsimp only [M.mk]
  

Proof state:
case H
F : PFunctor.{u}
X : Type u_1
f : X → ↑F X
x : M F
n : ℕ
⊢ Approx.sMk (dest x) n = MIntl.approx x n

Next tactic:
induction' n with n
@[simp]
theorem mk_dest (x : M F) : M.mk (dest x) = x := by
  apply ext'
  intro n
  dsimp only [M.mk]
  induction' n with n
  · 

Proof state:
case H.zero
F : PFunctor.{u}
X : Type u_1
f : X → ↑F X
x : M F
⊢ Approx.sMk (dest x) zero = MIntl.approx x zero

Next tactic:
apply @Subsingleton.elim _ CofixA.instSubsingleton
@[simp]
theorem mk_dest (x : M F) : M.mk (dest x) = x := by
  apply ext'
  intro n
  dsimp only [M.mk]
  induction' n with n
  · apply @Subsingleton.elim _ CofixA.instSubsingleton
  

Proof state:
case H.succ
F : PFunctor.{u}
X : Type u_1
f : X → ↑F X
x : M F
n : ℕ
n_ih✝ : Approx.sMk (dest x) n = MIntl.approx x n
⊢ Approx.sMk (dest x) (succ n) = MIntl.approx x (succ n)

Next tactic:
dsimp only [Approx.sMk, dest, head]
@[simp]
theorem mk_dest (x : M F) : M.mk (dest x) = x := by
  apply ext'
  intro n
  dsimp only [M.mk]
  induction' n with n
  · apply @Subsingleton.elim _ CofixA.instSubsingleton
  dsimp only [Approx.sMk, dest, head]
  

Proof state:
case H.succ
F : PFunctor.{u}
X : Type u_1
f : X → ↑F X
x : M F
n : ℕ
n_ih✝ : Approx.sMk (dest x) n = MIntl.approx x n
⊢ (CofixA.intro (head' (MIntl.approx x 1)) fun i => MIntl.approx (children x i) n) = MIntl.approx x (succ n)

Next tactic:
cases' h : x.approx (succ n) with _ hd ch
@[simp]
theorem mk_dest (x : M F) : M.mk (dest x) = x := by
  apply ext'
  intro n
  dsimp only [M.mk]
  induction' n with n
  · apply @Subsingleton.elim _ CofixA.instSubsingleton
  dsimp only [Approx.sMk, dest, head]
  cases' h : x.approx (succ n) with _ hd ch
  

Proof state:
case H.succ.intro
F : PFunctor.{u}
X : Type u_1
f : X → ↑F X
x : M F
n : ℕ
n_ih✝ : Approx.sMk (dest x) n = MIntl.approx x n
hd : F.A
ch : B F hd → CofixA F n
h : MIntl.approx x (succ n) = CofixA.intro hd ch
⊢ (CofixA.intro (head' (MIntl.approx x 1)) fun i => MIntl.approx (children x i) n) = CofixA.intro hd ch

Next tactic:
have h' : hd = head' (x.approx 1) := by
    rw [← head_succ' n, h, head']
    apply x.consistent
@[simp]
theorem mk_dest (x : M F) : M.mk (dest x) = x := by
  apply ext'
  intro n
  dsimp only [M.mk]
  induction' n with n
  · apply @Subsingleton.elim _ CofixA.instSubsingleton
  dsimp only [Approx.sMk, dest, head]
  cases' h : x.approx (succ n) with _ hd ch
  have h' : hd = head' (x.approx 1) := by
    

Proof state:
F : PFunctor.{u}
X : Type u_1
f : X → ↑F X
x : M F
n : ℕ
n_ih✝ : Approx.sMk (dest x) n = MIntl.approx x n
hd : F.A
ch : B F hd → CofixA F n
h : MIntl.approx x (succ n) = CofixA.intro hd ch
⊢ hd = head' (MIntl.approx x 1)

Next tactic:
rw [← head_succ' n, h, head']
@[simp]
theorem mk_dest (x : M F) : M.mk (dest x) = x := by
  apply ext'
  intro n
  dsimp only [M.mk]
  induction' n with n
  · apply @Subsingleton.elim _ CofixA.instSubsingleton
  dsimp only [Approx.sMk, dest, head]
  cases' h : x.approx (succ n) with _ hd ch
  have h' : hd = head' (x.approx 1) := by
    rw [← head_succ' n, h, head']
    

Proof state:
case Hconsistent
F : PFunctor.{u}
X : Type u_1
f : X → ↑F X
x : M F
n : ℕ
n_ih✝ : Approx.sMk (dest x) n = MIntl.approx x n
hd : F.A
ch : B F hd → CofixA F n
h : MIntl.approx x (succ n) = CofixA.intro hd ch
⊢ AllAgree x.approx

Next tactic:
apply x.consistent
@[simp]
theorem mk_dest (x : M F) : M.mk (dest x) = x := by
  apply ext'
  intro n
  dsimp only [M.mk]
  induction' n with n
  · apply @Subsingleton.elim _ CofixA.instSubsingleton
  dsimp only [Approx.sMk, dest, head]
  cases' h : x.approx (succ n) with _ hd ch
  have h' : hd = head' (x.approx 1) := by
    rw [← head_succ' n, h, head']
    apply x.consistent
  

Proof state:
case H.succ.intro
F : PFunctor.{u}
X : Type u_1
f : X → ↑F X
x : M F
n : ℕ
n_ih✝ : Approx.sMk (dest x) n = MIntl.approx x n
hd : F.A
ch : B F hd → CofixA F n
h : MIntl.approx x (succ n) = CofixA.intro hd ch
h' : hd = head' (MIntl.approx x 1)
⊢ (CofixA.intro (head' (MIntl.approx x 1)) fun i => MIntl.approx (children x i) n) = CofixA.intro hd ch

Next tactic:
revert ch
@[simp]
theorem mk_dest (x : M F) : M.mk (dest x) = x := by
  apply ext'
  intro n
  dsimp only [M.mk]
  induction' n with n
  · apply @Subsingleton.elim _ CofixA.instSubsingleton
  dsimp only [Approx.sMk, dest, head]
  cases' h : x.approx (succ n) with _ hd ch
  have h' : hd = head' (x.approx 1) := by
    rw [← head_succ' n, h, head']
    apply x.consistent
  revert ch
  

Proof state:
case H.succ.intro
F : PFunctor.{u}
X : Type u_1
f : X → ↑F X
x : M F
n : ℕ
n_ih✝ : Approx.sMk (dest x) n = MIntl.approx x n
hd : F.A
h' : hd = head' (MIntl.approx x 1)
⊢ ∀ (ch : B F hd → CofixA F n),
    MIntl.approx x (succ n) = CofixA.intro hd ch →
      (CofixA.intro (head' (MIntl.approx x 1)) fun i => MIntl.approx (children x i) n) = CofixA.intro hd ch

Next tactic:
rw [h']
@[simp]
theorem mk_dest (x : M F) : M.mk (dest x) = x := by
  apply ext'
  intro n
  dsimp only [M.mk]
  induction' n with n
  · apply @Subsingleton.elim _ CofixA.instSubsingleton
  dsimp only [Approx.sMk, dest, head]
  cases' h : x.approx (succ n) with _ hd ch
  have h' : hd = head' (x.approx 1) := by
    rw [← head_succ' n, h, head']
    apply x.consistent
  revert ch
  rw [h']
  

Proof state:
case H.succ.intro
F : PFunctor.{u}
X : Type u_1
f : X → ↑F X
x : M F
n : ℕ
n_ih✝ : Approx.sMk (dest x) n = MIntl.approx x n
hd : F.A
h' : hd = head' (MIntl.approx x 1)
⊢ ∀ (ch : B F (head' (MIntl.approx x 1)) → CofixA F n),
    MIntl.approx x (succ n) = CofixA.intro (head' (MIntl.approx x 1)) ch →
      (CofixA.intro (head' (MIntl.approx x 1)) fun i => MIntl.approx (children x i) n) =
        CofixA.intro (head' (MIntl.approx x 1)) ch

Next tactic:
intros ch h
@[simp]
theorem mk_dest (x : M F) : M.mk (dest x) = x := by
  apply ext'
  intro n
  dsimp only [M.mk]
  induction' n with n
  · apply @Subsingleton.elim _ CofixA.instSubsingleton
  dsimp only [Approx.sMk, dest, head]
  cases' h : x.approx (succ n) with _ hd ch
  have h' : hd = head' (x.approx 1) := by
    rw [← head_succ' n, h, head']
    apply x.consistent
  revert ch
  rw [h']
  intros ch h
  

Proof state:
case H.succ.intro
F : PFunctor.{u}
X : Type u_1
f : X → ↑F X
x : M F
n : ℕ
n_ih✝ : Approx.sMk (dest x) n = MIntl.approx x n
hd : F.A
h' : hd = head' (MIntl.approx x 1)
ch : B F (head' (MIntl.approx x 1)) → CofixA F n
h : MIntl.approx x (succ n) = CofixA.intro (head' (MIntl.approx x 1)) ch
⊢ (CofixA.intro (head' (MIntl.approx x 1)) fun i => MIntl.approx (children x i) n) =
    CofixA.intro (head' (MIntl.approx x 1)) ch

Next tactic:
congr
@[simp]
theorem mk_dest (x : M F) : M.mk (dest x) = x := by
  apply ext'
  intro n
  dsimp only [M.mk]
  induction' n with n
  · apply @Subsingleton.elim _ CofixA.instSubsingleton
  dsimp only [Approx.sMk, dest, head]
  cases' h : x.approx (succ n) with _ hd ch
  have h' : hd = head' (x.approx 1) := by
    rw [← head_succ' n, h, head']
    apply x.consistent
  revert ch
  rw [h']
  intros ch h
  congr
  · 

Proof state:
case H.succ.intro.e_a
F : PFunctor.{u}
X : Type u_1
f : X → ↑F X
x : M F
n : ℕ
n_ih✝ : Approx.sMk (dest x) n = MIntl.approx x n
hd : F.A
h' : hd = head' (MIntl.approx x 1)
ch : B F (head' (MIntl.approx x 1)) → CofixA F n
h : MIntl.approx x (succ n) = CofixA.intro (head' (MIntl.approx x 1)) ch
⊢ (fun i => MIntl.approx (children x i) n) = ch

Next tactic:
ext a