Union-closed families, occurrences, density, nondegeneracy
DefinitionTenChallenges_UnionClosedThe definitions behind Challenge 9 of the Ten Challenges benchmark, for a finite family of finite subsets of a type .
- Union-closed. whenever .
- Occurrences. is the number of members of containing .
- Density. , a rational number; for nonempty this is the fraction of members containing .
- Nondegenerate. and , the two union-closed families excluded from the conjecture.
Formalization Note. Families are Finset (Finset U) with [DecidableEq U]; the density is a quotient in ℚ, with the denominator avoiding division by zero.
import Mathlib.Data.Finset.Card
import Mathlib.Algebra.Order.Ring.Unbundled.Rat
variable {U : Type*} [DecidableEq U] (F : Finset (Finset U))
/-- A finite family of finite sets is union-closed. -/
def IsUnionClosed : Prop :=
∀ ⦃A B : Finset U⦄, A ∈ F → B ∈ F → A ∪ B ∈ F
/-- The number of members of the family containing `x`. -/
def occurrences (x : U) : ℕ :=
(F.filter fun A => x ∈ A).card
/-- The density of an element with respect to a finite family. -/
def density (x : U) : ℚ :=
(occurrences F x : ℚ) / max 1 F.card
/-- The two degenerate families excluded from the union-closed sets conjecture. -/
def Nondegenerate : Prop :=
F ≠ ∅ ∧ F ≠ {∅}
Read-back
What the Lean code literally says, in plain math · claude-fable-5-1
Setting shared by all four definitions. Throughout, is an arbitrary type (any collection of "elements": finite or infinite, possibly empty; it lives in an arbitrary but fixed universe), and is a finite set whose members are finite subsets of , i.e. a finite family of finite sets with no repeated members. The first three definitions additionally assume that carries a decidable equality (a procedure deciding whether two given elements of are equal); this is an extra parameter of those definitions. Write for the number of members of .
Definition IsUnionClosed (" is union-closed") is the proposition
Here and range over all finite subsets of (the hypotheses , then restrict them), and is allowed. Nothing requires to be nonempty, to contain , to contain the whole union of its members, or to be closed under intersection. Edge cases: the empty family satisfies this vacuously; the family satisfies it; every one-member family satisfies it.
Definition occurrences assigns to the natural number
the number of members of that contain . It is when no member of contains (in particular for every when ), and it is at most .
Definition density assigns to the rational number
where the numerator and the denominator are natural numbers (the maximum is taken among natural numbers) viewed as rationals. The denominator is always , so this is an ordinary quotient and the "division by zero gives zero" convention of the rationals is never invoked. If this equals , a rational in (the fraction of members of containing ); if it equals for every .
Definition Nondegenerate (" is nondegenerate") is the proposition
i.e. is neither the empty family nor the family whose only member is the empty set. (This definition takes no decidable-equality assumption.) It does not say that , and it does not require to have two or more members: for example with , and with , are both nondegenerate. Literally, the condition is equivalent to " has at least one member that is a nonempty set"; in particular a nondegenerate can only exist when has at least one element (if is empty, every is or ).
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.