l3lab/ntp-mathlib huggingface dataset:
/-- Shows that `|v - Aₙ / Bₙ| ≤ 1 / (Bₙ * Bₙ₊₁)`. -/
theorem abs_sub_convergents_le (not_terminated_at_n : ¬(of v).TerminatedAt n) :
    |v - (of v).convergents n| ≤ 1 / ((of v).denominators n * ((of v).denominators <| n + 1)) := by
  -- shorthand notation
  let g := of v
  let nextConts := g.continuantsAux (n + 2)
  set conts := continuantsAux g (n + 1) with conts_eq
  set pred_conts := continuantsAux g n with pred_conts_eq
  -- change the goal to something more readable
  change |v - convergents g n| ≤ 1 / (conts.b * nextConts.b)
  obtain ⟨gp, s_nth_eq⟩ : ∃ gp, g.s.get? n = some gp
  exact Option.ne_none_iff_exists'.1 not_terminated_at_n
  have gp_a_eq_one : gp.a = 1 := of_part_num_eq_one (part_num_eq_s_a s_nth_eq)
  -- unfold the recurrence relation for `nextConts.b`
  have nextConts_b_eq : nextConts.b = pred_conts.b + gp.b * conts.b := by
    simp [continuantsAux_recurrence s_nth_eq pred_conts_eq conts_eq, gp_a_eq_one,
      pred_conts_eq.symm, conts_eq.symm, add_comm]
  let denom := conts.b * (pred_conts.b + gp.b * conts.b)
  suffices |v - g.convergents n| ≤ 1 / denom by rw [nextConts_b_eq]; congr 1
  

Proof state:
case intro
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
not_terminated_at_n : ¬TerminatedAt (of v) n
g : GeneralizedContinuedFraction K := of v
nextConts : Pair K := continuantsAux g (n + 2)
conts : Pair K := continuantsAux g (n + 1)
conts_eq : conts = continuantsAux g (n + 1)
pred_conts : Pair K := continuantsAux g n
pred_conts_eq : pred_conts = continuantsAux g n
gp : Pair K
s_nth_eq : Stream'.Seq.get? g.s n = some gp
gp_a_eq_one : gp.a = 1
nextConts_b_eq : nextConts.b = pred_conts.b + gp.b * conts.b
denom : K := conts.b * (pred_conts.b + gp.b * conts.b)
⊢ |v - convergents g n| ≤ 1 / denom

Next tactic:
obtain ⟨ifp_succ_n, succ_nth_stream_eq, ifp_succ_n_b_eq_gp_b⟩ :
    ∃ ifp_succ_n, IntFractPair.stream v (n + 1) = some ifp_succ_n ∧ (ifp_succ_n.b : K) = gp.b
/-- Shows that `|v - Aₙ / Bₙ| ≤ 1 / (Bₙ * Bₙ₊₁)`. -/
theorem abs_sub_convergents_le (not_terminated_at_n : ¬(of v).TerminatedAt n) :
    |v - (of v).convergents n| ≤ 1 / ((of v).denominators n * ((of v).denominators <| n + 1)) := by
  -- shorthand notation
  let g := of v
  let nextConts := g.continuantsAux (n + 2)
  set conts := continuantsAux g (n + 1) with conts_eq
  set pred_conts := continuantsAux g n with pred_conts_eq
  -- change the goal to something more readable
  change |v - convergents g n| ≤ 1 / (conts.b * nextConts.b)
  obtain ⟨gp, s_nth_eq⟩ : ∃ gp, g.s.get? n = some gp
  exact Option.ne_none_iff_exists'.1 not_terminated_at_n
  have gp_a_eq_one : gp.a = 1 := of_part_num_eq_one (part_num_eq_s_a s_nth_eq)
  -- unfold the recurrence relation for `nextConts.b`
  have nextConts_b_eq : nextConts.b = pred_conts.b + gp.b * conts.b := by
    simp [continuantsAux_recurrence s_nth_eq pred_conts_eq conts_eq, gp_a_eq_one,
      pred_conts_eq.symm, conts_eq.symm, add_comm]
  let denom := conts.b * (pred_conts.b + gp.b * conts.b)
  suffices |v - g.convergents n| ≤ 1 / denom by rw [nextConts_b_eq]; congr 1
  obtain ⟨ifp_succ_n, succ_nth_stream_eq, ifp_succ_n_b_eq_gp_b⟩ :
    ∃ ifp_succ_n, IntFractPair.stream v (n + 1) = some ifp_succ_n ∧ (ifp_succ_n.b : K) = gp.b
  

Proof state:
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
not_terminated_at_n : ¬TerminatedAt (of v) n
g : GeneralizedContinuedFraction K := of v
nextConts : Pair K := continuantsAux g (n + 2)
conts : Pair K := continuantsAux g (n + 1)
conts_eq : conts = continuantsAux g (n + 1)
pred_conts : Pair K := continuantsAux g n
pred_conts_eq : pred_conts = continuantsAux g n
gp : Pair K
s_nth_eq : Stream'.Seq.get? g.s n = some gp
gp_a_eq_one : gp.a = 1
nextConts_b_eq : nextConts.b = pred_conts.b + gp.b * conts.b
denom : K := conts.b * (pred_conts.b + gp.b * conts.b)
⊢ ∃ ifp_succ_n, IntFractPair.stream v (n + 1) = some ifp_succ_n ∧ ↑ifp_succ_n.b = gp.b
case intro.intro.intro
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
not_terminated_at_n : ¬TerminatedAt (of v) n
g : GeneralizedContinuedFraction K := of v
nextConts : Pair K := continuantsAux g (n + 2)
conts : Pair K := continuantsAux g (n + 1)
conts_eq : conts = continuantsAux g (n + 1)
pred_conts : Pair K := continuantsAux g n
pred_conts_eq : pred_conts = continuantsAux g n
gp : Pair K
s_nth_eq : Stream'.Seq.get? g.s n = some gp
gp_a_eq_one : gp.a = 1
nextConts_b_eq : nextConts.b = pred_conts.b + gp.b * conts.b
denom : K := conts.b * (pred_conts.b + gp.b * conts.b)
ifp_succ_n : IntFractPair K
succ_nth_stream_eq : IntFractPair.stream v (n + 1) = some ifp_succ_n
ifp_succ_n_b_eq_gp_b : ↑ifp_succ_n.b = gp.b
⊢ |v - convergents g n| ≤ 1 / denom

Next tactic:
exact IntFractPair.exists_succ_get?_stream_of_gcf_of_get?_eq_some s_nth_eq
/-- Shows that `|v - Aₙ / Bₙ| ≤ 1 / (Bₙ * Bₙ₊₁)`. -/
theorem abs_sub_convergents_le (not_terminated_at_n : ¬(of v).TerminatedAt n) :
    |v - (of v).convergents n| ≤ 1 / ((of v).denominators n * ((of v).denominators <| n + 1)) := by
  -- shorthand notation
  let g := of v
  let nextConts := g.continuantsAux (n + 2)
  set conts := continuantsAux g (n + 1) with conts_eq
  set pred_conts := continuantsAux g n with pred_conts_eq
  -- change the goal to something more readable
  change |v - convergents g n| ≤ 1 / (conts.b * nextConts.b)
  obtain ⟨gp, s_nth_eq⟩ : ∃ gp, g.s.get? n = some gp
  exact Option.ne_none_iff_exists'.1 not_terminated_at_n
  have gp_a_eq_one : gp.a = 1 := of_part_num_eq_one (part_num_eq_s_a s_nth_eq)
  -- unfold the recurrence relation for `nextConts.b`
  have nextConts_b_eq : nextConts.b = pred_conts.b + gp.b * conts.b := by
    simp [continuantsAux_recurrence s_nth_eq pred_conts_eq conts_eq, gp_a_eq_one,
      pred_conts_eq.symm, conts_eq.symm, add_comm]
  let denom := conts.b * (pred_conts.b + gp.b * conts.b)
  suffices |v - g.convergents n| ≤ 1 / denom by rw [nextConts_b_eq]; congr 1
  obtain ⟨ifp_succ_n, succ_nth_stream_eq, ifp_succ_n_b_eq_gp_b⟩ :
    ∃ ifp_succ_n, IntFractPair.stream v (n + 1) = some ifp_succ_n ∧ (ifp_succ_n.b : K) = gp.b
  exact IntFractPair.exists_succ_get?_stream_of_gcf_of_get?_eq_some s_nth_eq
  

Proof state:
case intro.intro.intro
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
not_terminated_at_n : ¬TerminatedAt (of v) n
g : GeneralizedContinuedFraction K := of v
nextConts : Pair K := continuantsAux g (n + 2)
conts : Pair K := continuantsAux g (n + 1)
conts_eq : conts = continuantsAux g (n + 1)
pred_conts : Pair K := continuantsAux g n
pred_conts_eq : pred_conts = continuantsAux g n
gp : Pair K
s_nth_eq : Stream'.Seq.get? g.s n = some gp
gp_a_eq_one : gp.a = 1
nextConts_b_eq : nextConts.b = pred_conts.b + gp.b * conts.b
denom : K := conts.b * (pred_conts.b + gp.b * conts.b)
ifp_succ_n : IntFractPair K
succ_nth_stream_eq : IntFractPair.stream v (n + 1) = some ifp_succ_n
ifp_succ_n_b_eq_gp_b : ↑ifp_succ_n.b = gp.b
⊢ |v - convergents g n| ≤ 1 / denom

Next tactic:
obtain ⟨ifp_n, stream_nth_eq, stream_nth_fr_ne_zero, if_of_eq_ifp_succ_n⟩ :
    ∃ ifp_n,
      IntFractPair.stream v n = some ifp_n ∧ ifp_n.fr ≠ 0 ∧ IntFractPair.of ifp_n.fr⁻¹ = ifp_succ_n
/-- Shows that `|v - Aₙ / Bₙ| ≤ 1 / (Bₙ * Bₙ₊₁)`. -/
theorem abs_sub_convergents_le (not_terminated_at_n : ¬(of v).TerminatedAt n) :
    |v - (of v).convergents n| ≤ 1 / ((of v).denominators n * ((of v).denominators <| n + 1)) := by
  -- shorthand notation
  let g := of v
  let nextConts := g.continuantsAux (n + 2)
  set conts := continuantsAux g (n + 1) with conts_eq
  set pred_conts := continuantsAux g n with pred_conts_eq
  -- change the goal to something more readable
  change |v - convergents g n| ≤ 1 / (conts.b * nextConts.b)
  obtain ⟨gp, s_nth_eq⟩ : ∃ gp, g.s.get? n = some gp
  exact Option.ne_none_iff_exists'.1 not_terminated_at_n
  have gp_a_eq_one : gp.a = 1 := of_part_num_eq_one (part_num_eq_s_a s_nth_eq)
  -- unfold the recurrence relation for `nextConts.b`
  have nextConts_b_eq : nextConts.b = pred_conts.b + gp.b * conts.b := by
    simp [continuantsAux_recurrence s_nth_eq pred_conts_eq conts_eq, gp_a_eq_one,
      pred_conts_eq.symm, conts_eq.symm, add_comm]
  let denom := conts.b * (pred_conts.b + gp.b * conts.b)
  suffices |v - g.convergents n| ≤ 1 / denom by rw [nextConts_b_eq]; congr 1
  obtain ⟨ifp_succ_n, succ_nth_stream_eq, ifp_succ_n_b_eq_gp_b⟩ :
    ∃ ifp_succ_n, IntFractPair.stream v (n + 1) = some ifp_succ_n ∧ (ifp_succ_n.b : K) = gp.b
  exact IntFractPair.exists_succ_get?_stream_of_gcf_of_get?_eq_some s_nth_eq
  obtain ⟨ifp_n, stream_nth_eq, stream_nth_fr_ne_zero, if_of_eq_ifp_succ_n⟩ :
    ∃ ifp_n,
      IntFractPair.stream v n = some ifp_n ∧ ifp_n.fr ≠ 0 ∧ IntFractPair.of ifp_n.fr⁻¹ = ifp_succ_n
  exact IntFractPair.succ_nth_stream_eq_some_iff.1 succ_nth_stream_eq
  

Proof state:
case intro.intro.intro.intro.intro.intro
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
not_terminated_at_n : ¬TerminatedAt (of v) n
g : GeneralizedContinuedFraction K := of v
nextConts : Pair K := continuantsAux g (n + 2)
conts : Pair K := continuantsAux g (n + 1)
conts_eq : conts = continuantsAux g (n + 1)
pred_conts : Pair K := continuantsAux g n
pred_conts_eq : pred_conts = continuantsAux g n
gp : Pair K
s_nth_eq : Stream'.Seq.get? g.s n = some gp
gp_a_eq_one : gp.a = 1
nextConts_b_eq : nextConts.b = pred_conts.b + gp.b * conts.b
denom : K := conts.b * (pred_conts.b + gp.b * conts.b)
ifp_succ_n : IntFractPair K
succ_nth_stream_eq : IntFractPair.stream v (n + 1) = some ifp_succ_n
ifp_succ_n_b_eq_gp_b : ↑ifp_succ_n.b = gp.b
ifp_n : IntFractPair K
stream_nth_eq : IntFractPair.stream v n = some ifp_n
stream_nth_fr_ne_zero : ifp_n.fr ≠ 0
if_of_eq_ifp_succ_n : IntFractPair.of ifp_n.fr⁻¹ = ifp_succ_n
⊢ |v - convergents g n| ≤ 1 / denom

Next tactic:
let denom' := conts.b * (pred_conts.b + ifp_n.fr⁻¹ * conts.b)
/-- Shows that `|v - Aₙ / Bₙ| ≤ 1 / (Bₙ * Bₙ₊₁)`. -/
theorem abs_sub_convergents_le (not_terminated_at_n : ¬(of v).TerminatedAt n) :
    |v - (of v).convergents n| ≤ 1 / ((of v).denominators n * ((of v).denominators <| n + 1)) := by
  -- shorthand notation
  let g := of v
  let nextConts := g.continuantsAux (n + 2)
  set conts := continuantsAux g (n + 1) with conts_eq
  set pred_conts := continuantsAux g n with pred_conts_eq
  -- change the goal to something more readable
  change |v - convergents g n| ≤ 1 / (conts.b * nextConts.b)
  obtain ⟨gp, s_nth_eq⟩ : ∃ gp, g.s.get? n = some gp
  exact Option.ne_none_iff_exists'.1 not_terminated_at_n
  have gp_a_eq_one : gp.a = 1 := of_part_num_eq_one (part_num_eq_s_a s_nth_eq)
  -- unfold the recurrence relation for `nextConts.b`
  have nextConts_b_eq : nextConts.b = pred_conts.b + gp.b * conts.b := by
    simp [continuantsAux_recurrence s_nth_eq pred_conts_eq conts_eq, gp_a_eq_one,
      pred_conts_eq.symm, conts_eq.symm, add_comm]
  let denom := conts.b * (pred_conts.b + gp.b * conts.b)
  suffices |v - g.convergents n| ≤ 1 / denom by rw [nextConts_b_eq]; congr 1
  obtain ⟨ifp_succ_n, succ_nth_stream_eq, ifp_succ_n_b_eq_gp_b⟩ :
    ∃ ifp_succ_n, IntFractPair.stream v (n + 1) = some ifp_succ_n ∧ (ifp_succ_n.b : K) = gp.b
  exact IntFractPair.exists_succ_get?_stream_of_gcf_of_get?_eq_some s_nth_eq
  obtain ⟨ifp_n, stream_nth_eq, stream_nth_fr_ne_zero, if_of_eq_ifp_succ_n⟩ :
    ∃ ifp_n,
      IntFractPair.stream v n = some ifp_n ∧ ifp_n.fr ≠ 0 ∧ IntFractPair.of ifp_n.fr⁻¹ = ifp_succ_n
  exact IntFractPair.succ_nth_stream_eq_some_iff.1 succ_nth_stream_eq
  let denom' := conts.b * (pred_conts.b + ifp_n.fr⁻¹ * conts.b)
  -- now we can use `sub_convergents_eq` to simplify our goal
  

Proof state:
case intro.intro.intro.intro.intro.intro
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
not_terminated_at_n : ¬TerminatedAt (of v) n
g : GeneralizedContinuedFraction K := of v
nextConts : Pair K := continuantsAux g (n + 2)
conts : Pair K := continuantsAux g (n + 1)
conts_eq : conts = continuantsAux g (n + 1)
pred_conts : Pair K := continuantsAux g n
pred_conts_eq : pred_conts = continuantsAux g n
gp : Pair K
s_nth_eq : Stream'.Seq.get? g.s n = some gp
gp_a_eq_one : gp.a = 1
nextConts_b_eq : nextConts.b = pred_conts.b + gp.b * conts.b
denom : K := conts.b * (pred_conts.b + gp.b * conts.b)
ifp_succ_n : IntFractPair K
succ_nth_stream_eq : IntFractPair.stream v (n + 1) = some ifp_succ_n
ifp_succ_n_b_eq_gp_b : ↑ifp_succ_n.b = gp.b
ifp_n : IntFractPair K
stream_nth_eq : IntFractPair.stream v n = some ifp_n
stream_nth_fr_ne_zero : ifp_n.fr ≠ 0
if_of_eq_ifp_succ_n : IntFractPair.of ifp_n.fr⁻¹ = ifp_succ_n
denom' : K := conts.b * (pred_conts.b + ifp_n.fr⁻¹ * conts.b)
⊢ |v - convergents g n| ≤ 1 / denom

Next tactic:
suffices |(-1) ^ n / denom'| ≤ 1 / denom by
    have : v - g.convergents n = (-1) ^ n / denom' := by
      -- apply `sub_convergents_eq` and simplify the result
      have tmp := sub_convergents_eq stream_nth_eq
      simp only [stream_nth_fr_ne_zero, conts_eq.symm, pred_conts_eq.symm, if_false] at tmp
      rw [tmp]
      ring
    rwa [this]
/-- Shows that `|v - Aₙ / Bₙ| ≤ 1 / (Bₙ * Bₙ₊₁)`. -/
theorem abs_sub_convergents_le (not_terminated_at_n : ¬(of v).TerminatedAt n) :
    |v - (of v).convergents n| ≤ 1 / ((of v).denominators n * ((of v).denominators <| n + 1)) := by
  -- shorthand notation
  let g := of v
  let nextConts := g.continuantsAux (n + 2)
  set conts := continuantsAux g (n + 1) with conts_eq
  set pred_conts := continuantsAux g n with pred_conts_eq
  -- change the goal to something more readable
  change |v - convergents g n| ≤ 1 / (conts.b * nextConts.b)
  obtain ⟨gp, s_nth_eq⟩ : ∃ gp, g.s.get? n = some gp
  exact Option.ne_none_iff_exists'.1 not_terminated_at_n
  have gp_a_eq_one : gp.a = 1 := of_part_num_eq_one (part_num_eq_s_a s_nth_eq)
  -- unfold the recurrence relation for `nextConts.b`
  have nextConts_b_eq : nextConts.b = pred_conts.b + gp.b * conts.b := by
    simp [continuantsAux_recurrence s_nth_eq pred_conts_eq conts_eq, gp_a_eq_one,
      pred_conts_eq.symm, conts_eq.symm, add_comm]
  let denom := conts.b * (pred_conts.b + gp.b * conts.b)
  suffices |v - g.convergents n| ≤ 1 / denom by rw [nextConts_b_eq]; congr 1
  obtain ⟨ifp_succ_n, succ_nth_stream_eq, ifp_succ_n_b_eq_gp_b⟩ :
    ∃ ifp_succ_n, IntFractPair.stream v (n + 1) = some ifp_succ_n ∧ (ifp_succ_n.b : K) = gp.b
  exact IntFractPair.exists_succ_get?_stream_of_gcf_of_get?_eq_some s_nth_eq
  obtain ⟨ifp_n, stream_nth_eq, stream_nth_fr_ne_zero, if_of_eq_ifp_succ_n⟩ :
    ∃ ifp_n,
      IntFractPair.stream v n = some ifp_n ∧ ifp_n.fr ≠ 0 ∧ IntFractPair.of ifp_n.fr⁻¹ = ifp_succ_n
  exact IntFractPair.succ_nth_stream_eq_some_iff.1 succ_nth_stream_eq
  let denom' := conts.b * (pred_conts.b + ifp_n.fr⁻¹ * conts.b)
  -- now we can use `sub_convergents_eq` to simplify our goal
  suffices |(-1) ^ n / denom'| ≤ 1 / denom by
    

Proof state:
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
not_terminated_at_n : ¬TerminatedAt (of v) n
g : GeneralizedContinuedFraction K := of v
nextConts : Pair K := continuantsAux g (n + 2)
conts : Pair K := continuantsAux g (n + 1)
conts_eq : conts = continuantsAux g (n + 1)
pred_conts : Pair K := continuantsAux g n
pred_conts_eq : pred_conts = continuantsAux g n
gp : Pair K
s_nth_eq : Stream'.Seq.get? g.s n = some gp
gp_a_eq_one : gp.a = 1
nextConts_b_eq : nextConts.b = pred_conts.b + gp.b * conts.b
denom : K := conts.b * (pred_conts.b + gp.b * conts.b)
ifp_succ_n : IntFractPair K
succ_nth_stream_eq : IntFractPair.stream v (n + 1) = some ifp_succ_n
ifp_succ_n_b_eq_gp_b : ↑ifp_succ_n.b = gp.b
ifp_n : IntFractPair K
stream_nth_eq : IntFractPair.stream v n = some ifp_n
stream_nth_fr_ne_zero : ifp_n.fr ≠ 0
if_of_eq_ifp_succ_n : IntFractPair.of ifp_n.fr⁻¹ = ifp_succ_n
denom' : K := conts.b * (pred_conts.b + ifp_n.fr⁻¹ * conts.b)
this : |(-1) ^ n / denom'| ≤ 1 / denom
⊢ |v - convergents g n| ≤ 1 / denom

Next tactic:
have : v - g.convergents n = (-1) ^ n / denom' := by
      -- apply `sub_convergents_eq` and simplify the result
      have tmp := sub_convergents_eq stream_nth_eq
      simp only [stream_nth_fr_ne_zero, conts_eq.symm, pred_conts_eq.symm, if_false] at tmp
      rw [tmp]
      ring
/-- Shows that `|v - Aₙ / Bₙ| ≤ 1 / (Bₙ * Bₙ₊₁)`. -/
theorem abs_sub_convergents_le (not_terminated_at_n : ¬(of v).TerminatedAt n) :
    |v - (of v).convergents n| ≤ 1 / ((of v).denominators n * ((of v).denominators <| n + 1)) := by
  -- shorthand notation
  let g := of v
  let nextConts := g.continuantsAux (n + 2)
  set conts := continuantsAux g (n + 1) with conts_eq
  set pred_conts := continuantsAux g n with pred_conts_eq
  -- change the goal to something more readable
  change |v - convergents g n| ≤ 1 / (conts.b * nextConts.b)
  obtain ⟨gp, s_nth_eq⟩ : ∃ gp, g.s.get? n = some gp
  exact Option.ne_none_iff_exists'.1 not_terminated_at_n
  have gp_a_eq_one : gp.a = 1 := of_part_num_eq_one (part_num_eq_s_a s_nth_eq)
  -- unfold the recurrence relation for `nextConts.b`
  have nextConts_b_eq : nextConts.b = pred_conts.b + gp.b * conts.b := by
    simp [continuantsAux_recurrence s_nth_eq pred_conts_eq conts_eq, gp_a_eq_one,
      pred_conts_eq.symm, conts_eq.symm, add_comm]
  let denom := conts.b * (pred_conts.b + gp.b * conts.b)
  suffices |v - g.convergents n| ≤ 1 / denom by rw [nextConts_b_eq]; congr 1
  obtain ⟨ifp_succ_n, succ_nth_stream_eq, ifp_succ_n_b_eq_gp_b⟩ :
    ∃ ifp_succ_n, IntFractPair.stream v (n + 1) = some ifp_succ_n ∧ (ifp_succ_n.b : K) = gp.b
  exact IntFractPair.exists_succ_get?_stream_of_gcf_of_get?_eq_some s_nth_eq
  obtain ⟨ifp_n, stream_nth_eq, stream_nth_fr_ne_zero, if_of_eq_ifp_succ_n⟩ :
    ∃ ifp_n,
      IntFractPair.stream v n = some ifp_n ∧ ifp_n.fr ≠ 0 ∧ IntFractPair.of ifp_n.fr⁻¹ = ifp_succ_n
  exact IntFractPair.succ_nth_stream_eq_some_iff.1 succ_nth_stream_eq
  let denom' := conts.b * (pred_conts.b + ifp_n.fr⁻¹ * conts.b)
  -- now we can use `sub_convergents_eq` to simplify our goal
  suffices |(-1) ^ n / denom'| ≤ 1 / denom by
    have : v - g.convergents n = (-1) ^ n / denom' := by
      -- apply `sub_convergents_eq` and simplify the result
      

Proof state:
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
not_terminated_at_n : ¬TerminatedAt (of v) n
g : GeneralizedContinuedFraction K := of v
nextConts : Pair K := continuantsAux g (n + 2)
conts : Pair K := continuantsAux g (n + 1)
conts_eq : conts = continuantsAux g (n + 1)
pred_conts : Pair K := continuantsAux g n
pred_conts_eq : pred_conts = continuantsAux g n
gp : Pair K
s_nth_eq : Stream'.Seq.get? g.s n = some gp
gp_a_eq_one : gp.a = 1
nextConts_b_eq : nextConts.b = pred_conts.b + gp.b * conts.b
denom : K := conts.b * (pred_conts.b + gp.b * conts.b)
ifp_succ_n : IntFractPair K
succ_nth_stream_eq : IntFractPair.stream v (n + 1) = some ifp_succ_n
ifp_succ_n_b_eq_gp_b : ↑ifp_succ_n.b = gp.b
ifp_n : IntFractPair K
stream_nth_eq : IntFractPair.stream v n = some ifp_n
stream_nth_fr_ne_zero : ifp_n.fr ≠ 0
if_of_eq_ifp_succ_n : IntFractPair.of ifp_n.fr⁻¹ = ifp_succ_n
denom' : K := conts.b * (pred_conts.b + ifp_n.fr⁻¹ * conts.b)
this : |(-1) ^ n / denom'| ≤ 1 / denom
⊢ v - convergents g n = (-1) ^ n / denom'

Next tactic:
have tmp := sub_convergents_eq stream_nth_eq
/-- Shows that `|v - Aₙ / Bₙ| ≤ 1 / (bₙ * Bₙ * Bₙ)`. This bound is worse than the one shown in
`GCF.abs_sub_convergents_le`, but sometimes it is easier to apply and sufficient for one's use case.
 -/
theorem abs_sub_convergents_le' {b : K}
    (nth_part_denom_eq : (of v).partialDenominators.get? n = some b) :
    |v - (of v).convergents n| ≤ 1 / (b * (of v).denominators n * (of v).denominators n) := by
  

Proof state:
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
b : K
nth_part_denom_eq : Stream'.Seq.get? (partialDenominators (of v)) n = some b
⊢ |v - convergents (of v) n| ≤ 1 / (b * denominators (of v) n * denominators (of v) n)

Next tactic:
have not_terminated_at_n : ¬(of v).TerminatedAt n := by
    simp [terminatedAt_iff_part_denom_none, nth_part_denom_eq]
/-- Shows that `|v - Aₙ / Bₙ| ≤ 1 / (bₙ * Bₙ * Bₙ)`. This bound is worse than the one shown in
`GCF.abs_sub_convergents_le`, but sometimes it is easier to apply and sufficient for one's use case.
 -/
theorem abs_sub_convergents_le' {b : K}
    (nth_part_denom_eq : (of v).partialDenominators.get? n = some b) :
    |v - (of v).convergents n| ≤ 1 / (b * (of v).denominators n * (of v).denominators n) := by
  have not_terminated_at_n : ¬(of v).TerminatedAt n := by
    

Proof state:
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
b : K
nth_part_denom_eq : Stream'.Seq.get? (partialDenominators (of v)) n = some b
⊢ ¬TerminatedAt (of v) n

Next tactic:
simp [terminatedAt_iff_part_denom_none, nth_part_denom_eq]
/-- Shows that `|v - Aₙ / Bₙ| ≤ 1 / (bₙ * Bₙ * Bₙ)`. This bound is worse than the one shown in
`GCF.abs_sub_convergents_le`, but sometimes it is easier to apply and sufficient for one's use case.
 -/
theorem abs_sub_convergents_le' {b : K}
    (nth_part_denom_eq : (of v).partialDenominators.get? n = some b) :
    |v - (of v).convergents n| ≤ 1 / (b * (of v).denominators n * (of v).denominators n) := by
  have not_terminated_at_n : ¬(of v).TerminatedAt n := by
    simp [terminatedAt_iff_part_denom_none, nth_part_denom_eq]
  

Proof state:
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
b : K
nth_part_denom_eq : Stream'.Seq.get? (partialDenominators (of v)) n = some b
not_terminated_at_n : ¬TerminatedAt (of v) n
⊢ |v - convergents (of v) n| ≤ 1 / (b * denominators (of v) n * denominators (of v) n)

Next tactic:
refine' (abs_sub_convergents_le not_terminated_at_n).trans _
/-- Shows that `|v - Aₙ / Bₙ| ≤ 1 / (bₙ * Bₙ * Bₙ)`. This bound is worse than the one shown in
`GCF.abs_sub_convergents_le`, but sometimes it is easier to apply and sufficient for one's use case.
 -/
theorem abs_sub_convergents_le' {b : K}
    (nth_part_denom_eq : (of v).partialDenominators.get? n = some b) :
    |v - (of v).convergents n| ≤ 1 / (b * (of v).denominators n * (of v).denominators n) := by
  have not_terminated_at_n : ¬(of v).TerminatedAt n := by
    simp [terminatedAt_iff_part_denom_none, nth_part_denom_eq]
  refine' (abs_sub_convergents_le not_terminated_at_n).trans _
  -- One can show that `0 < (GeneralizedContinuedFraction.of v).denominators n` but it's easier
  -- to consider the case `(GeneralizedContinuedFraction.of v).denominators n = 0`.
  

Proof state:
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
b : K
nth_part_denom_eq : Stream'.Seq.get? (partialDenominators (of v)) n = some b
not_terminated_at_n : ¬TerminatedAt (of v) n
⊢ 1 / (denominators (of v) n * denominators (of v) (n + 1)) ≤ 1 / (b * denominators (of v) n * denominators (of v) n)

Next tactic:
rcases (zero_le_of_denom (K := K)).eq_or_gt with
    ((hB : (GeneralizedContinuedFraction.of v).denominators n = 0) | hB)
/-- Shows that `|v - Aₙ / Bₙ| ≤ 1 / (bₙ * Bₙ * Bₙ)`. This bound is worse than the one shown in
`GCF.abs_sub_convergents_le`, but sometimes it is easier to apply and sufficient for one's use case.
 -/
theorem abs_sub_convergents_le' {b : K}
    (nth_part_denom_eq : (of v).partialDenominators.get? n = some b) :
    |v - (of v).convergents n| ≤ 1 / (b * (of v).denominators n * (of v).denominators n) := by
  have not_terminated_at_n : ¬(of v).TerminatedAt n := by
    simp [terminatedAt_iff_part_denom_none, nth_part_denom_eq]
  refine' (abs_sub_convergents_le not_terminated_at_n).trans _
  -- One can show that `0 < (GeneralizedContinuedFraction.of v).denominators n` but it's easier
  -- to consider the case `(GeneralizedContinuedFraction.of v).denominators n = 0`.
  rcases (zero_le_of_denom (K := K)).eq_or_gt with
    ((hB : (GeneralizedContinuedFraction.of v).denominators n = 0) | hB)
  · 

Proof state:
case inl
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
b : K
nth_part_denom_eq : Stream'.Seq.get? (partialDenominators (of v)) n = some b
not_terminated_at_n : ¬TerminatedAt (of v) n
hB : denominators (of v) n = 0
⊢ 1 / (denominators (of v) n * denominators (of v) (n + 1)) ≤ 1 / (b * denominators (of v) n * denominators (of v) n)

Next tactic:
simp only [hB, mul_zero, zero_mul, div_zero, le_refl]