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

Introduction To Artificial Intelligent Artificial Intelligence (AI) Is The Branch or Field of Computer Science That Is Concerned With

This document provides an introduction to artificial intelligence including definitions, areas of study, and techniques. It discusses how AI aims to automate intelligent behavior and develop systems that can perform tasks requiring high levels of intelligence. The document outlines several techniques used in AI like search, knowledge representation, and abstraction. It also summarizes common search algorithms like depth-first, breadth-first, hill climbing, and best-first searches that are applied to problems represented as state spaces.

Uploaded by

Rosemary Odor
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 views51 pages

Introduction To Artificial Intelligent Artificial Intelligence (AI) Is The Branch or Field of Computer Science That Is Concerned With

This document provides an introduction to artificial intelligence including definitions, areas of study, and techniques. It discusses how AI aims to automate intelligent behavior and develop systems that can perform tasks requiring high levels of intelligence. The document outlines several techniques used in AI like search, knowledge representation, and abstraction. It also summarizes common search algorithms like depth-first, breadth-first, hill climbing, and best-first searches that are applied to problems represented as state spaces.

Uploaded by

Rosemary Odor
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/ 51

Artificial Intelligence

Lecture 1
Introduction to Artificial Intelligent

Artificial Intelligence (AI) is the branch or field of computer science that is concerned with
the automation of intelligent behavior. Major AI researchers and textbooks define this field as
“the study and design of intelligent agents”, in which an intelligent agent is a system that
perceives its environment and takes actions that maximize its chances of success. John
McCarthy, who coined the term in 1955, defines it as “the science and engineering of making
intelligent machines”. AI has a long history but is still constantly and actively growing and
changing. It has become an essential part of the technology industry, providing the heavy
lifting for many of the most challenging problems in computer science and many other fields.

Commercial Products of AI

There are many areas of study in AI. We will try to list some of them:

• Game Playing

o Playing games using a well-defined set of rules such as checkers, chess and 15-puzzel.

• Knowledge Representation and Automated Reasoning

o Representing information about the world in a form that a computer system can utilize
to solve complex tasks such as diagnosing a medical condition, having a dialog in a natural
language, intelligent assistants, real-time problem solving and internet agents.

• Expert Systems

o A program that address the problem of reasoning with uncertain or incomplete


information, such as expert system for expert doctor or engineer.

• Natural Language Processing o information retrieval, summarization, understanding,


generation, and translation

• Vision

o Image analysis, Pattern recognition, and scene understanding.

• Robotics

o Grasping/manipulation, locomotion, motion planning, and mapping.


Artificial Intelligence

• Search and Optimization

o Planning, Airline scheduling, and resource allocation.

Importance of AI

▪ AI may well be one of the most important development of the world. It will affect
government & private companies interested in the development of computer products,
robotics & related field.
▪ Japanese realized that many of their goals to produce systems that can converse in a
natural language, understand speech & visual sense, learn & refine their knowledge ,
make decisions, & exhibit other traits can be achieved.
▪ British initiated a plan called the Alvey project with a reasonable budget.
▪ France, Canada, Russsia, Italy, Australia, & Singapore have committed to some extent
to funded research & development.
▪ 1983, developed VLSI to use in AI technologies.
▪ MCC( Microelectronics & computer technology corporation) & is headquartered in
Austin, Texas.
▪ Second DARPA( Defense Advanced Research Projects Agency) has increased its
funding for research in AI & supported in three significant programs:-
1. development of an autonomous land vehicle(ALV) a driverless military vehicle.
2. the development of a pilot's associate (an expert system which provides assistance to
fighter pilot)
3. the strategic computing program (an AI based military super computer project).
Goals of AI

the goal of AI is to develop working computer system that truly capable of performing tasks
that require high levels of intelligence. The programs are not necessarily meant to imitate
human sense & thought processes. Indeed, in performing some tasks differently, they may
actually exceed human capabilities. The important point is that the systems all be capable of
performing intelligent tasks effectively & efficient.
Artificial Intelligence

AI Technique

The three important AI techniques are:-

1. search: provides a way of solving programs for which no more direct approach is
available as well as a frame work into which any direct techniques that are available
can be embedded.
2. use of knowledge:- provides a way of solving complex problems by exploiting the
structures of the objects that are involved.
3. abstraction: provides a way of separating important features & variations from the
many unimportant ones that would otherwise overwhelm any process.
the techniques of AI must often require that the problem defined in some specific way,
for ex. Breaking a complex decision into a series of simpler sub problems that lead to
the final solution.The presentation of a problem in a simple, easily process able form
then aids in the development of a solution.Algorithm is a specific set of operations,
procedures & decisions which guarantees to yield correct results. ( Gloriose &
Osorio,1990)Where heuristic is a rule of thumb ,trick, strategy, simplification or any
other method that aids the solution of complex problems.One of the difference between
a heuristic & an algorithm is that while a heuristic generally aids in finding the
solution, it does not guarantee an optimal solutions or no a solution at all. However,
with an algorithm, one can be sure of finding the correct results.
Artificial Intelligence

(1) Knowledge Representation (k. base)

AI (2) Inference Mechanism

(3) Search

Inference Mechanism: How to represent information processes it, and reach to conclusions.

Search: How to search for specific information.

• Basic concept
• Directed graph

• Parent and child nodes


M Parent node

N Child node

• Rooted Graph: is a graph with unique node which has no parent

Root node

Leaf node

Last node

• Leaf node: is a node with no children.


Artificial Intelligence

• Path: is ordered sequence of nodes [ N1 , N2, …, Nk ] such that (Ni , Ni+1) represent an arc,
the path which consist of K nodes is said to have order K.

(Ni , Nj)
Ni Nj

C
The path is: A B C D
D

• Ancestor and descendants:-

A ancestor of B,C,D B descendant from A

B ancestor of C, D C descendant from B, A

• Cyclic Path: a path that contains a node more than once is said to be cycle.

A C D E
B B

• Tree: is a graph with no cyclic path.


Artificial Intelligence

• State space representation: - represents all states may be in the problem space.

(Op#1)
S
N1 (Op#i)

State Space (op#2) ……


Ni

N2

Nt

Path is: S Ni Nt

Example:-

Consider the following map:


link(a, d), link(a, b), link(d, e), link(e, c), link(d, a), link(b, c), link(c, b), link(c, d), the
path a e
a

d b

Note:

To reach a e we can find more than one path, and probably find a cyclic path.
Therefore the better way is to use tree.

Example:
Artificial Intelligence

8-puzzle problem

31 4
The Initial state 67
8 2 5
4 3 1
The goal state 8 6 7
5 2
________________________________________________

Solution:

The operation is to move the blank with directions

1 4 3
7 6
5 8 2

1 3 1 4 3 1 4 3 1 4 3
7 4 6 7 6 7 8 6 7 6
5 8 2 5 8 2 5 2 5 8 2

1 3 1 3 1 4 1 4 3 1 4 3 1 4 3 1 4 3 4 3
7 4 6 7 4 6 7 6 3 7 6 2 7 8 6 7 8 6 5 7 6 1 7 6
5 8 2 5 8 2 5 8 2 5 8 5 2 5 2 8 2 5 8 2

The goal
Search algorithm (1) Systematic Search (Blind Search)

(2) Heuristic Search


Artificial Intelligence

(1) Systematic (Blind) Search Depth-first


Breadth
Hybrid of both

(2) Heuristic Search Hill climbing


Best-first

Depth –first search algorithm

Algorithm depth-first
Begin
initialize = open [start], closed= [ ], parent [start] =” Nill”, found =No;
While open < > [ ] do
Begin
- Remove the first state from left of open, call it X;
- If X is the goal then found = true, break;
- Generate of children of X and put in list L;
- Put X on close;
- Eliminate from L any state already in closed;
- Eliminate from open any state already in L;
- Append L to the left of open;
- For each child Y in L, set parent [Y] = X;
- Empty L;
End;

If (found= True) compute the solution path;


Else return fail;
End.
Artificial Intelligence

E
D

F
H I J

Search space {S, A, E, F, H, D, I, J, G}


Solution path {S A D J G}

Example: Consider the following state space:


Start A A
E
Goal K
B R
D
Solution:
F C
H
X= A I J M
G
L= [B, C, D, E] L
K
N P Q
#0 open= [A], closed= [ ], found = No, parent [A] =”Nill”

#1 Closed= [A]
Open= [B, C, D, E]

#2 X=B X= the 1st node from Open


Closed=[B, A] Closed= [X+ Closed]
Open= [F, C, D, E] Open= [child. of X + Open without X]

#3 X=F
Artificial Intelligence

Closed= [F, B, A]
Open= [I, J, C, D, E]
#4 X=I
Closed=[I, F, B, A]
Open=[N, J, C, D, E]

#5 X=N
Closed= [N, I, F, B, A]
Open= [J, C, D, E]

#6 X=J
Closed= [J, N, I, F, B, A] parent [A] = “Nill”
Open= [C, D, E] parent [B] = A
Parent [C] = B
#7 X=C parent [F] = B
Closed= [C, J, N, I, F, B, A] parent [I] = F
Open= [G, H, D, E] parent [J] = F
Parent [N] = I
#8 X=G parent [G] = C
Closed= [G, C, J, N, I, F, B, A] parent [K] = G
Open= [K, L, H, D, E]

#9 X= K found = True

The solution path is: A B C G K


Artificial Intelligence

Lecture 2
Breadth – first Search

Breadth-first search expands nodes in order of their distance from the root, generating one
level of the tree at a time until a solution is found. It is most easily implemented by maintain
a queue of nodes, initially containing just the root, and always removing the node at the head
of the queue, expanding it, and adding its children to the end of the queue.

Tracing and Returning a Path in Breadth-First-Search


Artificial Intelligence

Fig 1: Order of node generation for Breadth-First-Search algorithm

Example:

Give the shortest path

X= A

L= [B, C, D, E] Parent [A]=”Nill”


Parent [B]=A
#0 open= [A] , closed=[ ] , found = No , parent [A]=”Nill”
#1 closed= [A] Parent [C]=A

Open= [B, C, D, E] Parent [D]=A


X=B Parent [E]=A
#2 Closed=[B, A] Parent [F]=B
Open= [C, D, E, F]
Parent [G]=C
X=C
Parent [H]=C
#3 Closed=[C, B, A]
Open= [D, E, F, G, H] Parent [M]=E
X=D Parent [R]=E
#4 Closed=[D, C, B, A] Parent [I]=F
Open=[ E, F, G, H]
Parent [J]=F
X=E
Parent [K]=G
Parent [L]=G
Artificial Intelligence

#5 Closed=[E, D, C, B, A]
Open=[F, G, H, M, R]
X=F
#6 Closed=[F, E, D, C, B, A ]
Open=[ G, H, M, R, I, J]
X=G
#7 Closed= [G, F, E, D, C, B, A]
Open= [H, M, R, I, J, K, L]
X=H
#8 Closed= [H, G, F, E, D, C, B, A]
Open= [M, R, I, J, K, L]
X=M
#9 Closed= [M, H, G, F, E, D, C, B, A]
Open= [R, I, J, K, L]
X=R
10# Closed= [R, M, H, G, F, E, D, C, B, A]
Open= [I, J, K, L]
X=I
11# Closed= [I, R, M, H, G, F, E, D, C, B, A]
Open= [J, K, L, N]
X=J
12# Closed= [J, R, M, H, G, F, E, D, C, B, A]
Open= [K, L, N]

13# X= K = Goal Path: A C G K

Depth-first with iterative deepening A


E
Start with one level use depth-first B R
D
if goal found stop
else use two level F C
H
I J M
G

N K L

P Q
Artificial Intelligence

Path: A B C G K

Comparison between depth- and breadth- first search algorithms:

Depth-first search gets quickly into a deep search space. If it is known that the solution path
will be long, depth-first search won't waste time searching a large number of "shallow" states
in the graph. On the other hand, depth-first search can get "lost" deep in a graph, missing
shorter paths to a goal or even becoming stuck in an infinitely long path that does not lead to
a goal. Depth-first search is much more efficient for searching spaces with many branches

since it does not have to keep all the nodes at a given level on the memory “open list”, so it
requires less memory space. Unlike breadth-first search, a depth first search does not
guarantee to find the shortest path to a state the first time it is encountered. Whereas,
breadthfirst search always finds the shortest path to a goal node. Breadth-first search will not
get trapped into along unfruitful path.

Heuristic Search

All of the search methods in the preceding section are uninformed in that they did not take
into account the goal.

The heuristic function is a way to inform the search about the direction to a goal. A heuristic
function h (n) is supposed to estimate the path cost of a solution beginning from the state at
node n to a goal node.

Hill climbing algorithm

Hill climbing (HC) algorithm is a technique for certain classes of optimization problems.
The idea is to start with a sub-optimal solution to a problem (i.e., start at the base of a hill)
and then repeatedly improve the solution (walk up the hill) until some condition is maximized
(the top of the hill is reached).
Artificial Intelligence

Begin
Cs=start, open = [start], stop=false, path [ ]
While (not stop) do Begin
Add Cs to path
If (Cs=Goal) then return (path);
Empty open;
Generate all possible children of CS and put into open;
If open = [ ] then
Stop= true; /* dead end reached */
Else Let X=Cs;
For each state Y in open do begin
Compute the heuristic value of Y , h(y);
If Y in better than X then X=Y
endfor
if X in better than CS then
CS=X
Else
Stop=true /* local optima*/
Endwhile
Return(fail)
End
Artificial Intelligence

Example:
A
100

B C D
38 33 30

H
E G 32
42 25

F
K
15
20

I J
10 8

N
L M
11
CS=A
3 5
Open=[B38,C33, D30]
#0 CS=A, open = [A], stop = false X= D30

#1 path= [A] CS= D30


CS=D30 OpenD = [G25 , H32]
#2 path= [D, A] X= G25
CS= G25
CS=G25
#3 path= [G, D, A] OpenG = [F15 , K20 ]
CS= F15 X= F15

CS=F15
#4 path=[F, G, D, A] OpenF = [I10 , J8 ]
CS= J8 X= J8

#5 path= [J, F, G, D, A] Cs= J8


Open = [M5 , N11 ]
X= M5
Artificial Intelligence

CS= M5

#6 path= [M, J, F, G, D, A]
CS= Goal, stop
Best –first (no cost fuction)

Begin
Input the start node S and the set of Goal nodes
Open = [S] ; closed= [ ];
Pred[S]= null; found= false;
While (open is not empty) and found = false Do Begin
L= the set of nodes on open for which h has the best value;
If L is a set with a single element then let X be that element;
Else
If there are any goals in L then let X be one of them
Else let X be the first element of L;
endif
remove X from open and put in close;
if X in the goal node then found=true
else
Begin
Generate the set Succ of children of X ;
For each child Y in Succ do
If Y is not already in open or closed then
Begin
Compute h[Y]; pred[Y]=X;
Insert Y in open;
Endif
Endfor
Endif
Endwhile
If found is false output failure
Else trace the pointers in pred to compute the solution path
Endif
Artificial Intelligence

End.

Example:

#0 open =[A] , closed = [ ] P[A]= null


#1 X=A100 P[B]= A
Open=[B25 , C33 , D30 ]
Closed = [A100 ] P[C]=A

P[D]= A
#2 X=B25
Closed= [B25 , A100 ] P[E]= B
Open = [E25 , C33 , D30 ]
P[G]= D
#3 X=D30 P[H]=D
Closed= [D30 , B25 , A100 ]
P[F]=C
Open = [G37 , H32 , E35 , C33 ]
P[I]= E
#4 X= H32
P[L]=I

P[M]= I
Artificial Intelligence

Closed= [H32 , D30 , B25 , A100 ]


Open = [G37 , E35 , C33 ]

#5 X= C33
Closed= [C33 , H32 , D30 , B25 , A100 ]
Open = [F38 , G37 , E35 ]

#6 X=E35
Closed = [ E35 , C33 , H32 , D30 , B25 , A100 ]
Open = [I20 , F38 , G37 ]

#7 X= I20
Closed = [ I20 , E35 , C33 , H32 , D30 , B25 , A100 ]
Open = [L3 , M5 , F38 , G37 ]

#8 X= L3
Closed = [ L3 , I20 , E35 , C33 , H32 , D30 , B25 , A100 ]
Open = [M5 , F38 , G37 ]

#9 X= M5
Found = true

Path: A B E I M
Artificial Intelligence

Lecture 3
Cost Function

The heuristic function is a way to inform the search about the direction to a goal. It provides
an informed way to guess which neighbor of a node will lead to a goal. There is no general
theory for finding heuristics, because every problem is different.

Another way to measure the cost from the start state to the goal state is the evaluation
function (cost function). Cost function can be measured as,

𝑓(𝑛) = 𝑔(𝑛) + ℎ(𝑛)


Where
𝑔(𝑛) : is the (known) distance from the start state to a node n.
ℎ(𝑛) : is the heuristic function that estimates the distance between node n and a goal node.
𝑓(𝑛): is distance from the start node to a goal node.
S

g (n1) g (n2)

n1 n2

h(n1) h(n2)

Goal
f (n1) = g(n1) + hn1) f(n2) = g(n2) + h(n2)

example: S

g(n1) = 100 g(n2) = 70


n1
h(n1) = 50 n2 h(n2) = 60
f(n1) = 150 f(n2) = 130
G
Artificial Intelligence

Heuristic Search Algorithms (with cost function)


A* Algorithm (Best-First Search Algorithm with cost)
Artificial Intelligence

Example:
Consider the following state space graph in Figure below with Initial State: A and Goal State
M. Find the path using A* algorithm.

7
A 14
100
9
B D
38 35 15
C 8
12 33
H
E 25 8 G 32
22 35 10

14
F
9 K
15 20
13 26

18
I J
10 40 8 6

8 14
N
L M
8
3 5
#0 open = [A100], closed = [ ]

#1 X=A100
State Pred h(state) g(state) f(state)
Open = [B45, C42, D49] A Null 100 0 100
Closed = [A] B A 38 7 45
__________________________ C A 33 9 42
#2 X= C42 D A 35 14 49
Closed = [C42, A100] F C,E,G 15 34, 33, 30 49, 48, 45
Open = [F49, B45, D49] E B 22 19 41
__________________________ I E 40 28 68
J F 8 51, 48 95, 56
#3 X= B45
G D 25 22 47
Closed = [B45, C42, A100] H D 32 29 61
Open = [E41, F49, D49] K G 26 32 58
__________________________ M J 5 62 67
#4 X= E41 N J 8 54 62
Closed = [E41, B45, C42, A100]
Open = [F48, I68, D49] F from E
Artificial Intelligence

Temp (F) = 15+19+14=48


#5 X= F48 LF = [I, J]
Closed = [F48, E41, B45, C42, A100] temp [I] = 40+33+13= 86
Open = [J59, I86, D49]
_____________________________
#6 X= D49
Closed = [D49, F48, E41, B45, C42, A100]
Open = [G47, H61, J59, I68]
______________________________
#7 X= G47 LG = [F, K]
Closed = [G47 , D49 , F48 , E41 , B45 , C42 , A100 ] temp[F]= 15+8+22 = 45
Open = [F45, K58, H61, J59, I68]
_______________________________
#8 X= F45 LF = [I, J]
Closed = [F45 , G47 , D49 , F48 , E41 , B45 , C42 , A100 ] temp[I] = 40+13+30 = 83
Open = [K58, H61, J56, I68] temp [J] = 8+18+30 = 56
_______________________________
#9 X= J56
Closed = [J56 , F45 , G47 , D49 , F48 , E41 , B45 , C42 , A100 ]
Open = [M67, N62, K58, H61, I68]
_______________________________
#10 X= K58
Closed = [K58 , J56 , F45 , G47 , D49 , F48 , E41 , B45 , C42 , A100 ]
Open = [M67, N62, H61, I68]
_______________________________
#11 X= H61
Closed = [H61 , K58 , J56 , F45 , G47 , D49 , F48 , E41 , B45 , C42 , A100 ]
Open = [M67, N62, I68]

#12 X= N62
Closed = [N62 , H61 , K58 , J56 , F45 , G47 , D49 , F48 , E41 , B45 , C42 , A100 ]
Open = [M67, I68]
_______________________________
#13 X= M67
Artificial Intelligence

Y in the goal: stop path: A →D →G →F →J →M

_______________________________________________________________

Logic Representation

In order to determine appropriate actions to take to achieve goals, an intelligent system needs
to compactly represent information about the world and draw conclusions based on general
world knowledge and specific facts.

Propositional Logic
Logic Representation
Predicate Logic

Propositional Logic
Propositional symbols are used to represent facts. Each symbol can mean what we want it to
be. Each fact can be either true or false. Propositional symbols: P, Q, etc. representing
specific facts about the world. For example,
P1 = “Water is a liquid”.
P2= “Today is Monday”.
P3= “It is hot”

Example :

q1= “The ground is wet”


q2=”It is raining” if q2 then q1

Propositions are combined with logical connectives to generate sentences with more complex
meaning. The connectives are:
Artificial Intelligence

p q ¬p p^ q Pvq P→q
T T F T T T
T F F F T F
F T T F T T
F F T F F T

For example, a proof of the equivalence of P → Q and ˥ P  Q is given by the truth table:

Answer:

P Q ˥P ˥ P Q P→Q
T T F T T
T F F F F
F T T T T
F F T T T
Artificial Intelligence
Example: Use a truth table to list all possible truth value assignments to the propositions of the expression (P
∧ Q)  (˥ Q  P).

Answer

P Q P∧Q ˥Q ˥QP (P ∧ Q)  (˥ Q  P)
T T T F T T
T F F T T T
F T F F F F
F F F T T T

H/W Prove T r u e o r f a ls e : ((P→Q ) ∧ Q )→P . A n s w e r


Artificial Intelligence

Lecture 4
Predicate Logic (First-Order logic)

In propositional logic, we can only represent the facts, which are either true or false.
Propositional logic is not sufficient to represent the complex sentences or natural language
statements. The propositional logic has very limited expressive power. Some statements
cannot be expressed in propositional logic, such as:

• All men are mortal.


• Some trees have needles.
• X > 3.

Predicate logic can express these statements and make inferences on them.

Predicate logic is also known as First-order 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.

Statements in Predicate Logic

𝑷(𝒙, 𝒚)
- A predicate P describes a relation or property.
- Variables (x, y) can take arbitrary values from some domain.
- Still have two truth values for statements (T and F).
- When we assign values to x and y, then P has a truth value.

Examples:
• Let Q(x, y) denote “x=y+3”.
What are truth values of:
- Q (1, 2) false
- Q (3, 0) true

• P = “it rained in Tuesday “

Weather (Tuesday, rain)

Predicate argument
Artificial Intelligence

q= “water is liquid”

liquid (water)
liquid (milk)

property (water, milk)

Generality: - predicate logic allows the use of variables and then we can represent general
statements.

P1 = “it rained on Tuesday”

P2= “it rained on Wednesday”

∀𝑋 𝑤𝑒𝑎𝑡ℎ𝑒𝑟 ( 𝑋 , 𝑟𝑎𝑖𝑛)

X ∈ { 𝑆𝑎𝑡𝑒𝑟𝑑𝑎𝑦, … . , 𝐹𝑟𝑖𝑑𝑎𝑦 )
P7= “it rained on Monday”

Definitions:

Constant: A constant refers to a specific object. A constant starts with a lower case letter.

Variable: A variable is used to refer to general classes of objects. A variable starts with an
upper case letter.

Function: a function name starts with a lower case letter. It has an associated number of
arguments and returns a value.

Example: product (a, b) returns a*b


Product (2, 3) returns 6

Term: a term is either a constant, variable or a function. The English alphabet (a...z, A...Z)
and the digits 0...9 and the character is used to constant term.
Artificial Intelligence

Atomic sentence: An atomic sentence is formed from a predicate symbol followed by list of
terms enclosed in parentheses and separated by commas. Predicate logic
sentences are delimited by a period (.).

Atomic Sentence = predicate (term1... termn)

Example: help (ali, ahmed, friday).


Like (ali, math).

The symbols true or false are also regarded as atomic sentences.


Example: LargeThan (2, 3) is false

Atomic sentences are used to construct compound expressions or


sentences using the connections: - ¬ , ^, v, → , =

Literal: a literal is an atomic sentence or the negation of an atomic sentence.

Clauses: A clause is one or more literals combined using the connectives above. An atomic
sentence is called a unit clause (it consists of one literal).

Horn Clause: A horn clause has the following form:


b1 ( ) ∧ b2 ( ) ∧ … ∧ bn ( ) → a ( ).

Where b1… bn and 𝑎 are all positive literals. a ( ) is called the head of the horn clause. b1
( )… bn ( ) is called the body of the horn clause.

There are three cases of the horn clause:

1- a ( ) (horn clause has no body), In this case the clause is called a Fact.

2- b1 ( ) ∧ b2 ( ) ∧ … ∧ bn ( )
The horn clause has no head. In this case it is regarded as a set of subgoals to be proved.

3- b1 ( ) ∧ b2 ( ) ∧ … ∧ bn ( ) → a ( ) (the standard form of the horn clause)


In this case the clause is called a Rule.
Artificial Intelligence

Using the identity P → q ≡ ¬ p v q


¬ (b1 ( ) ∧ … ∧ bn ( )) v a ( )
¬ b1 ( ) v ¬ b2 ( ) v … v ¬ bn v a ( )

Thus, a horn clause can be defined as a clause of disjunction of literals with at most.

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).
• Each variable must be associated with one of the two quantifiers ( ∀ or ∃ ) depending on
the meaning required.

Common Identifiers

(1) ¬∃𝑋 𝑝(𝑋) ≡ ∀𝑋 ¬ 𝑝(𝑋)

(2) ¬∀𝑋 𝑝(𝑋) ≡ ∃𝑋 ¬ 𝑝(𝑋)

(3) ∃𝑋 𝑝(𝑋) ≡ ∃𝑌 𝑝(𝑌)

(4) ∀𝑋 𝑝(𝑋) ≡ ∀𝑌 𝑝(𝑌)

(5) ∀𝑋 [𝑝(𝑋) ∧ 𝑞(𝑋)] ≡ ∀𝑋 𝑝(𝑋) ∧ ∀𝑌 𝑞(𝑌)

(6) ∃𝑋 [𝑝(𝑋) ∧ 𝑞(𝑋)] ≡ ∃𝑋 𝑝(𝑋) ∧ ∃𝑌 𝑞(𝑌)


Artificial Intelligence

Examples of knowledge representation:

1. If it does not rain tomorrow, Zaki will go to the lake.


¬ 𝑤𝑒𝑎𝑡ℎ𝑒𝑟 (𝑡𝑜𝑚𝑜𝑟𝑟𝑜𝑤, 𝑟𝑎𝑖𝑛) → 𝑔𝑜(𝑧𝑒𝑘𝑖, 𝑙𝑎𝑘𝑒)

2. All basketball players are tall.


(a) ∀𝑥 [ 𝑝𝑙𝑎𝑦𝑒𝑟(𝑥) ∧ 𝑝𝑙𝑎𝑦 (𝑥, 𝑏𝑎𝑠𝑘𝑒𝑡𝑏𝑎𝑙𝑙) → 𝑡𝑎𝑙𝑙(𝑥) ] 𝑥 ∈ (𝑠𝑒𝑡 𝑜𝑓 𝑎𝑙𝑙 𝑡ℎ𝑖𝑛𝑔𝑠)
(b) ∀𝑥 [ 𝑝𝑙𝑎𝑦 (𝑥, 𝑏𝑎𝑠𝑘𝑒𝑡𝑏𝑎𝑙𝑙) → 𝑡𝑎𝑙𝑙(𝑥)] 𝑥 ∈ (𝑠𝑒𝑡 𝑜𝑓 𝑎𝑙𝑙 𝑏𝑎𝑠𝑘𝑒𝑡𝑏𝑎𝑙𝑙 𝑝𝑙𝑎𝑦𝑒𝑟𝑠)

3. Some students like a.i.


∃𝑥 [𝑠𝑡𝑢𝑑𝑒𝑛𝑡 (𝑥) ∧ 𝑙𝑖𝑘𝑒(𝑥, 𝑎. 𝑖)]
All students like a.i. 𝑥 ∈ (𝑠𝑒𝑡 𝑜𝑓 𝑎𝑙𝑙 𝑡ℎ𝑖𝑛𝑔𝑠)
∀𝑥 [ 𝑠𝑡𝑢𝑑𝑒𝑛𝑡(𝑥) → 𝑙𝑖𝑘𝑒 (𝑥, 𝑎. 𝑖. )]

4. Nobody likes taxes.


¬ ∃𝑥 𝑙𝑖𝑘𝑒 (𝑥, 𝑡𝑎𝑥𝑒𝑠). 𝑥 ∈ (𝑠𝑒𝑡 𝑜𝑓 𝑎𝑙𝑙 𝑝𝑒𝑜𝑝𝑙𝑒)
∀𝑥 ¬ 𝑙𝑖𝑘𝑒 (𝑥, 𝑡𝑎𝑥𝑒𝑠).

5. All men drink coffee.


∀𝑥 𝑚𝑎𝑛(𝑥) → 𝑑𝑟𝑖𝑛𝑘 (𝑥, 𝑐𝑜𝑓𝑓𝑒𝑒).

6. Some boys are intelligent.


∃𝑥 𝑏𝑜𝑦𝑠(𝑥) ∧ 𝑖𝑛𝑡𝑒𝑙𝑙𝑖𝑔𝑒𝑛𝑡(𝑥)

7. All birds fly.


∀𝑥 𝑏𝑖𝑟𝑑(𝑥) → 𝑓𝑙𝑦(𝑥).

8. Every man respects his parent.


∀𝑥 𝑚𝑎𝑛(𝑥) → 𝑟𝑒𝑠𝑝𝑒𝑐𝑡𝑠 (𝑥, 𝑝𝑎𝑟𝑒𝑛𝑡).

9. Some boys play cricket.


∃𝑥 𝑏𝑜𝑦𝑠(𝑥) → 𝑝𝑙𝑎𝑦(𝑥, 𝑐𝑟𝑖𝑐𝑘𝑒𝑡).

10. Not all students like both Mathematics and Science.


¬∀ (𝑥) [ 𝑠𝑡𝑢𝑑𝑒𝑛𝑡(𝑥) → 𝑙𝑖𝑘𝑒(𝑥, 𝑀𝑎𝑡ℎ𝑒𝑚𝑎𝑡𝑖𝑐𝑠) ∧ 𝑙𝑖𝑘𝑒(𝑥, 𝑆𝑐𝑖𝑒𝑛𝑐𝑒)]
Artificial Intelligence

Unification

• Unification is a process of making two different logical atomic expressions identical by


finding a substitution. Unification depends on the substitution process.

• Unification is the process of making a set of literals with the same predicate match each
other exactly.

• In finding a substitution set we must seek a variable to be replaced by a term. Also a


variable cannot be replaced by a function of itself.

• Assume we have a set of literals to be unified {𝐿1 , 𝐿2 , … , 𝐿𝑘 }


We seek a substitution 𝐹 = {(𝑡1 , 𝑣1 ), … , (𝑡𝑛 , 𝑣𝑛 )} where variable 𝑣𝑖 is replaced by term 𝑡𝑖

Such that 𝑙1 𝐹 = 𝐿2 𝐹 = ⋯ = 𝐿𝑘 𝐹

Where 𝐿𝑖 𝐹 indicate the result of apply the substitution in 𝐹 on 𝐿𝑖

Example:

Assume that:- 𝐿 = 𝑝(𝑋, 𝑌, 𝑓(𝑌), 𝑏).

𝐹 = { (𝑎, 𝑋), (𝑓(𝑧), 𝑌)}

𝐿𝐹 = 𝑝(𝑎, 𝑓(𝑧), 𝑓(𝑓(𝑧), 𝑏).


Example:

𝐿1 = 𝑝(𝑋, 𝑌, 𝑏) , 𝐿2 = 𝑝(𝑍, 𝑊, 𝑏).


𝐹1 = { (𝑎, 𝑋), (𝑎, 𝑍), (𝑐, 𝑌), (𝑐, 𝑊)}
𝐿1 𝐹1 = 𝑝(𝑎, 𝑐, 𝑏)
𝐿2 𝐹1 = 𝑝(𝑎, 𝑐, 𝑏)

𝐹2 = {(𝑋, 𝑍), (𝑌, 𝑊)}


𝐿1 𝐹2 = 𝑝(𝑋, 𝑌, 𝑏)
𝐿2 𝐹2 = 𝑝(𝑋, 𝑌, 𝑏)

𝐹3 = {(𝑎, 𝑋), (𝑎, 𝑍), (𝑦, 𝑊)}


𝐿1 𝐹3 = 𝑝(𝑎, 𝑦, 𝑏)
𝐿2 𝐹3 = 𝑝(𝑎, 𝑦, 𝑏)
Artificial Intelligence

Procedure Most General Unifier (MGU)

Begin
Generate the first disagreement set D
Repeat
While (D in disagreement) do
If none of the terms in D consists of a variable by itself, then
* stop and report failure *

Else
*convert a variable into a term by adding a pair of the form (𝑡𝑖 , 𝑣𝑖 )
and perform the substitution on the predicates immediately *

If 𝑣𝑖 is not in F as a second argument pair, then add a pair (𝑡𝑖 , 𝑣𝑖 ) to F

Else * stop and report failure *


Endif
Endif
Endwhile
Generate the next disagreement set D
Until (no disagreement set remain)

* return the substitution set F


End.

Examples:
1. Find the MGU of Let 𝐋𝟏 = 𝐩(𝐗, 𝐟(𝐲)), 𝐋𝟐 = 𝐩(𝐚, 𝐟(𝐠(𝐳)))
Solution:
Step1:
D={x, a}
L1= p (a, f(y))
L2 = p (a, f (g (z)))
Step2:
D= {y, g (z)}
L”1= p (a, f (g (z)))
L”2= p (a, f (g (z))) Unified Successfully.
Artificial Intelligence

2. Find the MGU of L1= p(X, X) , L2= p(f(a), g(Y))


Solution:
Step1:
D= {X, f (a)}
L1= p (f (a), f (a))
L2= p (f (a), g(Y))

Step2:
D= {f (a), g (y)} Unification failed

3. Find the MGU of L1 = p (Z, f(Y), f(Y)), L2 = p (b, X, f (g (Z))


Solution:
Step1
D= {Z, b}
L1= p (b, f(Y), f(Y))
L2= p (b, X, f (g (b)))

Step2
D= {X, f(Y)}
L’1= p (b, f(Y), f(Y))
L’2= p (b, f(Y), f (g (b)))

Step3
D= {Y, g (b)}
L”1= p (b, f (g (b), b (g (b))
L”2= p (b, f (g (b), b (g (b)) Unified Successfully.

4. Find the MGU of L1= p (X, X), L2= p (Z, f (Z))


Step1
D= {X, Z}
L1= p (Z, Z)
L2= p (Z, f (Z))

Step2
D= {Z, f (Z)} Unification Failed.
Artificial Intelligence

5. Find the MGU of L1= (prime (11), L2= prime(y)


Step1
D= {y, 11}
L1= prime (11)
L2= prime (11) successfully unified

6. Find the MGU of L1= Q (a, g(x, a), f(y)), L2= Q (a, g (f (b), a), x)
Step1
D= {x, f (b)}
L1= Q (a, g (f (b), a), f(y))
L2= Q (a, g (f (b), a), f (b))

Step2
D= {y, b}
L’1= Q (a, g (f (b), a), f (b))
L’2= Q (a, g (f (b), a), f (b)) successfully unified

7. Unify L1= knows (Richard, x), L2= knows (Richard, John)


Step1
D= {x, john}
L1= knows (Richard, john)
L2= knows (Richard, john) Successfully Unified.
Artificial Intelligence

Lecture 5
Skolemization

Skolemization is the process of eliminating existential qualifiers and their corresponding


variables.

Example:

∃𝑋 𝑓𝑎𝑡ℎ𝑒𝑟(𝑋, 𝑎𝑙𝑖).

𝐹𝑎𝑡ℎ𝑒𝑟 (𝑧𝑒𝑘𝑖, 𝑎𝑙𝑖).

Skolem constant

∀𝑋 𝑓𝑎𝑡ℎ𝑒𝑟 (𝑓(𝑥), 𝑋).

Skolem function

∀𝑋 𝑓𝑎𝑡ℎ𝑒𝑟 (𝑎, 𝑋)

∀𝑋 ∀𝑌 ∃𝑍 ∃𝑊 𝑝(𝑋, 𝑌, 𝑍, 𝑊)
∀𝑋 ∀𝑌 𝑝(𝑋, 𝑌, 𝑓(𝑥, 𝑦), 𝑔(𝑥, 𝑦)).

∀𝑋 ∀𝑌 ∃𝑍 ∀𝑊 𝑝(𝑋, 𝑌, 𝑍, 𝑊) Z= f(x,y)

∀𝑋 ∀𝑌 ∀𝑊 𝑝(𝑋, 𝑌, 𝑓(𝑥, 𝑦), 𝑊)

Clause Normal Form

Definition: - A predicate logic expression (wff) is a clause normal form if it consists of a


disjunction of literals.
Artificial Intelligence

Steps to convert a wff to a normal form

∀𝑋{[𝑝(𝑋) ∧ 𝑞(𝑋)] → [𝑟(𝑋, 𝑎) ∧ ∃𝑌(∃𝑍 𝑟(𝑌, 𝑍) → 𝑠(𝑋, 𝑌))]} ∨ ∀𝑋 𝑡(𝑋)

1) Eliminate (→) by using the identity. (𝑝 → 𝑞 ≡ ⅂𝑝 ∨ 𝑞 )

∀𝑋{⅂ [𝑝(𝑋) ∧ 𝑞(𝑋)] ∨ [𝑟(𝑋, 𝑎) ∧ ∃𝑌( ⅂∃𝑍 𝑟(𝑌, 𝑍) ∨ 𝑆(𝑋, 𝑌))]} ∨ ∀𝑋 𝑡(𝑋)

2) Reduce the scope of negation.

∀𝑋{[⅂ 𝑝(𝑋) ∨ ⅂𝑞(𝑋)] ∨ [𝑟(𝑋, 𝑎) ∧ ∃𝑌 (∀𝑍 ⅂𝑟 (𝑌, 𝑍) ∨ 𝑆(𝑋, 𝑌)))]} ∨ ∀𝑋 𝑡(𝑋)

3) Standaring variables so that each quantifier uses a different variable.


∀𝑋{[⅂ 𝑝(𝑋) ∨ ⅂𝑞(𝑋)] ∨ [𝑟(𝑋, 𝑎) ∧ ∃𝑌 (∀𝑍 ⅂𝑟 (𝑌, 𝑍) ∨ 𝑆(𝑋, 𝑌)))]} ∨ ∀𝑊 𝑡(𝑊)

4) ∀𝑋 ∃𝑌 ∀𝑍 ∀𝑊 [{[⅂ 𝑝(𝑋) ∨ ⅂𝑞(𝑋)] ∨ [𝑟(𝑋, 𝑎) ∧ ( ⅂𝑟 (𝑌, 𝑍) ∨ 𝑆(𝑋, 𝑌))]} ∨ 𝑡(𝑊)]

5) Skoleming ∃ quantified variables.


∀𝑋 ∀𝑍 ∀𝑊 {[⅂ 𝑝(𝑋) ∨ ⅂𝑞(𝑋)] ∨ [𝑟(𝑋, 𝑎) ∧ ( ⅂𝑟 (𝑡(𝑋)), 𝑍) ∨ 𝑆(𝑋, 𝑡(𝑥))]} ∨ 𝑡(𝑊)]

6) Drop all ∀ quantifiers.

{[⅂ 𝑝(𝑋) ∨ ⅂𝑞(𝑋)] ∨ [𝑟(𝑋, 𝑎) ∧ ( ⅂𝑟 (𝑓(𝑋)), 𝑍) ∨ 𝑆(𝑋, 𝑓(𝑋))]} ∨ 𝑡(𝑊)]

7) Convert the expression into a conjunction of disjunction.


{[[⅂ 𝑝(𝑋) ∨ ⅂𝑞(𝑋)] ∨ [𝑟(𝑋, 𝑎)] ∧ [[( ⅂𝑝(𝑋) ∨ ⅂𝑞(𝑋)] ∨ (⅂𝑟(𝑓(𝑋), 𝑍) ∨ 𝑆(𝑋, 𝑓(𝑋)))]}
∨ 𝑡(𝑊)
Artificial Intelligence

{[[⅂𝑝(𝑋) ∨ ⅂𝑞(𝑋)] ∨ [𝑟(𝑋, 𝑎)] ∨ 𝑡(𝑊)}


∧ {[[(⅂𝑝(𝑋) ∨ ⅂𝑞(𝑋)] ∨ (⅂𝑟(𝑓(𝑋), 𝑍))] ∨ 𝑆(𝑋, 𝑓(𝑋))] ∨ 𝑡(𝑊)}
[ ⅂𝑝(𝑋) ∨ ⅂𝑞(𝑋) ∨ 𝑟(𝑋, 𝑎) ∨ 𝑡(𝑊)] ∧ [ ⅂𝑝(𝑋) ∨ ⅂𝑞(𝑋) ∨ ⅂𝑟(𝑓(𝑥), 𝑍) ∨ 𝑆(𝑋, 𝑓(𝑋) ∨ 𝑡(𝑊)]

8) Write each conjunction as a separate clause.


i) ⅂𝑝(𝑋) ∨ ⅂𝑞(𝑋) ∨ 𝑟(𝑋, 𝑎) ∨ 𝑡(𝑊)
ii) ⅂𝑝(𝑋) ∨ ⅂𝑞(𝑋) ∨ ⅂𝑟(𝑓(𝑋), 𝑍) ∨ 𝑆(𝑋, 𝑓(𝑋)) ∨ 𝑡(𝑊)

9) Remove variables so that each clause assumes a different set of variables.


i) ⅂p(X1) ∨ ⅂q(X1) ∨ r(X1, a) ∨ t(W1)
ii) ⅂p(X2) ∨ ⅂q(X2) ∨ ⅂r(f(X2),Z2) ∨ S(X2 ,f(X2)) ∨ t(W2)

Reasoning with Logic


A reasoning or inference rule is a mechanism for producing new sentences from other
sentences. There many types of reasoning mechanisms. The most common mechanism is
called Resolution. Resolution is the process of choosing two clauses in normal form such that
one contains (p) predicate and the negation (p) of this predicate in the other clause. The result
is a clause called the resolvent which consists of the disjunction of all the predicates of the
two clauses except the predicate (p) and its negation (p). This procedure continues until we
reach to contradiction or no contradiction. A contradiction is obtained when the empty clause
is generated. If contradiction is reached, this means that a clause with its negative cannot be
true and considered with the other clauses that are involved in the same context, and the
clause should be true; otherwise, if no contradiction then the negative clause is correct.

Resolution mechanism has two main parts:


1. Modus ponens
2. Resolution
Artificial Intelligence

Modus ponens
This rule states that:-
𝑔𝑖𝑣𝑒𝑛 𝑝 → 𝑞
&𝑝
___________________
𝑐𝑜𝑛𝑐𝑙𝑢𝑠𝑖𝑜𝑛: − 𝑞

Example1: (propositional logic)


Given “if it is raining then the ground will be wet”.
and “ it is raining”.

Solution:
What conclusion can be drawn? (Conclusion: the ground is wet)
Let
P: “it is raining”
q:”the ground is wet”
𝑝→𝑞
𝑝
∴ 𝑞 Is true

Example 2: (predicate logic)


Assume the following:

1. “all men are mortal”


2. “Socrates is a man”
Artificial Intelligence

What can be inferred?

1. ∀𝑋[𝑚𝑎𝑛(𝑋) → 𝑚𝑜𝑟𝑡𝑎𝑙(𝑋)]
2. 𝑚𝑎𝑛(𝑠𝑜𝑐𝑟𝑎𝑡𝑒𝑠)

Since (1) is true ∀𝑋, it is true when 𝑥 = 𝑠𝑜𝑐𝑟𝑎𝑡𝑒𝑠

𝑚𝑎𝑛(𝑠𝑜𝑐𝑟𝑎𝑡𝑒𝑠)

𝑚𝑜𝑟𝑡𝑎𝑙(𝑠𝑜𝑐𝑟𝑎𝑡𝑒𝑠)

Proof by Refutation (Resolution)


Resolution refutation proves a goal by negating the statement to be proved and adding it to
the set of clauses known to be true.
It then uses resolution rule of inference to show that there is a contradiction.
A contradiction is obtained when the empty clause is generated. An empty clause represents a
contradiction because it is the result of resolving a clause with its own negation and since
both cannot be true at the same time, it follows that the null clause represents a contradiction.

Resolution
Definition: resolution is the process of choosing two clauses in normal form such that one (p)
contains the negation of a literal in the other clause (⅂p). The result is a clause called the
resolvent which consists of the disjunction of all the literals in the two clauses except the
literal p and its negation ⅂p.

C1: 𝑝 ∨ 𝑞 ∨ 𝑟 (parent clause 1)


C2:𝑝 ∨ ⅂𝑞 ∨ 𝑠 (parent clause 2)
_____________________________
Artificial Intelligence

𝑝∨𝑟∨𝑠 (Resolvent)

Example 1:
Given the following:
1. “Fido is a dog”.
2. “All dogs are animals”.
3. “All animals will die”.
Goal: Fido will die.
Solution:

𝐶1 : 𝑑𝑜𝑔(𝑓𝑖𝑑𝑜) 𝐶1′ : 𝑑𝑜𝑔(𝑓𝑖𝑑𝑜)


𝐶2 : ∀𝑋1 [𝑑𝑜𝑔(𝑋1 ) → 𝑎𝑛𝑖𝑚𝑎𝑙𝑠 (𝑋1 )] 𝐶2′ : ⅂𝑑𝑜𝑔(𝑋1 ) ∨ 𝑎𝑛𝑖𝑚𝑎𝑙(𝑋1 )
𝐶3 : ∀𝑋2 [𝑎𝑛𝑖𝑚𝑎𝑙(𝑋2 ) → 𝑑𝑖𝑒(𝑋2 )] 𝐶3′ : ⅂ 𝑎𝑛𝑖𝑚𝑎𝑙(𝑋2 ) ∨ 𝑑𝑖𝑒(𝑋2 )
𝐺𝑜𝑎𝑙: 𝑑𝑖𝑒(𝑓𝑖𝑑𝑜) 𝑔𝑜𝑎𝑙: ⅂ 𝑑𝑖𝑒(𝑓𝑖𝑑𝑜)

(𝑓𝑖𝑑𝑜, 𝑋2 )
1) 𝑔: ⅂ 𝑑𝑖𝑒(𝑓𝑖𝑑𝑜) 𝐶4 : ⅂ 𝑎𝑛𝑖𝑚𝑎𝑙 (𝑓𝑖𝑑𝑜)
𝐶3′ : ⅂ 𝑎𝑛𝑖𝑚𝑎𝑙(𝑋2 ) ∨ 𝑑𝑖𝑒(𝑋2 )

(𝑓𝑖𝑑𝑜, 𝑋1 )
2) 𝐶4 : ⅂ 𝑎𝑛𝑖𝑚𝑎𝑙 (𝑓𝑖𝑑𝑜) 𝐶5 : ⅂ 𝑑𝑜𝑔(𝑓𝑖𝑑𝑜)
𝐶2′ : ⅂ 𝑑𝑜𝑔(𝑋1 ) ∨ 𝑎𝑛𝑖𝑚𝑎𝑙 (𝑋1 )
Artificial Intelligence

Example 2:
Consider the following story:
“Anyone passing his history exams and winning the lottery is happy. Anyone who studies or
is lucky passes all his exams. Ali did not study but he is lucky. Anyone who is lucky wins
the lottery”.

Goal: who is happy?

Solution:

𝐶1 : ∀𝑋1 [𝑝𝑎𝑠𝑠(𝑋1 , ℎ𝑖𝑠𝑡𝑜𝑟𝑦) ∧ 𝑤𝑖𝑛 (𝑋1 , 𝑙𝑜𝑡𝑡𝑒𝑟𝑦) → ℎ𝑎𝑝𝑝𝑦(𝑋1 )].


𝐶2 : ∀𝑋2 ∀𝑌2 [𝑠𝑡𝑢𝑑𝑦(𝑋2 ) ∨ 𝑙𝑢𝑐𝑘𝑦(𝑋2 ) → 𝑝𝑎𝑠𝑠(𝑋2 , 𝑌2 )].
𝐶3 : ⅂𝑠𝑡𝑢𝑑𝑦(𝑎𝑙𝑖) ∧ 𝑙𝑢𝑐𝑘𝑦(𝑎𝑙𝑖).
𝐶4 : ∀𝑋3 [𝑙𝑢𝑐𝑘𝑦(𝑋3 ) → 𝑤𝑖𝑛 (𝑋3 , 𝑙𝑜𝑡𝑡𝑒𝑟𝑦)].
𝐶5 : ⅂∃𝑍 ℎ𝑎𝑝𝑝𝑦(𝑍).

𝐶1 : ⅂𝑝𝑎𝑠𝑠(𝑋1 , ℎ𝑖𝑠𝑡𝑜𝑟𝑦) ∨ ⅂𝑤𝑖𝑛 (𝑋1 , 𝑙𝑜𝑡𝑡𝑒𝑟𝑦) ∨ ℎ𝑎𝑝𝑝𝑦(𝑋1 ).


𝐶2 : [⅂𝑠𝑡𝑢𝑑𝑦(𝑋2 ) ∧ ⅂𝑙𝑢𝑐𝑘𝑦(𝑋2 )] ∨ 𝑝𝑎𝑠𝑠(𝑋2 , 𝑌2 ).
𝐶2.1 : ⅂𝑠𝑡𝑢𝑑𝑦(𝑋2 ) ∨ 𝑝𝑎𝑠𝑠(𝑋2 , 𝑌2 ).
𝐶2.2 : ⅂𝑙𝑢𝑐𝑘𝑦(𝑋3 ) ∨ 𝑝𝑎𝑠𝑠(𝑋3 , 𝑌3 ).

𝐶3 : ⅂𝑠𝑡𝑢𝑑𝑦(𝑎𝑙𝑖) ∧ 𝑙𝑢𝑐𝑘𝑦(𝑎𝑙𝑖).
𝐶3.1 : ⅂𝑠𝑡𝑢𝑑𝑦(𝑎𝑙𝑖).
𝐶3.2 : 𝑙𝑢𝑐𝑘𝑦(𝑎𝑙𝑖).

𝐶4 : ⅂𝑙𝑢𝑐𝑘𝑦(𝑋4 ) ∨ 𝑤𝑖𝑛 (𝑋4 , 𝑙𝑜𝑡𝑡𝑒𝑟𝑦).


𝑔: ⅂ℎ𝑎𝑝𝑝𝑦(𝑍).
Artificial Intelligence

1) 𝑔: ⅂ℎ𝑎𝑝𝑝𝑦(𝑍). (𝑍, 𝑋1 )
𝐶1 : ⅂𝑝𝑎𝑠𝑠(𝑋1 , ℎ𝑖𝑠𝑡𝑜𝑟𝑦) ∨ ⅂𝑤𝑖𝑛(𝑋1 , 𝑙𝑜𝑡𝑡𝑒𝑟𝑦) ∨ ℎ𝑎𝑝𝑝𝑦(𝑋1 ) 𝐶5 : ⅂𝑝𝑎𝑠𝑠(𝑍, ℎ𝑖𝑠𝑡𝑜𝑟𝑦) ∨
⅂𝑤𝑖𝑛(𝑍, 𝑙𝑜𝑡𝑡𝑒𝑟𝑦)

2) 𝐶5 : : ⅂𝑝𝑎𝑠𝑠(𝑍, ℎ𝑖𝑠𝑡𝑜𝑟𝑦) ∨ ⅂𝑤𝑖𝑛(𝑍, 𝑙𝑜𝑡𝑡𝑒𝑟𝑦) (ℎ𝑖𝑠𝑡𝑜𝑟𝑦, 𝑌3 ), (𝑍, 𝑋3 )


𝐶2.2 : ⅂𝑙𝑢𝑐𝑘𝑦(𝑋3 ) ∨ 𝑝𝑎𝑠𝑠 (𝑋3 , 𝑌3 ) 𝐶6 : ⅂𝑙𝑢𝑐𝑘𝑦(𝑍) ∨
⅂𝑤𝑖𝑛(𝑍, 𝑙𝑜𝑡𝑡𝑒𝑟𝑦)

3) 𝐶6 : ⅂𝑙𝑢𝑐𝑘𝑦(𝑍) ∨ ⅂𝑤𝑖𝑛(𝑍, 𝑙𝑜𝑡𝑡𝑒𝑟𝑦) (𝑎𝑙𝑖, 𝑍)


𝐶3.2 : 𝑙𝑢𝑐𝑘𝑦(𝑎𝑙𝑖) 𝐶7 : ⅂𝑤𝑖𝑛(𝑎𝑙𝑖, 𝑙𝑜𝑡𝑡𝑒𝑟𝑦)

4) 𝐶7 : ⅂𝑤𝑖𝑛(𝑎𝑙𝑖, 𝑙𝑜𝑡𝑡𝑒𝑟𝑦) (𝑎𝑙𝑖, 𝑋4 )

𝐶4 : ⅂𝑙𝑢𝑐𝑘𝑦(𝑋4 ) ∨ 𝑤𝑖𝑛 (𝑋4 , 𝑙𝑜𝑡𝑡𝑒𝑟𝑦) 𝐶8 : ⅂𝑙𝑢𝑐𝑘𝑦(𝑎𝑙𝑖)

5)𝐶8 : ⅂𝑙𝑢𝑐𝑘𝑦(𝑎𝑙𝑖)
𝐶3.2 : 𝑙𝑢𝑐𝑘𝑦(𝑎𝑙𝑖) Goal proved

Example 3:

“All people who are not poor and smart are happy. These people who read are not stupid.
John can read and is wealthy. Happy people have exciting lives”.
Can anyone be found with an exciting life?
𝐶1 : ∀𝑋( ⅂𝑝𝑜𝑜𝑟(𝑋) ∧ 𝑠𝑚𝑎𝑟𝑡(𝑋) → ℎ𝑎𝑝𝑝𝑦(𝑋)
𝐶2 : ∀𝑌(𝑟𝑒𝑎𝑑(𝑌) → 𝑠𝑚𝑎𝑟𝑡(𝑌))
𝐶3 : 𝑟𝑒𝑎𝑑(𝑗𝑜ℎ𝑛) ∧ ⅂𝑝𝑜𝑜𝑟(𝑗𝑜ℎ𝑛)
𝐶4 : ∀𝑍(ℎ𝑎𝑝𝑝𝑦(𝑍) → 𝑒𝑥𝑐𝑖𝑡𝑖𝑛𝑔(𝑍))
𝑔: ∀𝑊(𝑒𝑥𝑐𝑖𝑡𝑖𝑛𝑔(𝑊))

𝐶1 : 𝑝𝑜𝑜𝑟(𝑋) ∨ ⅂𝑠𝑚𝑎𝑟𝑡(𝑋) ∨ ℎ𝑎𝑝𝑝𝑦(𝑋)


Artificial Intelligence

𝐶2 : ⅂𝑟𝑒𝑎𝑑(𝑌) ∨ 𝑠𝑚𝑎𝑟𝑡(𝑌)
𝐶3.1 : 𝑟𝑒𝑎𝑑 (𝑗𝑜ℎ𝑛)
𝐶3.2 : ⅂𝑝𝑜𝑜𝑟 (𝑗𝑜ℎ𝑛)
𝐶4 : ⅂ℎ𝑎𝑝𝑝𝑦(𝑍) ∨ 𝑒𝑥𝑐𝑖𝑡𝑖𝑛𝑔(𝑍)
𝑔: ⅂𝑒𝑥𝑐𝑖𝑡𝑖𝑛𝑔(𝑊)

1) 𝑔: ⅂𝑒𝑥𝑐𝑖𝑡𝑖𝑛𝑔(𝑊) (W, Z)
𝐶4 : ⅂ℎ𝑎𝑝𝑝𝑦(𝑍) ∨ 𝑒𝑥𝑐𝑖𝑡𝑖𝑛𝑔(𝑍) 𝐶5 : ⅂ℎ𝑎𝑝𝑝𝑦(𝑊)

(W, X)
2) 𝐶5 : ⅂ℎ𝑎𝑝𝑝𝑦(𝑊)
𝐶1 : 𝑝𝑜𝑜𝑟(𝑋) ∨ ⅂𝑠𝑚𝑎𝑟𝑡(𝑋) ∨ ℎ𝑎𝑝𝑝𝑦(𝑋) 𝐶6 : 𝑝𝑜𝑜𝑟(𝑊) ∨ ⅂𝑠𝑚𝑎𝑟𝑡(𝑊)

3) 𝐶6 : 𝑝𝑜𝑜𝑟(𝑊) ∨ ⅂𝑠𝑚𝑎𝑟𝑡(𝑊) (W, Y)


𝐶2 : ⅂𝑟𝑒𝑎𝑑(𝑌) ∨ 𝑠𝑚𝑎𝑟𝑡(𝑌) 𝐶7 : 𝑝𝑜𝑜𝑟(𝑤) ∨ ⅂𝑟𝑒𝑎𝑑(𝑊)

4) 𝐶7 : 𝑝𝑜𝑜𝑟(𝑤) ∨ ⅂𝑟𝑒𝑎𝑑(𝑊) (john, W)


𝐶3.1 : 𝑟𝑒𝑎𝑑 (𝑗𝑜ℎ𝑛) 𝐶8 : 𝑝𝑜𝑜𝑟(𝑗𝑜ℎ𝑛)

5) 𝐶8 : 𝑝𝑜𝑜𝑟(𝑗𝑜ℎ𝑛)
𝐶3.2 : ⅂𝑝𝑜𝑜𝑟 (𝑗𝑜ℎ𝑛) Goal proved
Artificial Intelligence

Lecture 6

Resolution Control Strategies

1) Breadth_ First

In this strategy, each clause in the base set (starting set of clauses) is compared for resolution
with every other clause in first round. On the second round, the new clauses produced on the
first round plus all the clauses in the base set are compared for resolution.

For the nth round, all previously generated clauses are added to the base set and all clauses are
compared for resolution.

In this strategy, the number of clauses to be compared can become extremely large at early
round of large problems which make it inefficient. However, this strategy ensures find the
shortest path to a solution.

Example: Consider the following clauses:

𝐶1 : ∀𝑋1 [𝑟 ′ (𝑋1 ) → 𝑡(𝑋1 )].


𝐶2 : ∀𝑋2 [𝑑(𝑋2 ) → ⅂𝑡(𝑋2 )].
𝐶3 : ∃𝑋3 [𝑑(𝑋3 ) ∧ ℎ(𝑋3 )].
Prove the goal: ∃𝑍[ℎ(𝑍) ∧ ⅂𝑟(𝑍)].
Solution:
𝐶1 : ⅂𝑟(𝑋1 ) ∨ 𝑡(𝑋1 ).
𝐶2 : ⅂𝑑(𝑋2 ) ∨ ⅂𝑡(𝑋2 ).
𝐶3.1 : 𝑑(𝑎)
𝐶3.2 : ℎ(𝑎)
𝑔: ⅂ℎ(𝑍) ∨ 𝑟(𝑍).
Round1:
Artificial Intelligence

1) 𝑅𝑒𝑠𝑜𝑙𝑣𝑒 𝐶1 & 𝐶2
𝐶4 : ⅂𝑟(𝑋1 ) ∨ ⅂𝑑(𝑋1 ) {(𝑋1 , 𝑋2 )}

2) 𝐶1 & 𝑔
𝐶5 : 𝑡(𝑋1 ) ∨ ⅂ℎ(𝑋1 ) {𝑋1 , 𝑍)}
3) 𝐶2 & 𝐶3.1
𝐶6 : ⅂𝑡(𝑎) {(𝑎, 𝑋2 )}

4) 𝐶3.2 & 𝑔
𝐶7 : 𝑟(𝑎) {(𝑎, 𝑍)}

Round 2:
5) 𝐶1 & 𝐶6
𝐶8 : ⅂𝑟(𝑎) {(𝑎, 𝑋1 )}

6) 𝐶1 & 𝐶7
𝐶9 : 𝑡(𝑎) {(𝑎, 𝑋1 )}

7) 𝐶2 & 𝐶5
𝐶10 : ⅂𝑑(𝑋1 ) ∨ ⅂ℎ(𝑋1 ) {(𝑋1 , 𝑋2 )}

8) 𝐶3.1 & 𝐶4
𝐶11 : ⅂ 𝑟(𝑎) {(𝑎, 𝑋1 )}

9) 𝐶3.2 & 𝐶5
𝐶12 : 𝑡(𝑎) {(𝑎, 𝑋1 )}

10) 𝑔 & 𝐶4
𝐶13 : ⅂𝑑(𝑋1 ) ∨ ⅂ℎ(𝑋1 ) {(𝑋1 , 𝑍)}
11) 𝐶4 & 𝐶7
𝐶14 : ⅂𝑑(𝑎) {(𝑎, 𝑋1 )}
Artificial Intelligence

12) 𝐶5 & 𝐶6
𝐶15 : ⅂ℎ(𝑎) {(𝑎, 𝑋1 )}

Round 3
13) Resolve 𝐶2 &𝐶9
𝐶16 : ⅂𝑑(𝑎) {(𝑎, 𝑋2 )}

14) 𝐶2 & 𝐶12


𝐶17 : ⅂𝑑(𝑎)} {(𝑎, 𝑋2 )}

15) 𝐶3.1 & 𝐶10


𝐶18 : ⅂ℎ(𝑎) {(𝑎, 𝑋1 )}

16) 𝐶3.1 & 𝐶13


𝐶19 : ⅂ℎ(𝑎) {(𝑎, 𝑋1 )}

17) 𝐶3.1 & 𝐶14


𝐶2𝑜 :
Other solution:
𝐶1 𝐶2 𝐶1 𝐶1 18) 𝐶3.2 & 𝐶15
𝐶20 :
𝐶2 𝐶3.1
𝐶4 𝐶7

𝐶1 𝐶1
𝐶3.1 𝐶14

𝐶1 𝐶1

2. Set of support strategy


This is a goal strategy for a large clause set for a set of input clauses S, we can specify a
subset T of S called the set of support. The strategy requires that at least one of the resolvent
in each resolution operation be in the set of support.
Artificial Intelligence

The strategy is based on the principle that the negation of what we want prove is going to be
responsible for generating the empty clause (contradiction).
The set of support consists initially of the negation of the goal. Consequently, any resolvent
whose parent is in the set of support becomes a member of the set of support. Thus, this
strategy forces resolution between clauses of which at least one is either the negation of the
goal or a clause whose one of its ancestors in the negation of the goal.
Example:

𝐶1 : 𝑝𝑜𝑜𝑟(𝑋) ∨ ⅂𝑠𝑚𝑎𝑟𝑡(𝑋) ∨ ℎ𝑎𝑝𝑝𝑦(𝑋)


𝐶2 : ⅂𝑟𝑒𝑎𝑑(𝑌) ∨ 𝑠𝑚𝑎𝑟𝑡(𝑌)
𝐶3.1 : 𝑟𝑒𝑎𝑑 (𝑗𝑜ℎ𝑛)
𝐶3.2 : ⅂𝑝𝑜𝑜𝑟 (𝑗𝑜ℎ𝑛)
𝐶4 : ⅂ℎ𝑎𝑝𝑝𝑦(𝑍) ∨ 𝑒𝑥𝑐𝑖𝑡𝑖𝑛𝑔(𝑍)
𝑔: ⅂𝑒𝑥𝑐𝑖𝑡𝑖𝑛𝑔(𝑊)

Solution:
1) 𝑆 = {𝑔}
𝑔 & 𝐶4 𝐶5 : ⅂ℎ𝑎𝑝𝑝𝑦(𝑋3 ) {(𝑋3 , 𝑊)}

2) 𝑆 = {𝑔, 𝐶5 }
𝐶5 & 𝐶1 𝐶6 : 𝑝𝑜𝑜𝑟(𝑋1 ) ∨ ⅂𝑠𝑚𝑎𝑟𝑡(𝑋1 ) {(𝑋1 , 𝑋3 )}

3) 𝑆 = {𝑔, 𝐶5 , 𝐶6 }
𝐶6 & 𝐶2 𝐶7 : ⅂𝑟𝑒𝑎𝑑(𝑋1 ) ∨ 𝑝𝑜𝑜𝑟 (𝑋1 ) {(𝑋1 , 𝑋2 )}
𝐶6 & 𝐶3.2 𝐶8 : ⅂𝑟𝑒𝑎𝑑(𝑎𝑙𝑖) {(𝑎𝑙𝑖, 𝑋1 )}

4) 𝑆 = {𝑔, 𝐶5 , 𝐶6 , 𝐶7 , 𝐶8 }
𝐶7 & 𝐶3.1 𝐶9 : 𝑝𝑜𝑜𝑟(𝑎𝑙𝑖) {(𝑎𝑙𝑖, 𝑋1 )}
𝐶7 & 𝐶3.2 𝐶10 : ⅂𝑟𝑒𝑎𝑑(𝑎𝑙𝑖) {(𝑎𝑙𝑖, 𝑋1 )}
𝐶8 & 𝐶3.1 𝐶11 : Stop
Artificial Intelligence

𝐶6 𝐶3.2

𝐶8 𝐶1

3. Unit Preference Strategy


In this strategy, clauses are chosen for resolution with as fewer literals as possible so that the
empty clause can be produced with less number of resolutions.

Example:
𝐶1 : 𝑝𝑜𝑜𝑟(𝑋) ∨ ⅂𝑠𝑚𝑎𝑟𝑡(𝑋) ∨ ℎ𝑎𝑝𝑝𝑦(𝑋)
𝐶2 : ⅂𝑟𝑒𝑎𝑑(𝑌) ∨ 𝑠𝑚𝑎𝑟𝑡(𝑌)
𝐶3.1 : 𝑟𝑒𝑎𝑑 (𝑗𝑜ℎ𝑛)
𝐶3.2 : ⅂𝑝𝑜𝑜𝑟 (𝑗𝑜ℎ𝑛)
𝐶4 : ⅂ℎ𝑎𝑝𝑝𝑦(𝑍) ∨ 𝑒𝑥𝑐𝑖𝑡𝑖𝑛𝑔(𝑍)
𝑔: ⅂𝑒𝑥𝑐𝑖𝑡𝑖𝑛𝑔(𝑊)
Solution:

1) 𝑔 & 𝐶4 𝐶5 : ⅂ℎ𝑎𝑝𝑝𝑦(𝑋3 ) {(𝑋3 , 𝑊)}


2) 𝐶5 & 𝐶1 𝐶6 : 𝑝𝑜𝑜𝑟(𝑋1 ) ∨ ⅂𝑠𝑚𝑎𝑟𝑡(𝑋1 ) {(𝑋1 , 𝑋3 )}
3) 𝐶6 & 𝐶3.2 𝐶7 : ⅂𝑠𝑚𝑎𝑟𝑡(𝑎𝑙𝑖) {(𝑎𝑙𝑖, 𝑋1 )}
4) 𝐶7 &𝐶2 𝐶8 : ⅂𝑟𝑒𝑎𝑑(𝑎𝑙𝑖) {(𝑎𝑙𝑖, 𝑋2 )}
5) 𝐶8 & 𝐶3.1 stop

𝑔 𝐶4
W=X3
𝐶5 𝐶1

𝐶6 𝐶3.2
Artificial Intelligence

X3=X1
X1= ali
X2=ali
∴ W= ali

4. Linear input Format Strategy

In this strategy, the negated goal is resolved with one of the original clauses. The resulting
clause is resolved with one of the original clause to produce a new clause which is a gain
resolved with the original set of input clause and so on until the empty clause is generated.
This strategy fails sometimes to generate the empty clause even if the original goal is true.

Same previous example:

1) 𝑔 & 𝐶4 𝐶5 : ⅂ℎ𝑎𝑝𝑝𝑦(𝑋3 ) {(𝑋3 , 𝑊)}


2) 𝐶5 & 𝐶1 𝐶6 : 𝑝𝑜𝑜𝑟(𝑋1 ) ∨ ⅂𝑠𝑚𝑎𝑟𝑡(𝑋1 ) {(𝑋1 , 𝑋3 )}
3) 𝐶6 & 𝐶3.2 𝐶7 : ⅂𝑠𝑚𝑎𝑟𝑡(𝑎𝑙𝑖) {(𝑎𝑙𝑖, 𝑋1 )}
4) 𝐶7 &𝐶2 𝐶8 : ⅂𝑟𝑒𝑎𝑑(𝑎𝑙𝑖) {(𝑎𝑙𝑖, 𝑋2 )}
5) 𝐶8 & 𝐶3.1 stop
Artificial Intelligence

Example:
𝐶1 : ⅂𝑎 ∨ 𝑏
𝐶2 : ⅂𝑎 ∨ ⅂𝑏
𝐶3 : 𝑎 ∨ 𝑏
𝑔: ⅂𝑎 ∧ 𝑏
Solution:
𝑎 ∨ ⅂𝑏
𝑎∨𝑏 𝑎

𝑎
⅂𝑎 ∨ 𝑏 𝑏

𝑏
⅂𝑎 ∨ 𝑏 ⅂𝑎

You might also like