I'm asking your help because I would like to know if it would be possible to allow the definition of potentially infinite fixpoints in Coq, just to check if the current definition eventually produces an output.
I've tried the new Unset Guard Checking
command, be what I'd like to disable precisely is the decreasing argument checking (because I actually have the error cannot guess decreasing argument of fix
.
I understand that it is a bit of a shame to disable this feature in Coq, but it is just to get a small utility function to check whether the current definition is correct, to make sure that providing then a decreasing argument will work in further development.
Unset Guard Checking
does disable the decreasing argument checking.
You may have to explicitly specify the argument which you want the system to assume decreasing using {struct foo}
like this example.
Unset Guard Checking.
Fixpoint y {A} (f : A -> A) {struct f} : A := f (y f).
However, if you don't have a strong reason, the better way to define a possibly infinite function is to add an argument to force termination.
Fixpoint y_opt {A} (lim : nat) (f : A -> A) : option A :=
match lim with
| O => None
| S lim' =>
match y_opt lim' f with
| None => None
| Some x => Some (f x)
end
end.