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/protect_proj): protect_proj attribute for structures #2855
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not needed now, but soon enough, someone will ask if they can protect only some of the fields of a structure. What about taking an optional list of identifiers? If it's not given, the behavior should be as it is now (protect all fields). If it's given, protect only those.
src/tactic/protect_proj.lean
Outdated
-/ | ||
import meta.expr | ||
/-! | ||
# protect_proj user attribute |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# protect_proj user attribute | |
# `protect_proj` user attribute |
src/tactic/protect_proj.lean
Outdated
namespace tactic | ||
|
||
/-- Tactic that is executed when a structure is marked with the `protect_proj` attribute -/ | ||
meta def protect_proj_tac (n : name) (env : environment) : tactic environment := |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like I've noticed this before, do we still not have tactic.mk_protected
? This seems like a big oversight.
I'd add this function to tactic.core
and implement protect_proj_tac : name -> tactic unit
that fails (with your current error message) if the name is not a structure. (There's environment.is_structure
to test this.)
src/tactic/protect_proj.lean
Outdated
all of the projections become projected, meaning they must always be referred to by | ||
their full name `foo.bar`, even when the `foo` namespace is open.", | ||
after_set := some (λ n _ _, get_env >>= protect_proj_tac n >>= set_env) } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protect_proj
should have an add_tactic_doc
.
I can't work out how to do this. I give it the type |
I worked this out. It takes a list of identifiers that shouldn't be protected, rather than a list that should, as this is usually a shorter list. I also added a |
Also see discussion in https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/old_structure_cmd |
It would also be nice to add a few tests for these functions! |
Co-authored-by: Rob Lewis <Rob.y.lewis@gmail.com>
Co-authored-by: Rob Lewis <Rob.y.lewis@gmail.com>
Co-authored-by: Rob Lewis <Rob.y.lewis@gmail.com>
Thanks Chris, this looks great. bors merge |
This attribute protect the projections of a structure that is being defined. There were some errors in Euclidean domain caused by `rw` using `euclidean_domain.mul_assoc` instead of `mul_assoc` because the `euclidean_domain` namespace was open. This fixes this problem, and makes the `group` and `ring` etc. namespaces more usable. Co-authored-by: Rob Lewis <Rob.y.lewis@gmail.com> Co-authored-by: Chris Hughes <33847686+ChrisHughes24@users.noreply.github.com> Co-authored-by: Rob Lewis <rob.y.lewis@gmail.com>
Pull request successfully merged into master. Build succeeded: |
This uses the recent `protect_proj` attribute (#2855).
This uses the recent `protect_proj` attribute (#2855).
…nprover-community#2855) This attribute protect the projections of a structure that is being defined. There were some errors in Euclidean domain caused by `rw` using `euclidean_domain.mul_assoc` instead of `mul_assoc` because the `euclidean_domain` namespace was open. This fixes this problem, and makes the `group` and `ring` etc. namespaces more usable. Co-authored-by: Rob Lewis <Rob.y.lewis@gmail.com> Co-authored-by: Chris Hughes <33847686+ChrisHughes24@users.noreply.github.com> Co-authored-by: Rob Lewis <rob.y.lewis@gmail.com>
…community#2867) This uses the recent `protect_proj` attribute (leanprover-community#2855).
This attribute protect the projections of a structure that is being defined.
There were some errors in Euclidean domain caused by
rw
usingeuclidean_domain.mul_assoc
instead ofmul_assoc
because theeuclidean_domain
namespace was open. This fixes this problem, and makes thegroup
andring
etc. namespaces more usable.