Skip to Content.
Sympa Menu

coq-club - RE: [Coq-Club] Question while learning Coq from Software Foundations book

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

RE: [Coq-Club] Question while learning Coq from Software Foundations book


Chronological Thread 
  • From: "Soegtrop, Michael" <michael.soegtrop AT intel.com>
  • To: "coq-club AT inria.fr" <coq-club AT inria.fr>
  • Subject: RE: [Coq-Club] Question while learning Coq from Software Foundations book
  • Date: Wed, 24 May 2017 12:03:37 +0000
  • Accept-language: de-DE, en-US
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=michael.soegtrop AT intel.com; spf=Pass smtp.mailfrom=michael.soegtrop AT intel.com; spf=None smtp.helo=postmaster AT mga02.intel.com
  • Dlp-product: dlpe-windows
  • Dlp-reaction: no-action
  • Dlp-version: 10.0.102.7
  • Ironport-phdr: 9a23:zLUTdhOSJYFDxsBKI94l6mtUPXoX/o7sNwtQ0KIMzox0I/z/rarrMEGX3/hxlliBBdydsKMazbeJ++C4ACpbsMnH6ChDOLV3FDY7yuwu3DYcSPafDkP6KPO4JwcbJ+9lEGFfwnegLEJOE9z/bVCB6le77DoVBwmtfVEtfre9FYHdldm42P6v8JPPfQpImCC9YbRvJxmqsAndrMcbjI9jJ6oryhbEoGZDd+BKyW91P16ekRLx68Wq8JJ/7yhcvu8q+tJdX6n9Y6k3QrtUASg8PWwy+MPlqwTIQxGV5nsbXGUWkx5IDBbA4RrnQJr/sTb0u/Rk1iWCMsL4Ub47WTK576d2UxDokzsINyQ48G7MlMN9ir9QrQ+7qBx+x47UZ5yVNOZ7c6jAc94WWXZNU8BMXCFHH4iybZYAD/AZMOhYsYfzukcOoxW9CwmiBuzvyyNHiXDt0KIgz+gsFRvL0BA8E98MtnnfsdX7NL0VUeCw1KTEwyjNb/RI1jfy9IjIaBchoemUUbltdsTRyFUgFwPfgVqOrYzpMS6e2+MIs2ia8+VgVfighHAjqw1ruTivwdkjiobVhoIPzVDE7T50wIczJd2kVkF7ZcSoH4dXtyGfLoZ7RN4pTW9vuCY/0LIGuJi7cTALyJQh2x7QdfiHf5KV7R39UuuaPDR2hGp9db6iiRu//lKsxvDyW8S7ylpGsyRIn9jWunwTyxDf8tWLR/pz80u71zuC2Rrf5v9KLE0wj6bXNp0szqMompYOsEnOGjX6lFv2gaKZbEko5PKk5/nnb7jooJKXKpV6hRvkMqs0n8yyGeQ4PRYKX2ic4em80bLj8lflTLlUlPE2k6/ZsIzEKsQfvKK2HwhV0oM75xa+CTepzsgYkGEaIF9Ldx+LlZXlNl/BLfziEPuyjVWhnC11y/zaJrHhB4/CLnnHkLfvZ7Z97EtcxRI2zdBe+51UCqsOL+z3WkPrr9zYCQE2MwOow+b9D9V9zpgTWWOJAq+FLqzStUWE6f4oI+mJfIMVoiryK+A55/7yin80gUMSfa6w3ZcOdH+4GulmLF6CbHr3gtYBFH8KsRAkQOzrjl2CSz9TaGyoU6Iy/DFoQL6hWM3IQZnoi7ic1g+6GIdXbyZIEBrERXzvbsCPX+oGQCOUOM5o1DIeA+uPUYgkgFuVswL116BgNq6c3ywTtZvu0JI9s+jSnhE7+DgyFMOQ3H2XSHlcn2UUSjtw16d69x8ugmyf2LR11qQLXedY4OlEB183

Dear Nikhil,

 

adding to what Benoit and David wrote: the conversion between 0 and O, 1 and S O and so on is an integrated notational transformation done by Coq. Essentially when reading 1 Coq will convert it to S O and when writing S O it will convert it to 1 (unless you have printing notation switched off). As far as I know this is “hard wired” and you cannot define such transformations yourself. Also this notation only works for various types of numbers defined in Coq libraries. It won’t work for numbers you define on your own (you can define coercions, though).

 

Best regards,

 

Michael

 

From: coq-club-request AT inria.fr [mailto:coq-club-request AT inria.fr] On Behalf Of nikhil kaushik
Sent: Wednesday, May 24, 2017 6:51 AM
To: coq-club AT inria.fr
Subject: [Coq-Club] Question while learning Coq from Software Foundations book

 

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 becomes 0 when we use it in definition of

Definition pred (n : nat) : nat :=
  match n with
    | O => O
    | S n' => n'
  end.

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 preddefinition how does O represent 0? And how does S n' pattern match gives us predecessor of n.

 

--

~Nikhil Kaushik

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928




Archive powered by MHonArc 2.6.18.

Top of Page