Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] trying to use Init.Wf.Fix .

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] trying to use Init.Wf.Fix .


chronological Thread 
  • From: Robert R Schneck-McConnell <schneck AT math.berkeley.edu>
  • To: dehlinge AT dpt-info.u-strasbg.fr
  • Cc: coq-club AT pauillac.inria.fr
  • Subject: Re: [Coq-Club] trying to use Init.Wf.Fix .
  • Date: Wed, 5 May 2004 11:09:58 -0700
  • List-archive: <http://pauillac.inria.fr/pipermail/coq-club/>

> I'm trying to translate the following function into Coq :
>       f n = 0         if n=1
>       f n = n+1       if n is even
>       f n = n-3       if n is odd

No recursion means you don't need to use Fixpoint or Fix.
How about:

Require Export Even.

(* Must redefine this lemma with "Defined" instead of "Qed" *)
Lemma even_odd_dec : forall n, {even n} + {odd n}.
Proof.
induction n.
auto with arith.
elim IHn; auto with arith.
Defined.

Definition f (n:nat) : nat :=
  match n with
  | 1 => 0
  | n =>
      match even_odd_dec n with
      | left _ => n + 1
      | right _ => n - 3
      end
  end.

Eval compute in (f 5).

Robert




Archive powered by MhonArc 2.6.16.

Top of Page