Prime-tail and single-prime divisibility estimates.
The number of N ∈ (0, X] satisfying N ≡ v (mod r) is at most X / r + 1.
The exact count is given by Nat.Ioc_filter_modEq_card:
{x ∈ Finset.Ioc a b | x ≡ v [MOD r]}.card = max(⌊(b - v)/r⌋ - ⌊(a - v)/r⌋, 0)
For a = 0, b = X, the count equals max(⌊(X - v)/r⌋ - ⌊-v/r⌋, 0).
By floor_diff_bound, the expression ⌊(X - v)/r⌋ - ⌊-v/r⌋ ≤ ⌊X/r⌋ + 1.
Since X, r are naturals, ⌊(X : ℝ)/r⌋ = X / r (integer division).
The nonnegative floor difference is at most the upper bound, giving count ≤ X / r + 1.
Constructs a unique residue v such that bv ≡ -d (mod p²) for prime p > b ≥ 2. In ZMod (p²), since b is a unit (coprime to p²), we can define v = b⁻¹ * (-d). The result is a natural number v < p² such that p² | bv + d.
For a fixed d, the count of N in [1,X] with q²|(bN+d) is at most X/q² + 1. Since q > b and q is prime, gcd(b,q²) = 1, so the congruence bN ≡ -d (mod q²) has a unique solution mod q². The solutions form an arithmetic progression with common difference q², so there are at most ⌊X/q²⌋ + 1 solutions in [1,X].
The count of N in [1,X] with ∃d∈T, q²|(bN+d) is at most |T|*(X/q² + 1).
This follows from the union bound over T applied to card_shifted_divisible_bound.
Uses Finset.card_biUnion_le_card_mul : ∀ (s : Finset ι) (f : ι → Finset β) (n : ℕ), (∀ a ∈ s, (f a).card ≤ n) → (s.biUnion f).card ≤ s.card * n.