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

tactic: let g := of v
state_before: K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
⊢ (of v).denominators n ≤ (of v).denominators (n + 1)
state_after: K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
g : GeneralizedContinuedFraction K := of v
⊢ (of v).denominators n ≤ (of v).denominators (n + 1)

tactic: cases' Decidable.em <| g.partialDenominators.TerminatedAt n with terminated not_terminated
state_before: K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
g : GeneralizedContinuedFraction K := of v
⊢ (of v).denominators n ≤ (of v).denominators (n + 1)
state_after: case inl
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
g : GeneralizedContinuedFraction K := of v
terminated : g.partialDenominators.TerminatedAt n
⊢ (of v).denominators n ≤ (of v).denominators (n + 1)

case inr
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
g : GeneralizedContinuedFraction K := of v
not_terminated : ¬g.partialDenominators.TerminatedAt n
⊢ (of v).denominators n ≤ (of v).denominators (n + 1)

tactic: have : g.partialDenominators.get? n = none := by rwa [Stream'.Seq.TerminatedAt] at terminated
state_before: case inl
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
g : GeneralizedContinuedFraction K := of v
terminated : g.partialDenominators.TerminatedAt n
⊢ (of v).denominators n ≤ (of v).denominators (n + 1)
state_after: case inl
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
g : GeneralizedContinuedFraction K := of v
terminated : g.partialDenominators.TerminatedAt n
this : g.partialDenominators.get? n = none
⊢ (of v).denominators n ≤ (of v).denominators (n + 1)

tactic: have : g.TerminatedAt n :=
  terminatedAt_iff_part_denom_none.2 (by rwa [Stream'.Seq.TerminatedAt] at terminated)
state_before: case inl
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
g : GeneralizedContinuedFraction K := of v
terminated : g.partialDenominators.TerminatedAt n
this : g.partialDenominators.get? n = none
⊢ (of v).denominators n ≤ (of v).denominators (n + 1)
state_after: case inl
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
g : GeneralizedContinuedFraction K := of v
terminated : g.partialDenominators.TerminatedAt n
this✝ : g.partialDenominators.get? n = none
this : g.TerminatedAt n
⊢ (of v).denominators n ≤ (of v).denominators (n + 1)

tactic: have : g.denominators (n + 1) = g.denominators n :=
  denominators_stable_of_terminated n.le_succ this
state_before: case inl
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
g : GeneralizedContinuedFraction K := of v
terminated : g.partialDenominators.TerminatedAt n
this✝ : g.partialDenominators.get? n = none
this : g.TerminatedAt n
⊢ (of v).denominators n ≤ (of v).denominators (n + 1)
state_after: case inl
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
g : GeneralizedContinuedFraction K := of v
terminated : g.partialDenominators.TerminatedAt n
this✝¹ : g.partialDenominators.get? n = none
this✝ : g.TerminatedAt n
this : g.denominators (n + 1) = g.denominators n
⊢ (of v).denominators n ≤ (of v).denominators (n + 1)

tactic: rw [this]
state_before: case inl
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
g : GeneralizedContinuedFraction K := of v
terminated : g.partialDenominators.TerminatedAt n
this✝¹ : g.partialDenominators.get? n = none
this✝ : g.TerminatedAt n
this : g.denominators (n + 1) = g.denominators n
⊢ (of v).denominators n ≤ (of v).denominators (n + 1)
state_after: no goals

tactic: rwa [Stream'.Seq.TerminatedAt] at terminated
state_before: K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
g : GeneralizedContinuedFraction K := of v
terminated : g.partialDenominators.TerminatedAt n
⊢ g.partialDenominators.get? n = none
state_after: no goals

tactic: rwa [Stream'.Seq.TerminatedAt] at terminated
state_before: K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
g : GeneralizedContinuedFraction K := of v
terminated : g.partialDenominators.TerminatedAt n
this : g.partialDenominators.get? n = none
⊢ g.partialDenominators.get? n = none
state_after: no goals

tactic: obtain ⟨b, nth_part_denom_eq⟩ : ∃ b, g.partialDenominators.get? n = some b :=
  Option.ne_none_iff_exists'.mp not_terminated
state_before: case inr
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
g : GeneralizedContinuedFraction K := of v
not_terminated : ¬g.partialDenominators.TerminatedAt n
⊢ (of v).denominators n ≤ (of v).denominators (n + 1)
state_after: case inr.intro
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
g : GeneralizedContinuedFraction K := of v
not_terminated : ¬g.partialDenominators.TerminatedAt n
b : K
nth_part_denom_eq : g.partialDenominators.get? n = some b
⊢ (of v).denominators n ≤ (of v).denominators (n + 1)

tactic: have : 1 ≤ b := of_one_le_get?_part_denom nth_part_denom_eq
state_before: case inr.intro
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
g : GeneralizedContinuedFraction K := of v
not_terminated : ¬g.partialDenominators.TerminatedAt n
b : K
nth_part_denom_eq : g.partialDenominators.get? n = some b
⊢ (of v).denominators n ≤ (of v).denominators (n + 1)
state_after: case inr.intro
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
g : GeneralizedContinuedFraction K := of v
not_terminated : ¬g.partialDenominators.TerminatedAt n
b : K
nth_part_denom_eq : g.partialDenominators.get? n = some b
this : 1 ≤ b
⊢ (of v).denominators n ≤ (of v).denominators (n + 1)

tactic: calc
  g.denominators n ≤ b * g.denominators n := by
    simpa using mul_le_mul_of_nonneg_right this zero_le_of_denom
  _ ≤ g.denominators (n + 1) := le_of_succ_get?_denom nth_part_denom_eq
state_before: case inr.intro
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
g : GeneralizedContinuedFraction K := of v
not_terminated : ¬g.partialDenominators.TerminatedAt n
b : K
nth_part_denom_eq : g.partialDenominators.get? n = some b
this : 1 ≤ b
⊢ (of v).denominators n ≤ (of v).denominators (n + 1)
state_after: no goals

tactic: simpa using mul_le_mul_of_nonneg_right this zero_le_of_denom
state_before: K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
g : GeneralizedContinuedFraction K := of v
not_terminated : ¬g.partialDenominators.TerminatedAt n
b : K
nth_part_denom_eq : g.partialDenominators.get? n = some b
this : 1 ≤ b
⊢ g.denominators n ≤ b * g.denominators n
state_after: no goals