SLIDE 1
Know ledge Representation using First-Order Logic Know ledge Representation using First Order Logic ( Part I I )
Reading: R&N Chapters 8, 9
SLIDE 2 Outline
- Review: KB |= S is equivalent to |= (KB S)
– So what does {} |= S mean?
- Review: Follows Entails Derives
- Review: Follows, Entails, Derives
– Follows: “Is it the case?” – Entails: “Is it true?” – Derives: “Is it provable?” p
- Review: FOL syntax
- Finish FOL Semantics, FOL examples
, p
- Inference in FOL
- Next Tuesday (1 June) is Review/Catch-up; Homework#7 is due
- Next Thursday (3 June) NO CLASS; I’m reviewing grants for NIH
- Next Friday (4 June) PROJECT REPORTS & CODE is due
Next Friday (4 June) PROJECT REPORTS & CODE is due
- Following Thursday (10 June) FINAL EXAM; 1:30-3:30pm
SLIDE 3 Review : KB | = S m eans | = ( KB S)
- KB |= S is read “KB entails S.”
– Means “S is true in every world (model) in which KB is true.” – Means “In the world S follows from KB ” Means In the world, S follows from KB.
- KB |= S is equivalent to |= (KB S)
– Means “(KB S) is true in every world (i.e., is valid).” ( ) y ( , )
- And so: {} |= S is equivalent to |= ({} S)
- So what does ({} S) mean?
– Means “True implies S.” – Means “S is valid.” – In Horn form, means “S is a fact.” p. 256 (3rd ed.; p. 281, 2nd ed.)
- Why does {} mean True here, but False in resolution proofs?
SLIDE 4 Review : ( True S) m eans “S is a fact.”
– The null conjunct is “syntactic sugar” for True. – The null disjunct is “syntactic sugar” for False The null disjunct is syntactic sugar for False. – Each is assigned the truth value of its identity element.
- For conjuncts, True is the identity: (A True) A
- For disjuncts, False is the identity: (A False) A
- A KB is the conjunction of all of its sentences.
– So in the expression: {} |= S
- We see that {} is the null conjunct and means True.
– The expression means “S is true in every world where True is true.”
– Better way to think of it: {} does not exclude any worlds (models) – Better way to think of it: {} does not exclude any worlds (models).
- In Conjunctive Normal Form each clause is a disjunct.
– So in, say, KB = { {P Q} {Q R} {} {X Y Z} } So in, say, KB { {P Q} {Q R} {} {X Y Z} }
- We see that {} is the null disjunct and means False.
SLIDE 5
Side Trip: Functions AND, OR, and null values ( Note: These are “syntactic sugar” in logic.)
function AND(arglist) returns a truth-value return ANDOR(arglist, True) return ANDOR(arglist, True) function OR(arglist) returns a truth-value function OR(arglist) returns a truth value return ANDOR(arglist, False) function ANDOR(arglist, nullvalue) returns a truth-value /* nullvalue is the identity element for the caller. */ if (arglist = {}) if (arglist {}) then return nullvalue if ( FIRST(arglist) = NOT(nullvalue) ) then return NOT(nullvalue) then return NOT(nullvalue) return ANDOR( REST(arglist) )
SLIDE 6
Review : Schem atic for Follow s, Entails, and Derives
Sentences Sentence Derives Inference
If KB is true in the real world, then any sentence entailed by KB and any sentence derived from KB by a sound inference procedure is also true in the real world.
SLIDE 7 Schem atic Exam ple: Follow s, Entails, and Derives
Inference Derives “Mary is Sue’s sister and Amy is Sue’s daughter.” “An aunt is a sister “Mary is Amy’s aunt.” I it bl ? “Mary is Sue’s sister and Amy is Sue’s daughter ” “Mary is E t il
Is it provable? Amy is Sue s daughter. Mary is Amy’s aunt.” Representation Entails “An aunt is a sister
Is it true? Follows World Mary Sue Sister Daughter Mary Aunt Is it the case? Amy g Amy
SLIDE 8 Review : Models ( and in FOL, I nterpretations)
- Models are formal worlds in which truth can be evaluated
- We say m is a model of a sentence α if α is true in m
- M(α) is the set of all models of α
- M(α) is the set of all models of α
- Then KB ╞ α iff M(KB) M(α)
– E.g. KB, = “Mary is Sue’s sister E.g. KB, Mary is Sue s sister and Amy is Sue’s daughter.” – α = “Mary is Amy’s aunt.”
Thi k f KB d t i t
- Think of KB and α as constraints,
and of models m as possible states.
- M(KB) are the solutions to KB
and M(α) the solutions to α and M(α) the solutions to α.
- Then, KB ╞ α, i.e., ╞ (KB a) ,
when all solutions to KB are also solutions to α.
SLIDE 9 Review : W um pus m odels
- KB = all possible wumpus-worlds consistent with the observations
and the “physics” of the Wumpus world.
SLIDE 10
Review : W um pus m odels
α1 = "[1,2] is safe", KB ╞ α1, proved by model checking. Every model that makes KB true also makes α1 true.
SLIDE 11 Review : Syntax of FOL: Basic elem ents
KingJohn, 2, UCI,...
- Predicates Brother >
- Predicates Brother, >,...
- Functions
Sqrt, LeftLegOf,...
x, y, a, b,... C ti
- Connectives
- , , , ,
- Equality
=
,
SLIDE 12 Syntax of FOL: Basic syntax elem ents are sym bols
– Stand for objects in the world.
- E.g., KingJohn, 2, UCI, ...
- Predicate Symbols
– Stand for relations (maps a tuple of objects to a truth-value)
- E.g., Brother(Richard, John), greater_than(3,2), ...
– P(x, y) is usually read as “x is P of y.”
- E.g., Mother(Ann, Sue) is usually “Ann is Mother of Sue.”
- Function Symbols
– Stand for functions (maps a tuple of objects to an object) E g Sqrt(3) LeftLegOf(John)
- E.g., Sqrt(3), LeftLegOf(John), ...
- Model (world) = set of domain objects, relations, functions
I nte p etation b l t th d l ( ld)
- I nterpretation maps symbols onto the model (world)
– Very many interpretations are possible for each KB and world! – Job of the KB is to rule out models inconsistent with our knowledge.
SLIDE 13 Syntax of FOL: Term s
- Term = logical expression that refers to an object
- There are tw o kinds of term s:
- There are tw o kinds of term s:
– Constant Sym bols stand for (or name) objects:
- E.g., KingJohn, 2, UCI, Wumpus, ...
E.g., KingJohn, 2, UCI, Wumpus, ... – Function Sym bols map tuples of objects to an object:
- E.g., LeftLeg(KingJohn), Mother(Mary), Sqrt(x)
- This is nothing but a complicated kind of name
– No “subroutine” call, no “return value”
SLIDE 14 Syntax of FOL: Atom ic Sentences
- Atom ic Sentences state facts (logical truth values).
– An atom ic sentence is a Predicate symbol, optionally followed by a parenthesized list of any argument terms – E.g., Married( Father(Richard), Mother(John) ) An atom ic sentence asserts that some relationship (some – An atom ic sentence asserts that some relationship (some predicate) holds among the objects that are its arguments.
- An Atom ic Sentence is true in a given model if the
An Atom ic Sentence is true in a given model if the relation referred to by the predicate symbol holds among the objects (terms) referred to by the arguments.
SLIDE 15 Syntax of FOL: Connectives & Com plex Sentences
- Com plex Sentences are formed in the same way,
and are formed using the same logical connectives and are formed using the same logical connectives, as we already know from propositional logic
- The Logical Connectives:
- The Logical Connectives:
– biconditional – implication – and –
– negation
- Sem antics for these logical connectives are the same as
Sem antics for these logical connectives are the same as we already know from propositional logic.
SLIDE 16 Syntax of FOL: Variables
- Variables range over objects in the world.
- A variable is like a term because it represents an object.
- A variable may be used wherever a term may be used
- A variable may be used wherever a term may be used.
– Variables may be arguments to functions and predicates.
- (A term w ith NO variables is called a ground term .)
( g )
- (A variable not bound by a quantifier is called free.)
SLIDE 17 Syntax of FOL: Logical Quantifiers
- There are two Logical Quantifiers:
– Universal: x P(x) means “For all x, P(x).” h “ d d ” d f “ ”
- The “upside-down A” reminds you of “ALL.”
– Existential: x P(x) means “There exists x such that, P(x).”
- The “upside-down E” reminds you of “EXISTS.”
- Syntactic “sugar” --- we really only need one quantifier.
– x P(x) x P(x) – x P(x) x P(x) You can ALWAYS convert one quantifier to the other – You can ALWAYS convert one quantifier to the other.
- RULES: and
- RULE: To move negation “in” across a quantifier,
change the quantifier to “the other quantifier” and negate the predicate on “the other side.” P( ) P( ) – x P(x) x P(x) – x P(x) x P(x)
SLIDE 18 Existential Quantification
- Existential quantification is equivalent to:
– Disjunction of all sentences obtained by substitution of an
- bject for the quantified variable.
- bject for the quantified variable.
- Spot has a sister who is a cat.
– x Sister(x, Spot) Cat(x)
- Disjunction of all sentences obtained by substitution of
an object for the quantified variable:
Si (S S ) C (S ) Sister(Spot, Spot) Cat(Spot) Sister(Rick, Spot) Cat(Rick) Sister(LAX, Spot) Cat(LAX) Sister(Shayama Spot) Cat(Shayama) Sister(Shayama, Spot) Cat(Shayama) Sister(France, Spot) Cat(France) Sister(Felix, Spot) Cat(Felix) …
SLIDE 19 Com bining Quantifiers --- Order ( Scope)
The order of “unlike” quantifiers is important. q p x y Loves(x,y)
– For everyone (“all x”) there is someone (“exists y”) whom they love
y x Loves(x,y)
- there is someone (“exists y”) whom everyone loves (“all x”)
Clearer with parentheses: y ( x
Loves(x,y) ) The order of “like” quantifiers does not matter. The order of like quantifiers does not matter. x y P(x, y) y x P(x, y) x y P(x, y) y x P(x, y)
SLIDE 20 De Morgan’s Law for Quantifiers
( ) x P x P
) P Q P Q
De Morgan’s Rule Generalized De Morgan’s Rule
( ) ( ) ( ) x P x P x P x P
) ( ) ( ) Q Q P Q P Q P Q P Q
( ) ( ) x P x P
) ( ) Q Q P Q P Q
Rule is simple: if you bring a negation inside a disjunction or a conjunction, always switch between them (or and, and or).
SLIDE 21 FOL (or FOPC) Ontology: What kind of things exist in the world? Wh t d d t d ib d b t? What do we need to describe and reason about? Objects --- with their relations, functions, predicates, properties, and general rules. R i Reasoning Representation Inference
Symbol System
Matching Syntax Semantics Schema Execution Syntax
said Semantics
means Schema
Inference Execution
Strategy This lecture Next lecture
SLIDE 22 Sem antics: W orlds
- The world consists of objects that have properties.
– There are relations and functions betw een these objects – Objects in the w orld, individuals: people, houses, numbers, colors, baseball games, wars, centuries
- Clock A John 7 the-house in the corner Tel-Aviv
- Clock A, John, 7, the-house in the corner, Tel-Aviv
– Functions on individuals:
- father-of, best friend, third inning of, one more than
– Relations:
- brother-of, bigger than, inside, part-of, has color, occurred
after – Properties ( a relation of arity 1 ) :
- red round bogus prime multistoried beautiful
- red, round, bogus, prime, multistoried, beautiful
SLIDE 23 Sem antics: I nterpretation
- An interpretation of a sentence (wff) is an assignment that
maps
– Object constant symbols to objects in the world, – n-ary function symbols to n-ary functions in the world, n ary relation symbols to n ary relations in the world – n-ary relation symbols to n-ary relations in the world
- Given an interpretation, an atomic sentence has the value
“true” if it denotes a relation that holds for those individuals true if it denotes a relation that holds for those individuals denoted in the terms. Otherwise it has the value “false.”
– Example: Kinship world:
- Symbols = Ann, Bill, Sue, Married, Parent, Child, Sibling, …
– World consists of individuals in relations:
- Married(Ann,Bill) is false, Parent(Bill,Sue) is true, …
SLIDE 24 Truth in first-order logic
- Sentences are true with respect to a model and an interpretation
- Model contains objects (domain elements) and relations among them
- Interpretation specifies referents for
constant symbols →
predicate symbols → relations predicate symbols relations function symbols → functional relations
- An atomic sentence predicate(term1,...,termn) is true
p (
1 n)
iff the objects referred to by term1,...,termn are in the relation referred to by predicate
SLIDE 25 Sem antics: Models
- An interpretation satisfies a w ff ( sentence) if the w ff has
the value “true” under the interpretation.
- Model: A dom ain and an interpretation that satisfies a
w ff is a model of that w ff V lidit A ff th t h th l “t ” d ll
- Validity: Any w ff that has the value “true” under all
interpretations is valid
- Any w ff that does not have a m odel is inconsistent or
unsatisfiable unsatisfiable
- I f a w ff w has a value true under all the m odels of a set
- f sentences KB then KB logically entails w
SLIDE 26
Models for FOL: Exam ple
SLIDE 27
SLIDE 28
SLIDE 29
SLIDE 30
SLIDE 31
SLIDE 32 Using FOL
- We want to TELL things to the KB, e.g.
TELL(KB, ) TELL(KB King(John) )
, ( ) ( ) x King x Person x
TELL(KB, King(John) ) These sentences are assertions
- We also want to ASK things to the KB,
ASK(KB )
( ) P
ASK(KB, ) these are queries or goals
, ( ) x Person x
The KB should return the list of x’s for which Person(x) is true:
{x/John,x/Richard,...}
SLIDE 33 FOL Version of W um pus W orld
- Typical percept sentence:
Percept([Stench,Breeze,Glitter,None,None],5)
Turn(Right), Turn(Left), Forward, Shoot, Grab, Release, Climb
- To determine best action, construct query:
a BestAction(a,5)
ASK l hi d { /G b}
- ASK solves this and returns {a/Grab}
– And TELL about the action.
SLIDE 34 Know ledge Base for W um pus W orld
– s,b,g,x,y,t Percept([s,Breeze,g,x,y],t) Breeze(t) s b x y t Percept([s b Glitter x y] t) Glitter(t) – s,b,x,y,t Percept([s,b,Glitter,x,y],t) Glitter(t)
t Glitter(t) BestAction(Grab t) – t Glitter(t) BestAction(Grab,t)
- Reflex action with internal state
t Glitt (t) H ldi (G ld t) B tA ti (G b t) – t Glitter(t) Holding(Gold,t) BestAction(Grab,t) Holding(Gold,t) can not be observed: keep track of change.
SLIDE 35
Deducing hidden properties
Environment definition:
x,y,a,b Adjacent([x,y],[a,b]) [a b] {[x+1 y] [x-1 y] [x y+1] [x y-1]} [a,b] {[x+1,y], [x 1,y],[x,y+1],[x,y 1]} Properties of locations: s,t At(Agent,s,t) Breeze(t) Breezy(s)
Squares are breezy near a pit: – Diagnostic rule---infer cause from effect s Breezy(s) r Adjacent(r,s) Pit(r) – Causal rule---infer effect from cause (model based reasoning) r Pit(r) [s Adjacent(r,s) Breezy(s)]
SLIDE 36
SLIDE 37
SLIDE 38
SLIDE 39 Set Theory in First-Order Logic
Can we define set theory using FOL?
- individual sets, union, intersection, etc
Answer is yes. Basics: Basics:
- empty set = constant = { }
- unary predicate Set( ), true for sets
- binary predicates:
x s (true if x is a member of the set x)
s1 s2 (true if s1 is a subset of s2) s1 s2 (true if s1 is a subset of s2)
intersection s1 s2, union s1 s2 , adjoining {x|s}
SLIDE 40 A Possible Set of FOL Axiom s for Set Theory
The only sets are the empty set and sets made by adjoining an element to a set s Set(s) (s = {} ) (x,s2 Set(s2) s = {x|s2}) ( ) ( {} ) ( , 2 ( 2) { | 2}) The empty set has no elements adjoined to it
Adjoining an element already in the set has no effect x,s x s s = {x|s} The only elements of a set are those that were adjoined into it. Expressed recursively: x,s x s [ y,s2 (s = {y|s2} (x = y x s2))] x,s x s [ y,s2 (s {y|s2} (x y x s2))]
SLIDE 41 A Possible Set of FOL Axiom s for Set Theory
A set is a subset of another set iff all the first set’s members are members of the 2nd set s1,s2 s1 s2 (x x s1 x s2)
1, 2 1 2
(
1 2)
Two sets are equal iff each is a subset of the other s1,s2 (s1 = s2) (s1 s2 s2 s1) An object is in the intersection of 2 sets only if a member of both x,s1,s2 x (s1 s2) (x s1 x s2) An object is in the union of 2 sets only if a member of either x,s1,s2 x (s1 s2) (x s1 x s2)
SLIDE 42
Know ledge engineering in FOL
1. Identify the task 2. Assemble the relevant knowledge 3. Decide on a vocabulary of predicates, functions, and constants 4 Encode general knowledge about the domain 4. Encode general knowledge about the domain 5. Encode a description of the specific problem instance 6 P i t th i f d d t 6. Pose queries to the inference procedure and get answers 7. Debug the knowledge base
SLIDE 43 The electronic circuits dom ain
One-bit full adder Possible queries:
- does the circuit function properly?
h t t t d t th fi t i t t i l?
- what gates are connected to the first input terminal?
- what would happen if one of the gates is broken?
and so on
SLIDE 44
The electronic circuits dom ain
1. Identify the task
– Does the circuit actually add properly?
2 Assemble the relevant knowledge 2. Assemble the relevant knowledge
– Composed of wires and gates; Types of gates (AND, OR, XOR, NOT) – – Irrelevant: size, shape, color, cost of gates –
3. Decide on a vocabulary
– Alternatives: – Type(X ) = XOR (function) Type(X1) = XOR (function) Type(X1, XOR) (binary predicate) XOR(X1) (unary predicate)
SLIDE 45
The electronic circuits dom ain
4. Encode general knowledge of the domain – t1,t2 Connected(t1, t2) Signal(t1) = Signal(t2) t Signal(t) 1 Signal(t) – t Signal(t) = 1 Signal(t) = 0 – 1 ≠ 0 t t Connected(t t ) Connected(t t ) – t1,t2 Connected(t1, t2) Connected(t2, t1) – g Type(g) = OR Signal(Out(1,g)) = 1 n Signal(In(n,g)) = 1 g Type(g) AND Signal(Out(1 g)) n Signal(In(n g)) – g Type(g) = AND Signal(Out(1,g)) = 0 n Signal(In(n,g)) = 0 – g Type(g) = XOR Signal(Out(1,g)) = 1 Signal(In(1,g)) ≠ Signal(In(2 g)) Signal(In(2,g)) – g Type(g) = NOT Signal(Out(1,g)) ≠ Signal(In(1,g))
SLIDE 46
The electronic circuits dom ain
5. Encode the specific problem instance Type(X1) = XOR Type(X2) = XOR Type(A1) = AND Type(A2) = AND Type(O1) = OR Connected(Out(1,X1),In(1,X2)) Connected(In(1,C1),In(1,X1)) Connected(Out(1 X1) In(2 A2)) Connected(In(1 C1) In(1 A1)) Connected(Out(1,X1),In(2,A2)) Connected(In(1,C1),In(1,A1)) Connected(Out(1,A2),In(1,O1)) Connected(In(2,C1),In(2,X1)) Connected(Out(1,A1),In(2,O1)) Connected(In(2,C1),In(2,A1)) Connected(Out(1,X2),Out(1,C1)) Connected(In(3,C1),In(2,X2)) C t d(O t(1 O ) O t(2 C )) C t d(I (3 C ) I (1 A )) Connected(Out(1,O1),Out(2,C1)) Connected(In(3,C1),In(1,A2))
SLIDE 47
The electronic circuits dom ain
6. Pose queries to the inference procedure
What are the possible sets of values of all the terminals for the adder circuit? c cu
i1,i2,i3,o1,o2 Signal(In(1,C_1)) = i1 Signal(In(2,C1)) = i2 Signal(In(3,C1)) = i3 Signal(Out(1,C1)) = o1 Signal(Out(2,C1)) = o2
7. Debug the knowledge base
May have omitted assertions like 1 ≠ 0
SLIDE 48 Syntactic Am biguity
- FOPC provides many ways to represent the same thing.
- E.g., “Ball-5 is red.”
HasColor(Ball 5 Red) – HasColor(Ball-5, Red)
- Ball-5 and Red are objects related by HasColor.
– Red(Ball-5)
- Red is a unary predicate applied to the Ball-5 object.
y p pp j – HasProperty(Ball-5, Color, Red)
- Ball-5, Color, and Red are objects related by HasProperty.
– ColorOf(Ball-5) = Red
- Ball-5 and Red are objects, and ColorOf() is a function.
– HasColor(Ball-5(), Red())
- Ball-5() and Red() are functions of zero arguments that both
return an object, which objects are related by HasColor. return an object, which objects are related by HasColor. – …
- This can GREATLY confuse a pattern-matching reasoner.
– Especially if multiple people collaborate to build the KB, and they all have different representational conventions.
SLIDE 49 Sum m ary
– Much more expressive than propositional logic – Allows objects and relations as semantic primitives Allows objects and relations as semantic primitives – Universal and existential quantifiers – syntax: constants, functions, predicates, equality, quantifiers –
- Knowledge engineering using FOL
– Capturing domain knowledge in logical form
- Inference and reasoning in FOL
– Next lecture
– All of Chapter 8 – Next lecture: Chapter 9 Next lecture: Chapter 9