coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Wilayat Khan <wilayatk AT gmail.com>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] Question while learning Coq from Software Foundations book
- Date: Thu, 25 May 2017 13:10:53 +0500
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=wilayatk AT gmail.com; spf=Pass smtp.mailfrom=wilayatk AT gmail.com; spf=None smtp.helo=postmaster AT mail-lf0-f41.google.com
- Ironport-phdr: 9a23:1Ylh4h8XUWimCv9uRHKM819IXTAuvvDOBiVQ1KB40O8cTK2v8tzYMVDF4r011RmSDNudtq0My7KP9fuxBipYudfJmUtBWaIPfidGs/lepxYnDs+BBB+zB9/RRAt+Iv5/UkR49WqwK0lfFZW2TVTTpnqv8WxaQU2nZkJ6KevvB4Hdkdm82fys9J3PeQVIgye2ba9vIBmsowjcssgbjZFiJ6sz1xDFpmdEd/lMyW5mIV+enQzw6tus8JJm7i9dp+8v+8lcXKr1eKg1UaZWADM6PW4r+cblrwPDTQyB5nsdVmUZjB9FCBXb4R/5Q5n8rDL0uvJy1yeGM8L2S6s0WSm54KdwVBDokiYHOCUn/2zRl8d9kbhUoBOlpxx43o7UfISYP+dwc6/BYd8XQ3dKU8BMXCJDH4y8dZMCAOgPPehYoYfzpEYAowWiCgS3Huzj1iVFi2Xq0aEm0eksFxzN0gw6H9IJtXTZtNX6NKYWUe+vzKjH1ynDZO5T1zf98ofIdA0qrPaCXLJxdcre00kuGBnZjlWTsoHlMDaV2f4Ms2if9eZvSeWvi2s+pgx3vzOhxd8sh5HXio4Jzl3I7yZ0zYYvKdGmVUJ2YcSoHZRNuyycKoB4WNktQ3tytyY/0rAGuYC0fCwNyJk/wh7Qcf2Hc4yR7hLnWuadPS50hHxqdb6inRqy/k+gyurzVsmwzllGtDZKkt7JtnwV1hzT7NaISudl80u/xTqC0xrf5+JELEwui6bXNp4szqQ/m5YOqUjDGzX5mETyjK+YbEUk/e2o5vzpY7Xnop+TLY91hRviMqQtgcG/DuE4PRIPX2if4+izyLrj/UjhTLVQkvI2irXZsIzdJckDuqG5BBZV3p8/5Ba7Ejepy88VnWIHLVJAYBKIlZLlO1DIIPDiDPewmU6gkDlxx6OOArq0CZLUa3PHjb3JfLBn6kcaxhBg48pY4sdrC7UIMfvvEmzxvdqQWgA4NwWlyvrkINp434IaH2mIB/nKY+vprVaU67d3cKG3b4gPtWOlJg==
This is Coq's way of representing elements of a type. S is the the constructor to add elements to type nat. The letter O represents an element of type (nat), which is normally interpreted as 0 (you can interpret it as another number too) and the constructor S defines a way how to generate other elements starting from the first element O. The constructor S means: if n is a natural then so is S n. Normally, as S is interpreted as the successor of n, so n is the predecessor of S n.
On Wed, May 24, 2017 at 9:50 AM, nikhil kaushik <nikhilka585 AT gmail.com> wrote:
I was going through the book Software foundations to learn Coq and I got stuck on Numbers. In this Type definition
Inductive nat : Type := | O : nat | S : nat -> nat.
How does
O
becomes0
when we use it in definition ofDefinition pred (n : nat) : nat := match n with | O => O | S n' => n' end.
I only understood that
O
represents natural numbers andS
takes a natural number and return another natural number so S is a function. What I do not get is when our definednat
data type is used inpred
definition how doesO
represent0
? And how doesS n'
pattern match gives us predecessor ofn
.--~Nikhil Kaushik
- [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.