Upload
debra-crawford
View
243
Download
4
Tags:
Embed Size (px)
Citation preview
Artificial Intelligence
First-Order Logic (FOL)
Outline of this Chapter
• The need for FOL?• What is a FOL?• Syntax and semantics of FOL• Using FOL
Pros and cons of propositional logic
Propositional logic is declarative:pieces of syntax correspond to facts.
Propositional logic has expressive power to deal with partial information, using disjunction & negation.– (unlike most data structures and databases)
Propositional logic is compositional: - the meaning of a sentence is a function of the meaning of its parts– 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 to describe an Env with many objects concisely– (unlike natural language- syntax & semantic of English make it
possible to describe the Env concisely.– E.g., cannot say "pits cause breezes in adjacent squares“
• except by writing a separate rule about B & P for each square.
First-order u logic (FOL)• FOL more expressive language than the PL.• FOL is a general-purpose representation language that is based
on an ontological commitment to the existence of objects & relations in the world.
• It builds on simple propositional logic by adding objects, predicates, variables and quantifiers.
• Whereas propositional logic assumes the world contains facts (can be T/F),
• FOL (like natural language) assumes the world contains– Objects: people, houses, numbers, colors, baseball games,
wars, …– Relations: brother of, bigger than, part of, comes between,
…– Properties: unary relation such as red, round– Functions: relations in which there is only 1 value for a giver
input. i.e. father of, best friend, plus, …
Example
• “One Plus Two Equals Three “
Objects: One, Two, Three
Relations: Equals Functions: Plus
• “Square neighboring the wumpus are smelly“
Objects: wumpus, square
Relations: neighboringProperty: smelly
Syntax and semantics
• In Propositional logic – every expression is a sentence
• In FOL = Sentences + Terms (which represents objects)
• Sentences - are built using quantifiers and predicate symbols
• Term : Logical expression that refers to an object
= function (term1,...,termn) or constant or variable. = Brother (Samir, Ali) Ali, x,y
Syntax of FOL: Basic elements
The basic syntactic elements of FOL are the symbols that stand for objects, relations & functions.
• Constants (stand for objects) Sarah, A, B,... • Predicates (stand for relation) Brother, Round,...• Functions (stand for function) FatherOf,...• Variables x, y, a, b,...• Connectives , , , , • Equality = • Quantifiers ,
Atomic sentences
• It is formed from a predicate symbol followed by a parenthesized list of terms.
• Atomic sentence = predicate (term1,...,termn) or term1 = term2
E.g. Sister (Mona, Manal)• They can have arguments that are complex terms
E.g. Married(FatherOf(Ali),Sister (Mona))
Complex sentences
• Complex sentences are made from atomic sentences using logical connectives
e.g. Sister(Mona,Alia) is true when Mona is not
the sister of Alia.– Older (Reem, 20) Younger(Reem, 20)
if Reem is older than 20, then she is not younger than 20.
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 forconstant symbols → objectspredicate symbols → relationsfunction symbols → functional relations
• An atomic sentence predicate(term1,...,termn) is trueiff the objects referred to by term1,...,termnare in the relation referred to by predicate
Truth Example
• Consider the interpretation in which– Sara Sara Ibrahim– Mona Mona Ibrahim– Sister the sisterhood relation
• Under this interpretation, Sister(Sara; Mona) is true just in case Sara Ibrahim and Mona Ibrahim are in the sisterhood relation in the model
Models for FOL: Example
A model containing 5 objects. These objects may be related in various ways:
• Binary relation – brother & on head
• Unary relations (properties) – person, crown & king
• Unary function – left leg
Quantification
• Quantification is a formula constructor that produces new formulas from old ones.
• Quantifier is a symbol- let us express properties of entire collections of objects, instead of listing the objects by name.
• In natural language- for all, for some; many, few, a lot, etc
• FOL contains 2 standard quantifiers:– Universal– existential
Universal quantification• <variables> <sentence>
e.g. All cats are mammals: x Cats(x) => Mammals(x), for all x, if x is a cat, then x is a
mammal• Universal quantification makes statements about every object.• Universal quantifiers often used with "implies" to form "rules.“
• Everyone at PSU is smart : x At(x, PSU) => Smart(x)• x P (any logical expression) is equivalent to the conjunction of
instantiations of P At( Sara, PSU) => Smart(Sara) At(Mary, PSU) => Smart(Mary) ...
• Typically, is the main connective with • Common mistake: using as the main connective with :
Existential quantification <variables> <sentence>• Existential quantification makes statements about some
object.
• Someone at PSU is smart: x At(x, PSU) Smart(x)
x P is equivalent to the disjunctions of instantiations of P
At( Sara, PSU) => Smart(Sara) At(Mary, PSU) => Smart(Mary)
...• Typically, is the main connective with
• Common mistake: using as the main connective with :
Properties of quantifiersTo express more complex sentences, use multiple quantifiers. x y is the same as y x x y is the same as y x
x y is not the same as y x x y Loves (x,y)
“For every person, there is someone that person loves” y x Loves(x,y)
“There is someone who is loved by every body”• Quantifier duality: each can be expressed using the other (&
are connected with each other through negation) x Likes(x,IceCream) x Likes(x,IceCream) x Likes (x, Cabbage) x Likes(x, Cabbage)The deMorgan rules for quantified and unquantified
sentences are as follows x P = x P P Q = (P V Q ) x P = x P (P Q) = P V Q x P = x P P Q = (P V Q )x P = x P P V Q = (P Q )
Equality
• term1 = term2 is true under a given
interpretation if and only if term1 and term2 refer to the same objecte.g. Mother(Mona) = Jenny
• The equality symbol can be used with negation to insist that two terms are not the same object.
e.g. Mona has at least 2 sisters. x,y Sister(Mona,x) Sister(Mona,y)
(x=y)
Examples1. All food are edible2. Brothers are siblings3. “Sibling" is symmetric relation ship (quantifiers
of the same type)4. One's mother is one's female parentSolutions:1. x food( x) => edible( x)2. x, y Brother(x, y) Sibling(x, y).3. x, y Sibling(x, y) Sibling(y, x).4. m, c Motherof(c) = m (Female(m)
Parent(m, c))
Interacting with FOL KBs
• To add sentences to a knowledge base KB, we would call TELL. Such sentences are called assertions.e.g. TELL (KB, Mother(Nora)) // assert that Nora is a Mother
TELL(KB, x Mother(x) Person (x)) // Mothers are persons
• To ask questions of the KB, we use ASK• Questions asked using ASK are called queries
e.g. ASK (KB, Mother(Nora))
In-class Activity• Abeer, Mona and linda belong to the champions
Club. – Every member of the club is either skier or a
mountain climber .– No mountain climber likes rain, and all skiers
like snow– linda dislikes whatever Abeer likes and likes
whatever Abeer dislikes– Abeer likes rain and snow
• Is there any member of the club who is climber but not skier?
• Translate this problem into FOL Sentences?
Solution
• S(x) means x is a skier• M(x) means x is a mountain climber• L(x,y) means x likes y
• The English sentences in the prev slide can be translated into the following FOL: x Clubmember(x) => S(x) V M (x)~ x M(x) L(x,rain) x S(x) => L(x,snow) y L(linda, y) <=> ~L(Abeer,y)L(Abeer, rain) ^L(Abeer,snow)
Summary
• FOL can be used as the representation language for a KB agent.
• FOL is more powerful than propositional logic• A possible world for FOL is defined by a set of :
– objects and relations are semantic primitives– syntax: constants, functions, predicates, equality,
quantifiers
• Complex sentences use connectives just like propositional logic, & quantified sentences allow the expression of general rules.
End of lecture