Mathlib.Data.Int.CardIntervalMod
14 declarations. Mathlib docs · Source
theorem Int.Ico_filter_modEq_eq E0 #
∀ (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 E0 #
∀ (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 E0 #
∀ (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 E0 #
∀ (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⌋)
theorem Int.Ico_filter_dvd_card E1 #
∀ (a b : ℤ) {r : ℤ}, 0 < r → ↑{x ∈ Finset.Ico a b | r ∣ x}.card = max (⌈↑b / ↑r⌉ - ⌈↑a / ↑r⌉) 0
There are ⌈b / r⌉ - ⌈a / r⌉ multiples of r in [a, b), if a ≤ b.
theorem Int.Ioc_filter_dvd_card E1 #
∀ (a b : ℤ) {r : ℤ}, 0 < r → ↑{x ∈ Finset.Ioc a b | r ∣ x}.card = max (⌊↑b / ↑r⌋ - ⌊↑a / ↑r⌋) 0
There are ⌊b / r⌋ - ⌊a / r⌋ multiples of r in (a, b], if a ≤ b.
theorem Int.Ico_filter_modEq_card E1 #
∀ (a b : ℤ) {r : ℤ},
0 < r → ∀ (v : ℤ), ↑{x ∈ Finset.Ico a b | x ≡ v [ZMOD r]}.card = max (⌈(↑b - ↑v) / ↑r⌉ - ⌈(↑a - ↑v) / ↑r⌉) 0
There are ⌈(b - v) / r⌉ - ⌈(a - v) / r⌉ numbers congruent to v mod r in [a, b),
if a ≤ b.
theorem Int.Ioc_filter_modEq_card E1 #
∀ (a b : ℤ) {r : ℤ},
0 < r → ∀ (v : ℤ), ↑{x ∈ Finset.Ioc a b | x ≡ v [ZMOD r]}.card = max (⌊(↑b - ↑v) / ↑r⌋ - ⌊(↑a - ↑v) / ↑r⌋) 0
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 E1 #
∀ (a b : ℕ) {r v : ℕ},
Finset.map Nat.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 E1 #
∀ (a b : ℕ) {r v : ℕ},
Finset.map Nat.castEmbedding ({x ∈ Finset.Ioc a b | x ≡ v [MOD r]}) = {x ∈ Finset.Ioc ↑a ↑b | x ≡ ↑v [ZMOD ↑r]}
theorem Nat.Ico_filter_modEq_card E1 #
∀ (a b : ℕ) {r : ℕ},
0 < r → ∀ (v : ℕ), ↑{x ∈ Finset.Ico a b | x ≡ v [MOD r]}.card = max (⌈(↑b - ↑v) / ↑r⌉ - ⌈(↑a - ↑v) / ↑r⌉) 0
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.
theorem Nat.Ioc_filter_modEq_card E1 #
∀ (a b : ℕ) {r : ℕ},
0 < r → ∀ (v : ℕ), ↑{x ∈ Finset.Ioc a b | x ≡ v [MOD r]}.card = max (⌊(↑b - ↑v) / ↑r⌋ - ⌊(↑a - ↑v) / ↑r⌋) 0
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.
theorem Nat.count_modEq_card_eq_ceil E1 #
∀ (b : ℕ) {r : ℕ}, 0 < r → ∀ (v : ℕ), ↑(Nat.count (fun x ↦ x ≡ v [MOD r]) b) = ⌈(↑b - ↑(v % r)) / ↑r⌉
There are ⌈(b - v % r) / r⌉ numbers in [0, b) congruent to v mod r.
theorem Nat.count_modEq_card E1 #
∀ (b : ℕ) {r : ℕ}, 0 < r → ∀ (v : ℕ), Nat.count (fun x ↦ x ≡ v [MOD r]) b = b / r + if v % r < b % r then 1 else 0
There are b / r + [v % r < b % r] numbers in [0, b) congruent to v mod r,
where [·] is the Iverson bracket.