L001: Rosen, 1.1 Propositional Logic

Discrete Structures
CMSC 2123
Lecture 1
1.1 Propositional Logic
DEFINITION 0
A proposition is a declarative sentence that is either true or false but not
both.
EXAMPLE 1.1
The following is a declarative sentence.
Washington D.C. is the capital of the United States of America.
True.
EXAMPLE 1.2
The following is a declarative sentence.
Toronto is the capital of Canada.
False
EXAMPLE 1.3
The following is a declarative sentence.
One plus one equals two. 1 + 1 = 2.
True
EXAMPLE 1.4
The following is a declarative sentence.
Two plus two equals three. 2 + 2 = 3.
False
EXAMPLE 2.1
The following is not a declarative sentence because the sentence is not a
statement of a fact. The sentence is a question.
What time is it?
EXAMPLE 2.2
The following is not a declarative sentence because the sentence is not a
statement of a fact. The sentence is a command.
Read this carefully.
EXAMPLE 2.3
The following is not a declarative sentence because the sentence cannot be
shown to be either true or false.
π‘₯π‘₯ + 1 = 2
EXAMPLE 2.4
The following is not a declarative sentence because the sentence cannot be
shown to be either true or false.
π‘₯π‘₯ + 𝑦𝑦 = 𝑧𝑧
1
Discrete Structures
CMSC 2123
DEFINITION 1
Lecture 1
1.1 Propositional Logic
Let p be a proposition. The negation of p, denoted by ¬π‘π‘ (also denoted by
𝑝𝑝), is the statement β€œIt is not the case that p.”
The proposition ¬π‘π‘ is read β€œnot p.” The truth value of the negation of p, ¬π‘π‘,
is the opposite of the truth value of p.
EXAMPLE 3
Find the negation of the proposition
β€œMichael’s PC runs Linux.”
and express this in simple English.
Solution: The negation is:
β€œIt is not the case that Michael’s PC runs Linux.”
This negation can be more simply expressed by
β€œMichael’s PC does not run Linux.”
EXAMPLE 3.1
Find the negation of the proposition
β€œToday is Friday.”
and express this in simple English.
Solution: The negation is:
β€œIt is not the case that today is Friday.”
This negation can be more simply expressed by
β€œToday is not Friday.”
2
Discrete Structures
CMSC 2123
EXAMPLE 4
Lecture 1
1.1 Propositional Logic
Find the negation of the proposition
β€œVandana’s smartphone has at least 32GB of memory.”
and express this in simple English.
Solution: The negation is:
β€œIt is not the case that Vandana’s smartphone has at least 32GB of
memory.”
This negation can also be expressed by
β€œVandana’s smartphone does not have at least 32GB of memory.”
or even more simply as
β€œVandana’s smartphone has less than 32GB of memory.”
EXAMPLE 4.1
Find the negation of the proposition
β€œAt least 10 inches of rain fell today in Miami.”
and express this in simple English.
Solution: The negation is:
β€œIt is not the case that at least 10 inches of rain fell today in Miami.”
This negation can be more simply expressed by
β€œLess than 10 inches of rain fell today in Miami.”
REMARK
Table 1 displays the truth table for the negation of a proposition p. This table
has a row for each of the two possible truth values of a proposition p. Each
row shows the truth value of ¬π’‘𝒑 corresponding to the truth value of 𝒑𝒑 for
this row.
TABLE 1 The Truth Table for the
Negation of a Proposition
𝒑𝒑
¬π’‘𝒑
T
F
F
T
3
Discrete Structures
CMSC 2123
REMARK
β€’
β€’
β€’
β€’
DEFINITION 2
Lecture 1
1.1 Propositional Logic
The negation of a proposition can also be considered the result of the
operation of the negation operator on a proposition.
The negation operator constructs a new proposition from a single
existing proposition.
We will now introduce the logical operators that are used to form new
propositions from two or more existing propositions.
The logical operators are also called connectives.
Let p and q be propositions. The conjunction of p and q, denoted by 𝑝𝑝 ∧ π‘žπ‘ž, is
the proposition β€œp and q.” The conjunction 𝑝𝑝 ∧ π‘žπ‘ž is true when both p and q
are true and is false otherwise.
TABLE 2 The Truth Table for the Conjunction of
Two Propositions
𝒑𝒑
𝒒𝒒
𝒑𝒑 ∧ 𝒒𝒒
T
T
T
T
F
F
F
T
F
F
F
F
EXAMPLE 5
Find the conjunction of the propositions p and q where p is the proposition
β€œToday is Friday” and q is the proposition β€œIt is raining today.”
Solution: The conjunction of these propositions, 𝑝𝑝 ∧ π‘žπ‘ž, is the proposition
β€œToday is Friday and it is raining today.”
This proposition is true on rainy Fridays and is false on any day that is not a
Friday and on Fridays when it does not rain.
DEFINITION 3
Let p and q be propositions. The disjunction of p and q, denoted by 𝑝𝑝 ∨ π‘žπ‘ž, is
the proposition β€œp or q.” The disjunction 𝑝𝑝 ∨ π‘žπ‘ž is false when both p and q
are false and is true otherwise.
TABLE 3 The Truth Table for the Disjunction of
Two Propositions
𝒑𝒑
𝒒𝒒
𝒑𝒑 ∨ 𝒒𝒒
T
T
T
T
F
T
F
T
T
F
F
F
4
Discrete Structures
CMSC 2123
EXAMPLE 6
Lecture 1
1.1 Propositional Logic
Find the disjunction of the propositions p and q where p is the proposition
β€œToday is Friday” and q is the proposition β€œIt is raining today.”
Solution: The disjunction of these propositions, 𝑝𝑝 ∨ π‘žπ‘ž, is the proposition
β€œToday is Friday or it is raining today.”
This proposition is true on any day that is either a Friday or a rainy day
(including rainy Fridays). It is only false on days that are not Fridays when it
also does not rain.
DEFINITION 4
Let p and q be propositions. The exclusive or of p and q, denoted by π‘π‘β¨π‘žπ‘ž, is
the proposition that is true when exactly one of p and q is true and is false
otherwise.
TABLE 4 The Truth Table for the Exclusive OR of
Two Propositions
𝒑𝒑
𝒒𝒒
𝒑𝒑⨁𝒒𝒒
T
T
F
T
F
T
F
T
T
F
F
F
Conditional Statements
DEFINITION 5
Let p and q be propositions. The conditional statement, 𝑝𝑝 β†’ π‘žπ‘ž, is the
proposition β€œif p, then q.” The conditional statement 𝑝𝑝 β†’ π‘žπ‘ž is false when p
is true and q is false, and true otherwise. In the conditional statement 𝑝𝑝 β†’
π‘žπ‘ž, p is called the hypothesis (or antecedent or premise) and q is called the
conclusion (or consequence).
TABLE 5 The Truth Table for the Conditional
Statement of Two Propositions
𝒑𝒑
𝒒𝒒
𝒑𝒑 β†’ 𝒒𝒒
T
T
T
T
F
F
F
T
T
F
F
T
β€’
The statement 𝑝𝑝 β†’ π‘žπ‘ž is called a conditional statement because 𝑝𝑝 β†’ π‘žπ‘ž asserts that q is true
on the condition that p holds. A conditional statement is also called an implication.
5
Discrete Structures
CMSC 2123
EXAMPLE 7
Lecture 1
1.1 Propositional Logic
β€œif p, then q”
β€œp implies q”
β€œif p, q”
β€œp only if q”
β€œp is sufficient for q”
β€œa sufficient condition for q is p”
β€œq if p”
β€œq whenever p”
β€œq when p”
β€œq is necessary for p”
β€œa necessary condition for p is q” β€œq follows from p”
β€œq unless ¬ 𝑝𝑝”
Figure 1. Alternative phrases for
𝒑𝒑 β†’ 𝒒𝒒
Let p be the statement β€œMaria learns discrete mathematics” and q the
statement β€œMaria will find a good job.” Express the statement 𝑝𝑝 β†’ π‘žπ‘ž as a
statement in English.
Solution: From the definition of conditional statements, we see that when p
is the statement Maria learns discrete mathematics” and q is the statement
β€œMaria will find a good job,” 𝑝𝑝 β†’ π‘žπ‘ž represents the statement
β€œIf Maria learns discrete mathematics, then she will find a good job.”
Alternatively:
β€œMaria will find a good job when she learns discrete mathematics.”
β€œFor Maria to get a good job, it is sufficient for her to learn discrete
mathematics.”
β€œMaria will find a good job unless she does not learn discrete
mathematics.”
EXAMPLE 8
What is the value of the variable x after the statement
if 2 + 2 = 4 then π‘₯π‘₯ ≔ π‘₯π‘₯ + 1
if π‘₯π‘₯ = 0 before this statement is encountered? (The symbol ≔ stands for
assignment. The statement π‘₯π‘₯ ≔ π‘₯π‘₯ + 1 means the assignment of the value
π‘₯π‘₯ + 1 to π‘₯π‘₯.)
Solution: Because 2 + 2 = 4 is true, the assignment statement π‘₯π‘₯ ≔ π‘₯π‘₯ + 1 is
executed. Hence π‘₯π‘₯ has the value 0 + 1 = 1 after this statement is
encountered.
6
Discrete Structures
CMSC 2123
Lecture 1
1.1 Propositional Logic
CONVERSE, CONTRAPOSITIVE, AND INVERSE
β€’
β€’
Implication
Converse of 𝑝𝑝 β†’ π‘žπ‘ž
Contrapositive 𝒑𝒑 β†’ 𝒒𝒒
Inverse 𝑝𝑝 β†’ π‘žπ‘ž
𝑝𝑝 β†’ π‘žπ‘ž
π‘žπ‘ž β†’ 𝑝𝑝
¬π’’𝒒 β†’ ¬π’‘𝒑
¬π‘π‘ β†’ ¬π‘žπ‘ž
if p, then q
if q, then p
if not q, then not p
if not p, then not q
Only the contrapositive ¬π’’𝒒 β†’ ¬π’‘𝒑, has the same truth values as the implication 𝑝𝑝 β†’ π‘žπ‘ž.
When two compound propositions have the same truth values they are called equivalent.
Equivalence is denoted by the operator ≑.
EXAMPLE 9
What are the contrapositive, the converse, and the inverse of the conditional
statement
β€œThe home team wins whenever it is raining.”?
Solution: Because β€œπ‘žπ‘ž whenever 𝑝𝑝” is one of the ways to express the
conditional statement 𝑝𝑝 β†’ π‘žπ‘ž, the original can be rewritten as
β€œIf it is raining, then the home team wins.”
contrapositive
β€œIf the home team does not win, then it is not
raining.”
converse
β€œIf the home team wins, then it is raining.”
π‘žπ‘ž β†’ 𝑝𝑝
inverse
¬π‘π‘ β†’ ¬π‘žπ‘ž β€œIf it is not raining, then the home team does
not win.”
Note: Only the contrapositive is equivalent to the original statement.
DEFINITION 6
¬π‘žπ‘ž β†’ ¬π‘π‘
Let p and q be propositions. The biconditional statement, 𝑝𝑝 ↔ π‘žπ‘ž, is the
proposition β€œp if and only if q.” The biconditional statement 𝑝𝑝 ↔ π‘žπ‘ž is true
when 𝑝𝑝 and π‘žπ‘ž have the same truth values, and is false otherwise.
Biconditional statements are also called bi-implications.
TABLE 6 The Truth Table for the Biconditional
𝒑𝒑 ↔ 𝒒𝒒.
𝒑𝒑
𝒒𝒒
𝒑𝒑 ↔ 𝒒𝒒
T
T
T
T
F
F
F
T
F
F
F
T
7
Discrete Structures
CMSC 2123
Lecture 1
1.1 Propositional Logic
The truth table for 𝑝𝑝 ↔ π‘žπ‘ž is shown in Table 6. Note that the statement 𝑝𝑝 ↔ π‘žπ‘ž is true when both
the conditional statements 𝑝𝑝 β†’ π‘žπ‘ž and π‘žπ‘ž β†’ 𝑝𝑝 are true and is false otherwise. That is why we use
the words β€œif and only if” to express this logical connective and why it is symbolically written by
combining the symbols β†’ and ←. There are other common ways to express 𝑝𝑝 ↔ π‘žπ‘ž:
β€œp is necessary and sufficient for q”
β€œif p then q, and conversely”
β€œp iff q.”
The last way of expressing the biconditional statement 𝑝𝑝 ↔ π‘žπ‘ž uses the abbreviation β€œiff” for β€œif
and only if.” Note that 𝑝𝑝 ↔ π‘žπ‘ž has exactly the same truth value as (𝑝𝑝 β†’ π‘žπ‘ž) ∧ (π‘žπ‘ž β†’ 𝑝𝑝).
EXAMPLE 10
Let p be the statement β€œYou can take the flight” and q be the statement β€œYou
buy a ticket.” Express the biconditional 𝑝𝑝 ↔ π‘žπ‘ž as an English sentence.
Solution: β€œYou can take the flight if and only if you buy a ticket.”
Truth Tables of Compound Propositions
EXAMPLE 11
Construct the truth table of the compound proposition
(𝑝𝑝 ∨ ¬π‘žπ‘ž) β†’ (𝑝𝑝 ∧ π‘žπ‘ž)
Solution:
1. Rows: The number of rows in the truth table is equal to 2|𝑣𝑣| , where
|𝑣𝑣| is the number of propositional variables. In this case, there are
two propositional variables, p and q. Hence, there are 22 = 4 rows.
2. Columns. There are as many columns as there are compound
propositions, propositional variables, and negated propositional
variables.
3. Construction. Complete the columns from left to right moving from
the simple to the complex.
TABLE 7 The Truth Table of (𝒑𝒑 ∨ ¬π’’𝒒) β†’ (𝒑𝒑 ∧ 𝒒𝒒)
𝒑𝒑 𝒒𝒒 ¬π’’𝒒 𝒑𝒑 ∨ ¬π’’𝒒
𝒑𝒑 ∧ 𝒒𝒒
T T
F
T
T
T F
T
T
F
F T
F
F
F
F F
T
T
F
8
(𝒑𝒑 ∨ ¬π’’𝒒) β†’ (𝒑𝒑 ∧ 𝒒𝒒)
T
F
T
F
Discrete Structures
CMSC 2123
Lecture 1
1.1 Propositional Logic
Precedence of Logical Operators
TABLE 8 Precedence of Logical Operators
Operator
Precedence
Precedence
1
Highest
¬
2
∧
3
∨
4
β†’
5
Lowest
↔
Translating English Sentences
EXAMPLE 12
How can this English sentence be translated into a logical expression?
β€œYou can access the Internet from campus only if you are a computer
science major or you are not a freshman.”
EXAMPLE 13
Solution: Define the following propositions:
Proposition English statement
β€œYou can access the Internet from campus.”
π‘Žπ‘Ž
β€œYou are a computer science major.”
𝑐𝑐
𝑓𝑓
β€œYou are a freshman”
β€œonly if” maps to β†’
π‘Žπ‘Ž β†’ (𝑐𝑐 ∨ ¬π‘“𝑓)
Translate the following sentence into a logical expression.
β€œYou cannot ride the roller coaster if you are under 4 feet tall unless you
are older than 16 years old.”
Solution: Define the following propositions:
Proposition English statement
β€œYou can ride the roller coaster.”
π‘žπ‘ž
β€œYou are under 4 feet tall.”
π‘Ÿπ‘Ÿ
s
β€œYou are older than 16 years old.”
(π‘Ÿπ‘Ÿ ∧ ¬π‘ π‘ ) β†’ ¬π‘žπ‘ž
Logic and Bit Operations
Truth Value
T
F
Bit
1
0
9
Discrete Structures
CMSC 2123
Lecture 1
1.1 Propositional Logic
REMARK
A bit is the contraction of binary digit, a zero (0) or a one (1).
DEFINITION 7
A bit string is a sequence of zero or more bits. The length of the string is the
number of bits in the string.
EXAMPLE 12
101010011 is a bit string of length nine.
EXAMPLE 13
Find the bitwise OR, bitwise AND, and bitwise XOR, of the bit strings 01
1011 0110 and 11 0001 1101.
Solution:
OR
0
1
1
1
1
1
1
0
1
0
0
0
1
0
1
1
1
1
0
1
1
1
1
1
1
0
1
0
1
1
AND
0
1
0
1
1
1
1
0
0
0
0
0
1
0
0
1
1
1
0
1
0
1
1
1
1
0
0
0
1
0
XOR
0
1
1
1
1
0
1
0
1
0
0
0
1
0
1
1
1
0
0
1
1
1
1
0
1
0
1
0
1
0
10