First-Order Logic - jbnu.ac.krnlp.jbnu.ac.kr/~nash/AI/slides_brown/1410_6.pdf · 2017-09-12 ·...
Transcript of First-Order Logic - jbnu.ac.krnlp.jbnu.ac.kr/~nash/AI/slides_brown/1410_6.pdf · 2017-09-12 ·...
![Page 2: First-Order Logic - jbnu.ac.krnlp.jbnu.ac.kr/~nash/AI/slides_brown/1410_6.pdf · 2017-09-12 · First-Order Logic We can build up complex sentences using logical connectives, as in](https://reader034.fdocuments.in/reader034/viewer/2022050323/5f7d6b98d8f2eb296e2cd029/html5/thumbnails/2.jpg)
Knowledge
![Page 3: First-Order Logic - jbnu.ac.krnlp.jbnu.ac.kr/~nash/AI/slides_brown/1410_6.pdf · 2017-09-12 · First-Order Logic We can build up complex sentences using logical connectives, as in](https://reader034.fdocuments.in/reader034/viewer/2022050323/5f7d6b98d8f2eb296e2cd029/html5/thumbnails/3.jpg)
Representation and ReasoningRepresent knowledge about the world.
• Representation language.• Knowledge base.• Declarative - facts and rules.
Reason using that represented knowledge.• Often asking questions.• Inference procedure.• Heavily dependent on representation language.
![Page 4: First-Order Logic - jbnu.ac.krnlp.jbnu.ac.kr/~nash/AI/slides_brown/1410_6.pdf · 2017-09-12 · First-Order Logic We can build up complex sentences using logical connectives, as in](https://reader034.fdocuments.in/reader034/viewer/2022050323/5f7d6b98d8f2eb296e2cd029/html5/thumbnails/4.jpg)
Propositional LogicA proposition is:
• A possible fact about the world.• Either true or false. • We may not know which.• Can be combined with logical connectives.
![Page 5: First-Order Logic - jbnu.ac.krnlp.jbnu.ac.kr/~nash/AI/slides_brown/1410_6.pdf · 2017-09-12 · First-Order Logic We can build up complex sentences using logical connectives, as in](https://reader034.fdocuments.in/reader034/viewer/2022050323/5f7d6b98d8f2eb296e2cd029/html5/thumbnails/5.jpg)
![Page 6: First-Order Logic - jbnu.ac.krnlp.jbnu.ac.kr/~nash/AI/slides_brown/1410_6.pdf · 2017-09-12 · First-Order Logic We can build up complex sentences using logical connectives, as in](https://reader034.fdocuments.in/reader034/viewer/2022050323/5f7d6b98d8f2eb296e2cd029/html5/thumbnails/6.jpg)
First-Order LogicMore sophisticated representation language.
World can be described by:
objects
functionsColor(·)
predicates
Adjacent(·, ·)IsApple(·)
![Page 7: First-Order Logic - jbnu.ac.krnlp.jbnu.ac.kr/~nash/AI/slides_brown/1410_6.pdf · 2017-09-12 · First-Order Logic We can build up complex sentences using logical connectives, as in](https://reader034.fdocuments.in/reader034/viewer/2022050323/5f7d6b98d8f2eb296e2cd029/html5/thumbnails/7.jpg)
First-Order LogicObjects:
• A “thing in the world”• Apples• Red• The Internet• Team Edward• Reddit
• A name that references something.• Cf. a noun.
MyApple271
TheInternetEnnui
![Page 8: First-Order Logic - jbnu.ac.krnlp.jbnu.ac.kr/~nash/AI/slides_brown/1410_6.pdf · 2017-09-12 · First-Order Logic We can build up complex sentences using logical connectives, as in](https://reader034.fdocuments.in/reader034/viewer/2022050323/5f7d6b98d8f2eb296e2cd029/html5/thumbnails/8.jpg)
First-Order LogicFunctions:• Operator that maps object(s) to single object.
• • • • •
ColorOf(·)ObjectNextTo(·)SocialSecurityNumber(·)DateOfBirth(·)Spouse(·)
ColorOf(MyApple271) = Red
![Page 9: First-Order Logic - jbnu.ac.krnlp.jbnu.ac.kr/~nash/AI/slides_brown/1410_6.pdf · 2017-09-12 · First-Order Logic We can build up complex sentences using logical connectives, as in](https://reader034.fdocuments.in/reader034/viewer/2022050323/5f7d6b98d8f2eb296e2cd029/html5/thumbnails/9.jpg)
First-Order LogicPredicates - replaces proposition
Like a function, but returns True or False - holds or does not.• • • •
IsApple(·)ParentOf(·, ·)BiggerThan(·, ·)HasA(·, ·)
![Page 10: First-Order Logic - jbnu.ac.krnlp.jbnu.ac.kr/~nash/AI/slides_brown/1410_6.pdf · 2017-09-12 · First-Order Logic We can build up complex sentences using logical connectives, as in](https://reader034.fdocuments.in/reader034/viewer/2022050323/5f7d6b98d8f2eb296e2cd029/html5/thumbnails/10.jpg)
First-Order LogicWe can build up complex sentences using logical connectives, as in propositional logic:
• • • •
Predicates can appear where a propositions appear in propositional logic, but functions cannot.
Fruit(X) =) Sweet(X)Food(X) =) (Savory(X) _ Sweet(X))ParentOf(Bob,Alice) ^ ParentOf(Alice,Humphrey)Fruit(X) =) Tasty(X) _ (IsTomato(X) ^ ¬Tasty(X))
![Page 11: First-Order Logic - jbnu.ac.krnlp.jbnu.ac.kr/~nash/AI/slides_brown/1410_6.pdf · 2017-09-12 · First-Order Logic We can build up complex sentences using logical connectives, as in](https://reader034.fdocuments.in/reader034/viewer/2022050323/5f7d6b98d8f2eb296e2cd029/html5/thumbnails/11.jpg)
Models for First-Order LogicRecall from Propositional Logic!
A model is a formalization of a “world”:• Set the value of every variable in the KB to True or False.• 2n models possible for n propositions.
Proposition Value
Cold FalseRaining FalseCloudy FalseHot False
Proposition Value
Cold TrueRaining FalseCloudy FalseHot False
Proposition Value
Cold TrueRaining TrueCloudy TrueHot True
…
![Page 12: First-Order Logic - jbnu.ac.krnlp.jbnu.ac.kr/~nash/AI/slides_brown/1410_6.pdf · 2017-09-12 · First-Order Logic We can build up complex sentences using logical connectives, as in](https://reader034.fdocuments.in/reader034/viewer/2022050323/5f7d6b98d8f2eb296e2cd029/html5/thumbnails/12.jpg)
Models for First-Order LogicThe situation is much more complex for FOL.
A model in FOL consists of:• A set of objects.• A set of functions + values for all inputs.• A set of predicates + values for all inputs.
![Page 13: First-Order Logic - jbnu.ac.krnlp.jbnu.ac.kr/~nash/AI/slides_brown/1410_6.pdf · 2017-09-12 · First-Order Logic We can build up complex sentences using logical connectives, as in](https://reader034.fdocuments.in/reader034/viewer/2022050323/5f7d6b98d8f2eb296e2cd029/html5/thumbnails/13.jpg)
Models for First-Order LogicConsider:
Objects Predicates Functions
Example model:
OrangeApple
IsRed(·)HasV itaminC(·)
OppositeOf(·)
Predicate Argument ValueIsRed Orange FalseIsRed Apple True
HasV itaminC Orange TrueHasV itaminC Apple True
Function Argument Return
OppositeOf Orange AppleOpposite Apple Orange
![Page 14: First-Order Logic - jbnu.ac.krnlp.jbnu.ac.kr/~nash/AI/slides_brown/1410_6.pdf · 2017-09-12 · First-Order Logic We can build up complex sentences using logical connectives, as in](https://reader034.fdocuments.in/reader034/viewer/2022050323/5f7d6b98d8f2eb296e2cd029/html5/thumbnails/14.jpg)
Knowledge Bases in FOLA KB is now:
• A set of objects.• A set of predicates.• A set of functions.• A set of sentences using the predicates, functions, and
objects, and asserted to be true.
Objects Predicates FunctionsOrangeApple
IsRed(·)HasV itaminC(·)
OppositeOf(·)
IsRed(Apple)
HasV itaminC(Orange)
vocabulary
![Page 15: First-Order Logic - jbnu.ac.krnlp.jbnu.ac.kr/~nash/AI/slides_brown/1410_6.pdf · 2017-09-12 · First-Order Logic We can build up complex sentences using logical connectives, as in](https://reader034.fdocuments.in/reader034/viewer/2022050323/5f7d6b98d8f2eb296e2cd029/html5/thumbnails/15.jpg)
Knowledge Bases in FOLListing everything is tedious …
• Especially when general relationships hold.
We would like a way to say more general things about the world than explicitly listing truth values for each object.
…
![Page 16: First-Order Logic - jbnu.ac.krnlp.jbnu.ac.kr/~nash/AI/slides_brown/1410_6.pdf · 2017-09-12 · First-Order Logic We can build up complex sentences using logical connectives, as in](https://reader034.fdocuments.in/reader034/viewer/2022050323/5f7d6b98d8f2eb296e2cd029/html5/thumbnails/16.jpg)
QuantifiersNew weapon:
• Quantifiers.
Make generic statements about properties that hold for the entire collection of objects in our KB.
Natural way to say things like:• All fish have fins.• All books have pages.• There is a textbook about AI.
Key idea: variable + binding rule.
![Page 17: First-Order Logic - jbnu.ac.krnlp.jbnu.ac.kr/~nash/AI/slides_brown/1410_6.pdf · 2017-09-12 · First-Order Logic We can build up complex sentences using logical connectives, as in](https://reader034.fdocuments.in/reader034/viewer/2022050323/5f7d6b98d8f2eb296e2cd029/html5/thumbnails/17.jpg)
Existential QuantifiersThere exists object(s) such that a sentence holds.
9x, IsPresident(x)
“there exists”
temporary variable
sentenceusing variable
![Page 18: First-Order Logic - jbnu.ac.krnlp.jbnu.ac.kr/~nash/AI/slides_brown/1410_6.pdf · 2017-09-12 · First-Order Logic We can build up complex sentences using logical connectives, as in](https://reader034.fdocuments.in/reader034/viewer/2022050323/5f7d6b98d8f2eb296e2cd029/html5/thumbnails/18.jpg)
Existential QuantifiersExamples:
•
•
•
9x, Person(x) ^Name(x,George)
9x,Car(x) ^ ParkedIn(x,E23)
9x,Course(x) ^ Prerequisite(x,CS270)
![Page 19: First-Order Logic - jbnu.ac.krnlp.jbnu.ac.kr/~nash/AI/slides_brown/1410_6.pdf · 2017-09-12 · First-Order Logic We can build up complex sentences using logical connectives, as in](https://reader034.fdocuments.in/reader034/viewer/2022050323/5f7d6b98d8f2eb296e2cd029/html5/thumbnails/19.jpg)
Universal QuantifiersA sentence holds for all object(s).
“for every”sentence
using variable
temporary variable
8x,HasStudentNumber(x) =) Person(x)
![Page 20: First-Order Logic - jbnu.ac.krnlp.jbnu.ac.kr/~nash/AI/slides_brown/1410_6.pdf · 2017-09-12 · First-Order Logic We can build up complex sentences using logical connectives, as in](https://reader034.fdocuments.in/reader034/viewer/2022050323/5f7d6b98d8f2eb296e2cd029/html5/thumbnails/20.jpg)
Universal QuantifiersExamples
•
•
•
8x, Fruit(x) =) Tasty(x)
8x,Bird(x) =) Feathered(x)
8x,Book(x) ! HasAuthor(x)
![Page 21: First-Order Logic - jbnu.ac.krnlp.jbnu.ac.kr/~nash/AI/slides_brown/1410_6.pdf · 2017-09-12 · First-Order Logic We can build up complex sentences using logical connectives, as in](https://reader034.fdocuments.in/reader034/viewer/2022050323/5f7d6b98d8f2eb296e2cd029/html5/thumbnails/21.jpg)
QuantifiersDifference in strength:
• Universal quantifier is very strong.• So use weak sentence.
• Existential quantifier is very weak.• So use strong sentence.
8x,Bird(x) =) Feathered(x)
9x,Car(x) ^ ParkedIn(x,E23)
![Page 22: First-Order Logic - jbnu.ac.krnlp.jbnu.ac.kr/~nash/AI/slides_brown/1410_6.pdf · 2017-09-12 · First-Order Logic We can build up complex sentences using logical connectives, as in](https://reader034.fdocuments.in/reader034/viewer/2022050323/5f7d6b98d8f2eb296e2cd029/html5/thumbnails/22.jpg)
Compound Quantifiers
8x, 9y, Person(x) =) Name(x, y)
“every person has a name”
![Page 23: First-Order Logic - jbnu.ac.krnlp.jbnu.ac.kr/~nash/AI/slides_brown/1410_6.pdf · 2017-09-12 · First-Order Logic We can build up complex sentences using logical connectives, as in](https://reader034.fdocuments.in/reader034/viewer/2022050323/5f7d6b98d8f2eb296e2cd029/html5/thumbnails/23.jpg)
Common Pitfalls
8x,Bird(x) ^ Feathered(x)
![Page 24: First-Order Logic - jbnu.ac.krnlp.jbnu.ac.kr/~nash/AI/slides_brown/1410_6.pdf · 2017-09-12 · First-Order Logic We can build up complex sentences using logical connectives, as in](https://reader034.fdocuments.in/reader034/viewer/2022050323/5f7d6b98d8f2eb296e2cd029/html5/thumbnails/24.jpg)
Common Pitfalls
9x,Car(x) =) ParkedIn(x,E23)
![Page 25: First-Order Logic - jbnu.ac.krnlp.jbnu.ac.kr/~nash/AI/slides_brown/1410_6.pdf · 2017-09-12 · First-Order Logic We can build up complex sentences using logical connectives, as in](https://reader034.fdocuments.in/reader034/viewer/2022050323/5f7d6b98d8f2eb296e2cd029/html5/thumbnails/25.jpg)
Examples…
![Page 26: First-Order Logic - jbnu.ac.krnlp.jbnu.ac.kr/~nash/AI/slides_brown/1410_6.pdf · 2017-09-12 · First-Order Logic We can build up complex sentences using logical connectives, as in](https://reader034.fdocuments.in/reader034/viewer/2022050323/5f7d6b98d8f2eb296e2cd029/html5/thumbnails/26.jpg)
Inference in First-Order LogicGround term, or literal - an actual object:
vs. a variable:
If you have only ground terms, you can convert to a propositional representation and proceed from there.
MyApple12
x
IsTasty(Apple) : IsTastyApple
![Page 27: First-Order Logic - jbnu.ac.krnlp.jbnu.ac.kr/~nash/AI/slides_brown/1410_6.pdf · 2017-09-12 · First-Order Logic We can build up complex sentences using logical connectives, as in](https://reader034.fdocuments.in/reader034/viewer/2022050323/5f7d6b98d8f2eb296e2cd029/html5/thumbnails/27.jpg)
InstantiationGetting rid of variables: instantiate a variable to a literal.Universally quantified:
For every object in the KB, just write out the rule with the variables substituted.
8x, Fruit(x) =) Tasty(x) Fruit(Apple) =) Tasty(Apple)
Fruit(Orange) =) Tasty(Orange)
Fruit(MyCar) =) Tasty(MyCar)
Fruit(TheSky) =) Tasty(TheSky)
![Page 28: First-Order Logic - jbnu.ac.krnlp.jbnu.ac.kr/~nash/AI/slides_brown/1410_6.pdf · 2017-09-12 · First-Order Logic We can build up complex sentences using logical connectives, as in](https://reader034.fdocuments.in/reader034/viewer/2022050323/5f7d6b98d8f2eb296e2cd029/html5/thumbnails/28.jpg)
InstantiationExistentially quantified:
• Invent a new name (Skolem constant)
• Name cannot be one you’ve already used.• Rule can then be discarded.
9x,Car(x) ^ ParkedIn(x,E23)
Car(C) ^ ParkedIn(C,E23)
![Page 29: First-Order Logic - jbnu.ac.krnlp.jbnu.ac.kr/~nash/AI/slides_brown/1410_6.pdf · 2017-09-12 · First-Order Logic We can build up complex sentences using logical connectives, as in](https://reader034.fdocuments.in/reader034/viewer/2022050323/5f7d6b98d8f2eb296e2cd029/html5/thumbnails/29.jpg)
PROLOGPROgramming in LOGic (Colmerauer, 1970s)
• General-purpose AI programming language• Based on First-Order Logic• Declarative
• Use centered in Europe and Japan• Fifth-Generation Computer Project
• Some parts of Watson (pattern matching over NLP)• Often used as component of a system.