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

tactic: induction n with
| zero => simp [continuantsAux]
| succ n IH =>
  let g := of v
  let conts := continuantsAux g (n + 2)
  set pred_conts := continuantsAux g (n + 1) with pred_conts_eq
  set ppred_conts := continuantsAux g n with ppred_conts_eq
  let pA := pred_conts.a
  let pB := pred_conts.b
  let ppA := ppred_conts.a
  let ppB := ppred_conts.b
  change pA * conts.b - pB * conts.a = (-1) ^ (n + 1)
  have not_terminated_at_n : ¬TerminatedAt g n := Or.resolve_left hyp n.succ_ne_zero
  obtain ⟨gp, s_nth_eq⟩ : ∃ gp, g.s.get? n = some gp :=
    Option.ne_none_iff_exists'.1 not_terminated_at_n
  suffices pA * (ppB + gp.b * pB) - pB * (ppA + gp.b * pA) = (-1) ^ (n + 1) by
    simp only [conts, continuantsAux_recurrence s_nth_eq ppred_conts_eq pred_conts_eq]
    have gp_a_eq_one : gp.a = 1 := of_part_num_eq_one (part_num_eq_s_a s_nth_eq)
    rw [gp_a_eq_one, this.symm]
    ring
  suffices pA * ppB - pB * ppA = (-1) ^ (n + 1) by calc
    pA * (ppB + gp.b * pB) - pB * (ppA + gp.b * pA) =
        pA * ppB + pA * gp.b * pB - pB * ppA - pB * gp.b * pA := by ring
    _ = pA * ppB - pB * ppA := by ring
    _ = (-1) ^ (n + 1) := by assumption
  suffices ppA * pB - ppB * pA = (-1) ^ n by
    have pow_succ_n : (-1 : K) ^ (n + 1) = -1 * (-1) ^ n := pow_succ' (-1) n
    rw [pow_succ_n, ← this]
    ring
  exact IH <| Or.inr <| mt (terminated_stable <| n.sub_le 1) not_terminated_at_n
state_before: K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
hyp : n = 0 ∨ ¬(of v).TerminatedAt (n - 1)
⊢ ((of v).continuantsAux n).a * ((of v).continuantsAux (n + 1)).b -
      ((of v).continuantsAux n).b * ((of v).continuantsAux (n + 1)).a =
    (-1) ^ n
state_after: no goals

tactic: simp [continuantsAux]
state_before: case zero
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
hyp : 0 = 0 ∨ ¬(of v).TerminatedAt (0 - 1)
⊢ ((of v).continuantsAux 0).a * ((of v).continuantsAux (0 + 1)).b -
      ((of v).continuantsAux 0).b * ((of v).continuantsAux (0 + 1)).a =
    (-1) ^ 0
state_after: no goals

tactic: let g := of v
state_before: case succ
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
IH :
  n = 0 ∨ ¬(of v).TerminatedAt (n - 1) →
    ((of v).continuantsAux n).a * ((of v).continuantsAux (n + 1)).b -
        ((of v).continuantsAux n).b * ((of v).continuantsAux (n + 1)).a =
      (-1) ^ n
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
⊢ ((of v).continuantsAux (n + 1)).a * ((of v).continuantsAux (n + 1 + 1)).b -
      ((of v).continuantsAux (n + 1)).b * ((of v).continuantsAux (n + 1 + 1)).a =
    (-1) ^ (n + 1)
state_after: case succ
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
IH :
  n = 0 ∨ ¬(of v).TerminatedAt (n - 1) →
    ((of v).continuantsAux n).a * ((of v).continuantsAux (n + 1)).b -
        ((of v).continuantsAux n).b * ((of v).continuantsAux (n + 1)).a =
      (-1) ^ n
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
⊢ ((of v).continuantsAux (n + 1)).a * ((of v).continuantsAux (n + 1 + 1)).b -
      ((of v).continuantsAux (n + 1)).b * ((of v).continuantsAux (n + 1 + 1)).a =
    (-1) ^ (n + 1)

tactic: let conts := continuantsAux g (n + 2)
state_before: case succ
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
IH :
  n = 0 ∨ ¬(of v).TerminatedAt (n - 1) →
    ((of v).continuantsAux n).a * ((of v).continuantsAux (n + 1)).b -
        ((of v).continuantsAux n).b * ((of v).continuantsAux (n + 1)).a =
      (-1) ^ n
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
⊢ ((of v).continuantsAux (n + 1)).a * ((of v).continuantsAux (n + 1 + 1)).b -
      ((of v).continuantsAux (n + 1)).b * ((of v).continuantsAux (n + 1 + 1)).a =
    (-1) ^ (n + 1)
state_after: case succ
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
IH :
  n = 0 ∨ ¬(of v).TerminatedAt (n - 1) →
    ((of v).continuantsAux n).a * ((of v).continuantsAux (n + 1)).b -
        ((of v).continuantsAux n).b * ((of v).continuantsAux (n + 1)).a =
      (-1) ^ n
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
⊢ ((of v).continuantsAux (n + 1)).a * ((of v).continuantsAux (n + 1 + 1)).b -
      ((of v).continuantsAux (n + 1)).b * ((of v).continuantsAux (n + 1 + 1)).a =
    (-1) ^ (n + 1)

tactic: set pred_conts := continuantsAux g (n + 1) with pred_conts_eq
state_before: case succ
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
IH :
  n = 0 ∨ ¬(of v).TerminatedAt (n - 1) →
    ((of v).continuantsAux n).a * ((of v).continuantsAux (n + 1)).b -
        ((of v).continuantsAux n).b * ((of v).continuantsAux (n + 1)).a =
      (-1) ^ n
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
⊢ ((of v).continuantsAux (n + 1)).a * ((of v).continuantsAux (n + 1 + 1)).b -
      ((of v).continuantsAux (n + 1)).b * ((of v).continuantsAux (n + 1 + 1)).a =
    (-1) ^ (n + 1)
state_after: case succ
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
IH :
  n = 0 ∨ ¬(of v).TerminatedAt (n - 1) →
    ((of v).continuantsAux n).a * pred_conts.b - ((of v).continuantsAux n).b * pred_conts.a = (-1) ^ n
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
⊢ pred_conts.a * ((of v).continuantsAux (n + 1 + 1)).b - pred_conts.b * ((of v).continuantsAux (n + 1 + 1)).a =
    (-1) ^ (n + 1)

tactic: set ppred_conts := continuantsAux g n with ppred_conts_eq
state_before: case succ
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
IH :
  n = 0 ∨ ¬(of v).TerminatedAt (n - 1) →
    ((of v).continuantsAux n).a * pred_conts.b - ((of v).continuantsAux n).b * pred_conts.a = (-1) ^ n
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
⊢ pred_conts.a * ((of v).continuantsAux (n + 1 + 1)).b - pred_conts.b * ((of v).continuantsAux (n + 1 + 1)).a =
    (-1) ^ (n + 1)
state_after: case succ
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
⊢ pred_conts.a * ((of v).continuantsAux (n + 1 + 1)).b - pred_conts.b * ((of v).continuantsAux (n + 1 + 1)).a =
    (-1) ^ (n + 1)

tactic: let pA := pred_conts.a
state_before: case succ
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
⊢ pred_conts.a * ((of v).continuantsAux (n + 1 + 1)).b - pred_conts.b * ((of v).continuantsAux (n + 1 + 1)).a =
    (-1) ^ (n + 1)
state_after: case succ
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
pA : K := pred_conts.a
⊢ pred_conts.a * ((of v).continuantsAux (n + 1 + 1)).b - pred_conts.b * ((of v).continuantsAux (n + 1 + 1)).a =
    (-1) ^ (n + 1)

tactic: let pB := pred_conts.b
state_before: case succ
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
pA : K := pred_conts.a
⊢ pred_conts.a * ((of v).continuantsAux (n + 1 + 1)).b - pred_conts.b * ((of v).continuantsAux (n + 1 + 1)).a =
    (-1) ^ (n + 1)
state_after: case succ
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
pA : K := pred_conts.a
pB : K := pred_conts.b
⊢ pred_conts.a * ((of v).continuantsAux (n + 1 + 1)).b - pred_conts.b * ((of v).continuantsAux (n + 1 + 1)).a =
    (-1) ^ (n + 1)

tactic: let ppA := ppred_conts.a
state_before: case succ
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
pA : K := pred_conts.a
pB : K := pred_conts.b
⊢ pred_conts.a * ((of v).continuantsAux (n + 1 + 1)).b - pred_conts.b * ((of v).continuantsAux (n + 1 + 1)).a =
    (-1) ^ (n + 1)
state_after: case succ
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
pA : K := pred_conts.a
pB : K := pred_conts.b
ppA : K := ppred_conts.a
⊢ pred_conts.a * ((of v).continuantsAux (n + 1 + 1)).b - pred_conts.b * ((of v).continuantsAux (n + 1 + 1)).a =
    (-1) ^ (n + 1)

tactic: let ppB := ppred_conts.b
state_before: case succ
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
pA : K := pred_conts.a
pB : K := pred_conts.b
ppA : K := ppred_conts.a
⊢ pred_conts.a * ((of v).continuantsAux (n + 1 + 1)).b - pred_conts.b * ((of v).continuantsAux (n + 1 + 1)).a =
    (-1) ^ (n + 1)
state_after: case succ
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
pA : K := pred_conts.a
pB : K := pred_conts.b
ppA : K := ppred_conts.a
ppB : K := ppred_conts.b
⊢ pred_conts.a * ((of v).continuantsAux (n + 1 + 1)).b - pred_conts.b * ((of v).continuantsAux (n + 1 + 1)).a =
    (-1) ^ (n + 1)

tactic: change pA * conts.b - pB * conts.a = (-1) ^ (n + 1)
state_before: case succ
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
pA : K := pred_conts.a
pB : K := pred_conts.b
ppA : K := ppred_conts.a
ppB : K := ppred_conts.b
⊢ pred_conts.a * ((of v).continuantsAux (n + 1 + 1)).b - pred_conts.b * ((of v).continuantsAux (n + 1 + 1)).a =
    (-1) ^ (n + 1)
state_after: case succ
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
pA : K := pred_conts.a
pB : K := pred_conts.b
ppA : K := ppred_conts.a
ppB : K := ppred_conts.b
⊢ pA * conts.b - pB * conts.a = (-1) ^ (n + 1)

tactic: have not_terminated_at_n : ¬TerminatedAt g n := Or.resolve_left hyp n.succ_ne_zero
state_before: case succ
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
pA : K := pred_conts.a
pB : K := pred_conts.b
ppA : K := ppred_conts.a
ppB : K := ppred_conts.b
⊢ pA * conts.b - pB * conts.a = (-1) ^ (n + 1)
state_after: case succ
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
pA : K := pred_conts.a
pB : K := pred_conts.b
ppA : K := ppred_conts.a
ppB : K := ppred_conts.b
not_terminated_at_n : ¬g.TerminatedAt n
⊢ pA * conts.b - pB * conts.a = (-1) ^ (n + 1)

tactic: obtain ⟨gp, s_nth_eq⟩ : ∃ gp, g.s.get? n = some gp :=
  Option.ne_none_iff_exists'.1 not_terminated_at_n
state_before: case succ
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
pA : K := pred_conts.a
pB : K := pred_conts.b
ppA : K := ppred_conts.a
ppB : K := ppred_conts.b
not_terminated_at_n : ¬g.TerminatedAt n
⊢ pA * conts.b - pB * conts.a = (-1) ^ (n + 1)
state_after: case succ.intro
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
pA : K := pred_conts.a
pB : K := pred_conts.b
ppA : K := ppred_conts.a
ppB : K := ppred_conts.b
not_terminated_at_n : ¬g.TerminatedAt n
gp : Pair K
s_nth_eq : g.s.get? n = some gp
⊢ pA * conts.b - pB * conts.a = (-1) ^ (n + 1)

tactic: suffices pA * (ppB + gp.b * pB) - pB * (ppA + gp.b * pA) = (-1) ^ (n + 1) by
  simp only [conts, continuantsAux_recurrence s_nth_eq ppred_conts_eq pred_conts_eq]
  have gp_a_eq_one : gp.a = 1 := of_part_num_eq_one (part_num_eq_s_a s_nth_eq)
  rw [gp_a_eq_one, this.symm]
  ring
state_before: case succ.intro
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
pA : K := pred_conts.a
pB : K := pred_conts.b
ppA : K := ppred_conts.a
ppB : K := ppred_conts.b
not_terminated_at_n : ¬g.TerminatedAt n
gp : Pair K
s_nth_eq : g.s.get? n = some gp
⊢ pA * conts.b - pB * conts.a = (-1) ^ (n + 1)
state_after: case succ.intro
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
pA : K := pred_conts.a
pB : K := pred_conts.b
ppA : K := ppred_conts.a
ppB : K := ppred_conts.b
not_terminated_at_n : ¬g.TerminatedAt n
gp : Pair K
s_nth_eq : g.s.get? n = some gp
⊢ pA * (ppB + gp.b * pB) - pB * (ppA + gp.b * pA) = (-1) ^ (n + 1)

tactic: suffices pA * ppB - pB * ppA = (-1) ^ (n + 1) by calc
  pA * (ppB + gp.b * pB) - pB * (ppA + gp.b * pA) =
      pA * ppB + pA * gp.b * pB - pB * ppA - pB * gp.b * pA := by ring
  _ = pA * ppB - pB * ppA := by ring
  _ = (-1) ^ (n + 1) := by assumption
state_before: case succ.intro
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
pA : K := pred_conts.a
pB : K := pred_conts.b
ppA : K := ppred_conts.a
ppB : K := ppred_conts.b
not_terminated_at_n : ¬g.TerminatedAt n
gp : Pair K
s_nth_eq : g.s.get? n = some gp
⊢ pA * (ppB + gp.b * pB) - pB * (ppA + gp.b * pA) = (-1) ^ (n + 1)
state_after: case succ.intro
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
pA : K := pred_conts.a
pB : K := pred_conts.b
ppA : K := ppred_conts.a
ppB : K := ppred_conts.b
not_terminated_at_n : ¬g.TerminatedAt n
gp : Pair K
s_nth_eq : g.s.get? n = some gp
⊢ pA * ppB - pB * ppA = (-1) ^ (n + 1)

tactic: suffices ppA * pB - ppB * pA = (-1) ^ n by
  have pow_succ_n : (-1 : K) ^ (n + 1) = -1 * (-1) ^ n := pow_succ' (-1) n
  rw [pow_succ_n, ← this]
  ring
state_before: case succ.intro
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
pA : K := pred_conts.a
pB : K := pred_conts.b
ppA : K := ppred_conts.a
ppB : K := ppred_conts.b
not_terminated_at_n : ¬g.TerminatedAt n
gp : Pair K
s_nth_eq : g.s.get? n = some gp
⊢ pA * ppB - pB * ppA = (-1) ^ (n + 1)
state_after: case succ.intro
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
pA : K := pred_conts.a
pB : K := pred_conts.b
ppA : K := ppred_conts.a
ppB : K := ppred_conts.b
not_terminated_at_n : ¬g.TerminatedAt n
gp : Pair K
s_nth_eq : g.s.get? n = some gp
⊢ ppA * pB - ppB * pA = (-1) ^ n

tactic: exact IH <| Or.inr <| mt (terminated_stable <| n.sub_le 1) not_terminated_at_n
state_before: case succ.intro
K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
pA : K := pred_conts.a
pB : K := pred_conts.b
ppA : K := ppred_conts.a
ppB : K := ppred_conts.b
not_terminated_at_n : ¬g.TerminatedAt n
gp : Pair K
s_nth_eq : g.s.get? n = some gp
⊢ ppA * pB - ppB * pA = (-1) ^ n
state_after: no goals

tactic: simp only [conts, continuantsAux_recurrence s_nth_eq ppred_conts_eq pred_conts_eq]
state_before: K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
pA : K := pred_conts.a
pB : K := pred_conts.b
ppA : K := ppred_conts.a
ppB : K := ppred_conts.b
not_terminated_at_n : ¬g.TerminatedAt n
gp : Pair K
s_nth_eq : g.s.get? n = some gp
this : pA * (ppB + gp.b * pB) - pB * (ppA + gp.b * pA) = (-1) ^ (n + 1)
⊢ pA * conts.b - pB * conts.a = (-1) ^ (n + 1)
state_after: K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
pA : K := pred_conts.a
pB : K := pred_conts.b
ppA : K := ppred_conts.a
ppB : K := ppred_conts.b
not_terminated_at_n : ¬g.TerminatedAt n
gp : Pair K
s_nth_eq : g.s.get? n = some gp
this : pA * (ppB + gp.b * pB) - pB * (ppA + gp.b * pA) = (-1) ^ (n + 1)
⊢ pA * (gp.b * (g.continuantsAux (n + 1)).b + gp.a * (g.continuantsAux n).b) -
      pB * (gp.b * (g.continuantsAux (n + 1)).a + gp.a * (g.continuantsAux n).a) =
    (-1) ^ (n + 1)

tactic: have gp_a_eq_one : gp.a = 1 := of_part_num_eq_one (part_num_eq_s_a s_nth_eq)
state_before: K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
pA : K := pred_conts.a
pB : K := pred_conts.b
ppA : K := ppred_conts.a
ppB : K := ppred_conts.b
not_terminated_at_n : ¬g.TerminatedAt n
gp : Pair K
s_nth_eq : g.s.get? n = some gp
this : pA * (ppB + gp.b * pB) - pB * (ppA + gp.b * pA) = (-1) ^ (n + 1)
⊢ pA * (gp.b * (g.continuantsAux (n + 1)).b + gp.a * (g.continuantsAux n).b) -
      pB * (gp.b * (g.continuantsAux (n + 1)).a + gp.a * (g.continuantsAux n).a) =
    (-1) ^ (n + 1)
state_after: K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
pA : K := pred_conts.a
pB : K := pred_conts.b
ppA : K := ppred_conts.a
ppB : K := ppred_conts.b
not_terminated_at_n : ¬g.TerminatedAt n
gp : Pair K
s_nth_eq : g.s.get? n = some gp
this : pA * (ppB + gp.b * pB) - pB * (ppA + gp.b * pA) = (-1) ^ (n + 1)
gp_a_eq_one : gp.a = 1
⊢ pA * (gp.b * (g.continuantsAux (n + 1)).b + gp.a * (g.continuantsAux n).b) -
      pB * (gp.b * (g.continuantsAux (n + 1)).a + gp.a * (g.continuantsAux n).a) =
    (-1) ^ (n + 1)

tactic: rw [gp_a_eq_one, this.symm]
state_before: K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
pA : K := pred_conts.a
pB : K := pred_conts.b
ppA : K := ppred_conts.a
ppB : K := ppred_conts.b
not_terminated_at_n : ¬g.TerminatedAt n
gp : Pair K
s_nth_eq : g.s.get? n = some gp
this : pA * (ppB + gp.b * pB) - pB * (ppA + gp.b * pA) = (-1) ^ (n + 1)
gp_a_eq_one : gp.a = 1
⊢ pA * (gp.b * (g.continuantsAux (n + 1)).b + gp.a * (g.continuantsAux n).b) -
      pB * (gp.b * (g.continuantsAux (n + 1)).a + gp.a * (g.continuantsAux n).a) =
    (-1) ^ (n + 1)
state_after: K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
pA : K := pred_conts.a
pB : K := pred_conts.b
ppA : K := ppred_conts.a
ppB : K := ppred_conts.b
not_terminated_at_n : ¬g.TerminatedAt n
gp : Pair K
s_nth_eq : g.s.get? n = some gp
this : pA * (ppB + gp.b * pB) - pB * (ppA + gp.b * pA) = (-1) ^ (n + 1)
gp_a_eq_one : gp.a = 1
⊢ pA * (gp.b * (g.continuantsAux (n + 1)).b + 1 * (g.continuantsAux n).b) -
      pB * (gp.b * (g.continuantsAux (n + 1)).a + 1 * (g.continuantsAux n).a) =
    pA * (ppB + gp.b * pB) - pB * (ppA + gp.b * pA)

tactic: ring
state_before: K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
pA : K := pred_conts.a
pB : K := pred_conts.b
ppA : K := ppred_conts.a
ppB : K := ppred_conts.b
not_terminated_at_n : ¬g.TerminatedAt n
gp : Pair K
s_nth_eq : g.s.get? n = some gp
this : pA * (ppB + gp.b * pB) - pB * (ppA + gp.b * pA) = (-1) ^ (n + 1)
gp_a_eq_one : gp.a = 1
⊢ pA * (gp.b * (g.continuantsAux (n + 1)).b + 1 * (g.continuantsAux n).b) -
      pB * (gp.b * (g.continuantsAux (n + 1)).a + 1 * (g.continuantsAux n).a) =
    pA * (ppB + gp.b * pB) - pB * (ppA + gp.b * pA)
state_after: no goals

tactic: calc
pA * (ppB + gp.b * pB) - pB * (ppA + gp.b * pA) =
pA * ppB + pA * gp.b * pB - pB * ppA - pB * gp.b * pA := by ring
_ = pA * ppB - pB * ppA := by ring
_ = (-1) ^ (n + 1) := by assumption
state_before: K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
pA : K := pred_conts.a
pB : K := pred_conts.b
ppA : K := ppred_conts.a
ppB : K := ppred_conts.b
not_terminated_at_n : ¬g.TerminatedAt n
gp : Pair K
s_nth_eq : g.s.get? n = some gp
this : pA * ppB - pB * ppA = (-1) ^ (n + 1)
⊢ pA * (ppB + gp.b * pB) - pB * (ppA + gp.b * pA) = (-1) ^ (n + 1)
state_after: no goals

tactic: ring
state_before: K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
pA : K := pred_conts.a
pB : K := pred_conts.b
ppA : K := ppred_conts.a
ppB : K := ppred_conts.b
not_terminated_at_n : ¬g.TerminatedAt n
gp : Pair K
s_nth_eq : g.s.get? n = some gp
this : pA * ppB - pB * ppA = (-1) ^ (n + 1)
⊢ pA * (ppB + gp.b * pB) - pB * (ppA + gp.b * pA) = pA * ppB + pA * gp.b * pB - pB * ppA - pB * gp.b * pA
state_after: no goals

tactic: ring
state_before: K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
pA : K := pred_conts.a
pB : K := pred_conts.b
ppA : K := ppred_conts.a
ppB : K := ppred_conts.b
not_terminated_at_n : ¬g.TerminatedAt n
gp : Pair K
s_nth_eq : g.s.get? n = some gp
this : pA * ppB - pB * ppA = (-1) ^ (n + 1)
⊢ pA * ppB + pA * gp.b * pB - pB * ppA - pB * gp.b * pA = pA * ppB - pB * ppA
state_after: no goals

tactic: assumption
state_before: K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
pA : K := pred_conts.a
pB : K := pred_conts.b
ppA : K := ppred_conts.a
ppB : K := ppred_conts.b
not_terminated_at_n : ¬g.TerminatedAt n
gp : Pair K
s_nth_eq : g.s.get? n = some gp
this : pA * ppB - pB * ppA = (-1) ^ (n + 1)
⊢ pA * ppB - pB * ppA = (-1) ^ (n + 1)
state_after: no goals

tactic: have pow_succ_n : (-1 : K) ^ (n + 1) = -1 * (-1) ^ n := pow_succ' (-1) n
state_before: K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
pA : K := pred_conts.a
pB : K := pred_conts.b
ppA : K := ppred_conts.a
ppB : K := ppred_conts.b
not_terminated_at_n : ¬g.TerminatedAt n
gp : Pair K
s_nth_eq : g.s.get? n = some gp
this : ppA * pB - ppB * pA = (-1) ^ n
⊢ pA * ppB - pB * ppA = (-1) ^ (n + 1)
state_after: K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
pA : K := pred_conts.a
pB : K := pred_conts.b
ppA : K := ppred_conts.a
ppB : K := ppred_conts.b
not_terminated_at_n : ¬g.TerminatedAt n
gp : Pair K
s_nth_eq : g.s.get? n = some gp
this : ppA * pB - ppB * pA = (-1) ^ n
pow_succ_n : (-1) ^ (n + 1) = -1 * (-1) ^ n
⊢ pA * ppB - pB * ppA = (-1) ^ (n + 1)

tactic: rw [pow_succ_n, ← this]
state_before: K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
pA : K := pred_conts.a
pB : K := pred_conts.b
ppA : K := ppred_conts.a
ppB : K := ppred_conts.b
not_terminated_at_n : ¬g.TerminatedAt n
gp : Pair K
s_nth_eq : g.s.get? n = some gp
this : ppA * pB - ppB * pA = (-1) ^ n
pow_succ_n : (-1) ^ (n + 1) = -1 * (-1) ^ n
⊢ pA * ppB - pB * ppA = (-1) ^ (n + 1)
state_after: K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
pA : K := pred_conts.a
pB : K := pred_conts.b
ppA : K := ppred_conts.a
ppB : K := ppred_conts.b
not_terminated_at_n : ¬g.TerminatedAt n
gp : Pair K
s_nth_eq : g.s.get? n = some gp
this : ppA * pB - ppB * pA = (-1) ^ n
pow_succ_n : (-1) ^ (n + 1) = -1 * (-1) ^ n
⊢ pA * ppB - pB * ppA = -1 * (ppA * pB - ppB * pA)

tactic: ring
state_before: K : Type u_1
v : K
n✝ : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
hyp : n + 1 = 0 ∨ ¬(of v).TerminatedAt (n + 1 - 1)
g : GeneralizedContinuedFraction K := of v
conts : Pair K := g.continuantsAux (n + 2)
pred_conts : Pair K := g.continuantsAux (n + 1)
pred_conts_eq : pred_conts = g.continuantsAux (n + 1)
ppred_conts : Pair K := g.continuantsAux n
IH : n = 0 ∨ ¬(of v).TerminatedAt (n - 1) → ppred_conts.a * pred_conts.b - ppred_conts.b * pred_conts.a = (-1) ^ n
ppred_conts_eq : ppred_conts = g.continuantsAux n
pA : K := pred_conts.a
pB : K := pred_conts.b
ppA : K := ppred_conts.a
ppB : K := ppred_conts.b
not_terminated_at_n : ¬g.TerminatedAt n
gp : Pair K
s_nth_eq : g.s.get? n = some gp
this : ppA * pB - ppB * pA = (-1) ^ n
pow_succ_n : (-1) ^ (n + 1) = -1 * (-1) ^ n
⊢ pA * ppB - pB * ppA = -1 * (ppA * pB - ppB * pA)
state_after: no goals