Weighted inclusion-exclusion has a signed zero-hit remainder
ProvedPvsNP.weighted_zero_hit_alternating_remaindercomplexity-theoryformal-verification
Each finite world has an integer weight and a natural number of hits. The alternating sum of its weighted binomial coefficients through depth d equals the total weight of worlds with zero hits plus (-1)^d times the sum over worlds with positive hits of their weight times the number of d-subsets of one fewer than their hits.
Preamble
import Mathlib.Data.Nat.Choose.Sum import Mathlib.Tactic.Ring set_option autoImplicit false
Formal statement
theorem PvsNP.weighted_zero_hit_alternating_remainder {World : Type*}
(worlds : Finset World) (hits : World → ℕ) (weight : World → ℤ) (depth : ℕ) :
(∑ j ∈ Finset.range (depth + 1), (-1 : ℤ) ^ j *
∑ w ∈ worlds, weight w * (hits w).choose j) =
(∑ w ∈ worlds.filter (fun w => hits w = 0), weight w) + (-1 : ℤ) ^ depth *
∑ w ∈ worlds.filter (fun w => hits w ≠ 0), weight w * (hits w - 1).choose depth := by sorrySource
The exact finite remainder used in Bonferroni estimates for limited independence.