-
Notifications
You must be signed in to change notification settings - Fork 34
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
Proposing to associate a qualified name to section variables so as to distinguish them from (other) goal variables #51
base: master
Are you sure you want to change the base?
Conversation
I really like this idea, but as usual the devil is in the details. I wouldn't be surprised if we discovered while implementing the CEP that something prevents this to work. |
At least, there are a number of decisions to take! To start with, there are two usages of the (current)
The second case is delicate. From the moment the Where to find it? I see several solutions:
Concretely, this means the two following options (in simplified informal code): type section_variable = Id.t
type section_context = section_variable declaration list
type goal_variable = {issecvar : bool; name : Id.t}
type goal_context = goal_variable declaration list
type env = {section_context : section_context; goal_context : goal_context; ...}
let lookup_named id env =
try List.assoc id env.goal_context
with Not_found -> if id.issecvar then List.assoc id.name env.section_context else raise Not_found type section_variable = Id.t
type section_context = section_variable declaration list
type goal_variable = {issecvar : bool; name : Id.t}
type goal_context = {it : goal_variable declaration list; secinvisibility : bool Id.Map.t}
type env = {section_context : section_context; goal_context : goal_context; ...}
(* invariant: each id in section_context occurs under the form {issecvar=true;name=id} in goal_context,
possibly registered in the invisibility map *)
let lookup_named id env = List.assoc id env.goal_context.it Any preference? Or alternative proposal? |
I like the idea too, and this is also what I simulate in Coq-Elpi by "identifying" the VarRef and ConstRef nodes in the GlobRef type. W.r.t. your question, I think that the displayed proof context should be made of section variables + proof variables. IMO the big change (which is also the most tricky part in the simulation of this I do in Coq-Elpi) is that evars do not have section variables in their explicit substitution any more (being akin to global constants, ConstRef, they don't show up there). I've no idea if this can break code in the tactics (for sure there are few ssr lines which rely on that). If you don't change the type of Env.name_context then this happens naturally (since evars won't born in the union of the section and proof context, but just in the latter). No idea what this means for vm (a recall a cache for section Let). |
Yes, the explicit substitution of evars does not need to give an instance for section vars since it is always the identity.
I would suspect that changing the explicit substitution would not break tactics. Of course, the presence of section variables or not in the defining context of an evar would modify the behavior of tactics.
Two distincts lists is ok for typing. Then, the
This is what I would consider as the default direction to go unless someone disagrees. We still need somewhere (at latest in the About what list of variables is displayed (by Please tell if you have implementation plans, so that we can prevent doing twice the same work! Another remark: I wonder whether |
Sorry if I was not clear. I was suggesting to use the node The command As a result, I would keep I hope now it's more clear how I would implement it. Of course, I may miss some detail ;-) PS: |
@gares: Using
Yes, that's what I morally had in mind too (up to using |
I think that treating section variables as constants is the way to go. Instead of having two lists of contexts in the proof engine, we could simply instantiate the toplevel variables of the proof with the section "variables", with an (apparent) shadowing. This would be fully transparent for the user, we wouldn't even need to print stuff specially. |
OK. (But I would not mind also an extra unfolding of the artificial let-in introduced for the toplevel variables before passing the term to the kernel). Concretely, @gares or @ppedrot, are you then expecting something from me on this topic or you have a roadmap (at least informally), and we just let things progress spontaneously? |
I don't have time for this myself, so I don't have a roadmap. Still I think having a design documented here is important for anyone, maybe some parts can be done by little steps (I don't know).
I don't know exactly what @ppedrot had in mind, but I would not use the logic here, at all. |
Do you exclude that a goal mentions both a section variable |
Yes, this can happen with something like Seciton X.
Variable x : nat.
Definition foo := x.
Goal forall y, foo = y.
(* goal is: x |- forall y, foo = y *)
unfold foo; clear x; intro x.
(* goal is: x |- X.x = x *)
tactic x; tactic X.x. I guess I don't know the internal of Coq vanilla tactic enough to see the problem with the second invocation. Do you have a specific tactic in mind? |
Actually, I got confused and asked something different that what I aimed at. A typical question is what would be the type of the More generally, how much the code of each tactic possibly referring to names of the goal context would have to be modified to decide explicitly if the name refers to a not-cleared section variable or to a non-section goal variable? I mean, all options are ok, but one has to be taken at some time. |
We should probably schedule a meeting to talk about this CEP. |
Next week is quite busy unless it is Thursday or Friday. Do you want me to set a poll? @gares, what would be your constraints, for, say, a 1h meeting? |
Yes. Section axiom "x" can only be cleared once, and the effect is to flip the boolean used by the pretty printer for the backward compatible "proof context from the section". After that point in time occurrences of it are displayed as "X.x" and can't be cleared. If the user introduces another |
they work for me |
1da4beb
to
964ee32
Compare
964ee32
to
cf53f4b
Compare
cf53f4b
to
c406d0b
Compare
I'm considering working back on this issue at some time, following this comment:
Here is a preliminary sketch about how to proceed: Step 1: section variables remain
Step 2: Prepare
Step 3: Use global constants for section variables
Step 4: Back to goals and tactics
Related questions:
[Feel free to edit this comment to refine it/amend it] |
@gares, @ppedrot, @SkySkimmer: I'm currently working at using
In any case, tell me if you want to take part to the design of the prototype, and at which step of the process. |
Great. I did a look at step3, but it is not clear to me which design choices you want to discuss. Can you write them here? |
There is the choice of names for the new datatypes and the organization of these datatypes. For instance, I'm currently moving |
Rendered here.