Theorem: GeneralizedContinuedFraction.of_s_succ
File: Mathlib/Algebra/ContinuedFractions/Computation/Translations.lean

tactic: cases' eq_or_ne (fract v) 0 with h h
state_before: K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ n : ℕ
⊢ Stream'.Seq.get? (of v).s (n + 1) = Stream'.Seq.get? (of (fract v)⁻¹).s n

tactic: cases' eq_or_ne ((of (fract v)⁻¹).s.get? n) none with h₁ h₁
state_before: case inr
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ n : ℕ
h : fract v ≠ 0
⊢ Stream'.Seq.get? (of v).s (n + 1) = Stream'.Seq.get? (of (fract v)⁻¹).s n

tactic: obtain ⟨a, rfl⟩ : ∃ a : ℤ, v = a := ⟨⌊v⌋, eq_of_sub_eq_zero h⟩
state_before: case inl
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ n : ℕ
h : fract v = 0
⊢ Stream'.Seq.get? (of v).s (n + 1) = Stream'.Seq.get? (of (fract v)⁻¹).s n

tactic: rw [fract_intCast, inv_zero, of_s_of_int, ← cast_zero, of_s_of_int,
  Stream'.Seq.get?_nil, Stream'.Seq.get?_nil]
state_before: case inl.intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n✝ n : ℕ
a : ℤ
h : fract ↑a = 0
⊢ Stream'.Seq.get? (of ↑a).s (n + 1) = Stream'.Seq.get? (of (fract ↑a)⁻¹).s n

tactic: rwa [h₁, ← terminatedAt_iff_s_none,
  of_terminatedAt_n_iff_succ_nth_intFractPair_stream_eq_none, stream_succ h, ←
  of_terminatedAt_n_iff_succ_nth_intFractPair_stream_eq_none, terminatedAt_iff_s_none]
state_before: case inr.inl
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ n : ℕ
h : fract v ≠ 0
h₁ : Stream'.Seq.get? (of (fract v)⁻¹).s n = none
⊢ Stream'.Seq.get? (of v).s (n + 1) = Stream'.Seq.get? (of (fract v)⁻¹).s n

tactic: obtain ⟨p, hp⟩ := Option.ne_none_iff_exists'.mp h₁
state_before: case inr.inr
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ n : ℕ
h : fract v ≠ 0
h₁ : Stream'.Seq.get? (of (fract v)⁻¹).s n ≠ none
⊢ Stream'.Seq.get? (of v).s (n + 1) = Stream'.Seq.get? (of (fract v)⁻¹).s n

tactic: obtain ⟨p', hp'₁, _⟩ := exists_succ_get?_stream_of_gcf_of_get?_eq_some hp
state_before: case inr.inr.intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ n : ℕ
h : fract v ≠ 0
h₁ : Stream'.Seq.get? (of (fract v)⁻¹).s n ≠ none
p : Pair K
hp : Stream'.Seq.get? (of (fract v)⁻¹).s n = some p
⊢ Stream'.Seq.get? (of v).s (n + 1) = Stream'.Seq.get? (of (fract v)⁻¹).s n

tactic: have Hp := get?_of_eq_some_of_succ_get?_intFractPair_stream hp'₁
state_before: case inr.inr.intro.intro.intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ n : ℕ
h : fract v ≠ 0
h₁ : Stream'.Seq.get? (of (fract v)⁻¹).s n ≠ none
p : Pair K
hp : Stream'.Seq.get? (of (fract v)⁻¹).s n = some p
p' : IntFractPair K
hp'₁ : IntFractPair.stream (fract v)⁻¹ (n + 1) = some p'
right✝ : ↑p'.b = p.b
⊢ Stream'.Seq.get? (of v).s (n + 1) = Stream'.Seq.get? (of (fract v)⁻¹).s n

tactic: rw [← stream_succ h] at hp'₁
state_before: case inr.inr.intro.intro.intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ n : ℕ
h : fract v ≠ 0
h₁ : Stream'.Seq.get? (of (fract v)⁻¹).s n ≠ none
p : Pair K
hp : Stream'.Seq.get? (of (fract v)⁻¹).s n = some p
p' : IntFractPair K
hp'₁ : IntFractPair.stream (fract v)⁻¹ (n + 1) = some p'
right✝ : ↑p'.b = p.b
Hp : Stream'.Seq.get? (of (fract v)⁻¹).s n = some { a := 1, b := ↑p'.b }
⊢ Stream'.Seq.get? (of v).s (n + 1) = Stream'.Seq.get? (of (fract v)⁻¹).s n

tactic: rw [Hp, get?_of_eq_some_of_succ_get?_intFractPair_stream hp'₁]
state_before: case inr.inr.intro.intro.intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ n : ℕ
h : fract v ≠ 0
h₁ : Stream'.Seq.get? (of (fract v)⁻¹).s n ≠ none
p : Pair K
hp : Stream'.Seq.get? (of (fract v)⁻¹).s n = some p
p' : IntFractPair K
hp'₁ : IntFractPair.stream v (n + 1 + 1) = some p'
right✝ : ↑p'.b = p.b
Hp : Stream'.Seq.get? (of (fract v)⁻¹).s n = some { a := 1, b := ↑p'.b }
⊢ Stream'.Seq.get? (of v).s (n + 1) = Stream'.Seq.get? (of (fract v)⁻¹).s n