[Work and discussion in progress] Add Unguarded syntax for (co)fixpoints and Assumed Positive for (co)inductive types. - #7651
Conversation
|
|
||
| let declare_fixpoint local poly ((fixnames,fixdefs,fixtypes),pl,ctx,fiximps) indexes ntns = | ||
| (* guarded: Some b -> set check_guarded to b, None -> does not change it *) | ||
| let declare_fixpoint guarded local poly ((fixnames,fixdefs,fixtypes),pl,ctx,fiximps) indexes ntns = |
There was a problem hiding this comment.
As you are breaking the API here maybe we'd like to upgrade to named parameters?
There was a problem hiding this comment.
I named guarded, but do you suggest I also name the other arguments?
There was a problem hiding this comment.
Maybe that would be a good idea, what do other devs think?
Zimmi48
left a comment
There was a problem hiding this comment.
Since we can also do fixed points using Theorem, Lemma, etc, would it make sense to also add this new syntax for these commands?
| By default, they are disabled and produce an error. The deprecation | ||
| warning which used to occur when using nested proofs has been removed. | ||
| - Guard check can be temporary disabled to define non terminating fixpoints | ||
| or non productive cofixpoints with the commands `Unguarded Fixpoints` |
| ind_body : `ident` [`binders`] : `term` := | ||
| : [[|] `ident` [`binders`] [:`term`] | … | `ident` [`binders`] [:`term`]] | ||
| fixpoint : Fixpoint `fix_body` with … with `fix_body` . | ||
| fixpoint : [Unguarded] Fixpoint `fix_body` with … with `fix_body` . |
There was a problem hiding this comment.
You should also add this on the CoFixpoint line below.
| end. | ||
|
|
||
| The ``{struct`` :token:`ident```}`` annotation may be left implicit, in this case the | ||
| The ``{struct`` :token:`ident` ``}`` annotation may be left implicit, in this case the |
There was a problem hiding this comment.
Note that this is already fixed in #7537 and the best fix goes further than this.
| starts with a constructor. | ||
|
|
||
| The check of decreasing argument can be temporary disabled using ``Unguarded``. | ||
| Warning: this can break the consistency of the system, use at your own risk. |
There was a problem hiding this comment.
This documentation is not done in the recommended style, the documentation must come after the variant grammar and must be indented. Since this chapter is heavily reindented by #7537 anyways, I suggest you rebase on top or wait for it to get merged. In any case, you will have so many conflicts in this file that the best way to solve them will be to copy / paste this part.
There was a problem hiding this comment.
Ok thanks, I will do this after merge then.
I withdraw this because I'm actually doubtful that doing fixed points using |
|
Please. Stop. Inflating. The. Definition. Modifier. Syntax. Again. There have been a shitload of arguments against definition modifiers, and it all boils down that it doesn't scale. I am too tired to repeat them here and I think there are pointers in #79. I am fundamentally against this PR. |
ppedrot
left a comment
There was a problem hiding this comment.
To expand on my above comment, I am even surprised that people that were (I think) at the heated Coq workgroup where we discussed the issue comment on that PR as if it was OK in principle, and that they did not try to deter @SimonBoulier from implementing it at the CIW... Is that the famous "History repeats twice, first as a tragedy, second as a farce" effect?
I don't remember hearing this project in the presentations of the first day, but I may have missed something. |
|
Also, I guess what @ppedrot means is that he would like to see this implemented only once we have the attributes syntax. |
|
@SimonBoulier The documentation PR has been merged so you might want to rebase now. @ppedrot I completely disagree with your argument to reject this change. This argument has been stupidly used to delay #79 for three years now. The problem you are pointing at is a well known syntax problem and must be addressed independently without preventing people to work on new features in the meantime. Attributes are now on their way thanks to @vbgl and will probably be finished for 8.9 so it means that the current syntax will probably never make it into a released version as-is. But even if it wasn't the case, that wouldn't be a good reason to delay the availability of this feature. |
|
I like this feature and its current syntax. We are taking attributes as a kind of "silver bullet" , but the more I think about them the less convinced I am they are going to bring significant benefits. Attributes are hard to handle, and worse, they tend to override all kind of static checks due to their "generic" nature. So IMVHO we shouldn't delay this PR just for that. |
I tend to agree with that part. |
Wrong. Syntax is non-local by nature, so this can affect people that are unrelated to this change. Plus in the current implementation it is a hell to get it right. There is no way to compute the syntax conflict because CAMLP5, but we would be surprised if this were possible. This is the kind of area where conservativity should be of utmost importance, because it will be hard to backtrack on that. But like, I don't understand why it is taking THREE YEARS. Like I can implement a syntax that scales properly in literally half a day. Should I do that or what? |
|
And also,
We've already discussed that, and the answer is: write a goddamn plugin. |
Seriously? And you didn't do it? |
This ended up in the sinkhole of workgroups and PR bikeshedding, as all syntactic considerations do. But yes, luckily @vbgl has started doing it with a wide approval, although I am still curious to see the moment where we start discussing on the actual syntax. |
Disable guard check for (co)fixpoints when defined with `Ungarded` keyword.
| loc : Loc.t option; | ||
| locality : bool option; | ||
| check_guard : bool option; (* None -> use global setting (true by default); Some -> override *) | ||
| polymorphic : bool; |
There was a problem hiding this comment.
Why is guarded a global attribute? AFAICS it only applies to fixpoints, am I correct?
There was a problem hiding this comment.
I mean this should not be an attribute, but an entry in the corresponding vernac_expr constructor.
| | VernacProgram | ||
| | VernacPolymorphic of bool | ||
| | VernacLocal of bool | ||
| | VernacGuarded of bool |
There was a problem hiding this comment.
There is an assymetry between the syntax and the interpreted here, which IMO signals that indeed the proper fixpoint AST should be extended.
|
IMO "Write a plugin" is hardly an answer to most problems, but rather a good way to add some maintenance burden and testing overhead. This seems to me like a well-delimited functionality that applies to two core vernaculars. |
ejgallego
left a comment
There was a problem hiding this comment.
I am convinced now that this property is local to the vernaculars and thus doesn't belong in an attribute.
|
It seems Emilio that you have a diverging opinion of what should be an attribute than what was in the CEP and what is being implemented. IMO the great benefit of attributes is that they make the parsing phase more tractable by moving some of the complexity / error handling from the parsing file to the interpretation phase. |
Right! Much better this way ;-) |
8817cfb to
58029a5
Compare
Unguarded syntax for (co)fixpoints.Unguarded syntax for (co)fixpoints.
Unguarded syntax for (co)fixpoints.Unguarded syntax for (co)fixpoints and Assumed Positive for (co)inductive types.
|
I don't have time to address your comments right now and I only pushed what I did in the train. |
|
@SimonBoulier personally I'd say that if you remove the Indeed it seems to me that quite a few design work on what "attributes" are and how are they gonna be implemented is needed, but IMHO that should be orthogonal to this PR. |
|
Except that this is precisely what @ppedrot opposed to, isn't it? |
|
The way I understand it is that @ppedrot complains about the syntax, I am referring to the AST itself. At least to me it is clear that the AST needs a bit more of design work so I think that what I suggest is a reasonable compromise in order not to get this PR stuck. About the syntax, I have no particular strong opinion. |
|
To be clear, I'm just opposed to the syntax extension. How hackish the implementation is can be frowned upon from an engineering point of view, but this is one order of magnitude less problematic as it does not appear directly to the user. Quizz: without looking at the code, which permutation(s) makes the syntax parsable in the current PR? |
|
I think Unguarded/General fxpoint could have even a larger scope than Program, and apply to Lemma, Inductive as well, ie any command where an unguarded fixpoint might be typechecked. In the current codebase there’s no parsing support for attributes so I didn’t see a problem with the implementation. When they’re available we’ll use them. I suppose there will be a mechanism to check the support of an attribute by a given command, @vbgl @maximedenes ? |
Yes, I believe that is the plan. @vbgl is very busy on other topics these days, but once he finds some time for Coq, I'm sure good progress will be made, and in particular the plans for attributes will be made clear. |
For For |
No, it's that you could write |
|
This might be very useful to me! But I often work with |
|
It was discussed and this PR doesn't go as far because it doesn't change the AST of terms (we can't attach |
That's my plan! I do this as soon as my thesis is written :-) |
herbelin
left a comment
There was a problem hiding this comment.
OK to me as far as I'm concerned.
maximedenes
left a comment
There was a problem hiding this comment.
This can now use attributes.
|
It seems to me that this PR could be rebased on top of attributes, now that we have them. |
|
I think this is simply waiting on @SimonBoulier finishing writing their thesis first. |
|
Sorry I am not very available those days but I will do it. |
|
October 1st is the date of the beta release so it will be too late for sure, but it is already quite late. If it is merged now, it goes in 8.10 by default unless developers convince the release manager how important it is to include this in 8.9. |
|
Ok, it will be for 8.10 then. |
|
Superseded by #9004. |
Disable guard check for (co)fixpoints when defined with
Ungardedkeyword.We can now write:
Kind: feature.
I know that this PR is far from being perfect, any comment welcome.