Predicate (First Order) Logic

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 23

Predicate (First Order) Logic

First Order Logic (FOL)


• PL isn’t powerful enough as a general KR language.
–Impossible to make general statements.
Example:
1.all students sit for exams
2.if any student sits for an exam, he either pass or fail

• FOL is a more powerful form of logic


–Almost any English sentence may be represented in first-
order predicate calculus
Example:
(1) John’s mother is married to John’s father
married(father(john), mother(john))
(2) Potato is good and Potato is a kind of food
good(Potato)  is(Potato, food)
good(Potato)  food(Potato)
(3) All food are edible
X food( X)  edible( X)
First Order Logic (FOL)
•FOL (like natural language) assumes the world
contains
–Objects: that have attributes/properties
people, house, number, color, baseball-game, war, …
–Relations: between objects:
brother-of, bigger-than, part-of, …
–Properties: distinguishing features.
color (red), shape (round), size (length), …
–Functions: returns value for a given object
father-of, best-friend, cosine, plus, …
•Almost any fact refer to objects & relations/properties
Example: King John ruled England in 1200
Objects: John, England, 1200
Relations: ruled
Properties: king
Syntax of FOL
• Constants symbol
–names (like Jonas, kebede, …), numbers (like 1, 2, … n), ...
• Predicates:
–Predicates used to relate one object with another. E.g.
brother, >,...
• Functions: Returns value (Sqrt, mother-of,...)
• Variables: x, y, a, b,...
–Important to increase generalization capability of KB
• Connectives:
–retains connectives used in PL (, , , , )
• Equality: =
• Quantifiers:
–Quantifiers specify whether all or some objects satisfy
properties or relations between objects
–Two standard quantifiers: Universal ( for all, for every) and
Existential ( there exists, some)
Universal quantification
• Universal Quantifiers: makes statements about every object
<variables> <sentence>
–Everyone at AAU is smart:
x At(x,AAU)  Smart(x)
–All cats are mammals:
x cat(x)  mammal(x)

x sentence P is true iff P is true with x being each possible


object in the given universe
–The above statement is equivalent to the conjunction
At(Jonas, AAU)  Smart(Jonas) 
At(Rawad, AAU)  Smart(Rawad) 
...
• A common mistake to avoid
–Typically,  is the main connective with 
–Common mistake: the use of  as the main connective with :
x At(x,AAU)  Smart(x) is true if “Everyone is at AAU & everyone is smart”
Existential quantification
•Makes statements about some objects in the universe
<variables> <sentence>
–Someone at AAU is smart:
x At(x,AAU)  Smart(x)
–Spot has a sister who is a cat:
x sister(spot,x)  cat(x)
x sentence P is true iff P is true with x being some
possible objects
–The above statement is equivalent to the disjunction
At(Jonas, AAU)  Smart(Jonas) 
At(Alemu, AAU)  Smart(Alemu) 
…..
•Common mistake to avoid
–Typically,  is the main connective with 
–Common mistake: using  as the main connective with :
x At(x,AAU)  Smart(x) is true if there is anyone who is not at AAU
Nested quantifiers
x,y parent(x,y)  child(y,x)
–for all x and y, if x is the parent of y then y is the child of x.
x y Loves(x,y)
–There is a person who loves everyone in the given world
y x Loves(x,y)
–Everyone in the given universe is loved by at least one person
Properties of 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
• Quantifier duality: each can be expressed using the other,
using negation ()
x Likes(x,icecream) x Likes(x,icecream)
–Everyone likes ice cream means that there is nobody who dislikes ice
cream
x Likes(x,cake) x Likes(x,cake)
–There is someone who likes cake means that there is no one who
dislikes cake
Equivalence: Demorgans rule for quantified sentence
X p(X) = X  p(X)
X p(X) = X  p(X)
X p(X) = Y p(Y)
X p(X) = Y p(Y)
X (p(X)  q(X)) = X p(X)  Y q(Y)
X (p(X)  q(X)) = X p(X)  Y q(Y)

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)]
Translating English to FOL
• Every gardener likes the sun.
(x) gardener(x) => likes(x,Sun)
• Not Every gardener likes the sun.
~((x) gardener(x) => likes(x,Sun))
• You can fool some of the people all of the time.
(x)(t) person(x) ^ time(t) => can-be-fooled(x,t)
• You can fool all of the people some of the time.
(x)(t) person(x) ^ time(t) => can-be-fooled(x,t)
(the time people are fooled may be different)
• You can fool all of the people at some time.
(t)(x) person(x) ^ time(t) => can-be-fooled(x,t)
(all people are fooled at the same time)
• You can not fool all of the people all of the time.
~((x)(t) person(x) ^ time(t) => can-be-fooled(x,t))
• Everyone is younger than his father
(x) person(x) => younger(x, father(x))
Translating English to FOL
• All purple mushrooms are poisonous.
(x) (mushroom(x) ^ purple(x)) => poisonous(x)
• No purple mushroom is poisonous.
~(x) purple(x) ^ mushroom(x) ^ poisonous(x)
(x) (mushroom(x) ^ purple(x)) => ~poisonous(x)
• There are exactly two purple mushrooms.
(x)(Ey) mushroom(x) ^ purple(x) ^ mushroom(y) ^ purple(y) ^ ~(x=y) ^
(z) (mushroom(z) ^ purple(z)) => ((x=z) v (y=z))
• Clinton is not tall.
~tall(Clinton)
• X is above Y if X is directly on top of Y or there is a
pile of one or more other objects directly on top of
one another starting with X and ending with Y.
(x)(y) above(x,y) <=> (on(x,y) v (z) (on(x,z) ^ above(z,y)))
Sentence structure
In FOL the basic unit is a predicate (argument/terms)
structure called sentence to represent facts.
• Terms refers to objects
Example: likes(muhe, chocolate); tall(fred)
–Terms or arguments can be any of: Constant symbol, such
as ‘muhe’, variable symbol, such as X , functions, such as
motherof(fred), father-of( father-of( john))
• A predicate is the one that says something about the
subject. E.g., The book is red
• Subject: color of the book, represented as: is-red(book)
• is-red: predicate, and book: argument
–Predicate also refers to a particular relation between objects
• Example: likes(X, richard)
friends(motherof(jonas), motherof(semu))
–A predicate statement takes the value true or false
Sentences
Atomic sentences: formed from a predicate symbol
followed by a parenthesized list of terms
Atomic sentence = predicate (term1,...,termn)
Example: Brother(John, Richard)
• Atomic sentences can have arguments that are complex terms
(e.g. term = function (term1,...,termn) )
Example: married(fatherof(Richard),motherof(John))
Complex sentences: complex sentences are made by
combining atomic sentences using connectives:
S, S1  S2, S1  S2, S1  S2, S1  S2,
Ex. likes(john, mary) V tall(mary)
tall(john) V handsome(john)
Sibling(John, Richard)  Sibling(Richard, John)
• Sentences can also be formed using quantifiers to indicate how
to treat variables:
– Universal quantifier: x lovely(x) - Everything is lovely.
– Existential quantifier: x lovely(x) - Something is lovely.
Semantics
•There is a precise meaning to expressions in predicate logic.
•Like in propositional logic, it is all about determining whether
something is true or false.
x P(x) means that P(x) must be true for every object x in the
domain of interest.
x P(x) means that P(x) must be true for at least one object x in
the domain of interest.
– So if we have a domain of interest consisting of just two people, john
and mary, and we know that tall(mary) and tall(john) are true,
we can say that x tall(x) is true.
•Atomic sentence is true if the relation referred by the
predicate holds b/n the objects referred by the arguments
brother(John, Richard)
•The truth value of complex sentences depends on logical
connectives used
older(John,30)  younger(John,30)
Inference in First Order Logic
• We saw inference rules for propositional logic
• These rules hold for first-order logic as well
• We, however, need additional inference rules to handle
1st order logic sentence with quantifiers

• We can define inference rules allowing us to say that if


certain things are true, certain other things are sure to be
true,
E.g. All men are mortal
Aristotle is a man
using logical inferences we can deduce that:
Aristotle is mortal
Sound Inference Rules
•Rules for PL apply to FOL as well.
–For example, Modus Ponens, And-Introduction, And-
Elimination, etc.
•New (sound) inference rules for use with quantifiers:
–Universal Elimination, Existential Introduction, Existential
Elimination
–By su bs t it ut in g p ar t ic u la r i nd iv i du al s f or th e
va r ia bl e . E .g . s ub s ti tu t e (x /sa m , y /c ak e ). T h en
li k es (x ,y ) = li k es (s a m ,ca k e )
•Universal Elimination: If x P(x) is true, then P(c) is
true, where c is a constant in the domain of x.
Example: x eats(x, IceCream).
Using the substitution (x/Ben) we can infer eats(Ben, Icecream).
–The variable symbol can be replaced by any constant symbol
or function symbol.
Sound Inference Rules
• Existential Introduction: If P(c) is true, then x
P(x) is inferred.
Example: eats(John, IceCream) we can infer x eats(x,
icecream).
– All instances of the given constant symbol are replaced
by the new variable symbol.

• Existential Elimination: From x P(x) infer P(c).


Example: x eats(Sol, x) infer eats(Sol, Cheese)
– Note that the variable x is replaced by a brand new
constant (like Cheese) that does not occur in this or any
other sentence in the Knowledge Base.
Proofs
• Sound inference: find α such that KB |= α
• Proof process is a search, operators are inference
rules
–It requires the operation of a series of inference rule to
come up with some conclusion
Example:
Bob is a buffalo. Pat is a pig. Buffaloes outrun pigs
Conclude: Bob outruns Pat
1. Buffalo(Bob)
2. Pig(Pat)
3. x,y Buffalo(x) ^ Pig(y) → Faster(x,y)
4. Buffalo(Bob) ^ Pig(Pat) And Introduction (1, 2)
5. Buffalo(Bob) ^ Pig(Pat) → Faster(Bob, Pat)
Universal Elimination (3, {x/Bob,y/Pat})
6. Faster(Bob,Pat) Modus Ponens (6, 7)
Conclude by Chaining
•Forward chaining
–Proofs start with the given axioms/premises in KB,
deriving new sentences using GMP until the
goal/query sentence is derived.
–This defines a forward chaining inference
procedure because it moves "forward" from the KB
to the goal.
•Backward chaining:
–Proofs start with the goal query, find implications that would
allow you to prove it, and then prove each of the
antecedents in the implication, continuing to work
"backwards" until we get to the axioms, which we know are
true.
Building a knowledge base
• We have seen that first order logic is a
powerful tool for knowledge representation
and reasoning.
• Logic does not offer guidance as to what
facts should be expressed, nor does it give
a guide on what vocabulary should be
used to express them.
• Process of building a knowledge base is
called knowledge engineering.
Knowledge engineer
• A person who
– Investigates a particular domain
– Determines what concepts are important in
the domain
– Creates a formal representation of objects
and relations in the domain
– Is trained in representation but is not an
expert
– Usually interviews the real experts to become
educated about the domain and to get the
required knowledge (process of knowledge
acquisition)
• Interviewing occurs before or along with
the process of creating formal
representation
• One does not become proficient
knowledge engineer just by studying the
syntax and semantics of a representation
language. It takes practice and exposure.
Criteria of good knowledge bases
• A knowledge base should be clear and correct
• The representation language in the knowledge
base should be expressive, concise,
unambiguous, and effective
• Relations should be relevant
• Knowledge base and inference procedure
should be clearly maintained/separated
• What ever language you use to represent the
knowledge, the inference procedure should
provide the same answer.
Common mistake in the knowledge base
• Common mistake is to choose predicate
names that are meaningful to the human
reader and to assume that the name would
be meaningful to the inference procedure
as well
• Eg. Pooh is a type of bear who has a very
small brain
BearofVerySmallbrain (pooh)

You might also like