Skip to content

[ add ] Nat lemmas with _∸_, _⊔_ and _⊓_#2924

Merged
MatthewDaggitt merged 1 commit intoagda:masterfrom
jkopanski:more-nats
Mar 3, 2026
Merged

[ add ] Nat lemmas with _∸_, _⊔_ and _⊓_#2924
MatthewDaggitt merged 1 commit intoagda:masterfrom
jkopanski:more-nats

Conversation

@jkopanski
Copy link
Contributor

Some stuff that I've needed. I have no idea if those belong here in stdlib. I don't know if I've put those in the right place, or named them properly. Hence the draft and lack of changlog entry.

@MatthewDaggitt MatthewDaggitt added this to the v2.4 milestone Jan 27, 2026
Copy link
Collaborator

@MatthewDaggitt MatthewDaggitt left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

  • Naming and placement looks good to me.
  • We tend to avoid rewriting in favour of using equational reasoning as its a) less brittle and b) clearer to the user what is going on. Could you switch these to use equational reasoning?

------------------------------------------------------------------------
-- Properties of _∸_ and _⊓_ and _⊔_

m∸n≤m⊔n : ∀ m n → m ∸ n ≤ m ⊔ n
Copy link
Member

Choose a reason for hiding this comment

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

This property doesn't feel natural to me, and the definition is short enough I don't really think it needs a name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks kind of similar to the m⊔n≤m+n that is already here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm okay - lets one do proofs at a higher level with fewer steps.

Copy link
Member

Choose a reason for hiding this comment

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

Can you provide an example of an "interesting" proof where this lemma is a useful step?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know if that counts as interesting, but the only place where I used it is down below in the m⊔n∸[m∸n]≡n.

Just to be clear I'm fine with removing that. In this PR I've just included stuff that I've tried to lookup in the stdlib first and written down once I couldn't find it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Having pondered this for a while, I'm leaning towards @Taneb 's position more than @JacquesCarette 's.

Copy link
Collaborator

@jamesmckinna jamesmckinna Feb 24, 2026

Choose a reason for hiding this comment

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

Namely, ... TL;DR: Fairbairn threshhold, I think. It's used only once.

@jamesmckinna
Copy link
Collaborator

Monus m∸n is characterised #1949 by a pair of adjoint properties wrt the ordering _≤_, so it seems as though these properties also ought to be obtainable from those and the corresponding characterisations of _⊓_ and _⊔_ as glb (product) and lub (copoduct) in that category/preorder.

Copy link
Collaborator

@JacquesCarette JacquesCarette left a comment

Choose a reason for hiding this comment

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

I'm fine with adding these. We can have later passes of simplification of proofs.

------------------------------------------------------------------------
-- Properties of _∸_ and _⊓_ and _⊔_

m∸n≤m⊔n : ∀ m n → m ∸ n ≤ m ⊔ n
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm okay - lets one do proofs at a higher level with fewer steps.

@jamesmckinna
Copy link
Collaborator

@jkopanski Shall we take this out of draft and try to get it in shape to merge? Or do you still want time to work on it further?

@jkopanski
Copy link
Contributor Author

@jkopanski Shall we take this out of draft and try to get it in shape to merge? Or do you still want time to work on it further?

yes, I would like to get it going. I've rebased it on recent changes and added changlog entry.

There's the case of m∸n≤m⊔n to be decided.

I've only now noticed your update regarding wlog. I don't think edits trigger notification here. Anyway that is something that I've never used so it may take me some time to figure out, if we were to push on it in this pr.

@jkopanski jkopanski marked this pull request as ready for review February 9, 2026 11:42
@jamesmckinna
Copy link
Collaborator

jamesmckinna commented Feb 9, 2026

@jkopanski Shall we take this out of draft and try to get it in shape to merge? Or do you still want time to work on it further?

...
I've only now noticed your update regarding wlog. I don't think edits trigger notification here. Anyway that is something that I've never used so it may take me some time to figure out, if we were to push on it in this pr.

No, as @JacquesCarette observes, we can handle that as a downstream refactoring. And wlog itself could do with some fresh thought... since #523 #2577 #2626

@jamesmckinna
Copy link
Collaborator

@MatthewDaggitt are you happy that your review requests have been answered satisfactorily?
if so, I think we could move to merging this in?

Some stuff that I've needed. I have no idea if those belong here in
stdlib.  I don't know if I've put those in the right place, or named
them properly.  Hence the draft and lack of changlog entry.
@MatthewDaggitt MatthewDaggitt added this pull request to the merge queue Mar 3, 2026
Merged via the queue into agda:master with commit 03acec1 Mar 3, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants