0% found this document useful (0 votes)
68 views51 pages

Knowledge Representation and Inference and Resolution Using First-Order Logic

This document discusses inference in first-order logic (FOL). It describes how FOL allows inferences to be made through rules like universal instantiation, existential instantiation, and generalized modus ponens. Resolution is introduced as a technique for theorem proving in FOL through refutation proofs. The key steps of resolution are outlined, including converting statements to conjunctive normal form and using a resolution graph with unification to deduce new facts. An example problem is provided to illustrate how resolution can be applied to prove a conclusion from given statements in FOL.

Uploaded by

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

Knowledge Representation and Inference and Resolution Using First-Order Logic

This document discusses inference in first-order logic (FOL). It describes how FOL allows inferences to be made through rules like universal instantiation, existential instantiation, and generalized modus ponens. Resolution is introduced as a technique for theorem proving in FOL through refutation proofs. The key steps of resolution are outlined, including converting statements to conjunctive normal form and using a resolution graph with unification to deduce new facts. An example problem is provided to illustrate how resolution can be applied to prove a conclusion from given statements in FOL.

Uploaded by

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

Knowledge Representation and

Inference and resolution using


First-Order Logic
Learning Objectives
• Difference FOL and PL
• Properties of FOL
• Inference in FOL
• Unification in FOL
• CNF in FOL
• Resolution in FOL
• Steps for Resolution in FOL

2
Inference using First-Order Logic
Inference Rules for FOL
• Inference means to find a conclusion based on the facts, information, and
evidence.
• In simple words, when we conclude the facts and figures to reach a particular
decision, that is called inference.
• In AI, the expert system or agent performs this task with the help of the inference
engine
• Inference rules for PL apply to FOL (eg Modus Ponens, And-Introduction, And-
Elimination, etc.) plus few more
• New (sound) inference rules for use with quantifiers:
– Universal Elimination
– Existential Introduction
– Existential Elimination
– Generalized Modus Ponens (GMP)
• Resolution
– Clause form (CNF in FOL)
– Unification (consistent variable substitution)
– Refutation resolution (proof by contradiction)
4
Rules of Inference in Artificial intelligence
Inference

In artificial intelligence, we need intelligent


computers which can create new logic from
old logic or by evidence, 

So generating the conclusions from


evidence and facts is termed as Inference.

5
Basic Inference rules:

Inference rules are the templates for generating valid arguments. Inference rules are
applied to derive proofs in artificial intelligence, and the proof is a sequence of the
conclusion that leads to the desired goal.

In inference rules, the implication among all the connectives plays an important role.
Following are some terminologies related to inference rules:

Basic Inference Rules


• Implication: It is one of the logical connectives which can be represented as P → Q. It
is a Boolean expression.

• Converse: The converse of implication, which means the right-hand side proposition


goes to the left-hand side and vice-versa. It can be written as Q → P.

• Contrapositive: The negation of converse is termed as contrapositive, and it can be


represented as ¬ Q → ¬ P.

• Inverse: The negation of implication is called inverse. It can be represented as ¬ P → ¬


Q.
6
7
8
Types of Inference rules:

9
10
11
12
13
14
15
16
Inference Rules for FOL
• Inference rules for PL apply to FOL as well (Modus
Ponens, And-Introduction, And-Elimination, etc.)
• New (sound) inference rules for use with quantifiers:
– Universal Elimination
– Existential Introduction
– Existential Elimination
– Generalized Modus Ponens (GMP)
• Resolution
– Clause form (CNF in FOL)
– Unification (consistent variable substitution)
– Refutation resolution (proof by contradiction)

17
Inference in First-Order Logic
Inference in First-Order Logic is used to deduce new facts or sentences from existing
sentences. Before understanding the FOL inference rule, let's understand some basic
terminologies used in FOL.

Substitution:
Substitution is a fundamental operation performed on terms and formulas. It occurs in all
inference systems in first-order logic. The substitution is complex in the presence of
quantifiers in FOL. If we write F[a/x], so it refers to substitute a constant "a" in place of
variable "x".
Note: First-order logic is capable of expressing facts about some or all objects in the
universe.
Equality:
23.2M
395
Hello Java Program for Beginners

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: ¬ (x=y) which is equivalent to x ≠y.
20
21
FOL inference rules for quantifier:
As propositional logic we also have inference rules in first-order logic, so following
are some basic inference rules in FOL:
o Universal Generalization
o Universal Instantiation
o Existential Instantiation
o Existential introduction
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.
Universal Instantiation:
o 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.
o The new KB is logically equivalent to the previous KB.
o As per UI, we can infer any sentence obtained by substituting a ground term for the
variable.

o 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: 1.
IF "Every person like ice-cream"=> ∀x P(x) so we can infer that
"John likes ice-cream" => P(c)
Example: 2.
Let's take a famous example,
"All kings who are greedy are Evil." So let our knowledge base contains this detail as in the form of
FOL:
∀x king(x) ∧ greedy (x) → Evil (x),
So from this information, we can infer any of the following statements using Universal Instantiation:
o King(John) ∧ Greedy (John) → Evil (John),
o King(Richard) ∧ Greedy (Richard) → Evil (Richard),
o King(Father(John)) ∧ Greedy (Father(John)) → Evil (Father(John)),
Existential Instantiation:
o Existential instantiation is also called as Existential Elimination, which is a valid inference
rule in first-order logic.
o It can be applied only once to replace the existential sentence.
o The new KB is not logically equivalent to old KB, but it will be satisfiable if old KB was
satisfiable.
o 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.
o The restriction with this rule is that c used in the rule must be a new term for which P(c ) is
true.

Example:
From the given sentence: ∃x Crown(x) ∧ OnHead(x, John),
So we can infer: Crown(K) ∧ OnHead( K, John), as long as K does not appear in the
knowledge base.
o The above used K is a constant symbol, which is called Skolem constant.
o The Existential instantiation is a special case of Skolemization process.
Existential introduction

o An existential introduction is also known as an existential generalization, which is a valid


inference rule in first-order logic.

o 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.

o Example: Let's say that,


"Priyanka got good marks in English."
"Therefore, someone got good marks in English."
Generalized Modus Ponens Rule:
For the inference process in FOL, we have a single inference rule which is called
Generalized Modus Ponens. It is lifted version of Modus ponens.
Generalized Modus Ponens can be summarized as, " 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), it can be represented as:

Example:
We will use this rule for Kings are evil, so we will find some x such that x is
king, and x is greedy so we can infer that x is evil.
 
Here let say, p1' is king(John)        p1 is king(x)  
p2' is Greedy(y)                       p2 is Greedy(x)  
θ is {x/John, y/John}                  q is evil(x)  
SUBST(θ,q).                                                        
 
Resolution in FOL
Resolution
Resolution is a theorem proving technique that proceeds by building refutation proofs,
i.e., proofs by contradictions. It was invented by a Mathematician John Alan Robinson
in the year 1965.

Resolution is used, if there are various statements are given, and we need to prove a
conclusion of those statements. Unification is a key concept in proofs by resolutions.
Resolution is a single inference rule which can efficiently operate on the conjunctive
normal form or clausal form.

Clause: Disjunction of literals (an atomic sentence) is called a clause. It is also known
as a unit clause.

Conjunctive Normal Form: A sentence represented as a conjunction of clauses is said


to be conjunctive normal form or CNF.
Steps for Resolution:

1. Conversion of facts into first-order logic.

2. Convert FOL statements into CNF

3. Negate the statement which needs to prove (proof by contradiction)

4. Draw resolution graph (unification).

To better understand all the above steps, we will take an example in which we will

apply resolution.
Example:
1.John likes all kind of food.
2.Apple and vegetable are food
3.Anything anyone eats and not killed is food.
4.Anil eats peanuts and still alive
5.Harry eats everything that Anil eats.
Prove by resolution that:
6.John likes peanuts.
Step-2: Conversion of FOL into CNF
In First order logic resolution, it is required to convert the FOL into CNF as CNF
form makes easier for resolution proofs.
35
• Eliminate existential instantiation quantifier by elimination.

In this step, we will eliminate existential quantifier ∃, and this process is known
as Skolemization.
But in this example problem since there is no existential quantifier so all the
statements will remain same in this step.
Step-3: Negate the statement to be proved

In this statement, we will apply negation to the conclusion statements, which will be
written as ¬likes(John, Peanuts)
Example
• https://
www.youtube.com/watch?v=C_iqWGOhvak&list=PLrjkTq
l3jnm_yol-ZK1QqPSn5YSg0NF9r&index=35

43
Conversion procedure
step 1: remove all “=>” and “<=>” operators
(using P => Q  ~P v Q and P <=> Q  P => Q ^ Q => P)
step 2: move all negation signs to individual predicates
(using de Morgan’s law)
step 3: remove all existential quantifiers y
case 1: y is not in the scope of any universally quantified variable,
then replace all occurrences of y by a skolem constant
case 2: if y is in scope of universally quantified variables x1, ... xi,
then replace all occurrences of y by a skolem function that
takes x1, ... xi as its arguments
step 4: remove all universal quantifiers x (with the understanding that
all remaining variables are universally quantified)
step 5: convert sentences using different distribution laws
step 6: use parenthesis to separate all disjunctions, then drop all v’s and
^’s
44
Conversion examples
x (P(x) ^ Q(x) => R(x)) y rose(y) ^ yellow(y)
x ~(P(x) ^ Q(x)) v R(x) (by step 1) rose(c) ^ yellow(c)
x ~P(x) v ~Q(x) v R(x) (by step 2) (where c is a skolem constant)
~P(x) v ~Q(x) v R(x) (by step 4) (rose(c)), (yellow(c))
(~P(x), ~Q(x), R(x)) (by step 6)

x [person(x) => y (person(y) ^ father(y, x))]


x [~person(x) v y (person(y) ^ father(y, x))] (by step 1)
x [~person(x) v (person(f_sk(x)) ^ father(f_sk(x), x))] (by step 3)
~person(x) v (person(f_sk(x)) ^ father(f_sk(x), x)) (by step 4)
(~person(x) v person(f_sk(x))) ^ (~person(x) v father(f_sk(x), x)) (by step 5)
(~person(x), person(f_sk(x))), (~person(x), father(f_sk(x), x)) (by step 6)
(where f_sk(.) is a skolem function)

45
Unification of two clauses
• Basic idea: x P(x) => Q(x), P(a) |-- Q(a)
(~P(x), Q(x)), (P(a))

{x/a} a substitution in which variable x is bound to a


(Q(a))
– The goal is to find a set of variable bindings so that the
argument lists of two opposite literals (in two clauses) can be
made the same.
– Only variables can be bound to other things.
• Constants a and b cannot be unified (different constants in general
refer to different objects) , including Skolem constants
• Constant a and function f(x) cannot be unified (unless the inverse
function of f is known, which is not the case for general functions
in FOL)
• f(x) and g(y) cannot be unified (function symbols f and g in
general refer to different functions and their exact definitions are
different in different interpretations) , including Skolem functions

46
Unification Examples
• parents(x, father(x), mother(Bill)) and parents(Bill, father(Bill), y)
– unify x and Bill: q = {x/Bill}
– unify father(Bill) and father(Bill): q = {x/Bill}
– unify mother(Bill) and y: q = {x/Bill}, y/mother(Bill)}
• parents(x, father(x), mother(Bill)) and parents(Bill, father(y), z)
– unify x and Bill: q = {x/Bill}
– unify father(Bill) and father(y): q = {x/Bill, y/Bill}
– unify mother(Bill) and z: q = {x/Bill, y/Bill, z/mother(Bill)}
• parents(x, father(x), mother(Jane)) and parents(Bill, father(y), mother(y))
– unify x and Bill: q = {x/Bill}
– unify father(Bill) and father(y): q = {x/Bill, y/Bill}
– unify mother(Jane) and mother(Bill): Failure because Jane and Bill are
different constants

47
More Unification Examples
• P(x, g(x), h(b)) and P(f(u, a), v, u))
– unify x and f(u, a): q = {x/ f(u, a)};
remaining lists: (g(f(u, a)), h(b)) and (v, u)
– unify g(f(u, a)) and v: q = {x/f(u, a), v/g(f(u, a))};
remaining lists: (h(b)) and (u)
– unify h(b) and u: q = {x/f(h(b), a), v/g(f(h(b), a)), u/h(b)};
• P(f(x, a), g(x, b)) and P(y, g(y, b))
– unify f(x, a) and y: q = {y/f(x, a)}
remaining lists: (g(x, b)) and (g(f(x, a), b))
– unify x and f(x, a): failure because x is in f(x, a)

48
Unification Algorithm
procedure unify(p, q, q) /* p and q are two lists of terms and |p| = |q| */
if p = empty then return q; /* success */
let r = first(p) and s = first(q);
if r = s then return unify(rest(p), rest(q), q);
if r is a variable then temp = unify-var(r, s);
else if s is a variable then temp = unify-var(s, r);
else if both r and s are functions of the same function name then
temp = unify(arglist(r), arglist(s), empty);
else return “failure”;
if temp = “failure” then return “failure”; /* p and q are not unifiable */
else q = subst(q, temp)U temp; /* apply tmp to old q then insert it into q
*/
return unify(subst(rest(p), tmp), subst(rest(q), tmp), q);
end{unify}
procedure unify-var(x, y)
if x appears anywhere in y then return “failure”;
else return (x/y)
end{unify-var}
49
Excellent links
• https://www.youtube.com/watch?v=73AUBVOW-sM
• https://www.youtube.com/watch?v=I0QAdG68K0o
• https://www.youtube.com/watch?v=EZJs6w2YFRM

50
What we learned
• Difference FOL and PL
• Properties of FOL
• Inference in FOL
• Unification in FOL
• CNF in FOL
• Resolution in FOL
• Steps for Resolution in FOL

51

You might also like