Skip to Content.
Sympa Menu

coq-club - [Coq-Club] SF, Fibonacci, and "Error: This clause is redundant."

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

[Coq-Club] SF, Fibonacci, and "Error: This clause is redundant."


chronological Thread 
  • From: Andrew Pennebaker <andrew.pennebaker AT gmail.com>
  • To: Coq <coq-club AT inria.fr>
  • Subject: [Coq-Club] SF, Fibonacci, and "Error: This clause is redundant."
  • Date: Thu, 3 Nov 2011 15:12:32 -0400

I'm following the Software Foundations tutorial, and I decided to write a fibonacci function.

Inductive nat : Set :=
| O : nat
| S : nat -> nat.

Fixpoint plus (n m : nat) : nat :=
match n with
| O => m
| S n' => S (plus n' m)
end.

Fixpoint mult (n m : nat) : nat :=
match n with
| O => O
| S n' => plus m (mult n' m)
end.

Definition one : nat := S O.
Definition two : nat := S(S O).

Fixpoint minus (n m : nat) : nat :=
match n, m with
| O, _ => O
| S _, O => n
| S n', S m' => minus n' m'
end.

Fixpoint fib (n : nat) : nat :=
match n with
| O => O
| one
| _ => plus (fib (minus n one)) (fib (minus n two))
end.

When I tell CoqIDE to go forward with the fib function, it reports "Error: This clause is redundant", and underlines the last case in fib:

_ => plus (fib (minus n one)) (fib (minus n two))

What am I doing wrong?

Cheers,

Andrew Pennebaker
www.yellosoft.us



Archive powered by MhonArc 2.6.16.

Top of Page