Mathlib theorem · Existing formal mathematics

Existing in Mathlib · Combinatorics

Inclusion–Exclusion Principle

To count a finite union exactly, add the sizes of the individual sets, subtract the sizes of all pairwise intersections, add the triple intersections, and continue alternating over every nonempty chosen subfamily.

Exact theorem

Exact Mathlib statement

theorem Finset.inclusion_exclusion_card_biUnion {ι α : Type*} [DecidableEq α]
    (s : Finset ι) (S : ι → Finset α) :
    #(s.biUnion S) = ∑ t : s.powerset.filter (·.Nonempty),
      (-1 : ℤ) ^ (#t.1 + 1) * #(t.1.inf' (mem_filter.1 t.2).2 S)

The theorem at a glance

Inclusion–exclusion at a glance

A visual guide to the theorem's hypotheses, structure, and conclusion; the exact statement gives the formal detail.

The cardinality of a finite union is recovered by alternating over the cardinalities of all nonempty subfamily intersections. Explanatory diagram.
Detailed visual description

The poster gives the exact three-set inclusion–exclusion identity as a readable representative of the general finite-family theorem. Seven patterned tokens occupy the seven nonempty Venn regions, while adjacent singleton, pair, and triple region shapes encode the add-subtract-add parity. Its route summary identifies the indicator expansion, parity by subfamily size, and specialization of the general sum identity at f = 1.

Statement structure

Statement and scope

Statement map for Inclusion–Exclusion PrincipleA finite union's cardinality is the alternating sum of the cardinalities of all nonempty subfamily intersections. Claim boundary: This page indexes Mathlib's finite-cardinality inclusion–exclusion theorem for a finite index Finset s and a family S : ι → Finset α. It sums the cardinalities of the intersections indexed by every nonempty subfamily t of s with sign (-1)^(|t|+1) to recover #(s.biUnion S). It is not the nearby theorem for weighted sums, complements, measures, integrals, infinite families, or truncated Bonferroni bounds. The pinned upstream declaration is Finset.inclusion_exclusion_card_biUnion. The complete formal statement is available in the Exact Mathlib statement section.Mathematical readingA finite union'scardinality is thealternating sum of thecardinalities of allnonempty subfamilyintersections.Claim boundaryThis page indexesMathlib'sfinite-cardinalityinclusion–exclusiontheorem for a finiteindex Finset s and afamily S : ι → Finset α.It sums thecardinalities of theintersections indexed byevery nonempty subfamilyt of s with sign(-1)^(|t|+1) to recover#(s.biUnion S). It isnot the nearby theoremfor weighted sums,complements, measures,integrals, infinitefamilies, or truncatedBonferroni bounds.Pinned declarationmathlib ·Finset.inclusion_exclusion_card_biUnionStatement map for Inclusion–Exclusion PrincipleA finite union's cardinality is the alternating sum of the cardinalities of all nonempty subfamily intersections. Claim boundary: This page indexes Mathlib's finite-cardinality inclusion–exclusion theorem for a finite index Finset s and a family S : ι → Finset α. It sums the cardinalities of the intersections indexed by every nonempty subfamily t of s with sign (-1)^(|t|+1) to recover #(s.biUnion S). It is not the nearby theorem for weighted sums, complements, measures, integrals, infinite families, or truncated Bonferroni bounds. The pinned upstream declaration is Finset.inclusion_exclusion_card_biUnion. The complete formal statement is available in the Exact Mathlib statement section.Mathematical readingA finite union'scardinality is thealternating sum of thecardinalities of allnonempty subfamilyintersections.Claim boundaryThis page indexesMathlib'sfinite-cardinalityinclusion–exclusiontheorem for a finiteindex Finset s and afamily S : ι → Finset α.It sums thecardinalities of theintersections indexed byevery nonempty subfamilyt of s with sign(-1)^(|t|+1) to recover#(s.biUnion S). It isnot the nearby theoremfor weighted sums,complements, measures,integrals, infinitefamilies, or truncatedBonferroni bounds.Pinned declarationmathlib ·Finset.inclusion_exclusion_card_biUnion

Read the exact Mathlib declaration

This map summarizes the statement's structure; the exact Mathlib declaration remains authoritative.

The representative three-set geometry shows how singleton contributions, pair corrections, and the restored triple overlap count every union region once. Explanatory scientific diagram.
Detailed visual description

Three overlapping blue, green, and gold enclosures form exactly seven nonempty regions, each carrying one texture: dots, horizontal stripes, vertical dashes, diagonal hatch, waves, grid, or concentric rings. A central lattice has three singleton nodes, three pair nodes, and one triple node. All six containing incidences are present: each singleton connects to exactly its two pair nodes, and every pair connects by a dashed arrow to the triple. A braided three-color strand and outer flows lead to one final enclosure containing the same seven textures exactly once. No empty-subfamily node or operator glyph appears.

Why it matters

A mathematical landmark

Inclusion–exclusion is one of the central counting principles of combinatorics. Mathlib's selected theorem exposes its full finite-family structure directly: the powerset of the index set organizes every nonempty intersection, and the parity of subfamily size controls the exact correction.

ProofAtlas record

What has been checked

Upstream indexedPinned source bytes verified locally
Locally reproducedExact upstream declaration replayed
Reviewed pageCurrent public presentation reviewed
Accepted Atlas resultNot recorded for the preferred artifact

Mathlib is the source of the theorem; the local Lean replay and page review are separate.

Claim boundary

No new theorem is claimed

This page indexes Mathlib's finite-cardinality inclusion–exclusion theorem for a finite index Finset s and a family S : ι → Finset α. It sums the cardinalities of the intersections indexed by every nonempty subfamily t of s with sign (-1)^(|t|+1) to recover #(s.biUnion S). It is not the nearby theorem for weighted sums, complements, measures, integrals, infinite families, or truncated Bonferroni bounds.

Source and local evidence

Where the theorem comes from

Existing declaration
Finset.inclusion_exclusion_card_biUnion in mathlib
Relationship
The checked artifact is the upstream declaration itself
Local Lean evidence
artifact.library.mathlib.inclusion-exclusion-principle.v001
Source
Open the pinned upstream reference