Discrete Mathematics: (COMP2121B)
Discrete Mathematics: (COMP2121B)
(ii) The converse of the implication P → Q, (iii) The contrapositive of the implication P → Q,
(iv) The inverse of the implication P → Q .
(ii) The converse Q → P says "If I come to class, then there is going to be a quiz".
(iii) The contrapositive ¬Q → ¬P says "If I don't come to class, then there won't be a quiz".
(iv) The inverse ¬P → ¬Q says "If there is not going to be a quiz, then I will not come to class".
Propositional Logic Exercises
(a) Berries are ripe along the trail, but grizzly bears have not been seen in the area.
(b) Grizzly bears have not been seen in the area and hiking on the trail is safe,
but berries are ripe along the trail.
(c) If berries are ripe along the trail, hiking is safe if and only if grizzly bears have not been
seen in the area.
(d) It is not safe to hike on the trail, but grizzly bears have not been seen in the area
and the berries along the trail are ripe.
(e) For hiking on the trail to be safe, it is necessary but not sufficient that berries not be ripe
along the trail and for grizzly bears not to have been seen in the area.
(f) Hiking is not safe on the trail whenever grizzly bears have been seen in the area
and berries are ripe along the trail.
A3. The truth table for the given propositions:
p q r p → q ¬p → r (p → q) ∧ ( ¬p → r) ¬p ↔ ¬q q ↔ r ( ¬p ↔ ¬q) ↔ (q ↔ r)
F F F T F F T T T
F F T T T T T F F
F T F T F F F F T
F T T T T T F T F
T F F F T F F T F
T F T F T F F F T
T T F T T T T F F
T T T T T T T T T
Propositional Logic Exercises
Q4. You are eligible to be President of the U.S.A. only if you are at least 35 years old,
were born in the U.S.A., or at the time of your birth both of your parents were citizens,
and you have lived at least 14 years in the country.
Express this statement in terms of e : "You are eligible to be President of the U.S.A.,
a : "You are at least 35 years old", b : "You were born in the U.S.A.",
c : "At the time of your birth, both of your parents were citizens",
d : "You have lived at least 14 years in the U.S.A.".
A4. e → (a ∧ (b ∨ c) ∧ d)
Logical Equivalences Exercises
Q5. Show that the following statements are Tautologies by applying a chain of logical identities
≡ p ∨ ( ¬p ∨ q) by the Conditional-Disjunction Equivalence
≡ (p ∨ ( ¬p)) ∨ q by the Associativity rule for Disjunction
≡ T ∨ q by the Negation Law
≡ T by the Domination Law
Since ¬p → (p → q) is always true irrespective of the truth values of the propositions p, q,
it is a Tautology. ◼
Logical Equivalences Exercises
Q5. Show that the following statements are Tautologies by applying a chain of logical identities
≡ ( ¬p ∨ ¬q) ∨ ( ¬p ∨ q) by De Morgan's Law
≡ ¬p ∨ ¬p ∨ ¬q ∨ q by the Associativity rule for Disjunction
≡ ¬p ∨ T by the Idempotent Law and the Negation Law
≡ T by the Domination Law
Since (p ∧ q) → (p → q) is always true irrespective of the truth values of the propositions p, q,
it is a Tautology. ◼
Logical Equivalences Exercises
Q5. Show that the following statements are Tautologies by applying a chain of logical identities
≡ T by the Domination Law
Such statements involving variables are neither true nor false until values of variables are specified.
Definition. For a variable x the set of values that it can take is called the Domain of Discourse
or Universe of Discourse or simply just the Domain.
Preconditions are statements that define a valid input for the program. Example: x = 0.
Besides assigning particular values to variables in a propositional function, there is another way
to convert it into a proposition called Quantification.
The area of logic dealing with predicates and quantifiers is called Predicate Logic or Predicate Calculus.
x in the domain such that P(x)". The Existential Quantifier is denoted by ∃ .
The quantifiers ∀, ∃ have higher precedence than all the logical operators from propositional logic.
The part of the statement to which a quantifier is applied is the Scope of this quantifier.
When a quantifier is used on the variable, this occurrence of the variable is said to be bound.
Any occurrence of a variable that is not bound by a quantifier or assigned a value is said to be free.
∀ is limited to P(x) .
Methods of Predicate Logic
Statements involving predicates and quantifiers are logically equivalent (denoted ≡ ) if and only if
they have the same truth value irrespective of which predicates are substituted and
which domains are used.
De Morgan's Laws for Quantifiers:
Example: The negation of the proposition: "Everybody in the class loves logic" is
"There exists at least one person in the class who does not love logic".
We can now construct logical equivalences in Predicate Logic.
Note: We cannot distribute a Universal Quantifier over a Disjunction.
We cannot distribute an Existential Quantifier over a Conjunction.
When one Quantifier is within the scope of another, the order is very important.
∀y ∃x P(x, y) : "For all doors, there exists a key that opens that door".
∃x ∀y P(x, y) : "There exists atleast one key that opens all the doors".
When we have predicates with more than one variable, even more care is necessary.
Negating propositions with nested quantifiers can be done by successively applying de Morgan laws
for negating statements with single quantifiers.
Example. ¬ ∀x ∃y (x + y = 0) ≡ ∃x ¬ ∃y (x + y = 0)
≡ ∃x ∀y ¬ (x + y = 0)
≡ ∃x ∀y (x + y ≠ 0)
Predicates and Quantifiers Exercises
then she or he is funny".
"Some comedians are funny".
Predicates and Quantifiers Exercises
(a) There is a student at HKU who can speak Russian and who knows C++,
(b) There is a student at HKU who can speak Russian but who does not know C++,
(c) Every student at HKU can either speak Russian or knows C++,
(d) No student at HKU can speak Russian or knows C++.
Q8. Express the negation of each of these statements in terms of quantifiers without
using the negation symbol
Q9. Express the following statements using predicates and quantifiers:
(a) "A man qualifies for the marathon if his previous best time is less than 3 hours and a woman
qualifies if her best previous time was less than 3.5 hours".
(b) "A student must take at least 60 course hours, or atleast 45 course hours and write a thesis,
and obtain at least a B in all courses, to receive a master's degree".
Q9. Express the following statements using predicates and quantifiers:
(a) "A man qualifies for the marathon if his previous best time is less than 3 hours and a woman
qualifies if her best previous time was less than 3.5 hours".
(b) "A student must take at least 60 course hours, or atleast 45 course hours and write a thesis,
and obtain at least a B in all courses, to receive a master's degree".
(( )
M(x) → C(x, 60) ∨ (C(x, 45) ∧ T(x))) ∧ ∀z G(x, B, z) .
Predicates and Quantifiers Exercises
Q10. Let P(x), Q(x), R(x) and S(x) be the statements "x is a baby", "x is logical",
"x is able to manage a crocodile", and "x is despised", respectively.
Suppose the domain consists of all people. Express the following using logical quantifiers, connectives.
(a) "Babies are illogical", (b) "Nobody is despised who can manage a crocodile",
(c) "Illogical persons are despised", (d) "Babies cannot manage crocodiles".
Does (d) follow from (a), (b) and (c)?
Therefore, (d) does follow from (a), (b) and (c).
Nested Quantifiers Exercises
and domain for y is all cuisines. Express the following by a simple English sentence.
there is some cuisine that at least one of them does not like".
Nested Quantifiers Exercises
about which they have the same opinion (either they both like it or they both do not like it)".
Nested Quantifiers Exercises
Q12. Express the following using mathematical and logical operators, predicates and quantifiers,
where the domain consists of all integers.
(a) "The sum of two negative integers is negative".
(b) "The difference of two positive integers is not necessarily positive".
(c) "The sum of squares of two integers is greater than or equal to the square of their sum".
(d) "The absolute value of the product of two integers is the product of their absolute values".
(b) "The difference of two positive integers is not necessarily positive":
Q12. Express the following using mathematical and logical operators, predicates and quantifiers,
where the domain consists of all integers.
(a) "The sum of two negative integers is negative".
(b) "The difference of two positive integers is not necessarily positive".
(c) "The sum of squares of two non-negative integers is less than or equal to the square of their sum".
(d) "The absolute value of the product of two integers is the product of their absolute values".
(d) ∀x ∀y ( | xy | = | x | | y | ) .
Nested Quantifiers Exercises
Q13. Rewrite the following statements so that the negations only appear within the predicates.
Q14. Use quantifiers and logical connectives to express the fact that every linear polynomial with
real coefficients and where the coefficient of x is nonzero, has exactly one real root.
(a) nonzero real numbers, (b) nonzero integers, (c) positive real numbers.
A15. (a) True. (b) False. (c) True.
Practice Exercises
1. Show that (p → q) ∧ (q → r) → (p → r) is a tautology.
2. Find a counterexample, if possible, to these universally quantified statements,
where the domain for all variables consists of all integers
(a) ∀x (x 2 ≥ x), (b) ∀x ((x > 0) ∨ (x < 0))
3 * (Optional). Steve would like to determine the relative salaries of three people using two facts.
First, he knows that if Fred is not the highest paid of the three, then Janice is.
Second, he knows that if Janice is not the lowest paid, then Maggie is paid the most.
Can you help Steve list the three people in order of decreasing salary? Explain your reasoning.
Practice Exercises
4. Translate these statements into English where the domain consists of all real numbers
(a) ∀x ∀y (((x ≥ 0) ∧ (y ≥ 0)) → (xy ≥ 0))
(b) ∀x ∀y ∃z (xy = z)
5. Use quantifiers and predicates with more than one variable to express these statements
(a) "Every student in this class has taken at least one math course".
(b) "There is a student in this class who has been in every room of at least one building on campus".
Summary
We have learnt the ideas of Predicate Logic.
1. Be familiar with definitions and precedence of quantifiers.
2. Learn to become proficient in the methods of Predicate Logic and in showing
logical equivalences.
3. Learn to translate statements given in plain English into the language of Predicate logic
and vice versa.
Next: Proofs.