Transcription of LECTURE 7: PROPOSITIONAL LOGIC (1)
1 LECTURE 7: PROPOSITIONALLOGIC (1)Software EngineeringMike WooldridgeLecture 7 Software Engineering1 What is a LOGIC ? When most people say LOGIC , they meaneitherpropositional logicorfirst-orderpredicate LOGIC . However, the precise definition is quitebroad, and literally hundreds of logicshave been studied by philosophers,computer scientists and mathematicians. Any formal system can be considered alogic if it has: a well-definedsyntax; a well-definedsemantics; and a Wooldridge1 LECTURE 7 Software Engineering Thesyntaxof a LOGIC defines thesyntactically acceptable objects of thelanguage, which are properly calledwell-formed formulae(wff).
2 (We shall justcall them formulae.) Thesemanticsof a LOGIC associate eachformula with ameaning. Theproof theoryis concerned withmanipulating formulae according tocertain Wooldridge2 LECTURE 7 Software Engineering2 PROPOSITIONAL LOGIC The simplest, and most abstract LOGIC wecan study is calledpropositional LOGIC . Definition:Apropositionis a statementthat can be eithertrueorfalse; it must beone or the other, and it cannot be both. EXAMPLES. The following arepropositions: the reactor is on; the wing-flaps are up; John Major is prime the following are not: are you going out somewhere?
3 2+3 Mike Wooldridge3 LECTURE 7 Software Engineering It is possible to determine whether anygiven statement is a proposition byprefixing it with:It is true that ..and seeing whether the result makesgrammatical sense. We now , these are the set of smallestpropositions. Definition:Anatomic propositionis onewhose truth or falsity does not depend onthe truth or falsity of any otherproposition. So all the above propositions are Wooldridge4 LECTURE 7 Software Engineering Now, rather than write out propositions infull, we will abbreviate them by usingpropositional variables. It is standard practice to use thelower-case roman lettersp,q,r.
4 To stand for propositions. If we do this, we must define what wemean by writing something like:LetpbeJohn Major is prime Minister. Another alternative is to write somethinglikereactorison, so that the interpretationof the PROPOSITIONAL variable Wooldridge5 LECTURE 7 Software The Connectives Now, the study of atomic propositions ispretty boring. We therefore now introducea number ofconnectiveswhich will allowus to build upcomplex propositions. The connectives we introduce are: and (& or .) or (|or +) not ( ) implies ( or ) iff (Some books use other notations; these aregiven in parentheses.)
5 Mike Wooldridge6 LECTURE 7 Software EngineeringAnd Any two propositions can be combined toform a third proposition called theconjunctionof the original propositions. Definition:Ifpandqare arbitrarypropositions, then theconjunctionofpandqis writtenp qand will be true iff bothpandqare Wooldridge7 LECTURE 7 Software Engineering We can summarise the operation of in atruth table. The idea of a truth table forsome formula is that it describes thebehaviour of a formula under all possibleinterpretations of the primitivepropositions the are included in theformula. If there arendifferent atomic propositionsin some formula, then there are2ndifferentlines in the truth table for that formula.
6 (This is because each proposition can takeone 1 of 2 values trueorfalse.) Let us writeTfor truth, andFfor the truth table forp qis:pqp qFFFFTFTFFTTTMike Wooldridge8 LECTURE 7 Software EngineeringOr Any two propositions can be combined bythe word or to form a third propositioncalled thedisjunctionof the originals. Definition:Ifpandqare arbitrarypropositions, then thedisjunctionofpandqis writtenp qand will be true iff eitherpis true, orqistrue, or bothpandqare Wooldridge9 LECTURE 7 Software Engineering The operation of is summarised in thefollowing truth table:pqp qFFFFTTTFTTTTMike Wooldridge10 LECTURE 7 Software EngineeringIf.
7 Then.. Many statements, particularly inmathematics, are of the form:ifpis true thenqis way of saying the same thing is towrite:pimpliesq. In PROPOSITIONAL LOGIC , we have aconnective that combines two propositionsinto a new proposition called theconditional, orimplicationof the originals,that attempts to capture the sense of sucha Wooldridge11 LECTURE 7 Software Engineering Definition:Ifpandqare arbitrarypropositions, then theconditionalofpandqis writtenp qand will be true iff eitherpis false orqistrue. The truth table for is:pqp qFFTFTTTFFTTTMike Wooldridge12 LECTURE 7 Software Engineering The operator is the hardest tounderstand of the operators we haveconsidered so far, and yet it is extremelyimportant.
8 If you find it difficult to understand, justremember that thep qmeans ifpistrue, thenqis true .Ifpis false, then we don t care aboutq, andby default, makep qevaluate toTinthis case. Terminology: if is the formulap q,thenpis theantecedentof andqis Wooldridge13 LECTURE 7 Software EngineeringIff Another common form of statement inmaths is:pis true if, and only if,qis true. The sense of such statements is capturedusing thebiconditionaloperator. Definition:Ifpandqare arbitrarypropositions, then thebiconditionalofpandqis written:p qand will be true iff both true; both Wooldridge14 LECTURE 7 Software Engineering The truth table for is:pqp qFFTFTFTFFTTT Ifp qis true, thenpandqare said to belogically equivalent.
9 They will be true underexactly the same Wooldridge15 LECTURE 7 Software EngineeringNot All of the connectives we have consideredso far have beenbinary: they have takentwoarguments. The final connective we consider here isunary. It only takesoneargument. Any proposition can be prefixed by theword not to form a second propositioncalled thenegationof the original. Definition:Ifpis an arbitrary propositionthen thenegationofpis written pand will be true iffpis false. Truth table for :p pFTTFMike Wooldridge16 LECTURE 7 Software EngineeringComments We cannestcomplex formulae as deeply aswe want.
10 We can , ),(, todisambiguateformulae. EXAMPLES. Ifp,q,r,sandtare atomicpropositions, then all of the following areformulae:p q rp (q r)(p (q r)) s((p (q r)) s) twhereas none of the following is:p p q)p Mike Wooldridge17 LECTURE 7 Software Engineering3 Tautologies & Consistency Given a particular formula, can you tell ifit is true or not? No you usually need to know the truthvalues of the component atomicpropositions in order to be able to tellwhether a formula is true. Definition:Avaluationis a function whichassigns a truth value to each primitiveproposition. In Modula-2, we might write:PROCEDURE Val(p : AtomicProp):BOOLEAN; Given a valuation, we can say for anyformula whether it is true or Wooldridge18 LECTURE 7 Software Engineering EXAMPLE.