HW6 Due Tue 33 10 pm P3 Due 35 Final Exam Monday May 4 14pm Let us know ASAP if you have 3 exams scheduled within 24 hours Make travel arrangements accordingly No Homework during Spring Break ID: 776425
Download Presentation The PPT/PDF document " Announcements Assignments:" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
Announcements
Assignments:
HW6
Due Tue 3/3, 10 pm
P3
Due 3/5!!!!
Final Exam Monday May 4, 1-4pm
Let us know ASAP if you have 3 exams scheduled within 24 hours
Make travel arrangements accordingly
No Homework during Spring Break!
Slide2AI: Representation and Problem Solving
First-Order Logic
Instructors: Pat Virtue & Stephanie Rosenthal
Slide credits: CMU AI, http://aima.eecs.berkeley.edu
Slide3Outline
Need for first-order logic
Syntax and semantics
Planning with FOL
Inference with FOL
Slide4Pros and Cons of Propositional Logic
Propositional
logic
is
declarative
:
pieces
of
syntax
correspond
to
facts
Propositional
logic
allows
partial/disjunctive/negated
information
(unlike
most
data structures
and
databases)
Propositional
logic
is
compositional
:
meaning
of
B
1
,
1
∧
P
1
,
2
is
derived
from
meaning
of
B
1
,
1
and
of
P
1
,
2
Meaning
in
propositional
logic
is
context-independent
(unlike
natural
language,
where
meaning
depends
on
context)
Propositional
logic
has
very
limited
expressive
power
(unlike
natural
language)
E.g.,
cannot
say
“pits
cause
breezes
in
adjacent
squares”
except
by
writing
one
sentence
for
each
square
Slide5Pros and Cons of Propositional Logic
Conciseness
We don’t need to write out the successor-state axioms for each state individually, we can use variables and qualifiers
Rules of chess:
100,000 pages in propositional logic
1 page in first-order logic
Rules of
pacman
:
x,y,t
At(
x,y,t
)
[
At(x,y,t-1)
u,v
Reachable(
x,y,u,v,Action
(t-1))] v
[
u,v
At(u,v,t-1)
Reachable(
x,y,u,v,Action
(t-1))]
Slide6First-Order Logic (First-Order Predicate Calculus)
Whereas
propositional
logic
assumes
world
contains
facts
,
first-order
logic
(like
natural
language)
assumes
the
world
contains
Objects
:
people,
houses,
numbers,
theories,
Ronald
McDonald,
colors,
baseball
games, wars,
centuries,
...
Relations (return true/false)
:
red,
round,
bogus,
prime,
multistoried
..
.
,
brother
of,
bigger
than,
inside,
part
of,
has
color,
occurred
after,
owns,
…
Functions (return an object)
:
father
of,
best
friend,
third
inning
of,
one more
than,
end
of, …
Slide7Logics in General
LanguageWhat exists in the worldWhat an agent believes about factsPropositional logicFactstrue / false / unknownFirst-order logicfacts, objects, relationstrue / false / unknownProbability theoryfactsdegree of beliefFuzzy logicfacts + degree of truthknown interval value
Slide8Syntax of FOL
Basic Elements
Constants Predicates Functions Variables Connectives Equality Quantifiers
KingJ ohn, 2, CMU, . . .Brother, >, . . .Sqrt, LeftLegOf, . . . x, y, a, b, . . .∧ ∨ ¬ ⇒ ⇔=∀ ∃
Slide9Syntax of FOL
Atomic sentence = predicate(term1, . . . , termn) or term1 = term2 Term = function(term1, . . . , termn) or constant or variableExamplesBrother(KingJ ohn, RichardT heLionheart)> (Length(LeftLegOf (Richard)), Length(LeftLegOf (KingJ ohn)))
Slide10Syntax of FOL
Complex sentences are made from atomic sentences using connectives¬S, S1 ∧ S2, S1 ∨ S2, S1 ⇒S2, S1 ⇔ S2Examples Sibling(KingJ ohn, Richard) ⇒ Sibling(Richard, KingJ ohn)>(1, 2) ∨ ≤(1, 2)>(1, 2) ∧ ¬>(1, 2)
Slide11Models for FOL
Example
R
J
$
left
leg
left leg
brother
brother
person
on headperson king
crown
Slide12Models for FOL
Brother(Richard, John)Consider the interpretation in which:Richard → Richard the Lionheart John → the evil King JohnBrother → the brotherhood relationWhat does the Brother relationship mean?
R
J
$
left
leg
left leg
brother
brother
person
on head person king
crown
Slide13Model for FOL
Lots of models!
R
J
$
left
leg
left
leg
brother
brother
person
on head person king
crown
Slide14Model for FOL
Lots of models!Entailment in propositional logic can be computed by enumerating modelsWe can enumerate the FOL models for a given KB vocabulary: For each number of domain elements n from 1 to ∞For each k-ary predicate Pk in the vocabulary For each possible k-ary relation on n objectsFor each constant symbol C in the vocabularyFor each choice of referent for C from n objects . . .Computing entailment by enumerating FOL models is not easy!
Slide15Truth in First-Order Logic
Sentences
are
true
with
respect
to
a
model
and an
interpretation
Model
contains
≥
1
objects
(
domain
elements
)
and
relations
among
them
Interpretation
specifies
referents
for
constant
symbols
→
objects
predicate
symbols
→
relations
function
symbols
→
functional
relations
An
atomic
sentence
predicate
(
term
1
,
.
.
.
,
term
n
)
is
true
:
iff
the
objects
referred
to
by
term
1
,
. . . ,
term
n
are
in
the
relation
referred
to
by
predicate
Slide16Models for FOL
Consider the interpretation in which:Richard → Richard the Lionheart John → the evil King JohnBrother → the brotherhood relationUnder this interpretation, Brother(Richard, John) is true just in the case Richard the Lionheart and the evil King John are in the brotherhood relation in the model
R
J
$
left
leg
left leg
brother
brother
person
on head person king
crown
Slide17Universal Quantification
∀ (variables) (sentence)Everyone at the banquet is hungry:∀ x At(x, Banquet) ⇒ Hungry(x)∀ x P is true in a model m iff P is true with x beingeach possible object in the modelRoughly speaking, equivalent to the conjunction of instantiations of P(At(KingJ ohn, Banquet) ⇒ Hungry(KingJ ohn))∧ (At(Richard, Banquet) ⇒ Hungry(Richard))∧ (At(Banquet, Banquet) ⇒ Hungry(Banquet))∧ . . .
Slide18Universal Quantification
Common mistakeTypically, ⇒ is the main connective with ∀Common mistake: using ∧ as the main connective with ∀:∀ x At(x, Banquet) ∧ Hungry(x)means “Everyone is at the banquet and everyone is hungry”
Slide19Existential Quantification
∃ (variables) (sentence)Someone at the tournament is hungry:∃ x At(x, Tournament) ∧ Hungry(x)∃ x P is true in a model m iff P is true with x beingsome possible object in the modelRoughly speaking, equivalent to the disjunction of instantiations of P(At(KingJ ohn, Tournament) ∧ Hungry(KingJ ohn))∨ (At(Richard, Tournament) ∧ Hungry(Richard))∨ (At(Tournament, Tournament) ∧ Hungry(Tournament))∨ . . .
Slide20Existential Quantification
Common mistakeTypically, ∧ is the main connective with ∃Common mistake: using ⇒ as the main connective with ∃:∃ x At(x, Tournament) ⇒ Hungry(x)is true if there is anyone who is not at the tournament!
Slide21Properties of Quantifiers
∀ x∀ yis the same as ∀ y∀ x∃ x∃ yis the same as ∃ y∃ x∃ x∀ yis not the same as∀ y∃ x
∃ x ∀ y Loves(x, y)“There is a person who loves everyone in the world”∀ y ∃ x Loves(x, y)“Everyone in the world is loved by at least one person”Quantifier duality: each can be expressed using the other
∀ x Likes(x, IceCream)∃ x Likes(x, Broccoli)
¬∃ x ¬Likes(x, IceCream) ¬∀ x ¬Likes(x, Broccoli)
Slide22Fun with Sentences
Brothers
are
siblings
∀
x,
y
Brother
(
x,
y
)
⇒
Sibling
(
x,
y
)
.
“Sibling”
is
symmetric
∀
x,
y
Sibling
(
x,
y
)
⇔
Sibling
(
y,
x
)
.
A
first
cousin
is
a
child
of
a
parent’s
sibling
∀
x,
y
FirstCousin
(
x,
y
)
⇔
∃
p,
ps
Parent
(
p,
x
)
∧
Sibling
(
ps
,
p
)
∧
Parent
(
ps
,
y
)
Slide23Equality
term1 = term2 is true under a given interpretationif and only if term1 and term2 refer to the same objectE.g., 1 = 2 and ∀ x × (Sqrt(x), Sqrt(x)) = x are satisfiable 2 = 2 is validE.g., definition of (full) Sibling in terms of Parent:∀ x, y Sibling(x, y) ⇔ [¬(x = y) ∧ ∃ m, f ¬(m = f ) ∧ Parent(m, x) ∧ Parent(f, x) ∧ Parent(m, y) ∧ Parent(f, y)]
Slide24Piazza Poll 1
Given the following two FOL sentences:Which of these is true? BothNeither
Piazza Poll 1
Given the following two FOL sentences:Which of these is true? BothNeither
Interacting with FOL KBs
Suppose a wumpus-world agent is using an FOL KBand perceives a smell and a breeze (but no glitter) at t = 5:T ell(KB, P ercept([Smell, Breeze, N one], 5))Ask(KB, ∃ a Action(a, 5))i.e., does KB entail any particular actions at t = 5? Answer: Y esGiven a sentence S and a substitution σ,Sσ denotes the result of plugging σ into S; e.g.,S = Smarter(x, y)σ = {x/EVE, y/WALL-E}Sσ = Smarter(EVE, WALL-E)Ask(KB, S) returns some/all σ such that KB |= Sσ
, {a/Shoot} ← substitution (binding list)
Notation Alert!
Notation Alert!
Slide27Inference in First-Order Logic
A) Reducing first-order inference to propositional inferenceRemoving Removing UnificationB) Lifting propositional inference to first-order inferenceGeneralized Modus PonensFOL forward chaining
Universal Instantiation
Every instantiation of a universally quantified sentence is entailed by it:∀ v αSubst({v/g}, α)for any variable v and ground term gE.g., ∀ x King(x) ∧ Greedy(x) ⇒ Evil(x) yieldsKing(John) ∧ Greedy(John) ⇒ Evil(John) King(Richard) ∧ Greedy(Richard) ⇒ Evil(Richard)King(Father(John)) ∧ Greedy(Father(John))⇒ Evil(Father(John))
Slide29Existential Instantiation
For any sentence α, variable v, and constant symbol kthat does not appear elsewhere in the knowledge base: ∃ v αSubst({v/k}, α)E.g., ∃ x Crown(x) ∧ OnHead(x, J ohn) yieldsCrown(C1) ∧ OnHead(C1, J ohn)provided C1 is a new constant symbol, called a Skolem constant
Slide30Reduction to Propositional Inference
Suppose
the
KB
contains
just
the
following:
∀
x
K
in
g
(
x
)
∧
G
r
eed
y
(
x
)
⇒
E
v
i
l
(
x
)
King
(
J
ohn
)
Greedy
(
J
ohn
)
Brother
(
Richard,
J
ohn
)
Instantiating
the
universal
sentence
in
all
possible
ways,
we
have
King
(
J
ohn
)
∧
Greedy
(
J
ohn
)
⇒
Evil
(
J
ohn
)
K
in
g
(
R
icha
r
d
)
∧
G
r
eed
y
(
R
icha
r
d
)
⇒
E
v
i
l
(
R
icha
r
d
)
King
(
J
ohn
)
Greedy
(
J
ohn
)
Brother
(
Richard,
J
ohn
)
The
new
KB
is
propositionalized
:
proposition
symbols
are
King
(
J
ohn
)
,
Greedy
(
J
ohn
)
,
Evil
(
J
ohn
)
,
King
(
Richard
)
etc.
Slide31Reduction to Propositional Inference
Claim:
a
ground
sentence
∗
is
entailed
by
new
KB
iff
entailed
by
original
KB
Claim:
every
FOL
KB
can
be
propositionalized
so as
to
preserve
entailment
Idea:
propositionalize
KB
and
query,
apply resolution,
return
result
Problem:
with
function
symbols,
there
are
infinitely
many
ground
terms,
e.g.,
Father
(
Father
(
Father
(
J
ohn
)))
Theorem:
Herbrand
(1930).
If a
sentence
α
is
entailed
by
an
FOL
KB,
it
is
entailed
by
a
finite
subset
of
the
propositional
KB
Idea:
For
n
=
0
to
∞
do
create
a
propositional
KB
by
instantiating
with
depth-
n
terms
see
if
α
is
entailed
by
this
KB
Problem:
works
if
α
is
entailed,
loops
if
α
is not
entailed
Theorem:
Turing
(1936),
Church
(1936),
entailment
in
FOL
is
semidecidable
Slide32Problems with Propositionalization
Propositionalization seems to generate lots of irrelevant sentences. E.g., from∀ x King(x) ∧ Greedy(x) ⇒Evil(x)King(John)∀ y Greedy(y)Brother(Richard, John)it seems obvious that Evil(John), but propositionalization produces lots of facts such as Greedy(Richard) that are irrelevant
Slide33Unification
We can get the inference immediately if we can find a substitution θsuch that King(x) and Greedy(x) match King(John) and Greedy(y)θ = {x/John, y/J ohn} worksUnify(α, β) = θ if αθ = βθ
p
qθKnows(J ohn, x)Knows(J ohn, Jane){x/Jane}Knows(J ohn, x)Knows(y, Sam ){x/Sam, y/J ohn}Knows(J ohn, x)Knows(y, M other(y)){y/J ohn, x/M other(J ohn)}Knows(J ohn, x)Knows(x, Sam )fail
Standardizing apart eliminates overlap of variables, e.g., Knows(z17, Sam)
Slide34Generalized Modus Ponens (GMP)
where
for all
Example
is is is is is is is GMP used with KB of definite clauses (exactly one positive literal) All variables assumed universally quantified
FOL Forward Chaining