Module 2 Class Presentation CS5002
Module 2 Class Presentation CS5002
Discrete Structures
• Please put away / silence your phone, and have only GoogleDoc, this Powerpoint,
and/or Teams running on your laptop
• Be sure your name card is in place (your instructor will always be fooled)
• If you can’t figure out an answer, just present some of your work on that
problem
• If you mess up one problem you can still get 92 out of 100
• If you mess up all the Individual problems you can still get 76 out of 100
• So you can spend your time and energy better than getting stuck on a
problem
Some Tricks For Understanding New
Stuff
Try looking at specific examples that are easy to understand
not (P or Q) = (not P) and (not Q)
• This is one of DeMorgan’s laws
• Then, following the Study Guide 2, you had some stuff to study
• And then you should have done your Quiz 2 yourself
• Quiz 2 was due at the start of class
Review of Problem Set 1
• IP Address
• Overflow
• Weights
• Day of week
• Nim
IP Address
• Simply convert between binary, decimal, and hex
• In Overflow, the sign bits of both operands are the same but the result has a
different value
• With three weights there are 27 possible combinations so you can’t measure
all values of N from 1 to 40
Day of Week
• Compute difference in # days from what you know (January 1, 2023 = Sunday)
• Take the difference mod-7, that tells how many days past Sunday
• You know the number in each month, so within the year you can add up the
number of days in the intervening months
• If the Nim Sum is 0 at the end of your turn you won or can force a win
• If the Nim Sum is 0 at the start of your turn you have to change it to non-0
• If the Nim Sum is not 0 at the start of your turn you can win by changing it to 0
• Pick a pile with a 1 in the same bit that the Nim Sum has its leftmost 1
• Remove stones to make that pile equal to (current Nim Sum) XOR (current pile value)
Quiz 2 In Groups
• Do you have any questions about the study materials and Quiz 2?
• How useful were the additional links?
• Now let’s arrange into groups and each group do the same Quiz 2
• Put your answers into today’s GoogleDoc
• Today’s Groups:
B [(not A) and C]
= not {B and not [(not A) and C]} definition of
= (not B) or [(not A) and C] DeMorgan’s Law
= (not B) or not [A or (not C)] DeMorgan’s Law again
• FOR ALL x means that no matter what value x has, the following is true
• x P(x) means “for all possible values of x, P of x is true”
• x: x = x is the basic identity law
• p: (p or not p) = True
• THERE EXISTS x means that somewhere there is an x that makes this true
• x P(x) means “there is at least one value of x that makes P of x true”
• x: x has four legs probably not me or you, but something somewhere
Substitution Rule
p = q means that wherever you see p, you can p q p=q
replace it with q T T T
T F F
In symbols: F T F
p = q F: F(p) = F(q) F F T
(p = q) = F: F(p) = F(q)
“p equals q means that for all predicates F, F of p has the same value as F of q”
Involution
not (not p) = p
Idempotent
(p and p) = p (p or p) = p
Negation
[p and (not p)] = F [p or (not p)] = T
More Basic Laws
p not P p and T p or F p and F p or T
T F T T F T
F T F F F T
Identity
(p and T) = p (p or F) = p
Null
(p and F) = F (p or T) = T
Almost As Basic Laws
Commutative
change order (p and q) = (q and p) (p or q) = (q or p)
Associative
reorder () [(p and q) and r] = [p and (q and r)]
[(p or q) or r] = [p or (q or r)]
Distributive
split into cases [p and (q or r)] = [(p and q) or (p and r)]
[p or (q and r)] = [(p or q) and (p or r)]
Example of Truth Table for Distributive
Lawp q r q or r p and p and q p and r (p and q) or
(q or r) (p and r)
T T T
T T F
T F T
T F F
F T T
F T F
F F T
F F F
Practically speaking: You can replace “and” with “or” (or “or” with “and”) by
negating the whole thing, and negating each of the operands
DeMorgan’s Laws By Truth Table
not (p and q) = (not p) or (not q)
I like this “positive” way of stating the laws because it is easier to substitute:
To change and to or:
Negate each of the parts
Then negate the whole thing
Lukasiewicz Notation (loo-kass-ee-
vitch)
Use upper-case letters for the operators:
not = N and = K or = A =C ==E xor = X
(p and q) p
= not [(p and q) and (not p) by definition of
= [not (p and q)] or p by DeMorgan’s Law
= (not p) or (not q) or p by DeMorgan’s Law
= p or (not p) or (not q) by Commutative Law
= T or (not q) by Negation Law
=T by Null Law
So the original statement is always true. This is called a Tautology
Example of Proving Detachment (Modus
Ponens)
[(p q) and p] q
We will use the definition of : p q = not [p and (not q)]
[(p q) and p] q
= not {[(p q) and p] and (not q)} by definition of
= not [(p q) and p] or q by DeMorgan’s Law
= [not (p q)] or (not p) or q by DeMorgan’s Law
= [p and (not q)] or (not p) or q by definition of
= [p or (not p) or q] and [(not q) or (not p) or q] by Distributive Law
= (T or q) and [T or (not p)]
= T and T = T so the original statement above is a Tautology
Disjunctive Normal Form
• You can rewrite any logical expression as the OR of a bunch of AND statements
• This is called Disjunctive Normal Form (DNF)
• We can go from the truth table directly to DNF using the Ts:
p q s
T T T
s= (p and q) or [(not p) and (not q)]
T F F
F T F
this is DNF
F F T
Conjunctive Normal Form
• You can rewrite any logical expression as the AND of a bunch of OR statements
• This is called Conjunctive Normal Form (CNF)
p q s
(not s) = [p and (not q)] or [(not p) and q]
T T T
T F F s = not {[p and (not q)] or [(not p) and q]}
F T F s = {not [p and (not q)]} and {not [(not p) and q]}
F F T s = [(not p) or q] and [p or (not q)] is CNF
Logic Circuit Diagrams
• Gates are bits of circuit that implement logical operations on signals
• Electrical Engineers have standard symbols for gates
Handout on Symbolic Logic
You will find all of these laws on this handout for class, in Canvas Module 2:
A very special island is inhabited only by knights and knaves. Knights always
tell the truth, and knaves always lie.
You meet four inhabitants: Bart, Dave, Rex and Zoey. Bart tells you that Rex
and Dave are both knights or both knaves. Dave tells you that Zoey is a knave.
Rex claims, “Bart is a knave.” Zoey claims, “Rex is a knight and Dave is a
knave.”
Can you determine who is a knight and who is a knave?
A Sneaky Way To Solve This Puzzle
• Notice that Bart and Zoey contradict each other, so both cannot be Truthies.
• Bart says that Rex and Dave are both Truthies or both Falsies
• Zoey claims “Rex is a Truthie and Dave is a Falsie”
• Study Guide 3 is what you need to learn for the next class
• Quiz 3 is based on the study materials; due in Canvas before next class