Skip to content
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

Program Fixpoint with wf fixannot and function return types #13812

Closed
allioux opened this issue Feb 2, 2021 · 4 comments · Fixed by #18834
Closed

Program Fixpoint with wf fixannot and function return types #13812

allioux opened this issue Feb 2, 2021 · 4 comments · Fixed by #18834
Labels
kind: bug An error, flaw, fault or unintended behaviour. part: program
Milestone

Comments

@allioux
Copy link

allioux commented Feb 2, 2021

There seems to be a problem in the proof term generated by Program Fixpoint when the wf fixannot is set and when the return type is a function type.

The problem occurs in the recursive call to foo in the following example:

Require Import Coq.Program.Wf.

Inductive Nat : Type :=
| O : Nat
| S : Nat -> Nat.

Inductive wfn : Nat -> Nat -> Prop :=
| wfn_suc : forall n, wfn n (S n)
| wfn_trans : forall x y z, wfn x y -> wfn y z -> wfn x z
.

Definition wfn_Sn (n : Nat) : Acc wfn (S n).
Admitted.

Lemma wfn_wf : well_founded wfn.
Admitted.

Program Fixpoint foo (n : Nat) {wf wfn n }: Nat -> Nat := fun x =>
  match n with
    O => x
  | S n => foo n _
  end.
Obligation 1. apply wfn_suc. Qed.
Obligation 3. unfold MR. apply wfn_wf. Qed.

foo n _ should be of type Nat -> Nat and the program shouldn't typecheck as a term of type Nat is expected.
Instead, it seems the argument is treated as implicit and the program is accepted.
When inspecting the produced proof obligation, one can see that the term x is passed to foo.
This problem does not occur when no fixannot is set.

My coq version is 8.13.

@herbelin herbelin added part: funind kind: bug An error, flaw, fault or unintended behaviour. labels Feb 3, 2021
@herbelin
Copy link
Member

herbelin commented Feb 3, 2021

There seems indeed to be a problem with wf here. Informing @coq/funind-maintainers.

@Matafou
Copy link
Contributor

Matafou commented Feb 3, 2021

This concerns Program, not Function. Informing @mattam82.

@herbelin
Copy link
Member

herbelin commented Feb 3, 2021

Oups, sorry.

@herbelin
Copy link
Member

herbelin commented Apr 1, 2024

Fixed by #18834. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug An error, flaw, fault or unintended behaviour. part: program
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants