coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Pierre Courtieu <Pierre.Courtieu AT univ-orleans.fr>
- To: chris jhons <chrisformal AT yahoo.co.uk>
- Cc: coq-club AT pauillac.inria.fr
- Subject: Re: [Coq-Club] functions for even
- Date: Tue, 21 Sep 2004 17:55:11 +0200
- List-archive: <http://pauillac.inria.fr/pipermail/coq-club/>
On 21 sep 2004, chris jhons wrote:
> Dear all,
>
> I want to define the following functions in Coq. Can you tell me how?
>
This is rather straightforward:
Fixpoint even (n:nat) : bool :=
match n with
| O => true
| 1 => false
| S (S n') => even n'
end.
Eval compute in even (S (S O)).
Eval compute in even (S (S (S O))).
(* even' and odd are mutually recursive: *)
Fixpoint even' (n:nat) : bool :=
match n with
| O => true
| S n' => odd n'
end
with odd (n:nat) : bool :=
match n with
| O => false
| S n' => even' n'
end
.
Eval compute in even' (S (S O)).
Eval compute in even' (S (S (S O))).
Cheers,
Pierre Courtieu
- [Coq-Club] functions for even, chris jhons
- Re: [Coq-Club] functions for even, Pierre Courtieu
Archive powered by MhonArc 2.6.16.