Documentation

LeanPool.DeadEnds.InclusionExclusion

Helper lemmas for inclusion-exclusion #

noncomputable def LeanPool.DeadEnds.sqfreeIndicator (n : ) :

Indicator function for squarefree: returns 1 if squarefree, 0 otherwise

Equations
Instances For
    noncomputable def LeanPool.DeadEnds.shiftSqfreeIndicator (b N d : ) :

    Indicator function for "bN+d is squarefree"

    Equations
    Instances For
      theorem LeanPool.DeadEnds.sum_over_subsets_containing_x (s : Finset ) (x : ) (hx : xs) (a : ) :
      Ts.powerset, (-1) ^ (insert x T).card * dinsert x T, a d = -a x * Ts.powerset, (-1) ^ T.card * dT, a d
      theorem LeanPool.DeadEnds.prod_one_sub_eq_sum_powerset (U : Finset ) (a : ) :
      dU, (1 - a d) = TU.powerset, (-1) ^ T.card * dT, a d
      theorem LeanPool.DeadEnds.countBaseBDeadEnds_as_sum (b X : ) (_hb : 0 < b) :
      (countBaseBDeadEnds b X) = NFinset.Icc 1 X, sqfreeIndicator N * dFinset.range b, (1 - shiftSqfreeIndicator b N d)
      theorem LeanPool.DeadEnds.dead_end_count_inclusion_exclusion (b : ) (_hb : 2 b) (X : ) :
      (countBaseBDeadEnds b X) = T(Finset.range b).powerset, (-1) ^ T.card * (countJointSquarefree b T X)

      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.

      theorem LeanPool.DeadEnds.alternating_sum_tendsto (b : ) (_hb : 2 b) (h_tendsto : T(Finset.range b).powerset, Filter.Tendsto (fun (X : ) => (countJointSquarefree b T X) / X) Filter.atTop (nhds (jointSquarefreeDensity b T))) :
      Filter.Tendsto (fun (X : ) => T(Finset.range b).powerset, (-1) ^ T.card * ((countJointSquarefree b T X) / X)) Filter.atTop (nhds (explicitDensityFormula b))

      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))

      theorem LeanPool.DeadEnds.sum_div_eq_div_sum (b X : ) (_hX : 0 < X) :
      T(Finset.range b).powerset, (-1) ^ T.card * ((countJointSquarefree b T X) / X) = (∑ T(Finset.range b).powerset, (-1) ^ T.card * (countJointSquarefree b T X)) / X

      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.

      theorem LeanPool.DeadEnds.baseBDeadEnd_density_unique (b : ) (D₁ D₂ : ) (h₁ : HasAsymptoticDensity b D₁) (h₂ : HasAsymptoticDensity b D₂) :
      D₁ = D₂
      noncomputable def LeanPool.DeadEnds.baseBDeadEndDensity (b : ) (hb : 2 b) :

      The asymptotic density D_b of base-b dead ends, defined (when b ≥ 2) as the unique limit guaranteed by baseBDeadEnd_density_exists.

      Equations
      Instances For
        theorem LeanPool.DeadEnds.jointSquarefreeDensity_is_asymptotic_density (b : ) (hb : 2 b) (T : Finset ) (hT : T Finset.range b) :
        have countJoint := fun (X : ) => {NFinset.Icc 1 X | Squarefree N dT, Squarefree (b * N + d)}.card; Filter.Tendsto (fun (X : ) => (countJoint X) / X) Filter.atTop (nhds (jointSquarefreeDensity b T))