Sie sind auf Seite 1von 51

Propositional Logic (Outline)

The Language of Propositions


Logical operators (connectives):
Negation Conjunction Disjunction Implication (contrapositive, inverse, converse) Biconditional

Truth Values Truth Tables

Application Examples:
Translating English Sentences System Specications Logic Puzzles

Logical Equivalences
Important Equivalences Showing Equivalence
Teresa Leyk (CSCE 222) Discrete Structures The Foundations (Part 1): Propositional Logic Fall 2012 1/37

Propositions
Denition
A proposition is a declarative sentence that is either true or false, but not both.

Examples of propositions
It rained yesterday in College Station. Houston is the capital of Texas. 1+0=1 0+0=2 Examples that are not propositions Sit down! What time is it? x +1=2 x +y =z
Teresa Leyk (CSCE 222) Discrete Structures The Foundations (Part 1): Propositional Logic Fall 2012 2/37

Propositional Logic
The area of logic that deals with propositions is called propositional logic. Constructing propositions
Propositional variables represent propositions: p , q , r , s , . . . (Similar to variables in algebra.) The proposition that is always true is denoted by T and the proposition that is always false is denoted by F . They are called truth values.

Examples
1 2 3

p =The sky was blue in College Station today at 10am. q =2+2=4 r =All students in this classroom are freshmen.

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

3/37

Compound Propositions

Compound propositions: constructed from logical operators and propositional variables


Negation (not) Conjunction (and) Disjunction (or) Implication (conditional) Biconditional

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

4/37

Negation
The negation of a proposition p is denoted by p and has this truth table: p T F Negation reverses a truth value. Negation is a unary operation. All other logical operations are binary. p F T

Example
If p denotes The earth is round., then p denotes It is not the case that the earth is round., or more simply, The earth is not round.

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

5/37

Conjunction
The conjunction of propositions p and q is denoted by p q and has this truth table: p T T F F q T F T F pq T F F F

Example
If p denotes I am at home. and q denotes It is raining. then p q denotes I am at home and it is raining.

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

6/37

Disjunction (Inclusive or)


The disjunction of propositions p and q is denoted by p q and has this truth table: p T T F F q T F T F pq T T T F

Example
If p denotes I am at home. and q denotes It is raining. then p q denotes I am at home or it is raining.

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

7/37

The Connective Or in English


In English the conjunction or has two distinct meanings:
Inclusive Or In the sentence Students who have taken CSCE222 or Math302 may take CSCE221, we assume that students need to have taken one of the prerequisites, but may have taken both. This is the meaning of disjunction. For p q to be true, either one or both of p and q must be true. Exclusive Or When reading the sentence Soup or salad comes with this entre, we do not expect to be able to get both soup and salad. This is the meaning of Exclusive Or (Xor ). In p q , one of p and q must be true, but not both. The truth table for is:

p T T F F
Teresa Leyk (CSCE 222)

q T F T F

pq F T T F
Fall 2012 8/37

Discrete Structures The Foundations (Part 1): Propositional Logic

Implication
If p and q are propositions, then p q is a conditional statement or implication which is read as if p , then q and has this truth table: p q pq T T T T F F F T T F F T In p q , p is the hypothesis (antecedent or premise) and q is the conclusion (or consequence). The rst two rows are easy to understand. The last two rows are not so obvious: One can derive anything from a false hypothesis.

Example
If p denotes I am at home. and q denotes It is raining. then p q denotes If I am at home then it is raining.
Teresa Leyk (CSCE 222) Discrete Structures The Foundations (Part 1): Propositional Logic Fall 2012 9/37

Understanding Implication
In p q there does not need to be any connection between the hypothesis or the conclusion. The meaning of p q depends only on the truth values of p and q . These implications are perfectly ne, but would not be used in ordinary English.

Examples
1

If the moon is made of green cheese, then I have more money than Bill Gates. If the moon is made of green cheese then Im on welfare. If 1 + 1 = 3, then your grandma wears combat boots.

2 3

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

10/37

Understanding Implication (cont)

One way to view the logical conditional is to think of an obligation or contract.


If I am elected, then I will lower taxes. If you get 100% on the nal, then you will get an A.

If the politician is elected and does not lower taxes, then the voters can say that he or she has broken the campaign pledge. Something similar holds for the professor. This corresponds to the case where p is true and q is false.

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

11/37

Dierent Ways of Expressing p q

if if q q q q

p , then q p, q unless p if p whenever p follows from p

p p q p q

implies q only if q when p is sucient for q is necessary for p

a necessary condition for p is q a sucient condition for q is p

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

12/37

Converse, Contrapositive, and Inverse


From p q we can form new conditional statements.
q p is the converse of p q q p is the contrapositive of p q p q is the inverse of p q

Example
Find the converse, inverse, and contrapositive of If it is raining then I do not go to town. converse:

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

13/37

Converse, Contrapositive, and Inverse


From p q we can form new conditional statements.
q p is the converse of p q q p is the contrapositive of p q p q is the inverse of p q

Example
Find the converse, inverse, and contrapositive of If it is raining then I do not go to town. converse: If I do not go to town, then it is raining. inverse:

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

13/37

Converse, Contrapositive, and Inverse


From p q we can form new conditional statements.
q p is the converse of p q q p is the contrapositive of p q p q is the inverse of p q

Example
Find the converse, inverse, and contrapositive of If it is raining then I do not go to town. converse: If I do not go to town, then it is raining. inverse: If it is not raining, then I go to town. contrapositive:

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

13/37

Converse, Contrapositive, and Inverse


From p q we can form new conditional statements.
q p is the converse of p q q p is the contrapositive of p q p q is the inverse of p q

Example
Find the converse, inverse, and contrapositive of If it is raining then I do not go to town. converse: If I do not go to town, then it is raining. inverse: If it is not raining, then I go to town. contrapositive: If I go to town, then it is not raining.

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

13/37

Biconditional
If p and q are propositions, then we can form the biconditional proposition p q , read as p if and only if q . The biconditional p q denotes the proposition with this truth table: p T T F F q T F T F pq T F F T

If p denotes I am at home. and q denotes It is raining. then p q denotes I am at home if and only if it is raining.

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

14/37

Expressing the Biconditional

Some alternative ways p if and only if q is expressed in English:


p is necessary and sucient for q if p then q , and, if q then p p i q (i means if and only if)

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

15/37

Truth Tables For Compound Propositions

Construction of a truth table:


Rows
Need a row for every possible combination of values for the atomic propositions.

Columns
Need a column for the compound proposition (usually at far right) Need a column for the truth values of each expression that occurs in the compound proposition as it is built up. (This includes the atomic propositions.)

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

16/37

Example Truth Table

Construct a truth table for p q r p T T T T F F F F q T T F F T T F F r T F T F T F T F r F T F T F T F T pq T T T T T T F F p q r F T F T F T T T

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

17/37

Equivalent Propositions
Two propositions are equivalent if they always have the same truth value.

Example
Show using a truth table that the implication is equivalent to the contrapositive of an implication.

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

18/37

Equivalent Propositions
Two propositions are equivalent if they always have the same truth value.

Example
Show using a truth table that the implication is equivalent to the contrapositive of an implication. p T T F F q T F T F p F F T T q F T F T pq T F T T q p T F T T

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

18/37

Using a Truth Table to Show Non-Equivalence

Example
Show using truth tables that neither the converse nor inverse of an implication are equivalent to the implication.

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

19/37

Using a Truth Table to Show Non-Equivalence

Example
Show using truth tables that neither the converse nor inverse of an implication are equivalent to the implication. p T T F F q T F T F p F F T T q F T F T pq T F T T p q T T F T qp T T F T

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

19/37

Problem

How many rows are there in a truth table with n propositional variables? Solution:
n = 2 variables: 4 rows n = 3 variables: 8 rows n variables:

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

20/37

Problem

How many rows are there in a truth table with n propositional variables? Solution:
n = 2 variables: 4 rows n = 3 variables: 8 rows n variables: 2n (We will see how to get this in Chapter 6)

Note that this means that with n propositional variables, we can construct 2n distinct (i.e., not equivalent) propositions.

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

20/37

Precedence of Logical Operators


Operator , Precedence 1 (highest) 2 3 4 5 (lowest)

Parenthesized subexpressions come rst, followed by negation operator. Then multiplicative operator (), followed by additive operators (, ), followed by implication operator (), followed by biconditional operator (). Use parentheses if you have any doubt. Evaluate ties left-to-right for multiplicative and additive operators. Evaluate ties right-to-left for negation, implication and biconditional.
Teresa Leyk (CSCE 222) Discrete Structures The Foundations (Part 1): Propositional Logic Fall 2012 21/37

Precedence of Logical Operators (cont)

Examples
1

p q r is equivalent to (p q ) (r ). (If the intended meaning is p (q r ) then parentheses must be used.) p q r s t u is equivalent to (p (q r )) ((s t ) u ).

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

22/37

Translating English Sentences


Steps to convert an English sentence to a statement in propositional logic
Identify atomic propositions and represent using propositional variables. Determine appropriate logical operators (connectives)

If I go to the cinema or to my friends place, I will not go shopping.


p = I go to the cinema. q = I go to my friends place. r = I will go shopping.

It corresponds to If p or q , then not r . Then we express it, formally, as p q r .

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

23/37

Example

Translate the following sentence into propositional logic: You can access the Internet from campus only if you are a computer science major or you are not a freshman. Solution:

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

24/37

Example

Translate the following sentence into propositional logic: You can access the Internet from campus only if you are a computer science major or you are not a freshman. Solution: Let a=You can access the Internet from campus. c =You are a computer science major. f =You are a freshman. Then we can represent this sentence as a (c f )

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

24/37

System Specications
System and software engineers take requirements in English and express them in a precise specication language based on logic.

Example
Express in propositional logic: The automated reply cannot be sent when the le system is full. Solution:

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

25/37

System Specications
System and software engineers take requirements in English and express them in a precise specication language based on logic.

Example
Express in propositional logic: The automated reply cannot be sent when the le system is full. Solution: Let p=The automated reply can be sent. q=The le system is full. Then the sentence can be represented as q p .

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

25/37

Consistent System Specications


Denition
A list of propositions is consistent if it is possible to assign truth values to the proposition variables so that each proposition is true.

Example
Are these specications consistent? The diagnostic message is stored in the buer or it is retransmitted. The diagnostic message is not stored in the buer. If the diagnostic message is stored in the buer, then it is retransmitted.

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

26/37

Consistent System Specications


Denition
A list of propositions is consistent if it is possible to assign truth values to the proposition variables so that each proposition is true.

Example
Are these specications consistent? The diagnostic message is stored in the buer or it is retransmitted. The diagnostic message is not stored in the buer. If the diagnostic message is stored in the buer, then it is retransmitted. Solution: Let p=The diagnostic message is stored in the buer. q=The diagnostic message is retransmitted. The specications can be written as: p q , p , p q . When p is false and q is true then all three statements are true. So the specications are consistent.
Teresa Leyk (CSCE 222) Discrete Structures The Foundations (Part 1): Propositional Logic Fall 2012 26/37

Consistent System Specications (cont)


Example
What if add this specication The diagnostic message is not retransmitted. to the previous three specications.

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

27/37

Consistent System Specications (cont)


Example
What if add this specication The diagnostic message is not retransmitted. to the previous three specications. Solution: We are adding q . But there is no satisfying assignment of truth values in order to make all four specications true (see the table below). So the specications are not consistent. p T T F F q T F T F pq T T T F p F F T T pq T F T T q F T F T

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

27/37

Logic Puzzles
An island has two kinds of inhabitants: knights, who always tell the truth, and knaves, who always lie. You go to the island and meet two inhabitants A and B .
1 2

A says B is a knight. B says The two of us are of opposite types.

What are the types of A and B ? Solution:

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

28/37

Logic Puzzles
An island has two kinds of inhabitants: knights, who always tell the truth, and knaves, who always lie. You go to the island and meet two inhabitants A and B .
1 2

A says B is a knight. B says The two of us are of opposite types.

What are the types of A and B ? Solution:


Let p =A is a knight. and q =B is a knight. Then p represents the proposition that A is a knave and q that B is a knave. If A is a knight, then p is true. Since knights tell the truth, q must also be true by (1). Then, by (2), (p q )(p q ) would have to be true, but it is not.

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

28/37

Logic Puzzles
An island has two kinds of inhabitants: knights, who always tell the truth, and knaves, who always lie. You go to the island and meet two inhabitants A and B .
1 2

A says B is a knight. B says The two of us are of opposite types.

What are the types of A and B ? Solution:


Let p =A is a knight. and q =B is a knight. Then p represents the proposition that A is a knave and q that B is a knave. If A is a knight, then p is true. Since knights tell the truth, q must also be true by (1). Then, by (2), (p q )(p q ) would have to be true, but it is not. Therefore, A is not a knight and p must be true. If A is a knave, then by (1) B must not be a knight (q is true) since knaves always lie. So, then both p and q hold since both are knaves.
Teresa Leyk (CSCE 222) Discrete Structures The Foundations (Part 1): Propositional Logic Fall 2012 28/37

Tautologies, Contradictions, and Contingencies


Denition
A tautology is a proposition which is always true.

Example
p p

Denition
A contradiction is a proposition which is always false.

Example
p p p T F
Teresa Leyk (CSCE 222)

p F T

p p T T

p p F F
Fall 2012 29/37

Discrete Structures The Foundations (Part 1): Propositional Logic

Tautologies, Contradictions, and Contingencies (cont)

Denition
A contingency is a proposition which is neither a tautology nor a contradiction.

Examples
p p pq

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

30/37

Logically Equivalent
Denition
Two compound propositions p and q are logically equivalent if p q is a tautology. We write this as p q or, sometimes, as p q where p and q are compound propositions. Two compound propositions p and q are equivalent if and only if the columns in a truth table giving their truth values agree.

Example
This truth table shows that p q is equivalent to p q . p T T F F
Teresa Leyk (CSCE 222)

q T F T F

p F F T T

p q T F T T

pq T F T T
Fall 2012 31/37

Discrete Structures The Foundations (Part 1): Propositional Logic

De Morgans Laws

(p q ) p q (First Law) (p q ) p q (Second Law) This truth table shows that De Morgans Second Law holds. p T T F F q T F T F p F F T T q F T F T (p q ) T T T F (p q ) F F F T p q F F F T

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

32/37

Key Logical Equivalences

Identity Laws: p T p and p F p Domination Laws: p T T and p F F Idempotent Laws: p p p and p p p Double Negation Law: (p ) p Negation Laws: p p T and p p F

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

33/37

Key Logical Equivalences (cont)

Commutative Laws: p q q p and p q q p Associative Laws: (p q ) r p (q r ) and (p q ) r p (q r ) Distributive Laws: p (q r ) (p q ) (p r ) and p (q r ) (p q ) (p r ) Absorption Laws: p (p q ) p and p (p q ) p For more logical equivalences, see Table 7 and 8, p. 28.

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

34/37

Constructing New Logical Equivalences

We can show that two expressions are logically equivalent by developing a series of logically equivalent statements. To prove that we produce a series of equivalences beginning with A and ending with B : A A1 , A1 A2 , . . . , An B Keep in mind that whenever a proposition (represented by a propositional variable) occurs in the equivalences listed earlier, it may be replaced by an arbitrarily complex compound proposition.

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

35/37

Equivalence Proofs
Example
Show that (p (p q )) is logically equivalent to (p q ) Solution: (p (p q ))

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

36/37

Equivalence Proofs
Example
Show that (p (p q )) is logically equivalent to (p q ) Solution: (p (p q )) p ((p q )) by the second De Morgans law p ((p ) q ) by the rst De Morgans law p (p q ) by the double negation law (p p ) (p q ) by the distributive law F (p q ) by the negation law (p q ) F by the commutative law (p q ) by the identity law

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

36/37

Equivalence Proofs (cont)

Example
Show that (p q ) (p q ) is a tautology. Solution: (p q ) (p q )

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

37/37

Equivalence Proofs (cont)

Example
Show that (p q ) (p q ) is Solution: (p q ) (p q ) (p q ) (p q ) (p q ) (p q ) (p p ) (q q ) T T T a tautology.

by truth table for by the rst De Morgans law by associative and commutative laws by truth tables by the domination law

Teresa Leyk (CSCE 222)

Discrete Structures The Foundations (Part 1): Propositional Logic

Fall 2012

37/37

Das könnte Ihnen auch gefallen