Skip to content

[Merged by Bors] - feat: better name guessing for to_additive - #779

Closed
fpvandoorn wants to merge 6 commits into
masterfrom
toAdditiveGuessName
Closed

fpvandoorn wants to merge 6 commits into
masterfrom
toAdditiveGuessName

Conversation

@fpvandoorn

@fpvandoorn fpvandoorn commented Nov 29, 2022 •

Copy link
Copy Markdown
Member
  • @[to_additive] will now correctly guess names with CoeTC, CoeT and CoeHTCT in it
  • rewrite function targetName.
    • It will now warn the user if it gives a composite name that can be auto-generated (before to_additive would never warn if a composite name was given).
    • the logic when allowAutoName = true now corresponds to the docstring
    • Fix a bug where declarations were silently allowed to translate to itself (maybe because the return statements returned a value for the whole function?)
    • Add some more tracing
    • The behavior of namespaces when giving a composite name has been changed. It will always generate a name with the same number of components. Example:
namespace MeasureTheory.MulMeasure
@[to_additive AddMeasure.myOperation] def myOperation := ...
-- before: generates `AddMeasure.myOperation` (and never gives a warning)
-- after: generates `MeasureTheory.AddMeasure.myOperation` (and probably warns that the name can be auto-generated)
end MeasureTheory.MulMeasure

Minor changes:

  • When applying @[to_additive] to a structure, add a trace message if no translation is inserted for a field.
  • Define Name.fromComponents and Name.splitAt
  • Reduce transitive imports of Tactic/toAdditive
  • Move some auxiliary declarations from Tactic/Simps to more appropriate places
    • swap arguments of String.isPrefixOf?
    • improve Name.getString

@fpvandoorn fpvandoorn added awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. and removed awaiting-review labels Nov 29, 2022
@fpvandoorn fpvandoorn added awaiting-review and removed awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. labels Nov 29, 2022
Comment thread Mathlib/Lean/Expr/Basic.lean Resolved
Comment thread Mathlib/Tactic/ToAdditive.lean Resolved
@kim-em

kim-em commented Nov 29, 2022

Copy link
Copy Markdown
Contributor

bors merge

@github-actions github-actions Bot added ready-to-merge This PR has been sent to bors. and removed awaiting-review labels Nov 29, 2022
bors Bot pushed a commit that referenced this pull request Nov 29, 2022
* `@[to_additive]` will now correctly guess names with `CoeTC`, `CoeT` and `CoeHTCT` in it
* rewrite function `targetName`. 
  - It will now warn the user if it gives a composite name that can be auto-generated (before `to_additive` would never warn if a composite name was given). 
  - the logic when `allowAutoName = true` now corresponds to the docstring
  - Fix a bug where declarations were silently allowed to translate to itself (maybe because the `return` statements returned a value for the whole function?)
  - Add some more tracing
  - The behavior of namespaces when giving a composite name has been changed. It will always generate a name with the same number of components. Example:
```lean
namespace MeasureTheory.MulMeasure
@[to_additive AddMeasure.myOperation] def myOperation := ...
-- before: generates `AddMeasure.myOperation` (and never gives a warning)
-- after: generates `MeasureTheory.AddMeasure.myOperation` (and probably warns that the name can be auto-generated)
end MeasureTheory.MulMeasure
```
* This should fix all problems in #659 other than #660

Minor changes:
* When applying `@[to_additive]` to a structure, add a trace message if no translation is inserted for a field.
* Define `Name.fromComponents` and `Name.splitAt`
* Reduce transitive imports of `Tactic/toAdditive`
* Move some auxiliary declarations from `Tactic/Simps` to more appropriate places 
  - swap arguments of `String.isPrefixOf?`
  - improve `Name.getString`

Co-authored-by: Scott Morrison <[email protected]>
@bors

ghost commented Nov 29, 2022

Copy link
Copy Markdown

Build failed:

@kim-em

ghost commented Nov 29, 2022

Copy link
Copy Markdown
Contributor

bors merge

@bors

ghost commented Nov 29, 2022

Copy link
Copy Markdown

Build failed:

@kim-em

ghost commented Nov 29, 2022

Copy link
Copy Markdown
Contributor

bors merge

@bors

ghost commented Nov 29, 2022

Copy link
Copy Markdown

Pull request successfully merged into master.

Build succeeded:

@bors bors Bot changed the title feat: better name guessing for to_additive [Merged by Bors] - feat: better name guessing for to_additive Nov 29, 2022
@bors bors Bot closed this Nov 29, 2022
@bors
bors Bot deleted the toAdditiveGuessName branch November 29, 2022 19:38
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants