S6 Ai 2022 New
S6 Ai 2022 New
Name : ……………………………………………………………………………….
[email protected] Page 1
S6 BSc Computer Science CS1643: Artificial Intelligence
SYLLABUS
Module I: Overview of Artificial Intelligence: What is AI, The importance of AI; Knowledge:
Introduction, Definition and Importance of knowledge, Knowledge–Based Systems, Representation
of Knowledge, Knowledge Organization, Knowledge Manipulation, Acquisition of Knowledge.
Module II: Formalized Symbolic Logics: Introduction, Syntax and Semantics for Propositional Logic
and FOPL, Properties of Wffs, Conversion to Clausal Form, Inference Rules, The Resolution
Principle; Structured Knowledge: Associative Networks, Frame Structures, Conceptual
Dependencies and Scripts.
Module III: Search and Control Strategies: Preliminary concepts, Examples of Search Problems,
Uniformed or blind Search, Informed Search, Searching And-Or graphs; Matching Techniques:
Introduction, Structures Used in Matching, Measures for Matching, Partial Matching, The RETE
Matching Algorithm.
Module IV: Natural Language Processing : Introduction, Overview of Linguistics, Grammars and
Languages, Basic Parsing Techniques, Semantic Analysis and Representation Structures, Natural
Language Generation, Natural Language Systems; Expert Systems : Introduction, Rule Based System
Architecture, Knowledge Acquisition and Validation, Knowledge System Building Tools.
[email protected] Page 2
S6 BSc Computer Science CS1643: Artificial Intelligence
Module I
Overview of Artificial Intelligence
What is AI, The importance of AI; Knowledge: Introduction, Definition and Importance of
knowledge, Knowledge–Based Systems, Representation of Knowledge, Knowledge Organization,
Knowledge Manipulation, Acquisition of Knowledge.
[email protected] Page 3
S6 BSc Computer Science CS1643: Artificial Intelligence
• Artificial Intelligence is composed of two words Artificial and Intelligence, where Artificial
defines "man-made," and intelligence defines "thinking power", hence AI means "a man-
made thinking power."
• Artificial Intelligence is a way of making a computer, a computer-controlled robot, or a
software think intelligently, in the similar manner the intelligent humans think.
• According to John McCarthy (the father of Artificial Intelligence )AI is “The science and
engineering of making intelligent machines, especially intelligent computer programs”.
• AI is accomplished by studying how human brain thinks, and how humans learn, decide, and
work while trying to solve a problem, and then using the outcomes of this study as a basis of
developing intelligent software and systems.
Goals of AI
1. Following are the main goals of Artificial Intelligence:
2. Replicate human intelligence
3. Solve Knowledge-intensive tasks
4. An intelligent connection of perception and action
5. Building a machine which can perform tasks that requires human intelligence such as:
• Proving a theorem
• Playing chess
• Plan some surgical operation
• Driving a car in traffic
6. Creating some system which can exhibit intelligent behavior, learn new things by itself,
demonstrate, explain, and can advise to its user.
[email protected] Page 4
S6 BSc Computer Science CS1643: Artificial Intelligence
Importance of AI
• With the help of AI, you can create such software or devices which can solve real-world
problems very easily and with accuracy such as health issues, marketing, traffic issues, etc.
• With the help of AI, you can create your personal virtual Assistant, such as Cortana, Google
Assistant, Siri, etc.
• With the help of AI, you can build such Robots which can work in an environment where
survival of humans can be at risk.
• AI opens a path for other new technologies, new devices, and new Opportunities.
1. AI in Healthcare
o In the last, five to ten years, AI becoming more advantageous for the healthcare industry
and going to have a significant impact on this industry.
o Healthcare Industries are applying AI to make a better and faster diagnosis than humans. AI
can help doctors with diagnoses and can inform when patients are worsening so that
medical help can reach to the patient before hospitalization.
2. AI in Data Security
o The security of data is crucial for every company and cyber-attacks are growing very rapidly
in the digital world.
o AI can be used to make your data more safe and secure. Some examples such as AEG bot,
AI2 Platform,are used to determine software bug and cyber-attacks in a better way.
3. AI in Social Media
o Social Media sites such as Facebook, Twitter, and Snapchat contain billions of user profiles,
which need to be stored and managed in a very efficient way.
o AI can organize and manage massive amounts of data. AI can analyze lots of data to identify
the latest trends, hashtag, and requirement of different users.
[email protected] Page 5
S6 BSc Computer Science CS1643: Artificial Intelligence
4. AI in Gaming
o AI can be used for gaming purpose. The AI machines can play strategic games like chess,
where the machine needs to think of a large number of possible places.
5. AI in Robotics:
o Artificial Intelligence has a remarkable role in Robotics.
o Usually, general robots are programmed such that they can perform some repetitive task,
but with the help of AI, we can create intelligent robots which can perform tasks with their
own experiences without pre-programmed.
o Humanoid Robots are best examples for AI in robotics, recently the intelligent Humanoid
robot named as Erica and Sophia has been developed which can talk and behave like
humans.
6. AI in Entertainment
• We are currently using some AI based applications in our daily life with some entertainment
services such as Netflix or Amazon.
• With the help of ML/AI algorithms, these services show the recommendations for programs
or shows.
7. AI in E-commerce
• AI is providing a competitive edge to the e-commerce industry, and it is becoming more
demanding in the e-commerce business.
• AI is helping shoppers to discover associated products with recommended size, color, or
even brand.
8. AI in education:
• AI can automate grading so that the tutor can have more time to teach. AI chatbot can
communicate with students as a teaching assistant.
• AI in the future can be work as a personal virtual tutor for students, which will be accessible
easily at any time and any place.
[email protected] Page 6
S6 BSc Computer Science CS1643: Artificial Intelligence
Types of Knowledge
There are two types of knowledge
1.Procedural
2.Declarative
1.Procedural knowledge:
• It is compiled knowledge related to the performance of some task.
• For example, the steps used to solve an algebraic equation
2.Declarative knowledge:
• It is passive knowledge expressed as statements of facts about the world.
• For example, personnel data in a database, such data are explicit pieces of independent
knowledge
[email protected] Page 7
S6 BSc Computer Science CS1643: Artificial Intelligence
Hypothesis
• Hypothesis is defined as a belief which is backed up with some supporting evidence, but it
may still be false
• Belief is a meaningful and coherent expression. Thus belief may be true or false.
Metaknowledge
• Metaknowledge is knowledge about knowledge, that is, knowledge about what we know
[email protected] Page 8
S6 BSc Computer Science CS1643: Artificial Intelligence
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.
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 behavior 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.:
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 Sentences (Here,
sentences are used as a technical term and not identical with the English language).
[email protected] Page 9
S6 BSc Computer Science CS1643: Artificial Intelligence
• The knowledge organization system provides a framework for the different classification of
schemes used to organize knowledge.
• There are mainly four approaches to knowledge representation, which are given below:
1. Simple relational knowledge:
2. Inheritable knowledge:
3. Inferential knowledge:
4. Procedural knowledge:
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.
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.
[email protected] Page 10
S6 BSc Computer Science CS1643: Artificial Intelligence
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
man(Marcus)
∀x = man (x) ----------> mortal (x)s
4. Procedural knowledge:
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.
[email protected] Page 11
S6 BSc Computer Science CS1643: Artificial Intelligence
There are mainly four ways of knowledge representation which are given as follows:
1. Logical Representation
3. Frame Representation
4. Production Rules
[email protected] Page 12
S6 BSc Computer Science CS1643: Artificial Intelligence
1. Logical Representation
• Logical representation is a language with some concrete rules which deals with propositions
.
• 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.
• 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.
a) Propositional Logics
b) Predicate logics
[email protected] Page 13
S6 BSc Computer Science CS1643: Artificial Intelligence
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.
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.
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 into substructures by
representing stereotypes situations.
• It consists of a collection of slots and slot values.
[email protected] Page 14
S6 BSc Computer Science CS1643: Artificial Intelligence
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: 1
Slots Filters
Year 1996
Page 1152
4. Production Rules
• Production rules system consist of (condition, action) pairs which mean, "If condition then
action". It has mainly three parts:
• Working Memory
• 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. This
complete process is called a recognize-act cycle.
[email protected] Page 15
S6 BSc Computer Science CS1643: Artificial Intelligence
• 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).
• Knowledge Acquisition is the transformation of knowledge from the forms in which it exists
into forms that can be used in a knowledge based system
• The primary goal discover, develop and implement efficient, effective method of knowledge
acquisition
• It is a process of adding new knowledge to a knowledge base refining, improving previously
acquire knowledge
• Acquisition is usually associated with some definite purpose such as expanding the
capabilities of system, improving or enhancing the performance of some specific tasks
• Acquired knowledge consist of facts, rules, concept, procedure, formulas, relationship,
stats, plans,heuristic or any relevant information
• The sources can be anyone of the following like-that , report, electronic
document,database,newspaper,news channel,soft copy of document etc
[email protected] Page 16
S6 BSc Computer Science CS1643: Artificial Intelligence
Module 2
Formalized Symbolic Logics
Introduction, Syntax and Semantics for Propositional Logic and FOPL, Properties of Wffs,
Conversion to Clausal Form, Inference Rules, The Resolution Principle; Structured Knowledge:
Associative Networks, Frame Structures, Conceptual Dependencies and Scripts.
[email protected] Page 17
S6 BSc Computer Science CS1643: Artificial Intelligence
Symbolic AI
[email protected] Page 18
S6 BSc Computer Science CS1643: Artificial Intelligence
Propositional logic(PL)
• Propositional logic (PL) is the simplest form of logic where all the statements
are made bypropositions.
Example:
Important features of PL
[email protected] Page 19
S6 BSc Computer Science CS1643: Artificial Intelligence
1. Atomic Propositions
2. Compound propositions
1. Atomic Proposition: Atomic propositions are the simple propositions. It consists of a single
proposition symbol. These are the sentences which must be either true or false.
Example:
a) 2+2 is 4, it is an atomic proposition as it is a true fact.
b) "The Sun is cold" is also a proposition as it is a false fact.
Logical Connectives:
Logical connectives are used to connect two simpler propositions or representing a sentence
logically. We can create compound propositions with the help of logical connectives. There are
mainly five connectives, which are given as follows:
[email protected] Page 20
S6 BSc Computer Science CS1643: Artificial Intelligence
P= Rohan is intelligent,
Q= Rohan is hardworking. → P𝖠 Q.
[email protected] Page 21
S6 BSc Computer Science CS1643: Artificial Intelligence
[email protected] Page 22
S6 BSc Computer Science CS1643: Artificial Intelligence
First-Order logic
o Relations: It can be unary relation such as: red, round, is adjacent, or n-any
relation such as: the sister of, brother of, has color, comes between
o Function: Father of, best friend, third inning of, end of, ......
[email protected] Page 23
S6 BSc Computer Science CS1643: Artificial Intelligence
Variables x, y, z, a, b,....
Connectives 𝖠, ∨, ¬, ⇒, ⇔
Equality ==
Quantifier ∀, ∃
o Predicate: A predicate can be defined as a relation, which binds two atoms together in a
statement.
Consider the statement: "x is an integer.", it consists of two parts, the first part x is the subject of the
statement and second part "is an integer," is known as a predicate.
[email protected] Page 24
S6 BSc Computer Science CS1643: Artificial Intelligence
o 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:
a.Universal Quantifier:
• Universal quantifier is a symbol of logical representation, which specifies that the
statement within its range is true for everything or every instance of a particular thing.
• The Universal quantifier is represented by a symbol ∀, which resembles an inverted A.
o For each x
o For every x.
b) Existential Quantifier:
• Existential quantifiers are the type of quantifiers, which express that the statement within
itsscope is true for at least one instance of something.
• It is denoted by the logical operator ∃, which resembles as inverted E. When it is used with a
predicate variable then it is called as an existential quantifier.
•
Note: In Existential quantifier we always use AND or Conjunction symbol (𝖠).
[email protected] Page 25
S6 BSc Computer Science CS1643: Artificial Intelligence
If x is a variable, then existential quantifier will be ∃x or ∃(x). And it will be read as:
Example:
Some boys are intelligent.
∃x: boys(x) 𝖠 intelligent(x)
It will be read as: There are some x where x is a boy who is intelligent.
Fortunately, the syntax of propositional logic is easy to learn. It has only three rules:
Properties of WWf
1. Any capital letter by itself is a WFF.
2. Any WFF can be prefixed with “~”. (The result will be a WFF too.)
3. Any two WFFs can be put together with “•”, “∨”, “⊃”, or “≡” between them, enclosing
the result in parentheses. (This will be a WFF too.)
[email protected] Page 26
S6 BSc Computer Science CS1643: Artificial Intelligence
Here are some examples of well-formed formulas, along with brief explanations how these
formulas are formed in accordance with the three rules of syntax:
WFF explanation
A by rule 1
non-WFF explanation
(A) parentheses are only introduced when joining two WFFs with •, ∨, ⊃, or ≡
[email protected] Page 27
S6 BSc Computer Science CS1643: Artificial Intelligence
When an existential quantifier (Y) precedes an essential quantifier (X), replace Y as S (X), where
S is the Skolem function. In this example, since Y is not a subset of X, such a situation does not
arise. Also the essential quantifier is dropped from the sentence.
Step VI: Putting the resulting expression in conjunctive normal form (CNF):
For example, if the original expression is in the from P ∨ (Q 𝖠 R), then replace it by
(P ∨ Q) 𝖠 (Q 𝖠 R).
[email protected] Page 28
S6 BSc Computer Science CS1643: Artificial Intelligence
In the present context, the resulting expression corresponding to expression (3) being in CNF,
we need not do any operation at this step.
Original Expression:
After writing one clause per line, the resulting expression become as follow:
Inference Rule
Inference rules are the templates for generating valid arguments. Inference rules are applied to
derive proofs in artificial intelligence, and the proof is a sequence of the conclusion that leads
to the desired goal.
In inference rules, the implication among all the connectives plays an important role. Following
are some terminologies related to inference rules:
o Converse: The converse of implication, which means the right-hand side proposition
goes to the left-hand side and vice-versa. It can be written as Q → P.
From the above term some of the compound statements are equivalent to each other, which we
can prove using truth table:
Hence from the above truth table, we can prove that P → Q is equivalent to ¬ Q → ¬ P, and Q→ P
is equivalent to ¬ P → ¬ Q.
1. Modus Ponens:
The Modus Ponens rule is one of the most important rules of inference, and it states that if
P and P → Q is true, then we can infer that Q will be true. It can be represented as:
2. Modus Tollens:
The Modus Tollens rule state that if P→ Q is true and ¬ Q is true, then ¬ P will also true. It
can be represented as:
3. Hypothetical Syllogism:
The Hypothetical Syllogism rule state that if P→R is true whenever P→Q is true, and Q→R is
true. It can be represented as the following notation:
4. Disjunctive Syllogism:
The Disjunctive syllogism rule state that if P∨Q is true, and ¬P is true, then Q will be true. It
can be represented as:
[email protected] Page 30
S6 BSc Computer Science CS1643: Artificial Intelligence
5. Addition:
The Addition rule is one the common inference rule, and it states that If P is true, then P∨Q
will be true.
6. Simplification:
The simplification rule state that if P𝖠 Q is true, then Q or P will also be true. It can be
represented as:
7. Resolution:
The Resolution rule state that if P∨Q and ¬ P𝖠R is true, then Q∨R will also be true. It can be
represented as
Resolution Principal
• Resolution method is an inference rule which is used in both Propositional as well as
First-order Predicate Logic in different ways. This method is basically used for proving
the satisfiability of a sentence. In resolution method, we use Proof by Refutation
technique to prove the given statement.
• The key idea for the resolution method is to use the knowledge base and negated goal
to obtain null clause (which indicates contradiction). Resolution method is also called
Proof by Refutation. Since the knowledge base itself is consistent, the contradiction
must be introduced by a negated goal. As a result, we have to conclude that the original
goal is true.
[email protected] Page 31
S6 BSc Computer Science CS1643: Artificial Intelligence
• In propositional logic, resolution method is the only inference rule which gives a new
clause when two or more clauses are coupled together.
• Using propositional resolution, it becomes easy to make a theorem prover sound and
complete for all.
The process followed to convert the propositional logic into resolution method contains the
below steps:
1. Convert the given axiom into clausal form, i.e., disjunction form.
2. Apply and proof the given goal using negation rule.
3. Use those literals which are needed to prove.
4. Solve the clauses together and achieve the goal.
1. Mapping is the process that maps facts to representations and vice versa.
[email protected] Page 32
S6 BSc Computer Science CS1643: Artificial Intelligence
Associative Network
Auto-Associative Network:
An auto-associative network recovers a previously stored pattern that most closely relates to
the current pattern. It is also known as an auto-associative correlator.
Hetero-Associative Network:
In a hetero-associate network, the recovered pattern is generally different from the input
pattern not only in type and format but also in content. It is also known as a hetero-
associative correlator.
[email protected] Page 33
S6 BSc Computer Science CS1643: Artificial Intelligence
Frame Structures
• 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 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.
• 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
Year 1996
[email protected] Page 34
S6 BSc Computer Science CS1643: Artificial Intelligence
The main motivation for the development of CD as a knowledge representation techniques are
given below:
2. To make inferences from the statements and also to identify conditions in which two
sentences can have similar meaning,
3. To provide facilities for the system to take part in dialogues and answer questions,
4. To provide a necessary plank that sentences in one language can be easily translated into
other languages, and
Scripts
A script is a structured representation describing a stereotyped sequence of events in a particular
context.
Scripts are used in natural language understanding systems to organize a knowledge base in terms
of the situations that the system should understand. Scripts use a frame-like structure to represent
the commonly occurring experience like going to the movies eating in a restaurant, shopping in a
supermarket, or visiting an ophthalmologist.
Thus, a script is a structure that prescribes a set of circumstances that could be expected to follow
on from one another.
[email protected] Page 35
S6 BSc Computer Science CS1643: Artificial Intelligence
Components of a script
The components of a script include: Describing a script, special symbols of actions are used. These
are:
1. Entry condition: These are basic condition which must be fulfilled before events in the script
can occur.
2. Results: Condition that will be true after events in script occurred.
3. Props: Slots representing objects involved in events
4. Roles: These are the actions that the individual participants perform.
5. Track: Variations on the script. Different tracks may share components of the same scripts.
6. Scenes: The sequence of events that occur.
[email protected] Page 17
S6 BSc Computer Science CS1643: Artificial Intelligence
Module III:
Search and Control Strategies:
[email protected] Page 37
S6 BSc Computer Science CS1643: Artificial Intelligence
• It helps us to decide which rule has to apply next without getting stuck at any point.
• These rules decide the way we approach the problem and how quickly it is solved and even
whether a problem is finally solved.
• Control Strategy helps to find the solution when there is more than one rule or fewer rules for
finding the solution at each point in problem space.
Examples: Widely used Control Strategies are Breadth-First Search, Depth-First Search, Generate and
Test, Hill-Climbing, Best-first search, Problem Reduction and many more.
1. Breadth-First Search: It searches along the breadth and follows first-in-first-out queue data structure
approach. It will start to scan node A first and then B-C-D-E-F.
2. Depth-First Search: It searches along the depth and follows the stack approach. The
sequence for scanning nodes will be A-B-D-E-C-F, it scans all the sub-nodes of parent
nodes and then moves to another node.
[email protected] Page 38
S6 BSc Computer Science CS1643: Artificial Intelligence
Breadth-first Search
• Breadth-first search is the most common search strategy for traversing a tree or graph.
This algorithm searches breadth wise in a tree or graph, so it is called breadth-first
search.
• BFS algorithm starts searching from the root node of the tree and expands all successor
node at the current level before moving to nodes of next level.
• Rule 1 − Visit adjacent unvisited vertex. Mark it visited. Display it. Insert it in a queue.
• Rule 2 − If no adjacent vertex found, remove the first vertex from queue.
[email protected] Page 39
S6 BSc Computer Science CS1643: Artificial Intelligence
[email protected] Page 40
S6 BSc Computer Science CS1643: Artificial Intelligence
[email protected] Page 41
S6 BSc Computer Science CS1643: Artificial Intelligence
At this stage we are left with no unmarked (unvisited) nodes. But as per algorithm we keep on
dequeuing in order to get all unvisited nodes. When the queue gets emptied the program is over.
Depth-first Search
• Depth-first search isa recursive algorithm for traversing a tree or graph data structure.
• It is called the depth-first search because it starts from the root node and follows each
path to its greatest depth node before moving to the next path.
Depth First Search algorithm(DFS) traverses a graph in a depthward motion and uses a stack to
remember to get the next vertex to start a search when a dead end occurs in any iteration.
As in example given above, DFS algorithm traverses from A to B to C to D first then to E, then to F and
lastly to G. It employs following rules.
• Rule 1 − Visit adjacent unvisited vertex. Mark it visited. Display it. Push it in a stack.
• Rule 2 − If no adjacent vertex found, pop up a vertex from stack. (It will pop up all the vertices
from the stack which do not have adjacent vertices.)
[email protected] Page 42
S6 BSc Computer Science CS1643: Artificial Intelligence
[email protected] Page 43
S6 BSc Computer Science CS1643: Artificial Intelligence
[email protected] Page 44
S6 BSc Computer Science CS1643: Artificial Intelligence
Heuristics function: Heuristic is a function which is used in Informed Search, and it finds the most
promising path. It takes the current state of the agent as its input and produces the estimation of how
close agent is from the goal. The heuristic method, however, might not always give the best solution,
but it guaranteed to find a good solution in reasonable time. Heuristic function estimates how close a
state is to the goal. It is represented by h(n), and it calculates the cost of an optimal path between the
pair of states. The value of the heuristic function is always positive.
f(n)= g(n).
[email protected] Page 45
S6 BSc Computer Science CS1643: Artificial Intelligence
Step 3: Remove the node n, from the OPEN list which has the lowest value of h(n), and places it in the
CLOSED list.
Step 5: Check each successor of node n, and find whether any node is a goal node or not. If any
successor node is goal node, then return success and terminate the search, else proceed to Step 6.
Step 6: For each successor node, algorithm checks for evaluation function f(n), and then check if the
node has been in either OPEN or CLOSED list. If the node has not been in both list, then add it to the
OPEN list.
A* Search Algorithm:
• A* search is the most commonly known form of best-first search.
• It uses heuristic function h(n), and cost to reach the node n from the start state g(n).
• A* search algorithm finds the shortest path through the search space using the heuristic
function.
• This search algorithm expands less search tree and provides optimal result faster.
• In A* search algorithm, we use search heuristic as well as the cost to reach the node.
• In A* search algorithm, we use search heuristic as well as the cost to reach the node. Hence
we can combine both costs as following, and this sum is called as a fitness number.
[email protected] Page 46
S6 BSc Computer Science CS1643: Artificial Intelligence
•
Algorithm of A* search:
Step 2: Check if the OPEN list is empty or not, if the list is empty then return failure and stops.
Step 3: Select the node from the OPEN list which has the smallest value of evaluation function (g+h), if
node n is goal node then return success and stop, otherwise
Step 4: Expand node n and generate all of its successors, and put n into the closed list. For each
successor n', check whether n' is already in the OPEN or CLOSED list, if not then compute evaluation
function for n' and place into Open list.
Step 5: Else if node n' is already in OPEN and CLOSED, then it should be attached to the back pointer
which reflects the lowest g(n') value.
[email protected] Page 47
S6 BSc Computer Science CS1643: Artificial Intelligence
Solution:
[email protected] Page 48
S6 BSc Computer Science CS1643: Artificial Intelligence
Iteration3: {(S--> A-->C--->G, 6), (S--> A-->C--->D, 11), (S--> A-->B, 7), (S-->G, 10)}
Iteration 4 will give the final result, as S--->A--->C--->G it provides the optimal path with cost 6.
And-Or graph
• The AND-OR GRAPH (or tree) is useful for representing the solution of problems that can
solved by decomposing them into a set of smaller problems, all of which must then be solved.
• This decomposition, or reduction, generates arcs that we call AND arcs. One AND arc may
point to any number of successor nodes, all of which must be solved in order for the arc to
point to a solution.
• Just as in an OR graph, several arcs may emerge from a single node, indicating a variety of
ways in which the original problem might be solved.
• This is why the structure is called not simply an AND-graph but rather an AND-OR graph (which
also happens to be an AND-OR tree)
[email protected] Page 49
S6 BSc Computer Science CS1643: Artificial Intelligence
Matching Techniques
• Matching is the process of comparing two or more structures to discover their likenesses or
differences.
• The structures may represent a wide range of objects including physical entities, words or
phrases in some language, complete classes of things, general concepts, relations between
complex entities, and the like.
• The representations will be given in one or more of the formalisms like FOPL, networks, or
some other scheme, and matching will involve comparing the component parts of such
structures.
• It may serve to control the sequence of operations, to identify or classify objects, to determine
the best of a number of different alternatives, or to retrieve items from a database.
• In its simplest form, matching is just the process of comparing two structures or patterns for
equality. The match fails if the patterns differ in any aspect. For example, a match between the
two character strings acdebfba and acdebeba fails on an exact match since the strings differ in
the sixth character positions.
[email protected] Page 50
S6 BSc Computer Science CS1643: Artificial Intelligence
[email protected] Page 51
S6 BSc Computer Science CS1643: Artificial Intelligence
[email protected] Page 52
S6 BSc Computer Science CS1643: Artificial Intelligence
2.Select
[email protected] Page 53
S6 BSc Computer Science CS1643: Artificial Intelligence
From the conflict set, one of the rules is selected to execute. The selection strategy may depend
on recency of useage, specificity of the rule or other criteria
3.Execute
• The rule selected from the conflict set is executed by carrying the action or conclusion part of
the rule, the RHS of the rule.
• This may involve an I/O operation, adding, removing or changing clauses in working memory
or simply causing a halt
The above cycle is repeated until no rules are put in the conflict set or until a stopping condition is
reached
[email protected] Page 54
S6 BSc Computer Science CS1643: Artificial Intelligence
Module IV
[email protected] Page 55
S6 BSc Computer Science CS1643: Artificial Intelligence
1. Speech
2. Written Text
Components of NLP
It is the process of producing meaningful phrases and sentences in the form of natural
language from some internal representation.
It involves −
• Text planning − It includes retrieving the relevant content from knowledge base.
• Sentence planning − It includes choosing required words, forming meaningful phrases,
setting tone of the sentence.
• Text Realization − It is mapping sentence plan into sentence structure.
[email protected] Page 56
S6 BSc Computer Science CS1643: Artificial Intelligence
Steps in NLP
[email protected] Page 57
S6 BSc Computer Science CS1643: Artificial Intelligence
Overview of linguistics
• “Linguistics is the scientific study of language. It involves the analysis of language form,
language meaning, and language in context. Linguists traditionally analyze human
language by observing an interplay between sound and meaning.
• Traditionally it has been analyzing human language by observing an interplay between
sound and meaning.
• It also deals with different factors that influence language, often:
1. Social.
2. Cultural.
3. Historical
4. Political
Types of Linguistics
1. Historical and evolutionary linguistics: focuses on how languages change and grow over
an extended period of time.
2. Semiotics: the study of direct and indirect language through signs and symbols.
3. Literary criticism: the historical and ideological analysis of literature, cinema, art, or
published material.
4. Translation: the conversion and documentation of meaning in written/spoken text from
one language or dialect onto another.
5. Speech-language pathology: a corrective method to cure phonetic disabilities and dis-
functions at the cognitive level
[email protected] Page 58
S6 BSc Computer Science CS1643: Artificial Intelligence
Example
Grammar G1 −
({S, A, B}, {a, b}, S, {S → AB, A → a, B → b})
Here,
• S, A, and B are Non-terminal symbols;
• a and b are Terminal symbols
• S is the Start symbol, S ∈ N
• Productions, P : S → AB, A → a, B → b
•
• Parser is a compiler that is used to break the data into smaller elements coming from
lexical analysis phase.
• A parser takes input in the form of sequence of tokens and produces output in the form
of parse tree.
• Parsing is of two types: top down parsing and bottom up parsing.
[email protected] Page 59
S6 BSc Computer Science CS1643: Artificial Intelligence
Bottom up parsing
[email protected] Page 60
S6 BSc Computer Science CS1643: Artificial Intelligence
Semantic Analysis
• The purpose of semantic analysis is to draw exact meaning, or you can say dictionary
meaning from the text. The work of semantic analyzer is to check the text for
meaningfulness.
• The most important task of semantic analysis is to get the proper meaning of the
sentence.
• For example, analyze the sentence “Ram is great.” In this sentence, the speaker is
talking either about Lord Ram or about a person whose name is Ram. That is why the
job, to get the proper meaning of the sentence, of semantic analyzer is important.
• semantic analysis can be divided into the following two parts −
It is the first part of the semantic analysis in which the study of the meaning of individual words
is performed. This part is called lexical semantics.
In the second part, the individual words will be combined to provide meaning in sentences.
Hyponymy :-It may be defined as the relationship between a generic term and instances of that
generic term.
Homonymy:-It may be defined as the words having same spelling or same form but having
different and unrelated meaning.
Polysemy:-Polysemy is a Greek word, which means “many signs”. It is a word or phrase with
different but related sense.
[email protected] Page 61
S6 BSc Computer Science CS1643: Artificial Intelligence
Representation Structure
Semantic analysis creates a representation of the meaning of a sentence. But before getting
into the concept and approaches related to meaning representation, we need to understand
the building blocks of semantic system.
1. Entities − It represents the individual such as a particular person, location etc. For
example, Haryana. India, Ram all are entities.
2. Concepts − It represents the general category of the individuals such as a person, city,
etc.
3. Relations − It represents the relationship between entities and concept. For example,
Ram is a person.
4. Predicates − It represents the verb structures. For example, semantic roles and case
grammar are the examples of predicates.
Example of a simple NLG system is the Pollen Forecast for Scotland system that could
essentially be a template. NLG system takes as input six numbers, which predicts the
pollen levels in different parts of Scotland. From these numbers, a short textual summary
of pollen levels is generated by the system as its output.
[email protected] Page 62
S6 BSc Computer Science CS1643: Artificial Intelligence
2. Human ratings: It assess the generated text on the basis of ratings given by a person on
the quality and usefulness of the text.
The expert systems are the computer applications developed to solve complex problems in a
particular domain, at the level of extra-ordinary human intelligence and expertise.
• High performance
• Understandable
• Reliable
• Highly responsive
• Advising
• Instructing and assisting human in decision making
• Demonstrating
• Deriving a solution
• Diagnosing
[email protected] Page 63
S6 BSc Computer Science CS1643: Artificial Intelligence
• Explaining
• Interpreting input
• Predicting results
• Justifying the conclusion
• Suggesting alternative options to a problem
1. Knowledge Base
2. Inference Engine
3. User Interface
Let us see them one by one briefly −
[email protected] Page 64
S6 BSc Computer Science CS1643: Artificial Intelligence
1. Knowledge Base
What is Knowledge?
The data is collection of facts. The information is organized as data and facts about
the task domain. Data, information, and past experience combined together are
termed as knowledge.
Knowledge Acquisition
• The success of any expert system majorly depends on the quality, completeness, and
accuracy of the information stored in the knowledge base.
• The knowledge base is formed by readings from various experts, scholars, and
the Knowledge Engineers. The knowledge engineer is a person with the qualities of
empathy, quick learning, and case analyzing skills.
• He acquires information from subject expert by recording, interviewing, and observing
him at work, etc. He then categorizes and organizes the information in a meaningful
way, in the form of IF-THEN-ELSE rules, to be used by interference machine. The
knowledge engineer also monitors the development of the ES.
2. Inference Engine
Use of efficient procedures and rules by the Inference Engine is essential in deducting a
correct, flawless solution.
In case of knowledge-based ES, the Inference Engine acquires and manipulates the knowledge
from the knowledge base to arrive at a particular solution.
In case of rule based ES, it −
• Applies rules repeatedly to the facts, which are obtained from earlier rule application.
• Adds new knowledge into the knowledge base if required.
[email protected] Page 65
S6 BSc Computer Science CS1643: Artificial Intelligence
• Resolves rules conflict when multiple rules are applicable to a particular case.
To recommend a solution, the Inference Engine uses the following strategies −
A. Forward Chaining
B. Backward Chaining
A. Forward Chaining
It is a strategy of an expert system to answer the question, “What can happen next?”
Here, the Inference Engine follows the chain of conditions and derivations and finally deduces
the outcome. It considers all the facts and rules, and sorts them before concluding to a
solution.
This strategy is followed for working on conclusion, result, or effect. For example, prediction of
share market status as an effect of changes in interest rates.
B. Backward Chaining
With this strategy, an expert system finds out the answer to the question, “Why this
happened?”
On the basis of what has already happened, the Inference Engine tries to find out which
conditions could have happened in the past for this result. This strategy is followed for finding
out cause or reason. For example, diagnosis of blood cancer in humans.
[email protected] Page 66
S6 BSc Computer Science CS1643: Artificial Intelligence
3. User Interface
User interface provides interaction between user of the ES and the ES itself. It is generally
Natural Language Processing so as to be used by the user who is well-versed in the task
domain. The user of the ES need not be necessarily an expert in Artificial Intelligence.
It explains how the ES has arrived at a particular recommendation. The explanation may
appear in the following forms −
Knowledge System Building Tools are programming systems which simplify the job of
constructing an expert system. We divide expert system tools into four major categories as
shown in Fig.
[email protected] Page 67
S6 BSc Computer Science CS1643: Artificial Intelligence
1. Programming Languages:
Most important programming languages used for expert system applications are generally
either problem-oriented languages, such as FORTRAN and PASCAL, or symbol-manipulation
languages, such as LISP and PROLOG. Problem oriented languages are designed for particular
classes of problems; e.g., FORTRAN has convenient features for performing algebraic
calculations
Symbol-manipulation languages are designed for artificial intelligence applications; e.g., LISP
3. System-Building Aids:
The system-building aids consist of programs which help acquire and represent the domain
expert’s knowledge and programs which help design the expert system under construction.
These programs address very difficult tasks; many are research tools just beginning to evolve
into practical and useful aids, although a few are offered as full-blown commercial systems
4. Explanation Facilities:Almost all expert systems can explain to users how they reach
particular conclusions, though not all provide the same degree of software support for
explanation.
[email protected] Page 68