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

[Merged by Bors] - chore(data/real/ereal): fix addition and multiplication on ereal #17770

Closed
wants to merge 6 commits into from

Conversation

sgouezel
Copy link
Collaborator

The current version of multiplication on ereal is completely broken (it satisfies (-1) * (+∞) = +∞). The addition is not really broken, but it satisfies (-∞) + (+∞) = +∞, while the analogy with ennreal through the exponential and the logarithm suggest that a better convention would be (-∞) + (+∞) = -∞. We fix the multiplication (by defining one directly by hand) and tweak the addition to obey the better convention (by changing the definition from with_top (with_bot ℝ) to with_bot (with_top ℝ)).


Open in Gitpod

@sgouezel sgouezel requested a review from a team as a code owner November 30, 2022 09:36
@sgouezel sgouezel added awaiting-review The author would like community review of the PR t-analysis Analysis (normed *, calculus) labels Nov 30, 2022
Copy link
Member

@fpvandoorn fpvandoorn left a comment

Choose a reason for hiding this comment

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

LGTM

The proofs are quite long though.
I'm wondering if you can simplify a lot of the proofs like this:
define a function ereal.signed_ennreal : sign_type ->ennreal -> ereal (defined by "multiplication"), and then define (x : ereal) * (y : ereal) := ereal.signed_ennreal (x.sign * y.sign) (x.abs * y.abs). Since ereal.signed_ennreal x.sign x.abs = x you should get many properties about multiplication for free.

Do you want to try this? If not, I'm also fine with merging this as-is.

@sgouezel
Copy link
Collaborator Author

I thought about this approach, but I used the current definition to make sure that defeqs are good for multiplication (especially for bot and for top) (in fact maybe they would also work with the other definition, but that's less obvious). The proofs look long because I've squeezed the simps, but in fact they are completely automatic case disjunctions, so I'd rather keep the current definition.

@fpvandoorn
Copy link
Member

Ok, then let's keep it as this for now.

bors merge

@github-actions github-actions bot added ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) and removed awaiting-review The author would like community review of the PR labels Nov 30, 2022
bors bot pushed a commit that referenced this pull request Nov 30, 2022
)

The current version of multiplication on ereal is completely broken (it satisfies `(-1) * (+∞) = +∞`). The addition is not really broken, but it satisfies `(-∞) + (+∞) = +∞`, while the analogy with ennreal through the exponential and the logarithm suggest that a better convention would be `(-∞) + (+∞) = -∞`. We fix the multiplication (by defining one directly by hand) and tweak the addition to obey the better convention (by changing the definition from `with_top (with_bot ℝ)` to `with_bot (with_top ℝ)`).
@bors
Copy link

bors bot commented Nov 30, 2022

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title chore(data/real/ereal): fix addition and multiplication on ereal [Merged by Bors] - chore(data/real/ereal): fix addition and multiplication on ereal Nov 30, 2022
@bors bors bot closed this Nov 30, 2022
@bors bors bot deleted the SG_better_ereal branch November 30, 2022 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) t-analysis Analysis (normed *, calculus)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants