-
Notifications
You must be signed in to change notification settings - Fork 81
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
Fix the translation of cofix to fix #1070
Conversation
…azy at the toplevel of the definition
What does this do on CoInductive stream := Cons { head : nat; tail : stream }.
Definition mk n tail := {| head := n; tail := {| head := n; tail := tail |} |}.
CoFixpoint repeat n :=
mk n (repeat n). ? |
I might be misreading this, but the change doesn't look correct to me. I think in the cases where CoFixpoint ones := {| head := 1; tail := ones |}.
CoFixpoint maybe_ones (b : bool) := if b then ones else {| head := 2; tail = maybe_ones b |}
In general, the translation should be to wrap the entire body of a cofixpoint in |
Shouldn't it rather become:
(Note the
Yes, I agree. I'll push the new code I have first, which also handles going under defined constants as the guard does and then correct it. |
With the latest definition in this branch I get:
Which looks fine to me! Indeed the general moto should be "Use a |
This moves the head constructors's lazy of a cofixpoint definition to the toplevel of the fixpoint definition to avoid creating diverging functions in call-by-value semantics. See stedolan/malfunction#39 for an explanation of the problem with Coq's extraction which we mimicked.