56 1 / The Foundations: Logic and Proofs
Prolog answers queries using the facts and rules it is given. For example, using the facts
and rules listed, the query
?enrolled(kevin,math273)
produces the response
yes
because the fact enrolled(kevin, math273) was provided as input. The query
?enrolled(X,math273)
produces the response
kevin
kiko
To produce this response, Prolog determines all possible values of X for which
enrolled(X, math273) has been included as a Prolog fact. Similarly, to find all the professors
who are instructors in classes being taken by Juana, we use the query
?teaches(X,juana)
This query returns
patel
grossman ◂
Exercises
1. Let P(x) denote the statement “x ≤ 4.” What are these a) ∃xP(x) b) ∀xP(x)
truth values? c) ∃x ¬P(x) d) ∀x ¬P(x)
a) P(0) b) P(4) c) P(6) 6. Let N(x) be the statement “x has visited North Dakota,”
2. Let P(x) be the statement “The word x contains the where the domain consists of the students in your school.
letter a.” What are these truth values? Express each of these quantifications in English.
a) P(orange) b) P(lemon) a) ∃xN(x) b) ∀xN(x) c) ¬∃xN(x)
c) P(true) d) P(false) d) ∃x¬N(x) e) ¬∀xN(x) f ) ∀x¬N(x)
3. Let Q(x, y) denote the statement “x is the capital of y.” 7. Translate these statements into English, where C(x) is “x
What are these truth values? is a comedian” and F(x) is “x is funny” and the domain
a) Q(Denver, Colorado) consists of all people.
b) Q(Detroit, Michigan) a) ∀x(C(x) → F(x)) b) ∀x(C(x) ∧ F(x))
c) Q(Massachusetts, Boston) c) ∃x(C(x) → F(x)) d) ∃x(C(x) ∧ F(x))
d) Q(New York, New York) 8. Translate these statements into English, where R(x) is “x
4. State the value of x after the statement if P(x) then x := 1 is a rabbit” and H(x) is “x hops” and the domain consists
is executed, where P(x) is the statement “x > 1,” if the of all animals.
value of x when this statement is reached is a) ∀x(R(x) → H(x)) b) ∀x(R(x) ∧ H(x))
a) x = 0. b) x = 1. c) ∃x(R(x) → H(x)) d) ∃x(R(x) ∧ H(x))
c) x = 2. 9. Let P(x) be the statement “x can speak Russian” and let
5. Let P(x) be the statement “x spends more than five hours Q(x) be the statement “x knows the computer language
every weekday in class,” where the domain for x consists C++.” Express each of these sentences in terms of P(x),
of all students. Express each of these quantifications in Q(x), quantifiers, and logical connectives. The domain
English. for quantifiers consists of all students at your school.
1.4 Predicates and Quantifiers 57
a) There is a student at your school who can speak Rus- 18. Suppose that the domain of the propositional function
sian and who knows C++. P(x) consists of the integers −2, −1, 0, 1, and 2. Write
b) There is a student at your school who can speak Rus- out each of these propositions using disjunctions, con-
sian but who doesn’t know C++. junctions, and negations.
c) Every student at your school either can speak Russian a) ∃xP(x) b) ∀xP(x) c) ∃x¬P(x)
or knows C++. d) ∀x¬P(x) e) ¬∃xP(x) f ) ¬∀xP(x)
d) No student at your school can speak Russian or knows 19. Suppose that the domain of the propositional function
C++. P(x) consists of the integers 1, 2, 3, 4, and 5. Express
these statements without using quantifiers, instead using
10. Let C(x) be the statement “x has a cat,” let D(x) be the
only negations, disjunctions, and conjunctions.
statement “x has a dog,” and let F(x) be the statement “x
has a ferret.” Express each of these statements in terms a) ∃xP(x) b) ∀xP(x)
e) ∀x((x ≠ 3) → P(x)) ∨ ∃x¬P(x)
c) ¬∃xP(x) d) ¬∀xP(x)
of C(x), D(x), F(x), quantifiers, and logical connectives.
Let the domain consist of all students in your class.
20. Suppose that the domain of the propositional function
a) A student in your class has a cat, a dog, and a ferret. P(x) consists of −5, −3, −1, 1, 3, and 5. Express these
b) All students in your class have a cat, a dog, or a ferret. statements without using quantifiers, instead using only
c) Some student in your class has a cat and a ferret, but negations, disjunctions, and conjunctions.
not a dog.
c) ∀x((x ≠ 1) → P(x))
a) ∃xP(x) b) ∀xP(x)
d) No student in your class has a cat, a dog, and a ferret.
e) For each of the three animals, cats, dogs, and ferrets, d) ∃x((x ≥ 0) ∧ P(x))
e) ∃x(¬P(x)) ∧ ∀x((x < 0) → P(x))
there is a student in your class who has this animal as
a pet. 21. For each of these statements find a domain for which the
statement is true and a domain for which the statement is
11. Let P(x) be the statement “x = x2 .” If the domain consists
false.
of the integers, what are these truth values?
a) Everyone is studying discrete mathematics.
a) P(0) b) P(1) c) P(2) b) Everyone is older than 21 years.
d) P(−1) e) ∃xP(x) f ) ∀xP(x) c) Every two people have the same mother.
12. Let Q(x) be the statement “x + 1 > 2x.” If the domain d) No two different people have the same grandmother.
consists of all integers, what are these truth values? 22. For each of these statements find a domain for which the
a) Q(0) b) Q(−1) c) Q(1) statement is true and a domain for which the statement is
false.
d) ∃xQ(x) e) ∀xQ(x) f ) ∃x¬Q(x)
a) Everyone speaks Hindi.
g) ∀x¬Q(x) b) There is someone older than 21 years.
13. Determine the truth value of each of these statements if c) Every two people have the same first name.
the domain consists of all integers. d) Someone knows more than two other people.
a) ∀n(n + 1 > n) b) ∃n(2n = 3n) 23. Translate in two ways each of these statements into logi-
c) ∃n(n = −n) d) ∀n(3n ≤ 4n) cal expressions using predicates, quantifiers, and logical
connectives. First, let the domain consist of the students
14. Determine the truth value of each of these statements if
in your class and second, let it consist of all people.
the domain consists of all real numbers.
a) Someone in your class can speak Hindi.
a) ∃x(x3 = −1) b) ∃x(x4 < x2 ) b) Everyone in your class is friendly.
c) ∀x((−x)2 = x2 ) d) ∀x(2x > x) c) There is a person in your class who was not born in
15. Determine the truth value of each of these statements if California.
the domain for all variables consists of all integers. d) A student in your class has been in a movie.
a) ∀n(n2 ≥ 0)
e) No student in your class has taken a course in logic
b) ∃n(n2 = 2) programming.
c) ∀n(n ≥ n)
2 d) ∃n(n2 < 0) 24. Translate in two ways each of these statements into logi-
16. Determine the truth value of each of these statements cal expressions using predicates, quantifiers, and logical
if the domain of each variable consists of all real num- connectives. First, let the domain consist of the students
bers. in your class and second, let it consist of all people.
a) ∃x(x2 = 2) b) ∃x(x2 = −1) a) Everyone in your class has a cellular phone.
c) ∀x(x + 2 ≥ 1)
2 d) ∀x(x2 ≠ x) b) Somebody in your class has seen a foreign movie.
17. Suppose that the domain of the propositional function c) There is a person in your class who cannot swim.
d) All students in your class can solve quadratic equa-
P(x) consists of the integers 0, 1, 2, 3, and 4. Write out
tions.
each of these propositions using disjunctions, conjunc- e) Some student in your class does not want to be rich.
tions, and negations.
25. Translate each of these statements into logical expres-
a) ∃xP(x) b) ∀xP(x) c) ∃x¬P(x) sions using predicates, quantifiers, and logical connec-
d) ∀x¬P(x) e) ¬∃xP(x) f ) ¬∀xP(x) tives.
58 1 / The Foundations: Logic and Proofs
a) No one is perfect. a) ∃x P(x, 3) b) ∀y P(1, y)
b) Not everyone is perfect. c) ∃y¬P(2, y) d) ∀x ¬P(x, 2)
31. Suppose that the domain of Q(x, y, z) consists of triples
c) All your friends are perfect.
x, y, z, where x = 0, 1, or 2, y = 0 or 1, and z = 0 or 1.
d) At least one of your friends is perfect. Write out these propositions using disjunctions and con-
e) Everyone is your friend and is perfect. junctions.
a) ∀yQ(0, y, 0) b) ∃xQ(x, 1, 1)
f ) Not everybody is your friend or someone is not per-
fect. c) ∃z¬Q(0, 0, z) d) ∃x¬Q(x, 0, 1)
26. Translate each of these statements into logical expres- 32. Express each of these statements using quantifiers. Then
sions in three different ways by varying the domain and form the negation of the statement so that no negation is
by using predicates with one and with two variables. to the left of a quantifier. Next, express the negation in
simple English. (Do not simply use the phrase “It is not
a) Someone in your school has visited Uzbekistan. the case that.”)
b) Everyone in your class has studied calculus and C++. a) All dogs have fleas.
c) No one in your school owns both a bicycle and a mo- b) There is a horse that can add.
torcycle. c) Every koala can climb.
d) No monkey can speak French.
d) There is a person in your school who is not happy.
e) There exists a pig that can swim and catch fish.
e) Everyone in your school was born in the twentieth 33. Express each of these statements using quantifiers. Then
century. form the negation of the statement, so that no negation
27. Translate each of these statements into logical expres- is to the left of a quantifier. Next, express the negation in
sions in three different ways by varying the domain and simple English. (Do not simply use the phrase “It is not
by using predicates with one and with two variables. the case that.”)
a) A student in your school has lived in Vietnam. a) Some old dogs can learn new tricks.
b) There is a student in your school who cannot speak b) No rabbit knows calculus.
Hindi. c) Every bird can fly.
d) There is no dog that can talk.
c) A student in your school knows Java, Prolog, and
e) There is no one in this class who knows French and
C++.
Russian.
d) Everyone in your class enjoys Thai food. 34. Express the negation of these propositions using quanti-
e) Someone in your class does not play hockey. fiers, and then express the negation in English.
28. Translate each of these statements into logical expres- a) Some drivers do not obey the speed limit.
sions using predicates, quantifiers, and logical connec- b) All Swedish movies are serious.
tives. c) No one can keep a secret.
a) Something is not in the correct place. d) There is someone in this class who does not have a
good attitude.
b) All tools are in the correct place and are in excellent
condition. 35. Express the negation of each of these statements in terms
of quantifiers without using the negation symbol.
c) Everything is in the correct place and in excellent a) ∀x(x > 1)
condition. b) ∀x(x ≤ 2)
d) Nothing is in the correct place and is in excellent con- c) ∃x(x ≥ 4)
dition. d) ∃x(x < 0)
e) One of your tools is not in the correct place, but it is e) ∀x((x < −1) ∨ (x > 2))
in excellent condition. f ) ∃x((x < 4) ∨ (x > 7))
29. Express each of these statements using logical operators, 36. Express the negation of each of these statements in terms
predicates, and quantifiers. of quantifiers without using the negation symbol.
a) Some propositions are tautologies. a) ∀x(−2 < x < 3)
b) ∀x(0 ≤ x < 5)
b) The negation of a contradiction is a tautology. c) ∃x(−4 ≤ x ≤ 1)
c) The disjunction of two contingencies can be a tautol- d) ∃x(−5 < x < −1)
ogy. 37. Find a counterexample, if possible, to these universally
d) The conjunction of two tautologies is a tautology. quantified statements, where the domain for all variables
30. Suppose the domain of the propositional function P(x, y) consists of all integers.
consists of pairs x and y, where x is 1, 2, or 3 and y is 1, 2, a) ∀x(x2 ≥ x)
or 3. Write out these propositions using disjunctions and b) ∀x(x > 0 ∨ x < 0)
conjunctions. c) ∀x(x = 1)