Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ refactor ] Revise definitions, consequences, and use, of Algebra.Definitions.(Almost)*Cancellative #2573

Open
wants to merge 37 commits into
base: master
Choose a base branch
from

Conversation

jamesmckinna
Copy link
Contributor

@jamesmckinna jamesmckinna commented Feb 6, 2025

Fixes #1436 , ...
... at least as far as 'AlmostCancellative' properties of operations wrt equality relation; the various order-theoretic generalisations are not covered
... so the issue probably ought to be kept open even if this gets merged? cf. #2580

NB.:

  • see issue for discussion of the design strategy (could be less breaking? naming issues... etc.)
  • Algebra.Consequences.Base refactoring [ refactor ] Add equality as a parameter to Algebra.Consequences.Base #2572 should probably be merged first; fold in the instance-based analysis for Decidable (and hence Recomputable) predicates into Except_-*Cancellative_?
  • only equality-based properties tackled so far... Algebra.Definitions only imported at the equality relation, but might better be left parameterised, so that the various Cancellative properties can be made generic...
  • for Integer and Rational, the Cancellative properties wrt multiplication don't easily cash out via the 'generic' design strategy of going via AlmostCancellative, so I haven't (yet) include such statements, nor refactored to make these the primary notions.

Copy link
Contributor

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

Seems all quite reasonable.

@jamesmckinna
Copy link
Contributor Author

I think I can't face doing more with this PR at this stage: the new definitions are in-place, with one specimen instantiation for Nat, but it isn't clear to me how best to proceed with:

  • the rest of Data.Nat.Properties
  • Data.Integer.Properties
  • Data.Rational.Properties

without a lot more refactoring, which I suggest take place downstream?

@jamesmckinna jamesmckinna marked this pull request as ready for review February 18, 2025 09:47
Copy link
Contributor

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

Seems like a nice PR as-is, more can be done subsequently.

@jamesmckinna
Copy link
Contributor Author

Seems like a nice PR as-is, more can be done subsequently.

Thanks @JacquesCarette I suppose my concern was that if it turned out those downstream PRs were still stymied by 'bad' design decisions here, then ... I'm not sure what. Certainly it seemed a big job to try to refactor existing proofs to try to conform to the new APIs...

@JacquesCarette
Copy link
Contributor

To allay your fears, might be worth taking Data.Rational.Properties (in a new branch based off of this one) and porting it, but without aiming to make that port a PR, just a "is this a good idea" test.

@jamesmckinna
Copy link
Contributor Author

To allay your fears, might be worth taking Data.Rational.Properties (in a new branch based off of this one) and porting it, but without aiming to make that port a PR, just a "is this a good idea" test.

So to allay the fears about whether it's too much work to make the change, I may as well (accept having to) do the additional work to make the change? Sigh...

@JacquesCarette
Copy link
Contributor

So to allay the fears about whether it's too much work to make the change, I may as well (accept having to) do the additional work to make the change? Sigh...

Well, it might turn out to be easy! Or you might be right, and be able to estimate just how much work it is, and let us know.

Copy link
Contributor

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

There are lots of good changes in here, but it's difficult to parse all the different definitions of cancellative being added. I'll have another look if you can lay them out on separate lines?

@@ -3,7 +3,7 @@
module README where

------------------------------------------------------------------------
-- The Agda standard library, version 2.3-dev
-- The Agda standard library, version 3.0-dev
Copy link
Contributor

Choose a reason for hiding this comment

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

This change probably shouldn't be made in this PR?

* In `Data.Nat.Properties`:
```agda
*-almostCancelʳ-≡ : AlmostRightCancellative 0 _*_
```
Copy link
Contributor

Choose a reason for hiding this comment

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

Seem to be missing a lot of stuff in the CHANGELOG?


Cancellative : Op₂ A → Set _
Cancellative _•_ = (LeftCancellative _•_) × (RightCancellative _•_)

_-AlmostLeftCancellative_ Provided_-LeftCancellative_
Except_-LeftCancellative_ : ∀ {p} (P : Pred A p) → Op₂ A → Set _
Copy link
Contributor

Choose a reason for hiding this comment

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

These lines are pretty unreadable to me. Can we separate them out into separate definitions even if they do have the same type?

Also why do these names have - in them?

@@ -44,6 +43,7 @@ import Relation.Binary.Properties.Poset as PosetProperties
import Relation.Binary.Reasoning.Setoid as ≈-Reasoning
open import Relation.Binary.Reasoning.Syntax

open import Algebra.Consequences.Propositional {A = ℚᵘ}
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like an unneeded import?

@@ -64,6 +63,7 @@ open import Relation.Nullary.Decidable.Core as Dec
using (yes; no; recompute; map′; _×-dec_)
open import Relation.Nullary.Negation.Core using (¬_; contradiction)

open import Algebra.Consequences.Propositional {A = ℚ}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we now need to import it with the type specifically applied? Is this a breaking change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Standardise implicit arguments of cancellation properties.
3 participants