Use this theorem
Create a project
lake +leanprover/lean4:v4.35.0 new myproject std.toml cd myprojectStandard template, not
math: themathtemplate adds its own Mathlib requirement pinned to the Lean release tag, not to the Mathlib commit this package is built and tested with, so you would get a second, different Mathlib. Mathlib comes in through this package. Skip this step in an existing project with the same Lean and Mathlib.Add the dependency to
lakefile.toml[[require]] name = "formalizations" git = "https://github.com/karlesmarin/formalizations" rev = "v0.15.0"Import the minimal module
import Formalizations.Reusable.CombinatoricsIn a file of the project, e.g.
Example.lean.Paste the example
open Formalizations.Reusable Filter Topology Classical /-- The Hall deficiency `δ(s) = |s| − |s.biUnion t|` is supermodular (the inequality behind the Kőnig–Ore deficiency formula). -/ example (t : ℕ → Finset ℕ) (s u : Finset ℕ) : ((s.card : ℤ) - (s.biUnion t).card) + ((u.card : ℤ) - (u.biUnion t).card) ≤ (((s ∪ u).card : ℤ) - ((s ∪ u).biUnion t).card) + (((s ∩ u).card : ℤ) - ((s ∩ u).biUnion t).card) := by have h1 := card_biUnion_submodular t s u have h2 := Finset.card_union_add_card_inter s u omegaSteps 3 and 4 together are a complete Lean file:
FormalizationsTest/ReusableCombinatoricsExample.leanat v0.15.0, compiled by the CI.Fetch and check
lake update lake lean Example.leanlake updatefetches this package and Mathlib, and Mathlib's update hook downloads the compiled Mathlib (lake exe cache get).lake lean Example.leanbuilds the imports of the file (steps 3 and 4) and checks it. If the file belongs to alean_libof your project,lake build <lib>does the same. Avoid a barelake buildin a project from the standard template: its default target is the executable, whose link compiles every imported Mathlib module to native code. Same versions required: Leanv4.35.0, Mathlibf0b4c81.
Alternative: import Formalizations.Reusable imports the whole layer (all areas).
For an indexed family of finite sets t, the neighbourhood function s ↦ |s.biUnion t| is submodular: |N(s ∪ u)| + |N(s ∩ u)| ≤ |N(s)| + |N(u)|.
Lean statement
theorem card_biUnion_submodular {ι α : Type*} [DecidableEq ι] [DecidableEq α]
(t : ι → Finset α) (s u : Finset ι) :
((s ∪ u).biUnion t).card + ((s ∩ u).biUnion t).card ≤ (s.biUnion t).card + (u.biUnion t).cardLinks
Lean docstring
The neighbourhood function of a set family is submodular. For an indexed family of finite sets t : ι → Finset α and s u : Finset ι, with N(s) = s.biUnion t (the union of the t i, i ∈ s): |N(s ∪ u)| + |N(s ∩ u)| ≤ |N(s)| + |N(u)|. It is the inequality behind the deficiency form of Hall's theorem (Kőnig–Ore) and behind the transversal matroid.
- Archive:
Finset.card_biUnion_union_add_card_biUnion_inter_le(Formalizations.Combinatorics.Hall.Tight, which imports onlyMathlib.Combinatorics.Hall.Finite); the module cites no paper DOI of ours. Mathlib proves Hall's theorem by another induction and has no tight-set lemmas. - Classical reference: L. Lovász, M. D. Plummer, Matching Theory (1986), ch. 1.
- Example: for
t i = {i, i + 1}onℕ,s = {0},u = {1}, it reads3 + 0 ≤ 2 + 2.
Upstream
a short Finset lemma next to Mathlib.Combinatorics.Hall.Finite, which has no tight-set lemmas
Depends on, in this repository
None besides the archive module (repo_dependencies = []).