The areas / V32. Logic, model theory and computability
Mathlib.ModelTheory.Arithmetic.Presburger.Semilinear.Basic
16 declarations and 2 deprecated aliases. Mathlib docs · Source
Semilinear sets are closed under intersection, set difference and complement
This file proves that the semilinear sets in any commutative monoid are closed under intersection
and set difference. They are also closed under complement if the monoid is finitely generated. We
prove these results on ℕ ^ k first (which are private APIs in this file) and then generalize to
any commutative monoid.
Main Results
isSemilinearSet_setOfPred_eq: the set of solutions to a linear equationa + f x = b + g yis semilinear.IsSemilinearSet.inter,IsSemilinearSet.diff: semilinear sets are closed under intersection and set difference.IsSemilinearSet.compl: semilinear sets in a finitely generated commutative monoid are closed under complement.
References
- [Seymour Ginsburg and Edwin H. Spanier, Bounded ALGOL-Like Languages][ginsburg1964]
- [Samuel Eilenberg and M. P. Schützenberger, Rational Sets in Commutative Monoids][eilenberg1969]
Semilinearity from slice property
A set s is said to have slice property if a + b + c ∈ s whenever a ∈ s, a + b ∈ s and
a + c ∈ s. In ℕ ^ k, any set that has slice property is a semilinear set. This is an important
lemma to prove the semilinearity of linear equation solutions.
Semilinearity of linear equations and preimages
Semilinear sets are included in finitely generated submonoids
Semilinearity of intersection
Semilinearity of complement and set difference
We first show that the complement of a proper linear set s in ℕ ^ k is semilinear, through
several private definitions:
base,periods: the base vector and the set of periods of the proper linear sets.basisSet,basis: the linearly independent periods ofscan be extended to a basis ofℚ ^ k.fundamentalDomain: the set of vectors inℕ ^ k, starting frombase, with coordinates underbasisin[0, 1) ^ k.floor,fract: every vector inℕ ^ kcan be decomposed into aℤ-linear combination ofbasisSetand a vector infundamentalDomain.setOfFractNe,setOfFloorNeg,setOfFloorPos: the complement ofsis decomposed into three semilinear sets.
Closure of semilinear sets under complement and set difference follows.
theorem AddSubmonoid.inclusion.congr_simp E1 #
∀ {M : Type u_1} [inst : AddZeroClass M] {S T : AddSubmonoid M} (h : S ≤ T),
AddSubmonoid.inclusion h = AddSubmonoid.inclusion h
theorem isSemilinearSet_setOfPred_eq E3 #
∀ {M : Type u_1} {N : Type u_2} [inst : AddCommMonoid M] [inst_1 : AddCommMonoid N] [AddMonoid.FG M] {F : Type u_5}
{G : Type u_6} [inst_3 : FunLike F M N] [AddMonoidHomClass F M N] [inst_5 : FunLike G M N] [AddMonoidHomClass G M N]
(a b : N) (f : F) (g : G), IsSemilinearSet {x | a + f x = b + g x}
The set of solutions to a linear equation a + f x = b + g y in a finitely generated monoid is
semilinear.
theorem Nat.isSemilinearSet_setOfPred_mulVec_eq E0 #
∀ {ι : Type u_3} {κ : Type u_4} [inst : Fintype κ] (u v : ι → ℕ) (A B : Matrix ι κ ℕ),
IsSemilinearSet {x | u + A.mulVec x = v + B.mulVec x}
Matrix version of isSemilinearSet_setOfPred_eq.
theorem isLinearSet_iff_exists_fin_addMonoidHom E1 #
∀ {M : Type u_1} [inst : AddCommMonoid M] {s : Set M}, IsLinearSet s ↔ ∃ a n f, s = a +ᵥ Set.range ⇑f
theorem Nat.isLinearSet_iff_exists_matrix E1 #
∀ {ι : Type u_3} {s : Set (ι → ℕ)}, IsLinearSet s ↔ ∃ v n A, s = {x | ∃ x_1, v + A.mulVec x_1 = x}
theorem IsSemilinearSet.preimage E1 #
∀ {M : Type u_1} {N : Type u_2} [inst : AddCommMonoid M] [inst_1 : AddCommMonoid N] [AddMonoid.FG M] {F : Type u_5}
[inst_3 : FunLike F M N] [AddMonoidHomClass F M N] {s : Set N},
IsSemilinearSet s → ∀ (f : F), IsSemilinearSet (⇑f ⁻¹' s)
The preimage of a semilinear set under a homomorphism in a finitely generated monoid is semilinear.
theorem IsLinearSet.exists_fg_eq_subtypeVal E1 #
∀ {M : Type u_1} [inst : AddCommMonoid M] {s : Set M},
IsLinearSet s → ∃ P s', P.FG ∧ IsLinearSet s' ∧ s = Subtype.val '' s'
theorem IsSemilinearSet.exists_fg_eq_subtypeVal E1 #
∀ {M : Type u_1} [inst : AddCommMonoid M] {s : Set M},
IsSemilinearSet s → ∃ P s', P.FG ∧ IsSemilinearSet s' ∧ s = Subtype.val '' s'
theorem IsSemilinearSet.exists_fg_eq_subtypeVal₂ E1 #
∀ {M : Type u_1} [inst : AddCommMonoid M] {s₁ s₂ : Set M},
IsSemilinearSet s₁ →
IsSemilinearSet s₂ →
∃ P s₁' s₂', P.FG ∧ IsSemilinearSet s₁' ∧ s₁ = Subtype.val '' s₁' ∧ IsSemilinearSet s₂' ∧ s₂ = Subtype.val '' s₂'
theorem IsSemilinearSet.inter E3 #
∀ {M : Type u_1} [inst : AddCommMonoid M] {s₁ s₂ : Set M},
IsSemilinearSet s₁ → IsSemilinearSet s₂ → IsSemilinearSet (s₁ ∩ s₂)
Semilinear sets are closed under intersection.
theorem IsSemilinearSet.sInter E1 #
∀ {M : Type u_1} [inst : AddCommMonoid M] [AddMonoid.FG M] {S : Set (Set M)},
S.Finite → (∀ s ∈ S, IsSemilinearSet s) → IsSemilinearSet (⋂₀ S)
theorem IsSemilinearSet.iInter E1 #
∀ {M : Type u_1} {ι : Type u_3} [inst : AddCommMonoid M] [AddMonoid.FG M] [Finite ι] {s : ι → Set M},
(∀ (i : ι), IsSemilinearSet (s i)) → IsSemilinearSet (⋂ i, s i)
theorem IsSemilinearSet.biInter E1 #
∀ {M : Type u_1} {ι : Type u_3} [inst : AddCommMonoid M] [AddMonoid.FG M] {s : Set ι} {t : ι → Set M},
s.Finite → (∀ i ∈ s, IsSemilinearSet (t i)) → IsSemilinearSet (⋂ i ∈ s, t i)
theorem IsSemilinearSet.biInter_finset E1 #
∀ {M : Type u_1} {ι : Type u_3} [inst : AddCommMonoid M] [AddMonoid.FG M] {s : Finset ι} {t : ι → Set M},
(∀ i ∈ s, IsSemilinearSet (t i)) → IsSemilinearSet (⋂ i ∈ s, t i)
theorem IsSemilinearSet.sdiff E1 #
∀ {M : Type u_1} [inst : AddCommMonoid M] {s₁ s₂ : Set M},
IsSemilinearSet s₁ → IsSemilinearSet s₂ → IsSemilinearSet (s₁ \ s₂)
Semilinear sets are closed under set difference.
theorem IsSemilinearSet.compl E3 #
∀ {M : Type u_1} [inst : AddCommMonoid M] {s : Set M} [AddMonoid.FG M], IsSemilinearSet s → IsSemilinearSet sᶜ
Semilinear sets in a finitely generated monoid are closed under complement.
Deprecated aliases
| Name | New name | Since |
|---|---|---|
Nat.isSemilinearSet_setOf_mulVec_eq | Nat.isSemilinearSet_setOfPred_mulVec_eq | 2026-07-09 |
isSemilinearSet_setOf_eq | isSemilinearSet_setOfPred_eq | 2026-07-09 |