You are on page 1of 100

Knowledge Representation and

Inference using First-Order Logic


Outline
• What is First-Order Logic (FOL)?
– Syntax and semantics

• Using FOL

• Wumpus world in FOL

• Knowledge engineering in FOL


Limitations of propositional logic

 Propositional logic has limited expressive


power
–unlike natural language
–E.g., cannot say "pits cause breezes in
adjacent squares“
• except by writing one sentence for each
square
Wumpus World and propositional
logic
• Find Pits in Wumpus world
– Bx,y  (Px,y+1  Px,y-1  Px+1,y  Px-1,y) (Breeze next to Pit) 16 rules

• Find Wumpus
– Sx,y  (Wx,y+1  Wx,y-1  Wx+1,y  Wx-1,y) (stench next to Wumpus) 16 rules

• At least one Wumpus in world


– W1,1  W1,2  …  W4,4 (at least 1 Wumpus) 1 rule

• At most one Wumpus


–  W1,1   W1,2 (155 RULES)
Limitations of Propositional Logic
• Propositional logic cannot express general-purpose knowledge
succinctly
• We need 32 sentences to describe the relationship between wumpi
and stenches
• We would need another 32 sentences for pits and breezes
• We would need at least 64 sentences to describe the effects of
actions
• How would we express the fact that there is only one wumpus?
• Difficult to identify specific individuals (Mary, among 3)
• Generalizations, patterns, regularities difficult to represent (all
triangles have 3 sides)
First-Order Predicate Calculus
• Propositional Logic uses only propositions (symbols
representing facts), only possible values are True and False
• First-Order Logic includes:
– Objects: peoples, numbers, places, ideas (atoms)
– Relations: relationships between objects (predicates, T/F value)
• Example: father(fred, mary)
• Properties: properties of atoms (predicates, T/F value)
Example: red(ball)
– Functions: father-of(mary), next(3), (any value in range)
• Constant: function with no parameters, MARY
FOPC Models
Example
• Express “Socrates is a man” in
• Propositional logic
– MANSOCRATES - single proposition representing entire idea
• First-Order Predicate Calculus
– Man(SOCRATES) - predicate representing property of constant
SOCRATES
First-Order Logic
• Propositional logic assumes that the world contains facts.

• First-order logic (like natural language) assumes the world


contains

– Objects: people, houses, numbers, colors, baseball games, wars, …

– Relations: red, round, prime, brother of, bigger than, part of, comes between,

– Functions: father of, best friend, one more than, plus, …


Logics in General
• Ontological Commitment:
– What exists in the world — TRUTH
– PL : facts hold or do not hold.
– FOL : objects with relations between them that hold or do not hold

• Epistemological Commitment:
– What an agent believes about facts — BELIEF
Syntax of FOL: Basic elements
• Constant Symbols:
– Stand for objects
– e.g., KingJohn, 2, UCI,...

• Predicate Symbols
– Stand for relations
– E.g., Brother(Richard, John), greater_than(3,2)...

• Function Symbols
– Stand for functions
– E.g., Sqrt(3), LeftLegOf(John),...
Syntax of FOL: Basic elements
• Constants KingJohn, 2, UCI,...

• Predicates Brother, >,...

• Functions Sqrt, LeftLegOf,...

• Variables x, y, a, b,...

• Connectives , , , , 

• Equality =

• Quantifiers , 
Relations
• Some relations are properties: they state
some fact about a single object: Round(ball), Prime(7).

• n-ary relations state facts about two or more objects:


Married(John,Mary), LargerThan(3,2).

• Some relations are functions: their value is another object:


Plus(2,3), Father(Dan).
Models for FOL: Graphical
Example
Tabular Representation

• A FOL model is basically equivalent to a relational database instance.


• Historically, the relational data model comes from FOL.

Student Course Professor


s-id Intelligence Ranking
c-id Rating Difficulty p-id Popularity Teaching-a
Jack 3 1
101 3 1 Oliver 3 1
Kim 2 1
Paul 1 2 102 2 2 Jim 2 1

Registration
RA
s-id c.id Grade Satisfaction
s-id p-id Salary Capability Jack 101 A 1
Jack Oliver High 3 Jack 102 B 2
Kim Oliver Low 1 Kim 102 A 1
Paul Jim Med 2 Paul 101 B 1

21
Terms
• Term = logical expression that refers to an object.

• There are 2 kinds of terms:


– constant symbols: Table, Computer
– function symbols: LeftLeg(Pete), Sqrt(3), Plus(2,3) etc
• Functions can be nested:
– Pat_Grandfather(x) = father(father(x))
• Terms can contain variables.
• No variables = ground term.
Atomic Sentences

• Atomic sentences state facts using terms and predicate symbols


– P(x,y) interpreted as “x is P of y”
• We can represent atomic sentences as Predicate (term1, term2, ......, term n).
• Example: Ravi and Ajay are brothers: => Brothers(Ravi, Ajay).
                Chinky is a cat: => cat (Chinky)

• Examples:
LargerThan(2,3) is false.
Brother_of(Mary,Pete) is false.
Married(Father(Richard), Mother(John)) could be true or false

• Note: Functions do not state facts and form no sentence:


– Brother(Pete) refers to John (his brother) and is neither true nor false.

• Brother_of(Pete,Brother(Pete)) is True.

Binary relation Function


First-order logic statements can be divided into two parts:
•Subject: Subject is the main part of the statement.
•Predicate: A predicate can be defined as a relation, which binds two atoms
together in a statement.

Consider the statement: "x is an integer.", it consists of two parts, the first
part x is the subject of the statement and second part "is an integer," is known
as a predicate.
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).

The Universal quantifier is represented by a


symbol ∀, (all)
Ifx i
,s ∀a vari
: able, then ∀x is read as:
For all x
For each x
For every x.
Exam ple:
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 ∃ ,

It will be read as: There are some x where x is a boy who is


Complex Sentences
• We make complex sentences with connectives (just like in
propositional logic).
property

Brother (LeftLeg (Richard ), John )  (Democrat (Bush ))

binary function
relation

objects

connectives
More Examples
• Brother(Richard, John)  Brother(John, Richard)

• King(Richard)  King(John)

• King(John) =>  King(Richard)

• LessThan(Plus(1,2) ,4)  GreaterThan(1,2)

(Semantics are the same as in propositional logic)


Variables
• Person(John) is true or false because we give it a single
argument ‘John’

• We can be much more flexible if we allow variables which


can take on values in a domain. e.g., all persons x, all
integers i, etc.
– E.g., can state rules like Person(x) => HasHead(x)
or Integer(i) => Integer(plus(i,1)
Universal Quantification 
•  means “for all”

• Allows us to make statements about all objects that have certain properties

• Can now state general rules:

 x King(x) => Person(x)

 x Person(x) => HasHead(x)

" i Integer(i) => Integer(plus(i,1))

Note that
" x King(x)  Person(x) is not correct!
This would imply that all objects x are Kings and are People

 x King(x) => Person(x) is the correct way to say


Existential Quantification 
•  x means “there exists an x such that….” (at least one object x)
• Allows us to make statements about some object without naming it

• Examples:

x King(x)

x Lives_in(John, Castle(x))

i Integer(i)  GreaterThan(i,0)

Note that  is the natural connective to use with 

(And => is the natural connective to use with  )


More examples
For all real x, x>2 implies x>3.

x [(x  2)  (x  3)] x  R (false )


x [(x 2  1)] x  R (false )

There exists some real x whose square is minus 1.

UBC AI space demo for rules


Combining Quantifiers
 x  y Loves(x,y)
– For everyone (“all x”) there is someone (“y”) that they love.

$ y  x Loves(x,y)
- there is someone (“y”) who is loved by everyone

Clearer with parentheses: y(x Loves(x,y) )


Duality: Connections between
Quantifiers
• Asserting that all x have property P is the same as asserting
that
there does not exist any x that does’t have the property P

 x Likes(x, 430class)   x  Likes(x, 430class)

In effect:
-  is a conjunction over the universe of objects
-  is a disjunction over the universe of objects
Thus, DeMorgan’s rules can be applied
De Morgan’s Law for Quantifiers

De Morgan’s Rule Generalized De Morgan’s Rule


P  Q  (P  Q ) x P  x (P )
P  Q  (P  Q ) x P  x (P )
(P  Q )  P  Q x P  x (P )
(P  Q )  P  Q x P  x (P )

Rule is simple: if you bring a negation inside a disjunction or a conjunction,


always switch between them (or and, and  or).
Knowledge engineering in FOL
1. Identify the task
2. Assemble the relevant knowledge
3. Decide on a vocabulary of predicates, functions, and constants
4. Encode general knowledge about the domain
5. Encode a description of the specific problem instance
6. Pose queries to the inference procedure and get answers
7. Debug the knowledge base.
8. See text for full example: electric circuit knowledge base.
Examples
• https://www.youtube.com/watch?v=https://
www.youtube.com/watch?v=ADeffD2lxXkGH8yBBC9n3Y

https://
www.youtube.com/watch?v=xR2Y zdGzf9k

https://www.youtubecomwatch
. / ?v=ADeffD2lxXk
First-Order Logic: Better choice
for Wumpus World
• Propositional logic represents facts
• First-order logic gives us
– Objects
– Relations: how objects relate to each other
– Properties: features of an object
– Functions: output an object, given others
First-Order Logic in Wumpus
World
• Suppose an agent perceives a stench, breeze, no glitter at
time t = 5:
– Percept([Stench,Breeze,None],5)
– [Stench,Breeze,None] is a list
• Then want to query for an appropriate action. Find an a (ask
the KB):

a Action (a,5) ?
WW
• Performance measure
Agent Description
– gold +1000, death -1000
– -1 per step, -10 for using arrow
• Environment
– Squares adjacent to wumpus are smelly
– Squares adjacent to pit are breezy
– Glitter iff gold is in same square
– Shooting kills wumpus if agent facing it
– Shooting uses up only arrow
– Grabbing picks up gold if in same square
– Releasing drops gold in same square
• Actuators
– Left turn, right turn, forward, grab,
release, shoot
• Sensors
– Breeze, glitter, smell, bump, scream
Simplifying the percept and
deciding actions
b, g , t Percept ([ Stench , b, g ], t )  Stench (t )
s, g , t Percept ([ s, Breeze, g ], t )  Breeze(t )
s, b, t Percept ([ s, b, Glitter ], t )  AtGold (t )
• Simple Reflex Agent

t AtGold (t )  Action (Grab, t )


• Agent Keeping Track of the World
t AtGold (t )  Holding (Gold , t )  Action (Grab, t )
Using logic to deduce properties
• Define properties of locations:
l , t AtAgent (l , t )  Stench (t )  Smelly (l )
l , t AtAgent (l , t )  Breeze(t )  Breezy (l )
• Diagnostic rule: infer cause from effect
y Breezy ( y )  x Pit ( x)  Adjacent ( x, y )
• Causal rule: infer effect from cause
x, y Pit ( x)  Adjacent ( x, y )  Breezy ( y )

• Neither is sufficient: causal rule doesn’t say if squares far


from pits can be breezy. Leads to definition:
y Breezy ( y )  x Pit ( x)  Adjacent ( x, y )
Keeping track of the world is
important
• Without keeping track of state...
– Cannot head back home
– Repeat same actions when end up back in same place
– Unable to avoid infinite loops
– Do you leave, or keep searching for gold?
• Want to manage time as well
– Holding(Gold,Now) as opposed to just Holding(Gold)
Situation Calculus
• Adds time aspects to first-order logic
AtAgent ([1,1], S 0 )  AtAgent ([1,2], S1 )

Result function connects actions to results


Result(For ward, S0 )  S1
Result(Tur n( Right ) , S1 )  S 2
Describing actions
• Pick up the gold!
– Stated with an effect axiom

s AtGold ( s)  Holding (Gold , Result (Grab, s ))


• When you pick up the gold, still have the arrow!
– Nonchanges: Stated with a frame axiom

s HaveArrow( s )  HaveArrow( Result (Grab, s))


Cleaner representation: successor-
state axiom
• For each predicate (not action):
– P is true afterwards means
• An action made P true, OR
• P true already and no action made P false
• Holding the gold:

a, s Holding (Gold , Result(a, s )) 


(( a  Grab)  AtGold ( s )) 
( Holding (Gold , s )  (a  Release ))
(if there was such a thing as a release action – ignore that for our example)
Keeping track of location
• Direction (0, 90, 180, 270)
Orientatio n( S 0 )  0

• Define function for how orientation affects x,y


location
x, y LocationTo ward ([ x, y ],0)  [ x  1, y ]
x, y LocationTo ward ([ x, y ],90)  [ x, y  1]
x, y LocationTo ward ([ x, y ],180)  [ x  1, y ]
x, y LocationTo ward ([ x, y ],270)  [ x, y  1]
Location cont...
• Define location ahead:
l , s AtAgent (l , s ) 
LocationAh ead ( s )  LocationTo ward (l , Orientatio n( s ))

• Define what actions do (assuming you know where


wall is):
l , d , p, s AtAgent (l , Result(a, s )) 
[ (a  Forward  l  LocationAh ead ( s )  Wall (l ))
 ( AgentAt (l , s )  a  Forward )
Primitive goal based ideas
• Once you have the gold, your goal is to get back
home
s Holding (Gold , s )  GoalLocati on([1,1], s)

• How to work out actions to achieve the goal?


– Inference: Lots more axioms.
– Search: Best-first (or other) search. Need to convert KB
to operators
– Planning: Special purpose reasoning systems
Summary
• FOL better are representing knowledge than
propositional
• FOL adapts well to different engineering
applications
• FOL based on traditional logic operators
• FOL can be extended to SOL
• Need to know about inference processes.
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)
72
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.

73
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.
74
75
76
Types of Inference rules:

77
78
79
80
81
82
83
84
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)

85
Universal Elimination (x) P(x) |-- P(c).
• If (x) P(x) is true, then P(c) is true for any constant c in the
domain of x, i.e.,, (x) P(x) |= P(c).
• Replace all occurrences of x in the scope of x by the same ground
term (a constant or a ground function).
• Example: (x) eats(Ali, x) |-- eats(Ali, IceCream)
Existential Introduction P(c) |-- (x) P(x)
• If P(c) is true, so is (x) P(x), i.e., P(c) |= (x) P(x)
• Replace all instances of the given constant symbol by the same new
variable symbol.
• Example eats(Ali, IceCream) |-- (x) eats(Ali, x)
Existential Elimination (x)P(x) |-- P(c)
• where c is a new constant symbol standing for object that makes P true,
– All we know is there must be some constant that makes this true, so
we can introduce a brand new one to stand in for that constant,
even though we don’t know exactly what that constant refer to.
– Example: (x) eats(Ali, x) |= eats(Ali, Stuff)

86
• Things become more complicated when there are universal quantifiers
(x)(y) eats(x, y) |-- (x)eats(x, Stuff) ???
(x)(y) eats(x, y) |-- eats(Ali, Stuff) ???
– Introduce a new function food_sk(x) to stand for y because that y
depends on x
(x)(y) eats(x, y) |-- (x)eats(x, food_sk(x))
(x)(y) eats(x, y) |-- eats(Ali, food_sk(Ali))
– What exactly the function food_sk(.) does is unknown, except that it
takes x as its argument
• The process of existential elimination is called Skolemization (after
Skolem, a Norwegian mathematician).
• The new, unique constants (e.g., Stuff) and functions (e.g., food_sk(.))
are called skolem constants and skolem functions

87
Resolution in FOL
• Resolution is a theorem proving technique that proceeds
by building refutation proofs, i.e., proofs by
contradictions.
• 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.

88
Resolution for FOL
• Resolution rule operates on two clauses
– Clause: Disjunction of literals (an atomic sentence) is called a clause. It is
also known as a unit clause.
– Variables are universally quantified
– Relationship between clauses in KB is conjunction

89
We need answers to the following questions

• How to convert FOL sentences to clause form (especially how


to remove quantifiers)
• How to unify two argument lists, i.e., how to find their most
general unifier (mgu) q
• How to determine which two clauses in KB should be resolved
next (among all resolvable pairs of clauses) and how to
determine a proof is completed

90
Converting FOL sentences to clause form
• Basic ideas
– How to handle quantifiers
• Careful on quantifiers with preceding negations (explicit or
implicit)
~x P(x) is really x ~P(x)
(x P(x)) => (y Q(y)) ~(x P(x)) v (y Q(y))
 x ~P(x) v y Q(y)
• Eliminate true existential quantifier by Skolemization
• For true universally quantified variables, treat them as such
without quantifiers
– similar to PL but need to work with quantifiers

91
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
92
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)

93
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

94
– Cannot bind variable x to y if x appears anywhere in y
• Try to unify x and f(x). If we bind x to f(x) and apply the binding
to both x and f(x), we get f(x) and f(f(x)) which are still not the
same (and will never be made the same no matter how many times
the binding is applied)
– Otherwise, bind variable x to y, written as x/y (this
guarantees to find the most general unifier, or mgu)
• Suppose both x and y are variables, then they can be made the
same by binding both of them to any constant c or any function
f(.). Such bindings are less general and impose unnecessary
restriction on x and y.
– To unify two terms of the same function symbol, unify
their argument lists (unification is recursive)
Ex: to unify f(x) and f(g(b)), we need to unify x and g(b)

95
– When the argument lists contain multiple terms, unify each
corresponding pair of terms
Ex. To unify (x, f(x), ...) (a, y, ...)
1. unify x and a (q = {x/a})
2. apply q to the remaining terms in both lists, resulting
(f(a), ...) and (y, ...)
3. unify f(a) and y with binding y/f(a)
4. apply the new binding y/f(a) to q
5. add y/f(a) to new q

96
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

97
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)

98
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}
99
Excellent links
• https://www.youtube.com/watch?v=73AUBVOW-sM
• https://www.youtube.com/watch?v=I0QAdG68K0o
• https://www.youtube.com/watch?v=EZJs6w2YFRM

100

You might also like