0% found this document useful (0 votes)
49 views25 pages

Knowledge Representation Using FOL Inference in FOL

- First-order logic is a way to represent knowledge that extends propositional logic by allowing predicates, functions, and quantifiers. - It includes objects, relations between objects, and functions. Sentences can be atomic, complex, or include quantifiers. - Quantifiers like ∀ and ∃ are used to express statements about all or some objects. Inference rules like universal instantiation and existential instantiation allow deducing new facts from existing knowledge expressed in first-order logic.

Uploaded by

Variable 14
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views25 pages

Knowledge Representation Using FOL Inference in FOL

- First-order logic is a way to represent knowledge that extends propositional logic by allowing predicates, functions, and quantifiers. - It includes objects, relations between objects, and functions. Sentences can be atomic, complex, or include quantifiers. - Quantifiers like ∀ and ∃ are used to express statements about all or some objects. Inference rules like universal instantiation and existential instantiation allow deducing new facts from existing knowledge expressed in first-order logic.

Uploaded by

Variable 14
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

MCSE601L - ARTIFICIAL I NTELLIGENCE

12/7/2022 MCSE601L-AI by Dr.Siva Sankari S 1


Representing Knowledge using First Order Logic

12/7/2022 MCSE601L-AI by Dr.Siva Sankari S 2


First Order Logic

• First-order logic is another way of knowledge representation


in artificial intelligence.
• It is an extension to propositional logic.
• FOL is sufficiently expressive to represent the natural
language statements in a concise way.
• First-order logic is also known as Predicate logic or First-
order predicate logic.
• First-order logic is a powerful language that develops
information about the objects in a more easy way and can
also express the relationship between those objects.

12/7/2022 MCSE601L-AI by Dr.Siva Sankari S 3


First Order Logic
• First-order logic (like natural language) does not only assume that
the world contains facts like propositional logic.
• It also assumes the following things in the world:
• Objects: A, B, people, numbers, colors, wars, theories, squares,
pits, wumpus, ......
• Relations:
• It can be unary relation such as: red, round, is adjacent,
• n-any relation such as: the sister of, brother of, has color, comes
between
• Function: Father of, best friend, third inning of, end of, ......
• As a natural language, first-order logic also has two main parts:
• Syntax
• Semantics
12/7/2022 MCSE601L-AI by Dr.Siva Sankari S 4
First Order Logic

• Elements of FOL

Constant 1, 2, A, John, Mumbai, cat,....


Variables x, y, z, a, b,....
Predicates Brother, Father, >,....
Function sqrt, LeftLegOf, ....
Connectives ∧, ∨, ¬, ⇒, ⇔
Equality ==
Quantifier ∀, ∃

12/7/2022 MCSE601L-AI by Dr.Siva Sankari S 5


First Order Logic
Types of sentences
• Atomic sentences:
• Atomic sentences are the most basic sentences of first-order logic.
These sentences are formed from a predicate symbol followed by a
parenthesis with a sequence of terms.
• We can represent atomic sentences as
Predicate (term1, term2, ......, term n).
Example:
• Ravi and Ajay are brothers: => Brothers(Ravi, Ajay).
Choo is a cat: => cat (Choo).

• Complex Sentences:
• Complex sentences are made by combining atomic sentences using
connectives.
12/7/2022 MCSE601L-AI by Dr.Siva Sankari S 6
First Order Logic

Quantifiers in First-order logic:


• A quantifier is a language element which generates quantification, and
quantification specifies the quantity of specimen in the universe of
discourse.
• These are the symbols that permit to determine or identify the range
and scope of the variable in the logical expression.
• There are two types of quantifier:
• Universal Quantifier, (for all, everyone, everything)
• Existential quantifier, (for some, at least one).

12/7/2022 MCSE601L-AI by Dr.Siva Sankari S 7


First Order Logic
Universal Quantifier:
• Universal quantifier is a symbol of logical representation, which
specifies that the statement within its range is true for everything or
every instance of a particular thing.
• The Universal quantifier is represented by a symbol ∀, which
resembles an inverted A.
• If x is a variable, then ∀x is read as:
• For all x
• For each x
• For every x.
Example:
• All man drink coffee.

12/7/2022 MCSE601L-AI by Dr.Siva Sankari S 8


First Order Logic

It will be read as:


There are all x where x is a man who drink coffee.
12/7/2022 MCSE601L-AI by Dr.Siva Sankari S 9
First Order Logic
Existential Quantifier:
• Existential quantifiers are the type of quantifiers, which express that
the statement within its scope is true for at least one instance of
something.
• It is denoted by the logical operator ∃, which resembles as inverted E.
• When it is used with a predicate variable then it is called as an
existential quantifier.
• If x is a variable, then existential quantifier will be ∃x or ∃(x).
• It will be read as:
• There exists a 'x.'
• For some 'x.'
• For at least one 'x.'
12/7/2022 MCSE601L-AI by Dr.Siva Sankari S 10
First Order Logic

It will be read as: There are some x


12/7/2022 where x is a boy who is intelligent. 11
First Order Logic

•The main connective for universal quantifier ∀ is implication →.


•The main connective for existential quantifier ∃ is and ∧.
•In universal quantifier, ∀x∀y is similar to ∀y∀x.
•In Existential quantifier, ∃x∃y is similar to ∃y∃x.
•∃x∀y is not similar to ∀y∃x.

•Ex:
•All birds fly
•Every man respects his parent
•Not all students like both Mathematics and Science

12/7/2022 MCSE601L-AI by Dr.Siva Sankari S 12


First Order Logic

•Ex:
•All birds fly : ∀x bird(x) →fly(x).
•Every man respects his parent : ∀x man(x) → respects (x, parent).
•Not all students like both Mathematics and Science :
¬∀ (x) [ student(x) → like(x, Mathematics) ∧ like(x, Science)]

12/7/2022 MCSE601L-AI by Dr.Siva Sankari S 13


First Order Logic

• Every gardener likes the sun.


(∀x) gardener(x) => likes(x,Sun)

• You can fool some of the people all of the time.


(Ex)(∀t) (person(x) ^ time(t)) => can-fool(x,t)

• You can fool all of the people some of the time.


(∀x)(Et) (person(x) ^ time(t) => can-fool(x,t)

• All purple mushrooms are poisonous.


(∀x) (mushroom(x) ^ purple(x)) => poisonous(x)
12/7/2022 MCSE601L-AI by Dr.Siva Sankari S 14
Inference in First Order Logic (FOL)

12/7/2022 MCSE601L-AI by Dr.Siva Sankari S 15


Inference in First Order Logic
• Inference in First-Order Logic is used to deduce new facts or sentences
from existing sentences.
Basic terminologies used in FOL
• First-Order logic does not only use predicate and terms for making
atomic sentences but also uses another way, which is equality in FOL.
• For this, we can use equality symbols which specify that the two terms
refer to the same object.
• Example: Brother (John) = Smith.
• As in the above example, the object referred by the Brother (John) is
similar to the object referred by Smith.
• The equality symbol can also be used with negation to represent that
two terms are not the same objects.
• Example:
12/7/2022
¬(x=y) which is equivalent to x ≠y. 16
Inference in First Order Logic
•Inference Rules:
A byte contains 8 bits
All bytes contain 8 bits
• Universal Generalization
Every person like ice-cream
John likes ice-cream
• Universal Instantiation

Some one wear crown on his head


• Existential Instantiation KingJohn wear crown on his head

• Existential Introduction
Priyanka got good marks in English
Someone got good marks in english

12/7/2022 MCSE601L-AI by Dr.Siva Sankari S 17


Inference in First Order Logic
Universal Generalization
 Universal generalization is a valid inference rule which states
that if premise P(c) is true for any arbitrary element c in the
universe of discourse, then we can have a conclusion as ∀ x P(x)

 This rule can be used if we want to show that every element has
a similar property
 In this rule, x must not appear as a free variable.
Example: Let's represent, P(c): "A byte contains 8 bits",
so for ∀ x P(x) "All bytes contain 8 bits.",
it will also be true.
12/7/2022 MCSE601L-AI by Dr.Siva Sankari S 18
Inference in First Order Logic
Universal Instantiation
• Universal instantiation is also called as universal elimination or UI is a
valid inference rule. It can be applied multiple times to add new
sentences.
• The new KB is logically equivalent to the previous KB.
• As per UI, we can infer any sentence obtained by substituting a ground
term for the variable.
• The UI rule state that we can infer any sentence P(c) by substituting a
ground term c (a constant within domain x) from ∀ x P(x) for any
object in the universe of discourse.

Example:
• IF "Every person like ice-cream"=> ∀x P(x)
so we can infer that "John likes ice-cream" => P(c)
12/7/2022 19
Inference in First Order Logic

∀x king(x) ∧ greedy (x) → Evil (x)


we can infer any of the following statements using Universal Instantiation:
1. King(John) ∧ Greedy (John) → Evil (John),
2. King(Richard) ∧ Greedy (Richard) → Evil (Richard),
3. King(Father(John)) ∧ Greedy (Father(John)) → Evil (Father(John))

12/7/2022 MCSE601L-AI by Dr.Siva Sankari S 20


Inference in First Order Logic
Existential Instantiation
• Existential instantiation is also called as Existential Elimination, which is a
valid inference rule in first-order logic.
• It can be applied only once to replace the existential sentence.
• The new KB is not logically equivalent to old KB, but it will be satisfiable if
old KB was satisfiable.
• This rule states that one can infer P(c) from the formula given in the form of ∃x
P(x) for a new constant symbol c.
• The restriction with this rule is that c used in the rule must be a new term for
which P(c ) is true.

Example:
∃x Crown(x) ∧ OnHead(x, John)
can infer:
Crown(K) ∧ OnHead( K, John), as long as K does not appear in the knowledge
12/7/2022 21
base
Inference in First Order Logic
Existential Introduction
• An existential introduction is also known as an existential
generalization, which is a valid inference rule in first-order
logic
• This rule states that if there is some element c in the universe
of discourse which has a property P, then we can infer that
there exists something in the universe which has the property P

Example:
Priyanka got good marks in English
Can infer someone got good marks in English
12/7/2022 MCSE601L-AI by Dr.Siva Sankari S 22
Inference in First Order Logic
Paramodulation
From P(a) and a=b derive P(b)
Generalized Modus Ponens
P implies Q and P is asserted to be true, therefore Q
must be True."
According to Modus Ponens,
for atomic sentences pi, pi', q.
Where there is a substitution θ such that
SUBST (θ, pi',) = SUBST(θ, pi)
12/7/2022 MCSE601L-AI by Dr.Siva Sankari S 23
Inference in First Order Logic

• Generalized Modus Ponens (GMP)


• Combines And-Introduction, Universal-Elimination, and Modus Ponens
• E.g.:
from P(c), Q(c), and (Ax)(P(x) ^ Q(x)) => R(x), derive R(c)

• In general, given atomic sentences P1, P2, ..., PN, and


• implication sentence (Q1 ^ Q2 ^ ... ^ QN) => R, where Q1, ..., QN and R
are atomic sentences, and
• subst(Theta, Pi) = subst(Theta, Qi) for i=1,...,N,
• derive new sentence: subst(Theta, R)
• Substitutions are made in left-to-right order in the list.
• E.g.:
subst({x/IceCream, y/Ziggy}, eats(y,x)) = eats(Ziggy,
IceCream)
12/7/2022 MCSE601L-AI by Dr.Siva Sankari S 24
Inference in First Order Logic

• Generalized Modus Ponens (GMP) is complete for KBs


containing only Horn clauses

• A Horn clause is a sentence of the form:


(∀x) (P1(x) ^ P2(x) ^ ... ^ Pn(x)) => Q(x)

12/7/2022 MCSE601L-AI by Dr.Siva Sankari S 25

You might also like