Discrete-Structures-2-Module-1 2
Discrete-Structures-2-Module-1 2
City of Olongapo
GORDON COLLEGE
Olongapo City Sports Complex, East Tapinac, Olongapo City
Tel. No. (047) 224-2089 loc. 314
www.gordoncollege.edu.ph
DISCRETE STRUCTURES 2
Title: PROPOSITIONAL LOGIC Module No. 1
I. INTRODUCTION
We begin our study of discrete mathematics with an introduction to logic. Besides the
importance of logic in understanding mathematical reasoning, logic has numerous
applications to computer science. These rules are used in the design of computer circuits,
the construction of computer programs, the verification of the correctness of programs,
and in many other ways. Furthermore, software systems have been developed for
constructing some, but not all, types of proofs automatically.
EXAMPLE 1
All the following declarative sentences are propositions.
EXAMPLE 2
Consider the following sentences.
Sentences 1 and 2 are not propositions because they are not declarative sentences.
Sentences 3 and 4 are not propositions because they are neither true nor false. Note
that each of sentences 3 and 4 can be turned into a proposition if we assign values to
the variables.
We use letters to denote propositional variables (or statement variables), that is,
variables that represent propositions, just as letters are used to denote numerical
variables. The conventional letters used for propositional variables are p, q, r, s, . . . .
The truth value of a proposition is true, denoted by T, if it is a true proposition, and
the truth value of a proposition is false, denoted by F, if it is a false proposition.
The area of logic that deals with propositions is called the propositional calculus or
propositional logic. It was first developed systematically by the Greek philosopher
Aristotle more than 2300 years ago.
We now turn our attention to methods for producing new propositions from those
that we already have. These methods were discussed by the English mathematician
George Boole in 1854 in his book The Laws of Thought. Many mathematical
statements are constructed by combining one or more propositions. New
propositions, called compound propositions, are formed from existing propositions
using logical operators.
The proposition ¬p is read “not p.” The truth value of the negation
of p, ¬p, is the opposite of the truth value of p.
EXAMPLE 3
Find the negation of the proposition
“Today is Friday”
or
EXAMPLE 4
Find the negation of the proposition
“It is not the case that at least 10 inches of rain fell today in Miami.”
p ¬p
T F
F T
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 ¬p corresponding to the truth value of p for this row.
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. These logical operators are also called connectives.
p q p∧q
T T T
T F F
F T F
F F F
Table 2 displays the truth table of p ∧ q. This table has a row for each of the four
possible combinations of truth values of p and q. The four rows correspond to the
pairs of truth values TT, TF, FT, and FF, where the first truth value in the pair is the
truth value of p and the second truth value is the truth value of q.
Note that in logic the word “but” sometimes is used instead of “and” in a conjunction.
For example, the statement “The sun is shining, but it is raining” is another way of
saying “The sun is shining and it is raining.” (In natural language, there is a subtle
difference in meaning between “and” and “but”; we will not be concerned with this
nuance here.)
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”.
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.
p q p∨q
T T T
T F T
F T T
F F F
The use of the connective or in a disjunction corresponds to one of the two ways the
word or is used in English, namely, as an inclusive or. A disjunction is true when at
least one of the two propositions is true. For instance, the inclusive or is being used in
the statement
“Students who have taken calculus or computer science can take this class.”
Here, we mean that students who have taken both calculus and computer science can
take the class, as well as the students who have taken only one of the two subjects. On
the other hand, we are using the exclusive or when we say
“Students who have taken calculus or computer science, but not both, can enroll
in this class.”
Here, we mean that students who have taken both calculus and a computer science
course cannot take the class. Only those who have taken exactly one of the two courses
can take the class.
Similarly, when a menu at a restaurant states, “Soup or salad comes with an entrée,”
the restaurant almost always means that customers can have either soup or salad, but
not both. Hence, this is an exclusive, rather than an inclusive, or.
EXAMPLE 6
What is the disjunction of the propositions p and q where p and q are the same
propositions as in Example 5?
This proposition is true on any day that is either a Fridays or a rainy day (including
rainy Fridays). It is only false on days that are not Fridays when it also does not rain.
p q p⊕q
T T F
T F T
F T T
F F F
The truth table for the exclusive or of two propositions is displayed in Table 4.
B. CONDITIONAL STATEMENTS
We will discuss several other important ways in which propositions can be combined.
p q p→q
T T T
T F F
F T T
F F T
The truth table for the conditional statement p → q is shown in Table 5. Note that the
statement p → q is true when both p and q are true and when p is false (no matter
what truth value q has).
If the politician is elected, voters would expect this politician to lower taxes.
Furthermore, if the politician is not elected, then voters will not have any expectation
that this person will lower taxes, although the person may have sufficient influence to
cause those in power to lower taxes. It is only when the politician is elected but does
not lower taxes that voters can say that the politician has broken the campaign pledge.
This last scenario corresponds to the case when p is true but q is false in p → q.
Many people find it confusing that “p only if q” expresses the same thing as “if p, then
q,” To remember this, note that “p only if q” says that p cannot be true when q is not
true. That is, the statement is false if p is true, but q is false. When p is false, q may be
either true or false, because the statement says nothing about the truth value of q. A
common error is for people to think that “q only if p” is a way of expressing p → q.
However, these statements have different truth values when p and q have different
truth values.
The word “unless” is often used to express conditional statements. Observe that “q
unless ¬p” means that if ¬p is false, then q must be true. That is, the statement “q
unless ¬p” is false when p is true and q is false, but it is true otherwise. Consequently,
“q unless ¬p” and p → q always have the same truth value.
EXAMPLE 7
Let p be the statement “Maria learns discrete mathematics” and q the statement
“Maria will find a good job.” Express the statement p → q 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,” p → q represents the statement
“If Maria learns discrete mathematics, then she will find a good job.”
There are many other ways to express this conditional statement in English. Among
the most natural of these are:
“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.”
and
“Maria will find a good job unless she does not learn discrete mathematics.”
Note that the way we have defined conditional statements is more general than the
meaning attached to such statements in the English language. For instance, the
conditional statement in Example 7 and the statement
are statements used in normal language where there is a relationship between the
hypothesis and the conclusion. Further, the first of these statements is true unless
Maria learns discrete mathematics, but she does not get a good job, and the second is
true unless it is indeed sunny, but we do not go to the beach. On the other hand, the
statement
is true from the definition of a conditional statement, because its conclusion is true.
(The truth value of the hypothesis does not matter then.) The conditional statement
We would not use these last two conditional statements in natural language (except
perhaps in sarcasm), because there is no relationship between the hypothesis and the
conclusion in either statement. In mathematical reasoning, we consider conditional
statements of a more general sort than we use in English. The mathematical concept
of a conditional statement is independent of a cause-and-effect relationship between
hypothesis and conclusion. Our definition of a conditional statement specifies its truth
values; it is not based on English usage. Propositional language is an artificial
language; we only parallel English usage to make it easy to use and remember.
The if-then construction used in many programming languages is different from that
used in logic. Most programming languages contain statements such as if p then S,
where p is a proposition and S is a program segment (one or more statements to be
executed). When execution of a program encounters such a statement, S is executed
if p is true, but S is not executed if p is false, as illustrated in Example 8.
EXAMPLE 8
What is the value of the variable x after the statement
if 2 + 2 = 4 then x := x + 1
When two compound propositions always have the same truth value we call them
equivalent, so that a conditional statement and its contrapositive are equivalent. The
converse and the inverse of a conditional statement are also equivalent, as the reader
can verify, but neither is equivalent to the original conditional statement. (We will
study equivalent propositions in Module 2.) Take note that one of the most common
logical errors is to assume that the converse or the inverse of a conditional statement
is equivalent to this conditional statement.
EXAMPLE 9
What are the contrapositive, the converse, and the inverse of the conditional
statement
“If the home team does not win, then it is not raining.”
The converse is
The inverse is
“If it is not raining, then the home team does not win.”
p q p↔q
T T T
T F F
F T F
F F T
The truth table for p ↔ q is shown in Table 6. Note that the statement p ↔ q is true
when both the conditional statements p → q and q → p 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 some
other common ways to express p ↔ q:
The last way of expressing the biconditional statement p ↔ q uses the abbreviation
“iff” for “if and only if.” Note that p ↔ q has exactly the same truth value as (p → q) ∧
(q → p).
EXAMPLE 10
Let p be the statement “You can take the flight,” and let q be the statement “You buy a
ticket.” Then p ↔ q is the statement
“You can take the flight if and only if you buy a ticket.”
This statement is true if p and q are either both true or both false, that is, if you buy a
ticket and can take the flight or if you do not buy a ticket and you cannot take the flight.
It is false when p and q have opposite truth values, that is, when you do not buy a
ticket, but you can take the flight (such as when you get a free trip) and when you buy
a ticket but you cannot take the flight (such as when the airline bumps you).
EXAMPLE 11
Construct the truth table of the compound proposition
(p ∨ ¬q) → (p ∧ q).
Solution: Because this truth table involves two propositional variables p and q, there
are four rows in this truth table, one for each of the pairs of truth values TT, TF, FT,
and FF. The first two columns are used for the truth values of p and q, respectively. In
the third column we find the truth value of ¬q, needed to find the truth value of
p ∨ ¬q, found in the fourth column. The fifth column gives the truth value of p ∧ q.
Finally, the truth value of (p ∨ ¬q) → (p ∧ q) is found in the last column. The resulting
truth table is shown in Table 7.
p q ¬q p ∨ ¬q p∧q (p ∨ ¬q) → (p ∧ q)
T T F T T T
T F T T F F
F T F F F T
F F T T F F
Another general rule of precedence is that the conjunction operator takes precedence
over the disjunction operator, so that p ∧ q ∨ r means (p ∧ q) ∨ r rather than p ∧ (q ∨
r). Because this rule may be difficult to remember, we will continue to use parentheses
so that the order of the disjunction and conjunction operators is clear.
Finally, it is an accepted rule that the conditional and biconditional operators → and
↔ have lower precedence than the conjunction and disjunction operators, ∧ and ∨.
Consequently, p ∨ q → r is the same as (p ∨ q) → r. We will use parentheses when the
order of the conditional operator and biconditional operator is at issue, although the
conditional operator has precedence over the biconditional operator.
TABLE 8 Precedence of
Logical Operators.
Operator Precedence
¬ 1
∧ 2
∨ 3
→ 4
↔ 5
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.”
Solution: There are many ways to translate this sentence into a logical expression.
Although it is possible to represent the sentence by a single propositional variable,
such as p, this would not be useful when analyzing its meaning or reasoning with it.
Instead, we will use propositional variables to represent each sentence part and
determine the appropriate logical connectives between them.
In particular, we let a, c, and f represent “You can access the Internet from campus”,
“You are a computer science major”, and “You are a freshman”, respectively. Noting
that “only if” is one way a conditional statement can be expressed, this sentence can
be represented as
a → (c ∨ ¬f ).
EXAMPLE 13
How can this English sentence be translated 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: Let q, r, and s represent “You can ride the roller coaster,” “You are under 4
feet tall,” and “You are older than 16 years old,” respectively. Then the sentence can
be translated to
(r ∧ ¬s) → ¬q.
Of course, there are other ways to represent the original sentence as a logical
expression, but the one we have used should meet our needs.
F. LOGIC PUZZLES
Puzzles that can be solved using logical reasoning are known as logic puzzles. Solving
logic puzzles is an excellent way to practice working with the rules of logic. Also,
computer programs designed to carry out logical reasoning often use well-known
logic puzzles to illustrate their capabilities. Many people enjoy solving logic puzzles,
published in periodicals, books, and on the Web, as a recreational activity.
We will discuss two logic puzzles here. We begin with a puzzle originally posed by
Raymond Smullyan, a master of logic puzzles, who has published more than a dozen
books containing challenging puzzles that involve logical reasoning.
EXAMPLE 14
In [Sm78] Smullyan posed many puzzles about an island that has two kinds of
inhabitants, knights, who always tell the truth, and their opposites, knaves, who
always lie. You encounter two people A and B. What are A and B if A says “B is a knight”
and B says “The two of us are opposite types?”
Solution: Let p and q be the statements that A is a knight and B is a knight, respectively,
so that ¬p and ¬q are the statements that A is a knave and B is a knave, respectively.
We first consider the possibility that A is a knight; this is the statement that p is true.
If A is a knight, then he is telling the truth when he says that B is a knight, so that q is
true, and A and B are the same type. However, if B is a knight, then B’s statement that
A and B are of opposite types, the statement (p ∧ ¬q) ∨ (¬p ∧ q), would have to be
true, which it is not, because A and B are both knights. Consequently, we can conclude
that A is not a knight, that is, that p is false.
If A is a knave, then because everything a knave says is false, A’s statement that B is a
knight, that is, that q is true, is a lie. This means that q is false and B is also a knave.
Furthermore, if B is a knave, then B’s statement that A and B are opposite types is a
lie, which is consistent with both A and B being knaves. We can conclude that both A
and B are knaves.
EXAMPLE 15
A father tells his two children, a boy and a girl, to play in their backyard without
getting dirty. However, while playing, both children get mud on their foreheads. When
the children stop playing, the father says “At least one of you has a muddy forehead,”
and then asks the children to answer “Yes” or “No” to the question: “Do you know
whether you have a muddy forehead?” The father asks this question twice. What will
the children answer each time this question is asked, assuming that a child can see
whether his or her sibling has a muddy forehead, but cannot see his or her own
forehead? Assume that both children are honest and that the children answer each
question simultaneously.
Solution: Let s be the statement that the son has a muddy forehead and let d be the
statement that the daughter has a muddy forehead. When the father says that at least
one of the two children has a muddy forehead, he is stating that the disjunction s ∨ d
is true. Both children will answer “No” the first time the question is asked because
each sees mud on the other child’s forehead. That is, the son knows that d is true, but
does not know whether s is true, and the daughter knows that s is true, but does not
know whether d is true.
After the son has answered “No” to the first question, the daughter can determine that
d must be true. This follows because when the first question is asked, the son knows
that s ∨ d is true, but cannot determine whether s is true. Using this information, the
daughter can conclude that d must be true, for if d were false, the son could have
reasoned that because s ∨ d is true, then s must be true, and he would have answered
“Yes” to the first question. The son can reason in a similar way to determine that s
must be true. It follows that both children answer “Yes” the second time the question
is asked.
V. LEARNING TASKS
EXERCISES:
1. Which of these sentences are propositions? What are the truth values of those that
are propositions?
a. Boston is the capital of Massachusetts.
b. Miami is the capital of Florida.
c. 2 + 3 = 5.
d. 5 + 7 = 10.
e. x + 2 = 11.
f. Answer this question.
5. State the converse, contrapositive, and inverse of each of the following conditional
statements.
a. If it snows today, I will ski tomorrow.
b. I come to class whenever there is going to be a quiz.
c. A positive integer is a prime only if it has no divisors other than 1 and itself.
d. I go to the beach whenever it is a sunny summer day.
e. When I stay up late, it is necessary that I sleep until noon.
RUBRIC:
3 2 1 0
VI. REFERENCE
Rosen, K. H. (2018). Discrete Mathematics and Its Applications, Eighth Edition.
McGraw-Hill.