Theorem: GeneralizedContinuedFraction.abs_sub_convergents_le'
File: Mathlib/Algebra/ContinuedFractions/Computation/Approximations.lean

tactic: have not_terminated_at_n : ¬(of v).TerminatedAt n := by
  simp [terminatedAt_iff_part_denom_none, nth_part_denom_eq]
state_before: K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
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)
state_after: K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
b : K
nth_part_denom_eq : (of v).partialDenominators.get? n = some b
not_terminated_at_n : ¬(of v).TerminatedAt n
⊢ |v - (of v).convergents n| ≤ 1 / (b * (of v).denominators n * (of v).denominators n)

tactic: refine (abs_sub_convergents_le not_terminated_at_n).trans ?_
state_before: K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
b : K
nth_part_denom_eq : (of v).partialDenominators.get? n = some b
not_terminated_at_n : ¬(of v).TerminatedAt n
⊢ |v - (of v).convergents n| ≤ 1 / (b * (of v).denominators n * (of v).denominators n)
state_after: K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
b : K
nth_part_denom_eq : (of v).partialDenominators.get? n = some b
not_terminated_at_n : ¬(of v).TerminatedAt n
⊢ 1 / ((of v).denominators n * (of v).denominators (n + 1)) ≤ 1 / (b * (of v).denominators n * (of v).denominators n)

tactic: rcases (zero_le_of_denom (K := K)).eq_or_gt with
  ((hB : (GeneralizedContinuedFraction.of v).denominators n = 0) | hB)
state_before: K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
b : K
nth_part_denom_eq : (of v).partialDenominators.get? n = some b
not_terminated_at_n : ¬(of v).TerminatedAt n
⊢ 1 / ((of v).denominators n * (of v).denominators (n + 1)) ≤ 1 / (b * (of v).denominators n * (of v).denominators n)
state_after: case inl
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
b : K
nth_part_denom_eq : (of v).partialDenominators.get? n = some b
not_terminated_at_n : ¬(of v).TerminatedAt n
hB : (of v).denominators n = 0
⊢ 1 / ((of v).denominators n * (of v).denominators (n + 1)) ≤ 1 / (b * (of v).denominators n * (of v).denominators n)

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

tactic: simp [terminatedAt_iff_part_denom_none, nth_part_denom_eq]
state_before: K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
b : K
nth_part_denom_eq : (of v).partialDenominators.get? n = some b
⊢ ¬(of v).TerminatedAt n
state_after: no goals

tactic: simp only [hB, mul_zero, zero_mul, div_zero, le_refl]
state_before: case inl
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
b : K
nth_part_denom_eq : (of v).partialDenominators.get? n = some b
not_terminated_at_n : ¬(of v).TerminatedAt n
hB : (of v).denominators n = 0
⊢ 1 / ((of v).denominators n * (of v).denominators (n + 1)) ≤ 1 / (b * (of v).denominators n * (of v).denominators n)
state_after: no goals

tactic: apply one_div_le_one_div_of_le
state_before: case inr
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
b : K
nth_part_denom_eq : (of v).partialDenominators.get? n = some b
not_terminated_at_n : ¬(of v).TerminatedAt n
hB : 0 < (of v).denominators n
⊢ 1 / ((of v).denominators n * (of v).denominators (n + 1)) ≤ 1 / (b * (of v).denominators n * (of v).denominators n)
state_after: case inr.ha
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
b : K
nth_part_denom_eq : (of v).partialDenominators.get? n = some b
not_terminated_at_n : ¬(of v).TerminatedAt n
hB : 0 < (of v).denominators n
⊢ 0 < b * (of v).denominators n * (of v).denominators n

case inr.h
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
b : K
nth_part_denom_eq : (of v).partialDenominators.get? n = some b
not_terminated_at_n : ¬(of v).TerminatedAt n
hB : 0 < (of v).denominators n
⊢ b * (of v).denominators n * (of v).denominators n ≤ (of v).denominators n * (of v).denominators (n + 1)

tactic: have : 0 < b := zero_lt_one.trans_le (of_one_le_get?_part_denom nth_part_denom_eq)
state_before: case inr.ha
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
b : K
nth_part_denom_eq : (of v).partialDenominators.get? n = some b
not_terminated_at_n : ¬(of v).TerminatedAt n
hB : 0 < (of v).denominators n
⊢ 0 < b * (of v).denominators n * (of v).denominators n
state_after: case inr.ha
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
b : K
nth_part_denom_eq : (of v).partialDenominators.get? n = some b
not_terminated_at_n : ¬(of v).TerminatedAt n
hB : 0 < (of v).denominators n
this : 0 < b
⊢ 0 < b * (of v).denominators n * (of v).denominators n

tactic: apply_rules [mul_pos]
state_before: case inr.ha
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
b : K
nth_part_denom_eq : (of v).partialDenominators.get? n = some b
not_terminated_at_n : ¬(of v).TerminatedAt n
hB : 0 < (of v).denominators n
this : 0 < b
⊢ 0 < b * (of v).denominators n * (of v).denominators n
state_after: no goals

tactic: conv_rhs => rw [mul_comm]
state_before: case inr.h
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
b : K
nth_part_denom_eq : (of v).partialDenominators.get? n = some b
not_terminated_at_n : ¬(of v).TerminatedAt n
hB : 0 < (of v).denominators n
⊢ b * (of v).denominators n * (of v).denominators n ≤ (of v).denominators n * (of v).denominators (n + 1)
state_after: case inr.h
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
b : K
nth_part_denom_eq : (of v).partialDenominators.get? n = some b
not_terminated_at_n : ¬(of v).TerminatedAt n
hB : 0 < (of v).denominators n
⊢ b * (of v).denominators n * (of v).denominators n ≤ (of v).denominators (n + 1) * (of v).denominators n

tactic: exact mul_le_mul_of_nonneg_right (le_of_succ_get?_denom nth_part_denom_eq) hB.le
state_before: case inr.h
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
b : K
nth_part_denom_eq : (of v).partialDenominators.get? n = some b
not_terminated_at_n : ¬(of v).TerminatedAt n
hB : 0 < (of v).denominators n
⊢ b * (of v).denominators n * (of v).denominators n ≤ (of v).denominators (n + 1) * (of v).denominators n
state_after: no goals