Skip to content

[Merged by Bors] - feat: extensible push and pull tactics#21965

Closed
JovanGerb wants to merge 76 commits intomasterfrom
push_tactic
Closed

[Merged by Bors] - feat: extensible push and pull tactics#21965
JovanGerb wants to merge 76 commits intomasterfrom
push_tactic

Conversation

@JovanGerb
Copy link
Copy Markdown
Contributor

@JovanGerb JovanGerb commented Feb 16, 2025

This PR defines the push and pull tactics, and makes push_neg a macro for push Not. The tactics are also available in conv mode.

For tagging, there is only the @[push] attribute, which adds the reverse rewrite for the pull tactic when relevant. In the future, we may also need a separate @[pull X] attribute for pulling X.

Thanks to this change, we will be able to make push_neg into a more powerful tactic by tagging more lemmas. It also means that about 60 files now don't need to import LinearOrder/PartialOrder. This will be especially useful when we get the @[to_dual] attribute.

This work originally started in #21769. There is now the follow up PR #29000 which adds push tags and tests for them.

The @[push] attribute is defined in Mathlib.Tactic.Push.Attr and the main implementation of push and pull is in Mathlib.Tactic.Push.

Some proofs need to be fixed because the new simp-based push_neg can see through more reducible definitions.

Zulip conversation: #mathlib4 > I made an extensible `push` tactic generalizing `push_neg`

closes #21841


Open in Gitpod

@github-actions github-actions bot added the large-import Automatically added label for PRs with a significant increase in transitive imports label Feb 16, 2025
@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 16, 2025

PR summary ea6c1124c8

Import changes for modified files

Dependency changes

File Base Count Head Count Change
Mathlib.Tactic.Push 88 76 -12 (-13.64%)
Import changes for all files
Files Import difference
There are 6451 files with changed transitive imports taking up over 278132 characters: this is too many to display!
You can run scripts/import_trans_difference.sh all locally to see the whole output.

Declarations diff

+ Head
+ Head.ofExpr?
+ Head.toString
+ PullTheorem
+ elabDischarger
+ elabHead
+ elabPushTree
+ instance : ToString Head := ⟨Head.toString⟩
+ isPullThm
+ log_abs
+ log_mul
+ nonempty_iff_empty_ne
+ not_exists
+ not_imp
+ not_le
+ not_not
+ pullCore
+ pullStep
+ pushCore
+ pushSimpConfig
+ pushStep
+ resolvePushId?
+-+ not_iff
- elabPushNegConv
- empty_ne_eq_nonempty
- ne_empty_eq_nonempty
- not_exists_eq
- not_ge_eq
- not_gt_eq
- not_implies_eq
- not_le_eq
- not_lt_eq
- not_ne_eq
- not_nonempty_eq
- not_not_eq
- not_or_eq
- pushNegCore
- transformNegationStep

You can run this locally as follows
## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>

## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>

The doc-module for script/declarations_diff.sh contains some details about this script.


No changes to technical debt.

You can run this locally as

./scripts/technical-debt-metrics.sh pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

@JovanGerb
Copy link
Copy Markdown
Contributor Author

What should I do with the copyright docstring at the top of these files? I added myself as the main author, set the year to 2025, and left the names which were there in the original file.

@JovanGerb JovanGerb added the t-meta Tactics, attributes or user commands label Feb 16, 2025
@grunweg
Copy link
Copy Markdown
Contributor

grunweg commented Feb 17, 2025

What should I do with the copyright docstring at the top of these files? I added myself as the main author, set the year to 2025, and left the names which were there in the original file.

Adding yourself as an author and leaving the original authors sounds good. Please leave the year as it was.

@JovanGerb
Copy link
Copy Markdown
Contributor Author

!bench

@leanprover-bot
Copy link
Copy Markdown
Collaborator

Here are the benchmark results for commit 13affdb.
There were no significant changes against commit 6b9635f.

@github-actions
Copy link
Copy Markdown

File Instructions %
build +28.471⬝10⁹ (+0.01%)
CI run

@leanprover-community-bot-assistant leanprover-community-bot-assistant added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Feb 18, 2025
@github-actions github-actions bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Feb 19, 2025
mathlib-bors bot pushed a commit that referenced this pull request Feb 20, 2025
This PR renames the file `PushNeg.lean` to `Push.lean`, to help reviewing #21965.

It also removes an import of PushNeg where it is already transitively imported
@leanprover-community-bot-assistant leanprover-community-bot-assistant added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Feb 20, 2025
@github-actions github-actions bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Feb 20, 2025
Co-authored-by: grunweg <[email protected]>
@grunweg grunweg mentioned this pull request Apr 5, 2025
1 task
@JovanGerb
Copy link
Copy Markdown
Contributor Author

Thanks for the reviews!

For the Polynomial.coeff example, it should definitelly be possible to turn coeff (X ^ 2 + 3 * X) 1 into something like (if 1 = 2 then 1 else 0) + 3 * 1. The issue is that you will need to do some simplification afterwards, so I think you might be better off just using simp.

@adomani
Copy link
Copy Markdown
Contributor

adomani commented Sep 21, 2025

I agree that simp could also achieve this, but I was more wondering whether pushCoeff could be a part of the compute_degree implementation, combined with some further norm_num/restricted simp call. Anyway, just an idea!

@adomani
Copy link
Copy Markdown
Contributor

adomani commented Sep 21, 2025

Ok, I think that this is probably the last extension that I will ask about push: would you mind adding tests for the #push ..., #pull ... and #push_discr_tree ... commands?

@JovanGerb
Copy link
Copy Markdown
Contributor Author

I didn't put the command #push_discr_tree Not into the test file, because I think this will be annoying to update when tagging more push_neg lemmas. However, looking at the output made me realize that some @[push] tags that I added weren't supposed to be there, so I've removed them now.

@JovanGerb
Copy link
Copy Markdown
Contributor Author

For a tactic that computes Polynomial.coeff, if you want to restrict your simp to a simp only, then you could indeed define a pushCoeff simproc to be an argument to the simp only. We can make a pushFoo simproc for any constant Foo where that is deemed useful, similar to pushNeg and pushFun.

Copy link
Copy Markdown
Contributor

@adomani adomani left a comment

Choose a reason for hiding this comment

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

I like the new tests, thanks! I also have a couple more that I just noticed...

I do not have a feeling for how much the #push_discr_tree test will cause issues. If it turns out to be quite fussy, there is always the option of commenting it out, while we think of an alternative.

Thank you for your patience through the various reviews!

bors d+

@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Sep 22, 2025

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

@ghost ghost added delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). and removed maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. labels Sep 22, 2025
@JovanGerb
Copy link
Copy Markdown
Contributor Author

I forgot about the fact that I removed the pushNeg simproc, because the relevant lemmas tend to already be tagged with simp, so the simproc doesn't really add to what simp can already do. Do you think I should still add it?

For the pushFun simproc I have a test in the follow-up PR.

@adomani
Copy link
Copy Markdown
Contributor

adomani commented Sep 22, 2025

Ok, let's remove the pushNeg simproc, as adding it later is straightforward.

Thanks!

@JovanGerb
Copy link
Copy Markdown
Contributor Author

bors r+

mathlib-bors bot pushed a commit that referenced this pull request Sep 22, 2025
This PR defines the `push` and `pull` tactics, and makes `push_neg` a macro for `push Not`. The tactics are also available in `conv` mode.

For tagging, there is only the `@[push]` attribute, which adds the reverse rewrite for the `pull` tactic when relevant. In the future, we may also need a separate `@[pull X]` attribute for pulling `X`.

Thanks to this change, we will be able to make `push_neg` into a more powerful tactic by tagging more lemmas. It also means that about 60 files now don't need to import `LinearOrder`/`PartialOrder`. This will be especially useful when we get the `@[to_dual]` attribute.

This work originally started in #21769. There is now the follow up PR #29000 which adds `push` tags and tests for them.

The `@[push]` attribute is defined in `Mathlib.Tactic.Push.Attr` and the main implementation of `push` and `pull` is in `Mathlib.Tactic.Push`.

Some proofs need to be fixed because the new simp-based `push_neg` can see through more reducible definitions.

Zulip conversation: [#mathlib4 > I made an extensible &#96;push&#96; tactic generalizing &#96;push_neg&#96;](https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/I.20made.20an.20extensible.20.60push.60.20tactic.20generalizing.20.60push_neg.60)

closes #21841
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Sep 22, 2025

Build failed:

@bryangingechen
Copy link
Copy Markdown
Contributor

I think this only failed due to a runner having a bad setup (which should be fixed now).
bors r+

@ghost ghost added the ready-to-merge This PR has been sent to bors. label Sep 23, 2025
mathlib-bors bot pushed a commit that referenced this pull request Sep 23, 2025
This PR defines the `push` and `pull` tactics, and makes `push_neg` a macro for `push Not`. The tactics are also available in `conv` mode.

For tagging, there is only the `@[push]` attribute, which adds the reverse rewrite for the `pull` tactic when relevant. In the future, we may also need a separate `@[pull X]` attribute for pulling `X`.

Thanks to this change, we will be able to make `push_neg` into a more powerful tactic by tagging more lemmas. It also means that about 60 files now don't need to import `LinearOrder`/`PartialOrder`. This will be especially useful when we get the `@[to_dual]` attribute.

This work originally started in #21769. There is now the follow up PR #29000 which adds `push` tags and tests for them.

The `@[push]` attribute is defined in `Mathlib.Tactic.Push.Attr` and the main implementation of `push` and `pull` is in `Mathlib.Tactic.Push`.

Some proofs need to be fixed because the new simp-based `push_neg` can see through more reducible definitions.

Zulip conversation: [#mathlib4 > I made an extensible &#96;push&#96; tactic generalizing &#96;push_neg&#96;](https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/I.20made.20an.20extensible.20.60push.60.20tactic.20generalizing.20.60push_neg.60)

closes #21841
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Sep 23, 2025

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title feat: extensible push and pull tactics [Merged by Bors] - feat: extensible push and pull tactics Sep 23, 2025
@mathlib-bors mathlib-bors bot closed this Sep 23, 2025
@mathlib-bors mathlib-bors bot deleted the push_tactic branch September 23, 2025 03:46
joelriou pushed a commit to joelriou/mathlib4 that referenced this pull request Oct 2, 2025
This PR defines the `push` and `pull` tactics, and makes `push_neg` a macro for `push Not`. The tactics are also available in `conv` mode.

For tagging, there is only the `@[push]` attribute, which adds the reverse rewrite for the `pull` tactic when relevant. In the future, we may also need a separate `@[pull X]` attribute for pulling `X`.

Thanks to this change, we will be able to make `push_neg` into a more powerful tactic by tagging more lemmas. It also means that about 60 files now don't need to import `LinearOrder`/`PartialOrder`. This will be especially useful when we get the `@[to_dual]` attribute.

This work originally started in leanprover-community#21769. There is now the follow up PR leanprover-community#29000 which adds `push` tags and tests for them.

The `@[push]` attribute is defined in `Mathlib.Tactic.Push.Attr` and the main implementation of `push` and `pull` is in `Mathlib.Tactic.Push`.

Some proofs need to be fixed because the new simp-based `push_neg` can see through more reducible definitions.

Zulip conversation: [#mathlib4 > I made an extensible &leanprover-community#96;push&leanprover-community#96; tactic generalizing &leanprover-community#96;push_neg&leanprover-community#96;](https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/I.20made.20an.20extensible.20.60push.60.20tactic.20generalizing.20.60push_neg.60)

closes leanprover-community#21841
zhuyizheng pushed a commit to zhuyizheng/mathlib4 that referenced this pull request Oct 2, 2025
This PR defines the `push` and `pull` tactics, and makes `push_neg` a macro for `push Not`. The tactics are also available in `conv` mode.

For tagging, there is only the `@[push]` attribute, which adds the reverse rewrite for the `pull` tactic when relevant. In the future, we may also need a separate `@[pull X]` attribute for pulling `X`.

Thanks to this change, we will be able to make `push_neg` into a more powerful tactic by tagging more lemmas. It also means that about 60 files now don't need to import `LinearOrder`/`PartialOrder`. This will be especially useful when we get the `@[to_dual]` attribute.

This work originally started in leanprover-community#21769. There is now the follow up PR leanprover-community#29000 which adds `push` tags and tests for them.

The `@[push]` attribute is defined in `Mathlib.Tactic.Push.Attr` and the main implementation of `push` and `pull` is in `Mathlib.Tactic.Push`.

Some proofs need to be fixed because the new simp-based `push_neg` can see through more reducible definitions.

Zulip conversation: [#mathlib4 > I made an extensible &leanprover-community#96;push&leanprover-community#96; tactic generalizing &leanprover-community#96;push_neg&leanprover-community#96;](https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/I.20made.20an.20extensible.20.60push.60.20tactic.20generalizing.20.60push_neg.60)

closes leanprover-community#21841
BeibeiX0 pushed a commit to BeibeiX0/mathlib4 that referenced this pull request Nov 7, 2025
This PR defines the `push` and `pull` tactics, and makes `push_neg` a macro for `push Not`. The tactics are also available in `conv` mode.

For tagging, there is only the `@[push]` attribute, which adds the reverse rewrite for the `pull` tactic when relevant. In the future, we may also need a separate `@[pull X]` attribute for pulling `X`.

Thanks to this change, we will be able to make `push_neg` into a more powerful tactic by tagging more lemmas. It also means that about 60 files now don't need to import `LinearOrder`/`PartialOrder`. This will be especially useful when we get the `@[to_dual]` attribute.

This work originally started in leanprover-community#21769. There is now the follow up PR leanprover-community#29000 which adds `push` tags and tests for them.

The `@[push]` attribute is defined in `Mathlib.Tactic.Push.Attr` and the main implementation of `push` and `pull` is in `Mathlib.Tactic.Push`.

Some proofs need to be fixed because the new simp-based `push_neg` can see through more reducible definitions.

Zulip conversation: [#mathlib4 > I made an extensible &leanprover-community#96;push&leanprover-community#96; tactic generalizing &leanprover-community#96;push_neg&leanprover-community#96;](https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/I.20made.20an.20extensible.20.60push.60.20tactic.20generalizing.20.60push_neg.60)

closes leanprover-community#21841
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). 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.

push tactic that generalizes push_neg from neg to any def.

10 participants