4 Fol
4 Fol
First-Order-Logic
Acknowledgement:
Tom Lenaerts, SWITCH, Vlaams Interuniversitair Instituut voor Biotechnologie
Outline
Why FOL?
Syntax and semantics of FOL
Using FOL
Wumpus world in FOL
Knowledge engineering in FOL
2
Pros and cons of propositional logic
First-order logic
4
Logics in General
6
Atomic sentences
E.g.,
Brother(John, Richard),
Length(LeftLegOf(Richard),
Length(LeftLegOf(John)))
Complex sentences
E.g. Sibling(KingJohn,Richard) ⇒
Sibling(Richard,KingJohn)
>(1,2) ∨ ≤ (1,2)
>(1,2) ∧ ¬ >(1,2)
8
Truth in first-order logic
Sentences are true with respect to a model and an
interpretation
10
Models for FOL
11
Quantifiers
12
Universal quantification
∀<variables> <sentence>
Everyone at IUT is smart:
∀x At(x, IUT) ⇒ Smart(x)
∀x P is true in a model m iff P is true with x being each
possible object in the model
Roughly speaking, equivalent to the conjunction of
instantiations of P
At(Faisal, IUT) ⇒ Smart(Faisal)
∧ At(Musa, IUT) ⇒ Smart(Musa)
∧ At(IUT, IUT) ⇒ Smart(IUT)
∧ ...
13
14
Existential quantification
∃<variables> <sentence>
Someone at IUT is smart:
∃x At(x, IUT) ∧ Smart(x)
∃x P is true in a model m iff P is true with x being
some possible object in the model
Roughly speaking, equivalent to the disjunction of
instantiations of P
At(Faisal, IUT) ∧ Smart(Faisal)
∨ At(Musa, IUT) ∧ Smart(Musa)
∨ At(IUT, IUT) ∧ Smart(IUT)
∨ ...
15
16
Properties of quantifiers
∀x ∀y is the same as ∀y ∀x
∃x ∃y is the same as ∃y ∃x
17
Equality
term1 = term2
is true under a given interpretation if and
only if term1 and term2 refer to the same
object
– Father(John) = Henry
18
Using FOL
Assertions:
Sentences are added to a knowledge base using TELL.
Example: we can assert that John is a king and kings
are persons:
TELL(KB, King(John)).
TELL(KB, ∀x King(x) ⇒ Person(x)).
Queries:
We can ask questions to knowledge base using ask.
Example:
ASK(KB, King(John)). return true
ASK(KB, Person(x)). returns substitution/binding list {x/john}
19
……….
20
The set domain
One possible set of axioms:
21
22
Knowledge base for the wumpus world
Perception:
– ∀t, s, g, m, c Percept([s, Breeze, g, m, c], t) ⇒ Breeze(t)
– ∀t, s, g, m, c Percept([s, b, Glitter, m, c], t) ⇒ Glitter(t)
‘Reflex’ behavior:
– ∀t Glitter(t) ⇒ BestAction(Grab,t)
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]}
Properties of locations:
∀s,t At(Agent,s,t) ∧ Smelt(t) ⇒ Smelly(s)
∀s,t At(Agent,s,t) ∧ Breeze(t) ⇒ Breezy(s)
23
24
Knowledge engineering in FOL
Knowledge Engineering: Process of knowledge based
construction.
Knowledge Engineer: Investigates a particular domain, learns the
important concepts in the domain, and creates a formal
representation of the objects and relations in the domain.
Steps:
1. Identify the task (what will the KB be used for)
2. Assemble the relevant knowledge
Knowledge acquisition.
3. Decide on a vocabulary of predicates, functions, and constants
Translate domain-level knowledge into logic-level names.
4. Encode general knowledge about the domain
define axioms
5. Encode a description of the specific problem instance
6. Pose queries to the inference procedure and get answers
7. Debug the knowledge base
25
26
The electronic circuits domain
Identify the task
– Does the circuit actually add properly? (circuit verification)
– If all the inputs are high, what is the output of gate A2?
Assemble the relevant knowledge
– Composed of wires and gates;
– Types of gates (AND, OR, XOR, NOT)
– Connections between terminals
– Irrelevant: size, shape, color, cost of gates
Decide on a vocabulary
Choose functions, predicates, and constants
– Gates are named with constants: X1, X2 …
– Type(X1) = XOR/AND/OR …
– First input terminal for gate X1 :In(1, X1)
– Connections: Connected(Out(1, X1), In(1, X2))
27
28
The electronic circuits domain
5. Encode the specific problem instance
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,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))
Connected(Out(1,O1),Out(2,C1)) Connected(In(3,C1),In(1,A2))
29
30
Summary
First-order logic:
– syntax: constants, functions, predicates, equality,
quantifiers.
– objects and relations are semantic primitives
31