l3lab/ntp-mathlib huggingface dataset:
/-- The convergents coincide in the expected way at the squashed position if the partial denominator
at the squashed position is not zero. -/
theorem succ_nth_convergent_eq_squashGCF_nth_convergent [Field K]
    (nth_part_denom_ne_zero : ∀ {b : K}, g.partialDenominators.get? n = some b → b ≠ 0) :
    g.convergents (n + 1) = (squashGCF g n).convergents n := by
  cases' Decidable.em (g.TerminatedAt n) with terminated_at_n not_terminated_at_n
  · have : squashGCF g n = g := squashGCF_eq_self_of_terminated terminated_at_n
    

Proof state:
case inl
K : Type u_1
n : ℕ
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : Field K
nth_part_denom_ne_zero : ∀ {b : K}, Stream'.Seq.get? (partialDenominators g) n = some b → b ≠ 0
terminated_at_n : TerminatedAt g n
this : squashGCF g n = g
⊢ convergents g (n + 1) = convergents (squashGCF g n) n

Next tactic:
simp only [this, convergents_stable_of_terminated n.le_succ terminated_at_n]
/-- The convergents coincide in the expected way at the squashed position if the partial denominator
at the squashed position is not zero. -/
theorem succ_nth_convergent_eq_squashGCF_nth_convergent [Field K]
    (nth_part_denom_ne_zero : ∀ {b : K}, g.partialDenominators.get? n = some b → b ≠ 0) :
    g.convergents (n + 1) = (squashGCF g n).convergents n := by
  cases' Decidable.em (g.TerminatedAt n) with terminated_at_n not_terminated_at_n
  · have : squashGCF g n = g := squashGCF_eq_self_of_terminated terminated_at_n
    simp only [this, convergents_stable_of_terminated n.le_succ terminated_at_n]
  · 

Proof state:
case inr
K : Type u_1
n : ℕ
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : Field K
nth_part_denom_ne_zero : ∀ {b : K}, Stream'.Seq.get? (partialDenominators g) n = some b → b ≠ 0
not_terminated_at_n : ¬TerminatedAt g n
⊢ convergents g (n + 1) = convergents (squashGCF g n) n

Next tactic:
obtain ⟨⟨a, b⟩, s_nth_eq⟩ : ∃ gp_n, g.s.get? n = some gp_n
/-- The convergents coincide in the expected way at the squashed position if the partial denominator
at the squashed position is not zero. -/
theorem succ_nth_convergent_eq_squashGCF_nth_convergent [Field K]
    (nth_part_denom_ne_zero : ∀ {b : K}, g.partialDenominators.get? n = some b → b ≠ 0) :
    g.convergents (n + 1) = (squashGCF g n).convergents n := by
  cases' Decidable.em (g.TerminatedAt n) with terminated_at_n not_terminated_at_n
  · have : squashGCF g n = g := squashGCF_eq_self_of_terminated terminated_at_n
    simp only [this, convergents_stable_of_terminated n.le_succ terminated_at_n]
  · obtain ⟨⟨a, b⟩, s_nth_eq⟩ : ∃ gp_n, g.s.get? n = some gp_n
    

Proof state:
K : Type u_1
n : ℕ
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : Field K
nth_part_denom_ne_zero : ∀ {b : K}, Stream'.Seq.get? (partialDenominators g) n = some b → b ≠ 0
not_terminated_at_n : ¬TerminatedAt g n
⊢ ∃ gp_n, Stream'.Seq.get? g.s n = some gp_n
case inr.intro.mk
K : Type u_1
n : ℕ
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : Field K
nth_part_denom_ne_zero : ∀ {b : K}, Stream'.Seq.get? (partialDenominators g) n = some b → b ≠ 0
not_terminated_at_n : ¬TerminatedAt g n
a b : K
s_nth_eq : Stream'.Seq.get? g.s n = some { a := a, b := b }
⊢ convergents g (n + 1) = convergents (squashGCF g n) n

Next tactic:
exact Option.ne_none_iff_exists'.mp not_terminated_at_n
/-- The convergents coincide in the expected way at the squashed position if the partial denominator
at the squashed position is not zero. -/
theorem succ_nth_convergent_eq_squashGCF_nth_convergent [Field K]
    (nth_part_denom_ne_zero : ∀ {b : K}, g.partialDenominators.get? n = some b → b ≠ 0) :
    g.convergents (n + 1) = (squashGCF g n).convergents n := by
  cases' Decidable.em (g.TerminatedAt n) with terminated_at_n not_terminated_at_n
  · have : squashGCF g n = g := squashGCF_eq_self_of_terminated terminated_at_n
    simp only [this, convergents_stable_of_terminated n.le_succ terminated_at_n]
  · obtain ⟨⟨a, b⟩, s_nth_eq⟩ : ∃ gp_n, g.s.get? n = some gp_n
    exact Option.ne_none_iff_exists'.mp not_terminated_at_n
    

Proof state:
case inr.intro.mk
K : Type u_1
n : ℕ
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : Field K
nth_part_denom_ne_zero : ∀ {b : K}, Stream'.Seq.get? (partialDenominators g) n = some b → b ≠ 0
not_terminated_at_n : ¬TerminatedAt g n
a b : K
s_nth_eq : Stream'.Seq.get? g.s n = some { a := a, b := b }
⊢ convergents g (n + 1) = convergents (squashGCF g n) n

Next tactic:
have b_ne_zero : b ≠ 0 := nth_part_denom_ne_zero (part_denom_eq_s_b s_nth_eq)
/-- The convergents coincide in the expected way at the squashed position if the partial denominator
at the squashed position is not zero. -/
theorem succ_nth_convergent_eq_squashGCF_nth_convergent [Field K]
    (nth_part_denom_ne_zero : ∀ {b : K}, g.partialDenominators.get? n = some b → b ≠ 0) :
    g.convergents (n + 1) = (squashGCF g n).convergents n := by
  cases' Decidable.em (g.TerminatedAt n) with terminated_at_n not_terminated_at_n
  · have : squashGCF g n = g := squashGCF_eq_self_of_terminated terminated_at_n
    simp only [this, convergents_stable_of_terminated n.le_succ terminated_at_n]
  · obtain ⟨⟨a, b⟩, s_nth_eq⟩ : ∃ gp_n, g.s.get? n = some gp_n
    exact Option.ne_none_iff_exists'.mp not_terminated_at_n
    have b_ne_zero : b ≠ 0 := nth_part_denom_ne_zero (part_denom_eq_s_b s_nth_eq)
    

Proof state:
case inr.intro.mk
K : Type u_1
n : ℕ
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : Field K
nth_part_denom_ne_zero : ∀ {b : K}, Stream'.Seq.get? (partialDenominators g) n = some b → b ≠ 0
not_terminated_at_n : ¬TerminatedAt g n
a b : K
s_nth_eq : Stream'.Seq.get? g.s n = some { a := a, b := b }
b_ne_zero : b ≠ 0
⊢ convergents g (n + 1) = convergents (squashGCF g n) n

Next tactic:
cases' n with n'
/-- The convergents coincide in the expected way at the squashed position if the partial denominator
at the squashed position is not zero. -/
theorem succ_nth_convergent_eq_squashGCF_nth_convergent [Field K]
    (nth_part_denom_ne_zero : ∀ {b : K}, g.partialDenominators.get? n = some b → b ≠ 0) :
    g.convergents (n + 1) = (squashGCF g n).convergents n := by
  cases' Decidable.em (g.TerminatedAt n) with terminated_at_n not_terminated_at_n
  · have : squashGCF g n = g := squashGCF_eq_self_of_terminated terminated_at_n
    simp only [this, convergents_stable_of_terminated n.le_succ terminated_at_n]
  · obtain ⟨⟨a, b⟩, s_nth_eq⟩ : ∃ gp_n, g.s.get? n = some gp_n
    exact Option.ne_none_iff_exists'.mp not_terminated_at_n
    have b_ne_zero : b ≠ 0 := nth_part_denom_ne_zero (part_denom_eq_s_b s_nth_eq)
    cases' n with n'
    

Proof state:
case inr.intro.mk.zero
K : Type u_1
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : Field K
a b : K
b_ne_zero : b ≠ 0
nth_part_denom_ne_zero : ∀ {b : K}, Stream'.Seq.get? (partialDenominators g) Nat.zero = some b → b ≠ 0
not_terminated_at_n : ¬TerminatedAt g Nat.zero
s_nth_eq : Stream'.Seq.get? g.s Nat.zero = some { a := a, b := b }
⊢ convergents g (Nat.zero + 1) = convergents (squashGCF g Nat.zero) Nat.zero
case inr.intro.mk.succ
K : Type u_1
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : Field K
a b : K
b_ne_zero : b ≠ 0
n' : ℕ
nth_part_denom_ne_zero : ∀ {b : K}, Stream'.Seq.get? (partialDenominators g) (Nat.succ n') = some b → b ≠ 0
not_terminated_at_n : ¬TerminatedAt g (Nat.succ n')
s_nth_eq : Stream'.Seq.get? g.s (Nat.succ n') = some { a := a, b := b }
⊢ convergents g (Nat.succ n' + 1) = convergents (squashGCF g (Nat.succ n')) (Nat.succ n')

Next tactic:
case zero =>
      suffices (b * g.h + a) / b = g.h + a / b by
        simpa [squashGCF, s_nth_eq, convergent_eq_conts_a_div_conts_b,
          continuants_recurrenceAux s_nth_eq zeroth_continuant_aux_eq_one_zero
            first_continuant_aux_eq_h_one]
      calc
        (b * g.h + a) / b = b * g.h / b + a / b := by ring
        -- requires `Field`, not `DivisionRing`
        _ = g.h + a / b := by rw [mul_div_cancel_left _ b_ne_zero]
/-- The convergents coincide in the expected way at the squashed position if the partial denominator
at the squashed position is not zero. -/
theorem succ_nth_convergent_eq_squashGCF_nth_convergent [Field K]
    (nth_part_denom_ne_zero : ∀ {b : K}, g.partialDenominators.get? n = some b → b ≠ 0) :
    g.convergents (n + 1) = (squashGCF g n).convergents n := by
  cases' Decidable.em (g.TerminatedAt n) with terminated_at_n not_terminated_at_n
  · have : squashGCF g n = g := squashGCF_eq_self_of_terminated terminated_at_n
    simp only [this, convergents_stable_of_terminated n.le_succ terminated_at_n]
  · obtain ⟨⟨a, b⟩, s_nth_eq⟩ : ∃ gp_n, g.s.get? n = some gp_n
    exact Option.ne_none_iff_exists'.mp not_terminated_at_n
    have b_ne_zero : b ≠ 0 := nth_part_denom_ne_zero (part_denom_eq_s_b s_nth_eq)
    cases' n with n'
    

Proof state:
K : Type u_1
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : Field K
a b : K
b_ne_zero : b ≠ 0
nth_part_denom_ne_zero : ∀ {b : K}, Stream'.Seq.get? (partialDenominators g) Nat.zero = some b → b ≠ 0
not_terminated_at_n : ¬TerminatedAt g Nat.zero
s_nth_eq : Stream'.Seq.get? g.s Nat.zero = some { a := a, b := b }
⊢ convergents g (Nat.zero + 1) = convergents (squashGCF g Nat.zero) Nat.zero

Next tactic:
case zero =>
      suffices (b * g.h + a) / b = g.h + a / b by
        simpa [squashGCF, s_nth_eq, convergent_eq_conts_a_div_conts_b,
          continuants_recurrenceAux s_nth_eq zeroth_continuant_aux_eq_one_zero
            first_continuant_aux_eq_h_one]
      calc
        (b * g.h + a) / b = b * g.h / b + a / b := by ring
        -- requires `Field`, not `DivisionRing`
        _ = g.h + a / b := by rw [mul_div_cancel_left _ b_ne_zero]
/-- The convergents coincide in the expected way at the squashed position if the partial denominator
at the squashed position is not zero. -/
theorem succ_nth_convergent_eq_squashGCF_nth_convergent [Field K]
    (nth_part_denom_ne_zero : ∀ {b : K}, g.partialDenominators.get? n = some b → b ≠ 0) :
    g.convergents (n + 1) = (squashGCF g n).convergents n := by
  cases' Decidable.em (g.TerminatedAt n) with terminated_at_n not_terminated_at_n
  · have : squashGCF g n = g := squashGCF_eq_self_of_terminated terminated_at_n
    simp only [this, convergents_stable_of_terminated n.le_succ terminated_at_n]
  · obtain ⟨⟨a, b⟩, s_nth_eq⟩ : ∃ gp_n, g.s.get? n = some gp_n
    exact Option.ne_none_iff_exists'.mp not_terminated_at_n
    have b_ne_zero : b ≠ 0 := nth_part_denom_ne_zero (part_denom_eq_s_b s_nth_eq)
    cases' n with n'
    case zero =>
      

Proof state:
K : Type u_1
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : Field K
a b : K
b_ne_zero : b ≠ 0
nth_part_denom_ne_zero : ∀ {b : K}, Stream'.Seq.get? (partialDenominators g) Nat.zero = some b → b ≠ 0
not_terminated_at_n : ¬TerminatedAt g Nat.zero
s_nth_eq : Stream'.Seq.get? g.s Nat.zero = some { a := a, b := b }
⊢ convergents g (Nat.zero + 1) = convergents (squashGCF g Nat.zero) Nat.zero

Next tactic:
suffices (b * g.h + a) / b = g.h + a / b by
        simpa [squashGCF, s_nth_eq, convergent_eq_conts_a_div_conts_b,
          continuants_recurrenceAux s_nth_eq zeroth_continuant_aux_eq_one_zero
            first_continuant_aux_eq_h_one]
/-- The convergents coincide in the expected way at the squashed position if the partial denominator
at the squashed position is not zero. -/
theorem succ_nth_convergent_eq_squashGCF_nth_convergent [Field K]
    (nth_part_denom_ne_zero : ∀ {b : K}, g.partialDenominators.get? n = some b → b ≠ 0) :
    g.convergents (n + 1) = (squashGCF g n).convergents n := by
  cases' Decidable.em (g.TerminatedAt n) with terminated_at_n not_terminated_at_n
  · have : squashGCF g n = g := squashGCF_eq_self_of_terminated terminated_at_n
    simp only [this, convergents_stable_of_terminated n.le_succ terminated_at_n]
  · obtain ⟨⟨a, b⟩, s_nth_eq⟩ : ∃ gp_n, g.s.get? n = some gp_n
    exact Option.ne_none_iff_exists'.mp not_terminated_at_n
    have b_ne_zero : b ≠ 0 := nth_part_denom_ne_zero (part_denom_eq_s_b s_nth_eq)
    cases' n with n'
    case zero =>
      suffices (b * g.h + a) / b = g.h + a / b by
        

Proof state:
K : Type u_1
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : Field K
a b : K
b_ne_zero : b ≠ 0
nth_part_denom_ne_zero : ∀ {b : K}, Stream'.Seq.get? (partialDenominators g) Nat.zero = some b → b ≠ 0
not_terminated_at_n : ¬TerminatedAt g Nat.zero
s_nth_eq : Stream'.Seq.get? g.s Nat.zero = some { a := a, b := b }
this : (b * g.h + a) / b = g.h + a / b
⊢ convergents g (Nat.zero + 1) = convergents (squashGCF g Nat.zero) Nat.zero

Next tactic:
simpa [squashGCF, s_nth_eq, convergent_eq_conts_a_div_conts_b,
          continuants_recurrenceAux s_nth_eq zeroth_continuant_aux_eq_one_zero
            first_continuant_aux_eq_h_one]
/-- The convergents coincide in the expected way at the squashed position if the partial denominator
at the squashed position is not zero. -/
theorem succ_nth_convergent_eq_squashGCF_nth_convergent [Field K]
    (nth_part_denom_ne_zero : ∀ {b : K}, g.partialDenominators.get? n = some b → b ≠ 0) :
    g.convergents (n + 1) = (squashGCF g n).convergents n := by
  cases' Decidable.em (g.TerminatedAt n) with terminated_at_n not_terminated_at_n
  · have : squashGCF g n = g := squashGCF_eq_self_of_terminated terminated_at_n
    simp only [this, convergents_stable_of_terminated n.le_succ terminated_at_n]
  · obtain ⟨⟨a, b⟩, s_nth_eq⟩ : ∃ gp_n, g.s.get? n = some gp_n
    exact Option.ne_none_iff_exists'.mp not_terminated_at_n
    have b_ne_zero : b ≠ 0 := nth_part_denom_ne_zero (part_denom_eq_s_b s_nth_eq)
    cases' n with n'
    case zero =>
      suffices (b * g.h + a) / b = g.h + a / b by
        simpa [squashGCF, s_nth_eq, convergent_eq_conts_a_div_conts_b,
          continuants_recurrenceAux s_nth_eq zeroth_continuant_aux_eq_one_zero
            first_continuant_aux_eq_h_one]
      

Proof state:
K : Type u_1
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : Field K
a b : K
b_ne_zero : b ≠ 0
nth_part_denom_ne_zero : ∀ {b : K}, Stream'.Seq.get? (partialDenominators g) Nat.zero = some b → b ≠ 0
not_terminated_at_n : ¬TerminatedAt g Nat.zero
s_nth_eq : Stream'.Seq.get? g.s Nat.zero = some { a := a, b := b }
⊢ (b * g.h + a) / b = g.h + a / b

Next tactic:
calc
        (b * g.h + a) / b = b * g.h / b + a / b := by ring
        -- requires `Field`, not `DivisionRing`
        _ = g.h + a / b := by rw [mul_div_cancel_left _ b_ne_zero]
/-- The convergents coincide in the expected way at the squashed position if the partial denominator
at the squashed position is not zero. -/
theorem succ_nth_convergent_eq_squashGCF_nth_convergent [Field K]
    (nth_part_denom_ne_zero : ∀ {b : K}, g.partialDenominators.get? n = some b → b ≠ 0) :
    g.convergents (n + 1) = (squashGCF g n).convergents n := by
  cases' Decidable.em (g.TerminatedAt n) with terminated_at_n not_terminated_at_n
  · have : squashGCF g n = g := squashGCF_eq_self_of_terminated terminated_at_n
    simp only [this, convergents_stable_of_terminated n.le_succ terminated_at_n]
  · obtain ⟨⟨a, b⟩, s_nth_eq⟩ : ∃ gp_n, g.s.get? n = some gp_n
    exact Option.ne_none_iff_exists'.mp not_terminated_at_n
    have b_ne_zero : b ≠ 0 := nth_part_denom_ne_zero (part_denom_eq_s_b s_nth_eq)
    cases' n with n'
    case zero =>
      suffices (b * g.h + a) / b = g.h + a / b by
        simpa [squashGCF, s_nth_eq, convergent_eq_conts_a_div_conts_b,
          continuants_recurrenceAux s_nth_eq zeroth_continuant_aux_eq_one_zero
            first_continuant_aux_eq_h_one]
      calc
        (b * g.h + a) / b = b * g.h / b + a / b := by 

Proof state:
K : Type u_1
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : Field K
a b : K
b_ne_zero : b ≠ 0
nth_part_denom_ne_zero : ∀ {b : K}, Stream'.Seq.get? (partialDenominators g) Nat.zero = some b → b ≠ 0
not_terminated_at_n : ¬TerminatedAt g Nat.zero
s_nth_eq : Stream'.Seq.get? g.s Nat.zero = some { a := a, b := b }
⊢ (b * g.h + a) / b = b * g.h / b + a / b

Next tactic:
ring
/-- The convergents coincide in the expected way at the squashed position if the partial denominator
at the squashed position is not zero. -/
theorem succ_nth_convergent_eq_squashGCF_nth_convergent [Field K]
    (nth_part_denom_ne_zero : ∀ {b : K}, g.partialDenominators.get? n = some b → b ≠ 0) :
    g.convergents (n + 1) = (squashGCF g n).convergents n := by
  cases' Decidable.em (g.TerminatedAt n) with terminated_at_n not_terminated_at_n
  · have : squashGCF g n = g := squashGCF_eq_self_of_terminated terminated_at_n
    simp only [this, convergents_stable_of_terminated n.le_succ terminated_at_n]
  · obtain ⟨⟨a, b⟩, s_nth_eq⟩ : ∃ gp_n, g.s.get? n = some gp_n
    exact Option.ne_none_iff_exists'.mp not_terminated_at_n
    have b_ne_zero : b ≠ 0 := nth_part_denom_ne_zero (part_denom_eq_s_b s_nth_eq)
    cases' n with n'
    case zero =>
      suffices (b * g.h + a) / b = g.h + a / b by
        simpa [squashGCF, s_nth_eq, convergent_eq_conts_a_div_conts_b,
          continuants_recurrenceAux s_nth_eq zeroth_continuant_aux_eq_one_zero
            first_continuant_aux_eq_h_one]
      calc
        (b * g.h + a) / b = b * g.h / b + a / b := by ring
        -- requires `Field`, not `DivisionRing`
        _ = g.h + a / b := by 

Proof state:
K : Type u_1
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : Field K
a b : K
b_ne_zero : b ≠ 0
nth_part_denom_ne_zero : ∀ {b : K}, Stream'.Seq.get? (partialDenominators g) Nat.zero = some b → b ≠ 0
not_terminated_at_n : ¬TerminatedAt g Nat.zero
s_nth_eq : Stream'.Seq.get? g.s Nat.zero = some { a := a, b := b }
⊢ b * g.h / b + a / b = g.h + a / b

Next tactic:
rw [mul_div_cancel_left _ b_ne_zero]
/-- The convergents coincide in the expected way at the squashed position if the partial denominator
at the squashed position is not zero. -/
theorem succ_nth_convergent_eq_squashGCF_nth_convergent [Field K]
    (nth_part_denom_ne_zero : ∀ {b : K}, g.partialDenominators.get? n = some b → b ≠ 0) :
    g.convergents (n + 1) = (squashGCF g n).convergents n := by
  cases' Decidable.em (g.TerminatedAt n) with terminated_at_n not_terminated_at_n
  · have : squashGCF g n = g := squashGCF_eq_self_of_terminated terminated_at_n
    simp only [this, convergents_stable_of_terminated n.le_succ terminated_at_n]
  · obtain ⟨⟨a, b⟩, s_nth_eq⟩ : ∃ gp_n, g.s.get? n = some gp_n
    exact Option.ne_none_iff_exists'.mp not_terminated_at_n
    have b_ne_zero : b ≠ 0 := nth_part_denom_ne_zero (part_denom_eq_s_b s_nth_eq)
    cases' n with n'
    case zero =>
      suffices (b * g.h + a) / b = g.h + a / b by
        simpa [squashGCF, s_nth_eq, convergent_eq_conts_a_div_conts_b,
          continuants_recurrenceAux s_nth_eq zeroth_continuant_aux_eq_one_zero
            first_continuant_aux_eq_h_one]
      calc
        (b * g.h + a) / b = b * g.h / b + a / b := by ring
        -- requires `Field`, not `DivisionRing`
        _ = g.h + a / b := by rw [mul_div_cancel_left _ b_ne_zero]
    case succ =>
      

Proof state:
K : Type u_1
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : Field K
a b : K
b_ne_zero : b ≠ 0
n' : ℕ
nth_part_denom_ne_zero : ∀ {b : K}, Stream'.Seq.get? (partialDenominators g) (Nat.succ n') = some b → b ≠ 0
not_terminated_at_n : ¬TerminatedAt g (Nat.succ n')
s_nth_eq : Stream'.Seq.get? g.s (Nat.succ n') = some { a := a, b := b }
⊢ convergents g (Nat.succ n' + 1) = convergents (squashGCF g (Nat.succ n')) (Nat.succ n')

Next tactic:
obtain ⟨⟨pa, pb⟩, s_n'th_eq⟩ : ∃ gp_n', g.s.get? n' = some gp_n' :=
        g.s.ge_stable n'.le_succ s_nth_eq
/-- The convergents coincide in the expected way at the squashed position if the partial denominator
at the squashed position is not zero. -/
theorem succ_nth_convergent_eq_squashGCF_nth_convergent [Field K]
    (nth_part_denom_ne_zero : ∀ {b : K}, g.partialDenominators.get? n = some b → b ≠ 0) :
    g.convergents (n + 1) = (squashGCF g n).convergents n := by
  cases' Decidable.em (g.TerminatedAt n) with terminated_at_n not_terminated_at_n
  · have : squashGCF g n = g := squashGCF_eq_self_of_terminated terminated_at_n
    simp only [this, convergents_stable_of_terminated n.le_succ terminated_at_n]
  · obtain ⟨⟨a, b⟩, s_nth_eq⟩ : ∃ gp_n, g.s.get? n = some gp_n
    exact Option.ne_none_iff_exists'.mp not_terminated_at_n
    have b_ne_zero : b ≠ 0 := nth_part_denom_ne_zero (part_denom_eq_s_b s_nth_eq)
    cases' n with n'
    case zero =>
      suffices (b * g.h + a) / b = g.h + a / b by
        simpa [squashGCF, s_nth_eq, convergent_eq_conts_a_div_conts_b,
          continuants_recurrenceAux s_nth_eq zeroth_continuant_aux_eq_one_zero
            first_continuant_aux_eq_h_one]
      calc
        (b * g.h + a) / b = b * g.h / b + a / b := by ring
        -- requires `Field`, not `DivisionRing`
        _ = g.h + a / b := by rw [mul_div_cancel_left _ b_ne_zero]
    case succ =>
      obtain ⟨⟨pa, pb⟩, s_n'th_eq⟩ : ∃ gp_n', g.s.get? n' = some gp_n' :=
        g.s.ge_stable n'.le_succ s_nth_eq
      -- Notations
      

Proof state:
case intro.mk
K : Type u_1
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : Field K
a b : K
b_ne_zero : b ≠ 0
n' : ℕ
nth_part_denom_ne_zero : ∀ {b : K}, Stream'.Seq.get? (partialDenominators g) (Nat.succ n') = some b → b ≠ 0
not_terminated_at_n : ¬TerminatedAt g (Nat.succ n')
s_nth_eq : Stream'.Seq.get? g.s (Nat.succ n') = some { a := a, b := b }
pa pb : K
s_n'th_eq : Stream'.Seq.get? g.s n' = some { a := pa, b := pb }
⊢ convergents g (Nat.succ n' + 1) = convergents (squashGCF g (Nat.succ n')) (Nat.succ n')

Next tactic:
let g' := squashGCF g (n' + 1)
/-- The convergents coincide in the expected way at the squashed position if the partial denominator
at the squashed position is not zero. -/
theorem succ_nth_convergent_eq_squashGCF_nth_convergent [Field K]
    (nth_part_denom_ne_zero : ∀ {b : K}, g.partialDenominators.get? n = some b → b ≠ 0) :
    g.convergents (n + 1) = (squashGCF g n).convergents n := by
  cases' Decidable.em (g.TerminatedAt n) with terminated_at_n not_terminated_at_n
  · have : squashGCF g n = g := squashGCF_eq_self_of_terminated terminated_at_n
    simp only [this, convergents_stable_of_terminated n.le_succ terminated_at_n]
  · obtain ⟨⟨a, b⟩, s_nth_eq⟩ : ∃ gp_n, g.s.get? n = some gp_n
    exact Option.ne_none_iff_exists'.mp not_terminated_at_n
    have b_ne_zero : b ≠ 0 := nth_part_denom_ne_zero (part_denom_eq_s_b s_nth_eq)
    cases' n with n'
    case zero =>
      suffices (b * g.h + a) / b = g.h + a / b by
        simpa [squashGCF, s_nth_eq, convergent_eq_conts_a_div_conts_b,
          continuants_recurrenceAux s_nth_eq zeroth_continuant_aux_eq_one_zero
            first_continuant_aux_eq_h_one]
      calc
        (b * g.h + a) / b = b * g.h / b + a / b := by ring
        -- requires `Field`, not `DivisionRing`
        _ = g.h + a / b := by rw [mul_div_cancel_left _ b_ne_zero]
    case succ =>
      obtain ⟨⟨pa, pb⟩, s_n'th_eq⟩ : ∃ gp_n', g.s.get? n' = some gp_n' :=
        g.s.ge_stable n'.le_succ s_nth_eq
      -- Notations
      let g' := squashGCF g (n' + 1)
      

Proof state:
case intro.mk
K : Type u_1
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : Field K
a b : K
b_ne_zero : b ≠ 0
n' : ℕ
nth_part_denom_ne_zero : ∀ {b : K}, Stream'.Seq.get? (partialDenominators g) (Nat.succ n') = some b → b ≠ 0
not_terminated_at_n : ¬TerminatedAt g (Nat.succ n')
s_nth_eq : Stream'.Seq.get? g.s (Nat.succ n') = some { a := a, b := b }
pa pb : K
s_n'th_eq : Stream'.Seq.get? g.s n' = some { a := pa, b := pb }
g' : GeneralizedContinuedFraction K := squashGCF g (n' + 1)
⊢ convergents g (Nat.succ n' + 1) = convergents (squashGCF g (Nat.succ n')) (Nat.succ n')

Next tactic:
set pred_conts := g.continuantsAux (n' + 1) with succ_n'th_conts_aux_eq