Use multiple statements to implement interactive fixpoints - #19091
Conversation
|
I'm not sure what the status of #10363 is, but last time I looked the proof engine API for multiple statements was in need of serious work. But this may be an interesting experiment, let's see what the CI yields (Tho I wouldn't be very surprised if we don't stress the particular corner cases that could be problematic) |
Are you suggesting possible issues if we use In the case of Require Import Derive.
Derive f SuchThat (f = 0) As spec.
unfold f. abstract reflexivity.
Qed.
Print spec.
(* spec = spec_subproof : f = 0 : f = 0 *)
Print f.
(* f = 0 : nat *)Or do you mean something else? |
|
Back in the day I meant that we duplicated side effects on each entry, this seems un/under-specified. |
|
I would need a definition of "side effects". If it is about Fixpoint f (n:nat) : nat with g (n:nat) : nat.
- abstract (exact 0).
- exact 0.
Qed.
Print f.
(* (fun f_subproof : nat => fix f (n : nat) : nat := f_subproof with g (n : nat) : nat := 0 for f) 0 *)
Print g.
(* (fun f_subproof : nat => fix f (n : nat) : nat := f_subproof with g (n : nat) : nat := 0 for g) 0 *)Fixpoint f (n:nat) : nat with g (n:nat) : nat.
- abstract (exact 0).
- exact 0.
Defined.
Print f.
(* fix f (n : nat) : nat := f_subproof with g (n : nat) : nat := 0 for f *)
Print g.
(* fix f (n : nat) : nat := f_subproof with g (n : nat) : nat := 0 for g *)
Print f_subproof.
(* f_subproof = 0 *) |
bb87dfa to
69366d1
Compare
69366d1 to
9c7e05b
Compare
9c7e05b to
404ca57
Compare
| As a mutual fixpoint decreasing on the 1st argument of foo and | ||
| 1st argument of bar: | ||
| Not enough abstractions in the definition. | ||
| As a mutual fixpoint decreasing on the 1st argument of foo and | ||
| 2nd argument of bar: | ||
| Not enough abstractions in the definition. | ||
| As a mutual fixpoint decreasing on the 2nd argument of foo and | ||
| 1st argument of bar: | ||
| Not enough abstractions in the definition. | ||
| As a mutual fixpoint decreasing on the 2nd argument of foo and | ||
| 2nd argument of bar: | ||
| Not enough abstractions in the definition. |
There was a problem hiding this comment.
this seems like it would get very long and unreadable as the number of possibilities increases.
It's already kinda bad IMO.
OTOH I don't know how to avoid listing the possibilities since the user didn't say {struct} (also I think there's currently no syntax for {struct} for Lemma with).
There was a problem hiding this comment.
With a bit more work, we could factorize the errors which are similar.
On the other side, #19301 adds syntax {struct} for Lemma with and for Lemma. So, an alternative could be to suggest using struct to get more information (???).
There was a problem hiding this comment.
We could also extend the Guarded syntax to be able to say eg Guarded {struct 1, 3} {struct 3, 1} to mean "test guardedness with 1st fixpoint recursive on 1st arg and 2nd on 3rd arg, and with 1st fixpoint recursive on 3rd arg and 2nd on 1st arg"
that way in the middle of a big proof there is no need to restart it to get a better error
There was a problem hiding this comment.
this seems like it would get very long and unreadable as the number of possibilities increases.
With a bit more work, we could factorize the errors which are similar.
I pushed a new version simplifying a bit the printing so that in the "Not enough abstractions", it is printed only once.
There was a problem hiding this comment.
We could also extend the Guarded syntax to be able to say eg Guarded {struct 1, 3} {struct 3, 1}
That's a good idea.
To depart not too much from the existing syntax, we could also say, e.g.: Guarded {struct 1} {struct 3} and repeat it for any combination we are interested in??
There was a problem hiding this comment.
Do you want me to implement it? (And otherwise, I'd be happy if ever you have some time for it.)
| exception NotGuarded of | ||
| Environ.env * Evd.evar_map * | ||
| (Environ.env * int * EConstr.t Type_errors.pcofix_guard_error) option * | ||
| (Environ.env * int * int list * EConstr.t Type_errors.pfix_guard_error) list * |
There was a problem hiding this comment.
Why are we keeping copies of the env?
There was a problem hiding this comment.
The first env is the context for the whole declaration. The other envs are the contexts for the respective errors.
|
test suite not happy |
07f4d69 to
1856bec
Compare
1856bec to
eb47bad
Compare
|
Adding |
|
Isn't this just ignoring the problem? What was the cause for the async failure? |
|
Output tests don't work well with async because it changes printing order |
|
(although in https://gitlab.inria.fr/coq/coq/-/jobs/4572169 it seems it entirely lost some messages so not sure what's going on) |
| - destruct n as [|n]. | ||
| + exact (bar 0 0). | ||
| Fail Guarded. (* failure is correct here *) | ||
| Undo 2. |
There was a problem hiding this comment.
We should probably use "-async-proofs-cache" "force" so that Undo works without repeating the previous messages
There was a problem hiding this comment.
the lack of repetition with async proofs on is probably what caused the issue
There was a problem hiding this comment.
alternatively write a test without Undo (I guess Abort then repeat the code for the start of the proof)
There was a problem hiding this comment.
OK, then, considering #19383, tell me when you know what the recommended approach will be.
There was a problem hiding this comment.
OK, so a test w/o Undo, right?
There was a problem hiding this comment.
You have the power to choose.
eb47bad to
624efc6
Compare
|
@coqbot run full ci |
|
@SkySkimmer if you're happy with the current status I can merge when CI finishes. |
…in case of failure. Co-authored-by: Gaëtan Gilbert <gaetan.gilbert@skyskimmer.net>
624efc6 to
224b21f
Compare
|
@coqbot run full ci |
|
@coqbot merge now |
Interactive co/fixpoints (and
Theorem with) used to declare a single proof starting with a dummyFix. We reimplement it using the proof engine support for multiple statements.This will allow to share the infrastructure for interactive fixpoints and
Deriveand this makes useless the copy of the types in theCInfo.tof proofs.Depends on: