{
  "artifactId": "artifact.library.mathlib.inclusion-exclusion-principle.v001",
  "candidateOnly": false,
  "category": "Combinatorics",
  "claimBoundary": "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.",
  "collectionSlug": "landmark-theorems-in-mathlib",
  "exactFormalStatement": "theorem Finset.inclusion_exclusion_card_biUnion {ι α : Type*} [DecidableEq α]\n    (s : Finset ι) (S : ι → Finset α) :\n    #(s.biUnion S) = ∑ t : s.powerset.filter (·.Nonempty),\n      (-1 : ℤ) ^ (#t.1 + 1) * #(t.1.inf' (mem_filter.1 t.2).2 S)",
  "family": "Enumerative combinatorics",
  "id": "library.mathlib.inclusion-exclusion-principle.v001",
  "links": {
    "collection": "/collections/landmark-theorems-in-mathlib/",
    "collectionData": "/data/collections/mathlib-landmarks.json",
    "entry": "/library-theorems/inclusion-exclusion-principle/",
    "entryData": "/data/library-theorems/inclusion-exclusion-principle.json",
    "evidence": "/proofs/artifact.library.mathlib.inclusion-exclusion-principle.v001.html",
    "evidenceData": "/data/proofs/artifact.library.mathlib.inclusion-exclusion-principle.v001.evidence.json",
    "source": "/sources/upstream/inclusion-exclusion-principle/"
  },
  "landmark": {
    "completeFormalType": "theorem Finset.inclusion_exclusion_card_biUnion {ι α : Type*} [DecidableEq α]\n    (s : Finset ι) (S : ι → Finset α) :\n    #(s.biUnion S) = ∑ t : s.powerset.filter (·.Nonempty),\n      (-1 : ℤ) ^ (#t.1 + 1) * #(t.1.inf' (mem_filter.1 t.2).2 S)",
    "concepts": [
      "finite unions",
      "finite intersections",
      "alternating sums",
      "powersets",
      "cardinality",
      "indicator functions"
    ],
    "plainLanguage": "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.",
    "poster": {
      "alt": "An ivory inclusion–exclusion poster states the three-set cardinality identity above seven patterned tokens, one in each Venn region, and an unlabeled plus-minus-plus correction stack.",
      "byteSize": 2518214,
      "caption": "The cardinality of a finite union is recovered by alternating over the cardinalities of all nonempty subfamily intersections.",
      "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.",
      "derivatives": [
        {
          "byteSize": 98914,
          "height": 960,
          "mediaType": "image/webp",
          "publicPath": "/assets/library-theorems/inclusion-exclusion-principle/theorem-poster-v1-640.webp",
          "sha256": "sha256:bf03cb100116b0f10e4a11e57f486bc199d8317448647295f17362cd895810ff",
          "width": 640
        },
        {
          "byteSize": 204074,
          "height": 1536,
          "mediaType": "image/webp",
          "publicPath": "/assets/library-theorems/inclusion-exclusion-principle/theorem-poster-v1-1024.webp",
          "sha256": "sha256:9ac44593615691071f09fbf4f2025be52e4b7859b147d69108ddabb5acb09537",
          "width": 1024
        }
      ],
      "generatedAt": "2026-07-27T10:44:59-04:00",
      "height": 1536,
      "mediaType": "image/png",
      "modelRequested": "gpt-image-2",
      "publicPath": "/assets/library-theorems/inclusion-exclusion-principle/theorem-poster-v1.png",
      "sha256": "sha256:30746a2d6a8533b8f81cafae619aa64c024a92c8a608c9878666e3a8f46cd574",
      "title": "Inclusion–exclusion at a glance",
      "width": 1024,
      "kind": "theorem_poster",
      "transcript": "COMBINATORICS · FINITE SETS\nINCLUSION–EXCLUSION\n|A ∪ B ∪ C|\n= |A| + |B| + |C|\n− |A ∩ B| − |A ∩ C| − |B ∩ C|\n+ |A ∩ B ∩ C|\nCOUNT EVERY ELEMENT EXACTLY ONCE\nHOW THE CHECKED ROUTE MOVES\nExpand membership indicators over nonempty subfamilies\nAlternate by the size of each chosen subfamily\nSet f = 1 so every intersection sum becomes a cardinality\nEXACT SCOPE\nFinite index set and finite sets. All nonempty intersections participate."
    },
    "visual": {
      "alt": "Three overlapping engraved set enclosures hold seven uniquely patterned medallions, one per Venn region; plus-minus-plus correction traces lead to one union enclosure containing the same seven patterns exactly once.",
      "byteSize": 3250408,
      "caption": "Alternating singleton, pair, and triple corrections ensure that every element of a finite union is counted exactly once.",
      "description": "A dark engraved landscape uses one patterned medallion per nonempty region of a representative three-set Venn diagram. Translucent echoes organize the singleton, pair-intersection, and triple-intersection corrections, while the final union preserves all seven identities exactly once. The representative three-set geometry expresses the general parity mechanism without limiting the theorem to three sets.",
      "derivatives": [
        {
          "byteSize": 43234,
          "height": 427,
          "mediaType": "image/webp",
          "publicPath": "/assets/library-theorems/inclusion-exclusion-principle/theorem-schematic-v1-640.webp",
          "sha256": "sha256:0ea91ab1bff5fe70c3509b2fc38f3bae298be935b08ea6baa0b21b81f80744ea",
          "width": 640
        },
        {
          "byteSize": 180674,
          "height": 800,
          "mediaType": "image/webp",
          "publicPath": "/assets/library-theorems/inclusion-exclusion-principle/theorem-schematic-v1-1200.webp",
          "sha256": "sha256:b9e557a2f5831a4d8842e0951cc02bcefbeee6a459d33d948ba620d1d5369dbc",
          "width": 1200
        }
      ],
      "generatedAt": "2026-07-27T10:44:59-04:00",
      "height": 1024,
      "mediaType": "image/png",
      "modelRequested": "gpt-image-2",
      "publicPath": "/assets/library-theorems/inclusion-exclusion-principle/theorem-schematic-v1.png",
      "sha256": "sha256:e9c7999c9bd8713534d538206aabf873c32885ea0964d989a37c347186c05de4",
      "title": "Alternating corrections recover the finite union",
      "width": 1536
    },
    "walkthrough": null,
    "whyLandmark": "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."
  },
  "nonClaims": [
    "The selected declaration concerns the cardinality of a finite union of finite sets; it does not state the nearby weighted-sum or complement variants.",
    "The theorem sums over every nonempty subfamily, so the alternating correction does not stop after pairwise or triple intersections in a larger family.",
    "The selected declaration does not assert a measure, integral, probability, infinite-family, or truncated Bonferroni formula.",
    "The three-set diagrams are finite representatives of the general Finset-indexed statement, not a restriction of the theorem to exactly three sets.",
    "ProofAtlas is indexing an existing Mathlib theorem, and generated explanations and visuals are not proof evidence."
  ],
  "publicExportEligible": true,
  "relationship": "upstream_direct",
  "schemaVersion": "library-theorem-entry-data.v1",
  "statementId": "statement.library.mathlib.inclusion-exclusion-principle.v001",
  "statusAxes": {
    "acceptedAtlasResult": "Not recorded for the preferred artifact",
    "locallyReproduced": "Exact upstream declaration replayed",
    "reviewedPage": "Current public presentation reviewed",
    "upstreamIndexed": "Pinned source bytes verified locally"
  },
  "summary": "A finite union's cardinality is the alternating sum of the cardinalities of all nonempty subfamily intersections.",
  "targetId": "target.library.mathlib.inclusion-exclusion-principle.v001",
  "title": "Inclusion–Exclusion Principle",
  "upstreamOrigin": {
    "declarationName": "Finset.inclusion_exclusion_card_biUnion",
    "immutableSourceUrl": "https://github.com/leanprover-community/mathlib4/blob/5e932f97dd25535344f80f9dd8da3aab83df0fe6/Mathlib/Combinatorics/Enumerative/InclusionExclusion.lean#L153",
    "packageName": "mathlib",
    "repositoryUrl": "https://github.com/leanprover-community/mathlib4",
    "sourceArtifactHash": "sha256:fe311ef00fbd82eac7832b308b04d5054edee2cec0ba25a6bf60abeb68918f9b",
    "sourceByteLength": 9025,
    "sourceCommit": "5e932f97dd25535344f80f9dd8da3aab83df0fe6",
    "sourceFile": "Mathlib/Combinatorics/Enumerative/InclusionExclusion.lean",
    "sourceLine": 153,
    "verificationKind": "git_worktree"
  },
  "publicPresentationReview": {
    "status": "reviewed"
  }
}
