Presburger cardinality, quorum-intersection, and pigeonhole solver for Finset #
Distributed consensus, quorum-system, and combinatorial proofs repeatedly combine Finset
cardinalities with Boolean set algebra (∅, Finset.univ, ∪, ∩, \, ᶜ), point operations
({x}, insert, erase), set relations (⊆, =, ≠, Disjoint, Finset.Nonempty),
membership (∈, ∉), Finset.filter subset and disjoint-fiber partitions, embedding/image size
bounds (Finset.map, Finset.image), and pigeonhole witness goals (∃ x ∈ S, x ∉ F,
S.Nonempty).
finset_card decides this quantifier-free Boolean Algebra with Presburger Arithmetic (BAPA)
fragment over each carrier type α present in the goal and hypotheses:
- Optional bracket arguments
finset_card [d₁, h₁, …]unfold named definitionsd₁in the goal and relevant hypotheses, rewrite with quantified=/↔lemmas, and add proof hintsh₁. - Existential nonemptiness and pigeonhole targets (
S.Nonempty,∃ x ∈ S, x ∉ T,∃ x, x ∈ S, and∃ x, x ∉ Tunder[Fintype α]) reduce to strict positivity of the correspondingFinset.card. - Pre-pass size bridges record
(S.map emb).card = S.card,(S.image f).card ≤ S.card, andFintype.card (Fin n) = n, connecting multiple carrier types when an embedding maps between them. - For each carrier type
α, atomic finsets are collected up to a hard cap (maxAtoms = 5, at most32Venn cells; points involved only in∈/∉without≠or{·}/insert/erasecontribute zero-atom nonemptiness bounds instead of Venn atoms). Every compound Boolean expression and set relation reduces over a verified Venn-partition tree (vennSum, working both with[Fintype α]viaFinset.univand without[Fintype α]viaunionAll) into nonnegativeℕcell counts, harvestedFinset.filterconstraints (filter_subset, distinct-value fiber disjointness, andBool/negation partitions) add zero new atoms, andomegacloses the resulting linear system.
Main definitions #
finset_card: close a quantifier-freeFinsetcardinality, quorum-intersection, set-relation, or pigeonhole goal via Venn decomposition andomega.
Syntax of compound Boolean Finset expressions over indexed atomic finsets and a bounding
ambient finset top.
- empty : FinsetCard.SetExpr
- top : FinsetCard.SetExpr
- atom (idx : ℕ) : FinsetCard.SetExpr
- union (a b : FinsetCard.SetExpr) : FinsetCard.SetExpr
- inter (a b : FinsetCard.SetExpr) : FinsetCard.SetExpr
- sdiff (a b : FinsetCard.SetExpr) : FinsetCard.SetExpr
Truth value of SetExpr under an atomic membership bit-vector bs.
Concrete Finset α denoted by a SetExpr inside ambient finset U over atoms as.
Predicate asserting every atom in as is a subset of ambient finset U.
- nil {α : Type u} {U : Finset α} : FinsetCard.AllSubset U []
- cons {α : Type u} {U A : Finset α} {rest : List (Finset α)} : A ⊆ U → FinsetCard.AllSubset U rest → FinsetCard.AllSubset U (A :: rest)
Finite bounding union of a list of finsets (used when [Fintype α] is unavailable).
Every list of finsets is contained in Finset.univ.
Every list of finsets is contained in unionAll as.
Reflection equation expressing (e.denote U as).card as a Venn-cell sum.
Reflection equation expressing Fintype.card α as the sum of Venn cells of Finset.univ.
Translate s ⊆ t into vennSum (s \ t) = 0.
Translate s = t into vennSum (s ∆ t) = 0.
Translate s ≠ t into 0 < vennSum (s ∆ t).
Coherence of Finset.univ across any two Fintype α instances.
Coherence of ∪ (Max.max) across any two DecidableEq α instances.
Coherence of ∩ (Min.min) across any two DecidableEq α instances.
Coherence of \ (SDiff.sdiff) across any two DecidableEq α instances.
Rewrite sᶜ to Finset.univ \ t across any Fintype and DecidableEq instances.
Rewrite insert x s to {x} ∪ t across any two DecidableEq α instances.
Rewrite s.erase x to t \ {x} across any two DecidableEq α instances.
Pigeonhole and Finset.filter structural lemmas #
Witness ∃ x ∈ s, x ∉ t from 0 < (s \ t).card.
Witness ∃ x, x ∉ t from 0 < (Finset.univ \ t).card.
Distinct fibers s₁.filter (f · = v₁) and s₂.filter (f · = v₂) are disjoint
when v₁ ≠ v₂.
Boolean fibers f x = true and f x = false partition s.
Prove a quantifier-free Finset cardinality, quorum-intersection, set-relation (⊆, =,
≠, Disjoint, Finset.Nonempty), membership (∈, ∉), or pigeonhole (∃ x ∈ S, x ∉ F) goal
by Venn-region decomposition (up to 5 atomic finsets per carrier type) followed by omega.
finset_cardinspects the goal and all local hypotheses across every carrier typeα.finset_card [d₁, h₁, …]additionally unfolds named definitionsd₁, rewrites with quantified=/↔lemmas, and supplies extra proof termsh₁(such as product bounds or list-nodup cardinalities).