Skip to content

[Merged by Bors] - feat: add notation for Real.sqrt#12056

Closed
eric-wieser wants to merge 5 commits intomasterfrom
eric-wieser/sqrt-notation
Closed

[Merged by Bors] - feat: add notation for Real.sqrt#12056
eric-wieser wants to merge 5 commits intomasterfrom
eric-wieser/sqrt-notation

Conversation

@eric-wieser
Copy link
Copy Markdown
Member

@eric-wieser eric-wieser commented Apr 10, 2024

This adds the notation √r for Real.sqrt r. The precedence is such that √x⁻¹ is parsed as √(x⁻¹); not because this is particularly desirable, but because it's the default and the choice doesn't really matter.

This is extracted from #7907, which adds a more general nth root typeclass.
The idea is to perform all the boring substitutions downstream quickly, so that we can play around with custom elaborators with a much slower rate of code-rot.
This PR also won't rot as quickly, as it does not forbid writing x.sqrt as that PR does.

While perhaps claiming for Real.sqrt is greedy; it:

  • Is far more common thatn NNReal.sqrt and Nat.sqrt
  • Is far more interesting to mathlib than sqrt on Float
  • Can be overloaded anyway, so this does not prevent downstream code using the notation on their own types.
  • Will be replaced by a more general typeclass in a future PR.

Zulip


Open in Gitpod

@eric-wieser eric-wieser added awaiting-review awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. labels Apr 10, 2024
@github-actions github-actions bot removed the awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. label Apr 10, 2024
@urkud
Copy link
Copy Markdown
Member

urkud commented Apr 11, 2024

LGTM. Should we wait for another maintainer, or just merge it?

@eric-wieser eric-wieser added the t-algebra Algebra (groups, rings, fields, etc) label Apr 11, 2024
@eric-wieser
Copy link
Copy Markdown
Member Author

Maybe maintainer merge it as a compromise?

Copy link
Copy Markdown
Contributor

@Ruben-VandeVelde Ruben-VandeVelde left a comment

Choose a reason for hiding this comment

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

Pretty.

maintainer merge

@github-actions
Copy link
Copy Markdown

🚀 Pull request has been placed on the maintainer queue by Ruben-VandeVelde.

@github-actions github-actions bot added the maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. label Apr 11, 2024
Copy link
Copy Markdown
Contributor

@j-loreaux j-loreaux left a comment

Choose a reason for hiding this comment

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

To be honest, it's cute, but I'm not sure it improves readability in large expressions.

bors merge

mathlib-bors bot pushed a commit that referenced this pull request Apr 11, 2024
This adds the notation `√r` for `Real.sqrt r`. The precedence is such that `√x⁻¹` is parsed as `√(x⁻¹)`; not because this is particularly desirable, but because it's the default and the choice doesn't really matter.

This is extracted from #7907, which adds a more general nth root typeclass.
The idea is to perform all the boring substitutions downstream quickly, so that we can play around with custom elaborators with a much slower rate of code-rot.
This PR also won't rot as quickly, as it does not forbid writing `x.sqrt` as that PR does.

While perhaps claiming `√` for `Real.sqrt` is greedy; it:
* Is far more common thatn `NNReal.sqrt` and `Nat.sqrt`
* Is far more interesting to mathlib than `sqrt` on `Float`
* Can be overloaded anyway, so this does not prevent downstream code using the notation on their own types.
* Will be replaced by a more general typeclass in a future PR.

[Zulip](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/.60Sqrt.60.20notation.20typeclass/near/400086502)



Co-authored-by: Yury G. Kudryashov <urkud@urkud.name>
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Apr 11, 2024

Build failed:

@j-loreaux
Copy link
Copy Markdown
Contributor

bors d+

@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Apr 11, 2024

✌️ eric-wieser can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@github-actions github-actions bot added delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). and removed awaiting-review labels Apr 11, 2024
@urkud
Copy link
Copy Markdown
Member

urkud commented Apr 13, 2024

@eric-wieser Should we merge it now or you plan to do more changes?

@eric-wieser
Copy link
Copy Markdown
Member Author

@fpvandoorn expressed some concerns about notation scope on Zulip, but I think they might need revisiting with your notation class PR anyway; so I'll just put this in. If the notation starts causing conflicts, we can revisit the notation being global.

bors merge

@github-actions github-actions bot added the ready-to-merge This PR has been sent to bors. label Apr 13, 2024
mathlib-bors bot pushed a commit that referenced this pull request Apr 13, 2024
This adds the notation `√r` for `Real.sqrt r`. The precedence is such that `√x⁻¹` is parsed as `√(x⁻¹)`; not because this is particularly desirable, but because it's the default and the choice doesn't really matter.

This is extracted from #7907, which adds a more general nth root typeclass.
The idea is to perform all the boring substitutions downstream quickly, so that we can play around with custom elaborators with a much slower rate of code-rot.
This PR also won't rot as quickly, as it does not forbid writing `x.sqrt` as that PR does.

While perhaps claiming `√` for `Real.sqrt` is greedy; it:
* Is far more common thatn `NNReal.sqrt` and `Nat.sqrt`
* Is far more interesting to mathlib than `sqrt` on `Float`
* Can be overloaded anyway, so this does not prevent downstream code using the notation on their own types.
* Will be replaced by a more general typeclass in a future PR.

[Zulip](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/.60Sqrt.60.20notation.20typeclass/near/400086502)



Co-authored-by: Yury G. Kudryashov <urkud@urkud.name>
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Apr 13, 2024

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title feat: add notation for Real.sqrt [Merged by Bors] - feat: add notation for Real.sqrt Apr 13, 2024
@mathlib-bors mathlib-bors bot closed this Apr 13, 2024
@mathlib-bors mathlib-bors bot deleted the eric-wieser/sqrt-notation branch April 13, 2024 11:16
xgenereux pushed a commit that referenced this pull request Apr 15, 2024
This adds the notation `√r` for `Real.sqrt r`. The precedence is such that `√x⁻¹` is parsed as `√(x⁻¹)`; not because this is particularly desirable, but because it's the default and the choice doesn't really matter.

This is extracted from #7907, which adds a more general nth root typeclass.
The idea is to perform all the boring substitutions downstream quickly, so that we can play around with custom elaborators with a much slower rate of code-rot.
This PR also won't rot as quickly, as it does not forbid writing `x.sqrt` as that PR does.

While perhaps claiming `√` for `Real.sqrt` is greedy; it:
* Is far more common thatn `NNReal.sqrt` and `Nat.sqrt`
* Is far more interesting to mathlib than `sqrt` on `Float`
* Can be overloaded anyway, so this does not prevent downstream code using the notation on their own types.
* Will be replaced by a more general typeclass in a future PR.

[Zulip](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/.60Sqrt.60.20notation.20typeclass/near/400086502)



Co-authored-by: Yury G. Kudryashov <urkud@urkud.name>
atarnoam pushed a commit that referenced this pull request Apr 16, 2024
This adds the notation `√r` for `Real.sqrt r`. The precedence is such that `√x⁻¹` is parsed as `√(x⁻¹)`; not because this is particularly desirable, but because it's the default and the choice doesn't really matter.

This is extracted from #7907, which adds a more general nth root typeclass.
The idea is to perform all the boring substitutions downstream quickly, so that we can play around with custom elaborators with a much slower rate of code-rot.
This PR also won't rot as quickly, as it does not forbid writing `x.sqrt` as that PR does.

While perhaps claiming `√` for `Real.sqrt` is greedy; it:
* Is far more common thatn `NNReal.sqrt` and `Nat.sqrt`
* Is far more interesting to mathlib than `sqrt` on `Float`
* Can be overloaded anyway, so this does not prevent downstream code using the notation on their own types.
* Will be replaced by a more general typeclass in a future PR.

[Zulip](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/.60Sqrt.60.20notation.20typeclass/near/400086502)



Co-authored-by: Yury G. Kudryashov <urkud@urkud.name>
uniwuni pushed a commit that referenced this pull request Apr 19, 2024
This adds the notation `√r` for `Real.sqrt r`. The precedence is such that `√x⁻¹` is parsed as `√(x⁻¹)`; not because this is particularly desirable, but because it's the default and the choice doesn't really matter.

This is extracted from #7907, which adds a more general nth root typeclass.
The idea is to perform all the boring substitutions downstream quickly, so that we can play around with custom elaborators with a much slower rate of code-rot.
This PR also won't rot as quickly, as it does not forbid writing `x.sqrt` as that PR does.

While perhaps claiming `√` for `Real.sqrt` is greedy; it:
* Is far more common thatn `NNReal.sqrt` and `Nat.sqrt`
* Is far more interesting to mathlib than `sqrt` on `Float`
* Can be overloaded anyway, so this does not prevent downstream code using the notation on their own types.
* Will be replaced by a more general typeclass in a future PR.

[Zulip](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/.60Sqrt.60.20notation.20typeclass/near/400086502)



Co-authored-by: Yury G. Kudryashov <urkud@urkud.name>
callesonne pushed a commit that referenced this pull request Apr 22, 2024
This adds the notation `√r` for `Real.sqrt r`. The precedence is such that `√x⁻¹` is parsed as `√(x⁻¹)`; not because this is particularly desirable, but because it's the default and the choice doesn't really matter.

This is extracted from #7907, which adds a more general nth root typeclass.
The idea is to perform all the boring substitutions downstream quickly, so that we can play around with custom elaborators with a much slower rate of code-rot.
This PR also won't rot as quickly, as it does not forbid writing `x.sqrt` as that PR does.

While perhaps claiming `√` for `Real.sqrt` is greedy; it:
* Is far more common thatn `NNReal.sqrt` and `Nat.sqrt`
* Is far more interesting to mathlib than `sqrt` on `Float`
* Can be overloaded anyway, so this does not prevent downstream code using the notation on their own types.
* Will be replaced by a more general typeclass in a future PR.

[Zulip](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/.60Sqrt.60.20notation.20typeclass/near/400086502)



Co-authored-by: Yury G. Kudryashov <urkud@urkud.name>
Jun2M pushed a commit that referenced this pull request Apr 24, 2024
This adds the notation `√r` for `Real.sqrt r`. The precedence is such that `√x⁻¹` is parsed as `√(x⁻¹)`; not because this is particularly desirable, but because it's the default and the choice doesn't really matter.

This is extracted from #7907, which adds a more general nth root typeclass.
The idea is to perform all the boring substitutions downstream quickly, so that we can play around with custom elaborators with a much slower rate of code-rot.
This PR also won't rot as quickly, as it does not forbid writing `x.sqrt` as that PR does.

While perhaps claiming `√` for `Real.sqrt` is greedy; it:
* Is far more common thatn `NNReal.sqrt` and `Nat.sqrt`
* Is far more interesting to mathlib than `sqrt` on `Float`
* Can be overloaded anyway, so this does not prevent downstream code using the notation on their own types.
* Will be replaced by a more general typeclass in a future PR.

[Zulip](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/.60Sqrt.60.20notation.20typeclass/near/400086502)



Co-authored-by: Yury G. Kudryashov <urkud@urkud.name>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. ready-to-merge This PR has been sent to bors. t-algebra Algebra (groups, rings, fields, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants