l3lab/ntp-mathlib huggingface dataset:
/-- The auxiliary function `convergents'Aux` returns the same value for a sequence and the
corresponding squashed sequence at the squashed position. -/
theorem succ_succ_nth_convergent'_aux_eq_succ_nth_convergent'_aux_squashSeq :
    convergents'Aux s (n + 2) = convergents'Aux (squashSeq s n) (n + 1) := by
  cases' s_succ_nth_eq : s.get? <| n + 1 with gp_succ_n
  case none =>
    rw [squashSeq_eq_self_of_terminated s_succ_nth_eq,
      convergents'Aux_stable_step_of_terminated s_succ_nth_eq]
  case some =>
    induction' n with m IH generalizing s gp_succ_n
    case zero =>
      obtain ⟨gp_head, s_head_eq⟩ : ∃ gp_head, s.head = some gp_head
      exact s.ge_stable zero_le_one s_succ_nth_eq
      have : (squashSeq s 0).head = some ⟨gp_head.a, gp_head.b + gp_succ_n.a / gp_succ_n.b⟩ :=
        squashSeq_nth_of_not_terminated s_head_eq s_succ_nth_eq
      simp_all [convergents'Aux, Stream'.Seq.head, Stream'.Seq.get?_tail]
    

Proof state:
K : Type u_1
g : GeneralizedContinuedFraction K
inst✝ : DivisionRing K
m : ℕ
IH :
  ∀ {s : Stream'.Seq (Pair K)} (gp_succ_n : Pair K),
    Stream'.Seq.get? s (m + 1) = some gp_succ_n → convergents'Aux s (m + 2) = convergents'Aux (squashSeq s m) (m + 1)
s : Stream'.Seq (Pair K)
gp_succ_n : Pair K
s_succ_nth_eq : Stream'.Seq.get? s (Nat.succ m + 1) = some gp_succ_n
⊢ convergents'Aux s (Nat.succ m + 2) = convergents'Aux (squashSeq s (Nat.succ m)) (Nat.succ m + 1)

Next tactic:
case succ =>
      obtain ⟨gp_head, s_head_eq⟩ : ∃ gp_head, s.head = some gp_head
      exact s.ge_stable (m + 2).zero_le s_succ_nth_eq
      suffices
        gp_head.a / (gp_head.b + convergents'Aux s.tail (m + 2)) =
          convergents'Aux (squashSeq s (m + 1)) (m + 2)
        by simpa only [convergents'Aux, s_head_eq]
      have : convergents'Aux s.tail (m + 2) = convergents'Aux (squashSeq s.tail m) (m + 1) := by
        refine' IH gp_succ_n _
        simpa [Stream'.Seq.get?_tail] using s_succ_nth_eq
      have : (squashSeq s (m + 1)).head = some gp_head :=
        (squashSeq_nth_of_lt m.succ_pos).trans s_head_eq
      simp_all [convergents'Aux, squashSeq_succ_n_tail_eq_squashSeq_tail_n]
/-- The auxiliary function `convergents'Aux` returns the same value for a sequence and the
corresponding squashed sequence at the squashed position. -/
theorem succ_succ_nth_convergent'_aux_eq_succ_nth_convergent'_aux_squashSeq :
    convergents'Aux s (n + 2) = convergents'Aux (squashSeq s n) (n + 1) := by
  cases' s_succ_nth_eq : s.get? <| n + 1 with gp_succ_n
  case none =>
    rw [squashSeq_eq_self_of_terminated s_succ_nth_eq,
      convergents'Aux_stable_step_of_terminated s_succ_nth_eq]
  case some =>
    induction' n with m IH generalizing s gp_succ_n
    case zero =>
      obtain ⟨gp_head, s_head_eq⟩ : ∃ gp_head, s.head = some gp_head
      exact s.ge_stable zero_le_one s_succ_nth_eq
      have : (squashSeq s 0).head = some ⟨gp_head.a, gp_head.b + gp_succ_n.a / gp_succ_n.b⟩ :=
        squashSeq_nth_of_not_terminated s_head_eq s_succ_nth_eq
      simp_all [convergents'Aux, Stream'.Seq.head, Stream'.Seq.get?_tail]
    case succ =>
      

Proof state:
K : Type u_1
g : GeneralizedContinuedFraction K
inst✝ : DivisionRing K
m : ℕ
IH :
  ∀ {s : Stream'.Seq (Pair K)} (gp_succ_n : Pair K),
    Stream'.Seq.get? s (m + 1) = some gp_succ_n → convergents'Aux s (m + 2) = convergents'Aux (squashSeq s m) (m + 1)
s : Stream'.Seq (Pair K)
gp_succ_n : Pair K
s_succ_nth_eq : Stream'.Seq.get? s (Nat.succ m + 1) = some gp_succ_n
⊢ convergents'Aux s (Nat.succ m + 2) = convergents'Aux (squashSeq s (Nat.succ m)) (Nat.succ m + 1)

Next tactic:
obtain ⟨gp_head, s_head_eq⟩ : ∃ gp_head, s.head = some gp_head
/-- The auxiliary function `convergents'Aux` returns the same value for a sequence and the
corresponding squashed sequence at the squashed position. -/
theorem succ_succ_nth_convergent'_aux_eq_succ_nth_convergent'_aux_squashSeq :
    convergents'Aux s (n + 2) = convergents'Aux (squashSeq s n) (n + 1) := by
  cases' s_succ_nth_eq : s.get? <| n + 1 with gp_succ_n
  case none =>
    rw [squashSeq_eq_self_of_terminated s_succ_nth_eq,
      convergents'Aux_stable_step_of_terminated s_succ_nth_eq]
  case some =>
    induction' n with m IH generalizing s gp_succ_n
    case zero =>
      obtain ⟨gp_head, s_head_eq⟩ : ∃ gp_head, s.head = some gp_head
      exact s.ge_stable zero_le_one s_succ_nth_eq
      have : (squashSeq s 0).head = some ⟨gp_head.a, gp_head.b + gp_succ_n.a / gp_succ_n.b⟩ :=
        squashSeq_nth_of_not_terminated s_head_eq s_succ_nth_eq
      simp_all [convergents'Aux, Stream'.Seq.head, Stream'.Seq.get?_tail]
    case succ =>
      obtain ⟨gp_head, s_head_eq⟩ : ∃ gp_head, s.head = some gp_head
      

Proof state:
K : Type u_1
g : GeneralizedContinuedFraction K
inst✝ : DivisionRing K
m : ℕ
IH :
  ∀ {s : Stream'.Seq (Pair K)} (gp_succ_n : Pair K),
    Stream'.Seq.get? s (m + 1) = some gp_succ_n → convergents'Aux s (m + 2) = convergents'Aux (squashSeq s m) (m + 1)
s : Stream'.Seq (Pair K)
gp_succ_n : Pair K
s_succ_nth_eq : Stream'.Seq.get? s (Nat.succ m + 1) = some gp_succ_n
⊢ ∃ gp_head, Stream'.Seq.head s = some gp_head
case intro
K : Type u_1
g : GeneralizedContinuedFraction K
inst✝ : DivisionRing K
m : ℕ
IH :
  ∀ {s : Stream'.Seq (Pair K)} (gp_succ_n : Pair K),
    Stream'.Seq.get? s (m + 1) = some gp_succ_n → convergents'Aux s (m + 2) = convergents'Aux (squashSeq s m) (m + 1)
s : Stream'.Seq (Pair K)
gp_succ_n : Pair K
s_succ_nth_eq : Stream'.Seq.get? s (Nat.succ m + 1) = some gp_succ_n
gp_head : Pair K
s_head_eq : Stream'.Seq.head s = some gp_head
⊢ convergents'Aux s (Nat.succ m + 2) = convergents'Aux (squashSeq s (Nat.succ m)) (Nat.succ m + 1)

Next tactic:
exact s.ge_stable (m + 2).zero_le s_succ_nth_eq
/-- The auxiliary function `convergents'Aux` returns the same value for a sequence and the
corresponding squashed sequence at the squashed position. -/
theorem succ_succ_nth_convergent'_aux_eq_succ_nth_convergent'_aux_squashSeq :
    convergents'Aux s (n + 2) = convergents'Aux (squashSeq s n) (n + 1) := by
  cases' s_succ_nth_eq : s.get? <| n + 1 with gp_succ_n
  case none =>
    rw [squashSeq_eq_self_of_terminated s_succ_nth_eq,
      convergents'Aux_stable_step_of_terminated s_succ_nth_eq]
  case some =>
    induction' n with m IH generalizing s gp_succ_n
    case zero =>
      obtain ⟨gp_head, s_head_eq⟩ : ∃ gp_head, s.head = some gp_head
      exact s.ge_stable zero_le_one s_succ_nth_eq
      have : (squashSeq s 0).head = some ⟨gp_head.a, gp_head.b + gp_succ_n.a / gp_succ_n.b⟩ :=
        squashSeq_nth_of_not_terminated s_head_eq s_succ_nth_eq
      simp_all [convergents'Aux, Stream'.Seq.head, Stream'.Seq.get?_tail]
    case succ =>
      obtain ⟨gp_head, s_head_eq⟩ : ∃ gp_head, s.head = some gp_head
      exact s.ge_stable (m + 2).zero_le s_succ_nth_eq
      

Proof state:
case intro
K : Type u_1
g : GeneralizedContinuedFraction K
inst✝ : DivisionRing K
m : ℕ
IH :
  ∀ {s : Stream'.Seq (Pair K)} (gp_succ_n : Pair K),
    Stream'.Seq.get? s (m + 1) = some gp_succ_n → convergents'Aux s (m + 2) = convergents'Aux (squashSeq s m) (m + 1)
s : Stream'.Seq (Pair K)
gp_succ_n : Pair K
s_succ_nth_eq : Stream'.Seq.get? s (Nat.succ m + 1) = some gp_succ_n
gp_head : Pair K
s_head_eq : Stream'.Seq.head s = some gp_head
⊢ convergents'Aux s (Nat.succ m + 2) = convergents'Aux (squashSeq s (Nat.succ m)) (Nat.succ m + 1)

Next tactic:
suffices
        gp_head.a / (gp_head.b + convergents'Aux s.tail (m + 2)) =
          convergents'Aux (squashSeq s (m + 1)) (m + 2)
        by simpa only [convergents'Aux, s_head_eq]
/-- The auxiliary function `convergents'Aux` returns the same value for a sequence and the
corresponding squashed sequence at the squashed position. -/
theorem succ_succ_nth_convergent'_aux_eq_succ_nth_convergent'_aux_squashSeq :
    convergents'Aux s (n + 2) = convergents'Aux (squashSeq s n) (n + 1) := by
  cases' s_succ_nth_eq : s.get? <| n + 1 with gp_succ_n
  case none =>
    rw [squashSeq_eq_self_of_terminated s_succ_nth_eq,
      convergents'Aux_stable_step_of_terminated s_succ_nth_eq]
  case some =>
    induction' n with m IH generalizing s gp_succ_n
    case zero =>
      obtain ⟨gp_head, s_head_eq⟩ : ∃ gp_head, s.head = some gp_head
      exact s.ge_stable zero_le_one s_succ_nth_eq
      have : (squashSeq s 0).head = some ⟨gp_head.a, gp_head.b + gp_succ_n.a / gp_succ_n.b⟩ :=
        squashSeq_nth_of_not_terminated s_head_eq s_succ_nth_eq
      simp_all [convergents'Aux, Stream'.Seq.head, Stream'.Seq.get?_tail]
    case succ =>
      obtain ⟨gp_head, s_head_eq⟩ : ∃ gp_head, s.head = some gp_head
      exact s.ge_stable (m + 2).zero_le s_succ_nth_eq
      suffices
        gp_head.a / (gp_head.b + convergents'Aux s.tail (m + 2)) =
          convergents'Aux (squashSeq s (m + 1)) (m + 2)
        by 

Proof state:
K : Type u_1
g : GeneralizedContinuedFraction K
inst✝ : DivisionRing K
m : ℕ
IH :
  ∀ {s : Stream'.Seq (Pair K)} (gp_succ_n : Pair K),
    Stream'.Seq.get? s (m + 1) = some gp_succ_n → convergents'Aux s (m + 2) = convergents'Aux (squashSeq s m) (m + 1)
s : Stream'.Seq (Pair K)
gp_succ_n : Pair K
s_succ_nth_eq : Stream'.Seq.get? s (Nat.succ m + 1) = some gp_succ_n
gp_head : Pair K
s_head_eq : Stream'.Seq.head s = some gp_head
this :
  gp_head.a / (gp_head.b + convergents'Aux (Stream'.Seq.tail s) (m + 2)) = convergents'Aux (squashSeq s (m + 1)) (m + 2)
⊢ convergents'Aux s (Nat.succ m + 2) = convergents'Aux (squashSeq s (Nat.succ m)) (Nat.succ m + 1)

Next tactic:
simpa only [convergents'Aux, s_head_eq]
/-- The auxiliary function `convergents'Aux` returns the same value for a sequence and the
corresponding squashed sequence at the squashed position. -/
theorem succ_succ_nth_convergent'_aux_eq_succ_nth_convergent'_aux_squashSeq :
    convergents'Aux s (n + 2) = convergents'Aux (squashSeq s n) (n + 1) := by
  cases' s_succ_nth_eq : s.get? <| n + 1 with gp_succ_n
  case none =>
    rw [squashSeq_eq_self_of_terminated s_succ_nth_eq,
      convergents'Aux_stable_step_of_terminated s_succ_nth_eq]
  case some =>
    induction' n with m IH generalizing s gp_succ_n
    case zero =>
      obtain ⟨gp_head, s_head_eq⟩ : ∃ gp_head, s.head = some gp_head
      exact s.ge_stable zero_le_one s_succ_nth_eq
      have : (squashSeq s 0).head = some ⟨gp_head.a, gp_head.b + gp_succ_n.a / gp_succ_n.b⟩ :=
        squashSeq_nth_of_not_terminated s_head_eq s_succ_nth_eq
      simp_all [convergents'Aux, Stream'.Seq.head, Stream'.Seq.get?_tail]
    case succ =>
      obtain ⟨gp_head, s_head_eq⟩ : ∃ gp_head, s.head = some gp_head
      exact s.ge_stable (m + 2).zero_le s_succ_nth_eq
      suffices
        gp_head.a / (gp_head.b + convergents'Aux s.tail (m + 2)) =
          convergents'Aux (squashSeq s (m + 1)) (m + 2)
        by simpa only [convergents'Aux, s_head_eq]
      

Proof state:
case intro
K : Type u_1
g : GeneralizedContinuedFraction K
inst✝ : DivisionRing K
m : ℕ
IH :
  ∀ {s : Stream'.Seq (Pair K)} (gp_succ_n : Pair K),
    Stream'.Seq.get? s (m + 1) = some gp_succ_n → convergents'Aux s (m + 2) = convergents'Aux (squashSeq s m) (m + 1)
s : Stream'.Seq (Pair K)
gp_succ_n : Pair K
s_succ_nth_eq : Stream'.Seq.get? s (Nat.succ m + 1) = some gp_succ_n
gp_head : Pair K
s_head_eq : Stream'.Seq.head s = some gp_head
⊢ gp_head.a / (gp_head.b + convergents'Aux (Stream'.Seq.tail s) (m + 2)) = convergents'Aux (squashSeq s (m + 1)) (m + 2)

Next tactic:
have : convergents'Aux s.tail (m + 2) = convergents'Aux (squashSeq s.tail m) (m + 1) := by
        refine' IH gp_succ_n _
        simpa [Stream'.Seq.get?_tail] using s_succ_nth_eq
/-- The auxiliary function `convergents'Aux` returns the same value for a sequence and the
corresponding squashed sequence at the squashed position. -/
theorem succ_succ_nth_convergent'_aux_eq_succ_nth_convergent'_aux_squashSeq :
    convergents'Aux s (n + 2) = convergents'Aux (squashSeq s n) (n + 1) := by
  cases' s_succ_nth_eq : s.get? <| n + 1 with gp_succ_n
  case none =>
    rw [squashSeq_eq_self_of_terminated s_succ_nth_eq,
      convergents'Aux_stable_step_of_terminated s_succ_nth_eq]
  case some =>
    induction' n with m IH generalizing s gp_succ_n
    case zero =>
      obtain ⟨gp_head, s_head_eq⟩ : ∃ gp_head, s.head = some gp_head
      exact s.ge_stable zero_le_one s_succ_nth_eq
      have : (squashSeq s 0).head = some ⟨gp_head.a, gp_head.b + gp_succ_n.a / gp_succ_n.b⟩ :=
        squashSeq_nth_of_not_terminated s_head_eq s_succ_nth_eq
      simp_all [convergents'Aux, Stream'.Seq.head, Stream'.Seq.get?_tail]
    case succ =>
      obtain ⟨gp_head, s_head_eq⟩ : ∃ gp_head, s.head = some gp_head
      exact s.ge_stable (m + 2).zero_le s_succ_nth_eq
      suffices
        gp_head.a / (gp_head.b + convergents'Aux s.tail (m + 2)) =
          convergents'Aux (squashSeq s (m + 1)) (m + 2)
        by simpa only [convergents'Aux, s_head_eq]
      have : convergents'Aux s.tail (m + 2) = convergents'Aux (squashSeq s.tail m) (m + 1) := by
        

Proof state:
K : Type u_1
g : GeneralizedContinuedFraction K
inst✝ : DivisionRing K
m : ℕ
IH :
  ∀ {s : Stream'.Seq (Pair K)} (gp_succ_n : Pair K),
    Stream'.Seq.get? s (m + 1) = some gp_succ_n → convergents'Aux s (m + 2) = convergents'Aux (squashSeq s m) (m + 1)
s : Stream'.Seq (Pair K)
gp_succ_n : Pair K
s_succ_nth_eq : Stream'.Seq.get? s (Nat.succ m + 1) = some gp_succ_n
gp_head : Pair K
s_head_eq : Stream'.Seq.head s = some gp_head
⊢ convergents'Aux (Stream'.Seq.tail s) (m + 2) = convergents'Aux (squashSeq (Stream'.Seq.tail s) m) (m + 1)

Next tactic:
refine' IH gp_succ_n _
/-- The auxiliary function `convergents'Aux` returns the same value for a sequence and the
corresponding squashed sequence at the squashed position. -/
theorem succ_succ_nth_convergent'_aux_eq_succ_nth_convergent'_aux_squashSeq :
    convergents'Aux s (n + 2) = convergents'Aux (squashSeq s n) (n + 1) := by
  cases' s_succ_nth_eq : s.get? <| n + 1 with gp_succ_n
  case none =>
    rw [squashSeq_eq_self_of_terminated s_succ_nth_eq,
      convergents'Aux_stable_step_of_terminated s_succ_nth_eq]
  case some =>
    induction' n with m IH generalizing s gp_succ_n
    case zero =>
      obtain ⟨gp_head, s_head_eq⟩ : ∃ gp_head, s.head = some gp_head
      exact s.ge_stable zero_le_one s_succ_nth_eq
      have : (squashSeq s 0).head = some ⟨gp_head.a, gp_head.b + gp_succ_n.a / gp_succ_n.b⟩ :=
        squashSeq_nth_of_not_terminated s_head_eq s_succ_nth_eq
      simp_all [convergents'Aux, Stream'.Seq.head, Stream'.Seq.get?_tail]
    case succ =>
      obtain ⟨gp_head, s_head_eq⟩ : ∃ gp_head, s.head = some gp_head
      exact s.ge_stable (m + 2).zero_le s_succ_nth_eq
      suffices
        gp_head.a / (gp_head.b + convergents'Aux s.tail (m + 2)) =
          convergents'Aux (squashSeq s (m + 1)) (m + 2)
        by simpa only [convergents'Aux, s_head_eq]
      have : convergents'Aux s.tail (m + 2) = convergents'Aux (squashSeq s.tail m) (m + 1) := by
        refine' IH gp_succ_n _
        

Proof state:
K : Type u_1
g : GeneralizedContinuedFraction K
inst✝ : DivisionRing K
m : ℕ
IH :
  ∀ {s : Stream'.Seq (Pair K)} (gp_succ_n : Pair K),
    Stream'.Seq.get? s (m + 1) = some gp_succ_n → convergents'Aux s (m + 2) = convergents'Aux (squashSeq s m) (m + 1)
s : Stream'.Seq (Pair K)
gp_succ_n : Pair K
s_succ_nth_eq : Stream'.Seq.get? s (Nat.succ m + 1) = some gp_succ_n
gp_head : Pair K
s_head_eq : Stream'.Seq.head s = some gp_head
⊢ Stream'.Seq.get? (Stream'.Seq.tail s) (m + 1) = some gp_succ_n

Next tactic:
simpa [Stream'.Seq.get?_tail] using s_succ_nth_eq
/-- The auxiliary function `convergents'Aux` returns the same value for a sequence and the
corresponding squashed sequence at the squashed position. -/
theorem succ_succ_nth_convergent'_aux_eq_succ_nth_convergent'_aux_squashSeq :
    convergents'Aux s (n + 2) = convergents'Aux (squashSeq s n) (n + 1) := by
  cases' s_succ_nth_eq : s.get? <| n + 1 with gp_succ_n
  case none =>
    rw [squashSeq_eq_self_of_terminated s_succ_nth_eq,
      convergents'Aux_stable_step_of_terminated s_succ_nth_eq]
  case some =>
    induction' n with m IH generalizing s gp_succ_n
    case zero =>
      obtain ⟨gp_head, s_head_eq⟩ : ∃ gp_head, s.head = some gp_head
      exact s.ge_stable zero_le_one s_succ_nth_eq
      have : (squashSeq s 0).head = some ⟨gp_head.a, gp_head.b + gp_succ_n.a / gp_succ_n.b⟩ :=
        squashSeq_nth_of_not_terminated s_head_eq s_succ_nth_eq
      simp_all [convergents'Aux, Stream'.Seq.head, Stream'.Seq.get?_tail]
    case succ =>
      obtain ⟨gp_head, s_head_eq⟩ : ∃ gp_head, s.head = some gp_head
      exact s.ge_stable (m + 2).zero_le s_succ_nth_eq
      suffices
        gp_head.a / (gp_head.b + convergents'Aux s.tail (m + 2)) =
          convergents'Aux (squashSeq s (m + 1)) (m + 2)
        by simpa only [convergents'Aux, s_head_eq]
      have : convergents'Aux s.tail (m + 2) = convergents'Aux (squashSeq s.tail m) (m + 1) := by
        refine' IH gp_succ_n _
        simpa [Stream'.Seq.get?_tail] using s_succ_nth_eq
      

Proof state:
case intro
K : Type u_1
g : GeneralizedContinuedFraction K
inst✝ : DivisionRing K
m : ℕ
IH :
  ∀ {s : Stream'.Seq (Pair K)} (gp_succ_n : Pair K),
    Stream'.Seq.get? s (m + 1) = some gp_succ_n → convergents'Aux s (m + 2) = convergents'Aux (squashSeq s m) (m + 1)
s : Stream'.Seq (Pair K)
gp_succ_n : Pair K
s_succ_nth_eq : Stream'.Seq.get? s (Nat.succ m + 1) = some gp_succ_n
gp_head : Pair K
s_head_eq : Stream'.Seq.head s = some gp_head
this : convergents'Aux (Stream'.Seq.tail s) (m + 2) = convergents'Aux (squashSeq (Stream'.Seq.tail s) m) (m + 1)
⊢ gp_head.a / (gp_head.b + convergents'Aux (Stream'.Seq.tail s) (m + 2)) = convergents'Aux (squashSeq s (m + 1)) (m + 2)

Next tactic:
have : (squashSeq s (m + 1)).head = some gp_head :=
        (squashSeq_nth_of_lt m.succ_pos).trans s_head_eq
/-- The auxiliary function `convergents'Aux` returns the same value for a sequence and the
corresponding squashed sequence at the squashed position. -/
theorem succ_succ_nth_convergent'_aux_eq_succ_nth_convergent'_aux_squashSeq :
    convergents'Aux s (n + 2) = convergents'Aux (squashSeq s n) (n + 1) := by
  cases' s_succ_nth_eq : s.get? <| n + 1 with gp_succ_n
  case none =>
    rw [squashSeq_eq_self_of_terminated s_succ_nth_eq,
      convergents'Aux_stable_step_of_terminated s_succ_nth_eq]
  case some =>
    induction' n with m IH generalizing s gp_succ_n
    case zero =>
      obtain ⟨gp_head, s_head_eq⟩ : ∃ gp_head, s.head = some gp_head
      exact s.ge_stable zero_le_one s_succ_nth_eq
      have : (squashSeq s 0).head = some ⟨gp_head.a, gp_head.b + gp_succ_n.a / gp_succ_n.b⟩ :=
        squashSeq_nth_of_not_terminated s_head_eq s_succ_nth_eq
      simp_all [convergents'Aux, Stream'.Seq.head, Stream'.Seq.get?_tail]
    case succ =>
      obtain ⟨gp_head, s_head_eq⟩ : ∃ gp_head, s.head = some gp_head
      exact s.ge_stable (m + 2).zero_le s_succ_nth_eq
      suffices
        gp_head.a / (gp_head.b + convergents'Aux s.tail (m + 2)) =
          convergents'Aux (squashSeq s (m + 1)) (m + 2)
        by simpa only [convergents'Aux, s_head_eq]
      have : convergents'Aux s.tail (m + 2) = convergents'Aux (squashSeq s.tail m) (m + 1) := by
        refine' IH gp_succ_n _
        simpa [Stream'.Seq.get?_tail] using s_succ_nth_eq
      have : (squashSeq s (m + 1)).head = some gp_head :=
        (squashSeq_nth_of_lt m.succ_pos).trans s_head_eq
      

Proof state:
case intro
K : Type u_1
g : GeneralizedContinuedFraction K
inst✝ : DivisionRing K
m : ℕ
IH :
  ∀ {s : Stream'.Seq (Pair K)} (gp_succ_n : Pair K),
    Stream'.Seq.get? s (m + 1) = some gp_succ_n → convergents'Aux s (m + 2) = convergents'Aux (squashSeq s m) (m + 1)
s : Stream'.Seq (Pair K)
gp_succ_n : Pair K
s_succ_nth_eq : Stream'.Seq.get? s (Nat.succ m + 1) = some gp_succ_n
gp_head : Pair K
s_head_eq : Stream'.Seq.head s = some gp_head
this✝ : convergents'Aux (Stream'.Seq.tail s) (m + 2) = convergents'Aux (squashSeq (Stream'.Seq.tail s) m) (m + 1)
this : Stream'.Seq.head (squashSeq s (m + 1)) = some gp_head
⊢ gp_head.a / (gp_head.b + convergents'Aux (Stream'.Seq.tail s) (m + 2)) = convergents'Aux (squashSeq s (m + 1)) (m + 2)

Next tactic:
simp_all [convergents'Aux, squashSeq_succ_n_tail_eq_squashSeq_tail_n]
/-- If the gcf already terminated at position `n`, nothing gets squashed. -/
theorem squashGCF_eq_self_of_terminated (terminated_at_n : TerminatedAt g n) :
    squashGCF g n = g := by
  

Proof state:
K : Type u_1
n : ℕ
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : DivisionRing K
terminated_at_n : TerminatedAt g n
⊢ squashGCF g n = g

Next tactic:
cases n
/-- If the gcf already terminated at position `n`, nothing gets squashed. -/
theorem squashGCF_eq_self_of_terminated (terminated_at_n : TerminatedAt g n) :
    squashGCF g n = g := by
  cases n
  

Proof state:
case zero
K : Type u_1
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : DivisionRing K
terminated_at_n : TerminatedAt g Nat.zero
⊢ squashGCF g Nat.zero = g
case succ
K : Type u_1
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : DivisionRing K
n✝ : ℕ
terminated_at_n : TerminatedAt g (Nat.succ n✝)
⊢ squashGCF g (Nat.succ n✝) = g

Next tactic:
case zero =>
    change g.s.get? 0 = none at terminated_at_n
    simp only [convergents', squashGCF, convergents'Aux, terminated_at_n]
/-- If the gcf already terminated at position `n`, nothing gets squashed. -/
theorem squashGCF_eq_self_of_terminated (terminated_at_n : TerminatedAt g n) :
    squashGCF g n = g := by
  cases n
  

Proof state:
K : Type u_1
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : DivisionRing K
terminated_at_n : TerminatedAt g Nat.zero
⊢ squashGCF g Nat.zero = g

Next tactic:
case zero =>
    change g.s.get? 0 = none at terminated_at_n
    simp only [convergents', squashGCF, convergents'Aux, terminated_at_n]
/-- If the gcf already terminated at position `n`, nothing gets squashed. -/
theorem squashGCF_eq_self_of_terminated (terminated_at_n : TerminatedAt g n) :
    squashGCF g n = g := by
  cases n
  case zero =>
    

Proof state:
K : Type u_1
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : DivisionRing K
terminated_at_n : TerminatedAt g Nat.zero
⊢ squashGCF g Nat.zero = g

Next tactic:
change g.s.get? 0 = none at terminated_at_n
/-- If the gcf already terminated at position `n`, nothing gets squashed. -/
theorem squashGCF_eq_self_of_terminated (terminated_at_n : TerminatedAt g n) :
    squashGCF g n = g := by
  cases n
  case zero =>
    change g.s.get? 0 = none at terminated_at_n
    

Proof state:
K : Type u_1
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : DivisionRing K
terminated_at_n : Stream'.Seq.get? g.s 0 = none
⊢ squashGCF g Nat.zero = g

Next tactic:
simp only [convergents', squashGCF, convergents'Aux, terminated_at_n]
/-- If the gcf already terminated at position `n`, nothing gets squashed. -/
theorem squashGCF_eq_self_of_terminated (terminated_at_n : TerminatedAt g n) :
    squashGCF g n = g := by
  cases n
  case zero =>
    change g.s.get? 0 = none at terminated_at_n
    simp only [convergents', squashGCF, convergents'Aux, terminated_at_n]
  

Proof state:
case succ
K : Type u_1
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : DivisionRing K
n✝ : ℕ
terminated_at_n : TerminatedAt g (Nat.succ n✝)
⊢ squashGCF g (Nat.succ n✝) = g

Next tactic:
case succ =>
    cases g
    simp only [squashGCF, mk.injEq, true_and]
    exact squashSeq_eq_self_of_terminated terminated_at_n
/-- If the gcf already terminated at position `n`, nothing gets squashed. -/
theorem squashGCF_eq_self_of_terminated (terminated_at_n : TerminatedAt g n) :
    squashGCF g n = g := by
  cases n
  case zero =>
    change g.s.get? 0 = none at terminated_at_n
    simp only [convergents', squashGCF, convergents'Aux, terminated_at_n]
  

Proof state:
K : Type u_1
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : DivisionRing K
n✝ : ℕ
terminated_at_n : TerminatedAt g (Nat.succ n✝)
⊢ squashGCF g (Nat.succ n✝) = g

Next tactic:
case succ =>
    cases g
    simp only [squashGCF, mk.injEq, true_and]
    exact squashSeq_eq_self_of_terminated terminated_at_n