op861_disjoint_boolean_windows_count
For a finite Boolean coordinate set, pairwise disjoint coordinate blocks, and integer offsets depending only on coordinates outside all blocks, the number of assignments satisfying one integer score window on each block, multiplied by the product of two to each block size, is at most two to the number of coordinates times the product over blocks of the window length times the largest binomial coefficient of that block size. Each score adds the offset to the number of bits matching a specified pattern.
Statement
theorem op861_disjoint_boolean_windows_count (β ι : Type) [Fintype β] [DecidableEq β] [DecidableEq ι] (J : Finset ι) (B : ι → Finset β) (pattern : ι → β → Bool) (lo hi : ι → ℤ) (offset : ι → (β → Bool) → ℤ) (hdisj : ∀ i ∈ J, ∀ j ∈ J, i ≠ j → Disjoint (B i) (B j)) (hwindow : ∀ i ∈ J, lo i ≤ hi i) (hstable : ∀ i ∈ J, ∀ ω ω' : β → Bool, (∀ t, t ∉ J.biUnion B → ω t = ω' t) → offset i ω = offset i ω') : let score : ι → (β → Bool) → ℤ := fun i ω => offset i ω + ∑ t ∈ B i, (if ω t = pattern i t then (1 : ℤ) else 0) ((Finset.univ : Finset (β → Bool)).filter (fun ω => ∀ i ∈ J, lo i ≤ score i ω ∧ score i ω ≤ hi i)).card * (∏ i ∈ J, 2 ^ (B i).card) ≤ 2 ^ Fintype.card β * ∏ i ∈ J, ((hi i - lo i + 1).toNat * (B i).card.choose ((B i).card / 2))
- Source
- Finite independent-block small-ball counting step for op861_dense_triangle_orientation_sqrt_cover.
- Verified
- 18 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 6
- op861_boolean_weight_interval_countFor natural numbers n, a, and b with a at most b, the number of subsets of an n-element set whose cardinalities lie between a and b…
- op861_boolean_restrictions_injectiveA Boolean function on a finite set is determined by its restrictions to the complement of a union of blocks and to each block in the…
- op861_boolean_block_product_boundFor Boolean assignments on a finite coordinate set and any family of block predicates depending on the assignment outside all blocks, the…
- op861_boolean_matching_window_countFor a finite Boolean coordinate set, a fixed bit pattern, an integer offset, and an integer interval with ordered endpoints, the number of…
- op861_boolean_block_uniform_boundA uniform bound on each block fiber yields a bound on the total number of good Boolean assignments by the outside-assignment count times…
- op861_disjoint_boolean_partition_cardFor pairwise disjoint finite blocks, the number of Boolean outside assignments times the product of Boolean assignment counts on the…
- Used by 2
- op861_dense_triangle_orientation_sqrt_coverThere are natural numbers C and n₀ with C positive such that, for every finite linearly ordered abelian group of exponent three with at…
- op861_ternary_tournament_sqrt_core_coverThere are natural numbers C and d₀ with C positive such that, for every d at least d₀, setting k = (3^d + 1)/2, there is a regular…
The proof, explained
The proof bounds the number of global Boolean assignments whose score on each coordinate block falls in a given integer window. Because the blocks are pairwise disjoint and the score offsets depend only on coordinates outside all blocks, conditioning on any assignment to the external coordinates decouples the blocks. On each block, Sperner-type bounds for windowed sums limit the number of valid local assignments by the window length times the central binomial coefficient of the block size. Combining these local bounds via a uniform block product theorem and multiplying by the product of 2 to each block size transforms the external factor into 2 to the total number of coordinates.
Set up the score function, an extension operator from external coordinates, and the per-block window condition.
Assuming classical logic, we introduce the score definition. To separate coordinates inside the blocks from those outside, we define ext (which extends an assignment on the complement of the block union to all coordinates by setting all block coordinates to false), cnt (which counts pattern matches within a block), and P (which requires that the offset determined by ext plus the local block count falls into [lo i, hi i]).
classical intro score let ext : ({t : β // t ∉ J.biUnion B} → Bool) → β → Bool := fun a t => if h : t ∉ J.biUnion B then a ⟨t, h⟩ else false let cnt : ∀ i : {i : ι // i ∈ J}, ({t : β // t ∈ B i.1} → Bool) → ℤ := fun i v => (((Finset.univ : Finset {t : β // t ∈ B i.1}).filter (fun t => v t = pattern i.1 t.1)).card : ℤ) let P : ({t : β // t ∉ J.biUnion B} → Bool) → ∀ i : {i : ι // i ∈ J}, ({t : β // t ∈ B i.1} → Bool) → Prop := fun a i v => lo i.1 ≤ offset i.1 (ext a) + cnt i v ∧ offset i.1 (ext a) + cnt i v ≤ hi i.1
For any block and assignment, the indicator sum for pattern matches equals the number of matching coordinates in that block.
Rewriting the sum over the block as a sum over the corresponding subtype using Finset.sum_coe_sort, the indicator sum simplifies via Finset.sum_boole to the cardinality of the filtered subtype of coordinates where the assignment matches the pattern.
uses
Finset.sum_coe_sort,Finset.sum_boolehave hsum : ∀ (i : ι) (ω : β → Bool), ∑ t ∈ B i, (if ω t = pattern i t then (1 : ℤ) else 0) = (((Finset.univ : Finset {t : β // t ∈ B i}).filter (fun t => (fun t : {t : β // t ∈ B i} => ω t.1) t = pattern i t.1)).card : ℤ) := by intro i ω rw [← Finset.sum_coe_sort (B i), Finset.sum_boole]
The offset for each block depends only on coordinates outside all blocks.
The stability hypothesis hstable guarantees that the offset is unchanged if an assignment is modified only on the coordinates within the blocks. Since ext preserves all values outside the blocks and sets block coordinates to false, the offset on the extended assignment equals the offset on the original assignment.
uses
dif_poshave hext : ∀ i ∈ J, ∀ ω : β → Bool, offset i (ext (fun t => ω t.1)) = offset i ω := by intro i hi ω apply hstable i hi intro t ht simp only [ext, dif_pos ht]
The number of global assignments satisfying all block score windows is bounded by the number of external assignments times the product of each block's local window bound.
We apply op861_boolean_block_uniform_bound. To satisfy its premises, we verify: (1) every global satisfying assignment fulfills the block predicate P for each block, since the score decomposes into the external offset and the match count; and (2) for any fixed external assignment and any block, the number of local assignments satisfying P is at most the window length times the central binomial coefficient of the block size, by op861_boolean_matching_window_count.
uses
op861_boolean_block_uniform_bound,op861_boolean_matching_window_count,Fintype.card_coe,le_trans,le_of_eq,Finset.mem_filter,Finset.mem_univ,true_andhave key := op861_boolean_block_uniform_bound β ι J B (fun ω => ∀ i ∈ J, lo i ≤ score i ω ∧ score i ω ≤ hi i) P (fun i => (hi i - lo i + 1).toNat * (B i).card.choose ((B i).card / 2)) (by intro ω hω i have h := hω i.1 i.2 simp only [score, hsum] at h simp only [P, cnt] rw [hext i.1 i.2 ω] exact h) (by intro a i have := op861_boolean_matching_window_count {t : β // t ∈ B i.1} (fun t => pattern i.1 t.1) (lo i.1) (hi i.1) (offset i.1 (ext a)) (hwindow i.1 i.2) rw [Fintype.card_coe] at this refine le_trans (le_of_eq ?_) this congr 1 ext v simp only [Finset.mem_filter, Finset.mem_univ, true_and, P, cnt])
The subtype product over block indices equals the finset product over J.
We rewrite the product over the subtype {i // i ∈ J} in the key bound to a product over the finite set J using Finset.prod_coe_sort.
uses
Finset.prod_coe_sorthave hprod : (∏ i : {i : ι // i ∈ J}, (hi i.1 - lo i.1 + 1).toNat * (B i.1).card.choose ((B i.1).card / 2)) = ∏ i ∈ J, ((hi i - lo i + 1).toNat * (B i).card.choose ((B i).card / 2)) := Finset.prod_coe_sort J (fun i => (hi i - lo i + 1).toNat * (B i).card.choose ((B i).card / 2)) rw [hprod] at key
Multiplying by the product of 2 to each block size yields the theorem inequality.
By op861_disjoint_boolean_partition_card, the pairwise disjointness of the blocks implies that 2 to the number of external coordinates times the product of 2 to each block size equals 2 to the total number of coordinates. Multiplying both sides of the key bound by the product of 2 to each block size and substituting this identity finishes the proof by ring arithmetic.
uses
op861_disjoint_boolean_partition_card,Nat.mul_le_mul_righthave hpart := op861_disjoint_boolean_partition_card β ι J B hdisj calc _ ≤ (Fintype.card ({t : β // t ∉ J.biUnion B} → Bool) * ∏ i ∈ J, ((hi i - lo i + 1).toNat * (B i).card.choose ((B i).card / 2))) * (∏ i ∈ J, 2 ^ (B i).card) := Nat.mul_le_mul_right _ key _ = _ := by rw [← hpart]; ring
dif_pos- A dependent if-then-else evaluates to its true branch when the condition holds.
Fintype.card_coe- The cardinality of the subtype corresponding to a finite set equals the cardinality of the finite set.
Finset.sum_boole- The sum of the indicator of a predicate over a finite set equals the cardinality of the subset satisfying that predicate.
Finset.sum_coe_sort- Summing a function over the subtype of elements in a finite set equals the sum over the finite set itself.
Finset.prod_coe_sort- Multiplying a function over the subtype of elements in a finite set equals the product over the finite set itself.
Finset.mem_filter- An element belongs to a filtered finite set if and only if it belongs to the set and satisfies the filter predicate.
Finset.mem_univ- Every element of a finite type belongs to its universal finite set.
le_trans- Inequality is transitive.
le_of_eq- An equality implies a weak inequality.
Nat.mul_le_mul_right- Multiplying both sides of a natural inequality by a non-negative factor preserves the inequality.
op861_boolean_block_uniform_bound- If a global property implies local block predicates and each block predicate has at most limit_i satisfying assignments regardless of the coordinates outside the blocks, then the number of global satisfying assignments is at most the number of external assignments times the product of the limits.
op861_boolean_matching_window_count- The number of assignments on a finite set whose number of pattern matches shifted by an offset falls in [lo, hi] is at most the interval length times the central binomial coefficient of the set size.
op861_disjoint_boolean_partition_card- For pairwise disjoint blocks of coordinates, the number of assignments outside the blocks times the product over blocks of 2 to each block size equals 2 to the total number of coordinates.
true_and- The conjunction of True with any proposition p is logically equivalent to p.
- To avoid rational division in the natural numbers, the upper bound is expressed by clearing denominators: multiplying both sides by the product of 2 to the power of each block size, so that the factor 2 to the number of coordinates outside the blocks becomes 2 to the total number of coordinates.
Written by a model (gemini-3.8-flash) from the Lean proof and the goal states Lean reported at each step. Lean verified the proof; this explanation is a reading aid and is not itself machine-checked.
Lean source view module on GitHub
Choose a tactic — a marked line — to see the goals Lean had before and after it, as in Lean’s infoview. Step with ← → or j k.
theorem op861_disjoint_boolean_windows_count (β ι : Type) [Fintype β] [DecidableEq β] [DecidableEq ι] (J : Finset ι) (B : ι → Finset β) (pattern : ι → β → Bool) (lo hi : ι → ℤ) (offset : ι → (β → Bool) → ℤ) (hdisj : ∀ i ∈ J, ∀ j ∈ J, i ≠ j → Disjoint (B i) (B j)) (hwindow : ∀ i ∈ J, lo i ≤ hi i) (hstable : ∀ i ∈ J, ∀ ω ω' : β → Bool, (∀ t, t ∉ J.biUnion B → ω t = ω' t) → offset i ω = offset i ω') : let score : ι → (β → Bool) → ℤ := fun i ω => offset i ω + ∑ t ∈ B i, (if ω t = pattern i t then (1 : ℤ) else 0) ((Finset.univ : Finset (β → Bool)).filter (fun ω => ∀ i ∈ J, lo i ≤ score i ω ∧ score i ω ≤ hi i)).card * (∏ i ∈ J, 2 ^ (B i).card) ≤ 2 ^ Fintype.card β * ∏ i ∈ J, ((hi i - lo i + 1).toNat * (B i).card.choose ((B i).card / 2)) := by classical intro score let ext : ({t : β // t ∉ J.biUnion B} → Bool) → β → Bool := fun a t => if h : t ∉ J.biUnion B then a ⟨t, h⟩ else false let cnt : ∀ i : {i : ι // i ∈ J}, ({t : β // t ∈ B i.1} → Bool) → ℤ := fun i v => (((Finset.univ : Finset {t : β // t ∈ B i.1}).filter (fun t => v t = pattern i.1 t.1)).card : ℤ) let P : ({t : β // t ∉ J.biUnion B} → Bool) → ∀ i : {i : ι // i ∈ J}, ({t : β // t ∈ B i.1} → Bool) → Prop := fun a i v => lo i.1 ≤ offset i.1 (ext a) + cnt i v ∧ offset i.1 (ext a) + cnt i v ≤ hi i.1 have hsum : ∀ (i : ι) (ω : β → Bool), ∑ t ∈ B i, (if ω t = pattern i t then (1 : ℤ) else 0) = (((Finset.univ : Finset {t : β // t ∈ B i}).filter (fun t => (fun t : {t : β // t ∈ B i} => ω t.1) t = pattern i t.1)).card : ℤ) := by intro i ω rw [← Finset.sum_coe_sort (B i), Finset.sum_boole] have hext : ∀ i ∈ J, ∀ ω : β → Bool, offset i (ext (fun t => ω t.1)) = offset i ω := by intro i hi ω apply hstable i hi intro t ht simp only [ext, dif_pos ht] have key := op861_boolean_block_uniform_bound β ι J B (fun ω => ∀ i ∈ J, lo i ≤ score i ω ∧ score i ω ≤ hi i) P (fun i => (hi i - lo i + 1).toNat * (B i).card.choose ((B i).card / 2)) (by intro ω hω i have h := hω i.1 i.2 simp only [score, hsum] at h simp only [P, cnt] rw [hext i.1 i.2 ω] exact h) (by intro a i have := op861_boolean_matching_window_count {t : β // t ∈ B i.1} (fun t => pattern i.1 t.1) (lo i.1) (hi i.1) (offset i.1 (ext a)) (hwindow i.1 i.2) rw [Fintype.card_coe] at this refine le_trans (le_of_eq ?_) this congr 1 ext v simp only [Finset.mem_filter, Finset.mem_univ, true_and, P, cnt]) have hprod : (∏ i : {i : ι // i ∈ J}, (hi i.1 - lo i.1 + 1).toNat * (B i.1).card.choose ((B i.1).card / 2)) = ∏ i ∈ J, ((hi i - lo i + 1).toNat * (B i).card.choose ((B i).card / 2)) := Finset.prod_coe_sort J (fun i => (hi i - lo i + 1).toNat * (B i).card.choose ((B i).card / 2)) rw [hprod] at key have hpart := op861_disjoint_boolean_partition_card β ι J B hdisj calc _ ≤ (Fintype.card ({t : β // t ∉ J.biUnion B} → Bool) * ∏ i ∈ J, ((hi i - lo i + 1).toNat * (B i).card.choose ((B i).card / 2))) * (∏ i ∈ J, 2 ^ (B i).card) := Nat.mul_le_mul_right _ key _ = _ := by rw [← hpart]; ring