You are on page 1of 5

Overview

Introduction & Agents


Search, Heuristics & CSPs
First-Order Logic Adversarial Search
Logical
g Knowledge
g Representation
p
Planning & MDPs
Daniel Weld Reinforcement Learning
CSE 473 Uncertainty & Bayesian Networks
Machine Learning
Spring 2012
NLP & Special Topics

Propositional. Logic vs. First Order FOL Definitions


• Constants: a,b, dog33.
Facts (P, Q)
Objects, Name a specific object.
Ontology Properties,
Relations • Variables: X, Y.
Variables & quantification Refer to an object without naming it.
Syntax Atomic sentences
Connectives
Sentences have structure: terms • Functions: dad-of
father-of(mother-of(X))) Mapping from objects to objects.
Semantics Truth Tables
Interpretations • Terms: dad-of(dog33)
(Much more complicated)
Refer to objects
Inference DPLL, GSAT Unification • Atomic Sentences: in(dad-of(dog33), food6)
Algorithm Fast in practice Forward, Backward chaining Can be true or false
Prolog, theorem proving Correspond to propositional symbols P, Q
Complexity NP-Complete Semi-decidable

© Daniel S. Weld 3 © Daniel S. Weld 4

More Definitions More Definitions


Logical connectives: and, or, not, => • Quantifiers:
 Forall
male(dan)  male(father-of(dan))
 There exists
• Examples
Dumbo is grey
P  Q

Elephants are grey


male(dan)  male(son-of(father-of(dan)))

There is a grey elephant

© Daniel S. Weld 5 © Daniel S. Weld 6

1
More Definitions More Definitions
• Quantifiers: • Quantifiers:
 Forall  Forall
 There exists  There exists
• Examples • Examples
Dumbo is grey Dumbo is grey
grey(dumbo) grey(dumbo)

Elephants are grey Elephants are grey


 elephant(x)  grey(x)

There is a grey elephant There is a grey elephant

© Daniel S. Weld 7 © Daniel S. Weld 8

More Definitions Quantifier / Connective


Interaction
• Quantifiers: E(x) == “x is an elephant”
 Forall G(x) == “x has the color grey”
 There exists 1. x E(x)  G(x)
• Examples
Dumbo is grey 2. x
x E(x) G(x)
grey(dumbo)
3. x E(x)  G(x)
Elephants are grey
 x elephant(x)  grey(x) 4. x E(x) G(x)
There is a grey elephant
 x elephant(x)  grey(x)
© Daniel S. Weld 9 © Daniel S. Weld 10

Nested Quantifiers: Wumpus world in prop logic


Order matters!
Let Pi,j be true if there is a pit in [i, j].
x y P(x,y)  y x P(x,y) Let Bi,j be true if there is a breeze in [i, j].

• Examples
KB:
KB
E
Every dog
d has
h s a tail
t il Every dog shares a tail!  P1,1
B1,1
d t has(d,t) ? t d has(d,t)
"Pits cause breezes in adjacent squares"
B1,1  (P1,2  P2,1)
B2,1  (P1,1  P2,2  P3,1)
Someone is loved by everyone
x y loves(y, x)
12
© Daniel S. Weld 11

2
Wumpus world in prop logic Semantics
• Syntax: a description of the legal
Let pit(i,j) be true if there is a pit in [i, j]. arrangements of symbols
Let breeze(i,j) be true if breezy in [i, j]. (Def “sentences”)
• Semantics: what the arrangement of
symbols means in the world
KB:
KB Inference
 pit(1,1) Sentences Sentences
 breeze(1,1)

Semantics

Semantics
"Pits cause breezes in adjacent squares" Representation
i,j breeze(i,j)  pit(i, add(j,1))  pit(i, add(j, -1))  …

World

Models Models
13
© Daniel S. Weld 15

Satisfiability, Validity, & Entailment Propositional Logic: SEMANTICS


• S is valid if it is true in all interpretations • “Interpretation” (or “possible world”)
• Specifically, TRUTH ASSIGNMENTS
• S is satisfiable if it is true in some interp Assignment to each variable either T or F
Assignment of T or F to each connective
• S is unsatisfiable if it is false all interps
|=
Symbols: P Q
• S1 entails S2 if Q

forall interps where S1 is true, T F


T T F
S2 is also true Models: T T
P
F F F
F T …
PQ
© Daniel S. Weld 16 © Daniel S. Weld 17

Models First Order Logic: Models


• Logicians often think in terms of models, which are formally • Depiction of one possible “real-world” model
structured worlds with respect to which truth can be evaluated
In propositional case, each model = truth assignment
Set of models can be enumerated in a truth table

• We say m is a model of a sentence α if α is true in m


(Equivalently “m satisfies ”)

• M(α)
M( ) is
i th
the sett of
f all d l of
ll models fα

• Then KB ╞ α iff M(KB)  M(α)



E.g. KB = (PQ) (P  R)
α = (PR)

18
© Daniel S. Weld 19

3
Interpretations=Mappings Interpretations=Mappings
syntactic tokens  model elements syntactic tokens  model elements
Depiction of one possible interpretation, assuming Another interpretation, same assumptions
Constants: Functions: Relations: Constants: Functions: Relations:
Richard John Leg(p,l) On(x,y) King(p) Richard John Leg(p,l) On(x,y) King(p)

© Daniel S. Weld 20 © Daniel S. Weld 21

FOL Reasoning Forward Chaining


• FO Forward & Backward Chaining • Given
?x lifeform(?x) => mortal(?x)
• FO Resolution
?x mammal(?x) => lifeform(?x)
• Many other types of theorem proving ?x dog(?x) => mammal(?x)
• Restricted representations dog(fido)
g( )
Description logics • Prove
Horn Clauses mortal(fido)
• Compilation to SAT
?x dog(?x) => mammal(?x)
dog(fido)
mammal(fido) ?
© Daniel S. Weld 23 © Daniel S. Weld 24

Unification Unification Examples


• Emphasize variables with ? • Unify(road(?a, kent), road(seattle, ?b))
• Useful for FO inference (modus ponens, …)
Also for compilation of FOPC -> propositional • Unify(road(?a, ?a), road(seattle, kent))

• Unify(,
U if ( )) returns
t ““mgu”” • Unify(f(g(?x, dog), ?y)), f(g(cat, ?y), dog)
Unify(city(?a), city(kent)) returns ?a/kent
• Unify(f(g(?x)), f(?x))
• Substitute(expr, mapping) returns new expr
Substitute(connected(?a, ?b), {?a/kent})
returns connected(kent, ?b)

© Daniel S. Weld 25 © Daniel S. Weld 26

4
Compilation to Prop. Logic I Compilation to Prop. Logic II
• Typed Logic • Universe
city a,b connected(a,b) • Cities: seattle, tacoma, enumclaw
• Universe • Firms: IBM, Microsoft, Boeing
Cities: seattle,, tacoma,, enumclaw • First
First-Order
Order formula
• Equivalent propositional formula: city c firm f hasHQ(c, f)
• Equivalent propositional formula

© Daniel S. Weld 36 © Daniel S. Weld 37

Hey! Restricted Forms of FO Logic


• You said FO Inference is semi-decidable • Known, Finite Universes
• But you compiled it to SAT Compile to SAT
Which is NP Complete • Frame Systems
• So now we can always do the inference?!? Ban certain types of expressions
Th it might
Tho i ht ttake
k exponential
ti l ti
time… • Horn
H rn Cl
Clauses
us s
Aka Prolog
• Function-Free Horn Clauses
• Something seems wrong here….???? Aka Datalog

© Daniel S. Weld 38 © Daniel S. Weld 39

You might also like