Theorem: GeneralizedContinuedFraction.convergents'Aux_stable_step_of_terminated
File: Mathlib/Algebra/ContinuedFractions/TerminatedStable.lean

tactic: change s.get? n = none at terminated_at_n
state_before: K : Type u_1
g : GeneralizedContinuedFraction K
n m : ℕ
inst✝ : DivisionRing K
s : Stream'.Seq (Pair K)
terminated_at_n : s.TerminatedAt n
⊢ convergents'Aux s (n + 1) = convergents'Aux s n
state_after: K : Type u_1
g : GeneralizedContinuedFraction K
n m : ℕ
inst✝ : DivisionRing K
s : Stream'.Seq (Pair K)
terminated_at_n : s.get? n = none
⊢ convergents'Aux s (n + 1) = convergents'Aux s n

tactic: induction n generalizing s with
| zero => simp only [convergents'Aux, terminated_at_n, Stream'.Seq.head]
| succ n IH =>
  cases s_head_eq : s.head with
  | none => simp only [convergents'Aux, s_head_eq]
  | some gp_head =>
    have : s.tail.TerminatedAt n := by
      simp only [Stream'.Seq.TerminatedAt, s.get?_tail, terminated_at_n]
    have := IH this
    rw [convergents'Aux] at this
    simp [this, Nat.add_eq, add_zero, convergents'Aux, s_head_eq]
state_before: K : Type u_1
g : GeneralizedContinuedFraction K
n m : ℕ
inst✝ : DivisionRing K
s : Stream'.Seq (Pair K)
terminated_at_n : s.get? n = none
⊢ convergents'Aux s (n + 1) = convergents'Aux s n
state_after: no goals

tactic: simp only [convergents'Aux, terminated_at_n, Stream'.Seq.head]
state_before: case zero
K : Type u_1
g : GeneralizedContinuedFraction K
n m : ℕ
inst✝ : DivisionRing K
s : Stream'.Seq (Pair K)
terminated_at_n : s.get? 0 = none
⊢ convergents'Aux s (0 + 1) = convergents'Aux s 0
state_after: no goals

tactic: cases s_head_eq : s.head with
| none => simp only [convergents'Aux, s_head_eq]
| some gp_head =>
  have : s.tail.TerminatedAt n := by
    simp only [Stream'.Seq.TerminatedAt, s.get?_tail, terminated_at_n]
  have := IH this
  rw [convergents'Aux] at this
  simp [this, Nat.add_eq, add_zero, convergents'Aux, s_head_eq]
state_before: case succ
K : Type u_1
g : GeneralizedContinuedFraction K
n✝ m : ℕ
inst✝ : DivisionRing K
n : ℕ
IH : ∀ {s : Stream'.Seq (Pair K)}, s.get? n = none → convergents'Aux s (n + 1) = convergents'Aux s n
s : Stream'.Seq (Pair K)
terminated_at_n : s.get? (n + 1) = none
⊢ convergents'Aux s (n + 1 + 1) = convergents'Aux s (n + 1)
state_after: no goals

tactic: simp only [convergents'Aux, s_head_eq]
state_before: case succ.none
K : Type u_1
g : GeneralizedContinuedFraction K
n✝ m : ℕ
inst✝ : DivisionRing K
n : ℕ
IH : ∀ {s : Stream'.Seq (Pair K)}, s.get? n = none → convergents'Aux s (n + 1) = convergents'Aux s n
s : Stream'.Seq (Pair K)
terminated_at_n : s.get? (n + 1) = none
s_head_eq : s.head = none
⊢ convergents'Aux s (n + 1 + 1) = convergents'Aux s (n + 1)
state_after: no goals

tactic: have : s.tail.TerminatedAt n := by
  simp only [Stream'.Seq.TerminatedAt, s.get?_tail, terminated_at_n]
state_before: case succ.some
K : Type u_1
g : GeneralizedContinuedFraction K
n✝ m : ℕ
inst✝ : DivisionRing K
n : ℕ
IH : ∀ {s : Stream'.Seq (Pair K)}, s.get? n = none → convergents'Aux s (n + 1) = convergents'Aux s n
s : Stream'.Seq (Pair K)
terminated_at_n : s.get? (n + 1) = none
gp_head : Pair K
s_head_eq : s.head = some gp_head
⊢ convergents'Aux s (n + 1 + 1) = convergents'Aux s (n + 1)
state_after: case succ.some
K : Type u_1
g : GeneralizedContinuedFraction K
n✝ m : ℕ
inst✝ : DivisionRing K
n : ℕ
IH : ∀ {s : Stream'.Seq (Pair K)}, s.get? n = none → convergents'Aux s (n + 1) = convergents'Aux s n
s : Stream'.Seq (Pair K)
terminated_at_n : s.get? (n + 1) = none
gp_head : Pair K
s_head_eq : s.head = some gp_head
this : s.tail.TerminatedAt n
⊢ convergents'Aux s (n + 1 + 1) = convergents'Aux s (n + 1)

tactic: have := IH this
state_before: case succ.some
K : Type u_1
g : GeneralizedContinuedFraction K
n✝ m : ℕ
inst✝ : DivisionRing K
n : ℕ
IH : ∀ {s : Stream'.Seq (Pair K)}, s.get? n = none → convergents'Aux s (n + 1) = convergents'Aux s n
s : Stream'.Seq (Pair K)
terminated_at_n : s.get? (n + 1) = none
gp_head : Pair K
s_head_eq : s.head = some gp_head
this : s.tail.TerminatedAt n
⊢ convergents'Aux s (n + 1 + 1) = convergents'Aux s (n + 1)
state_after: case succ.some
K : Type u_1
g : GeneralizedContinuedFraction K
n✝ m : ℕ
inst✝ : DivisionRing K
n : ℕ
IH : ∀ {s : Stream'.Seq (Pair K)}, s.get? n = none → convergents'Aux s (n + 1) = convergents'Aux s n
s : Stream'.Seq (Pair K)
terminated_at_n : s.get? (n + 1) = none
gp_head : Pair K
s_head_eq : s.head = some gp_head
this✝ : s.tail.TerminatedAt n
this : convergents'Aux s.tail (n + 1) = convergents'Aux s.tail n
⊢ convergents'Aux s (n + 1 + 1) = convergents'Aux s (n + 1)

tactic: rw [convergents'Aux] at this
state_before: case succ.some
K : Type u_1
g : GeneralizedContinuedFraction K
n✝ m : ℕ
inst✝ : DivisionRing K
n : ℕ
IH : ∀ {s : Stream'.Seq (Pair K)}, s.get? n = none → convergents'Aux s (n + 1) = convergents'Aux s n
s : Stream'.Seq (Pair K)
terminated_at_n : s.get? (n + 1) = none
gp_head : Pair K
s_head_eq : s.head = some gp_head
this✝ : s.tail.TerminatedAt n
this : convergents'Aux s.tail (n + 1) = convergents'Aux s.tail n
⊢ convergents'Aux s (n + 1 + 1) = convergents'Aux s (n + 1)
state_after: case succ.some
K : Type u_1
g : GeneralizedContinuedFraction K
n✝ m : ℕ
inst✝ : DivisionRing K
n : ℕ
IH : ∀ {s : Stream'.Seq (Pair K)}, s.get? n = none → convergents'Aux s (n + 1) = convergents'Aux s n
s : Stream'.Seq (Pair K)
terminated_at_n : s.get? (n + 1) = none
gp_head : Pair K
s_head_eq : s.head = some gp_head
this✝ : s.tail.TerminatedAt n
this :
  (match s.tail.head with
    | none => 0
    | some gp => gp.a / (gp.b + convergents'Aux s.tail.tail n)) =
    convergents'Aux s.tail n
⊢ convergents'Aux s (n + 1 + 1) = convergents'Aux s (n + 1)

tactic: simp [this, Nat.add_eq, add_zero, convergents'Aux, s_head_eq]
state_before: case succ.some
K : Type u_1
g : GeneralizedContinuedFraction K
n✝ m : ℕ
inst✝ : DivisionRing K
n : ℕ
IH : ∀ {s : Stream'.Seq (Pair K)}, s.get? n = none → convergents'Aux s (n + 1) = convergents'Aux s n
s : Stream'.Seq (Pair K)
terminated_at_n : s.get? (n + 1) = none
gp_head : Pair K
s_head_eq : s.head = some gp_head
this✝ : s.tail.TerminatedAt n
this :
  (match s.tail.head with
    | none => 0
    | some gp => gp.a / (gp.b + convergents'Aux s.tail.tail n)) =
    convergents'Aux s.tail n
⊢ convergents'Aux s (n + 1 + 1) = convergents'Aux s (n + 1)
state_after: no goals

tactic: simp only [Stream'.Seq.TerminatedAt, s.get?_tail, terminated_at_n]
state_before: K : Type u_1
g : GeneralizedContinuedFraction K
n✝ m : ℕ
inst✝ : DivisionRing K
n : ℕ
IH : ∀ {s : Stream'.Seq (Pair K)}, s.get? n = none → convergents'Aux s (n + 1) = convergents'Aux s n
s : Stream'.Seq (Pair K)
terminated_at_n : s.get? (n + 1) = none
gp_head : Pair K
s_head_eq : s.head = some gp_head
⊢ s.tail.TerminatedAt n
state_after: no goals