coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Andreas Ames <andreas.ames AT gmx.de>
- To: coq-club AT inria.fr
- Subject: [Coq-Club] Question about recursive function
- Date: Sun, 09 Jul 2017 18:04:35 +0200
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=andreas.ames AT gmx.de; spf=Pass smtp.mailfrom=andreas.ames AT gmx.de; spf=None smtp.helo=postmaster AT mout.gmx.net
- Ironport-phdr: 9a23:pAOQiBMO6MkAvlda3K8l6mtUPXoX/o7sNwtQ0KIMzox0LPX5rarrMEGX3/hxlliBBdydsKMbzbKO+4nbGkU4qa6bt34DdJEeHzQksu4x2zIaPcieFEfgJ+TrZSFpVO5LVVti4m3peRMNQJW2aFLduGC94iAPERvjKwV1Ov71GonPhMiryuy+4ZPebgFKiTanfb9+MAi9oBnMuMURnYZsMLs6xAHTontPdeRWxGdoKkyWkh3h+Mq+/4Nt/jpJtf45+MFOTav1f6IjTbxFFzsmKHw65NfqtRbYUwSC4GYXX3gMnRpJBwjF6wz6Xov0vyDnuOdxxDWWMMvrRr0yRD+s7bpkSAXwhSkHKTA37W/ZhM9+g61UvB2svAB/z5LIbI2JKPZzZL/RcNUHTmRBRMZRUClBD5ugYosJEuUBJ/hXoJPmp1ATsRa+ABejBPjywTJPnHD227A10/4/Hg7cxwwsBcgBsHHKo9XuL6oSXuW1zabSwTrecfxbwDHw45XLfBA5ufyAQ698fdTLxUUxCQ/IjE+cpZHnMj+PyOgBrnCX4uhiWO61lmIqqQJ8riKyysswkIXFm5wZx17C+C5k2og6P8e4R1R+YdO8EJtfqSWaN4xuT8MnRGFopTo6xqcJuZ6+cykG0pInyADDa/CfcoiI5AzsVPqJLDtmmX5pZqiziwis/UWi0OHwS8u53ExUoiZYitXMs2oC1x3X6siJUPt9+UKh1C6V2ADV9+5EO147mrDAK5I72LEwk4QcsV/YEy/5nUX3g7WaeVg69eSw8eTofq3mpoOAN49zkgzxLqMumtWmDeskNggOQnOU9P+n1Lzj+E35WK9Fguc3kqnfqpDaJN4UqrS3Aw9Pgc4f7EO0CC7j29AFl1EGKkhEcVSJldvHIVbLddn+Ae2yik/kuTJm3LiSN7vtGJjENT7Klbr6Vbl4+whQxVxgnphk+5tIB+RZc7rIUUjruYmAAw==
Hi all,
I am ridiculously new to Coq, proof assistants in genral etc. My
primary interest is formal verification of real-world programs,
currently with frama-c. Therefore I am working through Software
Foundations, which seems to be exactly what I need to learn something
about Coq.
Unfortunately I am currently stuck at the end of the second chapter
about induction, where I would like to normalise the inductive type
"bin":
Inductive bin : Type :=
| B0 : bin (* binary zero *)
| BEV : bin -> bin (* even binary: 2*x *)
| BOD : bin -> bin. (* odd binary: 2*x+1 *)
The task is to make the notation of binary numbers unambiguous by
providing a normalisation for such numbers, because "BEV B0 = B0".
My idea to achieve this is to have a helper "normalize'" replacing a
single "BEV B0" with "B0" and call that from "normalize" as often as
needed. If normalize' returns its argument, ecursion has to stop.
Otherwise normalize has to recurse.
Fixpoint normalize' (b : bin) : bin :=
match b with
| B0 => B0
| BEV B0 => B0
| BEV b' => BEV (normalize' b')
| BOD b' => BOD (normalize' b')
end.
Unfortunately I am lacking the syntactic abilities to do so and the Coq
reference of "match" is still beyond my reach. I have tried things like
the following to no avail:
Fixpoint normalize (b : bin) : bin :=
match (normalize' b) with
| b => b
| _ => normalize _
end.
Could you please provide me some hint how to write normalize in a way
aceptable to Coq?
TIA,
Andreas
--
"I don't want to belong to any club that will have me as a member." G. Marx
- [Coq-Club] Question about recursive function, Andreas Ames, 07/09/2017
- Re: [Coq-Club] Question about recursive function, Adam Chlipala, 07/09/2017
Archive powered by MHonArc 2.6.18.