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] - feat: positivity extension for zpow #8003

Closed
wants to merge 15 commits into from

Conversation

dupuisf
Copy link
Contributor

@dupuisf dupuisf commented Oct 29, 2023

This PR adds a positivity extension for integer powers, i.e. a ^ (r : ℤ). It's basically copy-pasted from the natural power extension. Note that this makes the imports of Mathlib.Tactic.Positivity.Basic slightly heavier since the required lemmas were not there (and the relevant file doesn't import positivity so I couldn't put it there either). It's probably not too bad, but I can put it in a new file if people think this would be better.


Open in Gitpod

@dupuisf dupuisf added awaiting-review The author would like community review of the PR t-meta Tactics, attributes or user commands awaiting-CI labels Oct 29, 2023
let _a ← synthInstanceQ q(LinearOrderedField $α)
haveI' : $e =Q $a ^ $b := ⟨⟩
assumeInstancesCommute
pure (by exact .nonnegative q(zpow_bit0_nonneg $a $m))
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to use Even.zpow_nonneg here, instead of zpow_bit0_nonneg? Would that remove the need for the linter.deprecated false?

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 (see the current version), but this adds extra imports (namely Mathlib.Data.Int.Parity) to get Int.even_iff, and the way it's coded now the unusedHavesSuffices linter flags a line that doesn't seem spurious (at least I don't know how to remove it). Doesn't seem worth it unless we're actually planning to remove bit0 entirely.

Copy link
Member

Choose a reason for hiding this comment

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

Hm... I think I agree that we should try to avoid adding that new dependency.

In your original code, you can dodge linter.deprecated by doing this:

-    haveI' : $b =Q bit0 $m := ⟨⟩
+    haveI' : $b =Q $m + $m := ⟨⟩ -- b = bit0 m

That seems better to me than disabling the linter for the entire declaration.

@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. label Nov 8, 2023
@dupuisf dupuisf added awaiting-author A reviewer has asked the author a question or requested changes and removed awaiting-review The author would like community review of the PR labels Nov 8, 2023
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. label Nov 8, 2023
@dupuisf dupuisf added awaiting-review The author would like community review of the PR and removed awaiting-author A reviewer has asked the author a question or requested changes labels Nov 8, 2023
Mathlib/Tactic/Positivity/Basic.lean Outdated Show resolved Hide resolved
let _a ← synthInstanceQ q(LinearOrderedField $α)
haveI' : $e =Q $a ^ $b := ⟨⟩
assumeInstancesCommute
pure (by exact .nonnegative q(zpow_bit0_nonneg $a $m))
Copy link
Member

Choose a reason for hiding this comment

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

Hm... I think I agree that we should try to avoid adding that new dependency.

In your original code, you can dodge linter.deprecated by doing this:

-    haveI' : $b =Q bit0 $m := ⟨⟩
+    haveI' : $b =Q $m + $m := ⟨⟩ -- b = bit0 m

That seems better to me than disabling the linter for the entire declaration.

@YaelDillies
Copy link
Collaborator

What's the situation here? I would like this in mathlib 😄

@dwrensha
Copy link
Member

I reverted this to the initial version of the PR, before my first comment, and I switched to the more localized way of suppressing the linter that I suggested above.

Copy link
Collaborator

@YaelDillies YaelDillies left a comment

Choose a reason for hiding this comment

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

LGTM!

maintainer merge

Copy link

🚀 Pull request has been placed on the maintainer queue by YaelDillies.

@robertylewis
Copy link
Member

bors merge

@github-actions github-actions bot added ready-to-merge This PR has been sent to bors. and removed awaiting-review The author would like community review of the PR labels Dec 17, 2023
mathlib-bors bot pushed a commit that referenced this pull request Dec 17, 2023
This PR adds a positivity extension for integer powers, i.e. `a ^ (r : ℤ)`. It's basically copy-pasted from the natural power extension. Note that this makes the imports of `Mathlib.Tactic.Positivity.Basic` slightly heavier since the required lemmas were not there (and the relevant file doesn't import positivity so I couldn't put it there either). It's probably not too bad, but I can put it in a new file if people think this would be better.



Co-authored-by: David Renshaw <dwrenshaw@gmail.com>
@mathlib-bors
Copy link

mathlib-bors bot commented Dec 17, 2023

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title feat: positivity extension for zpow [Merged by Bors] - feat: positivity extension for zpow Dec 17, 2023
@mathlib-bors mathlib-bors bot closed this Dec 17, 2023
@mathlib-bors mathlib-bors bot deleted the dupuisf/positivity_zpow branch December 17, 2023 23:08
awueth pushed a commit that referenced this pull request Dec 19, 2023
This PR adds a positivity extension for integer powers, i.e. `a ^ (r : ℤ)`. It's basically copy-pasted from the natural power extension. Note that this makes the imports of `Mathlib.Tactic.Positivity.Basic` slightly heavier since the required lemmas were not there (and the relevant file doesn't import positivity so I couldn't put it there either). It's probably not too bad, but I can put it in a new file if people think this would be better.



Co-authored-by: David Renshaw <dwrenshaw@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge This PR has been sent to bors. t-meta Tactics, attributes or user commands
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants