0% found this document useful (0 votes)
19 views48 pages

Ai Chap 2

CHAP 2

Uploaded by

mehthegoat4510
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)
19 views48 pages

Ai Chap 2

CHAP 2

Uploaded by

mehthegoat4510
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/ 48

191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

KNOWLEDGE REPRESENTATION
Game playing – Knowledge representation, Knowledge representation using Predicate logic,
Introduction to predicate calculus, Resolution, Use of predicate calculus, Knowledge
representation using other Logic-Structured representation of Knowledge - Prolog
Programming.

Game playing
Game playing was one of the first tasks undertaken in Artificial Intelligence. Game theory
has its history from 1950, almost from the days when computers became programmable. The
very first game that is been tackled in AI is chess. Initiators in the field of game theory in AI
were Konard Zuse (the inventor of the first programmable computer and the first
programming language), Claude Shannon (the inventor of information theory), Norbert
Wiener (the creator of modern control theory), and Alan Turing. Since then, there has been a
steady progress in the standard of play, to the point that machines have defeated human
champions (although not every time) in chess and backgammon, and are competitive in many
other games.
Types of Game
1.Perfect Information Game: In which player knows all the possible moves of
himself and opponent and their results.
E.g. Chess.
2 Imperfect Information Game: In which player does not know all the
possible moves of the opponent.
E.g. Bridge since all the cards are not visible to player.
Definition
Game playing is a search problem defined by following components:
Initial state: This defines initial configuration of the game and identifies first player to move.
Successor function: This identifies which are the possible states that can be achieved from the
current state. This function returns a list of (move, state) pairs, each indicating a legal move
and the resulting state.
Goal test: Which checks whether a given state is a goal state or not. States where the game
ends are called as terminal states.
Path cost / utility / payoff function: Which gives a numeric value for the terminal states? In
chess, the outcome is win, loss or draw, with values +1, -1, or 0. Some games have wider
range of possible outcomes.
Characteristics of game playing

1
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

Unpredictable Opponent: Generally, we cannot predict the behaviour of the opponent. Thus
we need to find a solution which is a strategy specifying a move for every possible opponent
move or every possible state.
Time Constraints: Every game has a time constraint. Thus it may be infeasible to find the best
move in this time.
Typical structure of the game in the AI is:
 2- person game
 Players alternate moves
 Zero-sum game: one player’s loss is the other’s gain
 Perfect information: both players have access to complete information about the state
of the game. No information is hidden from either player.
 No chance (e. g. using dice) involved.
E.g. Tic- Tac- Toe, Checkers, Chess, Go, Nim, Othello
For dealing with such types of games, consider all the legal moves you can make from the
current position. Compute the new position resulting from each move. Evaluate each
resulting position and determine which is best for you. Make that move. Wait for your
opponent to move and repeat the procedure. But for this procedure the main problem is how
to evaluate the position? Evaluation function or static evaluator is used to evaluate the
‘goodness’ of a game position. The zero- sum assumption allows us to use a single evaluation
function to describe the goodness of a position with respect to both players.
Lets consider, f(n) is the evaluation function of the position ‘n’. Then,
– f(n) >> 0: position n is good for me and bad for you
– f(n) << 0: position n is bad for me and good for you
– f(n) near 0: position n is a neutral position
e.g. evaluation function for Tic- Tac- Toe:
f( n) = [# of 3- lengths open for me] - [# of 3- lengths open for you]
where a 3- length is a complete row, column, or diagonal
The most common search technique in game playing is Minimax search procedure. It is
depth-first depth-limited search procedure. It is used for games like chess and tic-tac-toe.
Mini-Max Algorithm in Artificial Intelligence

o Mini-max algorithm is a recursive or backtracking algorithm which is used in


decision-making and game theory. It provides an optimal move for the player
assuming that opponent is also playing optimally.
o Mini-Max algorithm uses recursion to search through the game-tree.

2
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

o Min-Max algorithm is mostly used for game playing in AI. Such as Chess, Checkers,
tic-tac-toe, go, and various tow-players game. This Algorithm computes the minimax
decision for the current state.
o In this algorithm two players play the game, one is called MAX and other is called
MIN.
o Both the players fight it as the opponent player gets the minimum benefit while they
get the maximum benefit.
o Both Players of the game are opponent of each other, where MAX will select the
maximized value and MIN will select the minimized value.
o The minimax algorithm performs a depth-first search algorithm for the exploration of
the complete game tree.
o The minimax algorithm proceeds all the way down to the terminal node of the tree,
then backtrack the tree as the recursion.

Pseudo-code for MinMax Algorithm:

1. function minimax(node, depth, maximizingPlayer) is


2. if depth ==0 or node is a terminal node then
3. return static evaluation of node
4. if MaximizingPlayer then // for Maximizer Player
5. maxEva= -infinity
6. for each child of node do
7. eva= minimax(child, depth-1, false)
8. maxEva= max(maxEva,eva) //gives Maximum of the values
9. return maxEva
10. else // for Minimizer player
11. minEva= +infinity
12. for each child of node do
13. eva= minimax(child, depth-1, true)
14. minEva= min(minEva, eva) //gives minimum of the values
15. return minEva

3
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

Initial call:

Minimax(node, 3, true)

Working of Min-Max Algorithm:

o The working of the minimax algorithm can be easily described using an example.
Below we have taken an example of game-tree which is representing the two-player
game.
o In this example, there are two players one is called Maximizer and other is called
Minimizer.
o Maximizer will try to get the Maximum possible score, and Minimizer will try to get
the minimum possible score.
o This algorithm applies DFS, so in this game-tree, we have to go all the way through
the leaves to reach the terminal nodes.
o At the terminal node, the terminal values are given so we will compare those value
and backtrack the tree until the initial state occurs. Following are the main steps
involved in solving the two-player game tree:

Step-1: In the first step, the algorithm generates the entire game-tree and apply the utility
function to get the utility values for the terminal states. In the below tree diagram, let's take A
is the initial state of the tree. Suppose maximizer takes first turn which has worst-case initial
value =- infinity, and minimizer will take next turn which has worst-case initial value =
+infinity.

4
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

Step 2: Now, first we find the utilities value for the Maximizer, its initial value is -∞, so we
will compare each value in terminal state with initial value of Maximizer and determines the
higher nodes values. It will find the maximum among the all.

35.6K
Drone Racing World Champs Turn To A.I.

o For node D max(-1,- -∞) => max(-1,4)= 4


o For Node E max(2, -∞) => max(2, 6)= 6
o For Node F max(-3, -∞) => max(-3,-5) = -3
o For node G max(0, -∞) = max(0, 7) = 7

Step 3: In the next step, it's a turn for minimizer, so it will compare all nodes value with +∞,
and will find the 3rd layer node values.

o For node B= min(4,6) = 4


o For node C= min (-3, 7) = -3

5
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

Step 4: Now it's a turn for Maximizer, and it will again choose the maximum of all nodes
value and find the maximum value for the root node. In this game tree, there are only 4
layers, hence we reach immediately to the root node, but in real games, there will be more
than 4 layers.

o For node A max(4, -3)= 4

That was the complete workflow of the minimax two player game.

Properties of Mini-Max algorithm:

o Complete- Min-Max algorithm is Complete. It will definitely find a solution (if


exist), in the finite search tree.
o Optimal- Min-Max algorithm is optimal if both opponents are playing optimally.

6
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

o Time complexity- As it performs DFS for the game-tree, so the time complexity of
Min-Max algorithm is O(bm), where b is branching factor of the game-tree, and m is
the maximum depth of the tree.
o Space Complexity- Space complexity of Mini-max algorithm is also similar to DFS
which is O(bm).

Limitation of the minimax Algorithm:

The main drawback of the minimax algorithm is that it gets really slow for complex games
such as Chess, go, etc. This type of games has a huge branching factor, and the player has lots
of choices to decide. This limitation of the minimax algorithm can be improved from alpha-
beta pruning which we have discussed in the next topic.

Alpha-Beta Pruning

o Alpha-beta pruning is a modified version of the minimax algorithm. It is an


optimization technique for the minimax algorithm.
o As we have seen in the minimax search algorithm that the number of game states it
has to examine are exponential in depth of the tree. Since we cannot eliminate the
exponent, but we can cut it to half. Hence there is a technique by which without
checking each node of the game tree we can compute the correct minimax decision,
and this technique is called pruning. This involves two threshold parameter Alpha
and beta for future expansion, so it is called alpha-beta pruning. It is also called
as Alpha-Beta Algorithm.
o Alpha-beta pruning can be applied at any depth of a tree, and sometimes it not only
prune the tree leaves but also entire sub-tree.
o The two-parameter can be defined as:

a. Alpha: The best (highest-value) choice we have found so far at any point
along the path of Maximizer. The initial value of alpha is -∞.
b. Beta: The best (lowest-value) choice we have found so far at any point along
the path of Minimizer. The initial value of beta is +∞.
o The Alpha-beta pruning to a standard minimax algorithm returns the same move as
the standard algorithm does, but it removes all the nodes which are not really

7
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

affecting the final decision but making algorithm slow. Hence by pruning these nodes,
it makes the algorithm fast.

Condition for Alpha-beta pruning:

The main condition which required for alpha-beta pruning is:

1. α>=β

Key points about alpha-beta pruning:

o The Max player will only update the value of alpha.


o The Min player will only update the value of beta.
o While backtracking the tree, the node values will be passed to upper nodes instead of
values of alpha and beta.
o We will only pass the alpha, beta values to the child nodes.

Pseudo-code for Alpha-beta Pruning:

1. function minimax(node, depth, alpha, beta, maximizingPlayer) is


2. if depth ==0 or node is a terminal node then
3. return static evaluation of node
4.
5. if MaximizingPlayer then // for Maximizer Player
6. maxEva= -infinity
7. for each child of node do
8. eva= minimax(child, depth-1, alpha, beta, False)
9. maxEva= max(maxEva, eva)
10. alpha= max(alpha, maxEva)
11. if beta<=alpha
12. break
13. return maxEva
14.
15. else // for Minimizer player
16. minEva= +infinity

8
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

17. for each child of node do


18. eva= minimax(child, depth-1, alpha, beta, true)
19. minEva= min(minEva, eva)
20. beta= min(beta, eva)
21. if beta<=alpha
22. break
23. return minEva

Working of Alpha-Beta Pruning:

Let's take an example of two-player search tree to understand the working of Alpha-beta
pruning

Step 1: At the first step the, Max player will start first move from node A where α= -∞ and
β= +∞, these value of alpha and beta passed down to node B where again α= -∞ and β= +∞,
and Node B passes the same value to its child D.

Step 2: At Node D, the value of α will be calculated as its turn for Max. The value of α is
compared with firstly 2 and then 3, and the max (2, 3) = 3 will be the value of α at node D
and node value will also 3.

Keep Watching

9
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

Step 3: Now algorithm backtrack to node B, where the value of β will change as this is a turn
of Min, Now β= +∞, will compare with the available subsequent nodes value, i.e. min (∞, 3)
= 3, hence at node B now α= -∞, and β= 3.

In the next step, algorithm traverse the next successor of Node B which is node E, and the
values of α= -∞, and β= 3 will also be passed.

Step 4: At node E, Max will take its turn, and the value of alpha will change. The current
value of alpha will be compared with 5, so max (-∞, 5) = 5, hence at node E α= 5 and β= 3,
where α>=β, so the right successor of E will be pruned, and algorithm will not traverse it, and
the value at node E will be 5.

10
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

Step 5: At next step, algorithm again backtrack the tree, from node B to node A. At node A,
the value of alpha will be changed the maximum available value is 3 as max (-∞, 3)= 3, and
β= +∞, these two values now passes to right successor of A which is Node C.

At node C, α=3 and β= +∞, and the same values will be passed on to node F.

Step 6: At node F, again the value of α will be compared with left child which is 0, and
max(3,0)= 3, and then compared with right child which is 1, and max(3,1)= 3 still α remains
3, but the node value of F will become 1.

Step 7: Node F returns the node value 1 to node C, at C α= 3 and β= +∞, here the value of
beta will be changed, it will compare with 1 so min (∞, 1) = 1. Now at C, α=3 and β= 1, and
again it satisfies the condition α>=β, so the next child of C which is G will be pruned, and the
algorithm will not compute the entire sub-tree G.

11
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

Step 8: C now returns the value of 1 to A here the best value for A is max (3, 1) = 3.
Following is the final game tree which is the showing the nodes which are computed and
nodes which has never computed. Hence the optimal value for the maximizer is 3 for this
example.

Move Ordering in Alpha-Beta pruning:

The effectiveness of alpha-beta pruning is highly dependent on the order in which each node
is examined. Move order is an important aspect of alpha-beta pruning.

It can be of two types:

o Worst ordering: In some cases, alpha-beta pruning algorithm does not prune any of
the leaves of the tree, and works exactly as minimax algorithm. In this case, it also
consumes more time because of alpha-beta factors, such a move of pruning is called
worst ordering. In this case, the best move occurs on the right side of the tree. The
time complexity for such an order is O(bm).
o Ideal ordering: The ideal ordering for alpha-beta pruning occurs when lots of
pruning happens in the tree, and best moves occur at the left side of the tree. We apply
DFS hence it first search left of the tree and go deep twice as minimax algorithm in
the same amount of time. Complexity in ideal ordering is O(bm/2).

Rules to find good ordering:

Following are some rules to find good ordering in alpha-beta pruning:

12
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

o Occur the best move from the shallowest node.


o Order the nodes in the tree such that the best nodes are checked first.
o Use domain knowledge while finding the best move. Ex: for Chess, try order:
captures first, then threats, then forward moves, backward moves.
o We can bookkeep the states, as there is a possibility that states may repeat.

ITERATIVE DEEPENING

Depth first search was efficient in terms of space but required some cutoff depth in order to
force backtracking when a solution was not found. Breadth first search was guaranteed to find the
shortest solution path but required inordinate amount of space because all leaf nodes had to be kept in
memory. An algorithm called depth first iterative deepening (DFID) combines the best aspects of
depth-first and breadth-first search.

To avoid the infinite depth problem of DFS, we can decide to only search until depth L, i.e.
we don’t expand beyond depth L. This is called Depth-Limited Search. Suppose if the solution is
deeper than L, then increase L iteratively. This is known as Iterative Deepening Search. This iterative
deepening search inherits the memory advantage of Depth-First search.

Iterative deepening search L=1

Iterative deepening search L=2

Iterative deepening search L=3

13
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

Algorithm
1. Set SEARCH-DEPTH=1.
2. Conduct a depth-first search to a depth of SEARCH-DEPTH. If a solution path is found, then return
it.
3. Otherwise, increment SEARCH-DEPTH by 1 and go to step2.

Disadvantage
Iterative deepening looks inefficient because so many states are expanded multiple times. In
practice this is not that bad, because by far most of the nodes are at the bottom level.
 For a branching factor b of 2, this might double the search time.
 For a branching factor b of 10, this might add 10% to the search time.
Advantage
 Avoids the problem of choosing cutoffs without sacrificing efficiency.
 DFID is the optimal algorithm for uniformed search.
Performance Analysis
Completeness - Yes
Time Complexity- (d+1)b0 + d b1 + (d-1)b2 + … + bd = O(bd)
Space Complexity - O(bd)
Optimality - Yes, if step cost = 1 or increasing function of depth.

ITERATIVE DEEPENING A*
1. Set THRESHOLD=the heuristic evaluation of the start state.
2. Conduct a depth-first search, pruning any branch when its total cost function (g+h) exceeds a
THRESHOLD. If a solution path is found during the search, return it.
3. Otherwise, Increment THRESHOLD by the minimum amount. It was exceeded during the previous
step, and the go to step 2.
Iterative Deepening A* is guaranteed to find optimal solution, provided that h is a n
admissible heuristic. Because of its depth-first search technique, IDA* is very efficient with respect to
space. IDA* is the first heuristic search algorithm to find optimal paths within reasonable time and
space constraints.

14
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

Knowledge representation

Humans are best at understanding, reasoning, and interpreting knowledge. Human knows
things, which is knowledge and as per their knowledge they perform various actions in the
real world. But how machines do all these things comes under knowledge representation
and reasoning. Hence we can describe Knowledge representation as following:

o Knowledge representation and reasoning (KR, KRR) is the part of Artificial


intelligence which concerned with AI agents thinking and how thinking contributes to
intelligent behaviour of agents.
o It is responsible for representing information about the real world so that a computer
can understand and can utilize this knowledge to solve the complex real world
problems such as diagnosis a medical condition or communicating with humans in
natural language.
o It is also a way which describes how we can represent knowledge in artificial
intelligence. Knowledge representation is not just storing data into some database, but
it also enables an intelligent machine to learn from that knowledge and experiences so
that it can behave intelligently like a human.

What to Represent:

Following are the kind of knowledge which needs to be represented in AI systems:

o Object: All the facts about objects in our world domain. E.g., Guitars contains
strings, trumpets are brass instruments.
o Events: Events are the actions which occur in our world.
o Performance: It describe behavior which involves knowledge about how to do
things.
o Meta-knowledge: It is knowledge about what we know.
o Facts: Facts are the truths about the real world and what we represent.
o Knowledge-Base: The central component of the knowledge-based agents is the
knowledge base. It is represented as KB. The Knowledgebase is a group of the

15
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

Sentences (Here, sentences are used as a technical term and not identical with the
English language).

Knowledge: Knowledge is awareness or familiarity gained by experiences of facts, data, and


situations. Following are the types of knowledge in artificial intelligence:

Types of knowledge

Following are the various types of knowledge:

1. Declarative Knowledge:

o Declarative knowledge is to know about something.


o It includes concepts, facts, and objects.
o It is also called descriptive knowledge and expressed in declarative sentences.
o It is simpler than procedural language.

2. Procedural Knowledge

o It is also known as imperative knowledge.


o Procedural knowledge is a type of knowledge which is responsible for knowing how
to do something.

16
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

o It can be directly applied to any task.


o It includes rules, strategies, procedures, agendas, etc.
o Procedural knowledge depends on the task on which it can be applied.

3. Meta-knowledge:

o Knowledge about the other types of knowledge is called Meta-knowledge.

4. Heuristic knowledge:

o Heuristic knowledge is representing knowledge of some experts in a filed or subject.


o Heuristic knowledge is rules of thumb based on previous experiences, awareness of
approaches, and which are good to work but not guaranteed.

5. Structural knowledge:

o Structural knowledge is basic knowledge to problem-solving.


o It describes relationships between various concepts such as kind of, part of, and
grouping of something.
o It describes the relationship that exists between concepts or objects.

The relation between knowledge and intelligence:

Knowledge of real-worlds plays a vital role in intelligence and same for creating artificial
intelligence. Knowledge plays an important role in demonstrating intelligent behaviour in AI
agents. An agent is only able to accurately act on some input when he has some knowledge or
experience about that input.

Let's suppose if you met some person who is speaking in a language which you don't know,
then how you will able to act on that. The same thing applies to the intelligent behaviour of
the agents.

As we can see in below diagram, there is one decision maker which act by sensing the
environment and using knowledge. But if the knowledge part will not present then, it cannot
display intelligent behaviour.

17
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

AI knowledge cycle:

An Artificial intelligence system has the following components for displaying intelligent
behavior:

o Perception
o Learning
o Knowledge Representation and Reasoning
o Planning
o Execution

The above diagram is showing how an AI system can interact with the real world and what
components help it to show intelligence. AI system has Perception component by which it
retrieves information from its environment. It can be visual, audio or another form of sensory
input. The learning component is responsible for learning from data captured by Perception

18
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

comportment. In the complete cycle, the main components are knowledge representation and
Reasoning. These two components are involved in showing the intelligence in machine-like
humans. These two components are independent with each other but also coupled together.
The planning and execution depend on analysis of Knowledge representation and reasoning.

Approaches to knowledge representation:

There are mainly four approaches to knowledge representation, which are givenbelow:

1. Simple relational knowledge:

o It is the simplest way of storing facts which uses the relational method, and each fact
about a set of the object is set out systematically in columns.
o This approach of knowledge representation is famous in database systems where the
relationship between different entities is represented.
o This approach has little opportunity for inference.

Example: The following is the simple relational knowledge representation.

Player Weight Age

Player1 65 23

Player2 58 18

Player3 75 24

2. Inheritable knowledge:

o In the inheritable knowledge approach, all data must be stored into a hierarchy of
classes.
o All classes should be arranged in a generalized form or a hierarchal manner.
o In this approach, we apply inheritance property.
o Elements inherit values from other members of a class.

19
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

o This approach contains inheritable knowledge which shows a relation between


instance and class, and it is called instance relation.
o Every individual frame can represent the collection of attributes and its value.
o In this approach, objects and values are represented in Boxed nodes.
o We use Arrows which point from objects to their values.
o Example:

3. Inferential knowledge:

o Inferential knowledge approach represents knowledge in the form of formal logics.


o This approach can be used to derive more facts.
o It guaranteed correctness.
o Example: Let's suppose there are two statements:

a. Marcus is a man
b. All men are mortal
Then it can represent as;

man(Marcus)
∀x = man (x) ----------> mortal (x)s

4. Procedural knowledge:

20
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

o Procedural knowledge approach uses small programs and codes which describes how
to do specific things, and how to proceed.
o In this approach, one important rule is used which is If-Then rule.
o In this knowledge, we can use various coding languages such as LISP
language and Prolog language.
o We can easily represent heuristic or domain-specific knowledge using this approach.
o But it is not necessary that we can represent all cases in this approach.

Requirements for knowledge Representation system:

A good knowledge representation system must possess the following properties.

1. Representational Accuracy:
KR system should have the ability to represent all kind of required knowledge.

2. Inferential Adequacy:
KR system should have ability to manipulate the representational structures to produce
new knowledge corresponding to existing structure.

3. Inferential Efficiency:
The ability to direct the inferential knowledge mechanism into the most productive
directions by storing appropriate guides.

4. Acquisitional efficiency- The ability to acquire the new knowledge easily using
automatic methods.

Techniques of knowledge representation

There are mainly four ways of knowledge representation which are given as follows:

1. Logical Representation
2. Semantic Network Representation
3. Frame Representation
4. Production Rules

21
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

1. Logical Representation

Logical representation is a language with some concrete rules which deals with propositions
and has no ambiguity in representation. Logical representation means drawing a conclusion
based on various conditions. This representation lays down some important communication
rules. It consists of precisely defined syntax and semantics which supports the sound
inference. Each sentence can be translated into logics using syntax and semantics.

Syntax:
o Syntaxes are the rules which decide how we can construct legal sentences in the logic.
o It determines which symbol we can use in knowledge representation.
o How to write those symbols.

Semantics:
o Semantics are the rules by which we can interpret the sentence in the logic.
o Semantic also involves assigning a meaning to each sentence.

Logical representation can be categorised into mainly two logics:

a. Propositional Logics
b. Predicate logics

Advantages of logical representation:


1. Logical representation enables us to do logical reasoning.
2. Logical representation is the basis for the programming languages.

22
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

Disadvantages of logical Representation:


1. Logical representations have some restrictions and are challenging to work with.
2. Logical representation technique may not be very natural, and inference may not be so
efficient.

2. Semantic Network Representation

Semantic networks are alternative of predicate logic for knowledge representation. In


Semantic networks, we can represent our knowledge in the form of graphical networks. This
network consists of nodes representing objects and arcs which describe the relationship
between those objects. Semantic networks can categorize the object in different forms and
can also link those objects. Semantic networks are easy to understand and can be easily
extended.

This representation consist of mainly two types of relations:

a. IS-A relation (Inheritance)


b. Kind-of-relation

Example: Following are some statements which we need to represent in the form of nodes
and arcs.

Statements:
a. Jerry is a cat.
b. Jerry is a mammal
c. Jerry is owned by Priya.
d. Jerry is brown colored.
e. All Mammals are animal.

23
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

In the above diagram, we have represented the different type of knowledge in the form of
nodes and arcs. Each object is connected with another object by some relation.

Drawbacks in Semantic representation:


1. Semantic networks take more computational time at runtime as we need to traverse
the complete network tree to answer some questions. It might be possible in the worst
case scenario that after traversing the entire tree, we find that the solution does not
exist in this network.
2. Semantic networks try to model human-like memory (Which has 1015 neurons and
links) to store the information, but in practice, it is not possible to build such a vast
semantic network.
3. These types of representations are inadequate as they do not have any equivalent
quantifier, e.g., for all, for some, none, etc.
4. Semantic networks do not have any standard definition for the link names.
5. These networks are not intelligent and depend on the creator of the system.

Advantages of Semantic network:


1. Semantic networks are a natural representation of knowledge.
2. Semantic networks convey meaning in a transparent manner.
3. These networks are simple and easily understandable.

3. Frame Representation

A frame is a record like structure which consists of a collection of attributes and its values to
describe an entity in the world. Frames are the AI data structure which divides knowledge

24
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

into substructures by representing stereotypes situations. It consists of a collection of slots


and slot values. These slots may be of any type and sizes. Slots have names and values which
are called facets.

Facets: The various aspects of a slot is known as Facets. Facets are features of frames which
enable us to put constraints on the frames. Example: IF-NEEDED facts are called when data
of any particular slot is needed. A frame may consist of any number of slots, and a slot may
include any number of facets and facets may have any number of values. A frame is also
known as slot-filter knowledge representation in artificial intelligence.

Frames are derived from semantic networks and later evolved into our modern-day classes
and objects. A single frame is not much useful. Frames system consist of a collection of
frames which are connected. In the frame, knowledge about an object or event can be stored
together in the knowledge base. The frame is a type of technology which is widely used in
various applications including Natural language processing and machine visions.

Example: 1

Let's take an example of a frame for a book

Slots Filters

Title Artificial Intelligence

Genre Computer Science

Author Peter Norvig

Edition Third Edition

Year 1996

Page 1152

Example 2:

25
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

Let's suppose we are taking an entity, Peter. Peter is an engineer as a profession, and his age
is 25, he lives in city London, and the country is England. So following is the frame
representation for this:

Slots Filter

Name Peter

Profession Doctor

Age 25

Marital status Single

Weight 78

Advantages of frame representation:


1. The frame knowledge representation makes the programming easier by grouping the
related data.
2. The frame representation is comparably flexible and used by many applications in AI.
3. It is very easy to add slots for new attribute and relations.
4. It is easy to include default data and to search for missing values.
5. Frame representation is easy to understand and visualize.

Disadvantages of frame representation:


1. In frame system inference mechanism is not be easily processed.
2. Inference mechanism cannot be smoothly proceeded by frame representation.
3. Frame representation has a much generalized approach.

4. Production Rules

Production rules system consist of (condition, action) pairs which mean, "If condition then
action". It has mainly three parts:

26
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

o The set of production rules


o Working Memory
o The recognize-act-cycle

In production rules agent checks for the condition and if the condition exists then production
rule fires and corresponding action is carried out. The condition part of the rule determines
which rule may be applied to a problem. And the action part carries out the associated
problem-solving steps. This complete process is called a recognize-act cycle.

The working memory contains the description of the current state of problems-solving and
rule can write knowledge to the working memory. This knowledge match and may fire other
rules.

If there is a new situation (state) generates, then multiple production rules will be fired
together, this is called conflict set. In this situation, the agent needs to select a rule from these
sets, and it is called a conflict resolution.

Example:
o IF (at bus stop AND bus arrives) THEN action (get into the bus)
o IF (on the bus AND paid AND empty seat) THEN action (sit down).
o IF (on bus AND unpaid) THEN action (pay charges).
o IF (bus arrives at destination) THEN action (get down from the bus).

Advantages of Production rule:


1. The production rules are expressed in natural language.
2. The production rules are highly modular, so we can easily remove, add or modify an
individual rule.

Disadvantages of Production rule:


1. Production rule system does not exhibit any learning capabilities, as it does not store
the result of the problem for the future uses.
2. During the execution of the program, many rules may be active hence rule-based
production systems are inefficient.

27
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

Knowledge representation using Predicate logic

Every complete sentence contains two parts –

Subject: The subject is what or whom the sentence is about.

Predicate: It tells something about the subject. Sentence involving the predicates that
describe the property of objects are denoted by P(x) where

P – The Predicate

x – It is a variable denoting any object.

Characteristics of Predicate Logic:

1. Logical inferencing is allowed.

2. More accurate KR of facts of the real world.

3. Program designing is its application area.

4. Better theoretical foundation.

5. A predicate with no variable is called a Ground Atom.

Rules of Predicate calculus symbols:

1. Set of letters (uppercase or lowercase) is allowed.

2. Set of digits (0-9) is allowed.

3. Underscore (_) is allowed.

4. Blanks and non-alphanumeric characters can’t be used.

5. Special characters like $, *, #, / are not allowed.

Symbols:

1. Predicate Symbols: It denotes relations or functional mapping from the elements of a


domain to the values true or false.

2. Function Symbols: It denotes relations defined on a domain.

3. Variable Symbols: Lowercase unsubscribed or subscribed letters like x, y, z, t, u, v, etc. It


can assume different values over a given domain.

28
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

4. Constants: It is fixed value term. They are individual symbols which are names of objects
like 1, 2, 3, etc.

5. Quantifiers: There are two types of Quantifiers:

i. Existential Quantifier (Ǝ): It means for some x or there is no x.

ii. Universal Quantifier (∀): It means for all x.

6. Logical Operators: There are five type of logical operators such as – not(~), and (^), or(v),
implication, equivalence.

Representation in Predicate Logic

Introduction to predicate calculus

29
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

Why Predicate Calculus?

 There is no way to access the components of an individual assertion.

– Proposition: “It rained on Tuesday”

– Predicate: Weather( tuesday, rain)

 Predicate calculus also allows expressions to contain variables.

– Variables let us create general assertions about classes of entities.

– We could state that for all values of X where X is a day of the week, the statement
weather(X, rain) is true

 Whereas propositional logic assumes the world contains Facts,


 predicate logic 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, …

Predicate Calculus Syntax

Symbols-Terms-Sentences:

 Predicate calculus symbols include:

1. Truth symbols true and false

2. Constant symbols are symbol expressions having the first character lowercase.

3. Variable symbols are symbol expressions beginning with an uppercase


character.

4. Function symbols are symbol expressions having the first character lowercase.

 Functions have an attached arity indicating the number of elements of the domain
mapped onto each element of the range.
 A function expression consists of a function constant of arity n, followed by n terms,
 t 1, t 2,, t n, enclosed in parentheses and separated by commas.
 A term is either a constant, variable, or function expression

30
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

Terms

 Terms denote objects and properties in a problem domain.


 Examples of terms are: cat Times(2,3) X blue mother(jane) kate

Predicates-Atomic Sentences

 Predicate symbols are symbols beginning with a lowercase letter.


 An atomic sentence is a predicate constant of arity n, followed by n terms, t 1, t 2,, t n,
enclosed in parentheses and separated by commas.
 Preddicate sentence ends by a period.

– Likes (student, math).

– Likes (student, math, al_azhar).

Syntactic Rules

1.If s is a sentence, then so is its negation, ¬s.

2.If s1 and s2 are sentences, then so is their conjunction, s1 ^ s2.

3.If s1 and s2 are sentences, then so is their disjunction, s1 v s2.

4.If s1 and s2 are sentences, then so is their implication, Si => s2.

5.If s1 and s2 are sentences, then so is their equivalence, s1 = s2.

6.If X is a variable and s a sentence, then ∀ X s is a sentence.

7.If X is a variable and s a sentence, then Ǝ X s is a sentence.

Semantics

 Interpretation Let the domain D be a nonempty set.


 An interpretation over D is an assignment of the entities of D to each of the constant,
variable, predicate, and function symbols of a predicate calculus expression, such that:

1. Each constant is assigned an element of D.

2. Each variable is assigned to a nonempty subset of D; these are the allowable


substitutions for that variable.

31
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

3. Each function f of arity m is defined on m arguments of D and defines a mapping from


Dm into D.

4. Each predicate p of arity n is defined on n arguments from D and defines a mapping


from D n into {T, F}.

 The meaning of an expression is a truth value assignment over the interpretation.

Quantifiers:

 Universal, Existential
 Universal Quantifier: ∀
 The sentence is true for all constants that can be substituted for the variable under
the intended interpretation.
 In this case, the variable is said to be universally quantified.
 Existential Quantifier: Ǝ
 The sentence containing the variable is said to be true for at least one substitution
from the domain of definition.

Truth Value of Expressions

1. The value of a constant is the element of D it is assigned to by I.

2. The value of a variable is the set of elements of D it is assigned to by I.

3. The value of a function expression is that element of D obtained by evaluating the function
for the parameter values assigned by the interpretation.

4. The value of truth symbol "true: is T and "false" is F.

5. The value of an atomic sentence is either T or F, as determined by the interpretation I.

6. The value of the negation of a sentence is T if the value of the sentence is F and is F if the
value of the sentence is T.

7. The value of the conjunction of two sentences is T if the value of both sentences is T and is
F otherwise.

8.-10. The truth value of expressions using v, =>, and = is determined from the value of their
operands as defined propositional calculus.

Truth Value of Expressions For a variable X and a sentence S containing X:

32
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

11. The value of ∀ X S is T if S is T for all assignments to X under I, and it is F otherwise.


12. The value of Ǝ X S is T if there is an assignment to X in the interpretation under which S
is T; otherwise it is F.

Resolution

Resolution is a procedure used in proving that arguments which are expressible in predicate logic are
correct. Resolution is a procedure that produces proofs by refutation or contradiction. Resolution leads
to refute a theorem-proving technique for sentences in propositional logic and first order logic.
 Resolution is a rule of inference
 Resolution is a computerized theorem prover

33
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

Algorithm: Propositional Resolution


Let F be a set of axioms and P the theorem to prove.
1. Convert all the propositions of F to clause form.
2. Negate P and convert the result to clause form. Add it to the set of clauses obtained in step 1.
3. Repeat until either a contradiction is found or no progress can be made
(a) Select two clauses. Call these the parent clauses.
(b) Resolve them together. The resulting clause called the resolvent, will be the disjunction of
all of the literals of both of the parent clauses with the following exception: If there are any
pair of literals L and L such that one of the parent clauses contains L and the other contains
L, then select one such pair and eliminate both L and L from the resolvent.
(c) If the resolvent is the empty clause, then a contradiction has been found. If it is not, then
add it to the set of clauses available to the procedure.
Example 1
1. If a triangle is equilateral then it is isosceles.
2. If a triangle is isosceles the two sides AB and AC are equal.
3. If AB and AC are equal then angle B and angle C are equal.
4. ABC is an Equilateral triangle.
Prove “Angle B is equal to angle C”
Propositional Logic
4. Equilateral(ABC)
1. Equilateral(ABC)Isosceles(ABC)
2. Isosceles(ABC)Equal(AB,AC)
3. Equal(AB,AC) Equal(B,C)
Convert to clausal form
1. Equilateral(ABC) Isosceles(ABC)
2. Isosceles(ABC) Equal(AB,AC)
3. Equal(AB,AC)  Equal(B,C)
4. Equilateral(ABC)
To prove ” Equal (B,C)”. Let us disprove “Not equal B and C Equal (B,C)”

Equal (B,C) . Equal(AB,AC)  Equal(B,C)

Isosceles(ABC) Equal(AB,AC) Equal(AB,AC)

Equilateral(ABC) Isosceles(ABC) Isosceles(ABC)

Equilateral(ABC) Equilateral(ABC)

None

34
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

Thus we proved that angle B is equal to angle C

Example 2
1. Mammals drink milk.
2. Man is mortal.
3. Man is mammal.
4. Tom is a man.
Prove “Tom drinks milk” and Prove “Tom is mortal”
Propositional Logic
1. Mammal(Tom)drink(Tom, Milk)
2. Man(Tom)Mortal(Tom)
3. Man(Tom)Mammal(Tom)
4. Man(Tom)
Convert to clausal form
1. Mammal(Tom) drink(Tom, Milk)
2. Man(Tom) Mortal(Tom)
3. Man(Tom) Mammal(Tom)
4. Man(Tom)
To prove ” Tom drinks milk”
Let us disprove “Not Tom drinks milk”“Drink (Tom, Milk)”
Mammal(Tom) drink(Tom, Milk) . Drink (Tom, Milk)

Man(Tom) Mammal(Tom) Mammal(Tom)

Man(Tom) Man(Tom)

None
Thus we proved “Tom drinks Milk”
ii) To prove ” Tom is Mortal”Mortal(Tom)
Let us disprove “Not Tom is Mortal” Mortal(Tom)

Man(Tom) Mortal(Tom) . Mortal(Tom)

Man(Tom) Man(Tom)

None
Thus we proved “Tom is Mortal”
Disadvantages of propositional logic

35
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

Propositional logic only deals with finite number of propositions.


There exists a procedure for making the choice that can speed up the process considerably
 Only resolve pairs of clauses that contain complementary literals
 Eliminate certain clauses as soon as they are generated so that they cannot participate in later
resolutions.
 Whenever possible resolve either with one of the clauses that is part of the statement we are
trying to refute or with clause generated by a resolution with such clause. This is called set of
support strategy
 Whenever possible resolve with clauses that have a single literal. Such resolution generate
new clauses with fewer literals. This is called unit preference strategy.
Problem 1
1. All people who are graduating are happy.
2. All happy people smile.
3. Someone is graduating.
4. Conclusion: Is someone smiling?
Solution:
Convert in to predicate Logic
1. ∀x[graduating(x)happy(x)
2. ∀x(happy(x)smile(x)
3. ∃x graduating(x)
4. ∃x smile(x)
Convert to clausal form
(i) Eliminate the  sign
1. ∀xgraduating(x) happy(x)
2. ∀xhappy(x) smile(x)
3. ∃x graduating(x)
4. ∃x smile(x)

(ii) Reduce the scope of negation


1. ∀xgraduating(x) happy(x)
2. ∀xhappy(x) smile(x)
3. ∃x graduating(x)
4. ∀x  smile(x)
(iii) Standardize variables apart
1. ∀xgraduating(x) happy(x)
2. ∀yhappy(y) smile(y)
3. ∃x graduating(z)
4. ∀w  smile(w)
(iv) Move all quantifiers to the left
1. ∀xgraduating(x) happy(x)
2. ∀yhappy(y) smile(y)
3. ∃x graduating(z)
4. ∀w  smile(w)
(v) Eliminate ∃
1. ∀xgraduating(x) happy(x)
2. ∀xhappy(y) smile(y)

36
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

3. graduating(name1)
4. ∀w  smile(w)
(vi) Eliminate ∀
1. graduating(x) happy(x)
2. happy(y) smile(y)
3. graduating(name1)
4.  smile(w)
(vii) Convert to conjunct of disjuncts form.
(viii) Make each conjunct a separate clause.
(ix) Standardize variables apart again.

happy(y) smile(y)  smile(w)

graduating(x) happy(x) happy(y)

. graduating(name1) graduating(x)

None
Thus, we proved someone is smiling.

37
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

Problem 2
Explain the unification algorithm used for reasoning under predicate logic with an example.
Consider the following facts
a. Team India
b. Team Australia
c. Final match between India and Australia
d. India scored 350 runs, Australia scored 350 runs, India lost 5 wickets, Australia
lost 7 wickets.
e. The team which scored the maximum runs wins.
f. If the scores are same the team which lost minimum wickets wins the match.
Represent the facts in predicate, convert to clause form and prove by resolution “India wins the
match”.
Solution:
Convert in to predicate Logic

(a) team(India)
(b) team(Australia)
(c) team(India)  team(Australia)final_match(India, Australia)
(d) score(India,350)  score(Australia,350) wicket(India,5)  wicket(Australia,7)
(e) ∃x team(x)  wins(x)score(x, max_runs))
(f) ∃xy score(x,equal(y))  wicket(x, min) final_match(x,y)win(x)
Convert to clausal form
(i) Eliminate the  sign
(a) team(India)
(b) team(Australia)
(c)  (team(India)  team(Australia))  final_match(India, Australia)
(d) score(India,350)  score(Australia,350) wicket(India,5)  wicket(Australia,7)
(e) ∃x  (team(x)  wins(x)) score(x, max_runs))
(f) ∃xy  (score(x,equal(y))  wicket(x, min) final_match(x,y)) win(x)
(ii) Reduce the scope of negation
(a) team(India)
(b) team(Australia)
(c)  team(India)  team(Australia)  final_match(India, Australia)
(d) score(India,350)  score(Australia,350) wicket(India,5)  wicket(Australia,7)
(e) ∃x  team(x)  wins(x) score(x, max_runs))
(f) ∃xy  score(x,equal(y)) wicket(x, min_wicket) final_match(x,y)) win(x)
(iii) Standardize variables apart
(iv) Move all quantifiers to the left
(v) Eliminate ∃
(a) team(India)
(b) team(Australia)
(c)  team(India)  team(Australia)  final_match(India, Australia)
(d) score(India,350)  score(Australia,350) wicket(India,5)  wicket(Australia,7)
(e)  team(x)  wins(x) score(x, max_runs))
(f)  score(x,equal(y)) wicket(x, min_wicket) final_match(x,y)) win(x)
(vi) Eliminate ∀
(vii) Convert to conjunct of disjuncts form.

38
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

(viii) Make each conjunct a separate clause.


(a) team(India)
(b) team(Australia)
(c)  team(India)  team(Australia)  final_match(India, Australia)
(d) score(India,350)
score(Australia,350)
wicket(India,5)
wicket(Australia,7)
(e)  team(x)  wins(x) score(x, max_runs))
(f)  score(x, equal(y)) wicket(x, min_wicket) final_match(x, y)) win(x)
(ix) Standardize variables apart again.
To prove: win(India)

Disprove: win(India)

 score(x, equal(y)) wicket(x, min_wicket) final_match(x, y)) win(x) win(India)

 team(India)  team(Australia)  final_match(India, Australia)  score(x, equal(y))


wicket(x,min_wicket)
final_match(x, y))

team(India)
 team(India)  team(Australia)
score(x,equal(y))wicket(x,
min_wicket)

team(Australia) team(Australia) score(x, equal(y)) 


wicket(x, min_wicket)

score(India,350) score(x, equal(y))  wicket(x, min_wicket)

wicket(India,5) wicket(x, min_wicket)

None
Thus, proved India wins match.
Problem 3
Consider the following facts and represent them in predicate form:
F1. There are 500 employees in ABC company.
F2. Employees earning more than Rs. 5000 pay tax.
F3. John is a manager in ABC company.
F4. Manager earns Rs. 10,000.
Convert the facts in predicate form to clauses and then prove by resolution: “John pays tax”.

39
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

Solution:
Convert in to predicate Logic
1. company(ABC) employee(500,ABC)
2. x company(ABC) employee(x, ABC) earns(x,5000)pays(x, tax)
3. manager(John, ABC)
4. x manager(x, ABC)earns(x,10000)
Convert to clausal form
(i) Eliminate the  sign
1. company(ABC) employee(500,ABC)
2. x (company(ABC) employee(x, ABC) earns(x,5000))  pays(x, tax)
3. manager(John, ABC)
4. x manager(x, ABC)  earns(x, 10000)
(ii) Reduce the scope of negation
1. company(ABC) employee(500,ABC)
2. x company(ABC) employee(x, ABC) earns(x,5000)  pays(x, tax)
3. manager(John, ABC)
4. x manager(x, ABC)  earns(x, 10000)
(iii) Standardize variables apart
1. company(ABC) employee(500,ABC)
2. x company(ABC) employee(x, ABC) earns(x,5000)  pays(x, tax)
3. manager(John, ABC)
4. y manager(x, ABC)  earns(y, 10000)
(iv) Move all quantifiers to the left
(v) Eliminate ∃
1. company(ABC) employee(500,ABC)
2.  company(ABC) employee(x, ABC) earns(x,5000)  pays(x, tax)
3. manager(John, ABC)
4. manager(x, ABC)  earns(y, 10000)
(vi) Eliminate ∀
(vii) Convert to conjunct of disjuncts form.
(viii) Make each conjunct a separate clause.
1. (a)company(ABC)
(b)employee(500,ABC)
2.  company(ABC) employee(x, ABC) earns(x,5000)  pays(x, tax)
3. manager(John, ABC)
4. manager(x, ABC)  earns(y, 10000)
(ix) Standardize variables apart again.
Prove :pays(John, tax)
Disprove: pays(John, tax)

 company(ABC) employee(x, ABC) earns(x,5000)  pays(x, tax) pays(John, tax)

manager(x, ABC)  earns(y, 10000)  company(ABC)


employee(x,ABC) earns(x,5000)

40
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

manager(John, ABC) manager(x, ABC)


company(ABC) employee(x, ABC)

company(ABC) company(ABC) employee(x, ABC)

employee(500,ABC) employee(x, ABC)

None
Thus, proved john pays tax.
Problem 4
If a perfect square is divisible by a prime p then it is also divisible by square of p.
Every perfect square is divisible by some prime.
36 is a perfect square.
Convert in to predicate Logic
1. ∀xy perfect_sq(x) prime(y) divides(x,y)divides(x,square(y))
2. ∀x∃y perfect_sq(x) prime(y) divides(x,y)
3. perfect_sq(36)

Problem 5
1. Marcus was a man
man(Marcus)
2. Marcus was a Pompeian
Pompeian(Marcus)
3. All Pompeians were Romans
∀x (Pompeian(x) Roman(x))
4. Caesar was a ruler
ruler(Caesar)
5. All Romans were either loyal to Caesar or hated him
∀x (Roman(x) loyalto(x,Caesar)  hate(x,Caesar))
6. Everyone is loyal to someone
∀x y (person(x)  person(y)  loyalto(x,y))
7. People only try to assassinate rulers they are not loyal to
∀x ∀y (person(x)  ruler(y)  tryassassinate(x,y) ¬loyalto(x,y))
8. Marcus tried to assassinate Caesar
tryassassinate(Marcus, Caesar)
9. All men are persons
∀x (man(x)  person(x))

Knowledge Representation using other logic-semantic network

41
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

Semantic Network

A semantic net (or semantic network) is a knowledge representation technique used for
propositional information. So it is also called a propositional net. Semantic nets convey
meaning. They are two dimensional representations of knowledge. Mathematically a semantic
net can be defined as a labelled directed graph.
Semantic nets consist of nodes, links (edges) and link labels. In the semantic network
diagram, nodes appear as circles or ellipses or rectangles to represent objects such as physical
objects, concepts or situations. Links appear as arrows to express the relationships between
objects, and link labels specify particular relations. Relationships provide the basic structure
for organizing knowledge. The objects and relations involved need not be so concrete. As
nodes are associated with other nodes semantic nets are also referred to as associative nets.

Consider the example,

Tom is a cat.
Tom caught a bird.
Tom is owned by John.
Tom is ginger in colour.
Cats like cream.
The cat sat on the mat.
A cat is a mammal.
A bird is an animal.
All mammals are animals.
Mammals have fur

It is argued that this form of representation is closer to the way humans structure knowledge
by building mental links between things than the predicate logic we considered earlier.Note
In particular how all the information about a particular object is concentrated on the node
Representing that object, rather than scattered around several clauses in logic.There is,
however, some confusion here which stems from the imprecise nature of semantic nets.A
particular problem is that we haven’t distinguished between nodes representing classes of
things,and nodes representing individual objects. So, for example, the node labelled Cat
represents both the single (nameless) cat who sat on the mat, and the whole class of cats to
which Tom belongs, which are mammals and which like cream. The is_alink has two
different meanings – it can mean that one object is an individual item from a class, for
example Tom is a member of the class of cats,or that one class is a subset of another, for
example, the class of cats is a subset of the class of mammals. This confusion does not occur
in logic, where the use of quantifiers, names and predicates makes it clear what we mean so:
Tom is a catis represented by
Cat(Tom)

42
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

The cat sat on the matis represented by


∃x∃y(Cat(x)∧Mat(y)∧SatOn(x,y))

A cat is a mammal is represented by

∀x(Cat(X)→Mammal(x))

We can clean up the representation by distinguishing between nodes representing


individualOr instances, and nodes representing classes. The is_a link will only be used to
show an Individual belonging to a class. The link representing one class being a subset of
another will
be labelled a_kind_of , or ako for short. The names instance and subclass are often used in
the place of is_a and ako, but we will use these terms with a slightly different meaning in the
section on Frames below.Note also the modification which causesthe link labelled
is_owned_by to be reversed in direction. This is in order to avoid links
representing passive relationships. In general a passive sentence can be replaced by an active
one, so “Tom is owned by John” becomes “John owns Tom”. In general the rule which
converts passive to active in English converts sentences of the form “X is Yed by Z” to “Z
Ys X”. This is just an example (though often used for illustration) of the much more general

principle of looking beyond the immediate surface structure of a sentence to find its deep
structure.

Note that where we had an unnamed member of some class, we have had to introduce a node with an
invented name to represent a particular member of the class. This is a proces ssimilar to the
Skolemisation we considered previously as a way of dealing with existential quantifiers. For example,
“Tom caught a bird” would be represented in logic by ∃x(bird(x)∧caught(Tom,x))which would be
Skolemised by replacing the x with a Skolem constant; the same thing was done above where bird1
was the name given to the individual bird that Tom caught.There are still plenty of issues to be
resolved if we really want to represent what is meant by the English phrases, or to be really clear
about what the semantic net means, but we are getting towards a notation that can be used practically
(one example of a thing we have skated over is how to deal with mass nouns like “fur” or “cream”
which refer to things that come in amounts rather than individual objects).

STRUCTURED REPRESENTATIONS OF KNOWLEDGE


Modeling-based representations reflect the structure of the domain, and then reason based on the
model.
– Semantic Nets

43
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

– Frames
– Conceptual Dependency
– Scripts
– CYC
(i) Semantic Networks
In semantic net, information is represented as a set of nodes connected to each other by a set
of labelled arcs, which represent relationship among the nodes. In this network, inheritance is used to
derive the additional relation.
Eg has_part(Pee-Wee-Reesse, nose)

Intersection search
To find the relationship among objects by spreading activation out from each of two nodes and seeing
where the activation function met. This process is called intersection search.
Example:
What is the connection between the Brooklyn dodger and blue?
The answer is Pee-Wee-Reese
Representing non binary predicates
Semantic nets are a natural way to represent relationships that would appear as binary predicates.
instance(pee-Wee-Reese, Person)
team(Pee-Wee-Reese, Brooklyn-Dodger)
Unary predicates can also be represented as binary predicates
Unary Predicate: man(Marcus)
Binary Predicate: instance(Marcus, man)

(ii) Frame
A frame is a collection of attributes and associated values that describe some entity in the
world. Sometimes a frame describes an entity in some absolute sense; sometimes it represents the
entity from a particular point of view. A single frame taken alone is rarely useful. Instead build frame
systems out of collections of frames that are connected to each other by a virtue of the fact that the
value of an attribute of one frame may be another frame. Frame system can be used to encode
knowledge and support reasoning. Each frame represents either a class or an instance.
Example of a frame
Pee-wee-Reese
instance: :Fielder
height :5.10
bats :Right
batting-average :0.309
team :Brooklyn Dodger
uniform color :Blue

ML-Baseball-Team
isa :Team
cardinality :26
team-size :24

44
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

(iii) Conceptual Dependency


Conceptual dependency is a theory of how to represent the kind of knowledge about events
that is usually contained in natural language sentence. The goal is to represent the knowledge in a way
that
 Facilitates drawing inferences from the sentences
 Is independent of the language in which the sentence were originally stated

Conceptual dependency has been implemented in variety of programs that read and understand natural
language text. Unlike semantic nets, which provide only a structure in to which nodes representing
information at any level can be placed, conceptual dependency provides both a structure and a
specific set of primitives, at a particular level of granularity, out of which representations of particular
pieces of information can be constructed.

I gave the man a book


 Arrows indicate direction of dependency
 Double arrow indicate double two way link between actor and action
 P indicate past tense
 ATRANS is one of the primitive act used by the theory. It indicates transfer of possession.
 O indicates object case generation
 R indicate recipient case relation

(iv) Scripts
Script is a structure that describes a stereotyped sequence of events in a particular context. A
script consists of a set of slots. Associated with each slot some information about what kind of values
it may contain as well as a default value to be used if no other information is available. The important
components of the scripts are
Entry conditions-Conditions that must be satisfied before the events described in a script can
occur.
Result- Event happened after the script has occurred
Props- Objects involved in the event
Roles-People who are involved in the event
Track-The specific variation on a general more pattern
Scenes-The actual sequence of events that occur
Example: Restaurant
Track- Coffee Shop
Prop- Table, Menu, food, Money
Roles- S Customer
W Waiter
C cook
M Cashier
O Owner
Entry Condition
S is hungry
S has money

Results
S has less money
O has more money
S is not hungry

Scene-Eating

45
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

C ATRANS F to W
W WATRANS F to S
S INGEST F
(v) CYC
CYC is a very large knowledge base project aimed at capturing human common sense
knowledge. The goal of CYC is to encode the large body of knowledge. Such a knowledge base could
then be combined with specialized knowledge bases to produce systems.
CYC contains representations of events and objects. CYC is particularly concerned with the
issue of scale, that is, what happens when we build knowledge bases that contain millions of objects.

Advantages of structured representation


 Retrieves the values for an attributes in a fast manner.
 Easy to describe the properties of relations.
 It is a form of object oriented programming

Prolog Programming

Prolog is a logic programming language. It has important role in artificial intelligence. Unlike
many other programming languages, Prolog is intended primarily as a declarative
programming language. In prolog, logic is expressed as relations (called as Facts and Rules).
Core heart of prolog lies at the logic being applied. Formulation or Computation is carried out
by running a query over these relations.

Syntax and Basic Fields :

In prolog, We declare some facts. These facts constitute the Knowledge Base of the system.
We can query against the Knowledge Base. We get output as affirmative if our query is
already in the knowledge Base or it is implied by Knowledge Base, otherwise we get output
as negative. So, Knowledge Base can be considered similar to database, against which we can
query. Prolog facts are expressed in definite pattern. Facts contain entities and their relation.
Entities are written within the parenthesis separated by comma (, ). Their relation is expressed
at the start and outside the parenthesis. Every fact/rule ends with a dot (.). So, a typical prolog
fact goes as follows :

Format : relation(entity1, entity2, ....k'th entity).

Example :

friends(raju, mahesh).

singer(sonu).

odd_number(5).

46
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

Explanation :

These facts can be interpreted as :

raju and mahesh are friends.

sonu is a singer.

5 is an odd number.

Key Features :

1. Unification : The basic idea is, can the given terms be made to represent the same
structure.

2. Backtracking : When a task fails, prolog traces backwards and tries to satisfy previous task.

3. Recursion : Recursion is the basis for any search in program.

Running queries :

A typical prolog query can be asked as :

Query 1 : ?- singer(sonu).

Output : Yes.

Explanation : As our knowledge base contains

the above fact, so output was 'Yes', otherwise

it would have been 'No'.

Query 2 : ?- odd_number(7).

Output : No.

Explanation : As our knowledge base does not

contain the above fact, so output was 'No'.

Advantages :

1. Easy to build database. Doesn’t need a lot of programming effort.

2. Pattern matching is easy. Search is recursion based.

3. It has built in list handling. Makes it easier to play with any algorithm involving lists.

47
191AIC403T - ARTIFICIAL INTELLIGENCEUnit-II

Disadvantages :

1. LISP (another logic programming language) dominates over prolog with respect to I/O
features.

2. Sometimes input and output is not easy.

48

You might also like