coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Benoît Viguier <beviguier AT gmail.com>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] Question while learning Coq from Software Foundations book
- Date: Wed, 24 May 2017 11:25:28 +0200
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=beviguier AT gmail.com; spf=Pass smtp.mailfrom=beviguier AT gmail.com; spf=None smtp.helo=postmaster AT mail-wm0-f49.google.com
- Ironport-phdr: 9a23:Y7VrKh9PcueNE/9uRHKM819IXTAuvvDOBiVQ1KB30uwcTK2v8tzYMVDF4r011RmSDNudtq0My7KP9fuxBipYudfJmUtBWaIPfidGs/lepxYnDs+BBB+zB9/RRAt+Iv5/UkR49WqwK0lfFZW2TVTTpnqv8WxaQU2nZkJ6KevvB4Hdkdm82fys9J3PeQVIgye2ba9vIBmsowjcssgbjZFiJ6sz1xDFpmdEd/lMyW5mIV+enQzw6tus8JJm7i9dp+8v+8lcXKr1eKg1UaZWADM6PW4r+cblrwPDTQyB5nsdVmUZjB9FCBXb4R/5Q5n8rDL0uvJy1yeGM8L2S6s0WSm54KdwVBDokiYHOCUn/2zRl8d9kbhUoBOlpxx43o7UfISYP+dwc6/BYd8XQ3dKU8BMXCJDH4y8dZMCAfcfM+ZWr4fzpFUAohWxCgauGOzi0TBIimPs0KM9z+gsHwPL0Qo9FNwOqnTUq9D1Ob8PXO+ryqnIyjvbb+9O1jjy6YjIfQ0hofCSUrJqbMHczlIgGB3bjlWRpozlIjKV2foXs2WA4OpgUPigi28jqw1rvjevwcIsh5DPi4kIxF7E8iB5z5w0Jd2+UEN7f9+kEJRNtyGbKYR2WNkuQ2dsuCs817YIuoa7cTAIxZko3RLTduKLfoiS7h/gSuqdOzh1iXZ9dL6iiBu/8VKsxvDhWsS1ylpGsyRIn9fWunwQ1BHe6c6KQeZn8Ei7wzaAzQXT5/lEIU8qkarbLIYswrsqmZoStUTPByH3mEDqgKOPeEUp9eyl5/7oYrXhoZ+cOIt0hR/kPqsyncy/BPw0MgkIX2eF5eSxzL/u8ELjTLlXkPE7krPVvZPEKcgBqaO0BxdZ0oM55Ba+Czem3s4YnX4CLF9dYx2IkZbpO1DBIPDlDPewnU6snSxkx/DDJLLhA5HNImLfn7fmeLZx81RcxxYrzdBD+5JUDakML+70Wk/ordDXEhs5MxGvzOv8E9V81oYeWXqVDaODMaPSt0WI5uM1LOWWao8VomW1F/9w7Pn3yHQ9hFU1fK+z3JJRZmrrMO5hJhCzbHzrBMs2L2YFowszVqS+glCcUDFOZnuod6057zA/TomhCNGQFciWnLWd0XLjTdVtbWdcBwXUHA==
Hi Nikhil, you got it a bit wrong. 0 does not represent natural numbers. It
represent the number zero. Coq uses the Peano definition of
natural number (or recursive definition) : This gives us : etc... the pred function return the predecessor or the number "before". If you were to see it as a function it would be : f : x -> The predecessor of 3 is 2 or pred (S (S (S 0))) = S (S 0). If you try this definition of pred, it won't compile : it is missing a case.
the match in Coq checks the type of n, sees the induction principle
and notice that you are missing the case where n = 0.In the inductive definition of nat, S and 0 are what we call "constructors". Hope this helps. On 05/24/2017 06:50 AM, nikhil kaushik
wrote:
I
was going through the book Software
foundations to learn Coq and
I got stuck on Numbers. In this Type definition
How
does O becomes 0 when
we use it in definition of
I
only understood that O represents
natural numbers and S takes
a natural number and return another natural number so S is
a function. What I do not get is when our defined nat data
type is used in pred definition
how does O represent 0 ?
And how does S n' pattern
match gives us predecessor of n .
~Nikhil Kaushik
-- Kind regards, Benoît Viguier Software Engineer - PhD Student | Cryptography & Formal Methods Radboud University | Mercator 1, room 03.17, Toernooiveld 212 6525 EC Nijmegen, the Netherlands | www.viguier.nl -------------------------------------------------------------------------- This message (and any attachments) is intended solely for the addressee(s) and may contain confidential information. If you are not the addressee, do not copy this message (and any attachments), forward or share this message with third parties. You are requested to notify the sender immediately and delete this message. |
Attachment:
signature.asc
Description: OpenPGP digital signature
- [Coq-Club] Question while learning Coq from Software Foundations book, nikhil kaushik, 05/24/2017
- Re: [Coq-Club] Question while learning Coq from Software Foundations book, Benoît Viguier, 05/24/2017
- Re: [Coq-Club] Question while learning Coq from Software Foundations book, David P Á, 05/24/2017
- RE: [Coq-Club] Question while learning Coq from Software Foundations book, Soegtrop, Michael, 05/24/2017
- Re: [Coq-Club] Question while learning Coq from Software Foundations book, Wilayat Khan, 05/25/2017
- Re: [Coq-Club] Question while learning Coq from Software Foundations book, Matej Košík, 05/25/2017
Archive powered by MHonArc 2.6.18.