0% found this document useful (0 votes)
56 views20 pages

IntSys Lec 05 Inference Rules DR - Mina

This document provides an overview of inference rules in predicate logic. It defines inference rules and discusses how they allow deducing new logical statements from known facts or assumptions. Specifically, it defines inference rules, unification, and provides examples of common inference rules like modus ponens and universal instantiation. It explains how applying these rules through substitution of variables allows drawing new conclusions in a mechanical way.

Uploaded by

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

IntSys Lec 05 Inference Rules DR - Mina

This document provides an overview of inference rules in predicate logic. It defines inference rules and discusses how they allow deducing new logical statements from known facts or assumptions. Specifically, it defines inference rules, unification, and provides examples of common inference rules like modus ponens and universal instantiation. It explains how applying these rules through substitution of variables allows drawing new conclusions in a mechanical way.

Uploaded by

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

Intelligent Systems

Lecture 05: Inference Rules

Collected and Edited by:


Dr. Mina Younan
Lecturer of Computer Science,
Faculty of Computers and Information, Minia University

20
21
Dr. Mina Younan
Outline of this lecture
// this lecture collected and edited from Prof. Moheb Girgis Lectures in AI

Part One (cont.):


• Inference Rules
• Definitions
• Some useful inference rules
o Example
• Unification

20
21
Dr. Mina Younan
Intelligent Systems 2
Inference Rules
The ability to infer new correct expressions from a set of true assertions
is an important feature of the predicate calculus. These new expressions
are correct in that they are consistent with all previous interpretations of
the original set of expressions.

Definitions:
For a predicate calculus expression E and an interpretation I:
1. If E has a value of T under I and a particular variable
assignment, then I is said to satisfy E.
Example: Assume:
I is the Adam & Eve's world, and
E is X Y (father (X, Y)  mother (X, Y)  parent (X, Y))
E is T under I and the variable assignment X = adam and Y =
abel, then I satisfies E.

20
21
Dr. Mina Younan
Intelligent Systems 3
Definitions
2. If I satisfies E for all variable assignments, then I is a model of E.

3. E is satisfiable iff there exist an interpretation and variable


assignment that satisfy it; otherwise it is unsatisfiable.
Example:
• Satisfiable expression:
X Y (female (X)  sibling (X, Y)  sister (X, Y))
• Unsatisfiable expression:
X Y (male (X)  sibling (X, Y)  sister (X, Y))

20
21
Dr. Mina Younan
Intelligent Systems 4
Definitions
4. A set of expressions is satisfiable iff there exist an interpretation
and variable assignment that satisfy every expression in that set.
5. If a set of expressions is not satisfiable, is said to be inconsistent.
Example: X (p(X)  ‫ר‬p(X))
6. If E has a value T for all possible interpretations, E is said to be
valid.
Example: X (p(X)  ‫ר‬p(X))

7. A predicate calculus expression E logically follows from a set S of


predicate calculus expressions if every interpretation and
variable assignment that satisfies S also satisfies E.
8. The function of logical inference is to produce new sentences that
logically follow from a given set of predicate calculus sentences.

20
21
Dr. Mina Younan
Intelligent Systems 5
Definitions
9. An inference rule is a mechanical means of producing new
predicate calculus sentences from other sentences.
10. An inference rule is sound if every predicate calculus expression
produced by the rule from a set S of predicate calculus
expressions logically follows from S.
11. An inference rule is complete if, given a set S of predicate
calculus expressions, the rule can infer every expression that
logically follows from S.

Some useful inference rules


 Modus Ponens: If the sentences P and P  Q are known to be true, then
Q logically follows.
This rule can be represented graphically as follows:
PQ true
P true
Q true
20
21
Dr. Mina Younan
Intelligent Systems 6
Some useful inference rules
Modus Tollens: If the sentence P  Q is known to be true and Q is known to be
false, then ‫ר‬P logically follows.
This rule can be represented graphically as follows:
P Q true
‫ר‬Q true
‫ר‬P true
AND Elimination: If the conjunctive sentence P  Q is true, then its conjuncts P and
Q are true.
This rule can be represented graphically as follows:
PQ true
P true
Q true
AND Introduction: If the conjuncts P and Q are true, then conjunctive (P  Q) is
true.
This rule can be represented graphically as follows:
P true
Q true
PQ true
20
21
Dr. Mina Younan
Intelligent Systems 7
Some useful inference rules
Universal instantiation: If any universally quantified variable in a true
sentence is replaced by any appropriate term from the domain, the result is
a true sentence.
Thus, if X p(X) is true and a is from the domain of X, then we can
infer p(a).
Example
Consider the following observation:
"if it is raining, then the ground will be wet" and
"it is raining".
 Let P denotes "it is raining", Q denotes "the ground is wet". The first expression
becomes P  Q.
 Because it is now raining (P is true), our set of axioms becomes: P  Q and P.
 Through an application of modus ponens, the fact that "the ground is wet" (Q) can be
added to the set of true expressions.

20
21
Dr. Mina Younan
Intelligent Systems 8
Example
Applying modus ponens to expressions containing variables:
Consider the following statement:
“All men are mortal and Basem is a man; therefore Basem is mortal.”
1. "All men are mortal" may be represented in predicate calculus by:
X (man(X)  mortal(X))
2. “Basem is a man" is represented by man (basem).
3. Because X is universally quantified, we may substitute any value in the domain for
X and still have a true statement under the inference rule of universal
instantiation.
4. By substituting basem for X in the implication, we infer the expression:
man(basem)  mortal(basem)
5. We can now apply modus ponens and infer the conclusion mortal(basem).

This is added to the set of expressions that logically follows from the
original assertions.

20
21
Dr. Mina Younan
Intelligent Systems 9
Unification
Unification is an algorithm for determining the substitutions
needed to make two predicate calculus expressions match.

For example, Basem in the fact man(basem) was substituted for X


in X (man (X)  mortal (X)).
This allowed the application of modus ponens and the
conclusion mortal (basem).

20
21
Dr. Mina Younan
Intelligent Systems 10
Unification
• A substitution is a set of assignments of terms to variables, with no
variable being assigned more than one term.
• A variable may be replaced by a constant, a variable, and a function
that does not contain the variable, (This avoids circularities).

• For example, X cannot be replaced by p(X) as this creates an infinite


expression: p(p(p(p … X) … ). The test for this situation is called the
occurs check.
• The notation X/Y indicates that X is substituted for the variable Y in the
original expression.
• Substitutions are also referred to as bindings. A variable is said to be
bound to the value substituted for it.
• Any constant is considered a "ground instance" and can not be
replaced.

20
21
Dr. Mina Younan
Intelligent Systems 11
Unification
Example:
• Some instances of the expression:
foo (X, a, goo(Y))
• generated by legal substitutions and the corresponding
• substitution instances or unifications are given below:

Substitution Instance
{fred/X, Z/Y} foo(fred, a, goo(Z))
{W/X, jack/Y} foo(W, a, goo(jack))
{Z/X, moo(Z)/Y} foo(Z, a, goo(moo(Z)))

A substitution that makes two expressions match is called a unifier.


20
21
Dr. Mina Younan
Intelligent Systems 12
Unification
Example: Assume that the following predicate expressions are true :
(1) p(Y, Z)  q(Y, Z), (2) q(W, b)  r(W, b), (3) p(a, X)
Show that r(a, b) logically follows.

1. Firstly, p(a, X) can be unified with the premise of (1), p(Y, Z), with the
substitutions {a/Y, X/Z}.
2. Applying these substitutions to (1) by using universal instantiation, we can
infer: (4) p(a, X)  q(a, X).
3. Applying modus ponens to (3) and (4) we can infer: (5) q(a, X) as follows:
p(a, X)  q(a, X) true
p(a, X) true
q(a, X) true
4. Now, q(a, X) can be unified with the premise of (2), q(W, b), with the
substitutions {a/W, b/X}.
5. Applying these substitutions to (2) and (5) by using universal instantiation, we
can infer: (6) q(a, b)  r(a, b), and (7) q(a, b).
6. Applying modus ponens to (6) and (7), we can infer: (8) r(a, b)
20
21
Dr. Mina Younan
Intelligent Systems 13
Unification
The composition of unification substitutions:
• If S and S' are two substitution sets, then the composition of S and S'
(written SS') is obtained by applying S' to the elements of S and adding the
result to S.

Example: In the above example, the composition of substitution sets, {a/Y,


X/Z} and {a/W, b/X}, yields the single substitution {a/Y, b/Z, a/W}.

Example: Compose the sequence of substitutions:


{X/Y, W/Z}, {V/X}, {a/V, f(b)/W}
1. Firstly, compose {X/Y, W/Z} with {V/X} to yield {V/Y, W/Z}.
2. Then, compose {V/Y, W/Z} with {a/V, f(b)/W} to yield {a/Y, f(b)/Z}.

Composition can be shown to be associative but not commutative.

20
21
Dr. Mina Younan
Intelligent Systems 14
Unification ..
The function Unify:
• The function Unify() computes the unifying substitutions (when this is
possible) between two predicate calculus expressions.
• It takes as arguments two predicate calculus expressions and returns either
the most general unifying substitutions or Fail if no unification is possible.
• To simplify the manipulation of expressions, each expression is represented
as a list with the predicate or function name as the first element followed by
its arguments. Lists are delimited by parentheses, (), and list elements are
separated by spaces.

Examples:
List Syntax Predicate Calculus Syntax
(p a b) p(a, b)
(p (f a) (g X Y)) p(f(a), g(X, Y))
(equal eve (mother cain)) equal(eve, mother(cain))
20
21
Dr. Mina Younan
Intelligent Systems 15
Function Unify (E1, E2):
begin
case
both E1 and E2 are constants or the empty list : // recursion stops
if E1 = E2 then return { }
else return Fail;

E1 is a variable :
if E1 occurs in E2 then return Fail
else return {E2/E1};
E2 is a variable :
if E2 occurs in E1 then return Fail
else return {E1/E2};
either E1 or E2 is empty : // the lists are of different sizes
return Fail;
otherwise : // both E1 and E2 are lists
begin
HE1 := first element of E1;
HE2 := first element of E2;
SUBS1 := Unify (HE1, HE2);
if SUBS1 = Fail then return Fail;
TE1 := apply (SUBS1, rest of E1);
TE2 := apply (SUBS1, rest of E2);
SUBS2 := Unify (TE1, TE2);
if SUBS2 = Fail then return Fail
else return composition (SUBS1, SUBS2)
end
end case
end;

20
21
Dr. Mina Younan
Intelligent Systems 16
Unification ..
Example:
The two expressions:
parents(X, father(X), mother (bill)),
parents(bill, father(bill), Y).

can be unified by using the Unify function as follows:


Unify ( (parents X (father X) (mother bill)),
(parents bill (father bill) Y) ).
The trace of this call is shown below.

20
21
Dr. Mina Younan
Intelligent Systems 17
Initial Steps in the unification of {
( parent X (father x) (mother bill) ) and
( parent bill (father bill) Y )
}

20
21
Dr. Mina Younan
Intelligent Systems 18
20
21
Dr. Mina Younan
Intelligent Systems 19
20
21
Dr. Mina Younan
Intelligent Systems 20

You might also like