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] - fix(tactic/{norm_num, abel}): do not do syntactic matches on typeclass instances #18129

Closed
wants to merge 8 commits into from

Conversation

eric-wieser
Copy link
Member

@eric-wieser eric-wieser commented Jan 11, 2023

Specifically, this remove syntactic matches on has_pow and has_smul instances in favor of unification.
In all cases there is a cache we can exploit to avoid looking up the preferred instance from scratch every time.


Open in Gitpod

@eric-wieser eric-wieser added bug awaiting-review The author would like community review of the PR t-meta Tactics, attributes or user commands labels Jan 11, 2023
@eric-wieser eric-wieser requested a review from a team as a code owner January 11, 2023 11:43
@eric-wieser eric-wieser changed the title fix(tactic/norm_num): do not do syntactic matches on typeclass instances fix(tactic/{norm_num, abel}): do not do syntactic matches on typeclass instances Jan 11, 2023
@@ -189,8 +189,12 @@ meta def eval_neg (c : context) : normal_expr → tactic (normal_expr × expr)
return (term' c (n', -n.2) x a',
c.app ``term_neg c.inst [n.1, x, a, n', a', h₁, h₂])

def smul {α} [add_comm_monoid α] (n : ℕ) (x : α) : α := n • x
def smulg {α} [add_comm_group α] (n : ℤ) (x : α) : α := n • x
@[nolint doc_blame] def nat_smul_inst {α} [add_comm_monoid α] : has_smul ℕ α := by apply_instance
Copy link
Member

Choose a reason for hiding this comment

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

don't use nolint doc_blame, these should be in the nolints.json file (or documented).

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm confused, I thought nolint doc_blame was "this isn't deserving of documentation" whereas nolints.json is "I can't be bothered to document this.

These are not declarations that are intended as API; they only exist because it's easier/faster to construct terms with def than from within the meta code.

How do you feel about me just making them private? They're not something we want in the docs anyway, are they?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, private doesn't work with the name mangling. I've done what you suggest since it's consistent with how the rest of this file is handled.

I'd still argue that nolinting all of these helper declarations is the right thing to do, but not in this PR.

Copy link
Member

Choose a reason for hiding this comment

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

I'm confused, I thought nolint doc_blame was "this isn't deserving of documentation" whereas nolints.json is "I can't be bothered to document this.

I agree with this characterization. They are implementation details (a property they share with most declarations in this file) but the need for them is deserving of documentation.

Copy link
Member Author

Choose a reason for hiding this comment

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

but the need for them is deserving of documentation.

Indeed; probably as a library note. Maybe something like

-- see not [declarations for tactics] for an explanation of the lemmas and defs in this section
namespace _helpers

end _helpers

since I think the _ prefix will rightly exclude them from doc-gen.

@digama0
Copy link
Member

digama0 commented Jan 12, 2023

bors r+

@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 Jan 12, 2023
bors bot pushed a commit that referenced this pull request Jan 12, 2023
…s instances (#18129)

Specifically, this remove syntactic matches on `has_pow` and `has_smul` instances in favor of unification.
In all cases there is a cache we can exploit to avoid looking up the preferred instance from scratch every time.
@bors
Copy link

bors bot commented Jan 12, 2023

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title fix(tactic/{norm_num, abel}): do not do syntactic matches on typeclass instances [Merged by Bors] - fix(tactic/{norm_num, abel}): do not do syntactic matches on typeclass instances Jan 12, 2023
@bors bors bot closed this Jan 12, 2023
@bors bors bot deleted the eric-wieser/fix-norm_num branch January 12, 2023 05:55
bors bot pushed a commit that referenced this pull request Jan 19, 2023
…on `^` (#18156)

This code is copied from a similar pattern for `has_div.div` a few lines up.

Follows on from #18129
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) t-meta Tactics, attributes or user commands
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants