Title: Intelligent Systems, part III Intelligent Agents and Knowledge Representation
1Intelligent Systems, part IIIIntelligent Agents
and Knowledge Representation
- Lecture 1 Logic and Proofs
- Leon van der Torre
2Slides
- Slides can be found on the internet
- These slides are based on MIT open courseware,
by S. Devadas and E. Lehmann
3What do these sentence mean?
- You may have cake or you may have ice cream.
- If pigs can fly, then you can understand the
Chernoff bound. - If you can solve any problem we come up with,
then you get a 20 for the course. - Every American has a dream.
4Propositions and Boolean variables
- Proposition is a statement that is true or false.
- NotWhats a surjection, again? or Learn
logarithms! - All Greeks are human, All humans are mortal.
- 2Â Â 3Â 5
- a4Â b4Â Â c4Â Â d4Â has no solution where a, b, c
are positive integers. (Euler) - Every even integer greater than 2 is the sum of
two primes. (Goldbach)
5Combining propositions NOT
- If all humans are mortal and all Greeks are
human, then all Greeks are mortal. - Truth tables if P denotes an arbitrary
proposition, then the validity of the proposition
not P is defined by -
-
- First row when P is true (T), not P is false
(F). - Second line when P is false, not P is true.
6Combining propositions AND, OR
- True / false for each possible setting of
variables. - If a mathematician says You may have cake or
your may have ice cream, then you can have both.
7Combining propositions Implies
- If Goldbachs Conjecture is true, then x 0Â for
every real number x. - If pigs fly, then you can understand the
Chernoff bound. - If the moon is white, then the moon is made of
white cheddar. - An implication is true when the if-part is false
or the then-part is true.
8Combining propositions If and only if
- P if and only if Q P and Q logically
equivalent - That is, either both are true or both are false.
- x2 - 4Â 0Â if and only if x 2
- Doesnt arise in ordinary speech, abbreviated
iff.
9Propositional Logic in Computer Programs
- if ( x gt 0 (x lt 0 y gt 100) )
- (further instructions)
or, and. - A or ((not A) and B)Â for A
x gt0, B y gt 100. - if ( x gt 0 y gt 100 )
- (further instructions)
- Chip designers minimize physical devices on a
chip
10Two Cryptic Notations
- If P and not Q, then R (P ? ?Q) ? R
11Are these sentences saying the same?
- If I am hungry (P) , then I am grumpy (Q).
- If I am not grumpy, then I am not hungry.
12Are these sentences saying the same?
- If I am hungry (P) , then I am grumpy (Q).
- If I am grumpy, then I am hungry.
- An implication is logically equivalent to its
contrapositive, but not to its converse.
13Are these sentences saying the same?
- These two statements together
- If I am grumpy, then I am hungry.
- If I am hungry, then I am grumpy.
- I am grumpy if and only if I am hungry.
14Logic exercise
- In computer chip design, we often use nand
- Using nand and not, find an equivalent expression
for A and B, A or B, and A implies B
15Tautologies
- P P is a tautology P is always true
- (P ? Q) ? (Q ? P)
- P ? (Q ? R) ? (P ? Q) ? R
- P ? (Q ? R) ? (P ? Q) ? (P ? R)
- (P ? P) ? P
- ??P ? P
- ? (P ? Q) ? ?P ? ?Q
16SAT
- Proposition is satisfiable if some setting of
variables makes it true. - PÂ ? QÂ is satisfiable because it is true when
PÂ is true and QÂ is false. - PÂ ? PÂ is not satisfiable because it is false for
both settings of P. - How about (P?Q?R)?(?P??Q)?(?P??R)?(?R??Q) ?
- Deciding whether a proposition is satisfiable is
called SAT. - Construct a truth table and check whether or not
a TÂ ever appears. - Not very efficient a proposition with
n variables has a truth table with 2n lines.
With just 30 variables, thats already over a
billion! - Is there an efficient solution to SAT? No one
knows - An efficient solution to SAT would immediately
imply efficient solutions to many, many other
important problems involving packing, scheduling,
routing, and circuit verification, and worldwide
chaos - Decrypting coded messages would also become an
easy task (for most codes). Online financial
transactions would be insecure and secret
communications could be read by everyone.
17Predicates
- A predicate is a proposition whose truth depends
on the value of one or more variables. For
example, - n is a perfect square
- The predicate is true for n 4 since 4 is a
perfect square, but false for n 5 since 5 is not
a perfect square. - Function-like notation.
- P(n) n is a perfect square
- P(4) is true, and P(5) is false.
- Note If PÂ is a predicate, then P(n) is either
true or false, depending on the value of n. If
PÂ is an ordinary function, like n2Â Â 1, then P(n)
is a numerical quantity.
18Quantifying a Predicate
- Two ways to use variables
- x2 0 is always true when x is a real number.
- x2 - 9 0 is only sometimes true (when x Â
3). - Always True a universal quantification
- For all x, x2Â 0. or x2Â 0Â for every x.
- Sometimes True an existential quantification
- There exists an x such that x2 - 9 0.
- x2Â - 9Â 0 Â for some x.
- x2Â - 9Â 0 Â for at least one x.
19Natural language may be confusing
- If you can solve any problem we come up with,
then you get a 20 for the course. - Can be interpreted as universal or existential
quantification - you can solve every problem we come up with
- you can solve at least one problem we come up
with - Note that quantified statements are themselves
propositions and can be combined with and, or,
implies, etc. just like any other proposition.
20More Cryptic Notation
- Predicate P(n) is true for all values of n in
some set S - ?n ?S P(n)Â for all n in S, P(n)Â is true.
- Predicate P(n) is true for at least one value of
n in S - ?p?S P(n)Â There exists an n in S such that P(n)
is true. - ? and ? are always followed by a variable and
predicate. - Let P be the set of problems we come up with,
S(x)Â be the predicate You can solve problem x,
and A be the proposition, You get an 20 for the
course. - (?x ?P S(x)) ? A you can solve every problem we
come up with - (?x ?P S(x)) ? A you can solve at least one
problem we come up with
21Mixing of Quantifiers
- Every even integer greater than 2 is the sum of
two primes. (Goldbach) - For every even integer n greater than 2, there
exist primes p and q such that npq. - Let E be the set of even integers greater than 2,
and let PÂ be the set of primes - ?n ?E ? p?P ? q?P npq
22Order of Quantifiers
- Every American has a dream.
- Let A be the set of Americans, D be the set of
dreams, and predicate H(a,d) be American a has
dream d.. - There is a single dream every American shares
- ?d ? D ?a ? A H(a,d)
- Every American has an individual dream
- ?a ? A ?d ? D H(a,d)
- Swapping quantifiers in Goldbachs Conjecture
- ?p ? P ?q ? P ?n ? E npq
23Negating Quantifiers
- The following two sentences mean the same thing
- It is not the case that everyone likes to
snowboard. - There exists someone who does not like to
snowboard. - Similarly, these sentences mean the same thing
- There does not exist anyone who likes skiing
over magma. - Everyone dislikes skiing over magma.
- Moving a not across a quantifier changes
quantifier. - ??x P(x) ? ?x ?P(x) ??x P(x) ? ?x
?P(x)
24Logic test
- Prove using truth tables that ? (P ? Q) ? ?P
? ?Q - Let Cn(S) p S p Give ten distinct
elements of Cn(p/\q) - Formalize in first order logic
- "All red cars are owned by students
- "Everybody, who owns a red car, is rich."
- "At least two students own a red car."
- "Fred owns a blue car."
- "Every student living in L. owns at least one
blue car - "Some students are rich."