Counting exact covers, packings, set covers, and hitting sets
Lax280166.CountingSetFamilies · concepts/Lax280166/CountingSetFamilies.lean · lax-280166
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Definition
The instances are set systems: a universe of elements, a family of sets, and a membership relation, with a marked threshold where a size is asked. #Exact Cover counts the subfamilies covering every element exactly once. #Set Packing counts the subfamilies of pairwise disjoint sets of exactly the threshold size, #Set Cover the covering subfamilies of exactly the threshold size, and #Hitting Set the sets of elements of exactly the threshold size meeting every set of the family.
Concept map
Lean source view on GitHub
| 1 | import Mathlib.Tactic.FinCases |
| 2 | import Mathlib.Order.PiLex |
| 3 | import Mathlib.Data.Prod.Lex |
| 4 | import Mathlib.Data.Fintype.EquivFin |
| 5 | import Mathlib.ModelTheory.Order |
| 6 | import Mathlib.ModelTheory.Semantics |
| 7 | import Mathlib.ModelTheory.Complexity |
| 8 | import Mathlib.Logic.Equiv.Fin.Basic |
| 9 | import Mathlib.Data.Fintype.Lattice |
| 10 | import Mathlib.Data.Finite.Sigma |
| 11 | import Mathlib.Order.Lattice.Nat |
| 12 | import Mathlib.Data.Set.Card |
| 13 | import Mathlib.Data.Fintype.Pigeonhole |
| 14 | import Mathlib.Dynamics.FixedPoints.Basic |
| 15 | import Mathlib.ModelTheory.Syntax |
| 16 | import Mathlib.Algebra.Order.BigOperators.Group.Finset |
| 17 | import Mathlib.Data.Fintype.Card |
| 18 | import Mathlib.SetTheory.Cardinal.Finite |
| 19 | import Mathlib.Logic.Equiv.Prod |
| 20 | import Mathlib.Data.Set.Finite.Lemmas |
| 21 | import Mathlib.Data.Fintype.Sort |
| 22 | import Mathlib.Order.Hom.Set |
| 23 | import Lax799700.SetFamily |
| 24 | import Mathlib.SetTheory.Cardinal.Finite |
| 25 | import Lax366625.CountingProblems |
| 26 | |
| 27 | /-! |
| 28 | --- |
| 29 | title: Counting exact covers, packings, set covers, and hitting sets |
| 30 | type: definition |
| 31 | --- |
| 32 | The instances are set systems: a universe of elements, a family of sets, and |
| 33 | a membership relation, with a marked threshold where a size is asked. |
| 34 | #Exact Cover counts the subfamilies covering every element exactly once. |
| 35 | #Set Packing counts the subfamilies of pairwise disjoint sets of exactly the |
| 36 | threshold size, #Set Cover the covering subfamilies of exactly the threshold |
| 37 | size, and #Hitting Set the sets of elements of exactly the threshold size |
| 38 | meeting every set of the family. |
| 39 | -/ |
| 40 | |
| 41 | namespace Lax280166.CountingSetFamilies |
| 42 | |
| 43 | open Lax799700.SetFamily |
| 44 | |
| 45 | open FirstOrder |
| 46 | |
| 47 | open Language Structure |
| 48 | |
| 49 | section Solutions |
| 50 | |
| 51 | variable (A : Type) [setSystem.Structure A] |
| 52 | |
| 53 | /-- The subfamily `G` is a packing with exactly as many sets as the marked set, |
| 54 | in a finite set system. -/ |
| 55 | def PackingOfSize (G : A → Prop) : Prop := |
| 56 | Finite A ∧ (∀ s, G s → SSFam s) ∧ |
| 57 | (∀ s s', G s → G s' → s ≠ s' → ∀ x : A, SSElem x → ¬(SSMem x s ∧ SSMem x s')) ∧ |
| 58 | {s | G s}.ncard = {x : A | SSMarked x}.ncard |
| 59 | |
| 60 | end Solutions |
| 61 | |
| 62 | open FirstOrder |
| 63 | |
| 64 | open Language Structure |
| 65 | |
| 66 | section Generic |
| 67 | |
| 68 | variable {A B : Type} |
| 69 | |
| 70 | /-- The subfamily `G` of the `Fp`-sets covers every `Ep`-element and has |
| 71 | exactly as many members as the `Kp`-marked set. -/ |
| 72 | def CoverFamOfSizeOn (Ep Fp : A → Prop) (Mp : A → A → Prop) (Kp : A → Prop) |
| 73 | (G : A → Prop) : Prop := |
| 74 | (∀ s, G s → Fp s) ∧ (∀ x, Ep x → ∃ s, G s ∧ Mp x s) ∧ |
| 75 | {s | G s}.ncard = {x | Kp x}.ncard |
| 76 | |
| 77 | end Generic |
| 78 | |
| 79 | section Problems |
| 80 | |
| 81 | variable (A : Type) [setSystem.Structure A] |
| 82 | |
| 83 | /-- The subfamily `G` is a cover with exactly as many sets as the marked set, |
| 84 | in a finite set system. -/ |
| 85 | def SetCoverOfSize (G : A → Prop) : Prop := |
| 86 | Finite A ∧ CoverFamOfSizeOn (fun x : A => SSElem x) (fun s => SSFam s) |
| 87 | (fun x s => SSMem x s) (fun x => SSMarked x) G |
| 88 | |
| 89 | /-- The set `H` of ground elements is a hitting set with exactly as many |
| 90 | elements as the marked set, in a finite set system. -/ |
| 91 | def HittingSetOfSize (H : A → Prop) : Prop := |
| 92 | Finite A ∧ CoverFamOfSizeOn (fun s : A => SSFam s) (fun x => SSElem x) |
| 93 | (fun s x => SSMem x s) (fun x => SSMarked x) H |
| 94 | |
| 95 | end Problems |
| 96 | |
| 97 | open FirstOrder |
| 98 | |
| 99 | open Language Structure |
| 100 | |
| 101 | section Generic |
| 102 | |
| 103 | variable {A : Type} |
| 104 | |
| 105 | /-- The subfamily `G` is an exact cover: it consists of `Fp`-sets, covers every |
| 106 | `Ep`-element, and no element belongs to two distinct members. This is the body |
| 107 | of `ExactlyCoversOn`, named for the statements that are about a |
| 108 | particular cover and not only about the existence of one. -/ |
| 109 | def ExactCoverBy (Ep Fp : A → Prop) (Mp : A → A → Prop) (G : A → Prop) : Prop := |
| 110 | (∀ s, G s → Fp s) ∧ (∀ x, Ep x → ∃ s, G s ∧ Mp x s) ∧ |
| 111 | ∀ s s', G s → G s' → s ≠ s' → ∀ x, Ep x → ¬(Mp x s ∧ Mp x s') |
| 112 | |
| 113 | end Generic |
| 114 | |
| 115 | open Lax366625.CountingProblems Lax799700.SetFamily |
| 116 | |
| 117 | /-- **#Exact Cover**, as a counting problem. -/ |
| 118 | noncomputable def SharpExactCover : CountingProblem Lax799700.SetFamily.setSystem := |
| 119 | CountingProblem.ofFun fun A _ => |
| 120 | Nat.card {G : A → Prop // ExactCoverBy (SSElem (A := A)) SSFam SSMem G} |
| 121 | |
| 122 | /-- **#Set Packing**, as a counting problem. -/ |
| 123 | noncomputable def SharpSetPacking : CountingProblem Lax799700.SetFamily.setSystem := |
| 124 | CountingProblem.ofFun fun A _ => |
| 125 | Nat.card {G : A → Prop // PackingOfSize A G} |
| 126 | |
| 127 | /-- **#Set Cover**, as a counting problem. -/ |
| 128 | noncomputable def SharpSetCover : CountingProblem Lax799700.SetFamily.setSystem := |
| 129 | CountingProblem.ofFun fun A _ => |
| 130 | Nat.card {G : A → Prop // SetCoverOfSize A G} |
| 131 | |
| 132 | /-- **#Hitting Set**, as a counting problem. -/ |
| 133 | noncomputable def SharpHittingSet : CountingProblem Lax799700.SetFamily.setSystem := |
| 134 | CountingProblem.ofFun fun A _ => |
| 135 | Nat.card {H : A → Prop // HittingSetOfSize A H} |
| 136 | |
| 137 | end Lax280166.CountingSetFamilies |
| 138 |
Used by
Lax280166.CliqueCompleteLax280166.CliquesValuesLax280166.DirHamCircuitCompleteLax280166.DominatingSetCompleteLax280166.DominatingSetsValuesLax280166.ExactCoverCompleteLax280166.FeedbackArcSetCompleteLax280166.FeedbackSetsValuesLax280166.FeedbackVertexSetCompleteLax280166.HamCircuitCompleteLax280166.HamiltonCircuitsValuesLax280166.HittingSetCompleteLax280166.IndependentSetCompleteLax280166.KnapsackCompleteLax280166.KnapsacksValuesLax280166.OneInSATCompleteLax280166.SatVariantsValuesLax280166.SetCoverCompleteLax280166.SetFamiliesValuesLax280166.SetPackingCompleteLax280166.SteinerTreeCompleteLax280166.SteinerTreesValuesLax280166.ThreeSATCompleteLax280166.VertexCoverCompleteLax280166.ZeroOneIPComplete
From Mathlib
Mathlib.Algebra.Order.BigOperators.Group.FinsetMathlib.Data.Finite.SigmaMathlib.Data.Fintype.CardMathlib.Data.Fintype.EquivFinMathlib.Data.Fintype.LatticeMathlib.Data.Fintype.PigeonholeMathlib.Data.Fintype.SortMathlib.Data.Prod.LexMathlib.Data.Set.CardMathlib.Data.Set.Finite.LemmasMathlib.Dynamics.FixedPoints.BasicMathlib.Logic.Equiv.Fin.BasicMathlib.Logic.Equiv.ProdMathlib.ModelTheory.ComplexityMathlib.ModelTheory.OrderMathlib.ModelTheory.SemanticsMathlib.ModelTheory.SyntaxMathlib.Order.Hom.SetMathlib.Order.Lattice.NatMathlib.Order.PiLexMathlib.SetTheory.Cardinal.FiniteMathlib.Tactic.FinCases
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments