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
OCaml extraction can generate infinite recursion #7061
Comments
Note that the function causes a problem with cbv, vm_compute, native_compute.
So the problem is not only for extraction. |
FTR even |
This is the same as #6487, which did not get a definitive answer. |
If I'm not mistaken this is a known issue, but I don't know if there is already an issue opened for this. Fixpoint f (z : bool) := let x := (f z) in true.
Eval cbv in (f true). (* Stack overflow *) But in this case Anyways, the problem comes from some reduction being performed before the guard condition is checked. I don't remember exactly why it is so but I guess there are good reasons which have prevented people to fix this in the past. In any case, I acknowledge your problem. |
@cmangin You were faster than me :D |
In fact, I closed the previous issue instead because this one explains why this is a problem better. |
I think such definitions should be rejected, which would incidentally remove the problem with extraction. As for the why, some reduction is performed because there are some definitions like this one which would be rejected without any reduction: Fixpoint f (n m : nat) {struct} : nat :=
let g := f O in
match m with
| O => O
| S m' => g m'
end. This example is contrived of course, but there are some in the stdlib. EDIT: see below, I meant zeta indeed :) |
I think the problem is beta and zeta reduction which erase a term. If the termination checker checks termination condition of the erased term, Note that iota reduction also erases a term but I think it is not a problem for I made a simple example to show that there is an infinite reduction sequence
|
Oops. The termination of erased terms by iota reduction must be checked. In the following example, zeta reduction doesn't erase (f y) but moves it into
|
Fixed in #15434. |
Version
Operating system
Description of the problem
I found that Coq extraction can generate a function
which cause infinite recursion in OCaml.
I think this is dangerous because we can prove (f true) is true in Coq.
But the extracted function is infinite recursion.
I.e. the proof doesn't guarantee the extracted function returns true in OCaml.
The text was updated successfully, but these errors were encountered: