Beruflich Dokumente
Kultur Dokumente
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.
Fall 2012
3/37
Compound Propositions
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.
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.
Fall 2012
6/37
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.
Fall 2012
7/37
p T T F F
Teresa Leyk (CSCE 222)
q T F T F
pq F T T F
Fall 2012 8/37
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
Fall 2012
10/37
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.
Fall 2012
11/37
if if q q q q
p p q p q
Fall 2012
12/37
Example
Find the converse, inverse, and contrapositive of If it is raining then I do not go to town. converse:
Fall 2012
13/37
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:
Fall 2012
13/37
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:
Fall 2012
13/37
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.
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.
Fall 2012
14/37
Fall 2012
15/37
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.)
Fall 2012
16/37
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.
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
Fall 2012
18/37
Example
Show using truth tables that neither the converse nor inverse of an implication are equivalent to the implication.
Fall 2012
19/37
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
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:
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.
Fall 2012
20/37
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
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 ).
Fall 2012
22/37
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:
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 )
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:
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 .
Fall 2012
25/37
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.
Fall 2012
26/37
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
Fall 2012
27/37
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
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
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
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
Denition
A contingency is a proposition which is neither a tautology nor a contradiction.
Examples
p p pq
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
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
Fall 2012
32/37
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
Fall 2012
33/37
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.
Fall 2012
34/37
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.
Fall 2012
35/37
Equivalence Proofs
Example
Show that (p (p q )) is logically equivalent to (p q ) Solution: (p (p q ))
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
Fall 2012
36/37
Example
Show that (p q ) (p q ) is a tautology. Solution: (p q ) (p q )
Fall 2012
37/37
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
Fall 2012
37/37