l3lab/ntp-mathlib huggingface dataset:
/-- Shows that the partial denominators `bᵢ` correspond to an integer. -/
theorem exists_int_eq_of_part_denom {b : K}
    (nth_part_denom_eq : (of v).partialDenominators.get? n = some b) : ∃ z : ℤ, b = (z : K) := 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
⊢ ∃ z, b = ↑z

Next tactic:
obtain ⟨gp, nth_s_eq, gp_b_eq_b_n⟩ : ∃ gp, (of v).s.get? n = some gp ∧ gp.b = b
/-- Shows that the partial denominators `bᵢ` correspond to an integer. -/
theorem exists_int_eq_of_part_denom {b : K}
    (nth_part_denom_eq : (of v).partialDenominators.get? n = some b) : ∃ z : ℤ, b = (z : K) := by
  obtain ⟨gp, nth_s_eq, gp_b_eq_b_n⟩ : ∃ gp, (of v).s.get? n = some gp ∧ gp.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, Stream'.Seq.get? (of v).s n = some gp ∧ gp.b = b
case intro.intro
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 : Pair K
nth_s_eq : Stream'.Seq.get? (of v).s n = some gp
gp_b_eq_b_n : gp.b = b
⊢ ∃ z, b = ↑z

Next tactic:
exact exists_s_b_of_part_denom nth_part_denom_eq
/-- Shows that the partial denominators `bᵢ` correspond to an integer. -/
theorem exists_int_eq_of_part_denom {b : K}
    (nth_part_denom_eq : (of v).partialDenominators.get? n = some b) : ∃ z : ℤ, b = (z : K) := by
  obtain ⟨gp, nth_s_eq, gp_b_eq_b_n⟩ : ∃ gp, (of v).s.get? n = some gp ∧ gp.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
b : K
nth_part_denom_eq : Stream'.Seq.get? (partialDenominators (of v)) n = some b
gp : Pair K
nth_s_eq : Stream'.Seq.get? (of v).s n = some gp
gp_b_eq_b_n : gp.b = b
⊢ ∃ z, b = ↑z

Next tactic:
have : ∃ z : ℤ, gp.b = (z : K) := (of_part_num_eq_one_and_exists_int_part_denom_eq nth_s_eq).right
/-- Shows that the partial denominators `bᵢ` correspond to an integer. -/
theorem exists_int_eq_of_part_denom {b : K}
    (nth_part_denom_eq : (of v).partialDenominators.get? n = some b) : ∃ z : ℤ, b = (z : K) := by
  obtain ⟨gp, nth_s_eq, gp_b_eq_b_n⟩ : ∃ gp, (of v).s.get? n = some gp ∧ gp.b = b;
  exact exists_s_b_of_part_denom nth_part_denom_eq
  have : ∃ z : ℤ, gp.b = (z : K) := (of_part_num_eq_one_and_exists_int_part_denom_eq nth_s_eq).right
  

Proof state:
case intro.intro
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 : Pair K
nth_s_eq : Stream'.Seq.get? (of v).s n = some gp
gp_b_eq_b_n : gp.b = b
this : ∃ z, gp.b = ↑z
⊢ ∃ z, b = ↑z

Next tactic:
rwa [gp_b_eq_b_n] at this
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
      

Proof state:
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
⊢ ∀ (n : ℕ),
    (∀ m < n, m ≤ 1 ∨ ¬TerminatedAt (of v) (m - 2) → ↑(fib m) ≤ (continuantsAux (of v) m).b) →
      n ≤ 1 ∨ ¬TerminatedAt (of v) (n - 2) → ↑(fib n) ≤ (continuantsAux (of v) n).b

Next tactic:
intro n IH hyp
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
      

Proof state:
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
IH : ∀ m < n, m ≤ 1 ∨ ¬TerminatedAt (of v) (m - 2) → ↑(fib m) ≤ (continuantsAux (of v) m).b
hyp : n ≤ 1 ∨ ¬TerminatedAt (of v) (n - 2)
⊢ ↑(fib n) ≤ (continuantsAux (of v) n).b

Next tactic:
rcases n with (_ | _ | n)
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)
      · 

Proof state:
case zero
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
IH : ∀ m < zero, m ≤ 1 ∨ ¬TerminatedAt (of v) (m - 2) → ↑(fib m) ≤ (continuantsAux (of v) m).b
hyp : zero ≤ 1 ∨ ¬TerminatedAt (of v) (zero - 2)
⊢ ↑(fib zero) ≤ (continuantsAux (of v) zero).b

Next tactic:
simp [fib_add_two, continuantsAux]
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
      · 

Proof state:
case succ.zero
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
IH : ∀ m < Nat.succ zero, m ≤ 1 ∨ ¬TerminatedAt (of v) (m - 2) → ↑(fib m) ≤ (continuantsAux (of v) m).b
hyp : Nat.succ zero ≤ 1 ∨ ¬TerminatedAt (of v) (Nat.succ zero - 2)
⊢ ↑(fib (Nat.succ zero)) ≤ (continuantsAux (of v) (Nat.succ zero)).b

Next tactic:
simp [fib_add_two, continuantsAux]
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
      · 

Proof state:
case succ.succ
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)
⊢ ↑(fib (Nat.succ (Nat.succ n))) ≤ (continuantsAux (of v) (Nat.succ (Nat.succ n))).b

Next tactic:
let g := of v
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
        

Proof state:
case succ.succ
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
⊢ ↑(fib (Nat.succ (Nat.succ n))) ≤ (continuantsAux (of v) (Nat.succ (Nat.succ n))).b

Next tactic:
have : ¬n + 2 ≤ 1 := by linarith
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 

Proof state:
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
⊢ ¬n + 2 ≤ 1

Next tactic:
linarith
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
        

Proof state:
case succ.succ
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
⊢ ↑(fib (Nat.succ (Nat.succ n))) ≤ (continuantsAux (of v) (Nat.succ (Nat.succ n))).b

Next tactic:
have not_terminated_at_n : ¬g.TerminatedAt n := Or.resolve_left hyp this
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
        

Proof state:
case succ.succ
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
⊢ ↑(fib (Nat.succ (Nat.succ n))) ≤ (continuantsAux (of v) (Nat.succ (Nat.succ n))).b

Next tactic:
obtain ⟨gp, s_ppred_nth_eq⟩ : ∃ gp, g.s.get? n = some gp
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
        

Proof state:
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, Stream'.Seq.get? g.s n = some gp
case succ.succ.intro
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
⊢ ↑(fib (Nat.succ (Nat.succ n))) ≤ (continuantsAux (of v) (Nat.succ (Nat.succ n))).b

Next tactic:
exact Option.ne_none_iff_exists'.mp not_terminated_at_n
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
        

Proof state:
case succ.succ.intro
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
⊢ ↑(fib (Nat.succ (Nat.succ n))) ≤ (continuantsAux (of v) (Nat.succ (Nat.succ n))).b

Next tactic:
set pconts := g.continuantsAux (n + 1) with pconts_eq
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
        

Proof state:
case succ.succ.intro
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)
⊢ ↑(fib (Nat.succ (Nat.succ n))) ≤ (continuantsAux (of v) (Nat.succ (Nat.succ n))).b

Next tactic:
set ppconts := g.continuantsAux n with ppconts_eq
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`
        

Proof state:
case succ.succ.intro
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
⊢ ↑(fib (Nat.succ (Nat.succ n))) ≤ (continuantsAux (of v) (Nat.succ (Nat.succ n))).b

Next tactic:
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]
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
          

Proof state:
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
this : ↑(fib n) + ↑(fib (n + 1)) ≤ gp.a * ppconts.b + gp.b * pconts.b
⊢ ↑(fib (Nat.succ (Nat.succ n))) ≤ (continuantsAux (of v) (Nat.succ (Nat.succ n))).b

Next tactic:
simpa [fib_add_two, add_comm,
            continuantsAux_recurrence s_ppred_nth_eq ppconts_eq pconts_eq]
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`
        

Proof state:
case succ.succ.intro
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
⊢ ↑(fib n) + ↑(fib (n + 1)) ≤ gp.a * ppconts.b + gp.b * pconts.b

Next tactic:
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]
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
          

Proof state:
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
this : ↑(fib n) + ↑(fib (n + 1)) ≤ ppconts.b + gp.b * pconts.b
⊢ ↑(fib n) + ↑(fib (n + 1)) ≤ gp.a * ppconts.b + gp.b * pconts.b

Next tactic:
simpa [of_part_num_eq_one <| part_num_eq_s_a s_ppred_nth_eq]
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]
        

Proof state:
case succ.succ.intro
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
⊢ ↑(fib n) + ↑(fib (n + 1)) ≤ ppconts.b + gp.b * pconts.b

Next tactic:
have not_terminated_at_pred_n : ¬g.TerminatedAt (n - 1) :=
          mt (terminated_stable <| Nat.sub_le n 1) not_terminated_at_n