-- Mathlib/Algebra/ContinuedFractions/Computation/Approximations.lean
theorem of_partNum_eq_one_and_exists_int_partDen_eq {gp : GenContFract.Pair K}
    (nth_s_eq : (of v).s.get? n = some gp) : gp.a = 1 ∧ ∃ z : ℤ, gp.b = (z : K)

Proof state:
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
gp : Pair K
nth_s_eq : (of v).s.get? n = some gp
⊢ gp.a = 1 ∧ ∃ z, gp.b = ↑z

Tactic:
obtain ⟨ifp, stream_succ_nth_eq, -⟩ : ∃ ifp, IntFractPair.stream v (n + 1) = some ifp ∧ _ :=
  IntFractPair.exists_succ_get?_stream_of_gcf_of_get?_eq_some nth_s_eq

Result:
case intro.intro
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
gp : Pair K
nth_s_eq : (of v).s.get? n = some gp
ifp : IntFractPair K
stream_succ_nth_eq : IntFractPair.stream v (n + 1) = some ifp
⊢ gp.a = 1 ∧ ∃ z, gp.b = ↑z

Proof state:
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
gp : Pair K
nth_s_eq : (of v).s.get? n = some gp
ifp : IntFractPair K
stream_succ_nth_eq : IntFractPair.stream v (n + 1) = some ifp
this✝ : (of v).s.get? n = some { a := 1, b := ↑ifp.b }
this : some gp = some { a := 1, b := ↑ifp.b }
⊢ gp = { a := 1, b := ↑ifp.b }

Tactic:
injection this

Result:
no goals

Proof state:
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
gp : Pair K
nth_s_eq : (of v).s.get? n = some gp
ifp : IntFractPair K
stream_succ_nth_eq : IntFractPair.stream v (n + 1) = some ifp
this : (of v).s.get? n = some { a := 1, b := ↑ifp.b }
⊢ some gp = some { a := 1, b := ↑ifp.b }

Tactic:
rwa [nth_s_eq] at this

Result:
no goals

Proof state:
case intro.intro
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
gp : Pair K
nth_s_eq : (of v).s.get? n = some gp
ifp : IntFractPair K
stream_succ_nth_eq : IntFractPair.stream v (n + 1) = some ifp
this : gp = { a := 1, b := ↑ifp.b }
⊢ gp.a = 1 ∧ ∃ z, gp.b = ↑z

Tactic:
simp [this]

Result:
no goals

Proof state:
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
gp : Pair K
nth_s_eq : (of v).s.get? n = some gp
ifp : IntFractPair K
stream_succ_nth_eq : IntFractPair.stream v (n + 1) = some ifp
⊢ gp = { a := 1, b := ↑ifp.b }

Tactic:
have : (of v).s.get? n = some ⟨1, ifp.b⟩ :=
  get?_of_eq_some_of_succ_get?_intFractPair_stream stream_succ_nth_eq

Result:
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
gp : Pair K
nth_s_eq : (of v).s.get? n = some gp
ifp : IntFractPair K
stream_succ_nth_eq : IntFractPair.stream v (n + 1) = some ifp
this : (of v).s.get? n = some { a := 1, b := ↑ifp.b }
⊢ gp = { a := 1, b := ↑ifp.b }

Proof state:
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
gp : Pair K
nth_s_eq : (of v).s.get? n = some gp
ifp : IntFractPair K
stream_succ_nth_eq : IntFractPair.stream v (n + 1) = some ifp
this : (of v).s.get? n = some { a := 1, b := ↑ifp.b }
⊢ gp = { a := 1, b := ↑ifp.b }

Tactic:
have : some gp = some ⟨1, ifp.b⟩ := by rwa [nth_s_eq] at this

Result:
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
gp : Pair K
nth_s_eq : (of v).s.get? n = some gp
ifp : IntFractPair K
stream_succ_nth_eq : IntFractPair.stream v (n + 1) = some ifp
this✝ : (of v).s.get? n = some { a := 1, b := ↑ifp.b }
this : some gp = some { a := 1, b := ↑ifp.b }
⊢ gp = { a := 1, b := ↑ifp.b }

Proof state:
case intro.intro
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
gp : Pair K
nth_s_eq : (of v).s.get? n = some gp
ifp : IntFractPair K
stream_succ_nth_eq : IntFractPair.stream v (n + 1) = some ifp
⊢ gp.a = 1 ∧ ∃ z, gp.b = ↑z

Tactic:
have : gp = ⟨1, ifp.b⟩ := by
  have : (of v).s.get? n = some ⟨1, ifp.b⟩ :=
    get?_of_eq_some_of_succ_get?_intFractPair_stream stream_succ_nth_eq
  have : some gp = some ⟨1, ifp.b⟩ := by rwa [nth_s_eq] at this
  injection this

Result:
case intro.intro
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
gp : Pair K
nth_s_eq : (of v).s.get? n = some gp
ifp : IntFractPair K
stream_succ_nth_eq : IntFractPair.stream v (n + 1) = some ifp
this : gp = { a := 1, b := ↑ifp.b }
⊢ gp.a = 1 ∧ ∃ z, gp.b = ↑z