Week 2
Week 2
Lec # 02
1
Propositional Logic: Review
Compound Propositions
2
Computer Representation of True and False
We need to encode two values True and False:
• Computers represents data and programs using 0s and 1s
• Logical truth values – True and False
• A bit is sufficient to represent two possible values:
– 0 (False) or 1(True)
Bitwise Operations
• T and F replaced with 1 and 0
p q pq pq
1 1 1 1
1 0 1 0
0 1 1 0
0 0 0 0
p ¬p
1 0
0 1
3
Bitwise Operations
• Examples:
4
Translation
Assume a sentence:
If you are older than 13 or you are with your parents then you can
attend a PG-13 movie.
Parse:
• If ( you are older than 13 or you are with your parents ) then
( you can attend a PG-13 movie)
• Translation: A B C
Translation
• General rule for translation.
• Look for patterns corresponding to logical connectives in the
sentence and use them to define elementary propositions.
• Example:
You can have free coffee if you are senior citizen and it is a Tuesday
5
Translation
• General rule for translation.
• Look for patterns corresponding to logical connectives in the
sentence and use them to define elementary propositions.
• Example:
You can have free coffee if you are senior citizen and it is a Tuesday
6
Translation
• General rule for translation.
• Look for patterns corresponding to logical connectives in the
sentence and use them to define elementary propositions.
• Example:
You can have free coffee if you are senior citizen and it is a Tuesday
a b c
Translation
• General rule for translation .
• Look for patterns corresponding to logical connectives in the
sentence and use them to define elementary propositions.
• Example:
You can have free coffee if you are senior citizen and it is a Tuesday
a b c
bca
7
Translation
• Assume two elementary statements:
– p: you drive over 65 mph ; q: you get a speeding ticket
• Translate each of these sentences to logic
– you do not drive over 65 mph. (¬p)
– you drive over 65 mph, but you don't get a
speeding ticket. (p ¬q)
– you will get a speeding ticket if you drive over 65 mph.
(p q)
– if you do not drive over 65 mph then you will not get a
speeding ticket.(¬p ¬q)
– driving over 65 mph is sufficient for getting a
speeding ticket. (p q)
– you get a speeding ticket, but you do not drive over
65 mph. (q ¬p)
Application: Inference
Assume we know the following sentences are true:
If you are older than 13 or you are with your parents then you
can attend a PG-13 movie. You are older than 13.
Translation:
• If ( you are older than 13 or you are with your parents ) then
( you can attend a PG-13 movie) . (You are older than 13).
– A= you are older than 13
– B= you are with your parents
– C=you can attend a PG-13 movie
• (A B C), A
• (A B C) A is true
• With the help of the logic we can infer the following
statement (proposition):
– You can attend a PG-13 movie or C is True
8
Application: Inference
The field of Artificial Intelligence:
• Builds programs that act intelligently
• Programs often rely on symbolic manipulations
Expert systems:
• Encode knowledge about the world in logic
• Support inferences where new facts are inferred from existing
facts following the semantics of logic
Theorem provers:
• Encode existing knowledge (e.g. about math) using logic
• Show that some hypothesis is true
Example: MYCIN
• MYCIN: an expert system for diagnosis of bacterial infections
• It represents
– Facts about a specific patient case
– Rules describing relations between entities in the bacterial
infection domain
If 1. The stain of the organism is gram-positive, and
2. The morphology of the organism is coccus, and
3. The growth conformation of the organism is chains
Then the identity of the organism is streptococcus
• Inferences:
– manipulates the facts and known relations to answer
diagnostic queries (consistent with findings and rules)
9
Tautology and Contradiction
• Some propositions are interesting since their values in the truth
table are always the same
Definitions:
• A compound proposition that is always true for all possible
truth values of the propositions is called a tautology.
• A compound proposition that is always false is called a
contradiction.
• A proposition that is neither a tautology nor contradiction is
called a contingency.
• A statement that can be either true or false depending on
the truth values of its variables is called a contingency.
p ¬p p ¬p
T F T
F T T
Example: p ¬p is a Contradiction.
p ¬p p ¬p
T F F
F T F
10
Equivalence
• We have seen that some of the propositions are equivalent.
Their truth values in the truth table are the same.
• Example: p q is equivalent to ¬q ¬p (contrapositive)
p q pq ¬q ¬p
T T T T
T F F F
F T T T
F F T T
Logical Equivalence
Definition: The propositions p and q are called logically
equivalent if p q is a tautology (alternately, if they have the
same truth table). The notation p <=> q denotes p and q are
logically equivalent.
11
Logical Equivalence
Logical Equivalence
Example of important equivalences
• DeMorgan's Laws:
• 1) ¬( p q ) <=> ¬p ¬q
• 2) ¬( p q ) <=> ¬p ¬q
12
Logical Equivalence
Example of important equivalences
• DeMorgan's Laws:
• 1) ¬( p q ) <=> ¬p ¬q
• 2) ¬( p q ) <=> ¬p ¬q
Logical Equivalence
Example of important equivalences
• DeMorgan's Laws:
• 1) ¬( p q ) <=> ¬p ¬q
• 2) ¬( p q ) <=> ¬p ¬q
13
Logical Equivalence
Example of important equivalences
• DeMorgan's Laws:
• 1) ¬( p q ) <=> ¬p ¬q
• 2) ¬( p q ) <=> ¬p ¬q
• Domination
– p T <=> T
– p F <=> F
• Idempotent
– p p <=> p
– p p <=> p
14
Important Logical Equivalences
• Double negation
– ¬(¬p) <=> p
• Commutative
– p q <=> q p
– p q <=> q p
• Associative
– (p q) r <=> p (q r)
– (p q) r <=> p (q r)
• De Morgan
– ¬( p q ) <=> ¬p ¬q
–¬ ( p q ) <=> ¬p ¬q
15
Using Logical Equivalences
• Equivalences can be used in proofs. A proposition or its part
can be transformed using equivalences and some conclusion
can be reached.
p q pq (p q)p
T T T T
T F F T
F T F T
F F F T
16
Using Logical Equivalences
• Equivalences can be used in proofs. A proposition or its part
can be transformed using equivalences and some conclusion
can be reached.
17
Using logical equivalences
• Equivalences can be used in proofs. A proposition or its part
can be transformed using equivalences and some conclusion
can be reached.
18
Using logical equivalences
• Equivalences can be used in proofs. A proposition or its part
can be transformed using equivalences and some conclusion
can be reached.
19