coq-hurry - Coq in a Hurry Yves Bertot February 2010 These...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Coq in a Hurry Yves Bertot February 2010 These notes provide a quick introduction to the Coq system and show how it can be used to define logical concepts and functions and reason about them. It is designed as a tutorial, so that readers can quickly start their own experiments, learning only a few of the capabilities of the system. A much more comprehensive study is provided in [1], which also provides an extensive collection of exercises to train on. 1 Expressions and logical formulas The Coq system provides a language in which one handles formulas, verifies that they are well-formed, and proves them. Formulas may also contain functions and limited forms of computations are provided for these functions. 1.1 Writing correct formulas The first thing you need to know is how you can check whether a formula is well-formed. The command is called Check . Here are a few examples, which use a few of the basic objects and types of the system. Commands are always terminated by a period. In the following, text in this style is text that the user sends to the Coq system, while text in this style is the answer of the system. Check True. True : Prop Check False. False : Prop Check 3. 3 : nat Check (3+4). 3 + 4 : nat Check (3=5). 3=5 : Prop 1 inria-00001173, version 4 - 23 Feb 2010 Check (3,4). (3,4) : nat * nat Check ((3=5)/\True). 3 = 5 /\ True : Prop Check nat -> Prop. nat -> Prop : Type Check (3 <= 6). 3 <= 6 : Prop The notation A : B is used for two purposes: the first is to indicate that the type of the expression A is the expression B , the second purpose which will appear later is to express that A is a proof of B . This notation can also be used in expressions we build, if we want to be explicit about the type an expression should have: Check (3,3=5):nat*Prop. (3,3=5):nat * Prop : nat * Prop Among the formulas, some can be read as logical propositions (they have type Prop ), others may be read as numbers (they have type nat ), others may be read as elements of more complex data structures. You can also try to check badly formed formulas and in this case the Coq system returns an informative error statement. Complex formulas can be constructed by combining propositions with logical connec- tives, or other expressions with addition, multiplication, the pairing construct, and so on. You can also construct a new function by using the keyword fun , which replaces the λ symbol of lambda calculus and similar theories. The following Check command contains the description of a function that takes a number x of type nat as input and returns the proposition that x is equal to 3 . The next Check command contains a logical proposition which can be read as For every natural number x , either x is less than 3 or there exists a natural number y such that x = y + 3....
View Full Document

This note was uploaded on 04/03/2010 for the course SOC cs5209 taught by Professor Drmartin during the Spring '10 term at National University of Singapore.

Page1 / 42

coq-hurry - Coq in a Hurry Yves Bertot February 2010 These...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online