17 Logic Operators Puzzles
17 Logic Operators Puzzles
3
Puzzle (an example for conversion from
English to Symbolic logic)
5
Conversion
1. Either Kevin or Heather or both are chatting.
2. Either Randy or Paul but not both are chatting.
3. If Abby is chatting, so is Randy.
4. Paul and Kevin are either both chatting, or neither is.
5. If Heather is chatting than so are Abby and Kevin.
In symbols:
(1) K V H
(2) R P
(3) A R
(4) P K
(5) H (A K)
6
How to proceed:
• Observe that assuming hypothesis of (5) leads
to a strong (informative) conclusion
• We start with (5):
In symbols:
(1) K V H
(2) R P
(3) A R
(4) P K
(5) H (A K)
7
• Assume H is true
• (6) H
Thus we have determined that Kevin and Paul are chatting, but Heather,
Abbey and Randy are not chatting.
9
Note
• Only a contradiction tell that initial hypothesis
was wrong.
• In case of absence of a contradiction, we can
not conclude any useful information.
10
Precedence of Logical Operators (1)
11
Precedence of Logical Operators (2)
12
Usefulness of Logic (1)
13
Usefulness of Logic (2)
14
Bitwise Operations
• Computers represent information as bits (binary digits)
• A bit string is a sequence of bits
• The length of the string is the number of bits in the string
• Logical connectives can be applied to bit strings of equal
length
• Example 0110 1010 1101
0101 0010 1111
_____________
Bitwise OR 0111 1010 1111
Bitwise AND ...
Bitwise XOR …
15
Logic in AI
• What is SAT? SAT is the problem of determining
whether or not a sentence in propositional logic
(PL) is satisfiable.
– Given: a PL sentence
– Question: Determine whether or not it is satisfiable
• Characterizing SAT as an NP-complete problem
(complexity class) is at the foundation of
Theoretical Computer Science.
• MiniSat @ http://minisat.se/
16
17
Questions & Ideas?
Thank You!
18
Practice Puzzle 1
A detective has interviewed four witnesses to a crime.
From the stories of the witnesses the detective has con-
cluded that if the butler is telling the truth then so is the
cook; the cook and the gardener cannot both be telling the
truth; the gardener and the handyman are not both lying;
and if the handyman is telling the truth then the cook is
lying. For each of the four witnesses, can the detective de-
termine whether that person is telling the truth or lying?
Explain your reasoning.
19
Practice Puzzle 2
Four friends have been identified as suspects for an unau-
thorized access into a computer system. They have made
statements to the investigating authorities. Alice said
“Carlos did it.” John said “I did not do it.” Carlos said
“Diana did it.” Diana said “Carlos lied when he said that
I did it.”
a) If the authorities also know that exactly one of the
four suspects is telling the truth, who did it? Explain
your reasoning.
b) If the authorities also know that exactly one is lying,
who did it? Explain your reasoning.
20