Gomes esfera publicapoliticaecomunicacaoemmudancaestruturaldaesferapub…
1 CS 4700: Foundations of Artificial Intelligence Carla P. Gomes Module: FOL (Reading R&N: Chapter...
-
Upload
allyson-whitehead -
Category
Documents
-
view
224 -
download
0
description
Transcript of 1 CS 4700: Foundations of Artificial Intelligence Carla P. Gomes Module: FOL (Reading R&N: Chapter...
1
CS 4700:Foundations of Artificial Intelligence
Carla P. [email protected]
Module: FOL
(Reading R&N: Chapter 8)
2
Pros and cons of propositional logic
Propositional logic is declarative its semantics is based on a truth relation between sentences and possible worlds Propositional logic allows partial/disjunctive/negated information
– (unlike most data structures and databases)Propositional logic is compositional:
– meaning of B1,1 P1,2 is derived from meaning of B1,1 and of P1,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•
•–
•–
•–
3
Consider a formula to represent the Pigeon Hole principle: (n+1) pigeons in n holes.
Pij – pigeon i goes in hole j Pij {0,1} i= 1, 2, …, n+1; j = 1, 2, …n
Each pigeon has to go in a hole:Starting with pigeon 1
P11 P12 … P1n
…Pn+1,1 Pn+1,2 … Pn+1,n
.
: Pigeon Hole Principle
4
PH
And
Two pigeons cannot go in the same holeP11 ~P21; P11 ~P31; … P11 ~Pn+1,1;
~P11 ~P21; ~P11 ~P31; … ~P11 ~Pn+1,1;
….~Pn+1,n ~P2,n; ~Pn+1,n ~P3n; … ~Pn+1,n ~Pn,n;
Resolution proofs of PH take exponentially many steps:Resolution proofs of inconsistency of PH require an exponential number of clauses, no matter in what order we resolve the clauses (Armin Haken 85).
Related to NP vs. Co-NP questions
5
Pigeon Hole:A more concise formulation
x y (x Pigeons) (y Holes) IN(x,y)
xx’y ( IN(x,y) IN(x’,y) x=x’)
xyy’ (IN(x,y) IN(x,y’) y=y’)
We have first-order logic with some set notation
Pigeons = {P1,P2,…, Pn+1)}Holes = {H1,H2, …, Hn}
6
First-order logic
Whereas propositional logic assumes the world contains facts, first-order logic (like natural language) assumes the world contains
– Objects: people, houses, numbers, colors, baseball games, wars, …– Relations: red, round, prime, brother of, bigger than, part of,
comes between, …– Functions: father of, best friend, one more than, plus, …––
For finite domains, essentially equivalent to propositional logic….but more concise.Often pays off to propositionalize …(more later)
We’ll see how key properties from PL carry over: sound and complete proof theory;Sound and refutation complete resolution.
7
Syntax of FOL: Basic elements
Constants KingJohn, 2, CornellUniversity,... Predicates Brother, >,...Functions Sqrt, LeftLegOf,...Variables x, y, a, b,...Connectives , , , , Equality = Quantifiers ,
8
Atomic sentences
A term is a logical expression that refers to an object
Atomic sentence = predicate (term1,...,termn) or term1 = term2
Term = function (term1,...,termn) or constant or variable
Examples of atomic sentences: Brother(KingJohn,RichardTheLionheart)> (Length(LeftLegOf(Richard)), Length(LeftLegOf(KingJohn))
9
Complex sentences
Complex sentences are made from atomic sentences using connectivesS, S1 S2, S1 S2, S1 S2, S1 S2,
E.g. Sibling(KingJohn,Richard) Sibling(Richard,KingJohn)
>(1,2) ≤ (1,2)
>(1,2) >(1,2)
10
Syntax of FOL
Sentence AtomicSentence| (Sentence Connective Sentence)| Quantifier Variable, …. Sentence| Sentence
AtomicSentence Predicate(Term) | Term=Term
Term Function(Term)| Constant| Variable
Connective |||Quantifiers |Constant A | X1 | John | …Variable a | x | s | …Predicate Before | Greater | Raining |…Function MotherOf | SqrtOf |…
11
Truth in first-order logic
Sentences are true with respect to a world and an interpretation
A world contains objects (domain elements) and relations among them
Interpretation associatesconstant symbols → objectspredicate symbols → relationsfunction symbols → functional relations
An atomic sentence predicate(term1,...,termn) is trueiff the objects referred to by term1,...,termn
are in the relation referred to by predicate
–
12
Models for FOL: Example
World with five objects:•Richard the LionHeart, king of England (1189-1199);•Evil King John, Richard’s brother (1199-1215);•The left legs of Richard and John•A crown
Binary relation
Unary relations (or properties)
functions LeftLeg(Richard)
x King(x) Greedy(x) Evil(x)King(John)Brother(Richard,John)
13
Semantics:Universal quantification
<variables> <sentence>
(x) P(x)
it is true in an interpretation iif P(x) is true for all the values in the domain of x i.e., the universe of discourse
Everyone at Cornell is smart:x At(x,Cornell) Smart(x)
Roughly speaking, equivalent to the conjunction of instantiations of PAt(Mary,Cornell) Smart(Mary) At(Richard,Cornell) Smart(Richard) At(John,Cornell) Smart(John) ...
•
14
A common mistake to avoid
Typically, is the main connective with Common mistake: using as the main connective with :
x[ At(x,Cornell) Smart(x)]means “Everyone is at Cornell and everyone is smart”
15
Existential quantification
<variables> <sentence>
(x)P(x) it is true in an interpretation m iff there exists an element x in the universe of discourse such that P(x) is true.
Someone at Cornell is smart:x At(x,Cornell) Smart(x)
Roughly speaking, equivalent to the disjunction of instantiations of PAt(John,Cornell) Smart(John)
At(Mary,Cornell) Smart(Mary) At(Richard,Cornell) Smart(Richard) ...
•
16
Another common mistake to avoid
Typically, is the main connective with
Common mistake: using as the main connective with :x At(x,Cornell) Smart(x)
is true if there is anyone who is not at Cornell!•
17
More on Quantifiers
Loves(x,y) - x loves y
x y is the same as y xx y is the same as y x
x y is not the same as y xx 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 otherx Likes(x,IceCream) x Likes(x,IceCream)x Likes(x,Broccoli) x Likes(x,Broccoli)
(see additional hidden slides for recapitulation of this material)
26
Equality
term1 = term2 is true under a given interpretation if and only if term1 and term2 refer to the same object
E.g., definition of 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)]•
30
Interacting with FOL KBs
Sentences are added to the knowledge base using TELL (as in PL), assertions.For example, we can assert
TELL(KB,King(John)).TELL(KB,x King(x) Person(x))We can ask:Ask (KB, x Person(x))
The answer to a query with existential variables if true returns a substitution or binding list, which is a set of variable term:
{x/John};
if there is more than one possible answer, a list of substitutions can be returned.
31
Interacting with FOL KBs
Given a sentence S and a substitution σ,Sσ denotes the result of plugging σ into S; e.g.,
S = Smarter(x,y)σ = {x/Hillary,y/Bill}Sσ = Smarter(Hillary,Bill)
Suppose a wumpus-world agent is using an FOL KB and perceives a smell and a breeze (but no glitter) at t=5:
Tell(KB,Percept([Smell,Breeze,None],5))Ask(KB,a BestAction(a,5))
I.e., does the KB entail some best action at t=5?
Answer: Yes, {a/Shoot} ← substitution (binding list)
Ask(KB,S) returns some/all σ such that KB╞ σ
•
»•
»
32
Knowledge engineering in FOL
1. Identify the task2. Assemble the relevant knowledge3. Decide on a vocabulary of predicates, functions, and
constants4. Encode general knowledge about the domain5. Encode a description of the specific problem instance6. Pose queries to the inference procedure and get
answers7. Debug the knowledge base8.9.10.11.12.13.
The digital circuit domain
One-bit full adder
Input bitsto be added
Carry bit
XOR gates
AND gates OR gate
Sum
Carry bit for next adder
34
The electronic circuit domain
One-bit full adder
01
1
1 0
0
11
35
The electronic circuit domain
1 - Identify the task– Does the circuit actually add properly? (circuit verification)– Goal: analyze the design to see if it matches specification.
2 - Assemble the relevant knowledge– Talk about circuits, gates, terminals, and signals: e.g., we use constants
(X1, X2, etc) for refering the gates; Types of gates (AND, OR, XOR, NOT)
– Irrelevant: size, shape, color, cost of gates3 - Decide on a vocabulary
Constant symbols: X1, X2, …– Alternatives:
Type(X1) = XOR (note: XOR constant…)Type(X1, XOR)XOR(X1)
•–
•––
•–
Semantics of function alreadyguarantees that gates have only one type
36
Gates or circuits can have one or more input terminals and one or more output terminals.
E.g. the function In(1,X1) denotes the first input terminal for gate X1.
Connectivity between gates can be represented by a predicate:Connected(Out(1,X1),In(1,X2)
Signal has to be on or off –Signal(t) this function takes terminal as an argument and returns the signal value for that terminal.Two constants – 1 and 0. Note: We could use a unary predicate On(t); However, this would make it difficult to ask the
question – what are the possible values of the signals at the output terminals of circuit C!?
See page 263-264 for full description of vocabulary.
The electronic circuit domain
37
The electronic circuit domain
4- Encode general knowledge of the domain
• If two terminals are connected they have the same signal t1,t2 Connected(t1, t2) Signal(t1) = Signal(t2)
• Connected is a commutative predicate t1,t2 Connected(t1, t2) Connected(t2, t1)
• The signal at every terminal is either 1 or 0
t Signal(t) = 1 Signal(t) = 0– 1 ≠ 0
––
38
The electronic circuit domain
An OR gate’s output is 1 iif any of its inputs is 1 g Type(g) = OR Signal(Out(1,g)) = 1
n Signal(In(n,g)) = 1 An AND gate’s output is 0 iif any of its inputs is 0
g Type(g) = AND Signal(Out(1,g)) = 0 n Signal(In(n,g)) = 0
An XOR gate’s output is 1 iif its inputs are different
g Type(g) = XOR Signal(Out(1,g)) = 1 Signal(In(1,g)) ≠ Signal(In(2,g))
A NOT gate’s output is different from its input
g Type(g) = NOT Signal(Out(1,g)) ≠ Signal(In(1,g))–––
39
The electronic circuit domain
5 - Encode the specific problem instanceType(X1) = XOR Type(X2) = XORType(A1) = AND Type(A2) = ANDType(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,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))
40
The electronic circuit domain
6 - Pose queries to the inference procedureWhat are the possible sets of values of the input of the adder circuit that
lead to a signal of 0 for the sum output bit and a value of 1 for the carry output terminal?
i1,i2,i3 Signal(In(1,C1)) = i1 Signal(In(2,C1)) = i2 Signal(In(3,C1)) = i3 Signal(Out(1,C1)) = 0 Signal(Out(2,C1)) = 1
Answer: (i1 = 1; i2 = 1; i3 = 0) or ((i1 = 1; i2 = 0; i3 = 1) or (i1 = 0; i2 = 1; i3 = 0) What are the possible sets of values of all the terminals of the adder
circuit? i1,i2,i3,o1,o2 Signal(In(1,C1)) = i1 Signal(In(2,C1)) = i2 Signal(In(3,C1)) = i3 Signal(Out(1,C1)) = o1 Signal(Out(2,C1)) = o2
•–
41
The electronic circuit domain
7 - Debug the knowledge baseMay have omitted assertions like 1 ≠ 0–
•
What is the advantage over simulation?
Pentium bug…
42
Summary
First-order logic:– objects and relations are semantic primitives– syntax: constants, functions, predicates, equality, quantifiers
Increased expressive power!
But of course at a cost of increased complexity in general–