Theorem: GeneralizedContinuedFraction.convergents_eq_convergents'
File: Mathlib/Algebra/ContinuedFractions/ConvergentsEquiv.lean

tactic: simp
state_before: case zero
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
g : GeneralizedContinuedFraction K
s_pos : ∀ {gp : Pair K} {m : ℕ}, m < 0 → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b
⊢ g.convergents 0 = g.convergents' 0
state_after: no goals

tactic: let g' := squashGCF g n
state_before: case succ
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
n : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m : ℕ}, m < n → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b) → g.convergents n = g.convergents' n
g : GeneralizedContinuedFraction K
s_pos : ∀ {gp : Pair K} {m : ℕ}, m < n + 1 → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b
⊢ g.convergents (n + 1) = g.convergents' (n + 1)
state_after: case succ
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
n : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m : ℕ}, m < n → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b) → g.convergents n = g.convergents' n
g : GeneralizedContinuedFraction K
s_pos : ∀ {gp : Pair K} {m : ℕ}, m < n + 1 → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF n
⊢ g.convergents (n + 1) = g.convergents' (n + 1)

tactic: suffices g.convergents (n + 1) = g'.convergents' n by
  rwa [succ_nth_convergent'_eq_squashGCF_nth_convergent']
state_before: case succ
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
n : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m : ℕ}, m < n → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b) → g.convergents n = g.convergents' n
g : GeneralizedContinuedFraction K
s_pos : ∀ {gp : Pair K} {m : ℕ}, m < n + 1 → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF n
⊢ g.convergents (n + 1) = g.convergents' (n + 1)
state_after: case succ
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
n : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m : ℕ}, m < n → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b) → g.convergents n = g.convergents' n
g : GeneralizedContinuedFraction K
s_pos : ∀ {gp : Pair K} {m : ℕ}, m < n + 1 → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF n
⊢ g.convergents (n + 1) = g'.convergents' n

tactic: cases' Decidable.em (TerminatedAt g n) with terminated_at_n not_terminated_at_n
state_before: case succ
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
n : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m : ℕ}, m < n → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b) → g.convergents n = g.convergents' n
g : GeneralizedContinuedFraction K
s_pos : ∀ {gp : Pair K} {m : ℕ}, m < n + 1 → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF n
⊢ g.convergents (n + 1) = g'.convergents' n
state_after: case succ.inl
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
n : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m : ℕ}, m < n → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b) → g.convergents n = g.convergents' n
g : GeneralizedContinuedFraction K
s_pos : ∀ {gp : Pair K} {m : ℕ}, m < n + 1 → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF n
terminated_at_n : g.TerminatedAt n
⊢ g.convergents (n + 1) = g'.convergents' n

case succ.inr
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
n : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m : ℕ}, m < n → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b) → g.convergents n = g.convergents' n
g : GeneralizedContinuedFraction K
s_pos : ∀ {gp : Pair K} {m : ℕ}, m < n + 1 → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF n
not_terminated_at_n : ¬g.TerminatedAt n
⊢ g.convergents (n + 1) = g'.convergents' n

tactic: rwa [succ_nth_convergent'_eq_squashGCF_nth_convergent']
state_before: K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
n : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m : ℕ}, m < n → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b) → g.convergents n = g.convergents' n
g : GeneralizedContinuedFraction K
s_pos : ∀ {gp : Pair K} {m : ℕ}, m < n + 1 → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF n
this : g.convergents (n + 1) = g'.convergents' n
⊢ g.convergents (n + 1) = g.convergents' (n + 1)
state_after: no goals

tactic: have g'_eq_g : g' = g := squashGCF_eq_self_of_terminated terminated_at_n
state_before: case succ.inl
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
n : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m : ℕ}, m < n → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b) → g.convergents n = g.convergents' n
g : GeneralizedContinuedFraction K
s_pos : ∀ {gp : Pair K} {m : ℕ}, m < n + 1 → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF n
terminated_at_n : g.TerminatedAt n
⊢ g.convergents (n + 1) = g'.convergents' n
state_after: case succ.inl
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
n : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m : ℕ}, m < n → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b) → g.convergents n = g.convergents' n
g : GeneralizedContinuedFraction K
s_pos : ∀ {gp : Pair K} {m : ℕ}, m < n + 1 → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF n
terminated_at_n : g.TerminatedAt n
g'_eq_g : g' = g
⊢ g.convergents (n + 1) = g'.convergents' n

tactic: rw [convergents_stable_of_terminated n.le_succ terminated_at_n, g'_eq_g, IH _]
state_before: case succ.inl
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
n : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m : ℕ}, m < n → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b) → g.convergents n = g.convergents' n
g : GeneralizedContinuedFraction K
s_pos : ∀ {gp : Pair K} {m : ℕ}, m < n + 1 → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF n
terminated_at_n : g.TerminatedAt n
g'_eq_g : g' = g
⊢ g.convergents (n + 1) = g'.convergents' n
state_after: K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
n : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m : ℕ}, m < n → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b) → g.convergents n = g.convergents' n
g : GeneralizedContinuedFraction K
s_pos : ∀ {gp : Pair K} {m : ℕ}, m < n + 1 → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF n
terminated_at_n : g.TerminatedAt n
g'_eq_g : g' = g
⊢ ∀ {gp : Pair K} {m : ℕ}, m < n → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b

tactic: intro _ _ m_lt_n s_mth_eq
state_before: K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
n : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m : ℕ}, m < n → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b) → g.convergents n = g.convergents' n
g : GeneralizedContinuedFraction K
s_pos : ∀ {gp : Pair K} {m : ℕ}, m < n + 1 → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF n
terminated_at_n : g.TerminatedAt n
g'_eq_g : g' = g
⊢ ∀ {gp : Pair K} {m : ℕ}, m < n → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b
state_after: K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
n : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m : ℕ}, m < n → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b) → g.convergents n = g.convergents' n
g : GeneralizedContinuedFraction K
s_pos : ∀ {gp : Pair K} {m : ℕ}, m < n + 1 → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF n
terminated_at_n : g.TerminatedAt n
g'_eq_g : g' = g
gp✝ : Pair K
m✝ : ℕ
m_lt_n : m✝ < n
s_mth_eq : g.s.get? m✝ = some gp✝
⊢ 0 < gp✝.a ∧ 0 < gp✝.b

tactic: exact s_pos (Nat.lt.step m_lt_n) s_mth_eq
state_before: K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
n : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m : ℕ}, m < n → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b) → g.convergents n = g.convergents' n
g : GeneralizedContinuedFraction K
s_pos : ∀ {gp : Pair K} {m : ℕ}, m < n + 1 → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF n
terminated_at_n : g.TerminatedAt n
g'_eq_g : g' = g
gp✝ : Pair K
m✝ : ℕ
m_lt_n : m✝ < n
s_mth_eq : g.s.get? m✝ = some gp✝
⊢ 0 < gp✝.a ∧ 0 < gp✝.b
state_after: no goals

tactic: have : ∀ ⦃b⦄, g.partialDenominators.get? n = some b → b ≠ 0 := by
  intro b nth_part_denom_eq
  obtain ⟨gp, s_nth_eq, ⟨refl⟩⟩ : ∃ gp, g.s.get? n = some gp ∧ gp.b = b :=
    exists_s_b_of_part_denom nth_part_denom_eq
  exact (ne_of_lt (s_pos (lt_add_one n) s_nth_eq).right).symm
state_before: case succ.inr
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
n : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m : ℕ}, m < n → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b) → g.convergents n = g.convergents' n
g : GeneralizedContinuedFraction K
s_pos : ∀ {gp : Pair K} {m : ℕ}, m < n + 1 → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF n
not_terminated_at_n : ¬g.TerminatedAt n
⊢ g.convergents (n + 1) = g'.convergents n
state_after: case succ.inr
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
n : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m : ℕ}, m < n → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b) → g.convergents n = g.convergents' n
g : GeneralizedContinuedFraction K
s_pos : ∀ {gp : Pair K} {m : ℕ}, m < n + 1 → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF n
not_terminated_at_n : ¬g.TerminatedAt n
this : ∀ ⦃b : K⦄, g.partialDenominators.get? n = some b → b ≠ 0
⊢ g.convergents (n + 1) = g'.convergents n

tactic: exact succ_nth_convergent_eq_squashGCF_nth_convergent @this
state_before: case succ.inr
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
n : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m : ℕ}, m < n → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b) → g.convergents n = g.convergents' n
g : GeneralizedContinuedFraction K
s_pos : ∀ {gp : Pair K} {m : ℕ}, m < n + 1 → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF n
not_terminated_at_n : ¬g.TerminatedAt n
this : ∀ ⦃b : K⦄, g.partialDenominators.get? n = some b → b ≠ 0
⊢ g.convergents (n + 1) = g'.convergents n
state_after: no goals

tactic: rwa [← IH]
state_before: K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
n : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m : ℕ}, m < n → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b) → g.convergents n = g.convergents' n
g : GeneralizedContinuedFraction K
s_pos : ∀ {gp : Pair K} {m : ℕ}, m < n + 1 → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF n
not_terminated_at_n : ¬g.TerminatedAt n
this : g.convergents (n + 1) = g'.convergents n
⊢ g.convergents (n + 1) = g'.convergents' n
state_after: K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
n : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m : ℕ}, m < n → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b) → g.convergents n = g.convergents' n
g : GeneralizedContinuedFraction K
s_pos : ∀ {gp : Pair K} {m : ℕ}, m < n + 1 → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF n
not_terminated_at_n : ¬g.TerminatedAt n
this : g.convergents (n + 1) = g'.convergents n
⊢ ∀ {gp : Pair K} {m : ℕ}, m < n → g'.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b

tactic: intro gp' m m_lt_n s_mth_eq'
state_before: K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
n : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m : ℕ}, m < n → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b) → g.convergents n = g.convergents' n
g : GeneralizedContinuedFraction K
s_pos : ∀ {gp : Pair K} {m : ℕ}, m < n + 1 → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF n
not_terminated_at_n : ¬g.TerminatedAt n
this : g.convergents (n + 1) = g'.convergents n
⊢ ∀ {gp : Pair K} {m : ℕ}, m < n → g'.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b
state_after: K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
n : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m : ℕ}, m < n → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b) → g.convergents n = g.convergents' n
g : GeneralizedContinuedFraction K
s_pos : ∀ {gp : Pair K} {m : ℕ}, m < n + 1 → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF n
not_terminated_at_n : ¬g.TerminatedAt n
this : g.convergents (n + 1) = g'.convergents n
gp' : Pair K
m : ℕ
m_lt_n : m < n
s_mth_eq' : g'.s.get? m = some gp'
⊢ 0 < gp'.a ∧ 0 < gp'.b

tactic: cases' m_lt_n with n succ_m_lt_n
state_before: K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
n : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m : ℕ}, m < n → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b) → g.convergents n = g.convergents' n
g : GeneralizedContinuedFraction K
s_pos : ∀ {gp : Pair K} {m : ℕ}, m < n + 1 → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF n
not_terminated_at_n : ¬g.TerminatedAt n
this : g.convergents (n + 1) = g'.convergents n
gp' : Pair K
m : ℕ
m_lt_n : m < n
s_mth_eq' : g'.s.get? m = some gp'
⊢ 0 < gp'.a ∧ 0 < gp'.b
state_after: case refl
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
g : GeneralizedContinuedFraction K
gp' : Pair K
m : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b) →
      g.convergents m.succ = g.convergents' m.succ
s_pos : ∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ + 1 → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF m.succ
not_terminated_at_n : ¬g.TerminatedAt m.succ
this : g.convergents (m.succ + 1) = g'.convergents m.succ
s_mth_eq' : g'.s.get? m = some gp'
⊢ 0 < gp'.a ∧ 0 < gp'.b

case step
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
g : GeneralizedContinuedFraction K
gp' : Pair K
m n : ℕ
succ_m_lt_n : m.succ.le n
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m : ℕ}, m < n.succ → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b) →
      g.convergents n.succ = g.convergents' n.succ
s_pos : ∀ {gp : Pair K} {m : ℕ}, m < n.succ + 1 → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF n.succ
not_terminated_at_n : ¬g.TerminatedAt n.succ
this : g.convergents (n.succ + 1) = g'.convergents n.succ
s_mth_eq' : g'.s.get? m = some gp'
⊢ 0 < gp'.a ∧ 0 < gp'.b

tactic: obtain ⟨gp_succ_m, s_succ_mth_eq⟩ : ∃ gp_succ_m, g.s.get? (m + 1) = some gp_succ_m :=
  Option.ne_none_iff_exists'.mp not_terminated_at_n
state_before: case refl
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
g : GeneralizedContinuedFraction K
gp' : Pair K
m : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b) →
      g.convergents m.succ = g.convergents' m.succ
s_pos : ∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ + 1 → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF m.succ
not_terminated_at_n : ¬g.TerminatedAt m.succ
this : g.convergents (m.succ + 1) = g'.convergents m.succ
s_mth_eq' : g'.s.get? m = some gp'
⊢ 0 < gp'.a ∧ 0 < gp'.b
state_after: case refl.intro
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
g : GeneralizedContinuedFraction K
gp' : Pair K
m : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b) →
      g.convergents m.succ = g.convergents' m.succ
s_pos : ∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ + 1 → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF m.succ
not_terminated_at_n : ¬g.TerminatedAt m.succ
this : g.convergents (m.succ + 1) = g'.convergents m.succ
s_mth_eq' : g'.s.get? m = some gp'
gp_succ_m : Pair K
s_succ_mth_eq : g.s.get? (m + 1) = some gp_succ_m
⊢ 0 < gp'.a ∧ 0 < gp'.b

tactic: obtain ⟨gp_m, mth_s_eq⟩ : ∃ gp_m, g.s.get? m = some gp_m :=
  g.s.ge_stable m.le_succ s_succ_mth_eq
state_before: case refl.intro
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
g : GeneralizedContinuedFraction K
gp' : Pair K
m : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b) →
      g.convergents m.succ = g.convergents' m.succ
s_pos : ∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ + 1 → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF m.succ
not_terminated_at_n : ¬g.TerminatedAt m.succ
this : g.convergents (m.succ + 1) = g'.convergents m.succ
s_mth_eq' : g'.s.get? m = some gp'
gp_succ_m : Pair K
s_succ_mth_eq : g.s.get? (m + 1) = some gp_succ_m
⊢ 0 < gp'.a ∧ 0 < gp'.b
state_after: case refl.intro.intro
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
g : GeneralizedContinuedFraction K
gp' : Pair K
m : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b) →
      g.convergents m.succ = g.convergents' m.succ
s_pos : ∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ + 1 → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF m.succ
not_terminated_at_n : ¬g.TerminatedAt m.succ
this : g.convergents (m.succ + 1) = g'.convergents m.succ
s_mth_eq' : g'.s.get? m = some gp'
gp_succ_m : Pair K
s_succ_mth_eq : g.s.get? (m + 1) = some gp_succ_m
gp_m : Pair K
mth_s_eq : g.s.get? m = some gp_m
⊢ 0 < gp'.a ∧ 0 < gp'.b

tactic: suffices 0 < gp_m.a ∧ 0 < gp_m.b + gp_succ_m.a / gp_succ_m.b by
  have ot : g'.s.get? m = some ⟨gp_m.a, gp_m.b + gp_succ_m.a / gp_succ_m.b⟩ :=
    squashSeq_nth_of_not_terminated mth_s_eq s_succ_mth_eq
  have : gp' = ⟨gp_m.a, gp_m.b + gp_succ_m.a / gp_succ_m.b⟩ := by
    simp_all only [Option.some.injEq]
  rwa [this]
state_before: case refl.intro.intro
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
g : GeneralizedContinuedFraction K
gp' : Pair K
m : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b) →
      g.convergents m.succ = g.convergents' m.succ
s_pos : ∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ + 1 → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF m.succ
not_terminated_at_n : ¬g.TerminatedAt m.succ
this : g.convergents (m.succ + 1) = g'.convergents m.succ
s_mth_eq' : g'.s.get? m = some gp'
gp_succ_m : Pair K
s_succ_mth_eq : g.s.get? (m + 1) = some gp_succ_m
gp_m : Pair K
mth_s_eq : g.s.get? m = some gp_m
⊢ 0 < gp'.a ∧ 0 < gp'.b
state_after: case refl.intro.intro
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
g : GeneralizedContinuedFraction K
gp' : Pair K
m : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b) →
      g.convergents m.succ = g.convergents' m.succ
s_pos : ∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ + 1 → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF m.succ
not_terminated_at_n : ¬g.TerminatedAt m.succ
this : g.convergents (m.succ + 1) = g'.convergents m.succ
s_mth_eq' : g'.s.get? m = some gp'
gp_succ_m : Pair K
s_succ_mth_eq : g.s.get? (m + 1) = some gp_succ_m
gp_m : Pair K
mth_s_eq : g.s.get? m = some gp_m
⊢ 0 < gp_m.a ∧ 0 < gp_m.b + gp_succ_m.a / gp_succ_m.b

tactic: have m_lt_n : m < m.succ := Nat.lt_succ_self m
state_before: case refl.intro.intro
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
g : GeneralizedContinuedFraction K
gp' : Pair K
m : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b) →
      g.convergents m.succ = g.convergents' m.succ
s_pos : ∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ + 1 → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF m.succ
not_terminated_at_n : ¬g.TerminatedAt m.succ
this : g.convergents (m.succ + 1) = g'.convergents m.succ
s_mth_eq' : g'.s.get? m = some gp'
gp_succ_m : Pair K
s_succ_mth_eq : g.s.get? (m + 1) = some gp_succ_m
gp_m : Pair K
mth_s_eq : g.s.get? m = some gp_m
⊢ 0 < gp_m.a ∧ 0 < gp_m.b + gp_succ_m.a / gp_succ_m.b
state_after: case refl.intro.intro
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
g : GeneralizedContinuedFraction K
gp' : Pair K
m : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b) →
      g.convergents m.succ = g.convergents' m.succ
s_pos : ∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ + 1 → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF m.succ
not_terminated_at_n : ¬g.TerminatedAt m.succ
this : g.convergents (m.succ + 1) = g'.convergents m.succ
s_mth_eq' : g'.s.get? m = some gp'
gp_succ_m : Pair K
s_succ_mth_eq : g.s.get? (m + 1) = some gp_succ_m
gp_m : Pair K
mth_s_eq : g.s.get? m = some gp_m
m_lt_n : m < m.succ
⊢ 0 < gp_m.a ∧ 0 < gp_m.b + gp_succ_m.a / gp_succ_m.b

tactic: refine ⟨(s_pos (Nat.lt.step m_lt_n) mth_s_eq).left, ?_⟩
state_before: case refl.intro.intro
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
g : GeneralizedContinuedFraction K
gp' : Pair K
m : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b) →
      g.convergents m.succ = g.convergents' m.succ
s_pos : ∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ + 1 → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF m.succ
not_terminated_at_n : ¬g.TerminatedAt m.succ
this : g.convergents (m.succ + 1) = g'.convergents m.succ
s_mth_eq' : g'.s.get? m = some gp'
gp_succ_m : Pair K
s_succ_mth_eq : g.s.get? (m + 1) = some gp_succ_m
gp_m : Pair K
mth_s_eq : g.s.get? m = some gp_m
m_lt_n : m < m.succ
⊢ 0 < gp_m.a ∧ 0 < gp_m.b + gp_succ_m.a / gp_succ_m.b
state_after: case refl.intro.intro
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
g : GeneralizedContinuedFraction K
gp' : Pair K
m : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b) →
      g.convergents m.succ = g.convergents' m.succ
s_pos : ∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ + 1 → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF m.succ
not_terminated_at_n : ¬g.TerminatedAt m.succ
this : g.convergents (m.succ + 1) = g'.convergents m.succ
s_mth_eq' : g'.s.get? m = some gp'
gp_succ_m : Pair K
s_succ_mth_eq : g.s.get? (m + 1) = some gp_succ_m
gp_m : Pair K
mth_s_eq : g.s.get? m = some gp_m
m_lt_n : m < m.succ
⊢ 0 < gp_m.b + gp_succ_m.a / gp_succ_m.b

tactic: refine add_pos (s_pos (Nat.lt.step m_lt_n) mth_s_eq).right ?_
state_before: case refl.intro.intro
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
g : GeneralizedContinuedFraction K
gp' : Pair K
m : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b) →
      g.convergents m.succ = g.convergents' m.succ
s_pos : ∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ + 1 → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF m.succ
not_terminated_at_n : ¬g.TerminatedAt m.succ
this : g.convergents (m.succ + 1) = g'.convergents m.succ
s_mth_eq' : g'.s.get? m = some gp'
gp_succ_m : Pair K
s_succ_mth_eq : g.s.get? (m + 1) = some gp_succ_m
gp_m : Pair K
mth_s_eq : g.s.get? m = some gp_m
m_lt_n : m < m.succ
⊢ 0 < gp_m.b + gp_succ_m.a / gp_succ_m.b
state_after: case refl.intro.intro
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
g : GeneralizedContinuedFraction K
gp' : Pair K
m : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b) →
      g.convergents m.succ = g.convergents' m.succ
s_pos : ∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ + 1 → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF m.succ
not_terminated_at_n : ¬g.TerminatedAt m.succ
this : g.convergents (m.succ + 1) = g'.convergents m.succ
s_mth_eq' : g'.s.get? m = some gp'
gp_succ_m : Pair K
s_succ_mth_eq : g.s.get? (m + 1) = some gp_succ_m
gp_m : Pair K
mth_s_eq : g.s.get? m = some gp_m
m_lt_n : m < m.succ
⊢ 0 < gp_succ_m.a / gp_succ_m.b

tactic: have : 0 < gp_succ_m.a ∧ 0 < gp_succ_m.b := s_pos (lt_add_one <| m + 1) s_succ_mth_eq
state_before: case refl.intro.intro
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
g : GeneralizedContinuedFraction K
gp' : Pair K
m : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b) →
      g.convergents m.succ = g.convergents' m.succ
s_pos : ∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ + 1 → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF m.succ
not_terminated_at_n : ¬g.TerminatedAt m.succ
this : g.convergents (m.succ + 1) = g'.convergents m.succ
s_mth_eq' : g'.s.get? m = some gp'
gp_succ_m : Pair K
s_succ_mth_eq : g.s.get? (m + 1) = some gp_succ_m
gp_m : Pair K
mth_s_eq : g.s.get? m = some gp_m
m_lt_n : m < m.succ
⊢ 0 < gp_succ_m.a / gp_succ_m.b
state_after: case refl.intro.intro
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
g : GeneralizedContinuedFraction K
gp' : Pair K
m : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b) →
      g.convergents m.succ = g.convergents' m.succ
s_pos : ∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ + 1 → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF m.succ
not_terminated_at_n : ¬g.TerminatedAt m.succ
this✝ : g.convergents (m.succ + 1) = g'.convergents m.succ
s_mth_eq' : g'.s.get? m = some gp'
gp_succ_m : Pair K
s_succ_mth_eq : g.s.get? (m + 1) = some gp_succ_m
gp_m : Pair K
mth_s_eq : g.s.get? m = some gp_m
m_lt_n : m < m.succ
this : 0 < gp_succ_m.a ∧ 0 < gp_succ_m.b
⊢ 0 < gp_succ_m.a / gp_succ_m.b

tactic: exact div_pos this.left this.right
state_before: case refl.intro.intro
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
g : GeneralizedContinuedFraction K
gp' : Pair K
m : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b) →
      g.convergents m.succ = g.convergents' m.succ
s_pos : ∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ + 1 → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF m.succ
not_terminated_at_n : ¬g.TerminatedAt m.succ
this✝ : g.convergents (m.succ + 1) = g'.convergents m.succ
s_mth_eq' : g'.s.get? m = some gp'
gp_succ_m : Pair K
s_succ_mth_eq : g.s.get? (m + 1) = some gp_succ_m
gp_m : Pair K
mth_s_eq : g.s.get? m = some gp_m
m_lt_n : m < m.succ
this : 0 < gp_succ_m.a ∧ 0 < gp_succ_m.b
⊢ 0 < gp_succ_m.a / gp_succ_m.b
state_after: no goals

tactic: have ot : g'.s.get? m = some ⟨gp_m.a, gp_m.b + gp_succ_m.a / gp_succ_m.b⟩ :=
  squashSeq_nth_of_not_terminated mth_s_eq s_succ_mth_eq
state_before: K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
g : GeneralizedContinuedFraction K
gp' : Pair K
m : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b) →
      g.convergents m.succ = g.convergents' m.succ
s_pos : ∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ + 1 → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF m.succ
not_terminated_at_n : ¬g.TerminatedAt m.succ
this✝ : g.convergents (m.succ + 1) = g'.convergents m.succ
s_mth_eq' : g'.s.get? m = some gp'
gp_succ_m : Pair K
s_succ_mth_eq : g.s.get? (m + 1) = some gp_succ_m
gp_m : Pair K
mth_s_eq : g.s.get? m = some gp_m
this : 0 < gp_m.a ∧ 0 < gp_m.b + gp_succ_m.a / gp_succ_m.b
⊢ 0 < gp'.a ∧ 0 < gp'.b
state_after: K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
g : GeneralizedContinuedFraction K
gp' : Pair K
m : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b) →
      g.convergents m.succ = g.convergents' m.succ
s_pos : ∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ + 1 → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF m.succ
not_terminated_at_n : ¬g.TerminatedAt m.succ
this✝ : g.convergents (m.succ + 1) = g'.convergents m.succ
s_mth_eq' : g'.s.get? m = some gp'
gp_succ_m : Pair K
s_succ_mth_eq : g.s.get? (m + 1) = some gp_succ_m
gp_m : Pair K
mth_s_eq : g.s.get? m = some gp_m
this : 0 < gp_m.a ∧ 0 < gp_m.b + gp_succ_m.a / gp_succ_m.b
ot : g'.s.get? m = some { a := gp_m.a, b := gp_m.b + gp_succ_m.a / gp_succ_m.b }
⊢ 0 < gp'.a ∧ 0 < gp'.b

tactic: have : gp' = ⟨gp_m.a, gp_m.b + gp_succ_m.a / gp_succ_m.b⟩ := by
  simp_all only [Option.some.injEq]
state_before: K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
g : GeneralizedContinuedFraction K
gp' : Pair K
m : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b) →
      g.convergents m.succ = g.convergents' m.succ
s_pos : ∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ + 1 → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF m.succ
not_terminated_at_n : ¬g.TerminatedAt m.succ
this✝ : g.convergents (m.succ + 1) = g'.convergents m.succ
s_mth_eq' : g'.s.get? m = some gp'
gp_succ_m : Pair K
s_succ_mth_eq : g.s.get? (m + 1) = some gp_succ_m
gp_m : Pair K
mth_s_eq : g.s.get? m = some gp_m
this : 0 < gp_m.a ∧ 0 < gp_m.b + gp_succ_m.a / gp_succ_m.b
ot : g'.s.get? m = some { a := gp_m.a, b := gp_m.b + gp_succ_m.a / gp_succ_m.b }
⊢ 0 < gp'.a ∧ 0 < gp'.b
state_after: K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
g : GeneralizedContinuedFraction K
gp' : Pair K
m : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b) →
      g.convergents m.succ = g.convergents' m.succ
s_pos : ∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ + 1 → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF m.succ
not_terminated_at_n : ¬g.TerminatedAt m.succ
this✝¹ : g.convergents (m.succ + 1) = g'.convergents m.succ
s_mth_eq' : g'.s.get? m = some gp'
gp_succ_m : Pair K
s_succ_mth_eq : g.s.get? (m + 1) = some gp_succ_m
gp_m : Pair K
mth_s_eq : g.s.get? m = some gp_m
this✝ : 0 < gp_m.a ∧ 0 < gp_m.b + gp_succ_m.a / gp_succ_m.b
ot : g'.s.get? m = some { a := gp_m.a, b := gp_m.b + gp_succ_m.a / gp_succ_m.b }
this : gp' = { a := gp_m.a, b := gp_m.b + gp_succ_m.a / gp_succ_m.b }
⊢ 0 < gp'.a ∧ 0 < gp'.b

tactic: rwa [this]
state_before: K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
g : GeneralizedContinuedFraction K
gp' : Pair K
m : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b) →
      g.convergents m.succ = g.convergents' m.succ
s_pos : ∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ + 1 → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF m.succ
not_terminated_at_n : ¬g.TerminatedAt m.succ
this✝¹ : g.convergents (m.succ + 1) = g'.convergents m.succ
s_mth_eq' : g'.s.get? m = some gp'
gp_succ_m : Pair K
s_succ_mth_eq : g.s.get? (m + 1) = some gp_succ_m
gp_m : Pair K
mth_s_eq : g.s.get? m = some gp_m
this✝ : 0 < gp_m.a ∧ 0 < gp_m.b + gp_succ_m.a / gp_succ_m.b
ot : g'.s.get? m = some { a := gp_m.a, b := gp_m.b + gp_succ_m.a / gp_succ_m.b }
this : gp' = { a := gp_m.a, b := gp_m.b + gp_succ_m.a / gp_succ_m.b }
⊢ 0 < gp'.a ∧ 0 < gp'.b
state_after: no goals

tactic: simp_all only [Option.some.injEq]
state_before: K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
g : GeneralizedContinuedFraction K
gp' : Pair K
m : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b) →
      g.convergents m.succ = g.convergents' m.succ
s_pos : ∀ {gp : Pair K} {m_1 : ℕ}, m_1 < m.succ + 1 → g.s.get? m_1 = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF m.succ
not_terminated_at_n : ¬g.TerminatedAt m.succ
this✝ : g.convergents (m.succ + 1) = g'.convergents m.succ
s_mth_eq' : g'.s.get? m = some gp'
gp_succ_m : Pair K
s_succ_mth_eq : g.s.get? (m + 1) = some gp_succ_m
gp_m : Pair K
mth_s_eq : g.s.get? m = some gp_m
this : 0 < gp_m.a ∧ 0 < gp_m.b + gp_succ_m.a / gp_succ_m.b
ot : g'.s.get? m = some { a := gp_m.a, b := gp_m.b + gp_succ_m.a / gp_succ_m.b }
⊢ gp' = { a := gp_m.a, b := gp_m.b + gp_succ_m.a / gp_succ_m.b }
state_after: no goals

tactic: refine s_pos (Nat.lt.step <| Nat.lt.step succ_m_lt_n) ?_
state_before: case step
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
g : GeneralizedContinuedFraction K
gp' : Pair K
m n : ℕ
succ_m_lt_n : m.succ.le n
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m : ℕ}, m < n.succ → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b) →
      g.convergents n.succ = g.convergents' n.succ
s_pos : ∀ {gp : Pair K} {m : ℕ}, m < n.succ + 1 → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF n.succ
not_terminated_at_n : ¬g.TerminatedAt n.succ
this : g.convergents (n.succ + 1) = g'.convergents n.succ
s_mth_eq' : g'.s.get? m = some gp'
⊢ 0 < gp'.a ∧ 0 < gp'.b
state_after: case step
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
g : GeneralizedContinuedFraction K
gp' : Pair K
m n : ℕ
succ_m_lt_n : m.succ.le n
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m : ℕ}, m < n.succ → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b) →
      g.convergents n.succ = g.convergents' n.succ
s_pos : ∀ {gp : Pair K} {m : ℕ}, m < n.succ + 1 → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF n.succ
not_terminated_at_n : ¬g.TerminatedAt n.succ
this : g.convergents (n.succ + 1) = g'.convergents n.succ
s_mth_eq' : g'.s.get? m = some gp'
⊢ g.s.get? m = some gp'

tactic: exact Eq.trans (squashGCF_nth_of_lt succ_m_lt_n).symm s_mth_eq'
state_before: case step
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
g : GeneralizedContinuedFraction K
gp' : Pair K
m n : ℕ
succ_m_lt_n : m.succ.le n
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m : ℕ}, m < n.succ → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b) →
      g.convergents n.succ = g.convergents' n.succ
s_pos : ∀ {gp : Pair K} {m : ℕ}, m < n.succ + 1 → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF n.succ
not_terminated_at_n : ¬g.TerminatedAt n.succ
this : g.convergents (n.succ + 1) = g'.convergents n.succ
s_mth_eq' : g'.s.get? m = some gp'
⊢ g.s.get? m = some gp'
state_after: no goals

tactic: intro b nth_part_denom_eq
state_before: K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
n : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m : ℕ}, m < n → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b) → g.convergents n = g.convergents' n
g : GeneralizedContinuedFraction K
s_pos : ∀ {gp : Pair K} {m : ℕ}, m < n + 1 → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF n
not_terminated_at_n : ¬g.TerminatedAt n
⊢ ∀ ⦃b : K⦄, g.partialDenominators.get? n = some b → b ≠ 0
state_after: K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
n : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m : ℕ}, m < n → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b) → g.convergents n = g.convergents' n
g : GeneralizedContinuedFraction K
s_pos : ∀ {gp : Pair K} {m : ℕ}, m < n + 1 → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF n
not_terminated_at_n : ¬g.TerminatedAt n
b : K
nth_part_denom_eq : g.partialDenominators.get? n = some b
⊢ b ≠ 0

tactic: obtain ⟨gp, s_nth_eq, ⟨refl⟩⟩ : ∃ gp, g.s.get? n = some gp ∧ gp.b = b :=
  exists_s_b_of_part_denom nth_part_denom_eq
state_before: K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
n : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m : ℕ}, m < n → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b) → g.convergents n = g.convergents' n
g : GeneralizedContinuedFraction K
s_pos : ∀ {gp : Pair K} {m : ℕ}, m < n + 1 → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF n
not_terminated_at_n : ¬g.TerminatedAt n
b : K
nth_part_denom_eq : g.partialDenominators.get? n = some b
⊢ b ≠ 0
state_after: case intro.intro.refl
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
n : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m : ℕ}, m < n → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b) → g.convergents n = g.convergents' n
g : GeneralizedContinuedFraction K
s_pos : ∀ {gp : Pair K} {m : ℕ}, m < n + 1 → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF n
not_terminated_at_n : ¬g.TerminatedAt n
gp : Pair K
s_nth_eq : g.s.get? n = some gp
nth_part_denom_eq : g.partialDenominators.get? n = some gp.b
⊢ gp.b ≠ 0

tactic: exact (ne_of_lt (s_pos (lt_add_one n) s_nth_eq).right).symm
state_before: case intro.intro.refl
K : Type u_1
s : Stream'.Seq (Pair K)
inst✝ : LinearOrderedField K
n : ℕ
IH :
  ∀ {g : GeneralizedContinuedFraction K},
    (∀ {gp : Pair K} {m : ℕ}, m < n → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b) → g.convergents n = g.convergents' n
g : GeneralizedContinuedFraction K
s_pos : ∀ {gp : Pair K} {m : ℕ}, m < n + 1 → g.s.get? m = some gp → 0 < gp.a ∧ 0 < gp.b
g' : GeneralizedContinuedFraction K := g.squashGCF n
not_terminated_at_n : ¬g.TerminatedAt n
gp : Pair K
s_nth_eq : g.s.get? n = some gp
nth_part_denom_eq : g.partialDenominators.get? n = some gp.b
⊢ gp.b ≠ 0
state_after: no goals