Helper lemmas for inclusion-exclusion #
Indicator function for squarefree: returns 1 if squarefree, 0 otherwise
Equations
Instances For
Indicator function for "bN+d is squarefree"
Equations
- LeanPool.DeadEnds.shiftSqfreeIndicator b N d = if Squarefree (b * N + d) then 1 else 0
Instances For
Finite inclusion-exclusion for dead end counting.
For each fixed X, the count of dead ends equals the alternating sum over subsets T:
#{N ≤ X : dead end} =
∑_{T ⊆ Finset.range b} (-1) ^ |T| · #{N ≤ X : N sf ∧ ∀d∈T, bN+d sf}
This is the finite Bonferroni identity: for events A_d = "bN+d is squarefree",
#{sf N : all A_d fail} = ∑_T (-1) ^ |T| #{sf N : ∀d∈T, A_d holds}.
Mathlib has Finset.sum_powerset_neg_one_pow_card for this pattern.
Tendsto of alternating sums given Tendsto of each term.
If for each T ⊆ Finset.range b, the ratio (countJointSquarefree b T X)/X → α(b,T),
then the alternating sum ∑_T (-1) ^ |T| · (countJointSquarefree b T X)/X
converges to ∑_T (-1) ^ |T| · α(b,T) = explicitDensityFormula b.
This uses that Filter.Tendsto is preserved under finite sums:
Filter.Tendsto.sum : ∀ (hf : ∀ i ∈ s, Tendsto (f i) l (nhds (a i))), Tendsto (fun x => ∑ i ∈ s, f i x) l (nhds (∑ i ∈ s, a i))
Rewriting the sum: factor out division by X. ∑_T (-1) ^ |T| · count(T,X) / X = (∑_T (-1) ^ |T| · count(T,X)) / X when X ≠ 0. Uses basic algebra: ∑_i (a_i / c) = (∑_i a_i) / c for c ≠ 0.
Main theorems #
The base-b dead-end counting ratios tend to the explicit inclusion-exclusion density.
The asymptotic density D_b of base-b dead ends, defined (when b ≥ 2) as the
unique limit guaranteed by baseBDeadEnd_density_exists.