0% found this document useful (0 votes)
10 views250 pages

Ai 3

The document provides an overview of Artificial Intelligence (AI), defining it as the simulation of human intelligence in machines and discussing its applications such as speech recognition, computer vision, and expert systems. It outlines various types of knowledge, knowledge representation techniques, and the process of knowledge acquisition in AI systems. Additionally, it introduces propositional logic, logical equivalences, and rules of inference relevant to AI decision-making.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views250 pages

Ai 3

The document provides an overview of Artificial Intelligence (AI), defining it as the simulation of human intelligence in machines and discussing its applications such as speech recognition, computer vision, and expert systems. It outlines various types of knowledge, knowledge representation techniques, and the process of knowledge acquisition in AI systems. Additionally, it introduces propositional logic, logical equivalences, and rules of inference relevant to AI decision-making.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 250

ARTIFICIAL

INTELLIGENCE
Overview of Artificial
Intelligence: MODULE I
Artificial intelligence (AI) refers to the
simulation of human intelligence in
machines that are programmed to think like
humans and mimic their actions
John McCarthy (1955-1956)
AI action

Controller/ sensors
Processor:
Knowledge/
Model Environment

AI AGENT

Actuators
How to develop knowledge??

Explicitly programmed with required


knowledge to drive decisions/actions.
Eg:Robotics processing
automation.

Machine learning Based AI


Does memorization=Learning
??
Pigeons as art experts(Watanabe
1995)
Experiment
• Pigeon in box

• Present paintings of two different artists(eg


monet/picasso)

• Reward for picking when presented a


particular artist( eg picasso)
https://experiments.withgoogle.com/teachable-
machine

https
://www.kaggle.com/jessicali9530/stanford-dog
s
What is AI ?

 Artificial Intelligence (AI) is a branch of


Science which deals with helping machines
find solutions to complex problems in a more
human-like fashion.

This generally involves borrowing


characteristics from human intelligence, and
applying them as algorithms in a computer
friendly way.
Importance of AI

Game Playing
Speech Recognition
Understanding Natural Language
Computer Vision
Expert Systems
Heuristic Classification
Game Playing
Speech Recognition
Speech Recognition

Speech recognition is a technology which


enables a machine to understand the spoken
language and translate into a machine-
readable format.

It is a way to talk with a computer, and on the


basis of that command, a computer can
perform a specific task.

Eg: Google Virtual Assistant


Computer Vision
Computer Vision

Computer vision is a field of


artificial intelligence that trains computers to
interpret and understand the visual world.

Machines can accurately identify and locate


objects then react to what they “see” using
digital images from cameras, videos, and
deep learning models.
Expert Systems

• An expert system is a computer program that


is designed to solve complex problems and to
provide decision-making ability like a human
expert.
Heuristic Classification

One of the most feasible kinds of expert


system given the present knowledge of AI is
to put some information in one of a fixed set
of categories using several sources of
information.
Knowledge in AI

Knowledge is awareness or familiarity gained


by experiences of facts, data, and situations.
Types of Knowledge
Declarative Knowledge:
• Declarative knowledge is to know about
something.
• It includes concepts, facts, and objects.
• It is also called descriptive knowledge and
expressed in declarativesentences.
• It is simpler than procedural language.
Procedural Knowledge
• Procedural knowledge is a type of knowledge
which is responsible for knowing how to do
something.
• It can be directly applied to any task.
• It includes rules, strategies, procedures,
agendas, etc.
• Procedural knowledge depends on the task
on which it can be applied.
• It is imperative knowledge
Meta-knowledge

• Knowledge about the other types of


knowledge is called Meta-knowledge.

• Used to pick other knowledge that is best


suited for a problem.
Heuristic knowledge
• Heuristic knowledge is representing
knowledge of some experts in a field or
subject.

• Based on previous experiences, awareness of


approaches
Structural knowledge
• Structural knowledge is basic knowledge to
problem-solving.

• It describes relationships between various


concepts such as kind of, part of, and
grouping of something.

• It describes the relationship that exists


between concepts or objects.
AI knowledge cycle

Perception
Learning
Knowledge Representation and Reasoning
Planning
Execution
Knowledge Based Systems

A knowledge based system is a form of


Artificial intelligence that aims to capture
the knowledge of human experts to support
decision making.

Knowledge based system is more general


than expert

knowledge Base+inference engine


Components of KBS

Knowledge base
Contains system organized collection of facts
about a system domain.

Inference Engine
Tries to derives answers from knowledge base

User Interface
Enables the user to communicate with KBS.
Knowledge Representation

 There are mainly four approaches to knowledge


representation, which are given below

 Simple relational knowledge


 Inheritable knowledge
 Inferential knowledge
 Procedural knowledge
Simple Relational Knowledge

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.

This approach of knowledge representation is


famous in database systems where the
relationship between different entities is
represented.

This approach has little opportunity for


inference.
Player Name Weight Age

Rohit 65 33

Dhoni 70 39

kohli 50 32
Inheritable Knowledge

In the inheritable knowledge approach, all


data must be stored into a hierarchy of
classes.

All classes should be arranged in a


generalized form or a hierarchal manner.

This approach contains inheritable


knowledge which shows a relation between
instance and class, and it is called instance
relation.
Every individual frame can represent the
collection of attributes and its value.

 Arrows which point from objects to their


values.
Inferential knowledge

Inferential knowledge approach represents


knowledge in the form of formal logics.

This approach can be used to derive more


facts.

Example: Let's suppose there are two


statements:
a) Rohit is a man
b) All men are good
Procedural Knowledge

Procedural knowledge approach uses small


programs and codes which describes how to
do specific things, and how to proceed.

In this approach, one important rule is used


which is If-Then rule.

In this knowledge, we can use various coding


languages such as LISP
language and Prolog language.
Techniques of Knowledge Representation

There are mainly four ways of knowledge


representation which are given as follows:

 Logical Representation
 Semantic Network Representation
 Frame Representation
 Production Rules
Logical Representation

Logical representation means drawing a


conclusion based on various conditions.

 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:
 Syntax are the rules which decide how we
can construct legal sentences in the logic.
 It determines which symbol we can use in
knowledge representation.
 How to write those symbols.
Semantics:
 Semantics are the rules by which we can
interpret the sentence in the logic.
 Semantic also involves assigning a meaning
to each sentence.
Logical representation can be categorised into
two:
 Propositional Logics
 Predicate logics
Semantic Network 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.
This representation consist of mainly two
types of relations:
 IS-A relation (Inheritance)
 Kind-of-relation
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.
Slots may be of any type and sizes.

The various aspects of a slot is known


as Facets.

Facets are features of frames which enable us


to put constraints on the frames.
Production Rules

Production rules system consist of


(condition, action) pairs which mean, "If
condition then action". It has mainly three
parts:

 The set of production rules


 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.
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.
Example:
 IF (at bus stop AND bus arrives) THEN
action (get into the bus)
 IF (on the bus AND paid AND empty seat)
THEN action (sit down).
 IF (on bus AND unpaid) THEN action
(pay charges).
 IF (bus arrives at destination) THEN
action (get down from the bus).
Knowledge Acquisition

• Knowledge Acquisition is the process of


extracting,structuring and organizing the
knowledge from one or more sources.
Domain Knowledge Knowledge
Expert Engineer Base
Tasks of KA

Collect: Acquiring knowledge from expert

Interpret: Review and identify the key


information.

Analyze: Forming theories and stratigies for


solving a problem

Design: For better understanding of problem


KA Techniques

Introspection: Expert act as both expert and


knowledge Engineer

Observation: Experts closely observed work


with the help of video Recording

Induction : It is process of converting the set


of examples into rules.
Protocol Analysis:Expert is asked to perform
a task and verbalized thought process.

Protyping: Expert+KE

Interriewing: Early stage of Acquisition


ARTIFICIAL
INTELLIGENCE
Formalized Symbolic
Logics : MODULE II
Propositional Logic

Each sentence can be translated into logics


using syntax and semantics.
Syntax
Defines well formed sentence in the language.

Semantics
Defines the truth or meaning of sentence in a
world
PL is a simple logic

A proposition is a declarative statement that


either true or false.

It is not predicate , it can say either true or


false.
Symbols used in PL
NOT ┐ ¬A

AND ∧ A∧B

OR ∨ A ∨B

IMPLIES → A →B

IF AND ONLY ↔ A ↔B
IF
Negation(¬)

P ¬p

T F

F T
Conjunction(AND)

p q p∧q

T T T

T F F

F T F

F F F
Disjunction(OR)

p q p∨q

T T T

T F T

F T T

F F F
Implication(Then)

p q p→q

T T T

T F F

F T T

F F T
If and only If

p q p↔q

T T T

T F F

F T F

F F T
1) A-> It is not hot
B-> It is humid
C-> It is raining
Condition
A)If it is humid then it is hot
B→C
B)If it is hot and humid then it is not raining
A∧B→¬C
2) Translate the following propositional logic
into english sentences.
E-> Lion is eating
H->Lion is hungry

a)E→ ¬H
b)E∧ ¬H
c)¬(H → ¬E)
3)Translate the following English sentences to
Propositional Logic.
R-> Raining
S-> Rohit is Sick
H-> Rohit is Hungry
HA->Rohit is happy
C-> Rohit have a Cat
D-> Rohit have a Dog
1) It is raining if and only if rohit is sick
2) If rohit is sick then it is raining and
viceversa
3) Rohit is hungry but happy
4) Rohit either have a cat or a dog
Convert to PL

You are not allowed to drive car if your age is


less than 18 years or you have no age proof.
All these system specification consistent?
“The system is multiuser state if and only if it
is operating normally
“If the system is operating normally ,then
kernel is functioning”
“The kernel is not functioning or the system
is in interrupt mode”
“If the system is not in multiuser state, then
it is in interrupt mode”.
“The system is not in interrupt mode.”
Tautology
A Compound proposition which is always true.

p ¬p pv¬p

T F T

F T T
Contradiction
Compound proposition which is always false.

p ¬p p∧¬p

T F F

F T F
Contigency

Contigency
Compound proposition which is sometimes
true and sometimes false.
p q p∧q

T T T

T F F

F T F

F F F
Contigency

Satisfiability
Compound proposition is satisfiable if there
is atleast one true result in its truth table.
p q p∧q

T T T

T F F

F T F

F F F
Unsatisfiablity
Not even a single true result in its truth table.

p ¬p p∧¬p

T F F

F T F
Valid
A Compound statement is when it is tautology

p ¬p pv¬p

T F T

F T T
Invalid
A compound statement is invalid when it is
either contradiction or contigency.
Logical equivalences

• The compound proposition ‘p’ and ‘q’ are


said to be logically equivalent if p↔q is
tautology.

• Logical equivalence is denoted by ≡ or ↔ .


p∧T ≡ p
p T p∧T

T T T

F T F
Most common Logical equivalences
Which of the following boolean expression is
not a tautology?
a)(a→b) ∧(b→c) →(a→c)
b)(a↔c) →(¬b →(a ∧c))
c)(a ∧b ∧c) →(cv a)
d)a →(b →a)
The following propositional logic is
(p →(q ∨ r)) →((p ∧q) →r)

a)Satisfiable but not valid b)valid


c) Contradiction d) none of these
Let p,q,r denote the statements “It is
raining”,” “It is cold”, and “It is pleasant”,
respectively. Then the statement “It is not
raining and it is pleasant , and it is not
pleasant only if it is raining and it is cold” is
represented by
Rules of inference in PL

Premise is a proposition on the basis of


which we would be able to draw a conclusion,
or we can think premise as an evidence or
assumption.

Therefore, initially we assume something is


true and on the basis of that assumption, we
draw some conclusion.
Conclusion is a proposition that is reached
from given set of proposition

if premise then conclusion

Argument is a sequence of statements that


ends with a conclusion.
Valid Argument An Argument is said to be
valid if and only if it is not possible to make
all premises true and conclusion false.
Example
p1:If I love cat then I love dog
P2: I love cat
C: Therfore, “I love dog
p->q T
(p->q)^p->q
p T
q
Types of Inference rules

Rules of inferences are the templates for


constructing valid arguments.

Deriving conclusion from evidence.


Rules
Example:How to Build arguments using rules of
inference

Premises: “Rohit works hard”, “If Rohit


works hard ,then he is a dull boy” and “If
rohit is a dull boy ,then he will not get the
job”.

conclusion: Rohit will not get the job


p=Rohit works hard
q=Rohit is a dull boy
r= Rohit will get the job

p p p→q

p→q p→q q → ¬r
q → ¬r q ¬r
¬r q →¬r
¬r
Limitation of PL

We cannot represent relation like ALL,SOME


or NONE with PL
1) All girls are intelligent
2)some apples are sweet
• PL has limited expressive power.

• In PL ,we cannot describe statements in


terms of their proposition or logical
relationship.
First order logic or predicate Logic

Predicates
Quantifiers

Predicates are the statements involving variables


which are neither True or False until or unless the
values of the variable are specified.
x is a animal
x is greater than 5 7>5
x is less than 5
x+y=7 x= variable
In Predicate logic , a statement is divided into
two parts.
1)subject
2)predicate
For eg: “x is greater than 5”, can be
represented by G(x), where G(x) is denotes
predicate .”x is greater than 5” denote the
subject or variable.
g(x): x is greater than 5
After Assigning the value of a variable x, the
statement G(x) becomes a proposition and
has a truth value (either True or False).

G(7)= 7 is greater than 5 (True)


G(2)= 2 is greater than 5 (False)
Quantifiers

• Quantifiers are words that refers to


quantities such as “Some” or “ All”. It tells
for how many elements a given predicate is
TRUE.

Types of Quantifiers
 Universal quantifier
 Existential quantifier
Let p(x) be a statement x+1>x
p(1)= 1+1>1 T
P(2)=2+1>2 T

We can say that p(x) is true for all +ve


Integers x.

∀x p(x)
Let q(x) be the statement x<2
q(1):1<2 True
q(2):2<2 False

We can say that there is an ‘x’ for which q(x) is


True.

∃x q(x)
Universal quantiifer

• The Universal quantification of p(x) is the


statement:
“p(x) for all values of x in the domain”

• ∀ is called universal quantifier.


Domain
A domain specifies the possible values of
the vari
ables under consideration.

Let p(x) is the statement x+1>x


Domain: set of +ve integers

∀x p(x) is true under the domain of +ve


integers
Existential Quantifiers

The existential quantification of p(x) is the


proposition “ There exists an element “x” in
the domain such that p(x).

∃x p(x)
What is the truth value of ∃x p(x), where
p(x) is the statement x>10 and the domain
consists of the postive integers not
exceeding 4?
Logical equivalences involving predicates and
quantifiers

Two logical statements involving predicates


and quantifiers are said to be equivalent if
and only if they have same truth value in all
possible cases.

Logical equivalence is helpful in replacing


one expression with an equivalent expression
Two important equations Involving quantifiers

∀x(p(x) ∧Q(x)) ≡ ∀x p(x)∧ ∀x Q(x)

∃x(p(x) ∧Q(x)) ≡ ∃x p(x) ∧ ∃x Q(x)


Consider the following statement.
“Every student in the kerala University has
studied Artificial Intelligence”

Domain: All students of Kerala University


p(x):x has studied AI

∀x(p(x))
There is some student in the Kerala
university who has not studied AI

∃x ¬ p(x)
Nested quantifier

Two quantifier are said to be nested if one is


within the scope of other.

∀x ∃y Q(x,y)

∃ is within the scope of ∀.

∀x ∃y Q(x,y)= ∀x P(x)
∀x ∀y Q(x,y)
∀x ∃y Q(x,y)
∃y ∀x Q(x,y)
∃x ∃y Q(x,y)
Q)The sum of two postive integers is always
positive.

1) Read and understand the english statement


given in the question.
2) Find the domain according to the statement.
3) Find the associated quantifers
4) Rewrite the statement so that domain and
quantifier are visible.
5) Finally inroduce the variable in the
statement
Domain: Consists of all Integers
∀ (for all) quantifier will be used.
• For every two integers ,if the two integers are postitive then
the sum is also positive.

• For every two integers x and y, if x and y are postive then


x+y is also positive.

∀x ∀y((x>0 ^(y>0)-> (x+y>0))


ARTIFICIAL
INTELLIGENCE
Search and Control Strategies:
: MODULE III
Search and Control Strategies
• Problem solving is an important aspect of
Artificial Intelligence.

A problem can be considered to consist of a


goal and a set of actions that can be taken to
lead to the goal.

For eg: consider the problem of looking for a


ATM CARD on a football field.
Search is a method that can be used by
computers to examine a problem space like
this in order to find a goal.

A problem space can also be considered to be


a search space because in order to solve the
problem, we will search the space for a goal
state.
The Importance of Search in AI
It has already become clear that many of the
tasks underlying AI can be phrased in terms
of a search for the solution to the problem at
hand.

Many goal based agents are essentially


problem solving agents which must decide
what to do by searching for a sequence of
actions that lead to their solutions.
For production systems, we have seen the
need to search for a sequence of rule
applications that lead to the required fact or
action.

For neural network systems, we need to


search for the set of connection weights that
will result in the required input to output
mapping.
Four important factors to consider
Completeness – Is a solution guaranteed to
be found if at least one solution exists?
Optimality – Is the solution found guaranteed
to be the best (or lowest cost) solution if
there exists more than one solution?
Time Complexity – The upper bound on the
time required to find a solution, as a function
of the complexity of the problem.
Space Complexity – The upper bound on the
storage space (memory) requiredat any point
during the search, as a function of the
complexity of the problem.
Preliminary concepts

State Space Representations: The state


space is simply the space of all possible
states, or configurations, that our system may
be in.

There are two components to the


representation of state spaces:
 Static States
 Transitions between States
State Space Graphs
If the number of possible states of the system
is small enough,we can represent all of them,
along with the transitions between them, in a
state space graph.
Move(left,rigt,top,bottom)

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

2 4 2 3 4 2 3 4
5 3 1 5 7 1 5 1
8 7 6 8 6 8 7 6
Examples of search problems

Traveling Salesman Problem


Traveling Salesman Problem: Given n
cities with known distances between each
pair, find the shortest tour that passes
through all the cities exactly once before
returning to the starting city
1 2

4 3
Types of Search Algorithm

Based on the search problems we can classify


the search algorithms into two.

 uniformed (Blind search)


 informed search (Heuristic search)
Uniformed/Blind search
• The uniformed search does not contain any
domain knowledge.
• It operates in a brute-force way as it only
includes information about how to traverse
the tree and how to identify leaf and goal
nodes.
• It examines each node of the tree until it
achieves the goal node.
Breadth-first Search(BFS)
Breadth-first search is the most common
search strategy for traversing a tree or
graph. This algorithm searches breadthwise
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.
Breadth-first search implemented using FIFO
queue data structure.
S---> A--->B---->C--->D---->G--->H--->E---->F---->I----
>K
Advantages:
• BFS will provide a solution if any solution
exists.

• If there are more than one solutions for a


given problem, then BFS will provide the
minimal solution which requires the least
number of steps.
Disadvantages:
• It requires lots of memory since each level of
the tree must be saved into memory to
expand the next level.

• BFS needs lots of time if the solution is far


away from the root node.
Depth-first Search
• Starts from the root node and follows each
path to its greatest depth node before moving
to the next path.

• DFS uses a stack data structure for its


implementation.
Root->left->right
Advantage:
• DFS requires very less memory as it only
needs to store a stack of the nodes on the
path from root node to the current node.

• It takes less time to reach to the goal node


than BFS algorithm (if it traverses in the
right path).
Disadvantage:
• There is the possibility that many states keep
re-occurring, and there is no guarantee of
finding the solution.

• DFS algorithm goes for deep down searching


and sometime it may go to the infinite loop.
Uniform-cost Search Algorithm
• Uniform-cost search is a searching algorithm
used for traversing a weighted tree or graph.

• This algorithm comes into play when a


different cost is available for each edge.

• The primary goal of the uniform-cost search


is to find a path to the goal node which has
the lowest cumulative cost.
A uniform-cost search algorithm is
implemented by the priority queue.

It gives maximum priority to the lowest


cumulative cost.

Uniform cost search is equivalent to BFS


algorithm if the path cost of all edges is the
same.
Advantages:
Uniform cost search is optimal because at
every state the path with the least cost is
chosen.

Disadvantages:
It does not care about the number of steps
involve in searching and only concerned
about path cost. Due to which this algorithm
may be stuck in an infinite loop.
Depth-Limited Search Algorithm:
 A depth-limited search algorithm is similar to
depth-first search with a predetermined limit.

Depth-limited search can solve the drawback


of the infinite path in the Depth-first search.

Depth limited search algorithm consider the


node at the depth limit will treat as it has no
successor nodes further.
Depth-limited search can be terminated with
two Conditions of failure:

 Standard failure value: It indicates that


problem does not have any solution.

 Cutoff failure value: It defines no solution for


the problem within a given depth limit.
Advantages:
Depth-limited search is Memory efficient.

Disadvantages:
• Incompleteness.
• It may not be optimal if the problem has more
than one solution.
Iterative deepening depth-first Search:
• The iterative deepening algorithm is a
combination of DFS and BFS algorithms.

• This search algorithm finds out the best


depth limit and does it by gradually
increasing the limit until a goal is found.
IDDFS performs depth-first search up to a
certain "depth limit", and it keeps increasing
the depth limit after each iteration until the
goal node is found.
Advantages:
It combines the benefits of BFS and DFS
search algorithm in terms of fast search and
memory efficiency.

Disadvantages:
The main drawback of IDDFS is that it
repeats all the work of the previous phase.
1'st Iteration-----> A
2'nd Iteration----> A, B, C
3'rd Iteration------>A, B, D, E, C, F, G
Bidirectional Search Algorithm
• Two different search algorithm runs
simultaneously

• Forward search-> Start node towards the


goal node

• Backward search-> From goal node to start


node
Bidirectional search can use search
techniques such as BFS, DFS, DLS.

The search stops when these two graphs


intersect each other.
Advantages:
• Bidirectional search is fast.
• Bidirectional search requires less memory

Disadvantages
• Implementation of the bidirectional search
tree is difficult.
• In bidirectional search, one should know the
goal state in advance.
Informed Search
Informed search algorithm contains an array
of knowledge such as how far we are from the
goal, path cost, how to reach to goal node.

The informed search algorithm is more useful


for large search space.

Informed search algorithm uses the idea of


heuristic, so it is also called Heuristic search.
Heuristics function:
• Heuristic is a function which is used in
Informed Search, and it finds the most
promising path.

• 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.
h(n) <= h*(n)

h(n): Heuristic cost


h* (n): estimated cost.
Pure Heuristic Search
• Pure heuristic search is the simplest form of
heuristic search algorithms. It expands nodes
based on their heuristic value h(n).

• It maintains two lists, OPEN and CLOSED


list.

• In the CLOSED list, it places those nodes


which have already expanded
In the OPEN list, it places nodes which have
yet not been expanded.

On each iteration, each node n with the


lowest heuristic value is expanded and
generates all its successors and n is placed to
the closed list. The algorithm continues until
a goal state is found.
Best-first Search Algorithm(Greedy search)
• Best-first search algorithm always selects the
path which appears best at that moment.

• In best first search algorithm, we expand the


node which is closest to the goal node and
the closest cost is estimated by heuristic
function
Algorithm
Priority Queue AB containing intial states. AB=[A,B,C,D,E,F] node-A
ABCDE
Loop
if AB= Empty return fail
Else
NODE<-Remove_First(AB)
If NODE=GOAL
Return path from intial to node
Else
Generate all successors of NODE an insert newly generated NODE into AB
According cost value.
End loop
A-G=40
B-G=32
C-G=25
D-G=35
E-G=19
F-G=17
G-G=0
H-G=10
OPEN CLOSED
[A] []
[ C,B,D] [A]
[F,E,B,D] [A,C]
[G,E,B,D] [A,C,F]
[E,B,D] [A,C,F,G]

A-C-F-G =14+10+20=44
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).
In A* search algorithm, we use heuristic
value 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.

f(n)= g(n)+h(n)(CHILD NODE)


g(n)=cost to reach node N from start node
h(n)=cost to reach Node N to goal node.
Algorithm of A* search
1)Enter starting node in open List
2) Check if the OPEN list is empty or not, if the list is empty then return failure
and stops.
3)Select node from open list which has smallest value (g+h).
if node=Goal return success
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.
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.
6)Go to step 2
 S->A=1+3 =4 S->A->C-
>D->G=11
S->G=10+0=10 S->A->B-
>D->G=13

S->A->B=1+2+3=7
 S->A->C=1+1+2=4

 S->A->C->G=1+1+4=6
S->A->C->D=1+1+3+6=11
And-Or graphs(AO*)Search
• AO* is also known as AND-OR graph search
algorithms.
• According to AO* algorithm it is not exploring
all the solution paths once it has got the
solution.
• AO* Algorithm basically based on problem
decompositon (Breakdown problem into small
pieces)
When a problem can be divided into a set of
sub problems, where each sub problem can
be solved separately and a combination of
these will be a solution.
A* Vs AO*
• Both are part of informed search technique
and use heuristic values to solve the problem.
• A* always gives an optimal solution (shortest
path with low cost) But it is not guaranteed to
that in AO*. Because AO* does not explore all
the solution path once it got solution.
mobile

And
arc

Word Purchase
Gift hard mobile

OR
AND
ARTIFICIAL
INTELLIGENCE
NLP:
: MODULE IV
NLP

NLP stands for Natural Language Processing.

It is the technology that is used by machines to


understand, analyse, manipulate, and interpret
human's languages.

It helps developers to organize knowledge for


performing tasks such as translation, automatic
summarization, Named Entity Recognition
(NER), speech recognition, relationship
extraction, and topic segmentation.
Applications of NLP

1)Question Answering
Question Answering focuses on building
systems that automatically answer the
questions asked by humans in a natural
language.
Spam Detection
Spam detection is used to detect unwanted e-
mails getting to a user's inbox.
Machine Translation
Machine translation is used to translate text
or speech from one natural language to
another natural language.
Spelling correction
Speech Recognition
Speech recognition is used for converting
spoken words into text. It is used in
applications, such as mobile, home
automation, video recovery, voice biometrics,
voice user interface, and so on.
Chatbot
Implementing the Chatbot is one of the
important applications of NLP. It is used by
many companies to provide the customer's
chat services.
Grammars and Languages

According to Chomsky hierarchy, grammars


are divided of 4 types: G=(V,T,P,S) V:

 Type 0 known as unrestricted grammar.


 Type 1 known as context sensitive
grammar.
 Type 2 known as context free grammar.
 Type 3 Regular Grammar.
The simplest grammars are used to define
regular languages.

A regular language is one that can be


described or understood by a finite state
automaton.
• Finite Automata(FA) is the simplest machine
to recognize patterns.The finite automata or
finite state machine is an abstract machine
which have five elements or tuple.

• It has a set of states and rules for moving


from one state to another but it depends upon
the applied input symbol.
A Finite Automata consists of the following :
Q : Finite set of states.
Σ : set of Input Symbols.
q : Initial state.
F : set of Final States.
δ : Transition Function.
Formal specification of machine is
{ Q, Σ, q, F, δ }.
FA is characterized into two types:
1) Deterministic Finite Automata (DFA)
DFA consists of 5 tuples {Q, Σ, q, F, δ}.
Q : set of all states.
Σ : set of input symbols. ( Symbols which
machine takes as input )
q : Initial state. ( Starting state of a machine )
F : set of final state.
δ : Transition Function, defined as δ : Q X Σ -->
Q.
In a DFA, for a particular input character, the
machine goes to one state only. A transition
function is defined on every state for every
input symbol.
Nondeterministic Finite Automata(NFA)
δ: Transition Function
δ: Q X Σ --> 2 ^ Q.
Ability to transmit to any number of states for
a particular input.
Regular languages are of interest to
computer scientists, but are not of great
interest to the field of natural language
processing because they are not powerful
enough to represent even simple formal
languages.

Sentences defined by a regular grammar are


often known as regular expressions.
Context free grammar
 Context free grammar is a formal grammar
which is used to generate all possible strings
in a given formal language.
 Context free grammar G can be defined by
four tuples as:
G= (V, T, P, S)
T describes a finite set of terminal symbols.

V describes a finite set of non-terminal symbols

P describes a set of production rules

S is the start symbol.


S → aSa
S → bSb
S→c
Now check that abbcbba string can be
derived from the given CFG.
S ⇒ aSa
S ⇒ abSba
S ⇒ abbSbba
S ⇒ abbcbba
Context-sensitive grammars are most usually
used for natural language processing because
they are powerful enough to define the kinds
of grammars that natural languages use.
Parsing
The process, in which we convert a sentence
into a tree that represents the sentence’s
syntactic structure, is known as parsing.

Parsing a sentence tells us whether it is a


valid sentence, as defined by our grammar.

If a sentence is not a valid sentence, then it


cannot be parsed.
Parse trees can be built in a bottom-up fashion
or in a top-down fashion.

Building a parse tree from the top down involves


starting from a sentence and determining which
of the possible rewrites for Sentence can be
applied to the sentence that is being parsed.

Sentence→NounPhrase VerbPhrase
When a parse tree is built from the top down,
it is known as a derivation tree.
Basic Parsing Techniques
 Transition Networks
 Augmented Transition Networks
 Semantic Analysis
Transition Networks
A transition network is a finite state
automaton that is used to represent a part of
a grammar.
Augmented Transition Networks
An augmented transition network, or ATN, is an
extended version of a transition network.

An ATN is a top down parsing procedure that


allows various kinds of knowledge to
incorporated into the parsing system so it can
operate efficiently.

ATN build on the idea of using finite state


machines to parse sentences.
A grammatically correct sentence parsed by
reaching a final state in any state graph.

A sentence is determined to be grammatically


correct if a final state reached by the last
word in the sentence.
Semantic Analysis
Semantics is the study of the meaning of
words.

semantic analysis is the analysis we use to


extract meaning from expressions.
Semantic analysis involves building up a
representation of the objects andactions that
a sentence is describing, including details
provided by adjectives, adverbs, and
prepositions.
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 etc.
Matching is the process of comparing two
structures or patterns for equality.

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.
Structures used in Matching(Qualitative)

Variables
The structures are constructed from basic
atomic elements, numbers and characters.

Character string elements may represent


either constants or variables.
Nominal variables
• variables whose values or states have no
order nor rank

• It is possible to distinguish between equality


or inequality between two objects

• Each state can be given a numerical code


For example marks of students
50 to 60 C ->1
60 to 70 B ->2
70 to 80 A ->3
Ordinal variables
• variables whose states can be arranged in a
rank order
• Each state can be given a numerical code.

For example, the states very tall, tall,


medium, short and very short can be
arranged in order from tallest to shortest and
can be assigned an arbitrary scale of 5 to 1
Binary variable
discrete variables which may assume only
one of two values, such as 0 or 1, good or
bad, yes or no, high or low
Interval variables or Metric variables
Variables which take on numeric values and
for which equal differences between values
have the same significance.

For eg: 100-200 -> [A]


300-400 -> [B]
Graphs and Trees
A graph is a collection of points called
vertices, some of which are connected by line
segments called edges.
A graph G = (V, E) is an ordered pair of sets V
and E.

A tree is a connected graph in which there


are no cycles.
Sets and Bags
A set is represented as an unordered list of
unique elements such as the set (a d f c) or
(red blue green yellow)

A bag is a set which may contain more than


one copy of the same member.
Measure for Matching
The similarity between two structures is a
measure of the degree of association or
likeness between the object’s attributes and
other characteristics parts.

If the describing variables are quantitative, a


distance metric is used.
Distance Metrics

Euclidean Distance:
• Euclidean distance is considered the
traditional metric for problems with
geometry.
• It can be simply explained as the ordinary
distance between two points.
Manhattan Distance(city block distance):
• This determines the absolute difference
among the pair of the coordinates.

• Manhattan distance between P and Q = |x1 –


x2| + |y1 – y2|
Minkowski distance:
• It is the generalized form of the Euclidean
and Manhattan Distance Measure.
Probabilistic measures
 The representation variables should be
treated as random variables.

Mahalanobis distance which gives a


measure of the
separation between a point and a
distribution.
Partial Matching
For many AI applications complete matching
between two or more structures is inappropriate.

For example, input representations of speech


waveforms or visual scenes may have been
corrupted by noise or other unwanted distortions.

In such cases, we do not want to reject the input


out of hand. Our systems should be more tolerant
of such problems.
Finding Match Differences
In visual application, an industrial part may be
described using a graph structure where the set
of nodes correspond to rectangular or
cylindrical block subparts.
The arc in the graph correspond to positional
relations between the subparts.
Labels for rectangular block nodes contain
length, width and height, while labels for
cylindrical block nodes, where location can be
above, to the right of, behind,inside and so on.
This graph consists of subparts, made up of
rectangular and cylindrical blocks with
dimensions specified by attribute values.

This type of graph is called attributed


relational graphs (ATRs). Such a graph G is
defined as a 6 tuple G = (N, B, A, Gn, Gb)
N = { n1, n2, . . ., nk}is a set of nodes
A = {a n1, an2, . . . , ank} is an alphabet of
node
attributes.
B = { b1, b2, . . . , bm}is a set of directed
branches

Gn and Gb are functions for generating node


and
branch attributes
RETE matching algorithm
One potential problem with expert systems is the
number of comparisons that need to be made
between rules and facts in the database.

In some cases, where there are hundreds or even


thousands of rules, running comparisons against
each rule can be impractical.

The RETE Algorithm is an efficient method for


solving this problem and is used by a number of
expert system tools.
The RETE is a directed, acyclic, rooted graph.

Each path from the root node to a leaf in the


tree represents the left-hand side of a rule.

S(LHS)->J(RHS)


Each node stores details of which facts have
been matched by the rules at that point in the
path.

The basic inference cycle of a production


system is match, select and execute.
Match
During the match portion of the cycle, the
conditions in the LHS of the rules in the
knowledge base are matched against the
contents of working memory to determine
which rules have their LHS conditions
satisfied with consistent bindings to working
memory terms.

Rules which are found to be applicable are


put in a conflict set.
Select
From the conflict set, one of the rules is selected to
execute.
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.
 The above cycle is repeated until no rules are put
in the conflict set or until a stopping condition is
reached.

You might also like