-
Notifications
You must be signed in to change notification settings - Fork 299
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(tactic/elementwise): autogenerate lemmas in concrete categories #6941
Conversation
I can't comment on the contents of the |
At first glance, |
Ah -- the point, which I should explain in the docs, is that This difference is all that prevents you from using the original lemma. EDIT: I've updated the doc-strings so the example indicates this in action. |
It's certainly doable, but it's also just |
@b-mehta, what do you think about names? I was thinking about just Similarly, should we think about the |
This is true, but
I think I (weakly) prefer elementwise to concrete, but I'd be happy with either - concrete is more concise but I think elementwise is clearer?
Also happy with this. |
Okay! I will leave the names as is. I have added |
Co-authored-by: Gabriel Ebner <gebner@gebner.org>
bors r+ |
…6941) # The `elementwise` attribute The `elementwise` attribute can be applied to a lemma ```lean @[elementwise] lemma some_lemma {C : Type*} [category C] {X Y : C} (f g : X ⟶ Y) : f = g := ... ``` and produce ```lean lemma some_lemma_apply {C : Type*} [category C] [concrete_category C] {X Y : C} (f g : X ⟶ Y) (x : X) : f x = g x := ... ``` (Here `X` is being coerced to a type via `concrete_category.has_coe_to_sort` and `f` and `g` are being coerced to functions via `concrete_category.has_coe_to_fun`.) The name of the produced lemma can be specified with `@[elementwise other_lemma_name]`. If `simp` is added first, the generated lemma will also have the `simp` attribute. Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
Pull request successfully merged into master. Build succeeded: |
…6941) # The `elementwise` attribute The `elementwise` attribute can be applied to a lemma ```lean @[elementwise] lemma some_lemma {C : Type*} [category C] {X Y : C} (f g : X ⟶ Y) : f = g := ... ``` and produce ```lean lemma some_lemma_apply {C : Type*} [category C] [concrete_category C] {X Y : C} (f g : X ⟶ Y) (x : X) : f x = g x := ... ``` (Here `X` is being coerced to a type via `concrete_category.has_coe_to_sort` and `f` and `g` are being coerced to functions via `concrete_category.has_coe_to_fun`.) The name of the produced lemma can be specified with `@[elementwise other_lemma_name]`. If `simp` is added first, the generated lemma will also have the `simp` attribute. Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
The
elementwise
attributeThe
elementwise
attribute can be applied to a lemmaand produce
(Here
X
is being coerced to a type viaconcrete_category.has_coe_to_sort
andf
andg
are being coerced to functions viaconcrete_category.has_coe_to_fun
.)The name of the produced lemma can be specified with
@[elementwise other_lemma_name]
.If
simp
is added first, the generated lemma will also have thesimp
attribute.This doesn't immediately remove many lemmas, but I think the real situation is that we have wanted many lemmas of this form, but everyone immediately sees that humans shouldn't have to write them, and stops working on whatever needed the lemmas. :-)
For now I've reduced the main culprit file to a short stub with just an
attribute ...
line. I will probably update this PR to delete that file, distributing those attributes around to the original declarations.I don't intend to add lots of
@[elementwise]
attributes in this PR; they can be added as needed later.