Mathematical Logic IAN CHISWELL and WILFRID HODGES 1 3 GreatClarendonStreet,OxfordOX26DP OxfordUniversityPressisadepartmentoftheUniversityofOxford. ItfurtherstheUniversity’sobjectiveofexcellenceinresearch,scholarship, andeducationbypublishingworldwidein Oxford NewYork Auckland CapeTown DaresSalaam HongKong Karachi KualaLumpur Madrid Melbourne MexicoCity Nairobi NewDelhi Shanghai Taipei Toronto Withofficesin Argentina Austria Brazil Chile CzechRepublic France Greece Guatemala Hungary Italy Japan Poland Portugal Singapore SouthKorea Switzerland Thailand Turkey Ukraine Vietnam OxfordisaregisteredtrademarkofOxfordUniversityPress intheUKandincertainothercountries PublishedintheUnitedStates byOxfordUniversityPressInc.,NewYork (cid:1)c IanChiswellandWilfridHodges,2007 Themoralrightsoftheauthorhavebeenasserted DatabaserightOxfordUniversityPress(maker) Firstpublished2007 Allrightsreserved.Nopartofthispublicationmaybereproduced, storedinaretrievalsystem,ortransmitted,inanyformorbyanymeans, withoutthepriorpermissioninwritingofOxfordUniversityPress, orasexpresslypermittedbylaw,orundertermsagreedwiththeappropriate reprographicsrightsorganization.Enquiriesconcerningreproduction outsidethescopeoftheaboveshouldbesenttotheRightsDepartment, OxfordUniversityPress,attheaddressabove Youmustnotcirculatethisbookinanyotherbindingorcover andyoumustimposethesameconditiononanyacquirer BritishLibraryCataloguinginPublicationData Dataavailable LibraryofCongressCataloginginPublicationData Dataavailable TypesetbyNewgenImagingSystems(P)Ltd.,Chennai,India PrintedinGreatBritain onacid-freepaperby BiddlesLtd.,King’sLynn,Norfolk ISBN978–0–19–857100–1 ISBN978–0–19–921562–1(Pbk) 10 9 8 7 6 5 4 3 2 1 Preface This course in Mathematical Logic reflects a third-year undergraduate module that has been taught for a couple of decades at Queen Mary, University of London. Both the authors have taught it (though never together). Many years agothefirstauthorputtogetherasetoflecturenotesbroadlyrelatedtoDirkvan Dalen’s excellent text Logic and Structure (Springer-Verlag, 1980). The present text is based on those notes as a template, but everything has been rewritten with some changes of perspective. Nearly all of the text, and a fair number of the exercises, have been tested in the classroom by one or other of the authors. The book covers a standard syllabus in propositional and predicate logic. A teacher could use it to follow a geodesic path from truth tables to the Com- pleteness Theorem. Teachers who are willing to follow our choice of examples from diophantine arithmetic (and are prepared to take on trust Matiyasevich’s analysisofdiophantinerelations)shouldfind,aswedid,thatGo¨del’sIncomplete- ness Theorem and the undecidability of predicate logic fall out with almost no extra work. Sometimes the course at Queen Mary has finished with some appli- cations of the Compactness Theorem, and we have included this material too. We aimed to meet the following conditions, probably not quite compatible: • The mathematics should be clean, direct and correct. • As each notion is introduced, the students should be given something rele- vantthattheycandowithit,preferablyatleastacalculation.(Forexample, parsingtrees,besidessupportinganaccountofdenotationalsemantics,seem to help students to make computations both in syntax and in semantics.) • Appropriate links should be made to other areas in which mathematical logic is becoming important, for example, computer science, linguistics and cognitivescience(thoughwehavenotexploredlinkstophilosophicallogic). • We try to take into account the needs of students and teachers who prefer a formal treatment, as well as those who prefer an intuitive one. WeusetheHintikkamodelconstructionratherthanthemoretraditionalHenkin- Rasiowa-Sikorskione. Wedothisbecauseitismorehands-on: itallowsustoset uptheconstructionbydecidingwhatneedstobedoneandthendoingit, rather than checking that a piece of magic does the work for us. We do not assume that our students have studied any logic before (though in practice most will at least have seen a truth table). Until the more specialist vi Preface matter near the end of the book, the set theory is very light, and we aim to explain any symbolism that might cause puzzlement. There are several proofs by induction and definitions by recursion; we aim to set these out in a format that students can copy even if they are not confident with the underlying ideas. Other lecturers have taught the Queen Mary module. Two who have cer- tainlyinfluencedus(thoughtheywerenotdirectlyinvolvedinthewritingofthis book) were Stephen Donkin and Thomas Mu¨ller—our thanks to them. We also thank Lev Beklemishev, Ina Ehrenfeucht, Jaakko Hintikka, Yuri Matiyasevich and Zbigniew Ras for their kind help and permissions with the photographs of Anatoliˇı Mal’tsev, Alfred Tarski, Hintikka, Matiyasevich and Helena Rasiowa respectively. Every reasonable effort has been made to acknowledge copyright where appropriate. If notified, the publisher will be pleased to rectify any errors or omissions at the earliest opportunity. We have set up a web page at www.maths.qmul.ac.uk/∼wilfrid/mathlogic.html for errata and addenda to this text. Ian Chiswell Wilfrid Hodges School of Mathematical Sciences Queen Mary, University of London August 2006 Contents 1 Prelude 1 1.1 What is mathematics? 1 1.2 Pronunciation guide 3 2 Informal natural deduction 5 2.1 Proofs and sequents 6 2.2 Arguments introducing ‘and’ 9 2.3 Arguments eliminating ‘and’ 14 2.4 Arguments using ‘if’ 16 2.5 Arguments using ‘if and only if’ 22 2.6 Arguments using ‘not’ 24 2.7 Arguments using ‘or’ 27 3 Propositional logic 31 3.1 LP, the language of propositions 32 3.2 Parsing trees 38 3.3 Propositional formulas 45 3.4 Propositional natural deduction 53 3.5 Truth tables 62 3.6 Logical equivalence 69 3.7 Substitution 72 3.8 Disjunctive and conjunctive normal forms 78 3.9 Soundness for propositional logic 85 3.10 Completeness for propositional logic 89 4 First interlude: Wason’s selection task 97 5 Quantifier-free logic 101 5.1 Terms 101 5.2 Relations and functions 105 5.3 The language of first-order logic 111 5.4 Proof rules for equality 121 5.5 Interpreting signatures 128 5.6 Closed terms and sentences 134 5.7 Satisfaction 139 viii Contents 5.8 Diophantine sets and relations 143 5.9 Soundness for qf sentences 148 5.10 Adequacy and completeness for qf sentences 150 6 Second interlude: the Linda problem 157 7 First-order logic 159 7.1 Quantifiers 159 7.2 Scope and freedom 163 7.3 Semantics of first-order logic 169 7.4 Natural deduction for first-order logic 177 7.5 Proof and truth in arithmetic 186 7.6 Soundness and completeness for first-order logic 189 7.7 First-order theories 194 7.8 Cardinality 199 7.9 Things that first-order logic cannot do 206 8 Postlude 213 AppendixA The natural deduction rules 217 AppendixB Denotational semantics 223 AppendixC Solutions to some exercises 229 Index 245 1 Prelude 1.1 What is mathematics? Euclid Egypt, c. 325–265 bc. For Euclid, mathematics consists of proofs and constructions. Al-Khw¯arizm¯ı Baghdad, c. 780–850. For Al-Khwa¯rizm¯ı, mathematics consists of calculations. 2 Prelude G. W. Leibniz Germany, 1646–1716. According to Leibniz, we can calculate whether a proof is correct. This will need a suitable language (a universal characteristic) for writing proofs. Gottlob Frege Germany, 1848–1925. Frege invented a universal characteristic. He called it Concept-script (Begriffsschrift). Gerhard Gentzen Germany, 1909–1945. Gentzen’s system of natural deduction allows us to write proofs in a way that is mathematically natural. Prelude 3 1.2 Pronunciation guide Togetcontrolofabranchofmathematics, youneedtobeabletospeakit. Here aresomesymbolsthatyouwillprobablyneedtopronounce,withsomesuggested pronunciations: ⊥ ‘absurdity’ (cid:3) ‘turnstile’ |= ‘models’ ∀ ‘for all’ ∃ ‘there is’ tA ‘the interpretation of t in A’ |=A φ ‘A is a model of φ’ ≈ ‘has the same cardinality as’ ≺ ‘has smaller cardinality than’ The expression ‘x (cid:8)→ y’ is read as ‘x maps to y’, and is used for describing functions. For example, ‘x (cid:8)→ x2’ describes the function ‘square’, and ‘n (cid:8)→ n+2’describesthefunction‘plustwo’. Thisnotationisalwaysashorthand; the surrounding context must make clear where the x or n comes from. The notation ‘A ⇒ B’ is shorthand for ‘If A then B’, or ‘A implies B’, or sometimes ‘the implication from A to B’, as best suits the context. Do not confuse it with the notation ‘→’. From Chapter 3 onwards, the symbol ‘→’ is not shorthand; it is an expression of our formal languages. The safest way of reading it is probably just ‘arrow’ (though in Chapters 2 and 3 we will discuss its translation into English). Thenotation‘N’canbereadas‘thesetofnaturalnumbers’oras‘thenatural number structure’, whichever makes better sense in context. (See Example 5.5.1 for the natural number structure. Note that our natural numbers are 0,1,2,..., starting at 0 rather than 1.) The following rough pronunciations of personal names may help, though they are no substitute for guidance from a native speaker: Frege: FRAY-ga Peirce: PURSE Hintikka: HIN-ticka Helena Rasiowa: he-LAY-na Leibniz: LIBE-nits ra-SHOW-va L(cid:2) o´s: WASH Scholz: SHOLTS L(cid:2) ukasiewicz: woo-ka-SHAY-vitch Dana Scott: DAY-na SCOTT Matiyasevich: ma-ti-ya-SAY-vitch Sikorski: shi-COR-ski Giuseppe Peano: ju-SEP-pe Van Dalen: fan DAH-len pay-AH-no Zermelo: tser-MAY-low 2 Informal natural deduction In this course we shall study some ways of proving statements. Of course not every statement can be proved; so we need to analyse the statements before we prove them. Within propositional logic we analyse complex statements down into shorter statements. Later chapters will analyse statements into smaller expressions too, but the smaller expressions need not be statements. What is a statement? Here is a test. A string S of one or more words or symbols is a statement if it makes sense to put S in place of the ‘...’ in the question Is it true that ...? For example, it makes sense to ask any of the questions Is it true that π is rational? Is it true that differentiable functions are continuous? Is it true that f(x)>g(y)? So all of the following are statements: π is rational. Differentiable functions are continuous. f(x)>g(y). For this test it does not matter that the answers to the three questions are different: No. Yes. It depends on what f, g, x and y are. On the other hand, none of the following questions make sense: Is it true that π? Is it true that Pythagoras’ Theorem? Is it true that 3+cosθ? So none of the expressions ‘π’, ‘Pythagoras’ Theorem’ and ‘3 + cosθ’ is a statement.