Discrete First Lecture B 3

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 24

CS 211- Discrete Structures

11/18/2018
The Exclusive Or Operator

The binary exclusive-or operator “” (XOR)


combines two propositions to form their logical
“exclusive or” (exjunction?).

e.g. p = “I will earn an A in this course”


q = “I will drop this course”
p  q = “I will either earn an A in this course, or
I will drop it (but not both!)”
Exclusive-Or Truth Table

• Note that p  q means


p q pq
that p is true, or q is
true, but not both! F F F
• This operation is F T T
called exclusive or, T F T Note the
because it excludes the T T F difference
from OR
possibility that both p and q are true.
Natural Language is Ambiguous

Note that English “or” can be ambiguous regarding


the “both” case!
“Justin Bieber is a singer or
Justin Bieber is a writer” 
“John Cena is a man or
John Cena is a woman” 
Need context to disambiguate the meaning!
For this class, assume “OR” means inclusive.
The Implication Operator
hypothesis conclusion
The implication p  q states that p implies q.
p  q asserts that q is true on the condition that p
holds.

e.g. Let p = “You get 100% on the final”


q = “You will get an A”
p  q = “If you get 100% on the final, then
you will get an A”
Implication Truth Table

• p  q is false only when


p is true but q is not true. p q pq
• p  q does not say F F T
that p causes q! F T T The
only
• p  q does not require T F F False
that p or q are ever true! T T T case!

e.g. “(1 = 0)  pigs can fly” is TRUE!


Examples of Implications

• “If this lecture ever ends, then the sun will rise
tomorrow.” True or False?
• “If Tuesday is a day of the week, then I am a
penguin.” True or False?
• “If 1 + 1 = 6, then Donald is the president of
USA.” True or False?
P  Q has many forms in
English Language:
• "P implies Q”
• "If P, Q "
• "If P, then Q "
• "P only if Q "
• "P is sufficient for Q "
• "Q if P "
• "Q is necessary for P "
• "Q when P "
• "Q whenever P "
• "Q follows from P "
Logical Equivalence
• ¬ p  q is logically equivalent to p  q

p q ¬p  q pq
F F T T
F T T T
T F F F
T T T T
Converse, Inverse, Contrapositive
Some terminology, for an implication p  q :
• Its converse is: q p
• Its inverse is: ¬p ¬q
• Its contrapositive is: ¬ q  ¬ p

SAME
Example of Converse, Inverse,
Contrapositive
Write the converse, inverse and contrapositive of the
statement “if x ≠ 0, then John is a programmer”
• Its converse is: “if John is a programmer, then x ≠ 0”
• Its inverse is: “if x = 0, then John is not a
programmer”
• Its contrapositive is: “if John is not a programmer,
then x = 0”
Note: The negation operation (¬) is different from the
inverse operation.
Biconditional  Truth Table
In English:
• “p if and only if q "
• "If p, then q, and conversely"
• “p is sufficient and necessary for q "
• Written p  q p q pq
F F T
F T F
T F F
T T T
Translation English Sentences into
Logical Expressions

• If you are a computer science major or you are not


a freshman, then you can access the internet from
campus :
is translated to:
(c  f )  a
Nested Propositional Expressions

• Use parentheses to group sub-expressions:


“I just saw my old friend, and either he’s grown or
I’ve shrunk” = f  (g  s)
– (f  g)  s would mean something different
– f  g  s would be ambiguous
• By convention, “¬” takes precedence over both
“” and “”.
• order of precedence is (¬ ,  ,  ,  , )
– ¬s  f means (¬s)  f , not ¬ (s  f )
Precedence of Logical Operators

Operator Precedence
() 1
¬ 2
, 3
, 4
Left to Right 5
Logic and Bit Operations
• Find the bitwise AND, bitwise OR, and bitwise
XOR of the bit strings 0110110110 and
1100011101.
0110110110
Truth value Bit
1100011101 F 0
__________ T 1
Bitwise AND 0100010100
Bitwise OR 1110111111
Bitwise XOR 1010101011
Section 1.2: Propositional Equivalence,
Tautologies and Contradictions

• A tautology is a compound proposition that is


always true.
e.g. p  p  T
• A contradiction is a compound proposition that
is always false.
e.g. p  p  F
• Other compound propositions are contingencies.
e.g. p  q , p  q
Tautology

Example: p  p  q

p q pq ppq
F F F T
F T T T
T F T T
T T T T
Equivalence Laws 

• Identity: pTp , pFp


• Domination (Universal Bound Laws):
pTT , pFF
• Idempotent: ppp , pp
• 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)
• Negation Law: p ~p = T, p ~p = F.
More Equivalence Laws
• Distributive: p  (q  r)  (p  q)  (p  r)
p  (q  r)  (p  q)  (p  r)
• De Morgan’s:
(p  q)  p  q
(p  q)  p  q
• Trivial tautology/contradiction:
p  p  T , p  p  F Augustus
De Morgan
(1806-1871)

• (p  q)   p  q
• (p  q)  ( p  q)  p   q
Implications / Biconditional Rules

1. p  q  ¬p  q
2. ¬ (p  q)  p  ¬ q
3. p  q  ¬ q  ¬ p (contrapositive)
4. p  q  (p  q)  (q  p)
5. ¬ (p  q)  p  q
Proving Equivalence via Truth Tables

Example: Prove that p  q and (p  q) are


logically equivalent.

p q pq p q p  q (p  q)


F F F T T T F
F T T T F F T
T F T F T F T
T T T F F F T
Proving Equivalence using Logic
Laws
Example 1. Show that  (P  (P  Q)) and
(P  Q) are logically equivalent.

 (P  (P  Q))
  P   (P  Q) De Morgan
  P  ((P)  Q) De Morgan
  P  (P  Q ) Double negation
 ( P  P)  ( P  Q) Distributive
 F  ( P  Q) Negation
 ( P  Q) Identity
Proving Equivalence using Logic
Laws
Example 2: Show that  ( (P  Q)  Q) is a
contradiction.

 ( (P  Q)  Q)
  ( ( P  Q)  Q) Equivalence
  ( (P   Q)  Q) De Morgan
  ( (P   Q)  Q) Equivalence
  ( P  Q  Q) De Morgan
  ( P  T) Trivial Tautology
  (T) Domination
 F Contradiction

You might also like