# Type Theory & Functional Programming

Save this PDF as:

Size: px
Start display at page:

## Transcription

1 Type Theory & Functional Programming Simon Thompson Computing Laboratory, University of Kent March 1999 c Simon Thompson, 1999 Not to be reproduced

2 i

3 ii To my parents

4 Preface Constructive Type theory has been a topic of research interest to computer scientists, mathematicians, logicians and philosophers for a number of years. For computer scientists it provides a framework which brings together logic and programming languages in a most elegant and fertile way: program development and verification can proceed within a single system. Viewed in a different way, type theory is a functional programming language with some novel features, such as the totality of all its functions, its expressive type system allowing functions whose result type depends upon the value of its input, and sophisticated modules and abstract types whose interfaces can contain logical assertions as well as signature information. A third point of view emphasizes that programs (or functions) can be extracted from proofs in the logic. Up until now most of the material on type theory has only appeared in proceedings of conferences and in research papers, so it seems appropriate to try to set down the current state of development in a form accessible to interested final-year undergraduates, graduate students, research workers and teachers in computer science and related fields hence this book. The book can be thought of as giving both a first and a second course in type theory. We begin with introductory material on logic and functional programming, and follow this by presenting the system of type theory itself, together with many examples. As well as this we go further, looking at the system from a mathematical perspective, thus elucidating a number of its important properties. Then we take a critical look at the profusion of suggestions in the literature about why and how type theory could be augmented. In doing this we are aiming at a moving target; it must be the case that further developments will have been made before the book reaches the press. Nonetheless, such an survey can give the reader a much more developed sense of the potential of type theory, as well as giving the background of what is to come. iii

5 iv PREFACE Outline It seems in order to give an overview of the book. Each chapter begins with a more detailed introduction, so we shall be brief here. We follow this with a guide on how the book might be approached. The first three chapters survey the three fields upon which type theory depends: logic, the λ-calculus and functional programming and constructive mathematics. The surveys are short, establishing terminology, notation and a general context for the discussion; pointers to the relevant literature and in particular to more detailed introductions are provided. In the second chapter we discuss some issues in the λ-calculus and functional programming which suggest analogous questions in type theory. The fourth chapter forms the focus of the book. We give the formal system for type theory, developing examples of both programs and proofs as we go along. These tend to be short, illustrating the construct just introduced chapter 6 contains many more examples. The system of type theory is complex, and in chapter which follows we explore a number of different aspects of the theory. We prove certain results about it (rather than using it) including the important facts that programs are terminating and that evaluation is deterministic. Other topics examined include the variety of equality relations in the system, the addition of types (or universes ) of types and some more technical points. Much of our understanding of a complex formal system must derive from out using it. Chapter six covers a variety of examples and larger case studies. From the functional programming point of view, we choose to stress the differences between the system and more traditional languages. After a lengthy discussion of recursion, we look at the impact of the quantified types, especially in the light of the universes added above. We also take the opportunity to demonstrate how programs can be extracted from constructive proofs, and one way that imperative programs can be seen as arising. We conclude with a survey of examples in the relevant literature. As an aside it is worth saying that for any formal system, we can really only understand its precise details after attempting to implement it. The combination of symbolic and natural language used by mathematicians is surprisingly suggestive, yet ambiguous, and it is only the discipline of having to implement a system which makes us look at some aspects of it. In the case of T T, it was only through writing an implementation in the functional programming language Miranda 1 that the author came to understand the distinctive role of assumptions in T T, for instance. The system is expressive, as witnessed by the previous chapter, but are programs given in their most natural or efficient form? There is a 1 Miranda is a trade mark of Research Software Limited

6 v host of proposals of how to augment the system, and we look at these in chapter 7. Crucial to them is the incorporation of a class of subset types, in which the witnessing information contained in a type like ( x:a). B(x) is suppressed. As well as describing the subset type, we lay out the arguments for its addition to type theory, and conclude that it is not as necessary as has been thought. Other proposals include quotient (or equivalence class) types, and ways in which general recursion can be added to the system without its losing its properties like termination. A particularly elegant proposal for the addition of co-inductive types, such as infinite streams, without losing these properties, is examined. Chapter eight examines the foundations of the system: how it compares with other systems for constructive mathematics, how models of it are formed and used and how certain of the rules, the closure rules, may be seen as being generated from the introduction rules, which state what are the canonical members of each type. We end the book with a survey of related systems, implemented or not, and some concluding remarks. Bibliographic information is collected at the end of the book, together with a table of the rules of the various systems. We have used standard terminology whenever were able, but when a subject is of current research interest this is not always possible. Using the book In the hope of making this a self-contained introduction, we have included chapters one and two, which discuss natural deduction logic and the λ- calculus these chapters survey the fields and provide an introduction to the notation and terminology we shall use later. The core of the text is chapter four, which is the introduction to type theory. Readers who are familiar with natural deduction logic and the λ-calculus could begin with the brief introduction to constructive mathematics provided by chapter three, and then turn to chapter four. This is the core of the book, where we lay out type theory as both a logic and an functional programming system, giving small examples as we go. The chapters which follow are more or less loosely coupled. Someone keen to see applications of type theory can turn to chapter six, which contains examples and larger case studies; only occasionally will readers need to need to refer back to topics in chapter five. Another option on concluding chapter four is to move straight on to chapter five, where the system is examined from various mathematical perspectives, and an number of important results on the consistency, expressibility and determinacy are proved. Chapter eight should be seen as a continuation of this, as it explores topics of a foundational nature.

7 vi PREFACE Chapter seven is perhaps best read after the examples of chapter six, and digesting the deliberations of chapter five. In each chapter exercises are included. These range from the routine to the challenging. Not many programming projects are included as it is expected that readers will to be able to think of suitable projects for themselves the world is full of potential applications, after all. Acknowledgements The genesis of this book was a set of notes prepared for a lecture series on type theory given to the Theoretical Computer Science seminar at the University of Kent, and subsequently at the Federal University of Pernambuco, Recife, Brazil. Thanks are due to colleagues from both institutions; I am especially grateful to David Turner and Allan Grimley for both encouragement and stimulating discussions on the topic of type theory. I should also thank colleagues at UFPE, and the Brazilian National Research Council, CNPq, for making my visit to Brazil possible. In its various forms the text has received detailed commment and criticism from a number of people, including Martin Henson, John Hughes, Nic McPhee, Jerry Mead and various anonymous reviewers. Thanks to them the manuscript has been much improved, though needless to say, I alone will accept responsibility for any infelicities or errors which remain. The text itself was prepared using the LaTeX document preparation system; in this respect Tim Hopkins and Ian Utting have put up with numerous queries of varying complexity with unfailing good humour thanks to both of them. Duncan Langford and Richard Jones have given me much appreciated advice on using the Macintosh. The editorial and production staff at Addison-Wesley have been most helpful; in particular Simon Plumtree has given me exactly the right mixture of assistance and direction. The most important acknowledgements are to Jane and Alice: Jane has supported me through all stages of the book, giving me encouragement when it was needed and coping so well with having to share me with this enterprise over the last year; without her I am sure the book would not have been completed. Alice is a joy, and makes me realise how much more there is to life than type theory.

8 Contents Preface iii Introduction 1 1 Introduction to Logic Propositional Logic Predicate Logic Variables and substitution Quantifier rules Examples Functional Programming and λ-calculi Functional Programming The untyped λ-calculus Evaluation Convertibility Expressiveness Typed λ-calculus Strong normalisation Further type constructors: the product Base Types: Natural Numbers General Recursion Evaluation revisited Constructive Mathematics 59 4 Introduction to Type Theory Propositional Logic: an Informal View Judgements, Proofs and Derivations The Rules for Propositional Calculus vii

9 viii CONTENTS 4.4 The Curry Howard Isomorphism Some examples The identity function; A implies itself The transitivity of implication; function composition Different proofs and different derivations Conjunction and disjunction Quantifiers Some example proofs Base Types Booleans Finite types and The natural numbers Well-founded types trees Equality Equality over base types Inequalities Dependent Types Equality over the I-types Convertibility Definitions; convertibility and equality An example Adding one An example natural number equality Exploring Type Theory Assumptions Naming and abbreviations Naming Abbreviations Revising the rules Variable binding operators and disjunction Generalising The Existential Quantifier Derivability A is a type is derivable from a:a Unique types Computation Reduction The system T T Combinators and the system T T0 c T T0 c : Normalisation and its corollaries

10 CONTENTS ix Polymorphism and Monomorphism Equalities and Identities Definitional equality Convertibility Identity; the I type Equality functions Characterising equality Different Equalities A functional programming perspective Extensional Equality Defining Extensional Equality in T T Universes Type families Quantifying over universes Closure axioms Extensions Well-founded types Lists The general case - the W type Algebraic types in Miranda Expressibility The Curry Howard Isomorphism? Assumptions Normal Forms of Proofs Applying Type Theory Recursion Numerical functions Defining propositions and types by recursion Recursion over lists Recursion over lists A Case Study Quicksort Defining the function Verifying the function Dependent types and quantifiers Dependent Types The Existential Quantifier The Universal Quantifier Implementing a logic Quantification and Universes Quantification and Universes A Case Study Vectors

11 x CONTENTS Finite Types Revisited Vectors Proof Extraction; Top-Down Proof Propositional Logic Predicate Logic Natural Numbers Program Development Polish National Flag Program Transformation map and fold The Algorithm The Transformation Imperative Programming Examples in the literature Martin-Löf Goteborg Backhouse et al Nuprl Calculus of Constructions Augmenting Type Theory Background What is a specification? Computational Irrelevance; Lazy Evaluation The subset type The extensional theory Propositions not types Squash types The subset theory Gödel Interpretation Are subsets necessary? Quotient or Congruence Types Congruence types Case Study The Real Numbers Strengthened rules; polymorphism An Example Strong and Hypothetical Rules Polymorphic types Non-termination Well-founded recursion Well-founded recursion in type theory Constructing Recursion Operators The Accessible Elements

12 CONTENTS xi Conclusions Inductive types Inductive definitions Inductive definitions in type theory Co-inductions Streams Partial Objects and Types Modelling Foundations Proof Theory Intuitionistic Arithmetic Realizability Existential Elimination Model Theory Term Models Type-free interpretations An Inductive Definition A General Framework for Logics The Inversion Principle Conclusions Related Work The Nurpl System TK: A theory of types and kinds PX: A Computational Logic AUTOMATH Type Theories Concluding Remarks Rule Tables 360

13 xii CONTENTS

14 Introduction Types are types and propositions are propositions; types come from programming languages, and propositions from logic, and they seem to have no relation to each other. We shall see that if we make certain assumptions about both logic and programming, then we can define a system which is simultaneously a logic and a programming language, and in which propositions and types are identical. This is the system of constructive type theory, based primarily on the work of the Swedish logician and philosopher, Per Martin-Löf. In this introduction we examine the background in both logic and computing before going on to look at constructive type theory and its applications. We conclude with an overview of the book proper. Correct Programming The problem of correctness is ever-present in computing: a program is written with a particular specification in view and run on the assumption that it meets that specification. As is all too familiar, this assumption is unjustified: in most cases the program does not perform as it should. How should the problem be tackled? Testing cannot ensure the absence of errors; only a formal proof of correctness can guarantee that a program meets its specification. If we take a naïve view of this process, we develop the program and then, post hoc, give a proof that it meets a specification. If we do this the possibility exists that the program developed doesn t perform as it ought; we should instead try to develop the program in such a way that it must behave according to specification. A useful analogy here is with the types in a programming language. If we use a typed language, we are prevented by the rules of syntax from forming an expression which will lead to a type error when the program is executed. We could prove that a similar program in an untyped language shares this property, but we would have to do this for each program developed, whilst in the typed language it is guaranteed in every case. 1

15 2 INTRODUCTION Our aim, then, is to design a language in which correctness is guaranteed. We look in particular for a functional programming language with this property, as semantically the properties of these languages are the most straightforward, with a program simply being a value of a particular explicit type, rather than a state transformer. How will the new language differ from the languages with which we are familiar? The type system will have to be more powerful. This is because we will express a specification by means of a statement of the form p:p which is how we write the value p has the type P. The language of types in current programming languages can express the domain and range of a function, say, but cannot express the constraint that for every input value (of numeric type), the result is the positive square root of the value. If the language allows general recursion, then every type contains at least one value, defined by the equation x = x. This mirrors the observation that a non-terminating program meets every specification if we are only concerned with partial correctness. If we require total correctness we will need to design a language which only permits the definition of total functions and fully-defined objects. At the same time we must make sure that the language is expressive enough to be usable practically. To summarise, from the programming side, we are interested in developing a language in which correctness is guaranteed just as type-correctness is guaranteed in most contemporary languages. In particular, we are looking for a system of types within which we can express logical specifications. Constructive Logic Classical logic is accepted as the standard foundation of mathematics. At its basis is a truth-functional semantics which asserts that every proposition is true or false, so making valid assertions like A A, A A and x. P (x) x.p (x) which can be given the gloss If it is contradictory for no object x to have the property P (x), then there is an object x with the property P (x)

16 3 This is a principle of indirect proof, which has formed a cornerstone of modern mathematics since it was first used by Hilbert in his proof of the Basis Theorem about one hundred years ago. The problem with the principle is that it asserts the existence of an object without giving any indication of what the object is. It is a non-constructive method of proof, in other words. We can give a different, constructive, rendering of mathematics, based on the work of Brouwer, Heyting, Bishop and many others, in which every statement has computational content; in the light of the discussion above it is necessary to reject classical logic and to look for modes of reasoning which permit only constructive derivations. To explain exactly what can be derived constructively, we take a different foundational perspective. Instead of giving a classical, truth-functional, explanation of what is valid, we will explain what it means for a particular object p to be a proof of the proposition P. Our logic is proof-functional rather than truth-functional. The crucial explanation is for the existential quantifier. An assertion that z.p (z) can only be deduced if we can produce an a with the property P (a). A proof of z.p (z) will therefore be a pair, (a, p), consisting of an object a and a proof that a does in fact have the property P. A universal statement z.q(z) can be deduced only if there is a function taking any object a to a proof that Q(a). If we put these two explanations together, a constructive proof of the statement x. y.r(x, y) can be seen to require that there is a function, f say, taking any a to a value so that R(a, f a) Here we see that a constructive proof has computational content, in the shape of a function which gives an explicit witness value f a for each a. The other proof conditions are as follows. A proof of the conjunction A B can be seen as a pair of proofs, (p, q), with p a proof of A and q of B. A proof of the implication A B can be seen as a proof transformation: given a proof of A, we can produce a proof of B from it. A proof of the disjunction A B is either a proof of A or a proof of B, together with an indication of which (A or B). The negation A is defined to be the implication A, where is the absurd or false proposition, which has no proof but from which we can infer anything. A proof of A is thus a function taking a proof of A to a proof of absurdity. Given these explanations, it is easy to see that the law of the excluded middle will not be valid, as for a general A we cannot say that either A or A is provable. Similarly, the law of indirect proof will not be valid.

17 4 INTRODUCTION Having given the background from both computing and logic, we turn to examining the link between the two. The Curry Howard Isomorphism The central theme of this book is that we can see propositions and types as the same, the propositions-as-types notion, also known as the Curry Howard isomorphism, after two of the (many) logicians who observed the correspondence. We have seen that for our constructive logic, validity is explained by describing the circumstances under which p is a proof of the proposition P. To see P as a type, we think of it as the type of its proofs. It is then apparent that familiar constructs in logic and programming correspond to each other. We shall write p:p to mean, interchangeably, p is of type P and p is a proof of proposition P. The proofs of A B are pairs (a, b) with a from A and b from B the conjunction forms the Cartesian product of the propositions as types. Proofs of A B are functions from A to B, which is lucky as we use the same notation for implication and the function space. The type A B is the disjoint union or sum of the types A and B, the absurd proposition,, which has no proofs, is the empty type, and so on. The correspondence works in the other direction too, though it is slightly more artificial. We can see the type of natural numbers N as expressing the proposition there are natural numbers, which has the (constructive!) proofs 0, 1, 2,.... One elegant aspect of the system is in the characterisation of inductive types like the natural numbers and lists. Functional programmers will be familiar with the idea that functions defined by recursion have their properties proved by induction; in this system the principles of induction and recursion are identical. The dual view of the system as a logic and a programming language can enrich both aspects. As a logic, we can see that all the facilities of a functional programming language are at our disposal in defining functions which witness certain properties and so forth. As a programming language, we gain various novel features, and in particular the quantified types give us dependent function and sum types. The dependent function space ( x : A). B(x) generalises the standard function space, as the type of the result B(a) depends on the value a : A. This kind of dependence is usually not available in type systems. One example of its use is in defining

18 5 array operations parametrised on the dimension of the array, rather than on the type of the array elements. Dependent sum types ( x : A). B(x) can be used to represent modules and abstract data types amongst other things. More radically, we have the possibility of combining verification and programming, as types can be used to represent propositions. As an example consider the existential type again. We can think of the elements of ( x : A). B(x) as objects a of type A with the logical property B(a), witnessed by the proof b:b(a). We can give a third interpretation to p:p, in the case that P is an existential proposition: (a, b) : ( x:a). B(x) can be read thus: a of type A meets the specification B(x), as proved by b:b(a) This fulfills the promise made in the introduction to logic that we would give a system of types strong enough to express specifications. In our case the logic is an extension of many-sorted, first-order predicate logic, which is certainly sufficient to express all practical requirements. The system here integrates the process of program development and proof: to show that a program meets a specification we provide the program/proof pair. As an aside, note that it is misleading to read p : P as saying p meets specification P when P is an arbitrary proposition, an interpretation which seems to be suggested by much of the literature on type theory. This is because such statements include simple typings like plus : N N N in which case the right-hand side is a woeful under-specification of addition! The specification statement is an existential proposition, and objects of that type include an explicit witness to the object having the required property: in other words we can only state that a program meets its specification when we have a proof of correctness for it. We mentioned that one motivation for re-interpreting mathematics in a constructive form was to extract algorithms from proofs. A proof of a statement like x. y. R(x, y) contains a description of an algorithm taking any x into a y so that R(x, y). The logic we described makes explicit the proof terms. On the other hand it is instead possible to suppress explicit mention of the proof objects, and extract algorithms from more succinct derivations of logical theorems,

19 6 INTRODUCTION taking us from proofs to programs. This idea has been used with much success in the Nuprl system developed at Cornell University, and indeed in other projects. Background Our exposition of type theory and its applications will make continual reference to the fields of functional programming and constructivism. Separate introductions to these topics are provided by the introduction to chapter 2 and by chapter 3 respectively. The interested reader may care to refer to these now. Section 9.2 contains some concluding remarks.

20 Chapter 1 Introduction to Logic This chapter constitutes a short introduction to formal logic, which will establish notation and terminology used throughout the book. We assume that the reader is already familiar with the basics of logic, as discussed in the texts [Lem65, Hod77] for example. Logic is the science of argument. The purposes of formalization of logical systems are manifold. The formalization gives a clear characterisation of the valid proofs in the system, against which we can judge individual arguments, so sharpening our understanding of informal reasoning. If the arguments are themselves about formal systems, as is the case when we verify the correctness of computer programs, the argument itself should be written in a form which can be checked for correctness. This can only be done if the argument is formalized, and correctness can be checked mechanically. Informal evidence for the latter requirement is provided by Principia Mathematica [RW10] which contains numerous formal proofs; unfortunately, many of the proofs are incorrect, a fact which all too easily escapes the human proof-reader s eye. As well as looking at the correctness or otherwise of individual proofs in a formal theory, we can study its properties as a whole. For example, we can investigate its expressive strength, relative to other theories, or to some sort of meaning or semantics for it. This work, which is predominantly mathematical in nature, is called mathematical logic, more details of which can be found in [Men87a] amongst others. 7

### Mathematics for Computer Science/Software Engineering. Notes for the course MSM1F3 Dr. R. A. Wilson

Mathematics for Computer Science/Software Engineering Notes for the course MSM1F3 Dr. R. A. Wilson October 1996 Chapter 1 Logic Lecture no. 1. We introduce the concept of a proposition, which is a statement

### 2. Methods of Proof Types of Proofs. Suppose we wish to prove an implication p q. Here are some strategies we have available to try.

2. METHODS OF PROOF 69 2. Methods of Proof 2.1. Types of Proofs. Suppose we wish to prove an implication p q. Here are some strategies we have available to try. Trivial Proof: If we know q is true then

### Inference Rules and Proof Methods

Inference Rules and Proof Methods Winter 2010 Introduction Rules of Inference and Formal Proofs Proofs in mathematics are valid arguments that establish the truth of mathematical statements. An argument

### 3. Mathematical Induction

3. MATHEMATICAL INDUCTION 83 3. Mathematical Induction 3.1. First Principle of Mathematical Induction. Let P (n) be a predicate with domain of discourse (over) the natural numbers N = {0, 1,,...}. If (1)

### We would like to state the following system of natural deduction rules preserving falsity:

A Natural Deduction System Preserving Falsity 1 Wagner de Campos Sanz Dept. of Philosophy/UFG/Brazil sanz@fchf.ufg.br Abstract This paper presents a natural deduction system preserving falsity. This new

### Discrete Mathematics and Probability Theory Fall 2009 Satish Rao, David Tse Note 2

CS 70 Discrete Mathematics and Probability Theory Fall 2009 Satish Rao, David Tse Note 2 Proofs Intuitively, the concept of proof should already be familiar We all like to assert things, and few of us

### Predicate Calculus. There are certain arguments that seem to be perfectly logical, yet they cannot be expressed by using propositional calculus.

Predicate Calculus (Alternative names: predicate logic, first order logic, elementary logic, restricted predicate calculus, restricted functional calculus, relational calculus, theory of quantification,

### Section 1. Statements and Truth Tables. Definition 1.1: A mathematical statement is a declarative sentence that is true or false, but not both.

M3210 Supplemental Notes: Basic Logic Concepts In this course we will examine statements about mathematical concepts and relationships between these concepts (definitions, theorems). We will also consider

### Chapter 1. Logic and Proof

Chapter 1. Logic and Proof 1.1 Remark: A little over 100 years ago, it was found that some mathematical proofs contained paradoxes, and these paradoxes could be used to prove statements that were known

### CHAPTER 7 GENERAL PROOF SYSTEMS

CHAPTER 7 GENERAL PROOF SYSTEMS 1 Introduction Proof systems are built to prove statements. They can be thought as an inference machine with special statements, called provable statements, or sometimes

### Chapter I Logic and Proofs

MATH 1130 1 Discrete Structures Chapter I Logic and Proofs Propositions A proposition is a statement that is either true (T) or false (F), but or both. s Propositions: 1. I am a man.. I am taller than

### CHAPTER 3. Methods of Proofs. 1. Logical Arguments and Formal Proofs

CHAPTER 3 Methods of Proofs 1. Logical Arguments and Formal Proofs 1.1. Basic Terminology. An axiom is a statement that is given to be true. A rule of inference is a logical rule that is used to deduce

### MATH 55: HOMEWORK #2 SOLUTIONS

MATH 55: HOMEWORK # SOLUTIONS ERIC PETERSON * 1. SECTION 1.5: NESTED QUANTIFIERS 1.1. Problem 1.5.8. Determine the truth value of each of these statements if the domain of each variable consists of all

### 3(vi) B. Answer: False. 3(vii) B. Answer: True

Mathematics 0N1 Solutions 1 1. Write the following sets in list form. 1(i) The set of letters in the word banana. {a, b, n}. 1(ii) {x : x 2 + 3x 10 = 0}. 3(iv) C A. True 3(v) B = {e, e, f, c}. True 3(vi)

### Parametric Domain-theoretic models of Linear Abadi & Plotkin Logic

Parametric Domain-theoretic models of Linear Abadi & Plotkin Logic Lars Birkedal Rasmus Ejlers Møgelberg Rasmus Lerchedahl Petersen IT University Technical Report Series TR-00-7 ISSN 600 600 February 00

### 2. Propositional Equivalences

2. PROPOSITIONAL EQUIVALENCES 33 2. Propositional Equivalences 2.1. Tautology/Contradiction/Contingency. Definition 2.1.1. A tautology is a proposition that is always true. Example 2.1.1. p p Definition

### 3. Predicates and Quantifiers

3. PREDICATES AND QUANTIFIERS 45 3. Predicates and Quantifiers 3.1. Predicates and Quantifiers. Definition 3.1.1. A predicate or propositional function is a description of the property (or properties)

### You know from calculus that functions play a fundamental role in mathematics.

CHPTER 12 Functions You know from calculus that functions play a fundamental role in mathematics. You likely view a function as a kind of formula that describes a relationship between two (or more) quantities.

### Sets and functions. {x R : x > 0}.

Sets and functions 1 Sets The language of sets and functions pervades mathematics, and most of the important operations in mathematics turn out to be functions or to be expressible in terms of functions.

### The Foundations: Logic and Proofs. Chapter 1, Part III: Proofs

The Foundations: Logic and Proofs Chapter 1, Part III: Proofs Rules of Inference Section 1.6 Section Summary Valid Arguments Inference Rules for Propositional Logic Using Rules of Inference to Build Arguments

### WUCT121. Discrete Mathematics. Logic

WUCT121 Discrete Mathematics Logic 1. Logic 2. Predicate Logic 3. Proofs 4. Set Theory 5. Relations and Functions WUCT121 Logic 1 Section 1. Logic 1.1. Introduction. In developing a mathematical theory,

### DISCRETE MATHEMATICS W W L CHEN

DISCRETE MATHEMATICS W W L CHEN c W W L Chen, 1982, 2008. This chapter originates from material used by the author at Imperial College, University of London, between 1981 and 1990. It is available free

### MAT2400 Analysis I. A brief introduction to proofs, sets, and functions

MAT2400 Analysis I A brief introduction to proofs, sets, and functions In Analysis I there is a lot of manipulations with sets and functions. It is probably also the first course where you have to take

### (LMCS, p. 317) V.1. First Order Logic. This is the most powerful, most expressive logic that we will examine.

(LMCS, p. 317) V.1 First Order Logic This is the most powerful, most expressive logic that we will examine. Our version of first-order logic will use the following symbols: variables connectives (,,,,

### Summary Last Lecture. Automated Reasoning. Outline of the Lecture. Definition sequent calculus. Theorem (Normalisation and Strong Normalisation)

Summary Summary Last Lecture sequent calculus Automated Reasoning Georg Moser Institute of Computer Science @ UIBK Winter 013 (Normalisation and Strong Normalisation) let Π be a proof in minimal logic

### WHAT ARE MATHEMATICAL PROOFS AND WHY THEY ARE IMPORTANT?

WHAT ARE MATHEMATICAL PROOFS AND WHY THEY ARE IMPORTANT? introduction Many students seem to have trouble with the notion of a mathematical proof. People that come to a course like Math 216, who certainly

### INCIDENCE-BETWEENNESS GEOMETRY

INCIDENCE-BETWEENNESS GEOMETRY MATH 410, CSUSM. SPRING 2008. PROFESSOR AITKEN This document covers the geometry that can be developed with just the axioms related to incidence and betweenness. The full

### 31 is a prime number is a mathematical statement (which happens to be true).

Chapter 1 Mathematical Logic In its most basic form, Mathematics is the practice of assigning truth to welldefined statements. In this course, we will develop the skills to use known true statements to

### Predicate Logic. Lucia Moura. Winter Predicates and Quantifiers Nested Quantifiers Using Predicate Calculus

Predicate Logic Winter 2010 Predicates A Predicate is a declarative sentence whose true/false value depends on one or more variables. The statement x is greater than 3 has two parts: the subject: x is

### Fundamentals of Mathematics Lecture 6: Propositional Logic

Fundamentals of Mathematics Lecture 6: Propositional Logic Guan-Shieng Huang National Chi Nan University, Taiwan Spring, 2008 1 / 39 Connectives Propositional Connectives I 1 Negation: (not A) A A T F

### Chapter 2 Mathematical Background

Chapter 2 Mathematical Background We start this chapter with a summary of basic concepts and notations for sets and first-order logic formulas, which will be used in the rest of the book. Our aim is to

### Likewise, we have contradictions: formulas that can only be false, e.g. (p p).

CHAPTER 4. STATEMENT LOGIC 59 The rightmost column of this truth table contains instances of T and instances of F. Notice that there are no degrees of contingency. If both values are possible, the formula

### Handout #1: Mathematical Reasoning

Math 101 Rumbos Spring 2010 1 Handout #1: Mathematical Reasoning 1 Propositional Logic A proposition is a mathematical statement that it is either true or false; that is, a statement whose certainty or

### ML for the Working Programmer

ML for the Working Programmer 2nd edition Lawrence C. Paulson University of Cambridge CAMBRIDGE UNIVERSITY PRESS CONTENTS Preface to the Second Edition Preface xiii xv 1 Standard ML 1 Functional Programming

### Chapter 1 LOGIC AND PROOF

Chapter 1 LOGIC AND PROOF To be able to understand mathematics and mathematical arguments, it is necessary to have a solid understanding of logic and the way in which known facts can be combined to prove

### Students in their first advanced mathematics classes are often surprised

CHAPTER 8 Proofs Involving Sets Students in their first advanced mathematics classes are often surprised by the extensive role that sets play and by the fact that most of the proofs they encounter are

### An Innocent Investigation

An Innocent Investigation D. Joyce, Clark University January 2006 The beginning. Have you ever wondered why every number is either even or odd? I don t mean to ask if you ever wondered whether every number

### Logic and Incidence Geometry

Logic and Incidence Geometry February 27, 2013 1 Informal Logic Logic Rule 0. No unstated assumption may be used in a proof. 2 Theorems and Proofs If [hypothesis] then [conclusion]. LOGIC RULE 1. The following

### 1. R In this and the next section we are going to study the properties of sequences of real numbers.

+a 1. R In this and the next section we are going to study the properties of sequences of real numbers. Definition 1.1. (Sequence) A sequence is a function with domain N. Example 1.2. A sequence of real

### Higher-Order Logic. Specification and Verification with Higher-Order Logic

Higher-Order Logic Specification and Verification with Higher-Order Logic Arnd Poetzsch-Heffter Software Technology Group Fachbereich Informatik Technische Universität Kaiserslautern Sommersemester 2010

### CHAPTER 5: MODULAR ARITHMETIC

CHAPTER 5: MODULAR ARITHMETIC LECTURE NOTES FOR MATH 378 (CSUSM, SPRING 2009). WAYNE AITKEN 1. Introduction In this chapter we will consider congruence modulo m, and explore the associated arithmetic called

### Chapter 6 Finite sets and infinite sets. Copyright 2013, 2005, 2001 Pearson Education, Inc. Section 3.1, Slide 1

Chapter 6 Finite sets and infinite sets Copyright 013, 005, 001 Pearson Education, Inc. Section 3.1, Slide 1 Section 6. PROPERTIES OF THE NATURE NUMBERS 013 Pearson Education, Inc.1 Slide Recall that denotes

### ORDERS OF ELEMENTS IN A GROUP

ORDERS OF ELEMENTS IN A GROUP KEITH CONRAD 1. Introduction Let G be a group and g G. We say g has finite order if g n = e for some positive integer n. For example, 1 and i have finite order in C, since

### Applications of Methods of Proof

CHAPTER 4 Applications of Methods of Proof 1. Set Operations 1.1. Set Operations. The set-theoretic operations, intersection, union, and complementation, defined in Chapter 1.1 Introduction to Sets are

### 3. Recurrence Recursive Definitions. To construct a recursively defined function:

3. RECURRENCE 10 3. Recurrence 3.1. Recursive Definitions. To construct a recursively defined function: 1. Initial Condition(s) (or basis): Prescribe initial value(s) of the function.. Recursion: Use a

### INTRODUCTORY SET THEORY

M.Sc. program in mathematics INTRODUCTORY SET THEORY Katalin Károlyi Department of Applied Analysis, Eötvös Loránd University H-1088 Budapest, Múzeum krt. 6-8. CONTENTS 1. SETS Set, equal sets, subset,

### Logic, Sets, and Proofs

Logic, Sets, and Proofs David A. Cox and Catherine C. McGeoch Amherst College 1 Logic Logical Statements. A logical statement is a mathematical statement that is either true or false. Here we denote logical

### Discrete Mathematics, Chapter 5: Induction and Recursion

Discrete Mathematics, Chapter 5: Induction and Recursion Richard Mayr University of Edinburgh, UK Richard Mayr (University of Edinburgh, UK) Discrete Mathematics. Chapter 5 1 / 20 Outline 1 Well-founded

### Revised Version of Chapter 23. We learned long ago how to solve linear congruences. ax c (mod m)

Chapter 23 Squares Modulo p Revised Version of Chapter 23 We learned long ago how to solve linear congruences ax c (mod m) (see Chapter 8). It s now time to take the plunge and move on to quadratic equations.

### Introduction to Proofs

Chapter 1 Introduction to Proofs 1.1 Preview of Proof This section previews many of the key ideas of proof and cites [in brackets] the sections where they are discussed thoroughly. All of these ideas are

### It is time to prove some theorems. There are various strategies for doing

CHAPTER 4 Direct Proof It is time to prove some theorems. There are various strategies for doing this; we now examine the most straightforward approach, a technique called direct proof. As we begin, it

### Predicate Logic. Example: All men are mortal. Socrates is a man. Socrates is mortal.

Predicate Logic Example: All men are mortal. Socrates is a man. Socrates is mortal. Note: We need logic laws that work for statements involving quantities like some and all. In English, the predicate is

### Propositional Logic. A proposition is a declarative sentence (a sentence that declares a fact) that is either true or false, but not both.

irst Order Logic Propositional Logic A proposition is a declarative sentence (a sentence that declares a fact) that is either true or false, but not both. Are the following sentences propositions? oronto

### Correspondence analysis for strong three-valued logic

Correspondence analysis for strong three-valued logic A. Tamminga abstract. I apply Kooi and Tamminga s (2012) idea of correspondence analysis for many-valued logics to strong three-valued logic (K 3 ).

### Rigorous Software Development CSCI-GA 3033-009

Rigorous Software Development CSCI-GA 3033-009 Instructor: Thomas Wies Spring 2013 Lecture 11 Semantics of Programming Languages Denotational Semantics Meaning of a program is defined as the mathematical

### LOGICAL INFERENCE & PROOFs. Debdeep Mukhopadhyay Dept of CSE, IIT Madras

LOGICAL INFERENCE & PROOFs Debdeep Mukhopadhyay Dept of CSE, IIT Madras Defn A theorem is a mathematical assertion which can be shown to be true. A proof is an argument which establishes the truth of a

### Induction. Margaret M. Fleck. 10 October These notes cover mathematical induction and recursive definition

Induction Margaret M. Fleck 10 October 011 These notes cover mathematical induction and recursive definition 1 Introduction to induction At the start of the term, we saw the following formula for computing

### INTRODUCTION TO PROOFS: HOMEWORK SOLUTIONS

INTRODUCTION TO PROOFS: HOMEWORK SOLUTIONS STEVEN HEILMAN Contents 1. Homework 1 1 2. Homework 2 6 3. Homework 3 10 4. Homework 4 16 5. Homework 5 19 6. Homework 6 21 7. Homework 7 25 8. Homework 8 28

### MATH REVIEW KIT. Reproduced with permission of the Certified General Accountant Association of Canada.

MATH REVIEW KIT Reproduced with permission of the Certified General Accountant Association of Canada. Copyright 00 by the Certified General Accountant Association of Canada and the UBC Real Estate Division.

### Foundations of mathematics

Foundations of mathematics 1. First foundations of mathematics 1.1. Introduction to the foundations of mathematics Mathematics, theories and foundations Sylvain Poirier http://settheory.net/ Mathematics

### Predicate Logic Review

Predicate Logic Review UC Berkeley, Philosophy 142, Spring 2016 John MacFarlane 1 Grammar A term is an individual constant or a variable. An individual constant is a lowercase letter from the beginning

### Mathematical Induction

Mathematical Induction In logic, we often want to prove that every member of an infinite set has some feature. E.g., we would like to show: N 1 : is a number 1 : has the feature Φ ( x)(n 1 x! 1 x) How

### Encoding Mathematics in First-Order Logic

Applied Logic Lecture 19 CS 486 Spring 2005 Thursday, April 14, 2005 Encoding Mathematics in First-Order Logic Over the past few lectures, we have seen the syntax and the semantics of first-order logic,

### A Beginner s Guide to Modern Set Theory

A Beginner s Guide to Modern Set Theory Martin Dowd Product of Hyperon Software PO Box 4161 Costa Mesa, CA 92628 www.hyperonsoft.com Copyright c 2010 by Martin Dowd 1. Introduction..... 1 2. Formal logic......

### Mathematics Review for MS Finance Students

Mathematics Review for MS Finance Students Anthony M. Marino Department of Finance and Business Economics Marshall School of Business Lecture 1: Introductory Material Sets The Real Number System Functions,

### CHAPTER 3 Numbers and Numeral Systems

CHAPTER 3 Numbers and Numeral Systems Numbers play an important role in almost all areas of mathematics, not least in calculus. Virtually all calculus books contain a thorough description of the natural,

### Bindings, mobility of bindings, and the -quantifier

ICMS, 26 May 2007 1/17 Bindings, mobility of bindings, and the -quantifier Dale Miller, INRIA-Saclay and LIX, École Polytechnique This talk is based on papers with Tiu in LICS2003 & ACM ToCL, and experience

### Chapter 1. Informal introdution to the axioms of ZF.

Chapter 1. Informal introdution to the axioms of ZF. 1.1. Extension. Our conception of sets comes from set of objects that we know well such as N, Q and R, and subsets we can form from these determined

### Chapter 1 Verificationism Then and Now

Chapter 1 Verificationism Then and Now Per Martin-Löf The term veri fi cationism is used in two different ways: the fi rst is in relation to the veri fi cation principle of meaning, which we usually and

### Logic will get you from A to B. Imagination will take you everywhere.

Chapter 3 Predicate Logic Logic will get you from A to B. Imagination will take you everywhere. A. Einstein In the previous chapter, we studied propositional logic. This chapter is dedicated to another

### What Is School Mathematics?

What Is School Mathematics? Lisbon, Portugal January 30, 2010 H. Wu *I am grateful to Alexandra Alves-Rodrigues for her many contributions that helped shape this document. The German conductor Herbert

### 1 Proposition, Logical connectives and compound statements

Discrete Mathematics: Lecture 4 Introduction to Logic Instructor: Arijit Bishnu Date: July 27, 2009 1 Proposition, Logical connectives and compound statements Logic is the discipline that deals with the

### 4. FIRST-ORDER LOGIC

4. FIRST-ORDER LOGIC Contents 4.1: Splitting the atom: names, predicates and relations 4.2: Structures 4.3: Quantification:, 4.4: Syntax 4.5: Semantics 4.6: De Morgan s laws for and 4.7: Truth trees for

### Automated Theorem Proving - summary of lecture 1

Automated Theorem Proving - summary of lecture 1 1 Introduction Automated Theorem Proving (ATP) deals with the development of computer programs that show that some statement is a logical consequence of

### (What I Know about) the History of the Identity Type

(What I Know about) the History of the Identity Type Peter Dybjer Chalmers University, Göteborg, Sweden Workshop on Identity Types Uppsala, 13 November, 2006 When was the identity type born? Martin-Löf

### THREE DIMENSIONAL GEOMETRY

Chapter 8 THREE DIMENSIONAL GEOMETRY 8.1 Introduction In this chapter we present a vector algebra approach to three dimensional geometry. The aim is to present standard properties of lines and planes,

### A set is a Many that allows itself to be thought of as a One. (Georg Cantor)

Chapter 4 Set Theory A set is a Many that allows itself to be thought of as a One. (Georg Cantor) In the previous chapters, we have often encountered sets, for example, prime numbers form a set, domains

### CARDINALITY, COUNTABLE AND UNCOUNTABLE SETS PART ONE

CARDINALITY, COUNTABLE AND UNCOUNTABLE SETS PART ONE With the notion of bijection at hand, it is easy to formalize the idea that two finite sets have the same number of elements: we just need to verify

### CS510 Software Engineering

CS510 Software Engineering Propositional Logic Asst. Prof. Mathias Payer Department of Computer Science Purdue University TA: Scott A. Carr Slides inspired by Xiangyu Zhang http://nebelwelt.net/teaching/15-cs510-se

### Valid formulas, games and network protocols

Valid formulas, games and network protocols Jean-Louis Krivine & Yves Legrandgérard Paris VII University, CNRS November 14, 2007 Introduction We describe a remarkable relation between a fundamental notion

### Introduction to mathematical arguments

Introduction to mathematical arguments (background handout for courses requiring proofs) by Michael Hutchings A mathematical proof is an argument which convinces other people that something is true. Math

### Math 3000 Running Glossary

Math 3000 Running Glossary Last Updated on: July 15, 2014 The definition of items marked with a must be known precisely. Chapter 1: 1. A set: A collection of objects called elements. 2. The empty set (

### vertex, 369 disjoint pairwise, 395 disjoint sets, 236 disjunction, 33, 36 distributive laws

Index absolute value, 135 141 additive identity, 254 additive inverse, 254 aleph, 466 algebra of sets, 245, 278 antisymmetric relation, 387 arcsine function, 349 arithmetic sequence, 208 arrow diagram,

### INTRODUCTION TO LOGIC Lecture 4 The Syntax of Predicate Logic Dr. James Studd. Subject-Predicate form. Designators/Constants. is a tortoise Predicate

Introduction INTRODUCTION TO LOGIC Lecture 4 The Syntax of Predicate Logic Dr. James Studd I counsel you, dear friend, in sum, That first you take collegium logicum. Your spirit s then well broken in for

### Degrees of Truth: the formal logic of classical and quantum probabilities as well as fuzzy sets.

Degrees of Truth: the formal logic of classical and quantum probabilities as well as fuzzy sets. Logic is the study of reasoning. A language of propositions is fundamental to this study as well as true

### This asserts two sets are equal iff they have the same elements, that is, a set is determined by its elements.

3. Axioms of Set theory Before presenting the axioms of set theory, we first make a few basic comments about the relevant first order logic. We will give a somewhat more detailed discussion later, but

### Quotient Rings and Field Extensions

Chapter 5 Quotient Rings and Field Extensions In this chapter we describe a method for producing field extension of a given field. If F is a field, then a field extension is a field K that contains F.

### SJÄLVSTÄNDIGA ARBETEN I MATEMATIK

SJÄLVSTÄNDIGA ARBETEN I MATEMATIK MATEMATISKA INSTITUTIONEN, STOCKHOLMS UNIVERSITET Automated Theorem Proving av Tom Everitt 2010 - No 8 MATEMATISKA INSTITUTIONEN, STOCKHOLMS UNIVERSITET, 106 91 STOCKHOLM

### Answer Key for California State Standards: Algebra I

Algebra I: Symbolic reasoning and calculations with symbols are central in algebra. Through the study of algebra, a student develops an understanding of the symbolic language of mathematics and the sciences.

### SOME SUPER-INTUITIONISTIC LOGICS AS THE LOGICAL FRAGMENTS OF EQUATIONAL THEORIES 1

Tatsuya Shimura Nobu-Yuki Suzuki SOME SUPER-INTUITIONISTIC LOGICS AS THE LOGICAL FRAGMENTS OF EQUATIONAL THEORIES 1 Kripke frame semantics is used as a concise and convenient apparatus for the study of

### Chapter 4, Arithmetic in F [x] Polynomial arithmetic and the division algorithm.

Chapter 4, Arithmetic in F [x] Polynomial arithmetic and the division algorithm. We begin by defining the ring of polynomials with coefficients in a ring R. After some preliminary results, we specialize

### Software Verification and Testing. Lecture Notes: Z I

Software Verification and Testing Lecture Notes: Z I Motivation so far: we have seen that properties of software systems can be specified using first-order logic, set theory and the relational calculus

### Review for Final Exam

Review for Final Exam Note: Warning, this is probably not exhaustive and probably does contain typos (which I d like to hear about), but represents a review of most of the material covered in Chapters

### Regular Expressions and Automata using Haskell

Regular Expressions and Automata using Haskell Simon Thompson Computing Laboratory University of Kent at Canterbury January 2000 Contents 1 Introduction 2 2 Regular Expressions 2 3 Matching regular expressions

### 8 Divisibility and prime numbers

8 Divisibility and prime numbers 8.1 Divisibility In this short section we extend the concept of a multiple from the natural numbers to the integers. We also summarize several other terms that express

### 2.5 Gaussian Elimination

page 150 150 CHAPTER 2 Matrices and Systems of Linear Equations 37 10 the linear algebra package of Maple, the three elementary 20 23 1 row operations are 12 1 swaprow(a,i,j): permute rows i and j 3 3

### 3. INNER PRODUCT SPACES

. INNER PRODUCT SPACES.. Definition So far we have studied abstract vector spaces. These are a generalisation of the geometric spaces R and R. But these have more structure than just that of a vector space.

### Deductive Systems. Marco Piastra. Artificial Intelligence. Artificial Intelligence - A.A Deductive Systems [1]

Artificial Intelligence Deductive Systems Marco Piastra Artificial Intelligence - A.A. 2012- Deductive Systems 1] Symbolic calculus? A wff is entailed by a set of wff iff every model of is also model of