coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: AUGER Cédric <sedrikov AT gmail.com>
- To: Adam Chlipala <adamc AT csail.mit.edu>
- Cc: fengsheng <fsheng1990 AT 163.com>, coq-club AT inria.fr
- Subject: Re: [Coq-Club] How to define the devision on nat by using Fixpoint
- Date: Thu, 20 Dec 2012 20:36:37 +0100
Le Thu, 20 Dec 2012 11:54:08 -0500,
Adam Chlipala
<adamc AT csail.mit.edu>
a écrit :
> Maybe I'm missing something, but, the way I read the question, the
> (very straightforward) solution is to use this function:
>
> Fixpoint div2 (n : nat) : nat :=
> match n with
> | S (S n') => S (div2 n')
> | _ => O
> end.
In the original mail, it was question of halfing to be able to
translate from nat to a binary representation. So even/odd information
is also relevant.
> On 12/19/2012 11:29 PM, AUGER Cédric wrote:
> > Le Thu, 20 Dec 2012 04:17:21 +0100 (CET),
> > "fengsheng"<fsheng1990 AT 163.com>
> > a écrit :
> >
> >
> >> when I wrote a function to convert natural numbers to binary
> >> numbers,I met a problem:how to take the value of a number half.
> >>
> > [...]
> > Fixpoint div2 (m n:nat): nat*bool :=
> > match n with
> > | O => (m, false)
> > | S O => (m, true)
> > | S (S n) => div2 (S m) n
> > end.
> >
>
- [Coq-Club] How to define the devision on nat by using Fixpoint, fengsheng, 12/20/2012
- Re: [Coq-Club] How to define the devision on nat by using Fixpoint, Jason Gross, 12/20/2012
- Re: [Coq-Club] How to define the devision on nat by using Fixpoint, AUGER Cédric, 12/20/2012
- Re: [Coq-Club] How to define the devision on nat by using Fixpoint, Adam Chlipala, 12/20/2012
- Re: [Coq-Club] How to define the devision on nat by using Fixpoint, AUGER Cédric, 12/20/2012
- Re: [Coq-Club] How to define the devision on nat by using Fixpoint, Adam Chlipala, 12/20/2012
Archive powered by MHonArc 2.6.18.