-
Notifications
You must be signed in to change notification settings - Fork 11
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
Tutorial Equations: Indexed Inductive Types #9
Conversation
@MevenBertrand at last CUDW we discuss how to finish this tutorial but I lost the notes. Could you check it out, and give some thought on how to complete it ? I think mostly the ideas was discussed derive / signature / no confusion and depelim which are currently not discussed |
Isn't there a problem? The file called But yeah, I believe the points you mentioned were the main ones. There is also the subterm relation, which one can derive and subsequently use for well-founded proofs. And maybe saying something about forced patterns as well? Here's the example from the manual:
And finally might it make sense to mention how Equations can use UIP to make its life easier with indexed inductive types when the index type is an hSet? |
@MevenBertrand I have fixed the file (if you want to look at it, it is currently rather short) |
I gave it a quick look, a few remarks:
Otherwise, it's going in the right direction, although it's still quite raw :) I can do a proper detailed review for small things, typos etc. when you've finished a first draft. |
I have fixed the code.
I'll do a more careful reading to clean tomorrow. |
About About signature, not sure what to say, maybe it's mostly a technical aspect that does not need to go into the manual. About the difference between |
To summarize my criticism of this tutorial as discussed in in the Zulip chat:
It's also a bit surprising to me that the tutorial focuses on functions on vectors, even though using vectors is consistently recommended against for Coq beginners (Stdlib even has a warning these days). I agree with Matthieu's suggestions here on the order to present concepts/examples. |
@palmskog my understanding is that vectors are not recommended because without Equations to help you it is very painful to reason about them ? Which makes it a good example to me as it is also simple. But more importantly, what other example would you use ? |
src/Tutorial_Equations_indexed.v
Outdated
(** Though, the [NonConfusionHom] property is derivable for most index inductive types, | ||
it is not the case that is is derivable for all index inductive types. | ||
It only is when equality of constructors can be reduced to equality of forced | ||
argument, that is ??? |
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.
@mattam82 could you please suggest sth here ?
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 is derivable when diagonal constructor equalities C_i x1 .. xn = C_i y1 ... yn : I idx1 ... idxn
are equivalent to p1 : xk = yk, ... xl = yl
where {k, ..., l} is the subset of non-forced arguments. Equivalence = type equivalence (as in the HoTT book). The type equivalence proof might depend on possibly already declared HSet proofs for the types of indices.
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.
Typically:
vcons A n a v = vcons A n a' v' : Vector.t A (S n) <->
{ eqn : n = n & eqa : a = a' & v # eqn = v' } <-> (* Need to make eqn disappear as it is forced by index (S n) *)
{ eqa : a = a' & v # eq_refl = v' } <-> (* nat has UIP, eqa : n = n = eq_refl n *)
a = a' : A /\ v = v' :> Vector.t A n (* simplify *)
You may also want to point out the relation between depelim and dependent induction. |
Regarding part 2.2, I think it is easier and more useful to mostly introduce the lemmas Equations derive from the pov of where they are needed.
|
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 fixed quite a few things and added more examples of tactics. I think the "forced argument" explanation should be integrated somewhere but it's better for you to try it and I'll review it, to see if I managed to convey to you the idea or if it needs more explanations :)
@mattam82 don't expect me to write sth about forced arguments. I have read about it, and talked about it with people but I have the feeling that all the explanations I am getting are very handwavy. Sure, in practice I kind of get it, but until I see a proper definition in metacoq, I don't think I will really get it. So I think it is much better if you write sth small for it. I will review your PR, but I have already looked at it quickly, and it basiccaly looks good. |
Alright, I gave it a go. I implemented your suggestions as well. Remaing the depelim/dependent elimination thing to sort out |
Now is #75 |
A tutorial explaining how to use Equations to define functions on indexed inductive types and the particularities of reasoning about them
To do :