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
Convert 2nd part of rewriting chapter to prodn #13707
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
The introduction should probably refer to the Eval @red_expr in
command (and possibly also the Eval @red_expr in
construct in Definition
and the eval @red_expr in
Ltac-construct) as other ways of applying these reduction strategies.
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.
In addition to my previous comments about moving the section "Controlling the reduction strategies and the conversion algorithm" here and referring to the various constructs that use the red_expr
syntax in the introduction, I also think that the "Conversion rules" section of the "Core language" chapter should get some reference to this section in its introduction.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
It would be nice to have a bit of text in the introduction describing the differences between the various conversion tactics and when to use them. Or we could add a sentence covering that to each tactic. |
What do you think about pulling these sections into this chapter since they relate to equalities? https://coq.inria.fr/distrib/V8.12.2/refman/proof-engine/tactics.html#equality |
82ef0b9
to
8d2eda3
Compare
Updated. |
Is the forall optional? |
Yes. And it's the same thing for the argument to
With the new chapter title, this would make sense. But then we should rename the file to
Yes, you can maybe mention that |
reference_occs ::= @reference {? at @occs_nums } | ||
pattern_occs ::= @one_term {? at @occs_nums } | ||
|
||
Normalize the goal as specified by the :n:`@strategy_flag`\s. The flags |
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.
Not just the goal, but also the context, if so specified by @occurences
.
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.
Goal can sometimes designate the goal + its context: https://coq.gitlab.io/-/coq/-/jobs/1062149393/artifacts/_install_ci/share/doc/coq/sphinx/html/proofs/writing-proofs/proof-mode.html#term-goal
Up to @jfehrle to decide whether this one should stay as is or be reworded.
This comment has been minimized.
This comment has been minimized.
Updated. |
Updated. The "constant" and "body" changes are in a separate commit. I eyeballed them and removed some silly ones, e.g. uses of |
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 taking me a huge time reviewing the glossary term usages and it's not even for a huge gain, as this could be done incrementally too. So I'll stop there. I suggest you take my suggestions into account for the files I have reviewed (the ones in language/
, practical-tools/
and addendum/
) and drop the changes to the rest. Also, the rest of the PR is basically ready, so you may squash the review commits.
.. prodn:: | ||
term_cast ::= @term10 <: @type | ||
| @term10 <<: @type | ||
| @term10 : @type | ||
term_cast ::= @term10 : @type | ||
| @term10 :> | ||
| @term10 <: @type | ||
| @term10 <<: @type |
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.
Why did you change the order? I preferred the previous one.
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 made it match the order of the text below. The : case is the most common/basic case, right? While <: and <:: are specialized. And we lack an explanation for :>.
WDYT?
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've never seen :>
used, and while it parses, it does not seem to leave evidence in the term (at least not any printed evidence). Is it a no-op? I suspect it should be removed....
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.
Oh right, actually I prefer the new order. I just wanted the undocumented :>
to be last.
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.
:>
is CastCoerce
. It looks like it was introduced in 2007 by @mattam82. The only example use I found is:
(** Coerces objects before comparing them *)
Notation " x '`=' y " := ((x :>) = (y :>)) (at level 70).
introduced at that time in a contrib.
I don't have an example of what it does.
f610a50
to
28a2b28
Compare
Updated. Just a couple things left to tweak, see above. |
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 didn't re-review anything, just trusting that the last round of suggestion has been correctly implemented. The only remaining question is if we can document :>
(CastCoerce
) and if we put it at the end of the cast list. But I'm actually tempted to just merge this right now as this can always be left-over for future improvement.
To merge, or not to merge, that is the question: More seriously, putting CastCoerce at the end of the list makes sense; it appears to be the least important of the 4 alternatives. Seems to me the following comment could be adapted to give a bit of explanation. But not eager to wait long on this. Let me know what you'd like me to do (if anything).
|
Unfortunately, I don't know enough about coercions to come up with a working example from this explanation. But I guess you can still put this as a description. And with or without description, it makes sense for |
By inspecting the source code, I've discovered that Lines 39 to 43 in c738d65
Lines 502 to 508 in c738d65
Here is an example: Require Import Coq.Program.Program.
Program Definition foo (x : { n : nat | n = 0 }) := x.
Program Definition bar (x : { n : nat | n = 0 }) := x :>.
Print foo.
(* foo = fun x : {n : nat | n = 0} => x
: {n : nat | n = 0} -> {n : nat | n = 0}
*)
Print bar.
(* bar = fun x : {n : nat | n = 0} => ` x
: {n : nat | n = 0} -> nat
*)
Unset Printing Notations.
Print bar.
(* bar = fun x : sig (fun n : nat => eq n O) => proj1_sig x
: forall _ : sig (fun n : nat => eq n O), nat
*) Following code, it seems like this only applies for whatever is registered in coqlib as Lines 426 to 442 in c738d65
Lines 115 to 128 in c738d65
Line 20 in c738d65
|
So |
Unlike the other cast nodes, it seems that |
OK then it looks like a feature that is too intricate and of limited use, that we could propose for removal instead of documenting it. Thanks for figuring this out! |
28a2b28
to
3d4cd8d
Compare
Updated, put the :> cast last and added a terse description. |
:n:`@term10 :> @type` specifies casting to a base type (for example, an | ||
underlying inductive type). |
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.
Thanks to your PR #13911, I've discovered that this feature is documented in the refman in this section: https://coq.inria.fr/refman/addendum/program.html#syntactic-control-over-equalities
Instead of this approximate description, I suggest that you just add a link to this section for the documentation of :>
.
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.
Updated. I made it
:n:`@term10 :> @type` specifies casting to a base type (for example, an
underlying inductive type). See :ref:`syntactic_control`.
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.
This is still unsatisfying. The most problematic thing is this @type
after :>
(it doesn't correspond to the grammar). The second issue is that Jason pointed out that this is a Program-specific feature but this description doesn't make this clear at all. I'd suggest something much simpler like:
:n:`@term10 :>` casts to the support type in Program-mode. See :ref:`syntactic_control`.
It's a bit annoying though that we are losing so much time over documenting a feature that we might very well decide to remove very soon.
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.
Updated.
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.
Hooray! It's been a long time coming. Thanks for your help and patience.
And thanks to @JasonGross for your help.
3d4cd8d
to
8e36d27
Compare
8e36d27
to
0d33024
Compare
@coqbot merge now |
Should we try to put this in 8.13.2? OTOH I don't remember if we've included any post-8.13 material. |
My main issue with this is whether the move of an entire section + some additional commands from the Commands chapter to the Equality chapter is appropriate for a patch-level release (as it will break documentation links). |
Fixes: #13803