Zulip Chat Archive
Stream: general
Topic: metaprogramming and structure inheritance
Simon Hudon (Mar 11 2018 at 21:43):
I'm trying to write a tactic that explores the inheritance structure. Given the name of a structure type, can I discover what are its ancestors?
Sebastian Ullrich (Mar 11 2018 at 22:20):
Only for the new structure command. You need to reimplement get_parent_structures, but that shouldn't be too hard.
Sebastian Ullrich (Mar 11 2018 at 22:21):
tl;dr: subobject fields start with "_"
Simon Hudon (Mar 11 2018 at 22:31):
How does one use the new structure command? Also, is get_parent_structures
exposed to Lean?
Andrew Ashworth (Mar 11 2018 at 22:36):
you're using the new structure command by default, I think
Andrew Ashworth (Mar 11 2018 at 22:36):
as opposed to the old structure command which is accessed with set option
Sebastian Ullrich (Mar 11 2018 at 22:36):
yep
Simon Hudon (Mar 11 2018 at 22:42):
Thanks! And is it possible that structure_fields
by default does not list those symbols starting with _
?
Sebastian Ullrich (Mar 11 2018 at 22:46):
Sorry, that was ambiguous. It's only in the inductive constructor parameters that they are encoded with _
Sebastian Ullrich (Mar 11 2018 at 22:47):
All structure_fields
does is get the parameter names and strip any leading _
Simon Hudon (Mar 11 2018 at 22:58):
Let's say that I'm constructing an instance of group
(but I don't know in the tactic that it is specifically group). I'd like to know that monoid
is a direct parent so that I can use mk_instance
and use the result as a source in pexpr.mk_structure_instance
. How would you do it?
Last updated: Dec 20 2023 at 11:08 UTC