Counting elements in an interval with given residue #
The theorems in this file generalise Nat.card_multiples in
Mathlib/Data/Nat/Factorization/Basic.lean to all integer intervals and any fixed residue (not just
zero, which reduces to the multiples). Theorems are given for Ico and Ioc intervals.
theorem
Int.Ico_filter_modEq_eq
(a b : โค)
{r : โค}
(v : โค)
:
{x โ Finset.Ico a b | x โก v [ZMOD r]} = Finset.map { toFun := fun (x : โค) => x + v, inj' := โฏ } ({x โ Finset.Ico (a - v) (b - v) | r โฃ x})
theorem
Int.Ioc_filter_modEq_eq
(a b : โค)
{r : โค}
(v : โค)
:
{x โ Finset.Ioc a b | x โก v [ZMOD r]} = Finset.map { toFun := fun (x : โค) => x + v, inj' := โฏ } ({x โ Finset.Ioc (a - v) (b - v) | r โฃ x})
theorem
Int.Ico_filter_dvd_eq
(a b : โค)
{r : โค}
(hr : 0 < r)
:
{x โ Finset.Ico a b | r โฃ x} = Finset.map { toFun := fun (x : โค) => x * r, inj' := โฏ } (Finset.Ico โโa / โrโ โโb / โrโ)
theorem
Int.Ioc_filter_dvd_eq
(a b : โค)
{r : โค}
(hr : 0 < r)
:
{x โ Finset.Ioc a b | r โฃ x} = Finset.map { toFun := fun (x : โค) => x * r, inj' := โฏ } (Finset.Ioc โโa / โrโ โโb / โrโ)
There are โ(b - v) / rโ - โ(a - v) / rโ numbers congruent to v mod r in [a, b),
if a โค b.
There are โ(b - v) / rโ - โ(a - v) / rโ numbers congruent to v mod r in (a, b],
if a โค b.
theorem
Nat.Ico_filter_modEq_cast
(a b : โ)
{r v : โ}
:
Finset.map castEmbedding ({x โ Finset.Ico a b | x โก v [MOD r]}) = {x โ Finset.Ico โa โb | x โก โv [ZMOD โr]}
theorem
Nat.Ioc_filter_modEq_cast
(a b : โ)
{r v : โ}
:
Finset.map castEmbedding ({x โ Finset.Ioc a b | x โก v [MOD r]}) = {x โ Finset.Ioc โa โb | x โก โv [ZMOD โr]}
There are โ(b - v) / rโ - โ(a - v) / rโ numbers congruent to v mod r in [a, b),
if a โค b. Nat version of Int.Ico_filter_modEq_card.
There are โ(b - v) / rโ - โ(a - v) / rโ numbers congruent to v mod r in (a, b],
if a โค b. Nat version of Int.Ioc_filter_modEq_card.