File: Mathlib/Data/Int/CardIntervalMod.lean

full_name: Int.Ico_filter_dvd_eq
code: lemma Ico_filter_dvd_eq : (Ico a b).filter (r ∣ ·) =
    (Ico ⌈a / (r : ℚ)⌉ ⌈b / (r : ℚ)⌉).map ⟨(· * r), mul_left_injective₀ hr.ne'⟩ 
goal: Finset.filter (fun x => r ∣ x) (Finset.Ico a b) =
  Finset.map { toFun := fun x => x * r, inj' := ⋯ } (Finset.Ico ⌈↑a / ↑r⌉ ⌈↑b / ↑r⌉)

full_name: Int.Ioc_filter_dvd_eq
code: lemma Ioc_filter_dvd_eq : (Ioc a b).filter (r ∣ ·) =
    (Ioc ⌊a / (r : ℚ)⌋ ⌊b / (r : ℚ)⌋).map ⟨(· * r), mul_left_injective₀ hr.ne'⟩ 
goal: Finset.filter (fun x => r ∣ x) (Finset.Ioc a b) =
  Finset.map { toFun := fun x => x * r, inj' := ⋯ } (Finset.Ioc ⌊↑a / ↑r⌋ ⌊↑b / ↑r⌋)

full_name: Int.Ico_filter_dvd_card
code: /-- There are `⌈b / r⌉ - ⌈a / r⌉` multiples of `r` in `[a, b)`, if `a ≤ b`. -/
theorem Ico_filter_dvd_card : ((Ico a b).filter (r ∣ ·)).card =
    max (⌈b / (r : ℚ)⌉ - ⌈a / (r : ℚ)⌉) 0 
goal: ↑(Finset.filter (fun x => r ∣ x) (Finset.Ico a b)).card = max (⌈↑b / ↑r⌉ - ⌈↑a / ↑r⌉) 0

full_name: Int.Ioc_filter_dvd_card
code: /-- There are `⌊b / r⌋ - ⌊a / r⌋` multiples of `r` in `(a, b]`, if `a ≤ b`. -/
theorem Ioc_filter_dvd_card : ((Ioc a b).filter (r ∣ ·)).card =
    max (⌊b / (r : ℚ)⌋ - ⌊a / (r : ℚ)⌋) 0 
goal: ↑(Finset.filter (fun x => r ∣ x) (Finset.Ioc a b)).card = max (⌊↑b / ↑r⌋ - ⌊↑a / ↑r⌋) 0

full_name: Int.Ico_filter_modEq_eq
code: lemma Ico_filter_modEq_eq (v : ℤ) : (Ico a b).filter (· ≡ v [ZMOD r]) =
    ((Ico (a - v) (b - v)).filter (r ∣ ·)).map ⟨(· + v), add_left_injective v⟩ 
goal: Finset.filter (fun x => x ≡ v [ZMOD r]) (Finset.Ico a b) =
  Finset.map { toFun := fun x => x + v, inj' := ⋯ } (Finset.filter (fun x => r ∣ x) (Finset.Ico (a - v) (b - v)))

full_name: Int.Ioc_filter_modEq_eq
code: lemma Ioc_filter_modEq_eq (v : ℤ) : (Ioc a b).filter (· ≡ v [ZMOD r]) =
    ((Ioc (a - v) (b - v)).filter (r ∣ ·)).map ⟨(· + v), add_left_injective v⟩ 
goal: Finset.filter (fun x => x ≡ v [ZMOD r]) (Finset.Ioc a b) =
  Finset.map { toFun := fun x => x + v, inj' := ⋯ } (Finset.filter (fun x => r ∣ x) (Finset.Ioc (a - v) (b - v)))

full_name: Int.Ico_filter_modEq_card
code: /-- There are `⌈(b - v) / r⌉ - ⌈(a - v) / r⌉` numbers congruent to `v` mod `r` in `[a, b)`,
if `a ≤ b`. -/
theorem Ico_filter_modEq_card (v : ℤ) : ((Ico a b).filter (· ≡ v [ZMOD r])).card =
    max (⌈(b - v) / (r : ℚ)⌉ - ⌈(a - v) / (r : ℚ)⌉) 0 
goal: ↑(Finset.filter (fun x => x ≡ v [ZMOD r]) (Finset.Ico a b)).card = max (⌈(↑b - ↑v) / ↑r⌉ - ⌈(↑a - ↑v) / ↑r⌉) 0

full_name: Int.Ioc_filter_modEq_card
code: /-- There are `⌊(b - v) / r⌋ - ⌊(a - v) / r⌋` numbers congruent to `v` mod `r` in `(a, b]`,
if `a ≤ b`. -/
theorem Ioc_filter_modEq_card (v : ℤ) : ((Ioc a b).filter (· ≡ v [ZMOD r])).card =
    max (⌊(b - v) / (r : ℚ)⌋ - ⌊(a - v) / (r : ℚ)⌋) 0 
goal: ↑(Finset.filter (fun x => x ≡ v [ZMOD r]) (Finset.Ioc a b)).card = max (⌊(↑b - ↑v) / ↑r⌋ - ⌊(↑a - ↑v) / ↑r⌋) 0

full_name: Nat.Ico_filter_modEq_cast
code: lemma Ico_filter_modEq_cast {v : ℕ} : ((Ico a b).filter (· ≡ v [MOD r])).map castEmbedding =
    (Ico (a : ℤ) (b : ℤ)).filter (· ≡ v [ZMOD r]) 
goal: Finset.map Nat.castEmbedding (Finset.filter (fun x => x ≡ v [MOD r]) (Finset.Ico a b)) =
  Finset.filter (fun x => x ≡ ↑v [ZMOD ↑r]) (Finset.Ico ↑a ↑b)

full_name: Nat.Ioc_filter_modEq_cast
code: lemma Ioc_filter_modEq_cast {v : ℕ} : ((Ioc a b).filter (· ≡ v [MOD r])).map castEmbedding =
    (Ioc (a : ℤ) (b : ℤ)).filter (· ≡ v [ZMOD r]) 
goal: Finset.map Nat.castEmbedding (Finset.filter (fun x => x ≡ v [MOD r]) (Finset.Ioc a b)) =
  Finset.filter (fun x => x ≡ ↑v [ZMOD ↑r]) (Finset.Ioc ↑a ↑b)

full_name: Nat.Ico_filter_modEq_card
code: /-- 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 Ico_filter_modEq_card (v : ℕ) : ((Ico a b).filter (· ≡ v [MOD r])).card =
    max (⌈(b - v) / (r : ℚ)⌉ - ⌈(a - v) / (r : ℚ)⌉) 0 
goal: ↑(Finset.filter (fun x => x ≡ v [MOD r]) (Finset.Ico a b)).card = max (⌈(↑b - ↑v) / ↑r⌉ - ⌈(↑a - ↑v) / ↑r⌉) 0

full_name: Nat.Ioc_filter_modEq_card
code: /-- 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 Ioc_filter_modEq_card (v : ℕ) : ((Ioc a b).filter (· ≡ v [MOD r])).card =
    max (⌊(b - v) / (r : ℚ)⌋ - ⌊(a - v) / (r : ℚ)⌋) 0 
goal: ↑(Finset.filter (fun x => x ≡ v [MOD r]) (Finset.Ioc a b)).card = max (⌊(↑b - ↑v) / ↑r⌋ - ⌊(↑a - ↑v) / ↑r⌋) 0

full_name: Nat.count_modEq_card_eq_ceil
code: /-- There are `⌈(b - v % r) / r⌉` numbers in `[0, b)` congruent to `v` mod `r`. -/
theorem count_modEq_card_eq_ceil (v : ℕ) :
    b.count (· ≡ v [MOD r]) = ⌈(b - (v % r : ℕ)) / (r : ℚ)⌉ 
goal: ↑(Nat.count (fun x => x ≡ v [MOD r]) b) = ⌈(↑b - ↑(v % r)) / ↑r⌉

full_name: Nat.count_modEq_card
code: /-- There are `b / r + [v % r < b % r]` numbers in `[0, b)` congruent to `v` mod `r`,
where `[·]` is the Iverson bracket. -/
theorem count_modEq_card (v : ℕ) :
    b.count (· ≡ v [MOD r]) = b / r + if v % r < b % r then 1 else 0 
goal: Nat.count (fun x => x ≡ v [MOD r]) b = b / r + if v % r < b % r then 1 else 0