Skip to Content.
Sympa Menu

coq-club - [Coq-Club] Force Principle Argument Recognition

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

[Coq-Club] Force Principle Argument Recognition


Chronological Thread 
  • From: Kenneth Adam Miller <kennethadammiller AT gmail.com>
  • To: coq-club Club <coq-club AT inria.fr>
  • Subject: [Coq-Club] Force Principle Argument Recognition
  • Date: Sun, 29 Nov 2015 20:05:28 -0500
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=kennethadammiller AT gmail.com; spf=Pass smtp.mailfrom=kennethadammiller AT gmail.com; spf=None smtp.helo=postmaster AT mail-yk0-f181.google.com
  • Ironport-phdr: 9a23:upscQB9K5AFP8/9uRHKM819IXTAuvvDOBiVQ1KB92uocTK2v8tzYMVDF4r011RmSDdidu6wP0ruO+4nbGkU+or+5+EgYd5JNUxJXwe43pCcHRPC/NEvgMfTxZDY7FskRHHVs/nW8LFQHUJ2mPw6anHS+4HYoFwnlMkItf6KuStOU35r8jrHqs7ToICx2xxOFKYtoKxu3qQiD/uI3uqBFbpgL9x3Sv3FTcP5Xz247bXianhL7+9vitMU7q3cYk7sb+sVBSaT3ebgjBfwdVWx+cjN92Mq+vh7aCACL+3FUeWELmFIcCA/cqRr+Q53Zsy3gt+M71jPMbuPsSrVhejmk6ap3SFfBhC4Cfxs49GXakIQkj69dph+9pxVzyovRYYWROeBWcabUfNdcTm1ECJUCHxddC5+xOtNcR9EKOvxV+syk/wMD

Hello all,

I don't use Coq except for my personal hobbyist time, and I would just like to explain that I'm working through the manual problems from the Software Foundations book. Here's my current problem:

First, write a function to convert natural numbers to binary
        numbers.  Then prove that starting with any natural number,
        converting to binary, then converting back yields the same
        natural number you started with.

I'm having an awful time getting this:

Require Import Coq.Arith.Arith_base.
Require Import Coq.ZArith.ZArith.
Require Import Coq.Init.Datatypes.
Local Open Scope Z_scope.
Fixpoint nat_to_bin n := 
  let f :=fun f index =>
  (if (Zeq_bool index 0) then Terminus
   else if (Zeq_bool index (log_inf n)) then
          Biton (nat_to_bin (Z.to_pos (Zminus (Z.pos n) (log_inf n))) (index-1))
        else
          Bitoff (nat_to_bin n (index-1))
  ) in f (log_inf n).


To go through the coq interpreter, the error being. Here are my thoughts of what is going on:

Match statements allow the "magic" that the Coq interpreter executes with to see according to the type what the direction is in terms of a fixpoint in the knaster-tarski understanding, and so therefore can see when a particular variable is on a strictly descending nature. Therefore, at times it may see when a function will terminate. I need to use if statements because I want to look for a certain value of Z, and I didn't want to use peano integers for index. I tried to make the internal anonymous fixpoint because I wanted the system to recognize that index is the parameter that is being iterated over.

Does anybody have any advice how to move forward so that I can get the Coq interpreter to accept my definition?



Archive powered by MHonArc 2.6.18.

Top of Page