Logic 2010/2011 Introduction to Logic
Total Page:16
File Type:pdf, Size:1020Kb
Logic 2010/2011 Introduction to Logic R. Gennari Contents 1 Introduction 1 1.1 Logic in a Nutshell . .1 1.2 Examples . .3 1.2.1 Informal Arguments . .3 1.2.2 Formal Verification . .3 1.3 The ideal Logic . .5 1.4 Main Topics of the Course . .5 1.5 Conclusions: Slogans . .6 2 Language, Informally 7 2.1 Propositional Language, Informally . .7 3 4 CONTENTS 2.2 First-order Language, Informally . .9 3 Semantics and Interpretations, Informally 11 4 Proofs, Informally 15 4.1 Proofs . 15 4.2 Propositional Proof Rules . 16 4.2.1 Conjunction . 17 4.2.2 Disjunction . 17 4.2.3 Implication . 18 4.2.4 Negation . 19 4.2.5 Other Propositional Rules . 20 4.3 First-order Proof Rules . 21 4.3.1 Universal quantifier elimination . 21 4.3.2 Universal quantifier introduction . 22 4.4 Natural Induction Proof Rule . 23 5 Main Meta-questions 25 Chapter 1 Introduction 1.1 Logic in a Nutshell Logics are systems for formally representing and inferring information, hopefully, with terminating procedures of a certain computational complexity. The first two requirements means that a logic is characterised by: {a formal language, defining primitive symbols and the rules for composing symbols in formulae of the language (syntax), { interpretations for specifying the so-called meaning of formulae, that is, when they are true (semantics). 1 2 CHAPTER 1. INTRODUCTION The others mean that a logic is also characterised by {a proof calculus with inference rules for the formulae of the logic (proof theory), { hopefully, terminating procedures for scheduling those rules (decidability) { within specific computational bounds (complexity). 1.2. EXAMPLES 3 1.2 Examples 1.2.1 Informal Arguments If our government fails to control military spending then we will suffer huge budget deficits. We are suffering huge budget deficits. Therefore our government has failed to control military spending. Is the argument correct? In other words, is there a proof that the conclusion follows from the premises? If our government fails to control military spending then we will suffer huge budget deficits. We are not suffering huge budget deficits. Therefore our government has not failed to control military spending. Is the argument correct? In other words, is there a proof that the conclusion follows from the premises? 1.2.2 Formal Verification Consider the following classical integer division problem: Let x; y 2 N. Write a program that computes x=y. 4 CHAPTER 1. INTRODUCTION fx ≥ 0; y ≥ 0g a:=0; b:=x; while b ≥ y do b:=b − y; a:=a + 1; fay_ + b = x ^ 0 ≤ b < yg The language of Peano arithmetic, augmented with −, allows us to formalise assertions about the program's statements as formulae. See the blue formulae. A suitable proof calculus allows us to formally prove that if x ≥ 0 ^ y ≥ 0 before executing the program then ay_ + b = x ^ 0 ≤ b < y at the termination of the program. Alas, proof calculi for Peano arithmetics turn out not to be decidable. In general, full automatic formal verification of program assertions is an undecidable problem, and therefore impossible to be fully automatize. Nevertheless in special cases, e.g., for specific calculi, the verification can be automatized. This is for instance the case of programs that manipulate only variables ranging over finite data types. Besides formal verification, logic is relevant in several other fields of formal methods, e.g., formal synthesis. See the first chapter of [Apt et al.2010] for an overview and pointers. 1.3. THE IDEAL LOGIC 5 1.3 The ideal Logic The ideal logic. depends on the problem at hand: { its formal language should be sufficiently expressive (for the problem) { it should have a proof theory that { is sound and complete for its semantics { and allow for efficient inference procedures { scheduling the proof theory's rules In this course, we focus on classical logics: propositional logic; first order logic. 1.4 Main Topics of the Course { Classical Propositional Logic: { formal language, { semantics and interpretations, { proof theory and calculi, { computability Issues. 6 CHAPTER 1. INTRODUCTION { Classical First Order Logic: { formal language, { semantics and interpretations, { proof theory and calculi, { computability. 1.5 Conclusions: Slogans { A warning: { this is a rigorous and formal course { Two promises: { many examples { few concepts and theorems Chapter 2 Language, Informally 2.1 Propositional Language, Informally Propositional symbols are the elementary building blocks of a propositional (logic) language. Intuitively, they formalise atomic statements, that we do not need to decompose any further, and of which we can meaningfully ask the following question: is the statement true? According to such a criterion, \the program terminates" would qualify as an atomic statement, whereas \the program" would not. 7 8 CHAPTER 2. LANGUAGE, INFORMALLY 0 Statements, in symbols, are usually represented by p, q, r, pi, pi,. The following example lists several atomic statements and their formalisation with propositional symbols. Example 1. Natural language atomic statements Formalisation The program terminates p The program computes the square root of 4 q The program has 4 as input r Propositional formulae are specific sequences of propositional symbols and connec- tives: ^ (\and"), _ (\or"), ! (\if. then"), : (\not"). Intuitively, they formalise compound statements. In symbols, p ! q,(p0 ! p2) _ p1,... Example 2. Natural language compound statements Formalisation (1) If the program terminates then it computes the square (p ! q) root of 4 (2) If the program has 4 as input and it terminates then it ((r ^ p) ! q) computes the square root of 4 (3) If the program has 4 as input then, if it terminates, it (r ! (p ! q)) computes the square root of 4 (4) The program terminates or not (p _ (:p)) 2.2. FIRST-ORDER LANGUAGE, INFORMALLY 9 2.2 First-order Language, Informally The terms of a first-order language are: { the nouns of our language: they are the expressions that can formalise objects of a domain, and the applications of functions to objects; { the pronouns of our language: they allow to render variables, and the applications of functions to variables and objects of the domain. Example 3. Consider the semi-group of natural number N = (N; ×; 1), then terms allow us to render 1, 2, but also 1 × 2, and x × 2. The atomic formulae of a first-order language will be those formulae having neither connective nor quantifier 8; 9 symbols. They allow us to name relations between objects of a domain, and hence are obtained by applying relations symbols, like <, to terms. Example 4. Consider the linear order Q = (Q; <), then atomic formulae allow us to formalise 1 < 2 as well as inequalities like x < 2 and y < 2. The formulae of a first-order language are those expressions that can be (recursively) built up from the atomic formulae by use of the connective symbols and the quantifier symbols, 8 and 9, finitely many times. Example 5. Consider the linear order Q = (Q; <), then first-order formulae allow us 10 CHAPTER 2. LANGUAGE, INFORMALLY to formalise that a system of inequalities over Q like 8 x < x > 1 2 <> x2 < x3 . > . > : xn < 2 has a solution: 9x1 ::: 9xn(x1 < x2 ^ · · · ^ xn < 2). Chapter 3 Semantics and Interpretations, Informally Interpreting symbols of a logic language with a semantics amounts to giving them \mean- ings". Think of the process of interpreting the letters of a foreign language into your native language. There are two main types of interpretations: { for propositional logic languages; { for first-order logic languages. Propositional interpretations allow us to interpret connectives with a fixed interpreta- 11 12 CHAPTER 3. SEMANTICS AND INTERPRETATIONS, INFORMALLY tion, they behave like pattern words. Similarly, first-order interpretations allow us to interpret also quantifiers. Other symbols, like atomic formulae, have no fixed meaning. Interpretations allow us to attach temporary meanings to them. Think of interpreting variables of a system of linear inequalities. The interpretation depend on the domain over which, we say in maths, \variables range". The interpretation of a compound formula is compositional, e.g., the interpretation of p0 ^ p1 depends on the interpretation of p0 \and" that of p1. Example 6. Consider the following system of numerical inequalities. 8 < x1 < x2 x2 < x3 : x3 < 2 If the domain of interpretation is the linear order Q = (Q; <), then the first-order formula 9x19x29x3(x1 < x2 ^ x1 < x2 ^ x3 < 2) allows us to formalise that the system of inequalities over Q has a solution, that is, the formula \is true in this interpretation". The same formula can be interpreted over the natural order N = (N; <). Then the system has no solutions, that is, the same formula \is not true in this interpretation". Example 7. Consider the following statement|the fifth axiom of Euclidean geometry. Take a line l and a point A that does not belong to it. It is unique the line parallel to l and to which A belongs. 13 If l, A and \parallel" are given their standard interpretation in the Euclidean plane, than the statement is true. However, if lines and points are interpreted like in Figure 3.1, then the statement is no more true: there are infinite lines going through A and parallel to l. Figure 3.1: The Klein-Beltrami model of hyperbolic 2-dimension geometry, in which points are interpreted as the points in the interior of the unit disc, and lines are in- terpreted as chords. Taken from wikipedia, http://en.wikipedia.org/wiki/Klein_ model. 14 CHAPTER 3. SEMANTICS AND INTERPRETATIONS, INFORMALLY Chapter 4 Proofs, Informally 4.1 Proofs A mathematical proof is a proof of a statement. Generally, this statement is called the conclusion of the proof, or the thesis to be proved.