Skip to content

[Merged by Bors] - feat(ModelTheory): the language of Presburger Arithmetic - #27099

Closed
staroperator wants to merge 12 commits into
leanprover-community:masterfrom
staroperator:presburger
Closed

staroperator wants to merge 12 commits into
leanprover-community:masterfrom
staroperator:presburger

Conversation

@staroperator

@staroperator staroperator commented Jul 13, 2025 •

Copy link
Copy Markdown
Collaborator

This PR introduces the first-order language of Presburger Arithmetic. It has not defined the theory of Presburger Arithmetic yet (left as TODO), but is enough to prove some definability results (#27100).


Open in Gitpod

@github-actions

github-actions Bot commented Jul 13, 2025 •

Copy link
Copy Markdown

PR summary 27ba7f0e60

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference
Mathlib.ModelTheory.Arithmetic.Presburger.Basic (new file) 709

Declarations diff

+ Language.presburger
+ funMap_add
+ funMap_one
+ funMap_zero
+ instance : Add (presburger.Term α)
+ instance : NatCast (presburger.Term α)
+ instance : One (presburger.Term α)
+ instance : SMul ℕ (presburger.Term α)
+ instance : Zero (presburger.Term α)
+ instance : presburger.Structure M
+ natCast_succ
+ natCast_zero
+ presburgerFunc
+ realize_add
+ realize_natCast
+ realize_nsmul
+ realize_one
+ realize_sum
+ realize_zero
+ succ_nsmul
+ sum
+ zero_nsmul

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).

@YaelDillies YaelDillies 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.

Thanks for the PR! Here is a first batch of comments.

namespace FirstOrder

/-- The type of Presburger arithmetic functions, defined as (0,1,+) -/
inductive presburgerFunc : ℕ → Type

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.

The usual abbreviation of "function" is "fun"

Suggested change
inductive presburgerFunc : ℕ → Type
inductive presburgerFun : ℕ → Type

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.

I'm following FirstOrder.ringFunc which uses Func instead of Fun.

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.

Can you maybe raise on Zulip that this is inconsistent with the rest of mathlib?

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.

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.

Based on the discussions, fun is mostly used for the lambda functions in Lean, so I think I can keep the name presburgerFunc? Or do you have any other suggestions?

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.

It probably can be changed later if we care

add := Functions.apply₂ .add

instance : NatCast (presburger.Term α) where
natCast := Nat.unaryCast

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.

Is it at all relevant to your formalisation of model theory to have log depth terms, in which case a binary cast would be more pertinent?

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.

Nope, I don't really compute these terms or prove anything on their sizes. However, that might be an interesting topic for future work.

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 think that if we care at all about the size of these terms, we should just do an expansion-by-definitions to a language better suited for that (not in this PR!). The function mapping x to 2x is definable in Presburger, and adding that as a function symbol would make log-length terms.

@YaelDillies YaelDillies added the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Jul 15, 2025
@staroperator staroperator removed the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Jul 16, 2025

@YaelDillies YaelDillies 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.

Thanks!

maintainer delegate

@github-actions

Copy link
Copy Markdown

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

@ghost ghost added the maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. label Jul 22, 2025
@awainverse

Copy link
Copy Markdown
Contributor

Everything here looks good to me - I'll take a look at #27100.

@staroperator

Copy link
Copy Markdown
Collaborator Author

Everything here looks good to me - I'll take a look at #27100.

Thanks for review! #27100 is unfortunately too large and I'm currently refactoring it into smaller PRs. #27342 is the first one separated from it.

@bryangingechen

Copy link
Copy Markdown
Contributor

Thanks!
bors r+

@ghost ghost 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 Jul 22, 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]>
@mathlib-bors

mathlib-bors Bot commented Jul 22, 2025

Copy link
Copy Markdown
Contributor

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors Bot changed the title feat(ModelTheory): the language of Presburger Arithmetic [Merged by Bors] - feat(ModelTheory): the language of Presburger Arithmetic Jul 22, 2025
@mathlib-bors mathlib-bors Bot closed this Jul 22, 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]>
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

4 participants