File: Mathlib/Algebra/ContinuedFractions/Computation/Translations.lean

full_name: GenContFract.IntFractPair.stream_zero
code: theorem stream_zero (v : K) : IntFractPair.stream v 0 = some (IntFractPair.of v) 
goal: GenContFract.IntFractPair.stream v 0 = some (GenContFract.IntFractPair.of v)

full_name: GenContFract.IntFractPair.stream_eq_none_of_fr_eq_zero
code: theorem stream_eq_none_of_fr_eq_zero {ifp_n : IntFractPair K}
    (stream_nth_eq : IntFractPair.stream v n = some ifp_n) (nth_fr_eq_zero : ifp_n.fr = 0) :
    IntFractPair.stream v (n + 1) = none 
goal: GenContFract.IntFractPair.stream v (n + 1) = none

full_name: GenContFract.IntFractPair.succ_nth_stream_eq_none_iff
code: /-- Gives a recurrence to compute the `n + 1`th value of the sequence of integer and fractional
parts of a value in case of termination.
-/
theorem succ_nth_stream_eq_none_iff :
    IntFractPair.stream v (n + 1) = none ↔
      IntFractPair.stream v n = none ∨ ∃ ifp, IntFractPair.stream v n = some ifp ∧ ifp.fr = 0 
goal: GenContFract.IntFractPair.stream v (n + 1) = none ↔
  GenContFract.IntFractPair.stream v n = none ∨ ∃ ifp, GenContFract.IntFractPair.stream v n = some ifp ∧ ifp.fr = 0

full_name: GenContFract.IntFractPair.succ_nth_stream_eq_some_iff
code: /-- Gives a recurrence to compute the `n + 1`th value of the sequence of integer and fractional
parts of a value in case of non-termination.
-/
theorem succ_nth_stream_eq_some_iff {ifp_succ_n : IntFractPair K} :
    IntFractPair.stream v (n + 1) = some ifp_succ_n ↔
      ∃ ifp_n : IntFractPair K,
        IntFractPair.stream v n = some ifp_n ∧
          ifp_n.fr ≠ 0 ∧ IntFractPair.of ifp_n.fr⁻¹ = ifp_succ_n 
goal: GenContFract.IntFractPair.stream v (n + 1) = some ifp_succ_n ↔
  ∃ ifp_n,
    GenContFract.IntFractPair.stream v n = some ifp_n ∧
      ifp_n.fr ≠ 0 ∧ GenContFract.IntFractPair.of ifp_n.fr⁻¹ = ifp_succ_n

full_name: GenContFract.IntFractPair.stream_succ_of_some
code: /-- An easier to use version of one direction of
`GenContFract.IntFractPair.succ_nth_stream_eq_some_iff`. -/
theorem stream_succ_of_some {p : IntFractPair K} (h : IntFractPair.stream v n = some p)
    (h' : p.fr ≠ 0) : IntFractPair.stream v (n + 1) = some (IntFractPair.of p.fr⁻¹) 
goal: GenContFract.IntFractPair.stream v (n + 1) = some (GenContFract.IntFractPair.of p.fr⁻¹)

full_name: GenContFract.IntFractPair.stream_succ_of_int
code: /-- The stream of `IntFractPair`s of an integer stops after the first term.
-/
theorem stream_succ_of_int (a : ℤ) (n : ℕ) : IntFractPair.stream (a : K) (n + 1) = none 
goal: GenContFract.IntFractPair.stream (↑a) (n + 1) = none

full_name: GenContFract.IntFractPair.exists_succ_nth_stream_of_fr_zero
code: theorem exists_succ_nth_stream_of_fr_zero {ifp_succ_n : IntFractPair K}
    (stream_succ_nth_eq : IntFractPair.stream v (n + 1) = some ifp_succ_n)
    (succ_nth_fr_eq_zero : ifp_succ_n.fr = 0) :
    ∃ ifp_n : IntFractPair K, IntFractPair.stream v n = some ifp_n ∧ ifp_n.fr⁻¹ = ⌊ifp_n.fr⁻¹⌋ 
goal: ∃ ifp_n, GenContFract.IntFractPair.stream v n = some ifp_n ∧ ifp_n.fr⁻¹ = ↑⌊ifp_n.fr⁻¹⌋

full_name: GenContFract.IntFractPair.stream_succ
code: /-- A recurrence relation that expresses the `(n+1)`th term of the stream of `IntFractPair`s
of `v` for non-integer `v` in terms of the `n`th term of the stream associated to
the inverse of the fractional part of `v`.
-/
theorem stream_succ (h : Int.fract v ≠ 0) (n : ℕ) :
    IntFractPair.stream v (n + 1) = IntFractPair.stream (Int.fract v)⁻¹ n 
goal: GenContFract.IntFractPair.stream v (n + 1) = GenContFract.IntFractPair.stream (Int.fract v)⁻¹ n

full_name: GenContFract.IntFractPair.seq1_fst_eq_of
code: /-- The head term of the sequence with head of `v` is just the integer part of `v`. -/
@[simp]
theorem IntFractPair.seq1_fst_eq_of : (IntFractPair.seq1 v).fst = IntFractPair.of v 
goal: (GenContFract.IntFractPair.seq1 v).1 = GenContFract.IntFractPair.of v

full_name: GenContFract.of_h_eq_intFractPair_seq1_fst_b
code: theorem of_h_eq_intFractPair_seq1_fst_b : (of v).h = (IntFractPair.seq1 v).fst.b 
goal: (GenContFract.of v).h = ↑(GenContFract.IntFractPair.seq1 v).1.b

full_name: GenContFract.of_h_eq_floor
code: /-- The head term of the gcf of `v` is `⌊v⌋`. -/
@[simp]
theorem of_h_eq_floor : (of v).h = ⌊v⌋ 
goal: (GenContFract.of v).h = ↑⌊v⌋

full_name: GenContFract.IntFractPair.get?_seq1_eq_succ_get?_stream
code: theorem IntFractPair.get?_seq1_eq_succ_get?_stream :
    (IntFractPair.seq1 v).snd.get? n = (IntFractPair.stream v) (n + 1) 
goal: (GenContFract.IntFractPair.seq1 v).2.get? n = GenContFract.IntFractPair.stream v (n + 1)

full_name: GenContFract.of_terminatedAt_iff_intFractPair_seq1_terminatedAt
code: theorem of_terminatedAt_iff_intFractPair_seq1_terminatedAt :
    (of v).TerminatedAt n ↔ (IntFractPair.seq1 v).snd.TerminatedAt n 
goal: (GenContFract.of v).TerminatedAt n ↔ (GenContFract.IntFractPair.seq1 v).2.TerminatedAt n

full_name: GenContFract.of_terminatedAt_n_iff_succ_nth_intFractPair_stream_eq_none
code: theorem of_terminatedAt_n_iff_succ_nth_intFractPair_stream_eq_none :
    (of v).TerminatedAt n ↔ IntFractPair.stream v (n + 1) = none 
goal: (GenContFract.of v).TerminatedAt n ↔ GenContFract.IntFractPair.stream v (n + 1) = none

full_name: GenContFract.IntFractPair.exists_succ_get?_stream_of_gcf_of_get?_eq_some
code: theorem IntFractPair.exists_succ_get?_stream_of_gcf_of_get?_eq_some {gp_n : Pair K}
    (s_nth_eq : (of v).s.get? n = some gp_n) :
    ∃ ifp : IntFractPair K, IntFractPair.stream v (n + 1) = some ifp ∧ (ifp.b : K) = gp_n.b 
goal: ∃ ifp, GenContFract.IntFractPair.stream v (n + 1) = some ifp ∧ ↑ifp.b = gp_n.b

full_name: GenContFract.get?_of_eq_some_of_succ_get?_intFractPair_stream
code: /-- Shows how the entries of the sequence of the computed continued fraction can be obtained by the
integer parts of the stream of integer and fractional parts.
-/
theorem get?_of_eq_some_of_succ_get?_intFractPair_stream {ifp_succ_n : IntFractPair K}
    (stream_succ_nth_eq : IntFractPair.stream v (n + 1) = some ifp_succ_n) :
    (of v).s.get? n = some ⟨1, ifp_succ_n.b⟩ 
goal: (GenContFract.of v).s.get? n = some { a := 1, b := ↑ifp_succ_n.b }

full_name: GenContFract.get?_of_eq_some_of_get?_intFractPair_stream_fr_ne_zero
code: /-- Shows how the entries of the sequence of the computed continued fraction can be obtained by the
fractional parts of the stream of integer and fractional parts.
-/
theorem get?_of_eq_some_of_get?_intFractPair_stream_fr_ne_zero {ifp_n : IntFractPair K}
    (stream_nth_eq : IntFractPair.stream v n = some ifp_n) (nth_fr_ne_zero : ifp_n.fr ≠ 0) :
    (of v).s.get? n = some ⟨1, (IntFractPair.of ifp_n.fr⁻¹).b⟩ 
goal: (GenContFract.of v).s.get? n = some { a := 1, b := ↑(GenContFract.IntFractPair.of ifp_n.fr⁻¹).b }

full_name: GenContFract.of_s_head_aux
code: theorem of_s_head_aux (v : K) : (of v).s.get? 0 = (IntFractPair.stream v 1).bind (some ∘ fun p =>
    { a := 1
      b := p.b }) 
goal: (GenContFract.of v).s.get? 0 = (GenContFract.IntFractPair.stream v 1).bind (some ∘ fun p => { a := 1, b := ↑p.b })

full_name: GenContFract.of_s_head
code: /-- This gives the first pair of coefficients of the continued fraction of a non-integer `v`.
-/
theorem of_s_head (h : fract v ≠ 0) : (of v).s.head = some ⟨1, ⌊(fract v)⁻¹⌋⟩ 
goal: (GenContFract.of v).s.head = some { a := 1, b := ↑⌊(Int.fract v)⁻¹⌋ }

full_name: GenContFract.of_s_of_int
code: /-- If `a` is an integer, then the coefficient sequence of its continued fraction is empty.
-/
theorem of_s_of_int (a : ℤ) : (of (a : K)).s = Stream'.Seq.nil 
goal: (GenContFract.of ↑a).s = Stream'.Seq.nil

full_name: GenContFract.of_s_succ
code: /-- Recurrence for the `GenContFract.of` an element `v` of `K` in terms of that of the inverse of
the fractional part of `v`.
-/
theorem of_s_succ (n : ℕ) : (of v).s.get? (n + 1) = (of (fract v)⁻¹).s.get? n 
goal: (GenContFract.of v).s.get? (n + 1) = (GenContFract.of (Int.fract v)⁻¹).s.get? n

full_name: GenContFract.of_s_tail
code: /-- This expresses the tail of the coefficient sequence of the `GenContFract.of` an element `v` of
`K` as the coefficient sequence of that of the inverse of the fractional part of `v`.
-/
theorem of_s_tail : (of v).s.tail = (of (fract v)⁻¹).s 
goal: (GenContFract.of v).s.tail = (GenContFract.of (Int.fract v)⁻¹).s

full_name: GenContFract.convs'_of_int
code: /-- If `a` is an integer, then the `convs'` of its continued fraction expansion
are all equal to `a`.
-/
theorem convs'_of_int (a : ℤ) : (of (a : K)).convs' n = a 
goal: (GenContFract.of ↑a).convs' n = ↑a

full_name: GenContFract.convs'_succ
code: /-- The recurrence relation for the `convs'` of the continued fraction expansion
of an element `v` of `K` in terms of the convergents of the inverse of its fractional part.
-/
theorem convs'_succ :
    (of v).convs' (n + 1) = ⌊v⌋ + 1 / (of (fract v)⁻¹).convs' n 
goal: (GenContFract.of v).convs' (n + 1) = ↑⌊v⌋ + 1 / (GenContFract.of (Int.fract v)⁻¹).convs' n