michael genesereth: introduction to logic

9
C H A P T E R 2 Propositional Logic 2.1 Introduction Propositional Logic is concerned with propositions and their interrelationships. The notion of a proposition here cannot be defined precisely. Roughly speaking, a proposition is a possible condition of the world that is either true or false, e.g. the possibility that it is raining, the possibility that it is cloudy, and so forth. The condition need not be true in order for it to be a proposition. In fact, we might want to say that it is false or that it is true if some other proposition is true. In this chapter, we first look at the syntactic rules for the language of Propositional Logic. We then look at the semantics of the expressions specified by these rules. Given this semantics, we talk about evaluation, satisfaction, and the properties of sentences. We then define the concept of propositional entailment, which identifies for us, at least in principle, all of the logical conclusions one can draw from any set of propositional sentences. 2.2 Syntax In Propositional Logic, there are two types of sentences -- simple sentences and compound sentences. Simple sentences express simple facts about the world. Compound sentences express logical relationships between the simpler sentences of which they are composed. Simple sentences in Propositional Logic are often called propositional constants or, sometimes, logical constants. In what follows, we write proposition constants as strings of letters, digits, and underscores ("_"), where the first character is a lower case letter. For example, raining is a proposition constant, as are rAiNiNg, r32aining, and raining_or_snowing. Raining is not a logical constant because it begins with an upper case character. 324567 fails because it begins with a number. raining-or-snowing fails because it contains hyphens. Compound sentences are formed from simpler sentences and express relationships among the constituent sentences. There are five types of compound sentences, viz. negations, conjunctions, disjunctions, implications, and biconditionals. A negation consists of the negation operator ¬ and a simple or compound sentence, called the target. For example, given the sentence p, we can form the negation of p as shown below. p) A conjunction is a sequence of sentences separated by occurrences of the ! operator and enclosed in parentheses, as shown below. The constituent sentences are called conjuncts. For example, we can form the conjunction of p and q as follows. (p ! q)

Upload: josegarcia

Post on 29-Apr-2015

136 views

Category:

Documents


3 download

DESCRIPTION

Michael Genesereth: Introduction to logic, chapter 1

TRANSCRIPT

Page 1: Michael Genesereth: Introduction to logic

C H A P T E R 2

Propositional Logic

2.1 Introduction

Propositional Logic is concerned with propositions and their interrelationships. The notion of aproposition here cannot be defined precisely. Roughly speaking, a proposition is a possiblecondition of the world that is either true or false, e.g. the possibility that it is raining, thepossibility that it is cloudy, and so forth. The condition need not be true in order for it to be aproposition. In fact, we might want to say that it is false or that it is true if some other propositionis true.

In this chapter, we first look at the syntactic rules for the language of Propositional Logic. We thenlook at the semantics of the expressions specified by these rules. Given this semantics, we talkabout evaluation, satisfaction, and the properties of sentences. We then define the concept ofpropositional entailment, which identifies for us, at least in principle, all of the logical conclusionsone can draw from any set of propositional sentences.

2.2 Syntax

In Propositional Logic, there are two types of sentences -- simple sentences and compoundsentences. Simple sentences express simple facts about the world. Compound sentences expresslogical relationships between the simpler sentences of which they are composed.

Simple sentences in Propositional Logic are often called propositional constants or, sometimes,logical constants. In what follows, we write proposition constants as strings of letters, digits, andunderscores ("_"), where the first character is a lower case letter. For example, raining is aproposition constant, as are rAiNiNg, r32aining, and raining_or_snowing. Raining is not a logicalconstant because it begins with an upper case character. 324567 fails because it begins with anumber. raining-or-snowing fails because it contains hyphens.

Compound sentences are formed from simpler sentences and express relationships among theconstituent sentences. There are five types of compound sentences, viz. negations, conjunctions,disjunctions, implications, and biconditionals.

A negation consists of the negation operator ¬ and a simple or compound sentence, called thetarget. For example, given the sentence p, we can form the negation of p as shown below.

(¬p)

A conjunction is a sequence of sentences separated by occurrences of the ! operator and enclosedin parentheses, as shown below. The constituent sentences are called conjuncts. For example, wecan form the conjunction of p and q as follows.

(p ! q)

Page 2: Michael Genesereth: Introduction to logic

A disjunction is a sequence of sentences separated by occurrences of the " operator and enclosedin parentheses. The constituent sentences are called disjuncts. For example, we can form thedisjunction of p and q as follows.

(p " q)

An implication consists of a pair of sentences separated by the # operator and enclosed inparentheses. The sentence to the left of the operator is called the antecedent, and the sentence tothe right is called the consequent. The implication of p and q is shown below.

(p # q)

An equivalence, or biconditional, is a combination of an implication and a reduction. For example,we can express the biconditional of p and q as shown below.

(p $ q)

Note that the constituent sentences within any compound sentence can be either simple sentencesor compound sentences or a mixture of the two. For example, the following is a legal compoundsentence.

((p " q) # r)

One disadvantage of our notation, as written, is that the parentheses tend to build up and need tobe matched correctly. It would be nice if we could dispense with parentheses, e.g. simplifying thepreceding sentence to the one shown below.

p " q # r

Unfortunately, we cannot do without parentheses entirely, since then we would be unable to rendercertain sentences unambiguously. For example, the sentence shown above could have resultedfrom dropping parentheses from either of the following sentences.

((p " q) # r)

(p " (q # r))

The solution to this problem is the use of operator precedence. The following table gives ahierarchy of precedences for our operators. The ¬ operator has higher precedence than !; ! hashigher precedence than "; and " has higher precedence than # and $.

¬!"

# $

In unparenthesized sentences, it is often the case that an expression is flanked by operators, one oneither side. In interpreting such sentences, the question is whether the operator associates with theoperator on its left or the one on its right. We can use precedence to make this determination. Inparticular, we agree that an operand in such a situation always associates with the operator ofhigher precedence. When an operand is surrounded by operators of equal precedence, the operand

Page 3: Michael Genesereth: Introduction to logic

associates to the right. The following examples show how these rules work in various cases. Theexpressions on the right are the fully parenthesized versions of the expressions on the left.

¬ p ! q ((¬ p) ! q)p ! ¬q (p ! (¬ q))p ! q " r ((p ! q) " r)p " q ! r (p " (q ! r)p # q # r (p # (q # r))p # q $ r (p # (q $ r))

Note that just because precedence allows us to delete parentheses in some cases does not meanthat we can dispense with parentheses entirely. Consider the example shown earlier. Precedenceeliminates the ambiguity by dictating that the unparenthesized sentence is an implication with adisjunction as antecedent. However, this makes for a problem for those cases when we want toexpress a disjunction with an implication as a disjunct. In such cases, we must retain at least onepair of parentheses.

2.3 Semantics

The treatment of semantics in Logic is similar to its treatment in Algebra. Algebra is unconcernedwith the real-world significance of variables. What is interesting are the relationships among thevalues of the variables expressed in the equations we write. Algebraic methods are designed torespect these relationships, independent of what the variables represent.

In a similar way, Logic is unconcerned with the real world significance of proposition constants.What is interesting is the relationship among the truth values of simple sentences and the truthvalues of compound sentences within which the simple sentences are contained. As with Algebra,logical reasoning methods are independent of the significance of proposition constants; all thatmatter is the form of sentences.

Although the values assigned to logical constants are not crucial in the sense just described, intalking about Logic, it is sometimes useful to make truth assignments explicit and to considervarious assignments or all assignments and so forth. Such an assignment is called a truthassignment.

Formally, a truth assignment for Propositional Logic is a function assigning a truth value to eachof the proposition constants of the language. In what follows, we use the digit 1 as a synonym fortrue and 0 as a synonym for false; and we refer to the value of a constant or expression under atruth assignment i by superscripting the constant or expression with i as the superscript.

The assignment shown below is an example for the case of a logical language with just threeproposition constants, viz. p, q, and r.

pi = 1qi = 0ri = 1

The following assignment is another truth assignment for the same language.

Page 4: Michael Genesereth: Introduction to logic

pi = 0qi = 0ri = 1

Note that the formulas above are not themselves sentences in Propositional Logic. PropositionalLogic does not allow superscripts and does not use the = symbol. Rather, these are informal,metalevel statements about particular truth assignments. Although talking about propositionallogic using a notation similar to that propositional logic can sometimes be confusing, it allows usto convey meta-information precisely and efficiently. To minimize problems, in this book we usesuch meta-notation infrequently and only when there is little chance of confusion.

Looking at the preceding truth assignments, it is important to bear in mind that, as far as logic isconcerned, any truth assignment is as good as any other. It does not directly fix the truthassignment of individual proposition constants.

On the other hand, given a truth assignment for the logical constants of a language, logic does fixthe truth assignment for all compound sentences in that language. In fact, it is possible todetermine the truth value of a compound sentence by repeatedly applying the following rules.

If the truth value of a sentence is 1, the truth value of its negation is 0. If the truth value of asentence is 0, the truth value of its negation is 1.

The truth value of a conjunction is true if and only if the truth value of its conjuncts are bothtrue; otherwise, the truth value is false.

The truth value of a disjunction is true if and only if the truth value of at least one itsconjuncts is true; otherwise, the truth value is false. Note that this is the inclusive orinterpretation of the " operator and is differentiated from the exclusive or interpretation inwhich a disjunction is true if and only if an odd number of its disjuncts are false.

The truth value of an implication is false if and only if its antecedent is true and isconsequent is false; otherwise, the truth value is true. This is called material implication.

A biconditional is true if and only if the truth values of its constituents agree, i.e. they areeither both true or both false.

Given the semantic definitions in the last section, we can easily determine the truth value for anysentence, wether simple or compound, given a truth assignment for our proposition constants. Thetechnique is simple. We substitute true and false values for the proposition constants in oursentence, forming an expression with 1s and 0s and logical operators. We use our operatorsemantics to evaluate subexpressions with these truth values as arguments. We then repeat,working from the inside out, until we have a truth value for the sentence as a whole.

As an example, consider the truth assignment i shown below.

pi = 1qi = 0ri = 1

Using our evaluation method, we can see that i satisfies (p " q) ! (¬q " r).

Page 5: Michael Genesereth: Introduction to logic

(p " q) ! (¬ q " r)(1 " 0) ! (¬ 0 " 1)

1 ! (¬ 0 " 1)1 ! (1 " 1)

1 ! 11

Now consider truth assignment j defined as follows.

pj = 1qj = 1rj = 0

In this case, j does not satisfy (p " q) ! (¬q " r).

(p " q) ! (¬q " r)(1 " 1) ! (¬1 " 0)

1 ! (¬1 " 0)1 ! (0 " 0)

1 ! 00

Using this technique, we can evaluate the truth of arbitrary sentences in our language. The cost isproportional to the size of the sentence.

We finish up this section with a few definitions for future use. We say that a truth assignmentsatisfies a sentence if and only if it is true under that truth assignment. We say that a truthassignment falsifies a sentence if and only if it is false under that truth assignment. A truthassignment satisfies a set of sentences if and only if it satisfies every sentence in the set. A truthassignment falsifies a set of sentences if and only if it satisfies at least one sentence in the set.

2.4 Satisfaction

Satisfaction is the opposite of evaluation. We begin with one or more compound sentences and tryto figure out which truth assignments satisfy those sentences.

One way to do this is using a truth table for the language. A truth table for a propositionallanguage is a table showing all of the possible truth assignments for the propositional constants inthe language.

The following figure shows a truth table for a propositional language with just three propositionalconstants (p, q, and r). Each column corresponds to one proposition constant, and each rowcorresponds to a single truth assignment. The truth assignments i and j defined in the precedingsection correspond to the third and seventh rows of this table, respectively.

p q r1 1 11 1 01 0 1

Page 6: Michael Genesereth: Introduction to logic

1 0 00 1 10 1 00 0 10 0 0

Note that, for a propositional language with n logical constants, there are n columns in the truthtables and 2n rows.

Here is an intuitively simple method of finding truth assignments that satisfy given sentences. (1)We start with a truth table for the proposition constants of our language, and we add columns foreach sentence in our set. (2) We then evaluate each sentence for each of the rows of the truth table.(3) Finally, any row that satisfies all sentences in the set is a solution to the problem as a whole.Note that there might be more than one.

In solving satisfaction problems, we start with a truth table for the proposition constants of ourlanguage. We then process our sentences in turn, for each sentence crossing out truth assignmentsin the truth table that do not satisfy the sentence. The truth assignments remaining at the end ofthis process are all possible truth assignments of the input sentences.

2.5 Logical Properties of Propositional Sentences

Evaluation and satisfaction are processes that involve specific sentences and specific truthassignments. In Logic, we are sometimes more interested in the properties of sentences that holdacross truth assignments. In particular, the notion of satisfaction imposes a classification ofsentences in a language based on whether there are truth assignments that satisfy that sentence.

A sentence is valid if and only if it is satisfied by every truth assignment. For example, thesentence p " ¬p is valid.

A sentence is unsatisfiable if and only if it is not satisfied by any truth assignment. For example,teh sentence p $ ¬p is unsatisfiable. No matter what truth assignment we take, the sentence isalways false.

A sentence is contingent if and only if there is some truth assignment that satisfies it and sometruth assignment that falsifies it.

It is frequently useful to group these classifications into two groups. A sentence is satisfiable ifand only if it is valid or contingent. A sentence is falsifiable if and only if it is unsatisfiable orcontingent. We have already seen several examples of satisfiable and falsifiable sentences.

In one sense, valid sentences and unsatisfiable sentences are useless. Valid sentences do not ruleout any possible truth assignments; unsatisfiable sentences rule out all truth assignments; thus theysay nothing about the world. On the other hand, from a logical perspective, they are extremelyuseful in that, as we shall see, they serve as the basis for legal transformations that we can performon other logical sentences.

2.6 Propositional Entailment

Validity, satisfiability, and unsatisfiability are properties of individual sentences. In logical

Page 7: Michael Genesereth: Introduction to logic

reasoning, we are not so much concerned with individual sentences as we are with therelationships between sentences. In particular, we would like to know, given some sentences,whether other sentences are or are not logical conclusions. This relative property is known aslogical entailment. When we are speaking about Propositional Logic, we use the phrasepropositional entailment.

A set of sentences ! logically entails a sentence " (written ! |= ") if and only if every truthassignment that satisfies ! also satisfies ".

For example, the sentence p logically entails the sentence (p " q). Since a disjunction is truewhenever one of its disjuncts is true, then (p " q) must be true whenever p is true. On the otherhand, the sentence p does not logically entail (p ! q). A conjunction is true if and only if both of itsconjuncts are true, and q may be false. Of course, any set of sentences containing both p and qdoes logically entail (p ! q).

Note that the relationship of logical entailment is a logical one. Even if the premises of a problemdo not logically entail the conclusion, this does not mean that the conclusion is necessarily false,even if the premises are true. It just means that it is possible that the conclusion is false.

Once again, consider the case of (p ! q). Although p does not logically entail this sentence, it ispossible that both p and q are true and, therefore, (p ! q) is true. However, the logical entailmentdoes not hold because it is also possible that q is false and, therefore, (p ! q) is false.

Note that logical entailment is not the same as logical equivalence. The sentence p logically entails(p " q), but (p " q) does not logically entail p. Logical entailment is not analogous to arithmeticequality; it is closer to arithmetic inequality.

One way of determining whether or not a set of premises logically entails a possible conclusion isto check the truth table for the proposition constants in the language. This is called the truth tablemethod. (1) First, we form a truth table for the proposition constants and add a column for thepremises and a column for the conclusion. (2) We then evaluate the premises. (3) We evaluate theconclusion. (4) Finally, we compare the results. If every row that satisfies the premises alsosatisfies the conclusion, then the premises logically entail the conclusion.

As an example, let's use this method to show that p logically entails (p " q). We set up our truthtable and add a column for our premise and a column for our conclusion. In this case the premiseis just p and so evaluation is straightforward; we just copy the column. The conclusion is true ifand only if p is true or q is true. Finally, we notice that every row that satisfies the the premise alsosatisfies the conclusion.

p q p p "" q1 1 1 11 0 1 10 1 0 10 0 0 0

Now, let's do the same for the premise p and the conclusion (p ! q). We set up our table as beforeand evaluate our premise. In this case, there is only one row that satisfies our conclusion. Finally,we notice that the assignment in the second row satisfies our premise but does not satisfy ourconclusion; so logical entailment does not hold.

Page 8: Michael Genesereth: Introduction to logic

p q p p !! q1 1 1 11 0 1 00 1 0 00 0 0 0

Finally, let's look at the problem of determining whether the set of propositions {p, q} logicallyentails (p ! q). Here we set up our table as before, but this time we have two premises to satisfy.Only one truth assignment satisfies both premises, and this truth assignment also satisfies theconclusion; hence in this case logical entailment does hold.

p q p q p !! q1 1 1 1 11 0 1 0 00 1 0 1 00 0 0 0 0

As a final example, let's return to the love life of the fickle Mary. Here is the problem from thecourse introduction. We know (p # q), i.e. if Mary loves Pat, then Mary loves Quincy. We know(m # p " q), i.e. if it is Monday, then Mary loves Pat or Quincy. Let's confirm that, if it isMonday, then Mary loves Quincy. We set up our table and evaluate our premises and ourconclusion. Both premises are satisfied by the truth assignments on rows 1, 3, 5, 7, and 8; and wenotice that those truth assignments make the conclusion true. Hence, the logical entailment holds.

m p q m ## p "" q p ## q m ## q1 1 1 1 1 11 1 0 1 0 01 0 1 1 1 11 0 0 0 1 00 1 1 1 1 10 1 0 1 0 10 0 1 1 1 10 0 0 1 1 1

The disadvantage of the truth table method is computational complexity. As mentioned above, thesize of a truth table for a language grows exponentially with the number of proposition constantsin the language. When the number of constants is small, the method works well. When the numberis large, the method becomes impractical. Even for moderate sized problems, it can be tedious.Even for an application like Sorority World, where there are only 16 proposition constants, thereare 65,536 truth assignments.

Over the years, researchers have proposed ways to improve the performance of truth tablechecking. We discuss some of these in Chapter 5. The other approach is to use symbolicmanipulation (i.e. logical reasoning and proofs) in place of truth table checking. We discuss thesemethods in the next chapter.

Page 9: Michael Genesereth: Introduction to logic

Before we end this section, it is worth noting that logical entailment and satisfiability have aninteresting relationship to each other. In particular, if a set ! of sentences logically entails asentence ", then ! together with the negation of " must be unsatisfiable. The reverse is also true.If ! and the negation of " is unsatisfiable, then ! must logically entail ". This is guaranteed by ametatheorem called the unsatisfiability theorem.

Unsatisfiability Theorem: ! |= " if and only if ! % {¬"} is unsatisfiable.

Proof: Suppose that ! |= ". If a truth assignment satisfies !, then it must also satisfy ". But then itcannot satisfy ¬". Therefore, ! % {¬"} is unsatisfiable. Suppose that !%{¬"} is unsatisfiable.Then every truth assignment that satisfies ! must fail to satisfy ¬", i.e. it must satisfy ".Therefore, ! |= ".

An interesting consequence of this result is that we can determine logical entailment by checkingfor unsatisfiability. This turns out to be useful in various logical proof methods.

Recap

The syntax of propositional logic begins with a set proposition constants. Compound sentences areformed by combining simpler sentences with logical operators. In the version of PropositionalLogic used here, there are five types of compound sentences - negations, conjunctions,disjunctions, implications, and biconditionals. A truth assignment for Propositional Logic is amapping that assigns a truth value to each of the propositional constants in the language. The truthor falsity of compound sentences can be determined from a truth assignment using rules based onthe six logical operators of the language. A truth assignment i satisfies a sentence if and only if thesentences is true under that truth assignment. A sentence is valid if and only if it is satisfied byevery truth assignment. A sentence is unsatisfiable if and only if it is not satisfied by any truthassignment. A sentence is contingent if and only if it is both satisfiable and falsifiable, i.e. it isneither valid nor unsatisfiable. A sentence is satisfiable if and only if it is either valid orcontingent. A sentence is falsifiable if and only if it is falsifiable or contingent. A set of sentences! logically entails a sentence " (written ! |= ") if and only if every truth assignment that satisfies! also satisfies ".