Quick viewing(Text Mode)

Propositional Logic

Propositional Logic

CSCE 222 Discrete Structures for Computing Propositional

Dr. Hyunyoung Lee

Based on slides by Andreas Klappenecker

1

A is a declarative sentence that is either true or (but not both).

Examples:

• College Station is the capital of the USA. • There are fewer politicians in College Station than in Washington, D.C. • 1+1=2 • 2+2=5

2 Propositional Variables

A variable that represents propositions is called a . For example: p, q, r, ...

[Propositional variables in logic play the same role as numerical variables in arithmetic.]

3 Propositional Logic

The area of logic that deals with propositions is called propositional logic.

In addition to propositional variables, we have logical connectives (or operators) such as not (for ), and (for ), or (for disjunction), (for exclusive disjunction), conditional (for implication), and biconditional.

4 Formation Tree

Each logical connective is enclosed in parentheses, except for the negation connective ¬. Thus, we can associate a unique binary tree to each proposition, called the formation tree. The formation tree contains all subformulas of a formula, starting with the formula at its root and breaking it down into its subformulas until you reach the propositional variables at its leafs.

5 Formation Tree

A formation tree of a proposition p has a root labeled with p and satisfies the following rules: T1. Each leaf is an occurrence of a propositional variable in p. T2. Each internal node with a single successor is labeled by a subformula ¬q of p and has q as a successor. T3. Each internal node with two successors is labeled by a subformula aXb of p with X in {∧,∨,⊕,→, } and has a as a left successor and b as a right successor. 6 The start is formula . The terminal symbols are the elements in S, the connectives, and the parentheses.⌦ We will refer to the elements in S as propositional variables or variables for short. Remark. We could have used any other countable S to name the variables, as long as it does not contain the parentheses and the connectives. Example 3. The formula ((a b) c) ⇧ ⌃ ¬ belongs to the language of propositional logic. Indeed, this can be seen as follows: formula yields ( formula formula ) ⌦ yields (( formula⌦⌃ formula⌦ ) formula ) yields (( formula ⌦⇧ formula ⌦) ⌃ formula⌦ ). ⌦⇧ ⌦ ⌃ ¬ ⌦ By applying the last rule three times, we get

(( symbol symbol ) symbol ), ⌦⇧ ⌦ ⌃ ¬ ⌦ and the symbols can be chosen to be a, b and c,respectively. You might have wondered why each logical connective is enclosed in paren- theses, except for the negation connective . This ensures that we can associate a unique binary tree to each proposition,¬ called the formation tree. The for- mation tree contains all subformulas of a proposition. A formation tree of a proposition p has a root labeled with p and satisfies the following rules: T1. Each leaf is an occurrence of a propositional variable in p. T2. Each internal node with a single successor is labeled by a subformula q of p and has q as a successor. ¬ T3. Each internal node with two successorsExample is labeled by a subformula aXb of p with X in , , , , and has a as a left successor and b as a right successor. {⇧ ⌃ ⇥ ⇤}

Example 4. The formation tree of the formula ((a b) c) is given by ⇧ ⌃ ¬ ((a b) c) ⇧ ⌃ ¬ ΩΩZZ (a b) c ⇧ ¬ ≠≠JJ ab c Remark. In a course on compiler construction, you will learn how to write a parser for languages such as the one that we have specified for propositional logic. You can check out lex and yacc if you want to write a parser for propo- sitional logic in C or C++ now. In Haskell,7 you can use for example the parser generator Happy.

4 Assigning Meanings to Formulas

We know that each formula corresponds to a unique binary tree. We can evaluate the formula by - giving each propositional variable a value - defining the meaning of each logical connective - propagate the truth values from the leafs to the root in a unique way, so that we get an unambiguous evaluation of each formula.

8 4 The of Propositional Logic

Let B = t, f denote the set of truth values, where t and f represent true and false,{ respectively.} We associateSemantics to the logical connective the M : B B given by ¬ ¬ ⌅ P M (P ) 4 The Semantics of Propositional¬ Logic f t LetLetB =B={t,t,ff }.denote Assign the setto ofeacht truth connective values,f where xt aand functionf represent true and false,{ respectively.} We associate to the logical connective the function Thus,MMx: (B->BP ) is truethat if anddetermines only if P isthe false. semantics This justifies of thex¬. name negation M : B¬ B given by for this¬ connective.⌅ The graph of the function M given above is called the P M (P ) ¬ ¬ of the negation connective.f t Similarly, we associate to a connective X in the set , , , , a binaryt functionf MX : B B B.Thetruth tables of these{⌥ connectives ⇥ ⌅ ⇧ are} as follows: ⌅ Thus, M (P ) is true P is false. This justifies the name negation for thisPQ connective.¬ M (P, Q The) M graph(P, ofQ) theM function(P, Q)MMgiven(P, Q above) M is called(P, Q) the ⇧ ⌃ ¬ ⇥ ⇤ truth ff table of thef negation connective.f Similarly,f we associatet to a connectivet X inft the set , f , , , ta binary functiont MX : Bt B B.Thetruthf {⌥ ⇥ ⌅ ⇧} ⌅ tables tf of these connectivesf aret as follows: t f f ttPQM t(P, Q) M (tP, Q) M (P,f Q) M (P,t Q) M (P,t Q) ⇧ ⌃ ⇥ ⇤ You shouldff very carefullyf inspectf this table!f It is criticalt that yout memorize ft f t t t f and fully understand the meaning of each9 connective. tf f t t f f The semantics of the language Prop is given by assigning truth values to tt t t f t t each proposition in Prop. Clearly, an arbitrary assignment of truth values is notYou interesting, should very since carefully we would inspect like everything this table! to It be is critical consistent that with you the memorize meaning ofand the fullyconnectives understand that the we meaning have just of learned. each connective. For example, if the propositions a and bThehave semantics been assigned of the languagethe valuePropt, thenis given it is reasonable by assigning to truth insist values that a to b beeach assigned proposition the value in Propt as. well. Clearly, Therefore, an arbitrary we will assignment introduce of truth the concept values is of⌥ a valuation,not interesting, which since models we thewould semantics like everything of Prop to bein consistent an appropriate with the way. meaning ofA thevaluation connectivesv : thatProp we haveB is just a functionlearned. For that example, assigns if a the truth propositions value to eacha propositionand b have in beenProp assignedsuch that⌅ the value t, then it is reasonable to insist that a b be assigned the value t as well. Therefore, we will introduce the concept of⌥ a V1.valuation,v a = whichM ( modelsv a ) the semantics of Prop in an appropriate way. V2. v (¬a b) =¬ M (v a ,v b ) A valuation⌥ v :⇧Prop B is a function that assigns a to each V3.propositionvJ(a K b) in=PropMJ (Ksuchv a that,v⌅ b ) V4. v (a b) = M⌃ (v a ,v b ) V1. Jv ⇥a =K M (va J) K J K V5. v (a¬ b) =¬ M (v a ,v b ) V2. Jv (a⌅ bK) = M⇥(vJ aK ,vJ bK) V6. v (a ⌥b) = M⇧ (v a ,v b ) V3. Jv (a bK) = M⇤(vJaK ,vJbK) J ⇧K J⌃ K holdsV4. forJvJ(a allb propositions)KK = M (vJJaKaK,vandJ JbK )K b in Prop. The properties V1–V6 ensure thatV5. theJv ( valuationa ⇥ bK) = respectsM (vJ aK the,vJb meaningK) of the connectives. We can restrict a J ⌅ K ⇥ J K J K valuationV6. v (av tob) a = M (v ofa the,v b set) of proposition. If A and B are of J ⇧ K ⇤ J K J K Propholdssuch forJ that all propositionsKA B, andJ aK vandAJ :KAb in PropB and.v TheB : B propertiesB areV1 valuations,–V6 ensure then ⇤ ⌅ ⌅ vBthatis called theJ valuation an extensionK respectsJ ofK the theJ meaningK valuation of thevA connectives.if and only if WevB cancoincides restrict with a vAvaluationwhen restrictedv to a subset to A. of the set of proposition. If A and B are subsets of PropThe consistencysuch that A conditionsB, and vAV1: A-V6 Bareand quitevB : stringent,B B are as valuations, the next then ⇤ ⌅ ⌅ shows.vB is called an of the valuation vA if and only if vB coincides with vA when restricted to A. The consistency conditions V1-V6 are quite stringent, as the next theorem shows. 5

5 Summary

Informally, we can summarize the meaning of the connectives in words as follows: 1. The and connective (a ⋀ b) is true if and only if both a and b are true. 2. The or connective (a ⋁ b) is true if and only if at least one of a, b is true. 3. The exclusive or (a ⊕ b) is true if and only if precisely one of a, b is true. 4. The implication (a → b) is false if and only if the premise a is true and the conclusion b is false. 5. The biconditional (a ︎ b) is true if and only if the truth values of a and b are the same.

10 Equivalences and Applications

11 Remarks

• In our formal introduction of propositional logic, we used a strict syntactic structure with full parenthesizing (except ). • From now on, we will be more relaxed about the and allow to drop enclosing parentheses. • This can introduce , which is resolved by introducing operator precedence rules (from highest to lowest) as follows. 1) negation, 2) and, 3) or, xor, 4) conditional, 5) biconditional

12 Tautologies

A proposition p is called a if and only if in a truth table it always evaluates to true regardless of the assignment of truth values to its variables. Example:

p ¬p p ⋁ ¬p F T T T F T

13 Example of a Tautology

p q ¬p ¬p⋁q p→q (¬p⋁q) (p→q)

F F T T T T

F T T T T T T F F F F T T T F T T T Roughly speaking, this means that ¬p⋁q has the same meaning as p→q.

14

Two propositions p and q are called logically equivalent if and only if p q is a tautology. We write p ≡ q if and only if p and q are logically equivalent. We have shown that (¬p⋁q) ≡ (p→q). In general, we can use truth tables to establish logical equivalences.

15 De Morgan’s Laws (1)

Theorem: ¬(p⋀q) ≡ ¬p ⋁ ¬q. Proof: We can use a truth table:

p q (p⋀q) ¬(p⋀q) ¬ p ¬ q ¬p ⋁ ¬q

F F F T T T T

F T F T T F T

T F F T F T T

T T T F F F F

16 De Morgan’s Laws (2)

Theorem: ¬(p⋁q) ≡ ¬p ⋀ ¬q Proof: Use truth table, as before. See Example 2 on page 27 of our textbook.

17 Commutative, Associative, and Distributive Laws

Commutative laws:

Associative laws:

Distributive laws:

18 Double Negation Law

We have ¬(¬p) ≡ p

p ¬p ¬(¬p)

F T F

T F T

19 Logical Equivalences

You find many more logical equivalences listed in Table 6 on page 29. You should very carefully study these laws.

20 Logical Equivalences in Action

Let us show that ¬(p → q) and p ⋀ ¬q are logically equivalent without using truth tables.

[ using laws of logic are more desirable than truth tables unless the number of propositional variables is tiny.]

21