Skip to content

[Merged by Bors] - feat(ModelTheory): Presburger definability and semilinear sets - #27100

Closed
staroperator wants to merge 16 commits into
leanprover-community:masterfrom
staroperator:semilinear
Closed

staroperator wants to merge 16 commits into
leanprover-community:masterfrom
staroperator:semilinear

Conversation

@staroperator

@staroperator staroperator commented Jul 13, 2025 •

Copy link
Copy Markdown
Collaborator

@github-actions

github-actions Bot commented Jul 13, 2025 •

Copy link
Copy Markdown

PR summary f821781ed2

Import changes exceeding 2%

% File
+15.44% Mathlib.ModelTheory.Arithmetic.Presburger.Semilinear.Defs

Import changes for modified files

Dependency changes

File Base Count Head Count Change
Mathlib.ModelTheory.Arithmetic.Presburger.Semilinear.Defs 881 1017 +136 (+15.44%)
Import changes for all files
Files Import difference
Mathlib.ModelTheory.Arithmetic.Presburger.Semilinear.Basic 7
Mathlib.ModelTheory.Arithmetic.Presburger.Semilinear.Defs 136
Mathlib.ModelTheory.Arithmetic.Presburger.Definability (new file) 1293

Declarations diff

+ IsLinearSet.definable
+ IsSemilinearSet.definable
+ Nat.isSemilinearSet_iff_ultimately_periodic
+ definable_iff_isSemilinearSet
+ definable₁_iff_ultimately_periodic
+ isProperSemilinearSet_iff
+ isSemilinearSet_boundedFormula_realize
+ isSemilinearSet_formula_realize_semilinear
+ isSemilinearSet_iff
+ mul_not_definable
+ term_realize_eq_add_dotProduct

You can run this locally as follows
## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>

## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>

The doc-module for script/declarations_diff.sh contains some details about this script.


No changes to technical debt.

You can run this locally as

./scripts/technical-debt-metrics.sh pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

@mathlib4-dependent-issues-bot mathlib4-dependent-issues-bot added the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Jul 13, 2025
@staroperator staroperator added the t-logic Logic (model theory, etc) label Jul 14, 2025
@leanprover-community-bot-assistant leanprover-community-bot-assistant added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Jul 14, 2025
@leanprover-community-bot-assistant

Copy link
Copy Markdown
Contributor

This pull request has conflicts, please merge master and resolve them.

@github-actions github-actions Bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Jul 14, 2025
mathlib-bors Bot pushed a commit that referenced this pull request Jul 22, 2025
This PR introduces the first-order language of [Presburger Arithmetic](https://en.wikipedia.org/wiki/Presburger_arithmetic). It has not defined the theory of Presburger Arithmetic yet (left as TODO), but is enough to prove some definability results (#27100).



Co-authored-by: staroperator <[email protected]>
@leanprover-community-bot-assistant leanprover-community-bot-assistant added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Jul 22, 2025
@leanprover-community-bot-assistant

Copy link
Copy Markdown
Contributor

This pull request has conflicts, please merge master and resolve them.

@github-actions github-actions Bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Jul 24, 2025
callesonne pushed a commit to callesonne/mathlib4 that referenced this pull request Jul 24, 2025
…community#27099)

This PR introduces the first-order language of [Presburger Arithmetic](https://en.wikipedia.org/wiki/Presburger_arithmetic). It has not defined the theory of Presburger Arithmetic yet (left as TODO), but is enough to prove some definability results (leanprover-community#27100).



Co-authored-by: staroperator <[email protected]>
@leanprover-community-bot-assistant

Copy link
Copy Markdown
Contributor

This pull request has conflicts, please merge master and resolve them.

@leanprover-community-bot-assistant leanprover-community-bot-assistant added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Jul 26, 2025
@github-actions github-actions Bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Jul 27, 2025
hrmacbeth pushed a commit to szqzs/mathlib4 that referenced this pull request Jul 28, 2025
…community#27099)

This PR introduces the first-order language of [Presburger Arithmetic](https://en.wikipedia.org/wiki/Presburger_arithmetic). It has not defined the theory of Presburger Arithmetic yet (left as TODO), but is enough to prove some definability results (leanprover-community#27100).



Co-authored-by: staroperator <[email protected]>
Equilibris pushed a commit to Equilibris/mathlib4 that referenced this pull request Aug 7, 2025
…community#27099)

This PR introduces the first-order language of [Presburger Arithmetic](https://en.wikipedia.org/wiki/Presburger_arithmetic). It has not defined the theory of Presburger Arithmetic yet (left as TODO), but is enough to prove some definability results (leanprover-community#27100).



Co-authored-by: staroperator <[email protected]>
@mathlib4-merge-conflict-bot mathlib4-merge-conflict-bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Aug 11, 2025
@mathlib4-merge-conflict-bot

Copy link
Copy Markdown

This pull request has conflicts, please merge master and resolve them.

mathlib-bors Bot pushed a commit that referenced this pull request Sep 17, 2025
joelriou pushed a commit to joelriou/mathlib4 that referenced this pull request Oct 2, 2025
zhuyizheng pushed a commit to zhuyizheng/mathlib4 that referenced this pull request Oct 2, 2025
@mathlib4-dependent-issues-bot mathlib4-dependent-issues-bot added blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) and removed blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) labels Oct 25, 2025
mathlib-bors Bot pushed a commit that referenced this pull request Nov 24, 2025
…ference and complement (#27414)

Separated from #27100. This PR proves that semilinear sets in any commutative monoid are closed under intersection, set difference and complement (requires finitely generated). We prove these results on `ℕ ^ k` first (which are private) and then generalize to any monoid.
@mathlib4-dependent-issues-bot mathlib4-dependent-issues-bot removed the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Nov 24, 2025
@github-actions github-actions Bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Nov 24, 2025

@awainverse awainverse left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, except for a comment about splitting a theorem with a large proof.


/-- In the 1-dimensional case, a set is Presburger arithmetic definable in `ℕ` if and only if it
is ultimately periodic, i.e. periodic after some number `k`. -/
theorem definable₁_iff_ultimately_periodic {s : Set ℕ} :

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd break this result up slightly, spinning off the first few lines, because the vast majority of the proof is just about semilinear sets.
Since we already have files about semilinear sets, the second lemma can be moved into one of those, provided the imports are changed accordingly.

First lemma:

    A.Definable₁ presburger s ↔ IsSemilinearSet s := by
  rw [Definable₁, definable_iff_isSemilinearSet,
    ← isSemilinearSet_image_iff (LinearEquiv.funUnique (Fin 1) ℕ ℕ), ← preimage_setOf_eq]
  simp only [LinearEquiv.funUnique_apply, Function.eval, Fin.default_eq_zero, setOf_mem_eq]
  rw [image_preimage_eq s fun x => ⟨![x], rfl⟩]```

Second lemma:
```lemma isSemilinearSet_iff_ultimately_periodic {s : Set ℕ} :
    IsSemilinearSet s ↔ ∃ k, ∃ p > 0, ∀ x ≥ k, x ∈ s ↔ x + p ∈ s := by```

Then this theorem can be
```/-- In the 1-dimensional case, a set is Presburger arithmetic definable in `ℕ` if and only if it
  is ultimately periodic, i.e. periodic after some number `k`. -/
theorem definable₁_iff_ultimately_periodic {s : Set ℕ} :
    A.Definable₁ presburger s ↔ ∃ k, ∃ p > 0, ∀ x ≥ k, x ∈ s ↔ x + p ∈ s := by
  rw [definable₁_iff_isSemilinearSet, isSemilinearSet_iff_ultimately_periodic]```

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. Thanks!

@github-actions github-actions Bot added the large-import Automatically added label for PRs with a significant increase in transitive imports label Jan 29, 2026

@awainverse awainverse left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My suggested changes were implemented well, this looks good to me.

@awainverse

Copy link
Copy Markdown
Contributor

maintainer merge

@github-actions

Copy link
Copy Markdown

🚀 Pull request has been placed on the maintainer queue by awainverse.

@mathlib-triage mathlib-triage Bot added the maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. label Feb 17, 2026
@fpvandoorn

Copy link
Copy Markdown
Member

Thank you!

LGTM

bors merge

@mathlib-triage mathlib-triage Bot added ready-to-merge This PR has been sent to bors. and removed maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. labels Feb 19, 2026
mathlib-bors Bot pushed a commit that referenced this pull request Feb 19, 2026
This PR formalizes the classical result that Presburger definable sets are the same as semilinear sets. As an application of this result, we show that the graph of multiplication is not Presburger definable.
@mathlib-bors

mathlib-bors Bot commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors Bot changed the title feat(ModelTheory): Presburger definability and semilinear sets [Merged by Bors] - feat(ModelTheory): Presburger definability and semilinear sets Feb 19, 2026
@mathlib-bors mathlib-bors Bot closed this Feb 19, 2026
pfaffelh pushed a commit to pfaffelh/mathlib4 that referenced this pull request Mar 2, 2026
…rover-community#27100)

This PR formalizes the classical result that Presburger definable sets are the same as semilinear sets. As an application of this result, we show that the graph of multiplication is not Presburger definable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

large-import Automatically added label for PRs with a significant increase in transitive imports ready-to-merge This PR has been sent to bors. t-logic Logic (model theory, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants