l3lab/ntp-mathlib huggingface dataset:
theorem fib_le_of_continuantsAux_b :
    n ≤ 1 ∨ ¬(of v).TerminatedAt (n - 2) → (fib n : K) ≤ ((of v).continuantsAux n).b :=
  Nat.strong_induction_on n
    (by
      intro n IH hyp
      rcases n with (_ | _ | n)
      · simp [fib_add_two, continuantsAux] -- case n = 0
      · simp [fib_add_two, continuantsAux] -- case n = 1
      · let g := of v -- case 2 ≤ n
        have : ¬n + 2 ≤ 1 := by linarith
        have not_terminated_at_n : ¬g.TerminatedAt n := Or.resolve_left hyp this
        obtain ⟨gp, s_ppred_nth_eq⟩ : ∃ gp, g.s.get? n = some gp
        exact Option.ne_none_iff_exists'.mp not_terminated_at_n
        set pconts := g.continuantsAux (n + 1) with pconts_eq
        set ppconts := g.continuantsAux n with ppconts_eq
        -- use the recurrence of `continuantsAux`
        suffices (fib n : K) + fib (n + 1) ≤ gp.a * ppconts.b + gp.b * pconts.b by
          simpa [fib_add_two, add_comm,
            continuantsAux_recurrence s_ppred_nth_eq ppconts_eq pconts_eq]
        -- make use of the fact that `gp.a = 1`
        suffices (fib n : K) + fib (n + 1) ≤ ppconts.b + gp.b * pconts.b by
          simpa [of_part_num_eq_one <| part_num_eq_s_a s_ppred_nth_eq]
        have not_terminated_at_pred_n : ¬g.TerminatedAt (n - 1) :=
          mt (terminated_stable <| Nat.sub_le n 1) not_terminated_at_n
        have not_terminated_at_ppred_n : ¬TerminatedAt g (n - 2) :=
          mt (terminated_stable (n - 1).pred_le) not_terminated_at_pred_n
        -- use the IH to get the inequalities for `pconts` and `ppconts`
        have ppred_nth_fib_le_ppconts_B : (fib n : K) ≤ ppconts.b :=
          IH n (lt_trans (Nat.lt.base n) <| Nat.lt.base <| n + 1) (Or.inr not_terminated_at_ppred_n)
        suffices : (fib (n + 1) : K) ≤ gp.b * pconts.b
        solve_by_elim [_root_.add_le_add ppred_nth_fib_le_ppconts_B]
        -- finally use the fact that `1 ≤ gp.b` to solve the goal
        suffices 1 * (fib (n + 1) : K) ≤ gp.b * pconts.b by rwa [one_mul] at this
        have one_le_gp_b : (1 : K) ≤ gp.b :=
          of_one_le_get?_part_denom (part_denom_eq_s_b s_ppred_nth_eq)
        have : (0 : K) ≤ fib (n + 1) := mod_cast (fib (n + 1)).zero_le
        have : (0 : K) ≤ gp.b := le_trans zero_le_one one_le_gp_b
        

Proof state:
case this
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
IH : ∀ m < Nat.succ (Nat.succ n), m ≤ 1 ∨ ¬TerminatedAt (of v) (m - 2) → ↑(fib m) ≤ (continuantsAux (of v) m).b
hyp : Nat.succ (Nat.succ n) ≤ 1 ∨ ¬TerminatedAt (of v) (Nat.succ (Nat.succ n) - 2)
g : GeneralizedContinuedFraction K := of v
this✝¹ : ¬n + 2 ≤ 1
not_terminated_at_n : ¬TerminatedAt g n
gp : Pair K
s_ppred_nth_eq : Stream'.Seq.get? g.s n = some gp
pconts : Pair K := continuantsAux g (n + 1)
pconts_eq : pconts = continuantsAux g (n + 1)
ppconts : Pair K := continuantsAux g n
ppconts_eq : ppconts = continuantsAux g n
not_terminated_at_pred_n : ¬TerminatedAt g (n - 1)
not_terminated_at_ppred_n : ¬TerminatedAt g (n - 2)
ppred_nth_fib_le_ppconts_B : ↑(fib n) ≤ ppconts.b
one_le_gp_b : 1 ≤ gp.b
this✝ : 0 ≤ ↑(fib (n + 1))
this : 0 ≤ gp.b
⊢ 1 * ↑(fib (n + 1)) ≤ gp.b * pconts.b

Next tactic:
mono
/-- Shows that the `n`th denominator is greater than or equal to the `n + 1`th fibonacci number,
that is `Nat.fib (n + 1) ≤ Bₙ`. -/
theorem succ_nth_fib_le_of_nth_denom (hyp : n = 0 ∨ ¬(of v).TerminatedAt (n - 1)) :
    (fib (n + 1) : K) ≤ (of v).denominators n := by
  

Proof state:
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
hyp : n = 0 ∨ ¬TerminatedAt (of v) (n - 1)
⊢ ↑(fib (n + 1)) ≤ denominators (of v) n

Next tactic:
rw [denom_eq_conts_b, nth_cont_eq_succ_nth_cont_aux]
/-- Shows that the `n`th denominator is greater than or equal to the `n + 1`th fibonacci number,
that is `Nat.fib (n + 1) ≤ Bₙ`. -/
theorem succ_nth_fib_le_of_nth_denom (hyp : n = 0 ∨ ¬(of v).TerminatedAt (n - 1)) :
    (fib (n + 1) : K) ≤ (of v).denominators n := by
  rw [denom_eq_conts_b, nth_cont_eq_succ_nth_cont_aux]
  

Proof state:
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
hyp : n = 0 ∨ ¬TerminatedAt (of v) (n - 1)
⊢ ↑(fib (n + 1)) ≤ (continuantsAux (of v) (n + 1)).b

Next tactic:
have : n + 1 ≤ 1 ∨ ¬(of v).TerminatedAt (n - 1) := by
    cases' n with n
    case zero => exact Or.inl <| le_refl 1
    case succ => exact Or.inr (Or.resolve_left hyp n.succ_ne_zero)
/-- Shows that the `n`th denominator is greater than or equal to the `n + 1`th fibonacci number,
that is `Nat.fib (n + 1) ≤ Bₙ`. -/
theorem succ_nth_fib_le_of_nth_denom (hyp : n = 0 ∨ ¬(of v).TerminatedAt (n - 1)) :
    (fib (n + 1) : K) ≤ (of v).denominators n := by
  rw [denom_eq_conts_b, nth_cont_eq_succ_nth_cont_aux]
  have : n + 1 ≤ 1 ∨ ¬(of v).TerminatedAt (n - 1) := by
    

Proof state:
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
hyp : n = 0 ∨ ¬TerminatedAt (of v) (n - 1)
⊢ n + 1 ≤ 1 ∨ ¬TerminatedAt (of v) (n - 1)

Next tactic:
cases' n with n
/-- Shows that the `n`th denominator is greater than or equal to the `n + 1`th fibonacci number,
that is `Nat.fib (n + 1) ≤ Bₙ`. -/
theorem succ_nth_fib_le_of_nth_denom (hyp : n = 0 ∨ ¬(of v).TerminatedAt (n - 1)) :
    (fib (n + 1) : K) ≤ (of v).denominators n := by
  rw [denom_eq_conts_b, nth_cont_eq_succ_nth_cont_aux]
  have : n + 1 ≤ 1 ∨ ¬(of v).TerminatedAt (n - 1) := by
    cases' n with n
    

Proof state:
case zero
K : Type u_1
v : K
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
hyp : zero = 0 ∨ ¬TerminatedAt (of v) (zero - 1)
⊢ zero + 1 ≤ 1 ∨ ¬TerminatedAt (of v) (zero - 1)
case succ
K : Type u_1
v : K
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : Nat.succ n = 0 ∨ ¬TerminatedAt (of v) (Nat.succ n - 1)
⊢ Nat.succ n + 1 ≤ 1 ∨ ¬TerminatedAt (of v) (Nat.succ n - 1)

Next tactic:
case zero => exact Or.inl <| le_refl 1
/-- Shows that the `n`th denominator is greater than or equal to the `n + 1`th fibonacci number,
that is `Nat.fib (n + 1) ≤ Bₙ`. -/
theorem succ_nth_fib_le_of_nth_denom (hyp : n = 0 ∨ ¬(of v).TerminatedAt (n - 1)) :
    (fib (n + 1) : K) ≤ (of v).denominators n := by
  rw [denom_eq_conts_b, nth_cont_eq_succ_nth_cont_aux]
  have : n + 1 ≤ 1 ∨ ¬(of v).TerminatedAt (n - 1) := by
    cases' n with n
    

Proof state:
K : Type u_1
v : K
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
hyp : zero = 0 ∨ ¬TerminatedAt (of v) (zero - 1)
⊢ zero + 1 ≤ 1 ∨ ¬TerminatedAt (of v) (zero - 1)

Next tactic:
case zero => exact Or.inl <| le_refl 1
/-- Shows that the `n`th denominator is greater than or equal to the `n + 1`th fibonacci number,
that is `Nat.fib (n + 1) ≤ Bₙ`. -/
theorem succ_nth_fib_le_of_nth_denom (hyp : n = 0 ∨ ¬(of v).TerminatedAt (n - 1)) :
    (fib (n + 1) : K) ≤ (of v).denominators n := by
  rw [denom_eq_conts_b, nth_cont_eq_succ_nth_cont_aux]
  have : n + 1 ≤ 1 ∨ ¬(of v).TerminatedAt (n - 1) := by
    cases' n with n
    case zero => 

Proof state:
K : Type u_1
v : K
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
hyp : zero = 0 ∨ ¬TerminatedAt (of v) (zero - 1)
⊢ zero + 1 ≤ 1 ∨ ¬TerminatedAt (of v) (zero - 1)

Next tactic:
exact Or.inl <| le_refl 1
/-- Shows that the `n`th denominator is greater than or equal to the `n + 1`th fibonacci number,
that is `Nat.fib (n + 1) ≤ Bₙ`. -/
theorem succ_nth_fib_le_of_nth_denom (hyp : n = 0 ∨ ¬(of v).TerminatedAt (n - 1)) :
    (fib (n + 1) : K) ≤ (of v).denominators n := by
  rw [denom_eq_conts_b, nth_cont_eq_succ_nth_cont_aux]
  have : n + 1 ≤ 1 ∨ ¬(of v).TerminatedAt (n - 1) := by
    cases' n with n
    case zero => exact Or.inl <| le_refl 1
    

Proof state:
case succ
K : Type u_1
v : K
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : Nat.succ n = 0 ∨ ¬TerminatedAt (of v) (Nat.succ n - 1)
⊢ Nat.succ n + 1 ≤ 1 ∨ ¬TerminatedAt (of v) (Nat.succ n - 1)

Next tactic:
case succ => exact Or.inr (Or.resolve_left hyp n.succ_ne_zero)
/-- Shows that the `n`th denominator is greater than or equal to the `n + 1`th fibonacci number,
that is `Nat.fib (n + 1) ≤ Bₙ`. -/
theorem succ_nth_fib_le_of_nth_denom (hyp : n = 0 ∨ ¬(of v).TerminatedAt (n - 1)) :
    (fib (n + 1) : K) ≤ (of v).denominators n := by
  rw [denom_eq_conts_b, nth_cont_eq_succ_nth_cont_aux]
  have : n + 1 ≤ 1 ∨ ¬(of v).TerminatedAt (n - 1) := by
    cases' n with n
    case zero => exact Or.inl <| le_refl 1
    

Proof state:
K : Type u_1
v : K
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : Nat.succ n = 0 ∨ ¬TerminatedAt (of v) (Nat.succ n - 1)
⊢ Nat.succ n + 1 ≤ 1 ∨ ¬TerminatedAt (of v) (Nat.succ n - 1)

Next tactic:
case succ => exact Or.inr (Or.resolve_left hyp n.succ_ne_zero)
/-- Shows that the `n`th denominator is greater than or equal to the `n + 1`th fibonacci number,
that is `Nat.fib (n + 1) ≤ Bₙ`. -/
theorem succ_nth_fib_le_of_nth_denom (hyp : n = 0 ∨ ¬(of v).TerminatedAt (n - 1)) :
    (fib (n + 1) : K) ≤ (of v).denominators n := by
  rw [denom_eq_conts_b, nth_cont_eq_succ_nth_cont_aux]
  have : n + 1 ≤ 1 ∨ ¬(of v).TerminatedAt (n - 1) := by
    cases' n with n
    case zero => exact Or.inl <| le_refl 1
    case succ => 

Proof state:
K : Type u_1
v : K
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : Nat.succ n = 0 ∨ ¬TerminatedAt (of v) (Nat.succ n - 1)
⊢ Nat.succ n + 1 ≤ 1 ∨ ¬TerminatedAt (of v) (Nat.succ n - 1)

Next tactic:
exact Or.inr (Or.resolve_left hyp n.succ_ne_zero)
/-- Shows that the `n`th denominator is greater than or equal to the `n + 1`th fibonacci number,
that is `Nat.fib (n + 1) ≤ Bₙ`. -/
theorem succ_nth_fib_le_of_nth_denom (hyp : n = 0 ∨ ¬(of v).TerminatedAt (n - 1)) :
    (fib (n + 1) : K) ≤ (of v).denominators n := by
  rw [denom_eq_conts_b, nth_cont_eq_succ_nth_cont_aux]
  have : n + 1 ≤ 1 ∨ ¬(of v).TerminatedAt (n - 1) := by
    cases' n with n
    case zero => exact Or.inl <| le_refl 1
    case succ => exact Or.inr (Or.resolve_left hyp n.succ_ne_zero)
  

Proof state:
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
hyp : n = 0 ∨ ¬TerminatedAt (of v) (n - 1)
this : n + 1 ≤ 1 ∨ ¬TerminatedAt (of v) (n - 1)
⊢ ↑(fib (n + 1)) ≤ (continuantsAux (of v) (n + 1)).b

Next tactic:
exact fib_le_of_continuantsAux_b this
theorem zero_le_of_continuantsAux_b : 0 ≤ ((of v).continuantsAux n).b := by
  

Proof state:
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
⊢ 0 ≤ (continuantsAux (of v) n).b

Next tactic:
let g := of v
theorem zero_le_of_continuantsAux_b : 0 ≤ ((of v).continuantsAux n).b := by
  let g := of v
  

Proof state:
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
g : GeneralizedContinuedFraction K := of v
⊢ 0 ≤ (continuantsAux (of v) n).b

Next tactic:
induction' n with n IH
theorem zero_le_of_continuantsAux_b : 0 ≤ ((of v).continuantsAux n).b := by
  let g := of v
  induction' n with n IH
  

Proof state:
case zero
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
g : GeneralizedContinuedFraction K := of v
⊢ 0 ≤ (continuantsAux (of v) zero).b
case succ
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
g : GeneralizedContinuedFraction K := of v
n : ℕ
IH : 0 ≤ (continuantsAux (of v) n).b
⊢ 0 ≤ (continuantsAux (of v) (Nat.succ n)).b

Next tactic:
case zero => rfl
theorem zero_le_of_continuantsAux_b : 0 ≤ ((of v).continuantsAux n).b := by
  let g := of v
  induction' n with n IH
  

Proof state:
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
g : GeneralizedContinuedFraction K := of v
⊢ 0 ≤ (continuantsAux (of v) zero).b

Next tactic:
case zero => rfl
theorem zero_le_of_continuantsAux_b : 0 ≤ ((of v).continuantsAux n).b := by
  let g := of v
  induction' n with n IH
  case zero => 

Proof state:
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
g : GeneralizedContinuedFraction K := of v
⊢ 0 ≤ (continuantsAux (of v) zero).b

Next tactic:
rfl
theorem zero_le_of_continuantsAux_b : 0 ≤ ((of v).continuantsAux n).b := by
  let g := of v
  induction' n with n IH
  case zero => rfl
  

Proof state:
case succ
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
g : GeneralizedContinuedFraction K := of v
n : ℕ
IH : 0 ≤ (continuantsAux (of v) n).b
⊢ 0 ≤ (continuantsAux (of v) (Nat.succ n)).b

Next tactic:
case succ =>
    cases' Decidable.em <| g.TerminatedAt (n - 1) with terminated not_terminated
    · -- terminating case
      cases' n with n
      · simp [succ_eq_add_one, zero_le_one]
      · have : g.continuantsAux (n + 2) = g.continuantsAux (n + 1) :=
          continuantsAux_stable_step_of_terminated terminated
        simp only [this, IH]
    · -- non-terminating case
      calc
        (0 : K) ≤ fib (n + 1) := mod_cast (n + 1).fib.zero_le
        _ ≤ ((of v).continuantsAux (n + 1)).b := fib_le_of_continuantsAux_b (Or.inr not_terminated)
theorem zero_le_of_continuantsAux_b : 0 ≤ ((of v).continuantsAux n).b := by
  let g := of v
  induction' n with n IH
  case zero => rfl
  

Proof state:
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
g : GeneralizedContinuedFraction K := of v
n : ℕ
IH : 0 ≤ (continuantsAux (of v) n).b
⊢ 0 ≤ (continuantsAux (of v) (Nat.succ n)).b

Next tactic:
case succ =>
    cases' Decidable.em <| g.TerminatedAt (n - 1) with terminated not_terminated
    · -- terminating case
      cases' n with n
      · simp [succ_eq_add_one, zero_le_one]
      · have : g.continuantsAux (n + 2) = g.continuantsAux (n + 1) :=
          continuantsAux_stable_step_of_terminated terminated
        simp only [this, IH]
    · -- non-terminating case
      calc
        (0 : K) ≤ fib (n + 1) := mod_cast (n + 1).fib.zero_le
        _ ≤ ((of v).continuantsAux (n + 1)).b := fib_le_of_continuantsAux_b (Or.inr not_terminated)
theorem zero_le_of_continuantsAux_b : 0 ≤ ((of v).continuantsAux n).b := by
  let g := of v
  induction' n with n IH
  case zero => rfl
  case succ =>
    

Proof state:
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
g : GeneralizedContinuedFraction K := of v
n : ℕ
IH : 0 ≤ (continuantsAux (of v) n).b
⊢ 0 ≤ (continuantsAux (of v) (Nat.succ n)).b

Next tactic:
cases' Decidable.em <| g.TerminatedAt (n - 1) with terminated not_terminated
theorem zero_le_of_continuantsAux_b : 0 ≤ ((of v).continuantsAux n).b := by
  let g := of v
  induction' n with n IH
  case zero => rfl
  case succ =>
    cases' Decidable.em <| g.TerminatedAt (n - 1) with terminated not_terminated
    · -- terminating case
      

Proof state:
case inl
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
g : GeneralizedContinuedFraction K := of v
n : ℕ
IH : 0 ≤ (continuantsAux (of v) n).b
terminated : TerminatedAt g (n - 1)
⊢ 0 ≤ (continuantsAux (of v) (Nat.succ n)).b

Next tactic:
cases' n with n
theorem zero_le_of_continuantsAux_b : 0 ≤ ((of v).continuantsAux n).b := by
  let g := of v
  induction' n with n IH
  case zero => rfl
  case succ =>
    cases' Decidable.em <| g.TerminatedAt (n - 1) with terminated not_terminated
    · -- terminating case
      cases' n with n
      · 

Proof state:
case inl.zero
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
g : GeneralizedContinuedFraction K := of v
IH : 0 ≤ (continuantsAux (of v) zero).b
terminated : TerminatedAt g (zero - 1)
⊢ 0 ≤ (continuantsAux (of v) (Nat.succ zero)).b

Next tactic:
simp [succ_eq_add_one, zero_le_one]
theorem zero_le_of_continuantsAux_b : 0 ≤ ((of v).continuantsAux n).b := by
  let g := of v
  induction' n with n IH
  case zero => rfl
  case succ =>
    cases' Decidable.em <| g.TerminatedAt (n - 1) with terminated not_terminated
    · -- terminating case
      cases' n with n
      · simp [succ_eq_add_one, zero_le_one]
      · 

Proof state:
case inl.succ
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
g : GeneralizedContinuedFraction K := of v
n : ℕ
IH : 0 ≤ (continuantsAux (of v) (Nat.succ n)).b
terminated : TerminatedAt g (Nat.succ n - 1)
⊢ 0 ≤ (continuantsAux (of v) (Nat.succ (Nat.succ n))).b

Next tactic:
have : g.continuantsAux (n + 2) = g.continuantsAux (n + 1) :=
          continuantsAux_stable_step_of_terminated terminated
theorem zero_le_of_continuantsAux_b : 0 ≤ ((of v).continuantsAux n).b := by
  let g := of v
  induction' n with n IH
  case zero => rfl
  case succ =>
    cases' Decidable.em <| g.TerminatedAt (n - 1) with terminated not_terminated
    · -- terminating case
      cases' n with n
      · simp [succ_eq_add_one, zero_le_one]
      · have : g.continuantsAux (n + 2) = g.continuantsAux (n + 1) :=
          continuantsAux_stable_step_of_terminated terminated
        

Proof state:
case inl.succ
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
g : GeneralizedContinuedFraction K := of v
n : ℕ
IH : 0 ≤ (continuantsAux (of v) (Nat.succ n)).b
terminated : TerminatedAt g (Nat.succ n - 1)
this : continuantsAux g (n + 2) = continuantsAux g (n + 1)
⊢ 0 ≤ (continuantsAux (of v) (Nat.succ (Nat.succ n))).b

Next tactic:
simp only [this, IH]
theorem zero_le_of_continuantsAux_b : 0 ≤ ((of v).continuantsAux n).b := by
  let g := of v
  induction' n with n IH
  case zero => rfl
  case succ =>
    cases' Decidable.em <| g.TerminatedAt (n - 1) with terminated not_terminated
    · -- terminating case
      cases' n with n
      · simp [succ_eq_add_one, zero_le_one]
      · have : g.continuantsAux (n + 2) = g.continuantsAux (n + 1) :=
          continuantsAux_stable_step_of_terminated terminated
        simp only [this, IH]
    · -- non-terminating case
      

Proof state:
case inr
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
g : GeneralizedContinuedFraction K := of v
n : ℕ
IH : 0 ≤ (continuantsAux (of v) n).b
not_terminated : ¬TerminatedAt g (n - 1)
⊢ 0 ≤ (continuantsAux (of v) (Nat.succ n)).b

Next tactic:
calc
        (0 : K) ≤ fib (n + 1) := mod_cast (n + 1).fib.zero_le
        _ ≤ ((of v).continuantsAux (n + 1)).b := fib_le_of_continuantsAux_b (Or.inr not_terminated)
/-- Shows that all denominators are nonnegative. -/
theorem zero_le_of_denom : 0 ≤ (of v).denominators n := by
  

Proof state:
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
⊢ 0 ≤ denominators (of v) n

Next tactic:
rw [denom_eq_conts_b, nth_cont_eq_succ_nth_cont_aux]
/-- Shows that all denominators are nonnegative. -/
theorem zero_le_of_denom : 0 ≤ (of v).denominators n := by
  rw [denom_eq_conts_b, nth_cont_eq_succ_nth_cont_aux]; 

Proof state:
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
⊢ 0 ≤ (continuantsAux (of v) (n + 1)).b

Next tactic:
exact zero_le_of_continuantsAux_b
theorem le_of_succ_succ_get?_continuantsAux_b {b : K}
    (nth_part_denom_eq : (of v).partialDenominators.get? n = some b) :
    b * ((of v).continuantsAux <| n + 1).b ≤ ((of v).continuantsAux <| n + 2).b := 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
⊢ b * (continuantsAux (of v) (n + 1)).b ≤ (continuantsAux (of v) (n + 2)).b

Next tactic:
obtain ⟨gp_n, nth_s_eq, rfl⟩ : ∃ gp_n, (of v).s.get? n = some gp_n ∧ gp_n.b = b
theorem le_of_succ_succ_get?_continuantsAux_b {b : K}
    (nth_part_denom_eq : (of v).partialDenominators.get? n = some b) :
    b * ((of v).continuantsAux <| n + 1).b ≤ ((of v).continuantsAux <| n + 2).b := by
  obtain ⟨gp_n, nth_s_eq, rfl⟩ : ∃ gp_n, (of v).s.get? n = some gp_n ∧ gp_n.b = b
  

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
⊢ ∃ gp_n, Stream'.Seq.get? (of v).s n = some gp_n ∧ gp_n.b = b
case intro.intro
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
gp_n : Pair K
nth_s_eq : Stream'.Seq.get? (of v).s n = some gp_n
nth_part_denom_eq : Stream'.Seq.get? (partialDenominators (of v)) n = some gp_n.b
⊢ gp_n.b * (continuantsAux (of v) (n + 1)).b ≤ (continuantsAux (of v) (n + 2)).b

Next tactic:
exact exists_s_b_of_part_denom nth_part_denom_eq
theorem le_of_succ_succ_get?_continuantsAux_b {b : K}
    (nth_part_denom_eq : (of v).partialDenominators.get? n = some b) :
    b * ((of v).continuantsAux <| n + 1).b ≤ ((of v).continuantsAux <| n + 2).b := by
  obtain ⟨gp_n, nth_s_eq, rfl⟩ : ∃ gp_n, (of v).s.get? n = some gp_n ∧ gp_n.b = b
  exact exists_s_b_of_part_denom nth_part_denom_eq
  

Proof state:
case intro.intro
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
gp_n : Pair K
nth_s_eq : Stream'.Seq.get? (of v).s n = some gp_n
nth_part_denom_eq : Stream'.Seq.get? (partialDenominators (of v)) n = some gp_n.b
⊢ gp_n.b * (continuantsAux (of v) (n + 1)).b ≤ (continuantsAux (of v) (n + 2)).b

Next tactic:
simp [of_part_num_eq_one (part_num_eq_s_a nth_s_eq), zero_le_of_continuantsAux_b,
    GeneralizedContinuedFraction.continuantsAux_recurrence nth_s_eq rfl rfl]
/-- Shows that `bₙ * Bₙ ≤ Bₙ₊₁`, where `bₙ` is the `n`th partial denominator and `Bₙ₊₁` and `Bₙ` are
the `n + 1`th and `n`th denominator of the continued fraction. -/
theorem le_of_succ_get?_denom {b : K}
    (nth_part_denom_eq : (of v).partialDenominators.get? n = some b) :
    b * (of v).denominators n ≤ (of v).denominators (n + 1) := 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
⊢ b * denominators (of v) n ≤ denominators (of v) (n + 1)

Next tactic:
rw [denom_eq_conts_b, nth_cont_eq_succ_nth_cont_aux]
/-- Shows that `bₙ * Bₙ ≤ Bₙ₊₁`, where `bₙ` is the `n`th partial denominator and `Bₙ₊₁` and `Bₙ` are
the `n + 1`th and `n`th denominator of the continued fraction. -/
theorem le_of_succ_get?_denom {b : K}
    (nth_part_denom_eq : (of v).partialDenominators.get? n = some b) :
    b * (of v).denominators n ≤ (of v).denominators (n + 1) := by
  rw [denom_eq_conts_b, nth_cont_eq_succ_nth_cont_aux]
  

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
⊢ b * (continuantsAux (of v) (n + 1)).b ≤ denominators (of v) (n + 1)

Next tactic:
exact le_of_succ_succ_get?_continuantsAux_b nth_part_denom_eq
/-- Shows that the sequence of denominators is monotone, that is `Bₙ ≤ Bₙ₊₁`. -/
theorem of_denom_mono : (of v).denominators n ≤ (of v).denominators (n + 1) := by
  

Proof state:
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
⊢ denominators (of v) n ≤ denominators (of v) (n + 1)

Next tactic:
let g := of v
/-- Shows that the sequence of denominators is monotone, that is `Bₙ ≤ Bₙ₊₁`. -/
theorem of_denom_mono : (of v).denominators n ≤ (of v).denominators (n + 1) := by
  let g := of v
  

Proof state:
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
g : GeneralizedContinuedFraction K := of v
⊢ denominators (of v) n ≤ denominators (of v) (n + 1)

Next tactic:
cases' Decidable.em <| g.partialDenominators.TerminatedAt n with terminated not_terminated
/-- Shows that the sequence of denominators is monotone, that is `Bₙ ≤ Bₙ₊₁`. -/
theorem of_denom_mono : (of v).denominators n ≤ (of v).denominators (n + 1) := by
  let g := of v
  cases' Decidable.em <| g.partialDenominators.TerminatedAt n with terminated not_terminated
  · 

Proof state:
case inl
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
g : GeneralizedContinuedFraction K := of v
terminated : Stream'.Seq.TerminatedAt (partialDenominators g) n
⊢ denominators (of v) n ≤ denominators (of v) (n + 1)

Next tactic:
have : g.partialDenominators.get? n = none := by rwa [Stream'.Seq.TerminatedAt] at terminated
/-- Shows that the sequence of denominators is monotone, that is `Bₙ ≤ Bₙ₊₁`. -/
theorem of_denom_mono : (of v).denominators n ≤ (of v).denominators (n + 1) := by
  let g := of v
  cases' Decidable.em <| g.partialDenominators.TerminatedAt n with terminated not_terminated
  · have : g.partialDenominators.get? n = none := by 

Proof state:
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
g : GeneralizedContinuedFraction K := of v
terminated : Stream'.Seq.TerminatedAt (partialDenominators g) n
⊢ Stream'.Seq.get? (partialDenominators g) n = none

Next tactic:
rwa [Stream'.Seq.TerminatedAt] at terminated