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
add_mul_self (x y : R) : (x + y) * (x + y) = x * x + y * y
by rw [←pow_two, ←pow_two, ←pow_two, add_sq]
lemma
char_two.add_mul_self
algebra.char_p
src/algebra/char_p/two.lean
[ "algebra.char_p.basic" ]
[ "add_sq" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
list_sum_sq (l : list R) : l.sum ^ 2 = (l.map (^ 2)).sum
list_sum_pow_char _ _
lemma
char_two.list_sum_sq
algebra.char_p
src/algebra/char_p/two.lean
[ "algebra.char_p.basic" ]
[ "list_sum_pow_char" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
list_sum_mul_self (l : list R) : l.sum * l.sum = (list.map (λ x, x * x) l).sum
by simp_rw [←pow_two, list_sum_sq]
lemma
char_two.list_sum_mul_self
algebra.char_p
src/algebra/char_p/two.lean
[ "algebra.char_p.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
multiset_sum_sq (l : multiset R) : l.sum ^ 2 = (l.map (^ 2)).sum
multiset_sum_pow_char _ _
lemma
char_two.multiset_sum_sq
algebra.char_p
src/algebra/char_p/two.lean
[ "algebra.char_p.basic" ]
[ "multiset", "multiset_sum_pow_char" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
multiset_sum_mul_self (l : multiset R) : l.sum * l.sum = (multiset.map (λ x, x * x) l).sum
by simp_rw [←pow_two, multiset_sum_sq]
lemma
char_two.multiset_sum_mul_self
algebra.char_p
src/algebra/char_p/two.lean
[ "algebra.char_p.basic" ]
[ "multiset", "multiset.map" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
sum_sq (s : finset ι) (f : ι → R) : (∑ i in s, f i) ^ 2 = ∑ i in s, f i ^ 2
sum_pow_char _ _ _
lemma
char_two.sum_sq
algebra.char_p
src/algebra/char_p/two.lean
[ "algebra.char_p.basic" ]
[ "finset", "sum_pow_char" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
sum_mul_self (s : finset ι) (f : ι → R) : (∑ i in s, f i) * (∑ i in s, f i) = ∑ i in s, f i * f i
by simp_rw [←pow_two, sum_sq]
lemma
char_two.sum_mul_self
algebra.char_p
src/algebra/char_p/two.lean
[ "algebra.char_p.basic" ]
[ "finset" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
neg_one_eq_one_iff [nontrivial R]: (-1 : R) = 1 ↔ ring_char R = 2
begin refine ⟨λ h, _, λ h, @@char_two.neg_eq _ (ring_char.of_eq h) 1⟩, rw [eq_comm, ←sub_eq_zero, sub_neg_eq_add, ← nat.cast_one, ← nat.cast_add] at h, exact ((nat.dvd_prime nat.prime_two).mp (ring_char.dvd h)).resolve_left char_p.ring_char_ne_one end
lemma
neg_one_eq_one_iff
algebra.char_p
src/algebra/char_p/two.lean
[ "algebra.char_p.basic" ]
[ "char_p.ring_char_ne_one", "char_two.neg_eq", "nat.cast_add", "nat.cast_one", "nat.dvd_prime", "nat.prime_two", "nontrivial", "ring_char", "ring_char.dvd", "ring_char.of_eq" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
order_of_neg_one [nontrivial R] : order_of (-1 : R) = if ring_char R = 2 then 1 else 2
begin split_ifs, { rw [neg_one_eq_one_iff.2 h, order_of_one] }, apply order_of_eq_prime, { simp }, simpa [neg_one_eq_one_iff] using h end
lemma
order_of_neg_one
algebra.char_p
src/algebra/char_p/two.lean
[ "algebra.char_p.basic" ]
[ "neg_one_eq_one_iff", "nontrivial", "order_of", "order_of_eq_prime", "order_of_one", "ring_char" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
char_zero (R : Type*) [add_monoid_with_one R] : Prop
(cast_injective : function.injective (coe : ℕ → R))
class
char_zero
algebra.char_zero
src/algebra/char_zero/defs.lean
[ "data.int.cast.defs" ]
[ "add_monoid_with_one" ]
Typeclass for monoids with characteristic zero. (This is usually stated on fields but it makes sense for any additive monoid with 1.) *Warning*: for a semiring `R`, `char_zero R` and `char_p R 0` need not coincide. * `char_zero R` requires an injection `ℕ ↪ R`; * `char_p R 0` asks that only `0 : ℕ` maps to `0 : R` u...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
char_zero_of_inj_zero {R : Type*} [add_group_with_one R] (H : ∀ n:ℕ, (n:R) = 0 → n = 0) : char_zero R
⟨λ m n h, begin induction m with m ih generalizing n, { rw H n, rw [← h, nat.cast_zero] }, cases n with n, { apply H, rw [h, nat.cast_zero], }, simp_rw [nat.cast_succ, add_right_cancel_iff] at h, rwa ih, end⟩
theorem
char_zero_of_inj_zero
algebra.char_zero
src/algebra/char_zero/defs.lean
[ "data.int.cast.defs" ]
[ "add_group_with_one", "char_zero", "ih", "nat.cast_succ", "nat.cast_zero" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
cast_injective : function.injective (coe : ℕ → R)
char_zero.cast_injective
theorem
nat.cast_injective
algebra.char_zero
src/algebra/char_zero/defs.lean
[ "data.int.cast.defs" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
cast_inj {m n : ℕ} : (m : R) = n ↔ m = n
cast_injective.eq_iff
theorem
nat.cast_inj
algebra.char_zero
src/algebra/char_zero/defs.lean
[ "data.int.cast.defs" ]
[ "cast_inj" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
cast_eq_zero {n : ℕ} : (n : R) = 0 ↔ n = 0
by rw [← cast_zero, cast_inj]
theorem
nat.cast_eq_zero
algebra.char_zero
src/algebra/char_zero/defs.lean
[ "data.int.cast.defs" ]
[ "cast_inj" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
cast_ne_zero {n : ℕ} : (n : R) ≠ 0 ↔ n ≠ 0
not_congr cast_eq_zero
theorem
nat.cast_ne_zero
algebra.char_zero
src/algebra/char_zero/defs.lean
[ "data.int.cast.defs" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
cast_add_one_ne_zero (n : ℕ) : (n + 1 : R) ≠ 0
by exact_mod_cast n.succ_ne_zero
lemma
nat.cast_add_one_ne_zero
algebra.char_zero
src/algebra/char_zero/defs.lean
[ "data.int.cast.defs" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
cast_eq_one {n : ℕ} : (n : R) = 1 ↔ n = 1
by rw [←cast_one, cast_inj]
theorem
nat.cast_eq_one
algebra.char_zero
src/algebra/char_zero/defs.lean
[ "data.int.cast.defs" ]
[ "cast_inj" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
cast_ne_one {n : ℕ} : (n : R) ≠ 1 ↔ n ≠ 1
cast_eq_one.not
theorem
nat.cast_ne_one
algebra.char_zero
src/algebra/char_zero/defs.lean
[ "data.int.cast.defs" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
char_zero {M} {n : ℕ} [ne_zero n] [add_monoid_with_one M] [char_zero M] : ne_zero (n : M)
⟨nat.cast_ne_zero.mpr out⟩
instance
ne_zero.char_zero
algebra.char_zero
src/algebra/char_zero/defs.lean
[ "data.int.cast.defs" ]
[ "add_monoid_with_one", "char_zero", "ne_zero" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
char_zero.infinite : infinite M
infinite.of_injective coe nat.cast_injective
instance
char_zero.infinite
algebra.char_zero
src/algebra/char_zero/infinite.lean
[ "algebra.char_zero.defs", "data.fintype.card" ]
[ "infinite", "infinite.of_injective", "nat.cast_injective" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
cast_embedding : ℕ ↪ R
⟨coe, cast_injective⟩
def
nat.cast_embedding
algebra.char_zero
src/algebra/char_zero/lemmas.lean
[ "data.nat.cast.field", "algebra.group_power.lemmas" ]
[]
`nat.cast` as an embedding into monoids of characteristic `0`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
cast_pow_eq_one {R : Type*} [semiring R] [char_zero R] (q : ℕ) (n : ℕ) (hn : n ≠ 0) : (q : R) ^ n = 1 ↔ q = 1
by { rw [←cast_pow, cast_eq_one], exact pow_eq_one_iff hn }
lemma
nat.cast_pow_eq_one
algebra.char_zero
src/algebra/char_zero/lemmas.lean
[ "data.nat.cast.field", "algebra.group_power.lemmas" ]
[ "char_zero", "pow_eq_one_iff", "semiring" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
cast_div_char_zero {k : Type*} [division_semiring k] [char_zero k] {m n : ℕ} (n_dvd : n ∣ m) : ((m / n : ℕ) : k) = m / n
begin rcases eq_or_ne n 0 with rfl | hn, { simp }, { exact cast_div n_dvd (cast_ne_zero.2 hn), }, end
theorem
nat.cast_div_char_zero
algebra.char_zero
src/algebra/char_zero/lemmas.lean
[ "data.nat.cast.field", "algebra.group_power.lemmas" ]
[ "char_zero", "division_semiring", "eq_or_ne" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
char_zero.ne_zero.two : ne_zero (2 : M)
⟨have ((2:ℕ):M) ≠ 0, from nat.cast_ne_zero.2 dec_trivial, by rwa [nat.cast_two] at this⟩
instance
char_zero.ne_zero.two
algebra.char_zero
src/algebra/char_zero/lemmas.lean
[ "data.nat.cast.field", "algebra.group_power.lemmas" ]
[ "nat.cast_two", "ne_zero" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
add_self_eq_zero {a : R} : a + a = 0 ↔ a = 0
by simp only [(two_mul a).symm, mul_eq_zero, two_ne_zero, false_or]
lemma
add_self_eq_zero
algebra.char_zero
src/algebra/char_zero/lemmas.lean
[ "data.nat.cast.field", "algebra.group_power.lemmas" ]
[ "mul_eq_zero", "two_mul", "two_ne_zero" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
bit0_eq_zero {a : R} : bit0 a = 0 ↔ a = 0
add_self_eq_zero
lemma
bit0_eq_zero
algebra.char_zero
src/algebra/char_zero/lemmas.lean
[ "data.nat.cast.field", "algebra.group_power.lemmas" ]
[ "add_self_eq_zero" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
zero_eq_bit0 {a : R} : 0 = bit0 a ↔ a = 0
by { rw [eq_comm], exact bit0_eq_zero }
lemma
zero_eq_bit0
algebra.char_zero
src/algebra/char_zero/lemmas.lean
[ "data.nat.cast.field", "algebra.group_power.lemmas" ]
[ "bit0_eq_zero" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
bit0_ne_zero : bit0 a ≠ 0 ↔ a ≠ 0
bit0_eq_zero.not
lemma
bit0_ne_zero
algebra.char_zero
src/algebra/char_zero/lemmas.lean
[ "data.nat.cast.field", "algebra.group_power.lemmas" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
zero_ne_bit0 : 0 ≠ bit0 a ↔ a ≠ 0
zero_eq_bit0.not
lemma
zero_ne_bit0
algebra.char_zero
src/algebra/char_zero/lemmas.lean
[ "data.nat.cast.field", "algebra.group_power.lemmas" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
neg_eq_self_iff {a : R} : -a = a ↔ a = 0
neg_eq_iff_add_eq_zero.trans add_self_eq_zero
lemma
neg_eq_self_iff
algebra.char_zero
src/algebra/char_zero/lemmas.lean
[ "data.nat.cast.field", "algebra.group_power.lemmas" ]
[ "add_self_eq_zero" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
eq_neg_self_iff {a : R} : a = -a ↔ a = 0
eq_neg_iff_add_eq_zero.trans add_self_eq_zero
lemma
eq_neg_self_iff
algebra.char_zero
src/algebra/char_zero/lemmas.lean
[ "data.nat.cast.field", "algebra.group_power.lemmas" ]
[ "add_self_eq_zero" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
nat_mul_inj {n : ℕ} {a b : R} (h : (n : R) * a = (n : R) * b) : n = 0 ∨ a = b
begin rw [←sub_eq_zero, ←mul_sub, mul_eq_zero, sub_eq_zero] at h, exact_mod_cast h, end
lemma
nat_mul_inj
algebra.char_zero
src/algebra/char_zero/lemmas.lean
[ "data.nat.cast.field", "algebra.group_power.lemmas" ]
[ "mul_eq_zero" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
nat_mul_inj' {n : ℕ} {a b : R} (h : (n : R) * a = (n : R) * b) (w : n ≠ 0) : a = b
by simpa [w] using nat_mul_inj h
lemma
nat_mul_inj'
algebra.char_zero
src/algebra/char_zero/lemmas.lean
[ "data.nat.cast.field", "algebra.group_power.lemmas" ]
[ "nat_mul_inj" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
bit0_injective : function.injective (bit0 : R → R)
λ a b h, begin dsimp [bit0] at h, simp only [(two_mul a).symm, (two_mul b).symm] at h, refine nat_mul_inj' _ two_ne_zero, exact_mod_cast h, end
lemma
bit0_injective
algebra.char_zero
src/algebra/char_zero/lemmas.lean
[ "data.nat.cast.field", "algebra.group_power.lemmas" ]
[ "nat_mul_inj'", "two_mul", "two_ne_zero" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
bit1_injective : function.injective (bit1 : R → R)
λ a b h, begin simp only [bit1, add_left_inj] at h, exact bit0_injective h, end
lemma
bit1_injective
algebra.char_zero
src/algebra/char_zero/lemmas.lean
[ "data.nat.cast.field", "algebra.group_power.lemmas" ]
[ "bit0_injective" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
bit0_eq_bit0 {a b : R} : bit0 a = bit0 b ↔ a = b
bit0_injective.eq_iff
lemma
bit0_eq_bit0
algebra.char_zero
src/algebra/char_zero/lemmas.lean
[ "data.nat.cast.field", "algebra.group_power.lemmas" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
bit1_eq_bit1 {a b : R} : bit1 a = bit1 b ↔ a = b
bit1_injective.eq_iff
lemma
bit1_eq_bit1
algebra.char_zero
src/algebra/char_zero/lemmas.lean
[ "data.nat.cast.field", "algebra.group_power.lemmas" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
bit1_eq_one {a : R} : bit1 a = 1 ↔ a = 0
by rw [show (1 : R) = bit1 0, by simp, bit1_eq_bit1]
lemma
bit1_eq_one
algebra.char_zero
src/algebra/char_zero/lemmas.lean
[ "data.nat.cast.field", "algebra.group_power.lemmas" ]
[ "bit1_eq_bit1" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
one_eq_bit1 {a : R} : 1 = bit1 a ↔ a = 0
by { rw [eq_comm], exact bit1_eq_one }
lemma
one_eq_bit1
algebra.char_zero
src/algebra/char_zero/lemmas.lean
[ "data.nat.cast.field", "algebra.group_power.lemmas" ]
[ "bit1_eq_one" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
half_add_self (a : R) : (a + a) / 2 = a
by rw [← mul_two, mul_div_cancel a two_ne_zero]
lemma
half_add_self
algebra.char_zero
src/algebra/char_zero/lemmas.lean
[ "data.nat.cast.field", "algebra.group_power.lemmas" ]
[ "mul_div_cancel", "mul_two", "two_ne_zero" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
add_halves' (a : R) : a / 2 + a / 2 = a
by rw [← add_div, half_add_self]
lemma
add_halves'
algebra.char_zero
src/algebra/char_zero/lemmas.lean
[ "data.nat.cast.field", "algebra.group_power.lemmas" ]
[ "add_div", "half_add_self" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
sub_half (a : R) : a - a / 2 = a / 2
by rw [sub_eq_iff_eq_add, add_halves']
lemma
sub_half
algebra.char_zero
src/algebra/char_zero/lemmas.lean
[ "data.nat.cast.field", "algebra.group_power.lemmas" ]
[ "add_halves'" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
half_sub (a : R) : a / 2 - a = - (a / 2)
by rw [← neg_sub, sub_half]
lemma
half_sub
algebra.char_zero
src/algebra/char_zero/lemmas.lean
[ "data.nat.cast.field", "algebra.group_power.lemmas" ]
[ "sub_half" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
ring_hom.char_zero (ϕ : R →+* S) [hS : char_zero S] : char_zero R
⟨λ a b h, char_zero.cast_injective (by rw [←map_nat_cast ϕ, ←map_nat_cast ϕ, h])⟩
lemma
ring_hom.char_zero
algebra.char_zero
src/algebra/char_zero/lemmas.lean
[ "data.nat.cast.field", "algebra.group_power.lemmas" ]
[ "char_zero" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
ring_hom.char_zero_iff {ϕ : R →+* S} (hϕ : function.injective ϕ) : char_zero R ↔ char_zero S
⟨λ hR, ⟨by introsI a b h; rwa [← @nat.cast_inj R, ← hϕ.eq_iff, map_nat_cast ϕ, map_nat_cast ϕ]⟩, λ hS, by exactI ϕ.char_zero⟩
lemma
ring_hom.char_zero_iff
algebra.char_zero
src/algebra/char_zero/lemmas.lean
[ "data.nat.cast.field", "algebra.group_power.lemmas" ]
[ "char_zero", "map_nat_cast", "nat.cast_inj" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
ring_hom.injective_nat (f : ℕ →+* R) [char_zero R] : function.injective f
subsingleton.elim (nat.cast_ring_hom _) f ▸ nat.cast_injective
lemma
ring_hom.injective_nat
algebra.char_zero
src/algebra/char_zero/lemmas.lean
[ "data.nat.cast.field", "algebra.group_power.lemmas" ]
[ "char_zero", "nat.cast_injective", "nat.cast_ring_hom" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
zsmul_mem_zmultiples_iff_exists_sub_div {r : R} {z : ℤ} (hz : z ≠ 0) : z • r ∈ add_subgroup.zmultiples p ↔ ∃ k : fin z.nat_abs, r - (k : ℕ) • (p / z : R) ∈ add_subgroup.zmultiples p
begin rw [add_subgroup.mem_zmultiples_iff], simp_rw [add_subgroup.mem_zmultiples_iff, div_eq_mul_inv, ←smul_mul_assoc, eq_sub_iff_add_eq], have hz' : (z : R) ≠ 0 := int.cast_ne_zero.mpr hz, conv_rhs { simp only [←(mul_right_injective₀ hz').eq_iff] { single_pass := tt}, }, simp_rw [←zsmul_eq_mul, smul_add, ←mu...
lemma
add_subgroup.zsmul_mem_zmultiples_iff_exists_sub_div
algebra.char_zero
src/algebra/char_zero/quotient.lean
[ "group_theory.quotient_group" ]
[ "add_subgroup.zmultiples", "div_eq_mul_inv", "fin.coe_mk", "int.abs_eq_nat_abs", "int.div_add_mod", "int.mod_lt", "int.mod_nonneg", "int.to_nat_of_nonneg", "mul_inv_cancel", "mul_one", "mul_right_injective₀", "smul_add", "smul_smul", "to_nat", "zsmul_eq_mul" ]
`z • r` is a multiple of `p` iff `r` is `pk/z` above a multiple of `p`, where `0 ≤ k < |z|`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
nsmul_mem_zmultiples_iff_exists_sub_div {r : R} {n : ℕ} (hn : n ≠ 0) : n • r ∈ add_subgroup.zmultiples p ↔ ∃ k : fin n, r - (k : ℕ) • (p / n : R) ∈ add_subgroup.zmultiples p
begin simp_rw [←coe_nat_zsmul r, zsmul_mem_zmultiples_iff_exists_sub_div (int.coe_nat_ne_zero.mpr hn), int.cast_coe_nat], refl, end
lemma
add_subgroup.nsmul_mem_zmultiples_iff_exists_sub_div
algebra.char_zero
src/algebra/char_zero/quotient.lean
[ "group_theory.quotient_group" ]
[ "add_subgroup.zmultiples", "int.cast_coe_nat" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
zmultiples_zsmul_eq_zsmul_iff {ψ θ : R ⧸ add_subgroup.zmultiples p} {z : ℤ} (hz : z ≠ 0) : z • ψ = z • θ ↔ (∃ k : fin z.nat_abs, ψ = θ + (k : ℕ) • (p / z : R))
begin induction ψ using quotient.induction_on', induction θ using quotient.induction_on', have : (quotient.mk' : R → R ⧸ add_subgroup.zmultiples p) = coe := rfl, simp only [this], simp_rw [←coe_zsmul, ←coe_nsmul, ←coe_add, quotient_add_group.eq_iff_sub_mem, ←smul_sub, ←sub_sub, add_subgroup.zsmul_mem_zmul...
lemma
quotient_add_group.zmultiples_zsmul_eq_zsmul_iff
algebra.char_zero
src/algebra/char_zero/quotient.lean
[ "group_theory.quotient_group" ]
[ "add_subgroup.zmultiples", "add_subgroup.zsmul_mem_zmultiples_iff_exists_sub_div", "quotient.induction_on'", "quotient.mk'" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
zmultiples_nsmul_eq_nsmul_iff {ψ θ : R ⧸ add_subgroup.zmultiples p} {n : ℕ} (hz : n ≠ 0) : n • ψ = n • θ ↔ (∃ k : fin n, ψ = θ + (k : ℕ) • (p / n : R))
begin simp_rw [←coe_nat_zsmul ψ, ←coe_nat_zsmul θ, zmultiples_zsmul_eq_zsmul_iff (int.coe_nat_ne_zero.mpr hz), int.cast_coe_nat], refl, end
lemma
quotient_add_group.zmultiples_nsmul_eq_nsmul_iff
algebra.char_zero
src/algebra/char_zero/quotient.lean
[ "group_theory.quotient_group" ]
[ "add_subgroup.zmultiples", "int.cast_coe_nat" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
generalized_continued_fraction.pair
(a : α) (b : α)
structure
generalized_continued_fraction.pair
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[]
We collect a partial numerator `aᵢ` and partial denominator `bᵢ` in a pair `⟨aᵢ,bᵢ⟩`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
map {β : Type*} (f : α → β) (gp : pair α) : pair β
⟨f gp.a, f gp.b⟩
def
generalized_continued_fraction.pair.map
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[]
Maps a function `f` on both components of a given pair.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
has_coe_to_generalized_continued_fraction_pair : has_coe (pair α) (pair β)
⟨map coe⟩
instance
generalized_continued_fraction.pair.has_coe_to_generalized_continued_fraction_pair
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[]
Coerce a pair by elementwise coercion.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
coe_to_generalized_continued_fraction_pair {a b : α} : (↑(pair.mk a b) : pair β) = pair.mk (a : β) (b : β)
rfl
lemma
generalized_continued_fraction.pair.coe_to_generalized_continued_fraction_pair
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
generalized_continued_fraction
(h : α) (s : seq $ pair α)
structure
generalized_continued_fraction
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[]
A *generalised continued fraction* (gcf) is a potentially infinite expression of the form $$ h + \dfrac{a_0} {b_0 + \dfrac{a_1} {b_1 + \dfrac{a_2} {b_2 + \dfrac{a_3} {b_3 + \dots}}}} $$ where ...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
of_integer (a : α) : generalized_continued_fraction α
⟨a, seq.nil⟩
def
generalized_continued_fraction.of_integer
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[ "generalized_continued_fraction" ]
Constructs a generalized continued fraction without fractional part.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
partial_numerators (g : generalized_continued_fraction α) : seq α
g.s.map pair.a
def
generalized_continued_fraction.partial_numerators
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[ "generalized_continued_fraction" ]
Returns the sequence of partial numerators `aᵢ` of `g`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
partial_denominators (g : generalized_continued_fraction α) : seq α
g.s.map pair.b
def
generalized_continued_fraction.partial_denominators
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[ "generalized_continued_fraction" ]
Returns the sequence of partial denominators `bᵢ` of `g`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
terminated_at (g : generalized_continued_fraction α) (n : ℕ) : Prop
g.s.terminated_at n
def
generalized_continued_fraction.terminated_at
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[ "generalized_continued_fraction" ]
A gcf terminated at position `n` if its sequence terminates at position `n`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
terminated_at_decidable (g : generalized_continued_fraction α) (n : ℕ) : decidable (g.terminated_at n)
by { unfold terminated_at, apply_instance }
instance
generalized_continued_fraction.terminated_at_decidable
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[ "generalized_continued_fraction" ]
It is decidable whether a gcf terminated at a given position.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
terminates (g : generalized_continued_fraction α) : Prop
g.s.terminates
def
generalized_continued_fraction.terminates
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[ "generalized_continued_fraction" ]
A gcf terminates if its sequence terminates.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
has_coe_to_generalized_continued_fraction : has_coe (generalized_continued_fraction α) (generalized_continued_fraction β)
⟨λ g, ⟨(g.h : β), (g.s.map coe : seq $ pair β)⟩⟩
instance
generalized_continued_fraction.has_coe_to_generalized_continued_fraction
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[ "generalized_continued_fraction" ]
Coerce a gcf by elementwise coercion.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
coe_to_generalized_continued_fraction {g : generalized_continued_fraction α} : (↑(g : generalized_continued_fraction α) : generalized_continued_fraction β) = ⟨(g.h : β), (g.s.map coe : seq $ pair β)⟩
rfl
lemma
generalized_continued_fraction.coe_to_generalized_continued_fraction
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[ "generalized_continued_fraction" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
generalized_continued_fraction.is_simple_continued_fraction (g : generalized_continued_fraction α) [has_one α] : Prop
∀ (n : ℕ) (aₙ : α), g.partial_numerators.nth n = some aₙ → aₙ = 1
def
generalized_continued_fraction.is_simple_continued_fraction
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[ "generalized_continued_fraction" ]
A generalized continued fraction is a *simple continued fraction* if all partial numerators are equal to one. $$ h + \dfrac{1} {b_0 + \dfrac{1} {b_1 + \dfrac{1} {b_2 + \dfrac{1} {b_3 + \dots}}...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
simple_continued_fraction [has_one α]
{g : generalized_continued_fraction α // g.is_simple_continued_fraction}
def
simple_continued_fraction
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[ "generalized_continued_fraction" ]
A *simple continued fraction* (scf) is a generalized continued fraction (gcf) whose partial numerators are equal to one. $$ h + \dfrac{1} {b_0 + \dfrac{1} {b_1 + \dfrac{1} {b_2 + \dfrac{1} {b_...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
of_integer (a : α) : simple_continued_fraction α
⟨generalized_continued_fraction.of_integer a, λ n aₙ h, by cases h⟩
def
simple_continued_fraction.of_integer
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[ "simple_continued_fraction" ]
Constructs a simple continued fraction without fractional part.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
has_coe_to_generalized_continued_fraction : has_coe (simple_continued_fraction α) (generalized_continued_fraction α)
by {unfold simple_continued_fraction, apply_instance}
instance
simple_continued_fraction.has_coe_to_generalized_continued_fraction
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[ "generalized_continued_fraction", "simple_continued_fraction" ]
Lift a scf to a gcf using the inclusion map.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
coe_to_generalized_continued_fraction {s : simple_continued_fraction α} : (↑s : generalized_continued_fraction α) = s.val
rfl
lemma
simple_continued_fraction.coe_to_generalized_continued_fraction
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[ "generalized_continued_fraction", "simple_continued_fraction" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
simple_continued_fraction.is_continued_fraction [has_one α] [has_zero α] [has_lt α] (s : simple_continued_fraction α) : Prop
∀ (n : ℕ) (bₙ : α), (↑s : generalized_continued_fraction α).partial_denominators.nth n = some bₙ → 0 < bₙ
def
simple_continued_fraction.is_continued_fraction
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[ "generalized_continued_fraction", "simple_continued_fraction" ]
A simple continued fraction is a *(regular) continued fraction* ((r)cf) if all partial denominators `bᵢ` are positive, i.e. `0 < bᵢ`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
continued_fraction [has_one α] [has_zero α] [has_lt α]
{s : simple_continued_fraction α // s.is_continued_fraction}
def
continued_fraction
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[ "simple_continued_fraction" ]
A *(regular) continued fraction* ((r)cf) is a simple continued fraction (scf) whose partial denominators are all positive. It is the subtype of scfs that satisfy `simple_continued_fraction.is_continued_fraction`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
of_integer (a : α) : continued_fraction α
⟨simple_continued_fraction.of_integer a, λ n bₙ h, by cases h⟩
def
continued_fraction.of_integer
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[ "continued_fraction" ]
Constructs a continued fraction without fractional part.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
has_coe_to_simple_continued_fraction : has_coe (continued_fraction α) (simple_continued_fraction α)
by {unfold continued_fraction, apply_instance}
instance
continued_fraction.has_coe_to_simple_continued_fraction
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[ "continued_fraction", "simple_continued_fraction" ]
Lift a cf to a scf using the inclusion map.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
coe_to_simple_continued_fraction {c : continued_fraction α} : (↑c : simple_continued_fraction α) = c.val
rfl
lemma
continued_fraction.coe_to_simple_continued_fraction
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[ "continued_fraction", "simple_continued_fraction" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
has_coe_to_generalized_continued_fraction : has_coe (continued_fraction α) (generalized_continued_fraction α)
⟨λ c, ↑(↑c : simple_continued_fraction α)⟩
instance
continued_fraction.has_coe_to_generalized_continued_fraction
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[ "continued_fraction", "generalized_continued_fraction", "simple_continued_fraction" ]
Lift a cf to a scf using the inclusion map.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
coe_to_generalized_continued_fraction {c : continued_fraction α} : (↑c : generalized_continued_fraction α) = c.val
rfl
lemma
continued_fraction.coe_to_generalized_continued_fraction
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[ "continued_fraction", "generalized_continued_fraction" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
next_numerator (a b ppredA predA : K) : K
b * predA + a * ppredA
def
generalized_continued_fraction.next_numerator
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[]
Returns the next numerator `Aₙ = bₙ₋₁ * Aₙ₋₁ + aₙ₋₁ * Aₙ₋₂`, where `predA` is `Aₙ₋₁`, `ppredA` is `Aₙ₋₂`, `a` is `aₙ₋₁`, and `b` is `bₙ₋₁`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
next_denominator (aₙ bₙ ppredB predB : K) : K
bₙ * predB + aₙ * ppredB
def
generalized_continued_fraction.next_denominator
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[]
Returns the next denominator `Bₙ = bₙ₋₁ * Bₙ₋₁ + aₙ₋₁ * Bₙ₋₂``, where `predB` is `Bₙ₋₁` and `ppredB` is `Bₙ₋₂`, `a` is `aₙ₋₁`, and `b` is `bₙ₋₁`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
next_continuants (a b : K) (ppred pred : pair K) : pair K
⟨next_numerator a b ppred.a pred.a, next_denominator a b ppred.b pred.b⟩
def
generalized_continued_fraction.next_continuants
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[]
Returns the next continuants `⟨Aₙ, Bₙ⟩` using `next_numerator` and `next_denominator`, where `pred` is `⟨Aₙ₋₁, Bₙ₋₁⟩`, `ppred` is `⟨Aₙ₋₂, Bₙ₋₂⟩`, `a` is `aₙ₋₁`, and `b` is `bₙ₋₁`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
continuants_aux (g : generalized_continued_fraction K) : stream (pair K)
| 0 := ⟨1, 0⟩ | 1 := ⟨g.h, 1⟩ | (n + 2) := match g.s.nth n with | none := continuants_aux (n + 1) | some gp := next_continuants gp.a gp.b (continuants_aux n) (continuants_aux $ n + 1) end
def
generalized_continued_fraction.continuants_aux
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[ "generalized_continued_fraction", "stream" ]
Returns the continuants `⟨Aₙ₋₁, Bₙ₋₁⟩` of `g`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
continuants (g : generalized_continued_fraction K) : stream (pair K)
g.continuants_aux.tail
def
generalized_continued_fraction.continuants
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[ "generalized_continued_fraction", "stream" ]
Returns the continuants `⟨Aₙ, Bₙ⟩` of `g`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
numerators (g : generalized_continued_fraction K) : stream K
g.continuants.map pair.a
def
generalized_continued_fraction.numerators
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[ "generalized_continued_fraction", "stream" ]
Returns the numerators `Aₙ` of `g`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
denominators (g : generalized_continued_fraction K) : stream K
g.continuants.map pair.b
def
generalized_continued_fraction.denominators
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[ "generalized_continued_fraction", "stream" ]
Returns the denominators `Bₙ` of `g`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
convergents (g : generalized_continued_fraction K) : stream K
λ (n : ℕ), (g.numerators n) / (g.denominators n)
def
generalized_continued_fraction.convergents
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[ "generalized_continued_fraction", "stream" ]
Returns the convergents `Aₙ / Bₙ` of `g`, where `Aₙ, Bₙ` are the nth continuants of `g`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
convergents'_aux : seq (pair K) → ℕ → K
| s 0 := 0 | s (n + 1) := match s.head with | none := 0 | some gp := gp.a / (gp.b + convergents'_aux s.tail n) end
def
generalized_continued_fraction.convergents'_aux
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[]
Returns the approximation of the fraction described by the given sequence up to a given position n. For example, `convergents'_aux [(1, 2), (3, 4), (5, 6)] 2 = 1 / (2 + 3 / 4)` and `convergents'_aux [(1, 2), (3, 4), (5, 6)] 0 = 0`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
convergents' (g : generalized_continued_fraction K) (n : ℕ) : K
g.h + convergents'_aux g.s n
def
generalized_continued_fraction.convergents'
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[ "generalized_continued_fraction" ]
Returns the convergents of `g` by evaluating the fraction described by `g` up to a given position `n`. For example, `convergents' [9; (1, 2), (3, 4), (5, 6)] 2 = 9 + 1 / (2 + 3 / 4)` and `convergents' [9; (1, 2), (3, 4), (5, 6)] 0 = 9`
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
ext_iff {g g' : generalized_continued_fraction α} : g = g' ↔ g.h = g'.h ∧ g.s = g'.s
by { cases g, cases g', simp }
lemma
generalized_continued_fraction.ext_iff
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[ "generalized_continued_fraction" ]
Two gcfs `g` and `g'` are equal if and only if their components are equal.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
ext {g g' : generalized_continued_fraction α} (hyp : g.h = g'.h ∧ g.s = g'.s) : g = g'
generalized_continued_fraction.ext_iff.elim_right hyp
lemma
generalized_continued_fraction.ext
algebra.continued_fractions
src/algebra/continued_fractions/basic.lean
[ "data.seq.seq", "algebra.field.defs" ]
[ "generalized_continued_fraction" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
continuants_aux_recurrence {gp ppred pred : pair K} (nth_s_eq : g.s.nth n = some gp) (nth_conts_aux_eq : g.continuants_aux n = ppred) (succ_nth_conts_aux_eq : g.continuants_aux (n + 1) = pred) : g.continuants_aux (n + 2) = ⟨gp.b * pred.a + gp.a * ppred.a, gp.b * pred.b + gp.a * ppred.b⟩
by simp [*, continuants_aux, next_continuants, next_denominator, next_numerator]
lemma
generalized_continued_fraction.continuants_aux_recurrence
algebra.continued_fractions
src/algebra/continued_fractions/continuants_recurrence.lean
[ "algebra.continued_fractions.translations" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
continuants_recurrence_aux {gp ppred pred : pair K} (nth_s_eq : g.s.nth n = some gp) (nth_conts_aux_eq : g.continuants_aux n = ppred) (succ_nth_conts_aux_eq : g.continuants_aux (n + 1) = pred) : g.continuants (n + 1) = ⟨gp.b * pred.a + gp.a * ppred.a, gp.b * pred.b + gp.a * ppred.b⟩
by simp [nth_cont_eq_succ_nth_cont_aux, (continuants_aux_recurrence nth_s_eq nth_conts_aux_eq succ_nth_conts_aux_eq)]
lemma
generalized_continued_fraction.continuants_recurrence_aux
algebra.continued_fractions
src/algebra/continued_fractions/continuants_recurrence.lean
[ "algebra.continued_fractions.translations" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
continuants_recurrence {gp ppred pred : pair K} (succ_nth_s_eq : g.s.nth (n + 1) = some gp) (nth_conts_eq : g.continuants n = ppred) (succ_nth_conts_eq : g.continuants (n + 1) = pred) : g.continuants (n + 2) = ⟨gp.b * pred.a + gp.a * ppred.a, gp.b * pred.b + gp.a * ppred.b⟩
begin rw [nth_cont_eq_succ_nth_cont_aux] at nth_conts_eq succ_nth_conts_eq, exact (continuants_recurrence_aux succ_nth_s_eq nth_conts_eq succ_nth_conts_eq) end
theorem
generalized_continued_fraction.continuants_recurrence
algebra.continued_fractions
src/algebra/continued_fractions/continuants_recurrence.lean
[ "algebra.continued_fractions.translations" ]
[]
Shows that `Aₙ = bₙ * Aₙ₋₁ + aₙ * Aₙ₋₂` and `Bₙ = bₙ * Bₙ₋₁ + aₙ * Bₙ₋₂`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
numerators_recurrence {gp : pair K} {ppredA predA : K} (succ_nth_s_eq : g.s.nth (n + 1) = some gp) (nth_num_eq : g.numerators n = ppredA) (succ_nth_num_eq : g.numerators (n + 1) = predA) : g.numerators (n + 2) = gp.b * predA + gp.a * ppredA
begin obtain ⟨ppredConts, nth_conts_eq, ⟨rfl⟩⟩ : ∃ conts, g.continuants n = conts ∧ conts.a = ppredA, from exists_conts_a_of_num nth_num_eq, obtain ⟨predConts, succ_nth_conts_eq, ⟨rfl⟩⟩ : ∃ conts, g.continuants (n + 1) = conts ∧ conts.a = predA, from exists_conts_a_of_num succ_nth_num_eq, rw [num_eq...
lemma
generalized_continued_fraction.numerators_recurrence
algebra.continued_fractions
src/algebra/continued_fractions/continuants_recurrence.lean
[ "algebra.continued_fractions.translations" ]
[]
Shows that `Aₙ = bₙ * Aₙ₋₁ + aₙ * Aₙ₋₂`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
denominators_recurrence {gp : pair K} {ppredB predB : K} (succ_nth_s_eq : g.s.nth (n + 1) = some gp) (nth_denom_eq : g.denominators n = ppredB) (succ_nth_denom_eq : g.denominators (n + 1) = predB) : g.denominators (n + 2) = gp.b * predB + gp.a * ppredB
begin obtain ⟨ppredConts, nth_conts_eq, ⟨rfl⟩⟩ : ∃ conts, g.continuants n = conts ∧ conts.b = ppredB, from exists_conts_b_of_denom nth_denom_eq, obtain ⟨predConts, succ_nth_conts_eq, ⟨rfl⟩⟩ : ∃ conts, g.continuants (n + 1) = conts ∧ conts.b = predB, from exists_conts_b_of_denom succ_nth_denom_eq, rw...
lemma
generalized_continued_fraction.denominators_recurrence
algebra.continued_fractions
src/algebra/continued_fractions/continuants_recurrence.lean
[ "algebra.continued_fractions.translations" ]
[]
Shows that `Bₙ = bₙ * Bₙ₋₁ + aₙ * Bₙ₋₂`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
squash_seq (s : seq $ pair K) (n : ℕ) : seq (pair K)
match prod.mk (s.nth n) (s.nth (n + 1)) with | ⟨some gp_n, some gp_succ_n⟩ := seq.nats.zip_with -- return the squashed value at position `n`; otherwise, do nothing. (λ n' gp, if n' = n then ⟨gp_n.a, gp_n.b + gp_succ_n.a / gp_succ_n.b⟩ else gp) s | _ := s end
def
generalized_continued_fraction.squash_seq
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" ]
[]
Given a sequence of gcf.pairs `s = [(a₀, bₒ), (a₁, b₁), ...]`, `squash_seq s n` combines `⟨aₙ, bₙ⟩` and `⟨aₙ₊₁, bₙ₊₁⟩` at position `n` to `⟨aₙ, bₙ + aₙ₊₁ / bₙ₊₁⟩`. For example, `squash_seq s 0 = [(a₀, bₒ + a₁ / b₁), (a₁, b₁),...]`. If `s.terminated_at (n + 1)`, then `squash_seq s n = s`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
squash_seq_eq_self_of_terminated (terminated_at_succ_n : s.terminated_at (n + 1)) : squash_seq s n = s
begin change s.nth (n + 1) = none at terminated_at_succ_n, cases s_nth_eq : (s.nth n); simp only [*, squash_seq] end
lemma
generalized_continued_fraction.squash_seq_eq_self_of_terminated
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" ]
[]
If the sequence already terminated at position `n + 1`, nothing gets squashed.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
squash_seq_nth_of_not_terminated {gp_n gp_succ_n : pair K} (s_nth_eq : s.nth n = some gp_n) (s_succ_nth_eq : s.nth (n + 1) = some gp_succ_n) : (squash_seq s n).nth n = some ⟨gp_n.a, gp_n.b + gp_succ_n.a / gp_succ_n.b⟩
by simp [*, squash_seq]
lemma
generalized_continued_fraction.squash_seq_nth_of_not_terminated
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" ]
[]
If the sequence has not terminated before position `n + 1`, the value at `n + 1` gets squashed into position `n`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
squash_seq_nth_of_lt {m : ℕ} (m_lt_n : m < n) : (squash_seq s n).nth m = s.nth m
begin cases s_succ_nth_eq : s.nth (n + 1), case option.none { rw (squash_seq_eq_self_of_terminated s_succ_nth_eq) }, case option.some { obtain ⟨gp_n, s_nth_eq⟩ : ∃ gp_n, s.nth n = some gp_n, from s.ge_stable n.le_succ s_succ_nth_eq, obtain ⟨gp_m, s_mth_eq⟩ : ∃ gp_m, s.nth m = some gp_m, from s.g...
lemma
generalized_continued_fraction.squash_seq_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
squash_seq_succ_n_tail_eq_squash_seq_tail_n : (squash_seq s (n + 1)).tail = squash_seq s.tail n
begin cases s_succ_succ_nth_eq : s.nth (n + 2) with gp_succ_succ_n, case option.none { have : squash_seq s (n + 1) = s, from squash_seq_eq_self_of_terminated s_succ_succ_nth_eq, cases s_succ_nth_eq : (s.nth (n + 1)); simp only [squash_seq, seq.nth_tail, s_succ_nth_eq, s_succ_succ_nth_eq] }, case option....
lemma
generalized_continued_fraction.squash_seq_succ_n_tail_eq_squash_seq_tail_n
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" ]
[ "option.map₂_none_right" ]
Squashing at position `n + 1` and taking the tail is the same as squashing the tail of the sequence at position `n`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
succ_succ_nth_convergent'_aux_eq_succ_nth_convergent'_aux_squash_seq : convergents'_aux s (n + 2) = convergents'_aux (squash_seq s n) (n + 1)
begin cases s_succ_nth_eq : (s.nth $ n + 1) with gp_succ_n, case option.none { rw [(squash_seq_eq_self_of_terminated s_succ_nth_eq), (convergents'_aux_stable_step_of_terminated s_succ_nth_eq)] }, case option.some { induction n with m IH generalizing s gp_succ_n, case nat.zero { obtain ⟨gp_head...
lemma
generalized_continued_fraction.succ_succ_nth_convergent'_aux_eq_succ_nth_convergent'_aux_squash_seq
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" ]
[ "zero_le_one" ]
The auxiliary function `convergents'_aux` returns the same value for a sequence and the corresponding squashed sequence at the squashed position.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
squash_gcf (g : generalized_continued_fraction K) : ℕ → generalized_continued_fraction K
| 0 := match g.s.nth 0 with | none := g | some gp := ⟨g.h + gp.a / gp.b, g.s⟩ end | (n + 1) := ⟨g.h, squash_seq g.s n⟩
def
generalized_continued_fraction.squash_gcf
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" ]
[ "generalized_continued_fraction" ]
Given a gcf `g = [h; (a₀, bₒ), (a₁, b₁), ...]`, we have - `squash_nth.gcf g 0 = [h + a₀ / b₀); (a₀, bₒ), ...]`, - `squash_nth.gcf g (n + 1) = ⟨g.h, squash_seq g.s n⟩`
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
squash_gcf_eq_self_of_terminated (terminated_at_n : terminated_at g n) : squash_gcf g n = g
begin cases n, case nat.zero { change g.s.nth 0 = none at terminated_at_n, simp only [convergents', squash_gcf, convergents'_aux, terminated_at_n] }, case nat.succ { cases g, simp [(squash_seq_eq_self_of_terminated terminated_at_n), squash_gcf] } end
lemma
generalized_continued_fraction.squash_gcf_eq_self_of_terminated
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" ]
[]
If the gcf already terminated at position `n`, nothing gets squashed.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83