Professional Documents
Culture Documents
• System Specifications.
• Boolean Searching.
• Logic Puzzles.
• Logic Circuits.
1
2.5.1 Translating English to Propositional Logic
Example:
Translate the following sentence into propositional logic:
“If I go to Harry’s or to the country, I will not go
shopping.”
Solution:
p: I go to Harry’s
q: I go to the country. If p or q then not r.
r: I will go shopping.
2
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:
a: You can access the internet from campus.
c: You are a computer science major.
f: You are a freshman.
a→(c ∨ ¬f)
3
2.5.2 System Specifications
Example:
Express the following in propositional logic:
“The automated reply cannot be sent when the file
system is full”
Solution:
One possible solution:
Let p:The automated reply can be sent.
q: The file system is full.
q→ ¬ p
4
A list of propositions is consistent if it is possible to
assign truth values to the proposition variables so that
each proposition is true.
Example:
Are these specifications consistent?
7
Solution:
Let
p: “The diagnostic message is stored in the buffer.”
q: “The diagnostic message is retransmitted.”
The specification can be written as:
• p∨q
• ¬p
• p → q.
• ¬q
When p is false and q is true :
• p∨q T
• ¬p T
• p → q. T
So the specification is not consistent
• ¬q F because all four statements are not true.
8
2.5.3 Boolean Searching
Solution:
NEW AND MEXICO AND UNIVERSITIES.
The results of this search will include those pages that
contain the three words NEW, MEXICO, and
UNIVERSITIES.
11
Example:
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.
12
Solution:
Let s: the son has a muddy forehead
d: the daughter has a muddy forehead.
13
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.
14
2.5.5 Logic Circuits
The inverter (NOT gate)takes an input bit and produces the negation of that bit.
The OR gate takes two input bits and produces the value equivalent to the disjunction of the two bits.
The AND gate takes two input bits and produces the value equivalent to the conjunction of the two bits.
15
More complicated digital circuits can be constructed by
combining these basic circuits to produce the desired
output given the input signals by building a circuit for
each piece of the output expression and then combining
them. For example:
16
Example:
Determine the output for the combinatorial circuit in the
following figure:
Solution:
17
Example:
Build a digital circuit that produces the output (p ∨ ¬r) ∧
(¬p ∨ (q ∨ ¬r)) when given input bits p, q, and r
Solution:
18
2.6 Tautologies, Contradictions, and Contingencies
P ¬p p ∨¬p p ∧¬p
T F T F
F T T F
19
Example:
Show that (¬p ∧ (p ∨ q))→q is a tautology by using truth
tables.
Solution:
20
Example:
Show that (p ∧ q) ∧ ¬(p ∨ q) is a contradiction by using
truth tables.
Solution:
21
2.7 Logical Equivalences
Note:
The symbols ≡ and ⬄ are not logical connectives.
22
Example:
Show that ¬p ∨ q is equivalent to p → q by using truth
tables.
Solution:
p q ¬p ¬p ∨ q p→ q
T T F T T
T F F F F
F T T T T
F F T T T
23
Example:
Show that ¬(p ∨ q) and ¬p ∧ ¬q are logically equivalent
by using truth tables.
Solution:
p q ¬p ¬q (p ∨ q) ¬ (p ∨ q) ¬p∧¬q
T T F F T F F
T F F T T F F
F T T F T F F
F F T T F T T
24
Some important logical equivalences can be shown in the
table below:
25
26
Some logical equivalences involving conditional
statements:
27
Some logical equivalences involving biconditional
statements:
28
Example:
Show that ¬(p ∨ (¬p ∧ q)) and ¬p ∧ ¬q are logically equivalent
by developing a series of logical equivalences.
Solution:
¬(p ∨ (¬p ∧ q)) ≡ ¬p ∧ ¬(¬p ∧ q) by the second De Morgan law
≡ ¬p ∧ [¬(¬p) ∨ ¬q] by the first De Morgan law
≡ ¬p ∧ (p ∨ ¬q) by the double negation law
≡ (¬p ∧ p) ∨ (¬p ∧ ¬q) by the second distributive law
≡ F ∨ (¬p ∧ ¬q) because ¬p ∧ p ≡ F
≡ (¬p ∧ ¬q) ∨ F by the commutative law for disjunction
≡ ¬p ∧ ¬q by the identity law for F
Solution:
((p ∨ q) ∧ ¬p) ≡ ¬p ∧ (p ∨ q) by commutative law
≡ (¬p ∧ p) ∨ (¬p ∧ q) by distributive law
≡ (p ∧ ¬p) ∨ (¬p ∧ q) by commutative law
≡ F ∨ (¬p ∧ q) because ¬p ∧ p ≡ F
≡ ¬p ∧ q by Identity law
30
Example:
Simplify (p ∨ (p ∧ q)) by developing a series of logical
equivalences.
Solution:
(p ∨ (p ∧ q)) ≡ (p ∧ T) ∨ (p ∧ q) by Identity law
≡ p ∧ (T ∨ q) by distributive law
≡p∧T by Identity law
≡P by Identity law
31
Example:
Simplify (¬(p ∨ q) ∨ (¬p ∧ q)) by developing a series of
logical equivalences.
Solution:
¬(p ∨ q) ∨ (¬p ∧ q) ≡ (¬p ∧ ¬q) ∨ (¬p ∧ q) by Demorgan’s law
≡ ¬p ∧ (¬q ∨ q) by Distributive law
≡ ¬p ∧ T by Negation law
≡ ¬P by Identity law
32
2.8 Arguments in Propositional Logic
(sequence of propositions)
Note: Premises
The argument is valid
when its form (argument Implication
form) is valid.
Last statement
conclusion
33
Example:
Determine whether this is a valid argument:
“If you have a current password, then you can log onto the network.”
“You have a current password.”
Therefore,
“You can log onto the network.”
Solution:
The premises are:
“If you have a current password, then you can log onto
the network” and “You have a current password”.
The conclusion is: “You can log onto the network”.
34
2.9 Argument Form in Propositional Logic
Compound Propositions
(p1 ∧ p2 ∧…pn)
Premises T
Implication →
Last statement
Conclusion T
35
Example:
Determine the argument form for the following
statements and indicate the validity of it.
“If you have a current password, then you can log onto the network.”
“You have a current password.”
Therefore,
“You can log onto the network.”
Solution:
Let P: You have a current password.
q: You can log onto the network.
p→q
p ((p → q) ∧ p) → q is a tautology
∴q
Use Truth table to check it.
36
2.10 Rules of Inference for Propositional Logic
37
38
Example:
State which rule of inference is the basis of the
following argument: “It is below freezing now. Therefore,
it is either below freezing or raining now.”
Solution:
Let p: It is below freezing now.
q: It is raining now.
Then the argument form is:
p
∴p∨q
39
Example:
State which rule of inference is the basis of the
following argument: “It is below freezing and raining now.
Therefore, it is below freezing now.”
Solution:
Let p: It is below freezing now.
q: It is raining now.
Then the argument form is:
p∧q
∴p
40
Example:
State which rule of inference is used in the argument:
If it rains today, then we will not have a barbecue today.
If we do not have a barbecue today, then we will have a
barbecue tomorrow. Therefore, if it rains today, then we
will have a barbecue tomorrow.
Solution:
Let p: It is raining today.
q: We will not have a barbecue today.
r: We will have a barbecue tomorrow.
Then the argument form is:
p→q
q→r
∴p→r
This argument is a hypothetical syllogism.
41
Example:
If p be proposition “It is snowing.” and q be proposition
“I will study discrete math.”. Use Modus Ponens to
create the argument.
Solution:
Modus Ponens rule of inference is: so the
argument is:
42
Example:
If p be proposition “I will study discrete math.” and q be
proposition “I will study English literature.”. Use
Disjunctive Syllogism to create the argument.
Solution:
Disjunctive Syllogism rule of inference is: so
the argument is:
44
Solution:
1- Choose propositional variables:
Let p: It is sunny this afternoon.
q: It is colder than yesterday.
r: We will go swimming.
s: We will take a canoe trip.
t: We will be home by sunset.
2- Translation into propositional logic:
¬p ∧ q,
r → p,
Hypotheses
¬r → s,
s → t.
t Conclusion
45
3- Construct the Valid Argument:
Step Reason
1. ¬p ∧ q Premise
2. ¬p Simplification using (1)
3. r → p Premise
4. ¬r Modus tollens using (2) and (3)
5. ¬r → s Premise
6. s Modus ponens using (4) and (5)
7. s → t Premise
8. t Modus ponens using (6) and (7)
46
Example:
With these hypotheses:
“If you send me an e-mail message, then I will finish
writing the program.”
“If you do not send me an e-mail message, then I will go
to sleep early.”
“If I go to sleep early, then I will wake up feeling
refreshed.”
Using the inference rules, construct a valid argument
for the conclusion:
“If I do not finish writing the program, then I will wake
up feeling refreshed.”
47
Solution:
1- Choose propositional variables:
Let p: You send me an e-mail message.
q: I will finish writing the program.
r: I will go to sleep early.
s: I will wake up feeling refreshed.
48
3- Construct the Valid Argument:
Step Reason
1. p → q Premise
2. ¬q → ¬p Contrapositive of (1)
3. ¬p → r Premise
4. ¬q → r Hypothetical syllogism using (2) and (3)
5. r → s Premise
6. ¬q → s Hypothetical syllogism using (4) and (5)
49