l3lab/ntp-mathlib huggingface dataset:
/-- 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]
  case succ =>
    

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:
cases g
/-- 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]
  case succ =>
    cases g
    

Proof state:
case mk
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : DivisionRing K
n✝ : ℕ
h✝ : K
s✝ : Stream'.Seq (Pair K)
terminated_at_n : TerminatedAt { h := h✝, s := s✝ } (Nat.succ n✝)
⊢ squashGCF { h := h✝, s := s✝ } (Nat.succ n✝) = { h := h✝, s := s✝ }

Next tactic:
simp only [squashGCF, mk.injEq, true_and]
/-- 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]
  case succ =>
    cases g
    simp only [squashGCF, mk.injEq, true_and]
    

Proof state:
case mk
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : DivisionRing K
n✝ : ℕ
h✝ : K
s✝ : Stream'.Seq (Pair K)
terminated_at_n : TerminatedAt { h := h✝, s := s✝ } (Nat.succ n✝)
⊢ squashSeq s✝ n✝ = s✝

Next tactic:
exact squashSeq_eq_self_of_terminated terminated_at_n
/-- The values before the squashed position stay the same. -/
theorem squashGCF_nth_of_lt {m : ℕ} (m_lt_n : m < n) :
    (squashGCF g (n + 1)).s.get? m = g.s.get? m := by
  

Proof state:
K : Type u_1
n : ℕ
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : DivisionRing K
m : ℕ
m_lt_n : m < n
⊢ Stream'.Seq.get? (squashGCF g (n + 1)).s m = Stream'.Seq.get? g.s m

Next tactic:
simp only [squashGCF, squashSeq_nth_of_lt m_lt_n, Nat.add_eq, add_zero]
/-- `convergents'` returns the same value for a gcf and the corresponding squashed gcf at the
squashed position. -/
theorem succ_nth_convergent'_eq_squashGCF_nth_convergent' :
    g.convergents' (n + 1) = (squashGCF g n).convergents' n := by
  

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

Next tactic:
cases n
/-- `convergents'` returns the same value for a gcf and the corresponding squashed gcf at the
squashed position. -/
theorem succ_nth_convergent'_eq_squashGCF_nth_convergent' :
    g.convergents' (n + 1) = (squashGCF g n).convergents' n := by
  cases n
  

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

Next tactic:
case zero =>
    cases g_s_head_eq : g.s.get? 0 <;>
      simp [g_s_head_eq, squashGCF, convergents', convergents'Aux, Stream'.Seq.head]
/-- `convergents'` returns the same value for a gcf and the corresponding squashed gcf at the
squashed position. -/
theorem succ_nth_convergent'_eq_squashGCF_nth_convergent' :
    g.convergents' (n + 1) = (squashGCF g n).convergents' n := by
  cases n
  

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

Next tactic:
case zero =>
    cases g_s_head_eq : g.s.get? 0 <;>
      simp [g_s_head_eq, squashGCF, convergents', convergents'Aux, Stream'.Seq.head]
/-- `convergents'` returns the same value for a gcf and the corresponding squashed gcf at the
squashed position. -/
theorem succ_nth_convergent'_eq_squashGCF_nth_convergent' :
    g.convergents' (n + 1) = (squashGCF g n).convergents' n := by
  cases n
  case zero =>
    

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

Next tactic:
cases g_s_head_eq : g.s.get? 0
/-- `convergents'` returns the same value for a gcf and the corresponding squashed gcf at the
squashed position. -/
theorem succ_nth_convergent'_eq_squashGCF_nth_convergent' :
    g.convergents' (n + 1) = (squashGCF g n).convergents' n := by
  cases n
  case zero =>
    cases g_s_head_eq : g.s.get? 0 <;>
      

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

Next tactic:
simp [g_s_head_eq, squashGCF, convergents', convergents'Aux, Stream'.Seq.head]
/-- `convergents'` returns the same value for a gcf and the corresponding squashed gcf at the
squashed position. -/
theorem succ_nth_convergent'_eq_squashGCF_nth_convergent' :
    g.convergents' (n + 1) = (squashGCF g n).convergents' n := by
  cases n
  case zero =>
    cases g_s_head_eq : g.s.get? 0 <;>
      

Proof state:
case some
K : Type u_1
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : DivisionRing K
val✝ : Pair K
g_s_head_eq : Stream'.Seq.get? g.s 0 = some val✝
⊢ convergents' g (Nat.zero + 1) = convergents' (squashGCF g Nat.zero) Nat.zero

Next tactic:
simp [g_s_head_eq, squashGCF, convergents', convergents'Aux, Stream'.Seq.head]
/-- `convergents'` returns the same value for a gcf and the corresponding squashed gcf at the
squashed position. -/
theorem succ_nth_convergent'_eq_squashGCF_nth_convergent' :
    g.convergents' (n + 1) = (squashGCF g n).convergents' n := by
  cases n
  case zero =>
    cases g_s_head_eq : g.s.get? 0 <;>
      simp [g_s_head_eq, squashGCF, convergents', convergents'Aux, Stream'.Seq.head]
  

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

Next tactic:
case succ =>
    simp only [succ_succ_nth_convergent'_aux_eq_succ_nth_convergent'_aux_squashSeq, convergents',
      squashGCF]
/-- `convergents'` returns the same value for a gcf and the corresponding squashed gcf at the
squashed position. -/
theorem succ_nth_convergent'_eq_squashGCF_nth_convergent' :
    g.convergents' (n + 1) = (squashGCF g n).convergents' n := by
  cases n
  case zero =>
    cases g_s_head_eq : g.s.get? 0 <;>
      simp [g_s_head_eq, squashGCF, convergents', convergents'Aux, Stream'.Seq.head]
  

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

Next tactic:
case succ =>
    simp only [succ_succ_nth_convergent'_aux_eq_succ_nth_convergent'_aux_squashSeq, convergents',
      squashGCF]
/-- `convergents'` returns the same value for a gcf and the corresponding squashed gcf at the
squashed position. -/
theorem succ_nth_convergent'_eq_squashGCF_nth_convergent' :
    g.convergents' (n + 1) = (squashGCF g n).convergents' n := by
  cases n
  case zero =>
    cases g_s_head_eq : g.s.get? 0 <;>
      simp [g_s_head_eq, squashGCF, convergents', convergents'Aux, Stream'.Seq.head]
  case succ =>
    

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

Next tactic:
simp only [succ_succ_nth_convergent'_aux_eq_succ_nth_convergent'_aux_squashSeq, convergents',
      squashGCF]
/-- The auxiliary continuants before the squashed position stay the same. -/
theorem continuantsAux_eq_continuantsAux_squashGCF_of_le {m : ℕ} :
    m ≤ n → continuantsAux g m = (squashGCF g n).continuantsAux m :=
  Nat.strong_induction_on m
    (by
      

Proof state:
K : Type u_1
n : ℕ
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : DivisionRing K
m : ℕ
⊢ ∀ (n_1 : ℕ),
    (∀ m < n_1, m ≤ n → continuantsAux g m = continuantsAux (squashGCF g n) m) →
      n_1 ≤ n → continuantsAux g n_1 = continuantsAux (squashGCF g n) n_1

Next tactic:
clear m
/-- The auxiliary continuants before the squashed position stay the same. -/
theorem continuantsAux_eq_continuantsAux_squashGCF_of_le {m : ℕ} :
    m ≤ n → continuantsAux g m = (squashGCF g n).continuantsAux m :=
  Nat.strong_induction_on m
    (by
      clear m
      

Proof state:
K : Type u_1
n : ℕ
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : DivisionRing K
⊢ ∀ (n_1 : ℕ),
    (∀ m < n_1, m ≤ n → continuantsAux g m = continuantsAux (squashGCF g n) m) →
      n_1 ≤ n → continuantsAux g n_1 = continuantsAux (squashGCF g n) n_1

Next tactic:
intro m IH m_le_n
/-- The auxiliary continuants before the squashed position stay the same. -/
theorem continuantsAux_eq_continuantsAux_squashGCF_of_le {m : ℕ} :
    m ≤ n → continuantsAux g m = (squashGCF g n).continuantsAux m :=
  Nat.strong_induction_on m
    (by
      clear m
      intro m IH m_le_n
      

Proof state:
K : Type u_1
n : ℕ
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : DivisionRing K
m : ℕ
IH : ∀ m_1 < m, m_1 ≤ n → continuantsAux g m_1 = continuantsAux (squashGCF g n) m_1
m_le_n : m ≤ n
⊢ continuantsAux g m = continuantsAux (squashGCF g n) m

Next tactic:
cases' m with m'
/-- The auxiliary continuants before the squashed position stay the same. -/
theorem continuantsAux_eq_continuantsAux_squashGCF_of_le {m : ℕ} :
    m ≤ n → continuantsAux g m = (squashGCF g n).continuantsAux m :=
  Nat.strong_induction_on m
    (by
      clear m
      intro m IH m_le_n
      cases' m with m'
      · 

Proof state:
case zero
K : Type u_1
n : ℕ
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : DivisionRing K
IH : ∀ m < Nat.zero, m ≤ n → continuantsAux g m = continuantsAux (squashGCF g n) m
m_le_n : Nat.zero ≤ n
⊢ continuantsAux g Nat.zero = continuantsAux (squashGCF g n) Nat.zero

Next tactic:
rfl
/-- The auxiliary continuants before the squashed position stay the same. -/
theorem continuantsAux_eq_continuantsAux_squashGCF_of_le {m : ℕ} :
    m ≤ n → continuantsAux g m = (squashGCF g n).continuantsAux m :=
  Nat.strong_induction_on m
    (by
      clear m
      intro m IH m_le_n
      cases' m with m'
      · rfl
      · 

Proof state:
case succ
K : Type u_1
n : ℕ
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : DivisionRing K
m' : ℕ
IH : ∀ m < Nat.succ m', m ≤ n → continuantsAux g m = continuantsAux (squashGCF g n) m
m_le_n : Nat.succ m' ≤ n
⊢ continuantsAux g (Nat.succ m') = continuantsAux (squashGCF g n) (Nat.succ m')

Next tactic:
cases' n with n'
/-- The auxiliary continuants before the squashed position stay the same. -/
theorem continuantsAux_eq_continuantsAux_squashGCF_of_le {m : ℕ} :
    m ≤ n → continuantsAux g m = (squashGCF g n).continuantsAux m :=
  Nat.strong_induction_on m
    (by
      clear m
      intro m IH m_le_n
      cases' m with m'
      · rfl
      · cases' n with n'
        · 

Proof state:
case succ.zero
K : Type u_1
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : DivisionRing K
m' : ℕ
IH : ∀ m < Nat.succ m', m ≤ Nat.zero → continuantsAux g m = continuantsAux (squashGCF g Nat.zero) m
m_le_n : Nat.succ m' ≤ Nat.zero
⊢ continuantsAux g (Nat.succ m') = continuantsAux (squashGCF g Nat.zero) (Nat.succ m')

Next tactic:
exact (m'.not_succ_le_zero m_le_n).elim
/-- The auxiliary continuants before the squashed position stay the same. -/
theorem continuantsAux_eq_continuantsAux_squashGCF_of_le {m : ℕ} :
    m ≤ n → continuantsAux g m = (squashGCF g n).continuantsAux m :=
  Nat.strong_induction_on m
    (by
      clear m
      intro m IH m_le_n
      cases' m with m'
      · rfl
      · cases' n with n'
        · exact (m'.not_succ_le_zero m_le_n).elim
        -- 1 ≰ 0
        · 

Proof state:
case succ.succ
K : Type u_1
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : DivisionRing K
m' n' : ℕ
IH : ∀ m < Nat.succ m', m ≤ Nat.succ n' → continuantsAux g m = continuantsAux (squashGCF g (Nat.succ n')) m
m_le_n : Nat.succ m' ≤ Nat.succ n'
⊢ continuantsAux g (Nat.succ m') = continuantsAux (squashGCF g (Nat.succ n')) (Nat.succ m')

Next tactic:
cases' m' with m''
/-- The auxiliary continuants before the squashed position stay the same. -/
theorem continuantsAux_eq_continuantsAux_squashGCF_of_le {m : ℕ} :
    m ≤ n → continuantsAux g m = (squashGCF g n).continuantsAux m :=
  Nat.strong_induction_on m
    (by
      clear m
      intro m IH m_le_n
      cases' m with m'
      · rfl
      · cases' n with n'
        · exact (m'.not_succ_le_zero m_le_n).elim
        -- 1 ≰ 0
        · cases' m' with m''
          · 

Proof state:
case succ.succ.zero
K : Type u_1
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : DivisionRing K
n' : ℕ
IH : ∀ m < Nat.succ Nat.zero, m ≤ Nat.succ n' → continuantsAux g m = continuantsAux (squashGCF g (Nat.succ n')) m
m_le_n : Nat.succ Nat.zero ≤ Nat.succ n'
⊢ continuantsAux g (Nat.succ Nat.zero) = continuantsAux (squashGCF g (Nat.succ n')) (Nat.succ Nat.zero)

Next tactic:
rfl
/-- The auxiliary continuants before the squashed position stay the same. -/
theorem continuantsAux_eq_continuantsAux_squashGCF_of_le {m : ℕ} :
    m ≤ n → continuantsAux g m = (squashGCF g n).continuantsAux m :=
  Nat.strong_induction_on m
    (by
      clear m
      intro m IH m_le_n
      cases' m with m'
      · rfl
      · cases' n with n'
        · exact (m'.not_succ_le_zero m_le_n).elim
        -- 1 ≰ 0
        · cases' m' with m''
          · rfl
          · -- get some inequalities to instantiate the IH for m'' and m'' + 1
            

Proof state:
case succ.succ.succ
K : Type u_1
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : DivisionRing K
n' m'' : ℕ
IH : ∀ m < Nat.succ (Nat.succ m''), m ≤ Nat.succ n' → continuantsAux g m = continuantsAux (squashGCF g (Nat.succ n')) m
m_le_n : Nat.succ (Nat.succ m'') ≤ Nat.succ n'
⊢ continuantsAux g (Nat.succ (Nat.succ m'')) = continuantsAux (squashGCF g (Nat.succ n')) (Nat.succ (Nat.succ m''))

Next tactic:
have m'_lt_n : m'' + 1 < n' + 1 := m_le_n
/-- The auxiliary continuants before the squashed position stay the same. -/
theorem continuantsAux_eq_continuantsAux_squashGCF_of_le {m : ℕ} :
    m ≤ n → continuantsAux g m = (squashGCF g n).continuantsAux m :=
  Nat.strong_induction_on m
    (by
      clear m
      intro m IH m_le_n
      cases' m with m'
      · rfl
      · cases' n with n'
        · exact (m'.not_succ_le_zero m_le_n).elim
        -- 1 ≰ 0
        · cases' m' with m''
          · rfl
          · -- get some inequalities to instantiate the IH for m'' and m'' + 1
            have m'_lt_n : m'' + 1 < n' + 1 := m_le_n
            

Proof state:
case succ.succ.succ
K : Type u_1
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : DivisionRing K
n' m'' : ℕ
IH : ∀ m < Nat.succ (Nat.succ m''), m ≤ Nat.succ n' → continuantsAux g m = continuantsAux (squashGCF g (Nat.succ n')) m
m_le_n : Nat.succ (Nat.succ m'') ≤ Nat.succ n'
m'_lt_n : m'' + 1 < n' + 1
⊢ continuantsAux g (Nat.succ (Nat.succ m'')) = continuantsAux (squashGCF g (Nat.succ n')) (Nat.succ (Nat.succ m''))

Next tactic:
have succ_m''th_conts_aux_eq := IH (m'' + 1) (lt_add_one (m'' + 1)) m'_lt_n.le
/-- The auxiliary continuants before the squashed position stay the same. -/
theorem continuantsAux_eq_continuantsAux_squashGCF_of_le {m : ℕ} :
    m ≤ n → continuantsAux g m = (squashGCF g n).continuantsAux m :=
  Nat.strong_induction_on m
    (by
      clear m
      intro m IH m_le_n
      cases' m with m'
      · rfl
      · cases' n with n'
        · exact (m'.not_succ_le_zero m_le_n).elim
        -- 1 ≰ 0
        · cases' m' with m''
          · rfl
          · -- get some inequalities to instantiate the IH for m'' and m'' + 1
            have m'_lt_n : m'' + 1 < n' + 1 := m_le_n
            have succ_m''th_conts_aux_eq := IH (m'' + 1) (lt_add_one (m'' + 1)) m'_lt_n.le
            

Proof state:
case succ.succ.succ
K : Type u_1
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : DivisionRing K
n' m'' : ℕ
IH : ∀ m < Nat.succ (Nat.succ m''), m ≤ Nat.succ n' → continuantsAux g m = continuantsAux (squashGCF g (Nat.succ n')) m
m_le_n : Nat.succ (Nat.succ m'') ≤ Nat.succ n'
m'_lt_n : m'' + 1 < n' + 1
succ_m''th_conts_aux_eq : continuantsAux g (m'' + 1) = continuantsAux (squashGCF g (Nat.succ n')) (m'' + 1)
⊢ continuantsAux g (Nat.succ (Nat.succ m'')) = continuantsAux (squashGCF g (Nat.succ n')) (Nat.succ (Nat.succ m''))

Next tactic:
have : m'' < m'' + 2 := lt_add_of_pos_right m'' zero_lt_two
/-- The auxiliary continuants before the squashed position stay the same. -/
theorem continuantsAux_eq_continuantsAux_squashGCF_of_le {m : ℕ} :
    m ≤ n → continuantsAux g m = (squashGCF g n).continuantsAux m :=
  Nat.strong_induction_on m
    (by
      clear m
      intro m IH m_le_n
      cases' m with m'
      · rfl
      · cases' n with n'
        · exact (m'.not_succ_le_zero m_le_n).elim
        -- 1 ≰ 0
        · cases' m' with m''
          · rfl
          · -- get some inequalities to instantiate the IH for m'' and m'' + 1
            have m'_lt_n : m'' + 1 < n' + 1 := m_le_n
            have succ_m''th_conts_aux_eq := IH (m'' + 1) (lt_add_one (m'' + 1)) m'_lt_n.le
            have : m'' < m'' + 2 := lt_add_of_pos_right m'' zero_lt_two
            

Proof state:
case succ.succ.succ
K : Type u_1
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : DivisionRing K
n' m'' : ℕ
IH : ∀ m < Nat.succ (Nat.succ m''), m ≤ Nat.succ n' → continuantsAux g m = continuantsAux (squashGCF g (Nat.succ n')) m
m_le_n : Nat.succ (Nat.succ m'') ≤ Nat.succ n'
m'_lt_n : m'' + 1 < n' + 1
succ_m''th_conts_aux_eq : continuantsAux g (m'' + 1) = continuantsAux (squashGCF g (Nat.succ n')) (m'' + 1)
this : m'' < m'' + 2
⊢ continuantsAux g (Nat.succ (Nat.succ m'')) = continuantsAux (squashGCF g (Nat.succ n')) (Nat.succ (Nat.succ m''))

Next tactic:
have m''th_conts_aux_eq := IH m'' this (le_trans this.le m_le_n)
/-- The auxiliary continuants before the squashed position stay the same. -/
theorem continuantsAux_eq_continuantsAux_squashGCF_of_le {m : ℕ} :
    m ≤ n → continuantsAux g m = (squashGCF g n).continuantsAux m :=
  Nat.strong_induction_on m
    (by
      clear m
      intro m IH m_le_n
      cases' m with m'
      · rfl
      · cases' n with n'
        · exact (m'.not_succ_le_zero m_le_n).elim
        -- 1 ≰ 0
        · cases' m' with m''
          · rfl
          · -- get some inequalities to instantiate the IH for m'' and m'' + 1
            have m'_lt_n : m'' + 1 < n' + 1 := m_le_n
            have succ_m''th_conts_aux_eq := IH (m'' + 1) (lt_add_one (m'' + 1)) m'_lt_n.le
            have : m'' < m'' + 2 := lt_add_of_pos_right m'' zero_lt_two
            have m''th_conts_aux_eq := IH m'' this (le_trans this.le m_le_n)
            

Proof state:
case succ.succ.succ
K : Type u_1
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : DivisionRing K
n' m'' : ℕ
IH : ∀ m < Nat.succ (Nat.succ m''), m ≤ Nat.succ n' → continuantsAux g m = continuantsAux (squashGCF g (Nat.succ n')) m
m_le_n : Nat.succ (Nat.succ m'') ≤ Nat.succ n'
m'_lt_n : m'' + 1 < n' + 1
succ_m''th_conts_aux_eq : continuantsAux g (m'' + 1) = continuantsAux (squashGCF g (Nat.succ n')) (m'' + 1)
this : m'' < m'' + 2
m''th_conts_aux_eq : continuantsAux g m'' = continuantsAux (squashGCF g (Nat.succ n')) m''
⊢ continuantsAux g (Nat.succ (Nat.succ m'')) = continuantsAux (squashGCF g (Nat.succ n')) (Nat.succ (Nat.succ m''))

Next tactic:
have : (squashGCF g (n' + 1)).s.get? m'' = g.s.get? m'' :=
              squashGCF_nth_of_lt (Nat.succ_lt_succ_iff.mp m'_lt_n)
/-- The auxiliary continuants before the squashed position stay the same. -/
theorem continuantsAux_eq_continuantsAux_squashGCF_of_le {m : ℕ} :
    m ≤ n → continuantsAux g m = (squashGCF g n).continuantsAux m :=
  Nat.strong_induction_on m
    (by
      clear m
      intro m IH m_le_n
      cases' m with m'
      · rfl
      · cases' n with n'
        · exact (m'.not_succ_le_zero m_le_n).elim
        -- 1 ≰ 0
        · cases' m' with m''
          · rfl
          · -- get some inequalities to instantiate the IH for m'' and m'' + 1
            have m'_lt_n : m'' + 1 < n' + 1 := m_le_n
            have succ_m''th_conts_aux_eq := IH (m'' + 1) (lt_add_one (m'' + 1)) m'_lt_n.le
            have : m'' < m'' + 2 := lt_add_of_pos_right m'' zero_lt_two
            have m''th_conts_aux_eq := IH m'' this (le_trans this.le m_le_n)
            have : (squashGCF g (n' + 1)).s.get? m'' = g.s.get? m'' :=
              squashGCF_nth_of_lt (Nat.succ_lt_succ_iff.mp m'_lt_n)
            

Proof state:
case succ.succ.succ
K : Type u_1
g : GeneralizedContinuedFraction K
s : Stream'.Seq (Pair K)
inst✝ : DivisionRing K
n' m'' : ℕ
IH : ∀ m < Nat.succ (Nat.succ m''), m ≤ Nat.succ n' → continuantsAux g m = continuantsAux (squashGCF g (Nat.succ n')) m
m_le_n : Nat.succ (Nat.succ m'') ≤ Nat.succ n'
m'_lt_n : m'' + 1 < n' + 1
succ_m''th_conts_aux_eq : continuantsAux g (m'' + 1) = continuantsAux (squashGCF g (Nat.succ n')) (m'' + 1)
this✝ : m'' < m'' + 2
m''th_conts_aux_eq : continuantsAux g m'' = continuantsAux (squashGCF g (Nat.succ n')) m''
this : Stream'.Seq.get? (squashGCF g (n' + 1)).s m'' = Stream'.Seq.get? g.s m''
⊢ continuantsAux g (Nat.succ (Nat.succ m'')) = continuantsAux (squashGCF g (Nat.succ n')) (Nat.succ (Nat.succ m''))

Next tactic:
simp [continuantsAux, succ_m''th_conts_aux_eq, m''th_conts_aux_eq, this]
/-- 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
  

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
⊢ convergents g (n + 1) = convergents (squashGCF g n) n

Next tactic:
cases' Decidable.em (g.TerminatedAt n) with terminated_at_n 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
  · 

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
⊢ convergents g (n + 1) = convergents (squashGCF g n) n

Next tactic:
have : squashGCF g n = g := squashGCF_eq_self_of_terminated terminated_at_n