coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Arnaud Spiwack <aspiwack AT lix.polytechnique.fr>
- To: Vladimir Voevodsky <vladimir AT ias.edu>
- Cc: Coq Club <coq-club AT inria.fr>
- Subject: Re: [Coq-Club] why it does not work?
- Date: Mon, 16 Dec 2013 18:03:14 +0100
Dear Vladimir,
It's due to the constructor restriction of fixpoints: a fixpoint is only unfolded when it's structural argument starts with a constructor. Here, Coq infers that the structural argument is n, and since you pass a variable as a first argument in "minuswithzero n O", the reduction is stuck. A fix is to specify the structural argument in the Fixpoint definition:
It's due to the constructor restriction of fixpoints: a fixpoint is only unfolded when it's structural argument starts with a constructor. Here, Coq infers that the structural argument is n, and since you pass a variable as a first argument in "minuswithzero n O", the reduction is stuck. A fix is to specify the structural argument in the Fixpoint definition:
Fixpoint minuswithzero ( n m : nat ) { struct m } : nat :=
match m , n with
| O , n => n
| S k , O => O
| S k , S l => minuswithzero l k
end .
Lemma test ( n : nat ) : paths n ( minuswithzero n O ) .
Proof . intro . unfold minuswithzero . apply idpath .
match m , n with
| O , n => n
| S k , O => O
| S k , S l => minuswithzero l k
end .
Lemma test ( n : nat ) : paths n ( minuswithzero n O ) .
Proof . intro . unfold minuswithzero . apply idpath .
On 16 December 2013 17:34, Vladimir Voevodsky <vladimir AT ias.edu> wrote:
Hello,
could someone explain to me why the following code does not compile?
Fixpoint minuswithzero ( n m : nat ) : nat :=
match m , n with
| O , n => n
| S k , O => O
| S k , S l => minuswithzero l k
end .
Lemma test ( n : nat ) : paths n ( minuswithzero n O ) .
Proof . intro . unfold minuswithzero . apply idpath .
V.
- [Coq-Club] why it does not work?, Vladimir Voevodsky, 12/16/2013
- Re: [Coq-Club] why it does not work?, Arnaud Spiwack, 12/16/2013
Archive powered by MHonArc 2.6.18.