You are on page 1of 49

2.

5 Applications of Propositional Logic

The propositional logic can be applied to the followings


fields:

• Translating English to Propositional Logic.

• System Specifications.

• Boolean Searching.

• Logic Puzzles.

• Logic Circuits.
1
2.5.1 Translating English to Propositional Logic

The steps required to convert an English sentence to a


statement in propositional logic:
1- Identify atomic propositions and represent using
propositional variables.
2- Determine appropriate logical connectives.

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

System and Software engineers take requirements in


English and express them in a precise specification
language based on logic.

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?

• “The diagnostic message is stored in the buffer or it


is retransmitted.”

• “The diagnostic message is not stored in the buffer.”

• “If the diagnostic message is stored in the buffer,


then it is retransmitted.”
5
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.
When p is false and q is true :
• p∨q T
• ¬p T
• p → q. T
So the specification is consistent because all three
statements are true.
6
Example:
Are these specifications consistent?

• “The diagnostic message is stored in the buffer or it


is retransmitted.”

• “The diagnostic message is not stored in the buffer.”

• “If the diagnostic message is stored in the buffer,


then it is retransmitted.”

• “The diagnostic message is not retransmitted.”

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

Logical connectives are used extensively in searches of


large collections of information, such as indexes of Web
pages. Because these searches employ techniques from
propositional logic, they are called Boolean searches.

In Boolean searches, the connective AND is used to


match records that contain both of two search terms,
the connective OR is used to match one or both of two
search terms, and the connective NOT (sometimes
written as AND NOT ) is used to exclude a particular
search term.

Careful planning of how logical connectives are used is


often required when Boolean searches are used to locate
information of potential interest.
9
Example:
Use Boolean searching to find Web pages about
universities in New Mexico.

Solution:
NEW AND MEXICO AND UNIVERSITIES.
The results of this search will include those pages that
contain the three words NEW, MEXICO, and
UNIVERSITIES.

(MEXICO AND UNIVERSITIES) NOT NEW


The results of this search include pages that contain
both the words MEXICO and UNIVERSITIES but do not
contain the word NEW.
10
2.5.4 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.

Computer programs designed to carry out logical


reasoning often use well-known logic puzzles to illustrate
their capabilities.

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.

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.

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

Propositional logic can be applied to the design of


computer hardware.

A logic circuit (or digital circuit) receives input signals


p1, p2,...,pn, each a bit [either 0 (off) or 1 (on)], and
produces output signals s1, s2,...,sn, each a bit.

The three basic logic gates are:

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

A tautology is a proposition which is always true.


Example: p ∨¬p

A contradiction is a proposition which is always false.


Example: p ∧¬p

A contingency is a proposition which is neither a


tautology nor a contradiction, such as p.

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

Compound propositions that have the same truth values in


all possible cases are called logically equivalent.

Two compound propositions p and q are called logically


equivalent if p↔q is a tautology.

The notation p ≡ q or p ⇔ q denotes that p and q are


logically equivalent.

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

Consequently ¬(p ∨ (¬p ∧ q)) and ¬p ∧ ¬q are logically


equivalent.
29
Example:
Simplify (p ∨ q) ∧ ¬p by developing a series of logical
equivalences.

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

An argument in propositional logic is a sequence of


propositions. All but the final proposition are called
premises. The last statement is the conclusion.

The argument is valid if the premises imply the


conclusion.
Argument is valid

(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”.

So the argument is valid because the premises imply the


conclusion.

34
2.9 Argument Form in Propositional Logic

An argument form in propositional logic is a sequence of


compound propositions involving propositional variables.

An argument form is valid when the conclusion is true if


the premises are all true.

The argument form with premises p1, p2,...,pn and


conclusion q is valid, when (p1 ∧ p2 ∧···∧ pn) → q is a
tautology.
Argument form is valid

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

The validity of some relatively simple argument forms,


called rules of inference.

These rules of inference can be used as building blocks to


construct more complicated valid argument forms.

The most important rules of inference in propositional


logic are listed in table below:

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

This is an argument that uses the addition rule.

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

This argument uses the simplification rule.

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:

“If it is snowing, then I will study discrete math.”


“It is snowing.”

“Therefore , I will study discrete math.”

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:

“I will study discrete math or I will study English


literature.”
“I will not study discrete math.”

“Therefore , I will study English literature.”


43
2.11 Using Rules of Inference to Build Arguments

When there are many premises, several rules of


inference are often needed to show that an argument is
valid.
Example:
With these hypotheses:
“It is not sunny this afternoon and it is colder than
yesterday.”
“We will go swimming only if it is sunny.”
“If we do not go swimming, then we will take a canoe trip.”
“If we take a canoe trip, then we will be home by sunset.”
Using the inference rules, construct a valid argument for
the conclusion: “We will be home by sunset.”

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)

A truth table can be used to show that whenever each of


the four hypotheses is true, the conclusion is also true.

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.

2- Translation into propositional logic:


p→q
¬p → r Hypotheses
r→s
¬q → s Conclusion

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

You might also like