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 ] (Re)define (Is)TightApartness and (Is)HeytingCommutativeRing/(Is)HeytingField #2588

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

Conversation

jamesmckinna
Copy link
Contributor

@jamesmckinna jamesmckinna commented Feb 18, 2025

Fixes #2587

Adds:

  • Algebra.Apartness.Properties.HeytingField, superseding Algebra.Apartness.Properties.HeytingCommutativeRing

NB:

  • latter module should now be deprecated (?) in favour of moving its one remaining property to Algebra.Properties.Ring (or even Algebra.Properties.AbelianGroup...) DONE properties moved; module NOT deprecated
  • Data.Rational.Unnormalised.Properties should be refactored to make use of Relation.Binary.Properties.DecSetoid for its (Is)*ApartnessRelation definitions DONE

Issue:

  • is this v2.3 (as a bug fix of the various APIs involved?) or v3.0 (as a large breaking change?)
  • re: @MatthewDaggitt 's comment below about the mathematics, perhaps if someone could check what is said in eg. Troelstra and van Dalen, that might shape how this goes forward, but my own view is: authors seem to disagree about Apartness vs. TightApartness, etc. but that the fundamental distinction should be between *CommutativeRing and *Field (and yes: perhaps HeytingLocalRing would have been better, but see also Define LocalRing #2219 ) in that the latter should have inverses, while the former need not. The existing APIs make the distinction turn on whether the apartness is tight or not, which seems 'wrong'... even to the point of being a bug?

RFC from @cspollard and @bsaul ...

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.

Otherwise, code-wise it looks good. Can't comment on the mathematics 😄

@@ -36,8 +37,19 @@ open SetoidProperties setoid
; cotrans = ≉-cotrans
}

≉-tight : Tight _≈_ _≉_
≉-tight x y = decidable-stable (x ≟ y)
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing addition from Changelog.

Copy link
Contributor Author

@jamesmckinna jamesmckinna Feb 19, 2025

Choose a reason for hiding this comment

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

yeah, I wasn't sure how to record this... it's a redefinition, rather than an addition, because the definition of Tight has been changed in Relation.Binary.Definitions to drop the redundant second conjunct, which is equivalent to Irreflexive, as noted on the issue.

What's the best way to do this? (See latest commits for one attempt...)

@@ -17,6 +17,10 @@ Non-backwards compatible changes
significantly faster. However, its reduction behaviour on open terms may have
changed.

* The definitions of `Algebra.Structures.IsHeyting*` and
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this is a draft, but in the final version it would be good to explain broadly what the refactorings actually are here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See latest commits, hopefully enough, but not too much, detail now!

@jamesmckinna
Copy link
Contributor Author

jamesmckinna commented Feb 19, 2025

I think this is now ready for review! Many thanks to @MatthewDaggitt for the pre-review, hopefully the latest round of (many!) commits have put things on a more sound footing. As in updated preamble above:

  • is this v2.3 or v3.0? (maybe the latter is safer? but the former is justifiable if we think the old APIs were a bug or not?)
  • I've left Algebra.Apartness.Properties.HeytingCommutativeRing as an empty stub, with two deprecations, rather than deprecate the module altogether, against possible future additions to this? But in any case, as a consequence it's no longer re-exported from the new Algebra.Apartness.Properties.HeytingField module.

@jamesmckinna jamesmckinna marked this pull request as ready for review February 19, 2025 11:24
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.

Spent a lot of time reviewing this... and no comment to speak of. I did spot several proofs that I'd want to change, but I should add some reasoning combinators first that would show how these embody repeated patterns.

Comment on lines +47 to +48
x#0y#0→xy#0 : x # 0# → y # 0# → x * y # 0#
x#0y#0→xy#0 {x} {y} x#0 y#0 = helper (#⇒invertible x#0) (#⇒invertible y#0)
Copy link
Contributor Author

@jamesmckinna jamesmckinna Feb 19, 2025

Choose a reason for hiding this comment

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

@JacquesCarette 's wanting to refactor the proofs (and FTR, largely inherited from the original PR #1968 ...)
It occurs to me that some (all?) of these arguments could be refactored by going via Algebra.Properties.CancellativeCommutativeSemiring, after establishing the relevant structure/bundle?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Er... no, in fact. Those properties require Decidable _≈_, and maybe could be simplified to consider only Tight _≈_ _≉_, but I'm not going to push my luck...

Copy link
Contributor

Choose a reason for hiding this comment

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

Could be. I was thinking of analogs to the elim and cancel reasoning combinators of agda-categories. While at it, I would have ported push/pull (but renamed them) too. Many of these already work on Monoid.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed: please raise a PR addressing #2288 !

@jamesmckinna
Copy link
Contributor Author

Otherwise, code-wise it looks good. Can't comment on the mathematics 😄

Hopefully the discussion on #2587 clarifies this?

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.

[ refactor ] Definitions of Relation.Binary.Apartness and Algebra.*.*Heyting*
3 participants