Skip to content

[Merged by Bors] - feat(to_additive): unfold lemmas generated by simp - #14628

Closed
fpvandoorn wants to merge 5 commits into
masterfrom
fvd/to_additive_unfold_aux
Closed

fpvandoorn wants to merge 5 commits into
masterfrom
fvd/to_additive_unfold_aux

Conversation

@fpvandoorn

Copy link
Copy Markdown
Member
  • This removes a bunch of hacky code
  • Thanks to @kmill for the idea
  • Also fix a bug in the implementation of @[to_additive (attr := to_additive, x)]
  • The removed test tested for an implementation detail. The rest of the test file (and Mathlib) still passes, which shows that it still works as desired.

Open in Gitpod

@fpvandoorn
fpvandoorn requested review from kim-em and kmill July 10, 2024 19:57
@fpvandoorn fpvandoorn added the awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. label Jul 10, 2024
@github-actions

Copy link
Copy Markdown

PR summary 360d18f00a

Import changes for modified files

Dependency changes

File Base Count Head Count Change
Mathlib.Lean.Name 3 4 +1 (+33.33%)
Mathlib.Tactic.ToAdditive 34 39 +5 (+14.71%)
Import changes for all files
Files Import difference
Too many changes (4249)!

Declarations diff

+ Lean.Meta.unfoldAuxLemmas
+ Lean.Name.isAuxLemma
- addSimpAttr
- addSimpAttrFromSyntax
- addSimpTheorem'
- mkSimpTheoremsFromConst'

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

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

@kmill kmill left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me. The best kind of feature is one that's implemented by mostly deleting code!

For due diligence, I'll mention that I think the whole auxLemma business is about trying to avoid re-typechecking proof terms, so unfolding auxLemmas defeats this optimization, however I don't believe that simp's auxLemmas tend to be very complicated.

@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 Jul 10, 2024
@fpvandoorn fpvandoorn added the t-meta Tactics, attributes or user commands label Jul 10, 2024
@eric-wieser

Copy link
Copy Markdown
Member

What's the "feat" here? Is there any visible behavior change, or is this just internal cleanup?

@eric-wieser

Copy link
Copy Markdown
Member

!bench

@leanprover-bot

Copy link
Copy Markdown

Here are the benchmark results for commit 360d18f.
There were no significant changes against commit 5b4d457.

@fpvandoorn

Copy link
Copy Markdown
Member Author

See the issues that reference this: one feature request there is now fixed, another bug might be fixed (haven't tested)

@kim-em

kim-em commented Jul 15, 2024

Copy link
Copy Markdown
Contributor

bors merge

@github-actions github-actions Bot added the ready-to-merge This PR has been sent to bors. label Jul 15, 2024
mathlib-bors Bot pushed a commit that referenced this pull request Jul 15, 2024
* This removes a bunch of hacky code
* Thanks to @kmill for the idea
* Also fix a bug in the implementation of `@[to_additive (attr := to_additive, x)]`
* The removed test tested for an implementation detail. The rest of the test file (and Mathlib) still passes, which shows that it still works as desired.
@mathlib-bors

mathlib-bors Bot commented Jul 16, 2024

Copy link
Copy Markdown
Contributor

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors Bot changed the title feat(to_additive): unfold lemmas generated by simp [Merged by Bors] - feat(to_additive): unfold lemmas generated by simp Jul 16, 2024
@mathlib-bors mathlib-bors Bot closed this Jul 16, 2024
@mathlib-bors
mathlib-bors Bot deleted the fvd/to_additive_unfold_aux branch July 16, 2024 00:30
@adomani adomani mentioned this pull request Aug 1, 2024
mathlib-bors Bot pushed a commit that referenced this pull request Apr 2, 2025
This PR changes how `to_additive` approaches translation by first unfolding all aux lemmas. Unfolding aux lemmas was previously added in #14628, since it was observed that aux lemmas tend not to have enough context to properly be additivized. This was added as a step after processing any aux decls. The change here is to make the unfolding happen before processing aux decls. We now also abstract nested proofs in additivized definitions.

Additionally, we use `Meta.check` instead of `Meta.inferType` to correctly check the type of the translated declaration.

The aux lemma unfolding is necessary for the next Lean release (v4.19.0).



Co-authored-by: Floris van Doorn <[email protected]>
tannerduve pushed a commit that referenced this pull request May 13, 2025
This PR changes how `to_additive` approaches translation by first unfolding all aux lemmas. Unfolding aux lemmas was previously added in #14628, since it was observed that aux lemmas tend not to have enough context to properly be additivized. This was added as a step after processing any aux decls. The change here is to make the unfolding happen before processing aux decls. We now also abstract nested proofs in additivized definitions.

Additionally, we use `Meta.check` instead of `Meta.inferType` to correctly check the type of the translated declaration.

The aux lemma unfolding is necessary for the next Lean release (v4.19.0).



Co-authored-by: Floris van Doorn <[email protected]>
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.

5 participants