statement
stringlengths
1
2.88k
proof
stringlengths
0
13.9k
type
stringclasses
10 values
symbolic_name
stringlengths
1
131
library
stringclasses
417 values
filename
stringlengths
17
80
imports
listlengths
0
16
deps
listlengths
0
64
docstring
stringlengths
0
10.2k
source_url
stringclasses
1 value
commit
stringclasses
1 value
squash_gcf_nth_of_lt {m : ℕ} (m_lt_n : m < n) : (squash_gcf g (n + 1)).s.nth m = g.s.nth m
by simp only [squash_gcf, (squash_seq_nth_of_lt m_lt_n)]
lemma
generalized_continued_fraction.squash_gcf_nth_of_lt
algebra.continued_fractions
src/algebra/continued_fractions/convergents_equiv.lean
[ "algebra.continued_fractions.continuants_recurrence", "algebra.continued_fractions.terminated_stable", "tactic.field_simp", "tactic.ring" ]
[]
The values before the squashed position stay the same.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
succ_nth_convergent'_eq_squash_gcf_nth_convergent' : g.convergents' (n + 1) = (squash_gcf g n).convergents' n
begin cases n, case nat.zero { cases g_s_head_eq : (g.s.nth 0); simp [g_s_head_eq, squash_gcf, convergents', convergents'_aux, seq.head] }, case nat.succ { simp only [succ_succ_nth_convergent'_aux_eq_succ_nth_convergent'_aux_squash_seq, convergents', squash_gcf] } end
lemma
generalized_continued_fraction.succ_nth_convergent'_eq_squash_gcf_nth_convergent'
algebra.continued_fractions
src/algebra/continued_fractions/convergents_equiv.lean
[ "algebra.continued_fractions.continuants_recurrence", "algebra.continued_fractions.terminated_stable", "tactic.field_simp", "tactic.ring" ]
[]
`convergents'` returns the same value for a gcf and the corresponding squashed gcf at the squashed position.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
continuants_aux_eq_continuants_aux_squash_gcf_of_le {m : ℕ} : m ≤ n → continuants_aux g m = (squash_gcf g n).continuants_aux m
nat.strong_induction_on m (begin clear m, assume m IH m_le_n, cases m with m', { refl }, { cases n with n', { exact (m'.not_succ_le_zero m_le_n).elim }, -- 1 ≰ 0 { cases m' with m'', { refl }, { -- get some inequalities to instantiate the IH for m'' and m'' + 1 have m'_lt_n : m'' +...
lemma
generalized_continued_fraction.continuants_aux_eq_continuants_aux_squash_gcf_of_le
algebra.continued_fractions
src/algebra/continued_fractions/convergents_equiv.lean
[ "algebra.continued_fractions.continuants_recurrence", "algebra.continued_fractions.terminated_stable", "tactic.field_simp", "tactic.ring" ]
[ "lt_add_one", "zero_lt_two" ]
The auxiliary continuants before the squashed position stay the same.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
succ_nth_convergent_eq_squash_gcf_nth_convergent [field K] (nth_part_denom_ne_zero : ∀ {b : K}, g.partial_denominators.nth n = some b → b ≠ 0) : g.convergents (n + 1) = (squash_gcf g n).convergents n
begin cases decidable.em (g.terminated_at n) with terminated_at_n not_terminated_at_n, { have : squash_gcf g n = g, from squash_gcf_eq_self_of_terminated terminated_at_n, simp only [this, (convergents_stable_of_terminated n.le_succ terminated_at_n)] }, { obtain ⟨⟨a, b⟩, s_nth_eq⟩ : ∃ gp_n, g.s.nth n = some gp...
lemma
generalized_continued_fraction.succ_nth_convergent_eq_squash_gcf_nth_convergent
algebra.continued_fractions
src/algebra/continued_fractions/convergents_equiv.lean
[ "algebra.continued_fractions.continuants_recurrence", "algebra.continued_fractions.terminated_stable", "tactic.field_simp", "tactic.ring" ]
[ "field", "mul_div_cancel", "mul_div_cancel_left", "ring" ]
The convergents coincide in the expected way at the squashed position if the partial denominator at the squashed position is not zero.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
convergents_eq_convergents' [linear_ordered_field K] (s_pos : ∀ {gp : pair K} {m : ℕ}, m < n → g.s.nth m = some gp → 0 < gp.a ∧ 0 < gp.b) : g.convergents n = g.convergents' n
begin induction n with n IH generalizing g, case nat.zero { simp }, case nat.succ { let g' := squash_gcf g n, -- first replace the rhs with the squashed computation suffices : g.convergents (n + 1) = g'.convergents' n, by rwa [succ_nth_convergent'_eq_squash_gcf_nth_convergent'], cases decidable.em...
theorem
generalized_continued_fraction.convergents_eq_convergents'
algebra.continued_fractions
src/algebra/continued_fractions/convergents_equiv.lean
[ "algebra.continued_fractions.continuants_recurrence", "algebra.continued_fractions.terminated_stable", "tactic.field_simp", "tactic.ring" ]
[ "div_pos", "linear_ordered_field", "lt_add_one" ]
Shows that the recurrence relation (`convergents`) and direct evaluation (`convergents'`) of the gcf coincide at position `n` if the sequence of fractions contains strictly positive values only. Requiring positivity of all values is just one possible condition to obtain this result. For example, the dual - sequences wi...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
convergents_eq_convergents' [linear_ordered_field K] {c : continued_fraction K} : (↑c : generalized_continued_fraction K).convergents = (↑c : generalized_continued_fraction K).convergents'
begin ext n, apply convergents_eq_convergents', assume gp m m_lt_n s_nth_eq, exact ⟨zero_lt_one.trans_le ((c : simple_continued_fraction K).property m gp.a (part_num_eq_s_a s_nth_eq)).symm.le, c.property m gp.b $ part_denom_eq_s_b s_nth_eq⟩ end
theorem
continued_fraction.convergents_eq_convergents'
algebra.continued_fractions
src/algebra/continued_fractions/convergents_equiv.lean
[ "algebra.continued_fractions.continuants_recurrence", "algebra.continued_fractions.terminated_stable", "tactic.field_simp", "tactic.ring" ]
[ "continued_fraction", "generalized_continued_fraction", "linear_ordered_field", "simple_continued_fraction" ]
Shows that the recurrence relation (`convergents`) and direct evaluation (`convergents'`) of a (regular) continued fraction coincide.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
terminated_stable (n_le_m : n ≤ m) (terminated_at_n : g.terminated_at n) : g.terminated_at m
g.s.terminated_stable n_le_m terminated_at_n
lemma
generalized_continued_fraction.terminated_stable
algebra.continued_fractions
src/algebra/continued_fractions/terminated_stable.lean
[ "algebra.continued_fractions.translations" ]
[]
If a gcf terminated at position `n`, it also terminated at `m ≥ n`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
continuants_aux_stable_step_of_terminated (terminated_at_n : g.terminated_at n) : g.continuants_aux (n + 2) = g.continuants_aux (n + 1)
by { rw [terminated_at_iff_s_none] at terminated_at_n, simp only [terminated_at_n, continuants_aux] }
lemma
generalized_continued_fraction.continuants_aux_stable_step_of_terminated
algebra.continued_fractions
src/algebra/continued_fractions/terminated_stable.lean
[ "algebra.continued_fractions.translations" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
continuants_aux_stable_of_terminated (n_lt_m : n < m) (terminated_at_n : g.terminated_at n) : g.continuants_aux m = g.continuants_aux (n + 1)
begin refine nat.le_induction rfl (λ k hnk hk, _) _ n_lt_m, rcases nat.exists_eq_add_of_lt hnk with ⟨k, rfl⟩, refine (continuants_aux_stable_step_of_terminated _).trans hk, exact terminated_stable (nat.le_add_right _ _) terminated_at_n end
lemma
generalized_continued_fraction.continuants_aux_stable_of_terminated
algebra.continued_fractions
src/algebra/continued_fractions/terminated_stable.lean
[ "algebra.continued_fractions.translations" ]
[ "nat.exists_eq_add_of_lt", "nat.le_induction" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
convergents'_aux_stable_step_of_terminated {s : seq $ pair K} (terminated_at_n : s.terminated_at n) : convergents'_aux s (n + 1) = convergents'_aux s n
begin change s.nth n = none at terminated_at_n, induction n with n IH generalizing s, case nat.zero { simp only [convergents'_aux, terminated_at_n, seq.head] }, case nat.succ { cases s_head_eq : s.head with gp_head, case option.none { simp only [convergents'_aux, s_head_eq] }, case option.some {...
lemma
generalized_continued_fraction.convergents'_aux_stable_step_of_terminated
algebra.continued_fractions
src/algebra/continued_fractions/terminated_stable.lean
[ "algebra.continued_fractions.translations" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
convergents'_aux_stable_of_terminated {s : seq $ pair K} (n_le_m : n ≤ m) (terminated_at_n : s.terminated_at n) : convergents'_aux s m = convergents'_aux s n
begin induction n_le_m with m n_le_m IH, { refl }, { refine (convergents'_aux_stable_step_of_terminated _).trans IH, exact s.terminated_stable n_le_m terminated_at_n } end
lemma
generalized_continued_fraction.convergents'_aux_stable_of_terminated
algebra.continued_fractions
src/algebra/continued_fractions/terminated_stable.lean
[ "algebra.continued_fractions.translations" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
continuants_stable_of_terminated (n_le_m : n ≤ m) (terminated_at_n : g.terminated_at n) : g.continuants m = g.continuants n
by simp only [nth_cont_eq_succ_nth_cont_aux, (continuants_aux_stable_of_terminated (nat.pred_le_iff.elim_left n_le_m) terminated_at_n)]
lemma
generalized_continued_fraction.continuants_stable_of_terminated
algebra.continued_fractions
src/algebra/continued_fractions/terminated_stable.lean
[ "algebra.continued_fractions.translations" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
numerators_stable_of_terminated (n_le_m : n ≤ m) (terminated_at_n : g.terminated_at n) : g.numerators m = g.numerators n
by simp only [num_eq_conts_a, (continuants_stable_of_terminated n_le_m terminated_at_n)]
lemma
generalized_continued_fraction.numerators_stable_of_terminated
algebra.continued_fractions
src/algebra/continued_fractions/terminated_stable.lean
[ "algebra.continued_fractions.translations" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
denominators_stable_of_terminated (n_le_m : n ≤ m) (terminated_at_n : g.terminated_at n) : g.denominators m = g.denominators n
by simp only [denom_eq_conts_b, (continuants_stable_of_terminated n_le_m terminated_at_n)]
lemma
generalized_continued_fraction.denominators_stable_of_terminated
algebra.continued_fractions
src/algebra/continued_fractions/terminated_stable.lean
[ "algebra.continued_fractions.translations" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
convergents_stable_of_terminated (n_le_m : n ≤ m) (terminated_at_n : g.terminated_at n) : g.convergents m = g.convergents n
by simp only [convergents, (denominators_stable_of_terminated n_le_m terminated_at_n), (numerators_stable_of_terminated n_le_m terminated_at_n)]
lemma
generalized_continued_fraction.convergents_stable_of_terminated
algebra.continued_fractions
src/algebra/continued_fractions/terminated_stable.lean
[ "algebra.continued_fractions.translations" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
convergents'_stable_of_terminated (n_le_m : n ≤ m) (terminated_at_n : g.terminated_at n) : g.convergents' m = g.convergents' n
by simp only [convergents', (convergents'_aux_stable_of_terminated n_le_m terminated_at_n)]
lemma
generalized_continued_fraction.convergents'_stable_of_terminated
algebra.continued_fractions
src/algebra/continued_fractions/terminated_stable.lean
[ "algebra.continued_fractions.translations" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
terminated_at_iff_s_terminated_at : g.terminated_at n ↔ g.s.terminated_at n
by refl
lemma
generalized_continued_fraction.terminated_at_iff_s_terminated_at
algebra.continued_fractions
src/algebra/continued_fractions/translations.lean
[ "algebra.continued_fractions.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
terminated_at_iff_s_none : g.terminated_at n ↔ g.s.nth n = none
by refl
lemma
generalized_continued_fraction.terminated_at_iff_s_none
algebra.continued_fractions
src/algebra/continued_fractions/translations.lean
[ "algebra.continued_fractions.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
part_num_none_iff_s_none : g.partial_numerators.nth n = none ↔ g.s.nth n = none
by cases s_nth_eq : (g.s.nth n); simp [partial_numerators, s_nth_eq]
lemma
generalized_continued_fraction.part_num_none_iff_s_none
algebra.continued_fractions
src/algebra/continued_fractions/translations.lean
[ "algebra.continued_fractions.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
terminated_at_iff_part_num_none : g.terminated_at n ↔ g.partial_numerators.nth n = none
by rw [terminated_at_iff_s_none, part_num_none_iff_s_none]
lemma
generalized_continued_fraction.terminated_at_iff_part_num_none
algebra.continued_fractions
src/algebra/continued_fractions/translations.lean
[ "algebra.continued_fractions.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
part_denom_none_iff_s_none : g.partial_denominators.nth n = none ↔ g.s.nth n = none
by cases s_nth_eq : (g.s.nth n); simp [partial_denominators, s_nth_eq]
lemma
generalized_continued_fraction.part_denom_none_iff_s_none
algebra.continued_fractions
src/algebra/continued_fractions/translations.lean
[ "algebra.continued_fractions.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
terminated_at_iff_part_denom_none : g.terminated_at n ↔ g.partial_denominators.nth n = none
by rw [terminated_at_iff_s_none, part_denom_none_iff_s_none]
lemma
generalized_continued_fraction.terminated_at_iff_part_denom_none
algebra.continued_fractions
src/algebra/continued_fractions/translations.lean
[ "algebra.continued_fractions.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
part_num_eq_s_a {gp : pair α} (s_nth_eq : g.s.nth n = some gp) : g.partial_numerators.nth n = some gp.a
by simp [partial_numerators, s_nth_eq]
lemma
generalized_continued_fraction.part_num_eq_s_a
algebra.continued_fractions
src/algebra/continued_fractions/translations.lean
[ "algebra.continued_fractions.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
part_denom_eq_s_b {gp : pair α} (s_nth_eq : g.s.nth n = some gp) : g.partial_denominators.nth n = some gp.b
by simp [partial_denominators, s_nth_eq]
lemma
generalized_continued_fraction.part_denom_eq_s_b
algebra.continued_fractions
src/algebra/continued_fractions/translations.lean
[ "algebra.continued_fractions.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
exists_s_a_of_part_num {a : α} (nth_part_num_eq : g.partial_numerators.nth n = some a) : ∃ gp, g.s.nth n = some gp ∧ gp.a = a
by simpa [partial_numerators, seq.map_nth] using nth_part_num_eq
lemma
generalized_continued_fraction.exists_s_a_of_part_num
algebra.continued_fractions
src/algebra/continued_fractions/translations.lean
[ "algebra.continued_fractions.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
exists_s_b_of_part_denom {b : α} (nth_part_denom_eq : g.partial_denominators.nth n = some b) : ∃ gp, g.s.nth n = some gp ∧ gp.b = b
by simpa [partial_denominators, seq.map_nth] using nth_part_denom_eq
lemma
generalized_continued_fraction.exists_s_b_of_part_denom
algebra.continued_fractions
src/algebra/continued_fractions/translations.lean
[ "algebra.continued_fractions.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
nth_cont_eq_succ_nth_cont_aux : g.continuants n = g.continuants_aux (n + 1)
rfl
lemma
generalized_continued_fraction.nth_cont_eq_succ_nth_cont_aux
algebra.continued_fractions
src/algebra/continued_fractions/translations.lean
[ "algebra.continued_fractions.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
num_eq_conts_a : g.numerators n = (g.continuants n).a
rfl
lemma
generalized_continued_fraction.num_eq_conts_a
algebra.continued_fractions
src/algebra/continued_fractions/translations.lean
[ "algebra.continued_fractions.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
denom_eq_conts_b : g.denominators n = (g.continuants n).b
rfl
lemma
generalized_continued_fraction.denom_eq_conts_b
algebra.continued_fractions
src/algebra/continued_fractions/translations.lean
[ "algebra.continued_fractions.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
convergent_eq_num_div_denom : g.convergents n = g.numerators n / g.denominators n
rfl
lemma
generalized_continued_fraction.convergent_eq_num_div_denom
algebra.continued_fractions
src/algebra/continued_fractions/translations.lean
[ "algebra.continued_fractions.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
convergent_eq_conts_a_div_conts_b : g.convergents n = (g.continuants n).a / (g.continuants n).b
rfl
lemma
generalized_continued_fraction.convergent_eq_conts_a_div_conts_b
algebra.continued_fractions
src/algebra/continued_fractions/translations.lean
[ "algebra.continued_fractions.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
exists_conts_a_of_num {A : K} (nth_num_eq : g.numerators n = A) : ∃ conts, g.continuants n = conts ∧ conts.a = A
by simpa
lemma
generalized_continued_fraction.exists_conts_a_of_num
algebra.continued_fractions
src/algebra/continued_fractions/translations.lean
[ "algebra.continued_fractions.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
exists_conts_b_of_denom {B : K} (nth_denom_eq : g.denominators n = B) : ∃ conts, g.continuants n = conts ∧ conts.b = B
by simpa
lemma
generalized_continued_fraction.exists_conts_b_of_denom
algebra.continued_fractions
src/algebra/continued_fractions/translations.lean
[ "algebra.continued_fractions.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
zeroth_continuant_aux_eq_one_zero : g.continuants_aux 0 = ⟨1, 0⟩
rfl
lemma
generalized_continued_fraction.zeroth_continuant_aux_eq_one_zero
algebra.continued_fractions
src/algebra/continued_fractions/translations.lean
[ "algebra.continued_fractions.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
first_continuant_aux_eq_h_one : g.continuants_aux 1 = ⟨g.h, 1⟩
rfl
lemma
generalized_continued_fraction.first_continuant_aux_eq_h_one
algebra.continued_fractions
src/algebra/continued_fractions/translations.lean
[ "algebra.continued_fractions.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
zeroth_continuant_eq_h_one : g.continuants 0 = ⟨g.h, 1⟩
rfl
lemma
generalized_continued_fraction.zeroth_continuant_eq_h_one
algebra.continued_fractions
src/algebra/continued_fractions/translations.lean
[ "algebra.continued_fractions.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
zeroth_numerator_eq_h : g.numerators 0 = g.h
rfl
lemma
generalized_continued_fraction.zeroth_numerator_eq_h
algebra.continued_fractions
src/algebra/continued_fractions/translations.lean
[ "algebra.continued_fractions.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
zeroth_denominator_eq_one : g.denominators 0 = 1
rfl
lemma
generalized_continued_fraction.zeroth_denominator_eq_one
algebra.continued_fractions
src/algebra/continued_fractions/translations.lean
[ "algebra.continued_fractions.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
zeroth_convergent_eq_h : g.convergents 0 = g.h
by simp [convergent_eq_num_div_denom, num_eq_conts_a, denom_eq_conts_b, div_one]
lemma
generalized_continued_fraction.zeroth_convergent_eq_h
algebra.continued_fractions
src/algebra/continued_fractions/translations.lean
[ "algebra.continued_fractions.basic" ]
[ "div_one" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
second_continuant_aux_eq {gp : pair K} (zeroth_s_eq : g.s.nth 0 = some gp) : g.continuants_aux 2 = ⟨gp.b * g.h + gp.a, gp.b⟩
by simp [zeroth_s_eq, continuants_aux, next_continuants, next_denominator, next_numerator]
lemma
generalized_continued_fraction.second_continuant_aux_eq
algebra.continued_fractions
src/algebra/continued_fractions/translations.lean
[ "algebra.continued_fractions.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
first_continuant_eq {gp : pair K} (zeroth_s_eq : g.s.nth 0 = some gp) : g.continuants 1 = ⟨gp.b * g.h + gp.a, gp.b⟩
by simp [nth_cont_eq_succ_nth_cont_aux, (second_continuant_aux_eq zeroth_s_eq)]
lemma
generalized_continued_fraction.first_continuant_eq
algebra.continued_fractions
src/algebra/continued_fractions/translations.lean
[ "algebra.continued_fractions.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
first_numerator_eq {gp : pair K} (zeroth_s_eq : g.s.nth 0 = some gp) : g.numerators 1 = gp.b * g.h + gp.a
by simp[num_eq_conts_a, (first_continuant_eq zeroth_s_eq)]
lemma
generalized_continued_fraction.first_numerator_eq
algebra.continued_fractions
src/algebra/continued_fractions/translations.lean
[ "algebra.continued_fractions.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
first_denominator_eq {gp : pair K} (zeroth_s_eq : g.s.nth 0 = some gp) : g.denominators 1 = gp.b
by simp[denom_eq_conts_b, (first_continuant_eq zeroth_s_eq)]
lemma
generalized_continued_fraction.first_denominator_eq
algebra.continued_fractions
src/algebra/continued_fractions/translations.lean
[ "algebra.continued_fractions.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
zeroth_convergent'_aux_eq_zero {s : seq $ pair K} : convergents'_aux s 0 = 0
rfl
lemma
generalized_continued_fraction.zeroth_convergent'_aux_eq_zero
algebra.continued_fractions
src/algebra/continued_fractions/translations.lean
[ "algebra.continued_fractions.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
zeroth_convergent'_eq_h : g.convergents' 0 = g.h
by simp [convergents']
lemma
generalized_continued_fraction.zeroth_convergent'_eq_h
algebra.continued_fractions
src/algebra/continued_fractions/translations.lean
[ "algebra.continued_fractions.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
convergents'_aux_succ_none {s : seq (pair K)} (h : s.head = none) (n : ℕ) : convergents'_aux s (n + 1) = 0
by rw [convergents'_aux, h, convergents'_aux._match_1]
lemma
generalized_continued_fraction.convergents'_aux_succ_none
algebra.continued_fractions
src/algebra/continued_fractions/translations.lean
[ "algebra.continued_fractions.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
convergents'_aux_succ_some {s : seq (pair K)} {p : pair K} (h : s.head = some p) (n : ℕ) : convergents'_aux s (n + 1) = p.a / (p.b + convergents'_aux s.tail n)
by rw [convergents'_aux, h, convergents'_aux._match_1]
lemma
generalized_continued_fraction.convergents'_aux_succ_some
algebra.continued_fractions
src/algebra/continued_fractions/translations.lean
[ "algebra.continued_fractions.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
nth_stream_fr_nonneg_lt_one {ifp_n : int_fract_pair K} (nth_stream_eq : int_fract_pair.stream v n = some ifp_n) : 0 ≤ ifp_n.fr ∧ ifp_n.fr < 1
begin cases n, case nat.zero { have : int_fract_pair.of v = ifp_n, by injection nth_stream_eq, rw [←this, int_fract_pair.of], exact ⟨fract_nonneg _, fract_lt_one _⟩ }, case nat.succ { rcases (succ_nth_stream_eq_some_iff.elim_left nth_stream_eq) with ⟨_, _, _, ifp_of_eq_ifp_n⟩, rw [←ifp_of_eq_ifp_n...
lemma
generalized_continued_fraction.int_fract_pair.nth_stream_fr_nonneg_lt_one
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/approximations.lean
[ "algebra.continued_fractions.computation.correctness_terminating", "data.nat.fib", "tactic.solve_by_elim" ]
[]
Shows that the fractional parts of the stream are in `[0,1)`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
nth_stream_fr_nonneg {ifp_n : int_fract_pair K} (nth_stream_eq : int_fract_pair.stream v n = some ifp_n) : 0 ≤ ifp_n.fr
(nth_stream_fr_nonneg_lt_one nth_stream_eq).left
lemma
generalized_continued_fraction.int_fract_pair.nth_stream_fr_nonneg
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/approximations.lean
[ "algebra.continued_fractions.computation.correctness_terminating", "data.nat.fib", "tactic.solve_by_elim" ]
[]
Shows that the fractional parts of the stream are nonnegative.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
nth_stream_fr_lt_one {ifp_n : int_fract_pair K} (nth_stream_eq : int_fract_pair.stream v n = some ifp_n) : ifp_n.fr < 1
(nth_stream_fr_nonneg_lt_one nth_stream_eq).right
lemma
generalized_continued_fraction.int_fract_pair.nth_stream_fr_lt_one
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/approximations.lean
[ "algebra.continued_fractions.computation.correctness_terminating", "data.nat.fib", "tactic.solve_by_elim" ]
[]
Shows that the fractional parts of the stream are smaller than one.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
one_le_succ_nth_stream_b {ifp_succ_n : int_fract_pair K} (succ_nth_stream_eq : int_fract_pair.stream v (n + 1) = some ifp_succ_n) : 1 ≤ ifp_succ_n.b
begin obtain ⟨ifp_n, nth_stream_eq, stream_nth_fr_ne_zero, ⟨-⟩⟩ : ∃ ifp_n, int_fract_pair.stream v n = some ifp_n ∧ ifp_n.fr ≠ 0 ∧ int_fract_pair.of ifp_n.fr⁻¹ = ifp_succ_n, from succ_nth_stream_eq_some_iff.elim_left succ_nth_stream_eq, suffices : 1 ≤ ifp_n.fr⁻¹, { rw_mod_cast [le_floor], assumption }...
lemma
generalized_continued_fraction.int_fract_pair.one_le_succ_nth_stream_b
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/approximations.lean
[ "algebra.continued_fractions.computation.correctness_terminating", "data.nat.fib", "tactic.solve_by_elim" ]
[ "one_le_inv" ]
Shows that the integer parts of the stream are at least one.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
succ_nth_stream_b_le_nth_stream_fr_inv {ifp_n ifp_succ_n : int_fract_pair K} (nth_stream_eq : int_fract_pair.stream v n = some ifp_n) (succ_nth_stream_eq : int_fract_pair.stream v (n + 1) = some ifp_succ_n) : (ifp_succ_n.b : K) ≤ ifp_n.fr⁻¹
begin suffices : (⌊ifp_n.fr⁻¹⌋ : K) ≤ ifp_n.fr⁻¹, { cases ifp_n with _ ifp_n_fr, have : ifp_n_fr ≠ 0, { intro h, simpa [h, int_fract_pair.stream, nth_stream_eq] using succ_nth_stream_eq }, have : int_fract_pair.of ifp_n_fr⁻¹ = ifp_succ_n, { simpa [this, int_fract_pair.stream, nth_stream_eq, option.c...
lemma
generalized_continued_fraction.int_fract_pair.succ_nth_stream_b_le_nth_stream_fr_inv
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/approximations.lean
[ "algebra.continued_fractions.computation.correctness_terminating", "data.nat.fib", "tactic.solve_by_elim" ]
[ "option.coe_def" ]
Shows that the `n + 1`th integer part `bₙ₊₁` of the stream is smaller or equal than the inverse of the `n`th fractional part `frₙ` of the stream. This result is straight-forward as `bₙ₊₁` is defined as the floor of `1 / frₙ`
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
of_one_le_nth_part_denom {b : K} (nth_part_denom_eq : (of v).partial_denominators.nth n = some b) : 1 ≤ b
begin obtain ⟨gp_n, nth_s_eq, ⟨-⟩⟩ : ∃ gp_n, (of v).s.nth n = some gp_n ∧ gp_n.b = b, from exists_s_b_of_part_denom nth_part_denom_eq, obtain ⟨ifp_n, succ_nth_stream_eq, ifp_n_b_eq_gp_n_b⟩ : ∃ ifp, int_fract_pair.stream v (n + 1) = some ifp ∧ (ifp.b : K) = gp_n.b, from int_fract_pair.exists_succ_nth_...
lemma
generalized_continued_fraction.of_one_le_nth_part_denom
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/approximations.lean
[ "algebra.continued_fractions.computation.correctness_terminating", "data.nat.fib", "tactic.solve_by_elim" ]
[]
Shows that the integer parts of the continued fraction are at least one.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
of_part_num_eq_one_and_exists_int_part_denom_eq {gp : generalized_continued_fraction.pair K} (nth_s_eq : (of v).s.nth n = some gp) : gp.a = 1 ∧ ∃ (z : ℤ), gp.b = (z : K)
begin obtain ⟨ifp, stream_succ_nth_eq, -⟩ : ∃ ifp, int_fract_pair.stream v (n + 1) = some ifp ∧ _, from int_fract_pair.exists_succ_nth_stream_of_gcf_of_nth_eq_some nth_s_eq, have : gp = ⟨1, ifp.b⟩, by { have : (of v).s.nth n = some ⟨1, ifp.b⟩, from nth_of_eq_some_of_succ_nth_int_fract_pair_stream ...
lemma
generalized_continued_fraction.of_part_num_eq_one_and_exists_int_part_denom_eq
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/approximations.lean
[ "algebra.continued_fractions.computation.correctness_terminating", "data.nat.fib", "tactic.solve_by_elim" ]
[ "generalized_continued_fraction.pair" ]
Shows that the partial numerators `aᵢ` of the continued fraction are equal to one and the partial denominators `bᵢ` correspond to integers.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
of_part_num_eq_one {a : K} (nth_part_num_eq : (of v).partial_numerators.nth n = some a) : a = 1
begin obtain ⟨gp, nth_s_eq, gp_a_eq_a_n⟩ : ∃ gp, (of v).s.nth n = some gp ∧ gp.a = a, from exists_s_a_of_part_num nth_part_num_eq, have : gp.a = 1, from (of_part_num_eq_one_and_exists_int_part_denom_eq nth_s_eq).left, rwa gp_a_eq_a_n at this end
lemma
generalized_continued_fraction.of_part_num_eq_one
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/approximations.lean
[ "algebra.continued_fractions.computation.correctness_terminating", "data.nat.fib", "tactic.solve_by_elim" ]
[]
Shows that the partial numerators `aᵢ` are equal to one.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
exists_int_eq_of_part_denom {b : K} (nth_part_denom_eq : (of v).partial_denominators.nth n = some b) : ∃ (z : ℤ), b = (z : K)
begin obtain ⟨gp, nth_s_eq, gp_b_eq_b_n⟩ : ∃ gp, (of v).s.nth n = some gp ∧ gp.b = b, from exists_s_b_of_part_denom nth_part_denom_eq, have : ∃ (z : ℤ), gp.b = (z : K), from (of_part_num_eq_one_and_exists_int_part_denom_eq nth_s_eq).right, rwa gp_b_eq_b_n at this end
lemma
generalized_continued_fraction.exists_int_eq_of_part_denom
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/approximations.lean
[ "algebra.continued_fractions.computation.correctness_terminating", "data.nat.fib", "tactic.solve_by_elim" ]
[]
Shows that the partial denominators `bᵢ` correspond to an integer.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
fib_le_of_continuants_aux_b : (n ≤ 1 ∨ ¬(of v).terminated_at (n - 2)) → (fib n : K) ≤ ((of v).continuants_aux n).b
nat.strong_induction_on n begin clear n, assume n IH hyp, rcases n with _|_|n, { simp [fib_add_two, continuants_aux] }, -- case n = 0 { simp [fib_add_two, continuants_aux] }, -- case n = 1 { let g := of v, -- case 2 ≤ n have : ¬(n + 2 ≤ 1), by linarith, have not_terminated_at_n : ¬g.terminated_at n...
lemma
generalized_continued_fraction.fib_le_of_continuants_aux_b
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/approximations.lean
[ "algebra.continued_fractions.computation.correctness_terminating", "data.nat.fib", "tactic.solve_by_elim" ]
[ "one_mul", "zero_le_one" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
succ_nth_fib_le_of_nth_denom (hyp: n = 0 ∨ ¬(of v).terminated_at (n - 1)) : (fib (n + 1) : K) ≤ (of v).denominators n
begin rw [denom_eq_conts_b, nth_cont_eq_succ_nth_cont_aux], have : (n + 1) ≤ 1 ∨ ¬(of v).terminated_at (n - 1), by { cases n, case nat.zero : { exact (or.inl $ le_refl 1) }, case nat.succ : { exact or.inr (or.resolve_left hyp n.succ_ne_zero) } }, exact (fib_le_of_continuants_aux_b this) end
lemma
generalized_continued_fraction.succ_nth_fib_le_of_nth_denom
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/approximations.lean
[ "algebra.continued_fractions.computation.correctness_terminating", "data.nat.fib", "tactic.solve_by_elim" ]
[]
Shows that the `n`th denominator is greater than or equal to the `n + 1`th fibonacci number, that is `nat.fib (n + 1) ≤ Bₙ`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
zero_le_of_continuants_aux_b : 0 ≤ ((of v).continuants_aux n).b
begin let g := of v, induction n with n IH, case nat.zero: { refl }, case nat.succ: { cases (decidable.em $ g.terminated_at (n - 1)) with terminated not_terminated, { cases n, -- terminating case { simp [zero_le_one] }, { have : g.continuants_aux (n + 2) = g.continuants_aux (n + 1), from ...
lemma
generalized_continued_fraction.zero_le_of_continuants_aux_b
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/approximations.lean
[ "algebra.continued_fractions.computation.correctness_terminating", "data.nat.fib", "tactic.solve_by_elim" ]
[ "zero_le_one" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
zero_le_of_denom : 0 ≤ (of v).denominators n
by { rw [denom_eq_conts_b, nth_cont_eq_succ_nth_cont_aux], exact zero_le_of_continuants_aux_b }
lemma
generalized_continued_fraction.zero_le_of_denom
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/approximations.lean
[ "algebra.continued_fractions.computation.correctness_terminating", "data.nat.fib", "tactic.solve_by_elim" ]
[]
Shows that all denominators are nonnegative.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
le_of_succ_succ_nth_continuants_aux_b {b : K} (nth_part_denom_eq : (of v).partial_denominators.nth n = some b) : b * ((of v).continuants_aux $ n + 1).b ≤ ((of v).continuants_aux $ n + 2).b
begin obtain ⟨gp_n, nth_s_eq, rfl⟩ : ∃ gp_n, (of v).s.nth n = some gp_n ∧ gp_n.b = b, from exists_s_b_of_part_denom nth_part_denom_eq, simp [of_part_num_eq_one (part_num_eq_s_a nth_s_eq), zero_le_of_continuants_aux_b, generalized_continued_fraction.continuants_aux_recurrence nth_s_eq rfl rfl] end
lemma
generalized_continued_fraction.le_of_succ_succ_nth_continuants_aux_b
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/approximations.lean
[ "algebra.continued_fractions.computation.correctness_terminating", "data.nat.fib", "tactic.solve_by_elim" ]
[ "generalized_continued_fraction.continuants_aux_recurrence" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
le_of_succ_nth_denom {b : K} (nth_part_denom_eq : (of v).partial_denominators.nth n = some b) : b * (of v).denominators n ≤ (of v).denominators (n + 1)
begin rw [denom_eq_conts_b, nth_cont_eq_succ_nth_cont_aux], exact (le_of_succ_succ_nth_continuants_aux_b nth_part_denom_eq) end
theorem
generalized_continued_fraction.le_of_succ_nth_denom
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/approximations.lean
[ "algebra.continued_fractions.computation.correctness_terminating", "data.nat.fib", "tactic.solve_by_elim" ]
[]
Shows that `bₙ * Bₙ ≤ Bₙ₊₁`, where `bₙ` is the `n`th partial denominator and `Bₙ₊₁` and `Bₙ` are the `n + 1`th and `n`th denominator of the continued fraction.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
of_denom_mono : (of v).denominators n ≤ (of v).denominators (n + 1)
begin let g := of v, cases (decidable.em $ g.partial_denominators.terminated_at n) with terminated not_terminated, { have : g.partial_denominators.nth n = none, by rwa stream.seq.terminated_at at terminated, have : g.terminated_at n, from terminated_at_iff_part_denom_none.elim_right (by rwa stream.seq.t...
theorem
generalized_continued_fraction.of_denom_mono
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/approximations.lean
[ "algebra.continued_fractions.computation.correctness_terminating", "data.nat.fib", "tactic.solve_by_elim" ]
[ "mul_le_mul_of_nonneg_right", "stream.seq.terminated_at" ]
Shows that the sequence of denominators is monotone, that is `Bₙ ≤ Bₙ₊₁`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
determinant_aux (hyp: n = 0 ∨ ¬(of v).terminated_at (n - 1)) : ((of v).continuants_aux n).a * ((of v).continuants_aux (n + 1)).b - ((of v).continuants_aux n).b * ((of v).continuants_aux (n + 1)).a = (-1)^n
begin induction n with n IH, case nat.zero { simp [continuants_aux] }, case nat.succ { -- set up some shorthand notation let g := of v, let conts := continuants_aux g (n + 2), set pred_conts := continuants_aux g (n + 1) with pred_conts_eq, set ppred_conts := continuants_aux g n with ppred_conts_...
lemma
generalized_continued_fraction.determinant_aux
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/approximations.lean
[ "algebra.continued_fractions.computation.correctness_terminating", "data.nat.fib", "tactic.solve_by_elim" ]
[ "pow_succ", "ring" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
determinant (not_terminated_at_n : ¬(of v).terminated_at n) : (of v).numerators n * (of v).denominators (n + 1) - (of v).denominators n * (of v).numerators (n + 1) = (-1)^(n + 1)
(determinant_aux $ or.inr $ not_terminated_at_n)
lemma
generalized_continued_fraction.determinant
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/approximations.lean
[ "algebra.continued_fractions.computation.correctness_terminating", "data.nat.fib", "tactic.solve_by_elim" ]
[]
The determinant formula `Aₙ * Bₙ₊₁ - Bₙ * Aₙ₊₁ = (-1)^(n + 1)`
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
sub_convergents_eq {ifp : int_fract_pair K} (stream_nth_eq : int_fract_pair.stream v n = some ifp) : let g
of v in let B := (g.continuants_aux (n + 1)).b in let pB := (g.continuants_aux n).b in v - g.convergents n = if ifp.fr = 0 then 0 else (-1)^n / (B * (ifp.fr⁻¹ * B + pB)) := begin -- set up some shorthand notation let g := of v, let conts := g.continuants_aux (n + 1), let pred_conts := g.continuants_aux n,...
lemma
generalized_continued_fraction.sub_convergents_eq
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/approximations.lean
[ "algebra.continued_fractions.computation.correctness_terminating", "data.nat.fib", "tactic.solve_by_elim" ]
[ "div_sub_div", "generalized_continued_fraction.comp_exact_value", "inv_pos", "ring", "zero_lt_one" ]
This lemma follows from the finite correctness proof, the determinant equality, and by simplifying the difference.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
abs_sub_convergents_le (not_terminated_at_n : ¬(of v).terminated_at n) :
|v - (of v).convergents n| ≤ 1 / (((of v).denominators n) * ((of v).denominators $ n + 1)) := begin -- shorthand notation let g := of v, let nextConts := g.continuants_aux (n + 2), set conts := continuants_aux g (n + 1) with conts_eq, set pred_conts := continuants_aux g n with pred_conts_eq, -- change the...
theorem
generalized_continued_fraction.abs_sub_convergents_le
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/approximations.lean
[ "algebra.continued_fractions.computation.correctness_terminating", "data.nat.fib", "tactic.solve_by_elim" ]
[ "abs_div", "abs_neg_one_pow", "abs_of_pos", "div_le_div_of_le_left", "mul_le_mul_left", "zero_le_one" ]
Shows that `|v - Aₙ / Bₙ| ≤ 1 / (Bₙ * Bₙ₊₁)`
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
abs_sub_convergents_le' {b : K} (nth_part_denom_eq : (of v).partial_denominators.nth n = some b) :
|v - (of v).convergents n| ≤ 1 / (b * ((of v).denominators n) * ((of v).denominators n)) := begin have not_terminated_at_n : ¬(of v).terminated_at n, by simp [terminated_at_iff_part_denom_none, nth_part_denom_eq], refine (abs_sub_convergents_le not_terminated_at_n).trans _, -- One can show that `0 < (generali...
lemma
generalized_continued_fraction.abs_sub_convergents_le'
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/approximations.lean
[ "algebra.continued_fractions.computation.correctness_terminating", "data.nat.fib", "tactic.solve_by_elim" ]
[ "div_zero", "generalized_continued_fraction.of", "mul_comm", "mul_le_mul_of_nonneg_right", "mul_zero", "one_div_le_one_div_of_le", "zero_mul" ]
Shows that `|v - Aₙ / Bₙ| ≤ 1 / (bₙ * Bₙ * Bₙ)`. This bound is worse than the one shown in `gcf.abs_sub_convergents_le`, but sometimes it is easier to apply and sufficient for one's use case.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
generalized_continued_fraction.of_is_simple_continued_fraction : (of v).is_simple_continued_fraction
(λ _ _ nth_part_num_eq, of_part_num_eq_one nth_part_num_eq)
lemma
generalized_continued_fraction.of_is_simple_continued_fraction
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/approximation_corollaries.lean
[ "algebra.continued_fractions.computation.approximations", "algebra.continued_fractions.convergents_equiv", "algebra.order.archimedean", "algebra.algebra.basic", "topology.order.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
simple_continued_fraction.of : simple_continued_fraction K
⟨of v, generalized_continued_fraction.of_is_simple_continued_fraction v⟩
def
simple_continued_fraction.of
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/approximation_corollaries.lean
[ "algebra.continued_fractions.computation.approximations", "algebra.continued_fractions.convergents_equiv", "algebra.order.archimedean", "algebra.algebra.basic", "topology.order.basic" ]
[ "generalized_continued_fraction.of_is_simple_continued_fraction", "simple_continued_fraction" ]
Creates the simple continued fraction of a value.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
simple_continued_fraction.of_is_continued_fraction : (simple_continued_fraction.of v).is_continued_fraction
(λ _ denom nth_part_denom_eq, lt_of_lt_of_le zero_lt_one (of_one_le_nth_part_denom nth_part_denom_eq))
lemma
simple_continued_fraction.of_is_continued_fraction
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/approximation_corollaries.lean
[ "algebra.continued_fractions.computation.approximations", "algebra.continued_fractions.convergents_equiv", "algebra.order.archimedean", "algebra.algebra.basic", "topology.order.basic" ]
[ "simple_continued_fraction.of", "zero_lt_one" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
continued_fraction.of : continued_fraction K
⟨simple_continued_fraction.of v, simple_continued_fraction.of_is_continued_fraction v⟩
def
continued_fraction.of
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/approximation_corollaries.lean
[ "algebra.continued_fractions.computation.approximations", "algebra.continued_fractions.convergents_equiv", "algebra.order.archimedean", "algebra.algebra.basic", "topology.order.basic" ]
[ "continued_fraction", "simple_continued_fraction.of_is_continued_fraction" ]
Creates the continued fraction of a value.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
of_convergents_eq_convergents' : (of v).convergents = (of v).convergents'
@continued_fraction.convergents_eq_convergents' _ _ (continued_fraction.of v)
lemma
generalized_continued_fraction.of_convergents_eq_convergents'
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/approximation_corollaries.lean
[ "algebra.continued_fractions.computation.approximations", "algebra.continued_fractions.convergents_equiv", "algebra.order.archimedean", "algebra.algebra.basic", "topology.order.basic" ]
[ "continued_fraction.convergents_eq_convergents'", "continued_fraction.of" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
convergents_succ (n : ℕ) : (of v).convergents (n + 1) = ⌊v⌋ + 1 / (of (int.fract v)⁻¹).convergents n
by rw [of_convergents_eq_convergents', convergents'_succ, of_convergents_eq_convergents']
lemma
generalized_continued_fraction.convergents_succ
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/approximation_corollaries.lean
[ "algebra.continued_fractions.computation.approximations", "algebra.continued_fractions.convergents_equiv", "algebra.order.archimedean", "algebra.algebra.basic", "topology.order.basic" ]
[ "int.fract" ]
The recurrence relation for the `convergents` of the continued fraction expansion of an element `v` of `K` in terms of the convergents of the inverse of its fractional part.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
of_convergence_epsilon : ∀ (ε > (0 : K)), ∃ (N : ℕ), ∀ (n ≥ N), |v - (of v).convergents n| < ε
begin assume ε ε_pos, -- use the archimedean property to obtian a suitable N rcases (exists_nat_gt (1 / ε) : ∃ (N' : ℕ), 1 / ε < N') with ⟨N', one_div_ε_lt_N'⟩, let N := max N' 5, -- set minimum to 5 to have N ≤ fib N work existsi N, assume n n_ge_N, let g := of v, cases decidable.em (g.terminated_at n)...
theorem
generalized_continued_fraction.of_convergence_epsilon
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/approximation_corollaries.lean
[ "algebra.continued_fractions.computation.approximations", "algebra.continued_fractions.convergents_equiv", "algebra.order.archimedean", "algebra.algebra.basic", "topology.order.basic" ]
[ "div_lt_iff", "div_lt_iff'", "exists_nat_gt", "le_mul_self", "mul_le_mul", "mul_le_mul_left", "mul_le_mul_of_nonneg_left" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
of_convergence [order_topology K] : filter.tendsto ((of v).convergents) filter.at_top $ nhds v
by simpa [linear_ordered_add_comm_group.tendsto_nhds, abs_sub_comm] using (of_convergence_epsilon v)
theorem
generalized_continued_fraction.of_convergence
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/approximation_corollaries.lean
[ "algebra.continued_fractions.computation.approximations", "algebra.continued_fractions.convergents_equiv", "algebra.order.archimedean", "algebra.algebra.basic", "topology.order.basic" ]
[ "abs_sub_comm", "filter.at_top", "filter.tendsto", "linear_ordered_add_comm_group.tendsto_nhds", "nhds", "order_topology" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
int_fract_pair
(b : ℤ) (fr : K)
structure
generalized_continued_fraction.int_fract_pair
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/basic.lean
[ "algebra.order.floor", "algebra.continued_fractions.basic" ]
[]
We collect an integer part `b = ⌊v⌋` and fractional part `fr = v - ⌊v⌋` of a value `v` in a pair `⟨b, fr⟩`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
inhabited [inhabited K] : inhabited (int_fract_pair K)
⟨⟨0, default⟩⟩
instance
generalized_continued_fraction.int_fract_pair.inhabited
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/basic.lean
[ "algebra.order.floor", "algebra.continued_fractions.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mapFr {β : Type*} (f : K → β) (gp : int_fract_pair K) : int_fract_pair β
⟨gp.b, f gp.fr⟩
def
generalized_continued_fraction.int_fract_pair.mapFr
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/basic.lean
[ "algebra.order.floor", "algebra.continued_fractions.basic" ]
[]
Maps a function `f` on the fractional components of a given pair.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
has_coe_to_int_fract_pair : has_coe (int_fract_pair K) (int_fract_pair β)
⟨mapFr coe⟩
instance
generalized_continued_fraction.int_fract_pair.has_coe_to_int_fract_pair
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/basic.lean
[ "algebra.order.floor", "algebra.continued_fractions.basic" ]
[]
Coerce a pair by coercing the fractional component.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
coe_to_int_fract_pair {b : ℤ} {fr : K} : (↑(int_fract_pair.mk b fr) : int_fract_pair β) = int_fract_pair.mk b (↑fr : β)
rfl
lemma
generalized_continued_fraction.int_fract_pair.coe_to_int_fract_pair
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/basic.lean
[ "algebra.order.floor", "algebra.continued_fractions.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
of (v : K) : int_fract_pair K
⟨⌊v⌋, int.fract v⟩
def
generalized_continued_fraction.int_fract_pair.of
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/basic.lean
[ "algebra.order.floor", "algebra.continued_fractions.basic" ]
[ "int.fract" ]
Creates the integer and fractional part of a value `v`, i.e. `⟨⌊v⌋, v - ⌊v⌋⟩`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
stream (v : K) : stream $ option (int_fract_pair K)
| 0 := some (int_fract_pair.of v) | (n + 1) := (stream n).bind $ λ ap_n, if ap_n.fr = 0 then none else some (int_fract_pair.of ap_n.fr⁻¹)
def
generalized_continued_fraction.int_fract_pair.stream
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/basic.lean
[ "algebra.order.floor", "algebra.continued_fractions.basic" ]
[ "stream" ]
Creates the stream of integer and fractional parts of a value `v` needed to obtain the continued fraction representation of `v` in `generalized_continued_fraction.of`. More precisely, given a value `v : K`, it recursively computes a stream of option `ℤ × K` pairs as follows: - `stream v 0 = some ⟨⌊v⌋, v - ⌊v⌋⟩` - `stre...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
stream_is_seq (v : K) : (int_fract_pair.stream v).is_seq
by { assume _ hyp, simp [int_fract_pair.stream, hyp] }
lemma
generalized_continued_fraction.int_fract_pair.stream_is_seq
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/basic.lean
[ "algebra.order.floor", "algebra.continued_fractions.basic" ]
[]
Shows that `int_fract_pair.stream` has the sequence property, that is once we return `none` at position `n`, we also return `none` at `n + 1`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
seq1 (v : K) : stream.seq1 $ int_fract_pair K
⟨ int_fract_pair.of v,--the head stream.seq.tail -- take the tail of `int_fract_pair.stream` since the first element is already in -- the head -- create a sequence from `int_fract_pair.stream` ⟨ int_fract_pair.stream v, -- the underlying stream @stream_is_seq _ _ _ v ⟩ ⟩
def
generalized_continued_fraction.int_fract_pair.seq1
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/basic.lean
[ "algebra.order.floor", "algebra.continued_fractions.basic" ]
[ "stream.seq.tail", "stream.seq1" ]
Uses `int_fract_pair.stream` to create a sequence with head (i.e. `seq1`) of integer and fractional parts of a value `v`. The first value of `int_fract_pair.stream` is never `none`, so we can safely extract it and put the tail of the stream in the sequence part. This is just an intermediate representation and users sh...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
of [linear_ordered_field K] [floor_ring K] (v : K) : generalized_continued_fraction K
let ⟨h, s⟩ := int_fract_pair.seq1 v in -- get the sequence of integer and fractional parts. ⟨ h.b, -- the head is just the first integer part s.map (λ p, ⟨1, p.b⟩) ⟩
def
generalized_continued_fraction.of
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/basic.lean
[ "algebra.order.floor", "algebra.continued_fractions.basic" ]
[ "floor_ring", "generalized_continued_fraction", "linear_ordered_field" ]
Returns the `generalized_continued_fraction` of a value. In fact, the returned gcf is also a `continued_fraction` that terminates if and only if `v` is rational (those proofs will be added in a future commit). The continued fraction representation of `v` is given by `[⌊v⌋; b₀, b₁, b₂,...]`, where `[b₀; b₁, b₂,...]` re...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
comp_exact_value (pconts conts : pair K) (fr : K) : K
-- if the fractional part is zero, we exactly approximated the value by the last continuants if fr = 0 then conts.a / conts.b -- otherwise, we have to include the fractional part in a final continuants step. else let exact_conts := next_continuants 1 fr⁻¹ pconts conts in exact_conts.a / exact_conts.b
def
generalized_continued_fraction.comp_exact_value
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/correctness_terminating.lean
[ "algebra.continued_fractions.computation.translations", "algebra.continued_fractions.terminated_stable", "algebra.continued_fractions.continuants_recurrence", "order.filter.at_top_bot", "tactic.field_simp" ]
[]
Given two continuants `pconts` and `conts` and a value `fr`, this function returns - `conts.a / conts.b` if `fr = 0` - `exact_conts.a / exact_conts.b` where `exact_conts = next_continuants 1 fr⁻¹ pconts conts` otherwise. This function can be used to compute the exact value approxmated by a continued fraction `genera...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
comp_exact_value_correctness_of_stream_eq_some_aux_comp {a : K} (b c : K) (fract_a_ne_zero : int.fract a ≠ 0) : ((⌊a⌋ : K) * b + c) / (int.fract a) + b = (b * a + c) / int.fract a
by { field_simp [fract_a_ne_zero], rw int.fract, ring }
lemma
generalized_continued_fraction.comp_exact_value_correctness_of_stream_eq_some_aux_comp
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/correctness_terminating.lean
[ "algebra.continued_fractions.computation.translations", "algebra.continued_fractions.terminated_stable", "algebra.continued_fractions.continuants_recurrence", "order.filter.at_top_bot", "tactic.field_simp" ]
[ "int.fract", "ring" ]
Just a computational lemma we need for the next main proof.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
comp_exact_value_correctness_of_stream_eq_some : ∀ {ifp_n : int_fract_pair K}, int_fract_pair.stream v n = some ifp_n → v = comp_exact_value ((of v).continuants_aux n) ((of v).continuants_aux $ n + 1) ifp_n.fr
begin let g := of v, induction n with n IH, { assume ifp_zero stream_zero_eq, -- nat.zero have : int_fract_pair.of v = ifp_zero, by { have : int_fract_pair.stream v 0 = some (int_fract_pair.of v), from rfl, simpa only [this] using stream_zero_eq }, cases this, cases decidable.em (int.fract v...
lemma
generalized_continued_fraction.comp_exact_value_correctness_of_stream_eq_some
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/correctness_terminating.lean
[ "algebra.continued_fractions.computation.translations", "algebra.continued_fractions.terminated_stable", "algebra.continued_fractions.continuants_recurrence", "order.filter.at_top_bot", "tactic.field_simp" ]
[ "int.fract", "int.fract_add_floor", "inv_eq_one_div" ]
Shows the correctness of `comp_exact_value` in case the continued fraction `generalized_continued_fraction.of v` did not terminate at position `n`. That is, we obtain the value `v` if we pass the two successive (auxiliary) continuants at positions `n` and `n + 1` as well as the fractional part at `int_fract_pair.stream...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
of_correctness_of_nth_stream_eq_none (nth_stream_eq_none : int_fract_pair.stream v n = none) : v = (of v).convergents (n - 1)
begin induction n with n IH, case nat.zero { contradiction }, -- int_fract_pair.stream v 0 ≠ none case nat.succ { rename nth_stream_eq_none succ_nth_stream_eq_none, let g := of v, change v = g.convergents n, have : int_fract_pair.stream v n = none ∨ ∃ ifp, int_fract_pair.stream v n = some ifp ...
lemma
generalized_continued_fraction.of_correctness_of_nth_stream_eq_none
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/correctness_terminating.lean
[ "algebra.continued_fractions.computation.translations", "algebra.continued_fractions.terminated_stable", "algebra.continued_fractions.continuants_recurrence", "order.filter.at_top_bot", "tactic.field_simp" ]
[]
The convergent of `generalized_continued_fraction.of v` at step `n - 1` is exactly `v` if the `int_fract_pair.stream` of the corresponding continued fraction terminated at step `n`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
of_correctness_of_terminated_at (terminated_at_n : (of v).terminated_at n) : v = (of v).convergents n
have int_fract_pair.stream v (n + 1) = none, from of_terminated_at_n_iff_succ_nth_int_fract_pair_stream_eq_none.elim_left terminated_at_n, of_correctness_of_nth_stream_eq_none this
theorem
generalized_continued_fraction.of_correctness_of_terminated_at
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/correctness_terminating.lean
[ "algebra.continued_fractions.computation.translations", "algebra.continued_fractions.terminated_stable", "algebra.continued_fractions.continuants_recurrence", "order.filter.at_top_bot", "tactic.field_simp" ]
[]
If `generalized_continued_fraction.of v` terminated at step `n`, then the `n`th convergent is exactly `v`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
of_correctness_of_terminates (terminates : (of v).terminates) : ∃ (n : ℕ), v = (of v).convergents n
exists.elim terminates ( assume n terminated_at_n, exists.intro n (of_correctness_of_terminated_at terminated_at_n) )
lemma
generalized_continued_fraction.of_correctness_of_terminates
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/correctness_terminating.lean
[ "algebra.continued_fractions.computation.translations", "algebra.continued_fractions.terminated_stable", "algebra.continued_fractions.continuants_recurrence", "order.filter.at_top_bot", "tactic.field_simp" ]
[]
If `generalized_continued_fraction.of v` terminates, then there is `n : ℕ` such that the `n`th convergent is exactly `v`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
of_correctness_at_top_of_terminates (terminates : (of v).terminates) : ∀ᶠ n in at_top, v = (of v).convergents n
begin rw eventually_at_top, obtain ⟨n, terminated_at_n⟩ : ∃ n, (of v).terminated_at n, from terminates, use n, assume m m_geq_n, rw (convergents_stable_of_terminated m_geq_n terminated_at_n), exact of_correctness_of_terminated_at terminated_at_n end
lemma
generalized_continued_fraction.of_correctness_at_top_of_terminates
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/correctness_terminating.lean
[ "algebra.continued_fractions.computation.translations", "algebra.continued_fractions.terminated_stable", "algebra.continued_fractions.continuants_recurrence", "order.filter.at_top_bot", "tactic.field_simp" ]
[]
If `generalized_continued_fraction.of v` terminates, then its convergents will eventually always be `v`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
exists_gcf_pair_rat_eq_of_nth_conts_aux : ∃ (conts : pair ℚ), (of v).continuants_aux n = (conts.map coe : pair K)
nat.strong_induction_on n begin clear n, let g := of v, assume n IH, rcases n with _|_|n, -- n = 0 { suffices : ∃ (gp : pair ℚ), pair.mk (1 : K) 0 = gp.map coe, by simpa [continuants_aux], use (pair.mk 1 0), simp }, -- n = 1 { suffices : ∃ (conts : pair ℚ), pair.mk g.h 1 = conts.map coe, by ...
lemma
generalized_continued_fraction.exists_gcf_pair_rat_eq_of_nth_conts_aux
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/terminates_iff_rat.lean
[ "algebra.continued_fractions.computation.approximations", "algebra.continued_fractions.computation.correctness_terminating", "data.rat.floor" ]
[ "lt_add_one" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
exists_gcf_pair_rat_eq_nth_conts : ∃ (conts : pair ℚ), (of v).continuants n = (conts.map coe : pair K)
by { rw [nth_cont_eq_succ_nth_cont_aux], exact (exists_gcf_pair_rat_eq_of_nth_conts_aux v $ n + 1) }
lemma
generalized_continued_fraction.exists_gcf_pair_rat_eq_nth_conts
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/terminates_iff_rat.lean
[ "algebra.continued_fractions.computation.approximations", "algebra.continued_fractions.computation.correctness_terminating", "data.rat.floor" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
exists_rat_eq_nth_numerator : ∃ (q : ℚ), (of v).numerators n = (q : K)
begin rcases (exists_gcf_pair_rat_eq_nth_conts v n) with ⟨⟨a, _⟩, nth_cont_eq⟩, use a, simp [num_eq_conts_a, nth_cont_eq], end
lemma
generalized_continued_fraction.exists_rat_eq_nth_numerator
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/terminates_iff_rat.lean
[ "algebra.continued_fractions.computation.approximations", "algebra.continued_fractions.computation.correctness_terminating", "data.rat.floor" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
exists_rat_eq_nth_denominator : ∃ (q : ℚ), (of v).denominators n = (q : K)
begin rcases (exists_gcf_pair_rat_eq_nth_conts v n) with ⟨⟨_, b⟩, nth_cont_eq⟩, use b, simp [denom_eq_conts_b, nth_cont_eq] end
lemma
generalized_continued_fraction.exists_rat_eq_nth_denominator
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/terminates_iff_rat.lean
[ "algebra.continued_fractions.computation.approximations", "algebra.continued_fractions.computation.correctness_terminating", "data.rat.floor" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
exists_rat_eq_nth_convergent : ∃ (q : ℚ), (of v).convergents n = (q : K)
begin rcases (exists_rat_eq_nth_numerator v n) with ⟨Aₙ, nth_num_eq⟩, rcases (exists_rat_eq_nth_denominator v n) with ⟨Bₙ, nth_denom_eq⟩, use (Aₙ / Bₙ), simp [nth_num_eq, nth_denom_eq, convergent_eq_num_div_denom] end
lemma
generalized_continued_fraction.exists_rat_eq_nth_convergent
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/terminates_iff_rat.lean
[ "algebra.continued_fractions.computation.approximations", "algebra.continued_fractions.computation.correctness_terminating", "data.rat.floor" ]
[]
Every finite convergent corresponds to a rational number.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
exists_rat_eq_of_terminates (terminates : (of v).terminates) : ∃ (q : ℚ), v = ↑q
begin obtain ⟨n, v_eq_conv⟩ : ∃ n, v = (of v).convergents n, from of_correctness_of_terminates terminates, obtain ⟨q, conv_eq_q⟩ : ∃ (q : ℚ), (of v).convergents n = (↑q : K), from exists_rat_eq_nth_convergent v n, have : v = (↑q : K), from eq.trans v_eq_conv conv_eq_q, use [q, this] end
theorem
generalized_continued_fraction.exists_rat_eq_of_terminates
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/terminates_iff_rat.lean
[ "algebra.continued_fractions.computation.approximations", "algebra.continued_fractions.computation.correctness_terminating", "data.rat.floor" ]
[]
Every terminating continued fraction corresponds to a rational number.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
coe_of_rat_eq : ((int_fract_pair.of q).mapFr coe : int_fract_pair K) = int_fract_pair.of v
by simp [int_fract_pair.of, v_eq_q]
lemma
generalized_continued_fraction.int_fract_pair.coe_of_rat_eq
algebra.continued_fractions.computation
src/algebra/continued_fractions/computation/terminates_iff_rat.lean
[ "algebra.continued_fractions.computation.approximations", "algebra.continued_fractions.computation.correctness_terminating", "data.rat.floor" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83