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 ] Restate, and use, the definitions of Monotonic etc. operations #2580

Draft
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

jamesmckinna
Copy link
Contributor

@jamesmckinna jamesmckinna commented Feb 10, 2025

Aim: towards tackling #1579

TODO:

  • introduce the relevant definitions and consequences
  • deploy in Data.Nat.* UPDATED: unsolved metas suggest some more revision is necessary :-(
  • deploy in Data.Integer.*
  • deploy in Data.Rational.*
  • make the breaking changes (v3.0: separate PR once the rest is done?)

@jamesmckinna jamesmckinna marked this pull request as draft February 10, 2025 08:44
@JacquesCarette
Copy link
Contributor

Thanks - these already are easier to understand.

@jamesmckinna
Copy link
Contributor Author

How do I remove #1579 from the Development sidebar entry?

@MatthewDaggitt
Copy link
Contributor

How do I remove #1579 from the Development sidebar entry?

Not sure how you did it, but it's gone for me 🎉

mono⇒cong sym reflexive antisym mono x≈y = antisym
(mono (reflexive x≈y))
(mono (reflexive (sym x≈y)))

antimono⇒cong : Symmetric ≈₁ → ≈₁ ⇒ ≤₁ → Antisymmetric ≈₂ ≤₂ →
∀ {f} → f Preserves ≤₁ ⟶ (flip ≤₂) → f Preserves ≈₁ ⟶ ≈₂
∀ {f} → f Preserves ≤₁ ⟶ (flip ≤₂) → Monotonic₁ ≈₁ ≈₂ f
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This unfortunately is stated so as not to be able to exploit the refactoring redefinition of Antitonic₁ in Relation.Binary.Definitions below (wrong relation gets flipped!). Downstream refactoring?

@jamesmckinna
Copy link
Contributor Author

Now that the abstract definitions are mostly in place, can look at the instantiations in Data.Nat etc. Still questions in mind, as ever, about implicit/explicit quantification in Left/RightMonotonic, plus dependency on Relation.Binary adding one additional layer of indirection (cf. #2573 #2566 etc.) so a nudge from reviewers would be welcome before proceeding...

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.

Coming along nicely.

@jamesmckinna
Copy link
Contributor Author

Remark: all of the Data.X.Properties module duplicate the same abstract proof that (anti-)monotonicity implies distributivity over (lub)glb... so we should downstream lift that argument out once and for all? etc. DRY

@jamesmckinna jamesmckinna marked this pull request as ready for review February 17, 2025 19:13
@jamesmckinna
Copy link
Contributor Author

So this should now be ready, modulo:

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 looks really good! Massive improvement.

*-monoʳ-≤ : ∀ n → (n *_) Preserves _≤_ ⟶ _≤_
*-monoʳ-≤ n m≤o = *-mono-≤ (≤-refl {n}) m≤o
*-monoʳ-≤ : LeftMonotonic _≤_ _≤_ _*_
*-monoʳ-≤ = mono₂⇒monoˡ {≤₁ = _≤_} {≤₂ = _≤_} {≤₃ = _≤_} ≤-refl *-mono-≤
Copy link
Contributor

Choose a reason for hiding this comment

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

This providing of implicits is annoying. Suggests that some of them should be explicit in the proof?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I've been scratching my head over how it might be avoided... without a conclusion yet.

+-monoʳ-≤ : ∀ n → (n +_) Preserves _≤_ ⟶ _≤_
+-monoʳ-≤ n m≤o = +-mono-≤ (≤-refl {n}) m≤o
+-monoʳ-≤ : LeftMonotonic _≤_ _≤_ _+_
+-monoʳ-≤ = mono₂⇒monoˡ {≤₃ = _≤_} ≤-refl +-mono-≤
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

@jamesmckinna
Copy link
Contributor Author

jamesmckinna commented Feb 19, 2025

I'll resolve the merge conflict later, meanwhile tricky questions above needing more thought... ;-)... so have converted back to DRAFT.

@jamesmckinna jamesmckinna marked this pull request as draft February 28, 2025 09:01
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.

3 participants