Artificial Intelligence
Artificial Intelligence
MCA
Sem II- Even Sem
Academic Year 2021-22
Contents
LISP
LISP stands for LISt Processing. It is one of the oldest programming Languages. It was invented by
McCarthy during late 1950’s. It is particularly suited for AI programs because of its ability to process
symbolic information effectively. It is a language with a simple syntax, with little or no data typing
and dynamic memory management.
Syntax
1. Atom – An atom is a number or string of contiguous characters, including numbers and special
characters.
2. List – A list is a sequence of atoms and/or other lists enclosed within parenthesis.
3. String – A string is a group of characters enclosed in double quotation marks.
hello-from-tutorials-point
name
123008907
*hello*
Block#221
abc123
( i am a list)
(a ( a b c) d e fgh)
(father tom ( susan bill joe))
(sun mon tue wed thur fri sat)
()
" I am a string"
"a ba c d efg #$%^&!"
"Please enter the following details :"
"Hello from 'Tutorials Point'! "
Example:
List = (a b (c d) e (f))
Numeric Functions
Sometimes we wish to take atoms or lists literally and not have them evaluated or treated as function
calls, when the list represents data. To accomplish this we precede the atom or list with a singlequotation
mark.
Assignment in LISP
Example
Note: The quotation marks preceding the arguments in the function calls of the above table. An error
will result if they are not there because the interpreter will try to evaluate each argument before
evaluating the function.
Notice the difference in results with and without the quotation marks.
Function Call
Where any number of arguments may be used. When a function is called, the arguments are evaluated
first from left to right (unless within quotation marks) and then the function is executed using the
evaluated argument values.
The format is
(defun name (parm1 parm2 …) body)
Defun does not evaluate its arguments. It simply builds a function which may be called like any other
function.
Example
-> (defun averagethree (n1 n2 n3)
(/ (+ n1 n2 n3) 3))
AVERAGETHREE
->
When a function is called, the arguments supplied in the call are evaluated unless they are in quotation
marks and bound to (assigned) the function parameters. The argument values are bound to the
parameters in the same order they were given in the definition.
Predicate Function
Predicates are functions that test their arguments for some specific condition. Predicates return true (t)
or false (nil) depending on the arguments. The most common predicates are:
1. atom = takes one argument. It returns t if the argument is an atom and nil otherwise.
2. equal = takes 2arguments and returns t it they evaluate to the same value, and nil otherwise.
3. evenp, number, oddp, zerop = are tests on a single numeric argument. They return t if their
argument evaluates to an even number, a number, an odd number, or zero respectively. Otherwise
they each return nil.
4. greaterp and lessp = each take one or more arguments. If there is only one argument, each returns
t. If more than one argument is used, greaterp returns t if the arguments, from left to right, are
successively larger; otherwise nil is returned. Lessp requires that the arguments be successively
smaller from left to right to return t. Otherwise it returns nil.
5. >= and <= have same meaning as greaterp and lessp, except they return t if successive elemnets
are also equal.
6. listp and null = both take a single argument. Listp returns t if its argument evaluates to a list, and
nil otherwise. Null returns t if its argument evaluates to nil; otherwise it returns nil.
Examples:
The Conditional
To make use of predicates, we need some construct to permit branching. Cond (for conditional) is like
if…then…else construct.
. .
(<testk> <actionk>))
Each (<testi> <actioni>), i=1, …,k, is called a clause. Each clause consists of a test protion and an
action or result portion. The first clause following the cond is executed by evaluating <test1>. If this
evaluates to non-nil, the <action1> portion is evaluated, its value is returned, and the remaining clauses
are skipped over. If<test1> evaluates to nil, control passes to the second clause without evaluating
<action1> and the procedure is repeated, If all tests evaluate to nil, cond returns nil.
Example:
-> (defun maximum2 (a b)
(cond ((> a b) a)
(t b)))
MAXIMUM2
->
When maximum2 is executed, it starts with the first clause following the cond. The test sequence is as
follows: if (the argument bound to) a is greater than (that bound to) b, return a else return b. Note the t
in the second clause preceding b. This forces the last clause to be evaluated when the first clause is not
Logical Functions
Like predicates, logical functions may also be used for flow of control. The basic logical operators are
and, or and not. Not is the simplest. It takes one argument and returns t if the argument evaluates to nil;
returns nil if its argument evaluates to non-nil. The functions and and or both take any number of
arguments. For both the arguments are evaluated from left to right. In case of and, if all arguments
evaluate to non-nil, the value of the last argument is returned; otherwise nil is returned. The arguments
of or are evaluated until one evaluates to non-nil, in which case it returns the argument value; otherwise
it returns nil.
Examples:
The most commonly used I/O functions are read, print, prinl, princ, terpri and format.
Read takes no argument. When read appears in a procedure, processing halts until a single s-expression
is entered from the keyboard. The s-expression is then returned as the value of read and processing
continues.
Example:
If we include read in an arithmetic expression, an appropriate value should be entered when the
interpreter halts.
->(+ 5 (read))
6
11
->
Print takes one argument. It prints the argument as it is received, and then returns the argument. When
print is used to print an expression, its argument is preceded by the carriage-return and line feed
characters and is followed by a space.
-> (print ‘(a b c))
(A B C)
(A B C)
->(print “hello there”)
“hello there”
“hello there”
Notice that print even prints the double quotation marks defining the string.
Prinl is the same as print except that the new-line characters and space are not provided
-> ((prinl ‘(hello))(prinl ‘(hello)))
(HELLO)(HELLO)
->
Princ – used to avoid double quotation marks in the output. It is the same as prinl except it does not
print the unwanted quotation marks.
Example
-> (princ “hello there”)
hello there “hello there”
Princ eliminated the quotes, but the echo still remains. This is because princ returned its argument and
since that was the last thing returns, it was printed by the read-evaluate-print loop.
Terpri The primitive function terpri takes no arguments. It introduces a new-line (carriage return and
line feed) wherever it appears and then returns nil.
Format
The format function permits us to create cleaner output than is possible with just the basic printing
functions.
It has the form (format <destination> <string> arg1 arg2 …).
Destination specifies where the output is to be directed, like to the monitor or some other external
file. By default its monitor.
String is the desired output string, but intermixed with format directives which specify how each
argument is to be represented.
Directives appear in the string in the same order the arguments are to be printed.
The most common directives are given below:
-
A - The argument is printed as though princ were used.
-
S - The argument is printed as though prinl were used.
-
D – The argument which must be an integer is printed as a decimal number
-
F - The argument which must be a floating point number is printed as a decimal floating-point
number
-
C – The argument is printed as character output.
-
% - A new-line is printed.
The field widths for appropriate argument values are specified with an integer immediately following
the tilde symbol.
The values they are assigned within the function are accessible only within that function.
Example:
The variable x in the defun is local in scope. It reverts back to its previous value after the function local-
var is exited. The variable y, on the other hand, is global. It is accessible from any procedure and retain
its value unless with setq.
The let and prog constructs also permit the creation of local variables.
Let function
The syntax of the let function is (let ((var1 val1 ) ((var2 val2 )…) <s-expression>)
Where each vari , is a different variable name and vali is an initial value assigned to each vari
respectively. When let is executed, each vali is evaluated and assigned to the corresponding var i ,
and the s-expression which follow are then evaluated in order.
The value of the last expression evaluated is then returned.
If an initial value is not included with a vari, it is assigned nil, and the parenthesis enclosing it may
be omitted.
-> (let ((x ‘a)
(y ‘b)
(z ‘c)
(cons x (cons y (list z))))
(A B C)
->
Prog Function
The prog function is similar to let in that the first arguments following it are a list of local variables
where each element is either a variable name or a list containing a variable name and its initial
value.
This is followed by the body of the prog, and any no. of s-expressions.
Prog executes list s-expressions in sequence and returns nil unless it encounters a function named
return.
In this case a single argument of return is evaluated and returned.
-> (defun memb (e1 1st)
(Prog ()
Start
(cond ((equal el (car 1st)) (return 1st)))
(setq 1st (cdr 1st))
(go start)))
MEMB
->
Iteration Constructs
We introduce a structured form of iteration with the do construct, which is similar to while loop in
Pascal.
The vali are initial values which are all evaluated and then bound to the corresponding variables
vari in parallel.
Following each such statements are optional update statements which define how the vari are to be
updated with each iteration.
After the variables are updated during an iteration, the test is evaluated , and if it returns non-
nil(true), the return-value is evaluated and returned.
The s-expressions forming the body of the construct are optional.
If present, they are executed each iteration until an exit test condition is encouneterd.
Example:
-> (defun factorial (n)
(do ((count n (- count 1))
(Product n (* product (-count 1))
((equal 0 count) product)))
FACTORIAL
->
Recursion
A recursive function is one calls itself successively to reduce a problem to a sequence of simpler steps.
Recursion requires a stopping condition and a recursive step.
Example : Factorial
The recursive step in factorial is the product of n and factorial (n-1). The stopping condition is reached
when n= 0.
Property Lists
The function putprop assigns properties to an atom. It takes 3 arguments: an object name (an atom)
, a property or attribute name and property or attribute value.
For example: to assign properties to a car, we can assign properties such as make, year, color and
style with the following statements.
The object car will retain these properties until they are replaced with the new ones or until
removed with the remprop function.
Remprop function takes two arguments, the object and its attribute.
To retrieve a property value, such as color of car , we use function get, which also takes two
argments object and attribute.
Arrays
Single or multiple-dimension arrays may be defined in LISP using the make-array function.
The items stored in the array may be any LISP object.
To create an array with 10 cells named myarray, we bind the unquoted name to an array using setf
(or setq) with the make-array function and a specification of the number of cells.
-> (setf myarray (make-array ‘(10)))
#A(NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)
->
The function returns the pound sign (#) followed by an A and the array representation with its cells
initially set to nil.
To access the contents of cells, we use the function aref which takes two arguments, the name of
the array and the index value. Since the cells are indexed starting zero, an index value of 9 must
be used to retieve the contents of the tenth cell.
-> (aref myarray 9)
NIL
->
To store the items in the array, we use the function setf.
-> (setf (aref( myarray 0) 25)
25
-> (setf (aref myarray 1) ‘red)
RED
Prolog
Introduction
Applications of Prolog
o Specification Language
o Robot Planning
o Natural language understanding
o Machine Learning
o Problem Solving
o Intelligent Database retrieval
o Expert System
o Automated Reasoning
English Prolog
Dog is barking barking(dog)
Sun rises in east rises(sun)
Pickles are spicy spicy(pickles)
Priya like food if they are delicious likes(priya, Food):-delicious(Food)
Prakash likes food if they are spicy and delicious likes(prakash,Food):-
and spicy spicy(Food),delicious(Food)
While the first three statements are called facts and last two statements are called rules.
Note: Variable like Food’s whose first letter is capital because value of it came from the previous fact.
whereas the constants like priya, pickles are written in small letters. The predicates here are barking,
rises, spicy, likes etc. Who initialize the relation of subject to another? Or define what a subject do. First
three statement are called because they are declarative and doesn’t depends on any other statements,
they are just told. Where as in the last two statement first part is fact and another part is also fact and
the first part is depended on another part after “:-” symbol. That means priya likes food if the food is
delicious. prakash likes food if it is spicy and delicious too.
Note: Here (,) comma operator is applied for the And operator.
Goals
A goal is a statement starting with a predicate and probably followed by its arguments. In a valid goal,
the predicate must have appeared in at least one fact or rule in the consulted program, and the number
of arguments in the goal must be the same as that appears in the consulted program. Also, all the
arguments (if any) are constants.
The purpose of submitting a goal is to find out whether the statement represented by the goal is true
according to the knowledge database (i.e. the facts and rules in the consulted program). This is similar
to proving a hypothesis - the goal being the hypothesis, the facts being the axioms and the rules being
the theorems.
Prolog Variables
A variable in Prolog is a string of letters, digits, and underscores (_) beginning either with a capital
letter or with an underscore. Examples:
The variable _ is used as a "don't-care" variable, when we don't mind what value the variable has. For
example:
That is, X is a parent if they are a father or a mother, but we don't need to know who they are the
father or mother of, to establish that they are a parent.
Arithmetic Operators
For example:
?- X is 2 + 1.
X=3?
yes
6 -X Negation of 'X'
Operator precedence
If there is more than one operator in the arithmetic expression such as A-B*C+D, then the prolog
decides an order in which the operator should be applied.
Prolog gives numerical value for each operator, operators with high precedence like '*' and '/' are
applied before operators with relatively low precedence values like '+' and '-'.
Operator with same precedence value ('*' or '/') and ('+' or '-') should be applied from left to right.
So, the expression A-B*C+D can be written as A-(B*C)+D
Matching
Definition: The two terms are said to be matched, if they are equal or if they consist of variables
representing the resulting equal terms.
So,
?- 3 + 2= 5
no
Note: In prolog '=' means matches with.
But the following expressions will match because they have same structure.
Expression 1:
?- X + Y = 2 + 3
X=2
Y=3
Expression 2:
?- 2 + Y = X + 3
X=2
Y=3
Unification
The pattern matching part of Prolog is formally known as unification. The idea is simple. The
pattern color(X, Y) matches with color(rose, red) with the binding X=rose, Y=red. The pattern color(X,
X) does not match with the same predicate. (This requires a predicate of the form color(rose,rose).)
Control Structures
Loops
Loop statements are used to execute the code block multiple times. Code block is executed multiple
times using recursive predicate logic. There are no direct loops in some other languages, but we can
simulate loops with few different techniques.
Program
count_to_10(10) :- write(10),nl.
count_to_10(X) :-
write(X),nl,
Y is X + 1,
count_to_10(Y).
Output
| ?- [loop].
compiling D:/TP Prolog/Sample_Codes/loop.pl for byte code...
D:/TP Prolog/Sample_Codes/loop.pl compiled, 4 lines read - 751 bytes written, 16 ms
8
9
10
true ?
yes
| ?-
Decision Making
The decision statements are If-Then-Else statements. So when we try to match some condition, and
perform some task, then we use the decision making statements. The basic usage is as follows −
If <condition> is true, Then <do this>, Else
In some different programming languages, there are If-Else statements, but in Prolog we have to define
our statements in some other manner. Following is an example of decision making in Prolog.
Program
% If-Then-Else statement
% If-Elif-Else statement
Output
| ?- [test].
compiling D:/TP Prolog/Sample_Codes/test.pl for byte code...
D:/TP Prolog/Sample_Codes/test.pl compiled, 3 lines read - 529 bytes written, 15 ms
yes
| ?- gt(10,100).
X is smaller
yes
| ?- gt(150,100).
X is greater or equal
true ?
yes
| ?- gte(10,20).
X is smaller
true ?
yes
| ?- gte(100,100).
X and Y are same
true ?
yes
| ?-
Back Tracking
Backtracking is a procedure, in which prolog searches the truth value of different predicates by checking
whether they are correct or not. The backtracking term is quite common in algorithm designing, and in
different programming environments. In Prolog, until it reaches proper destination, it tries to backtrack.
When the destination is found, it stops.
Suppose A to G are some rules and facts. We start from A and want to reach G. The proper path will be
A-C-G, but at first, it will go from A to B, then B to D. When it finds that D is not the destination, it
backtracks to B, then go to E, and backtracks again to B, as there is no other child of B, then it backtracks
to A, thus it searches for G, and finally found G in the path A-C-G. (Dashed lines are indicating the
backtracking.) So when it finds G, it stops.
Recursion
Recursion is a technique in which one predicate uses itself (may be with some other predicates) to find
the truth value.
Let us understand this definition with the help of an example −
is_digesting(X,Y) :- just_ate(X,Y).
is_digesting(X,Y) :-just_ate(X,Z),is_digesting(Z,Y).
So we can understand the predecessor relationship is recursive. We can express this relationship using
the following syntax −
predecessor(X, Z) :- parent(X, Z).
predecessor(X, Z) :- parent(X, Y),predecessor(Y, Z).
Introduction
In the real world many times we encounter a situation when we can’t determine whether the state
is true or false, their fuzzy logic provides very valuable flexibility for reasoning.
In this way, we can consider the inaccuracies and uncertainties of any situation.
In the boolean system truth value, 1.0 represents the absolute truth value and 0.0 represents the
absolute false value.
But in the fuzzy system, there is no logic for the absolute truth and absolute false value.
But in fuzzy logic, there is an intermediate value too present which is partially true and partially
false.
Architecture
RULE BASE: It contains the set of rules and the IF-THEN conditions provided by the experts to
govern the decision-making system, on the basis of linguistic information. Recent developments
in fuzzy theory offer several effective methods for the design and tuning of fuzzy controllers.
Most of these developments reduce the number of fuzzy rules.
FUZZIFICATION: It is used to convert inputs i.e. crisp numbers into fuzzy sets. Crisp inputs are
basically the exact inputs measured by sensors and passed into the control system for processing,
such as temperature, pressure, rpm’s, etc.
INFERENCE ENGINE: It determines the matching degree of the current fuzzy input with respect
to each rule and decides which rules are to be fired according to the input field. Next, the fired
rules are combined to form the control actions.
DEFUZZIFICATION: It is used to convert the fuzzy sets obtained by the inference engine into a
crisp value. There are several defuzzification methods available and the best-suited one is used
with a specific expert system to reduce the error.
This system can work with any type of inputs whether it is imprecise, distorted or noisy input
information.
The construction of Fuzzy Logic Systems is easy and understandable.
Fuzzy logic comes with mathematical concepts of set theory and the reasoning of that is quite
simple.
It provides a very efficient solution to complex problems in all fields of life as it resembles human
reasoning and decision-making.
The algorithms can be described with little data, so little memory is required.
Many researchers proposed different ways to solve a given problem through fuzzy logic which
leads to ambiguity. There is no systematic approach to solve a given problem through fuzzy logic.
Proof of its characteristics is difficult or impossible in most cases because every time we do not
get a mathematical description of our approach.
As fuzzy logic works on precise as well as imprecise data so most of the time accuracy is
compromised.
Applications
It is used in the aerospace field for altitude control of spacecraft and satellites.
It has been used in the automotive system for speed control, traffic control.
It is used for decision-making support systems and personal evaluation in the large company
business.
It has application in the chemical industry for controlling the pH, drying, chemical distillation
process.
Fuzzy logic is used in Natural language processing and various intensive applications in Artificial
Intelligence.
Fuzzy logic is extensively used in modern control systems such as expert systems.
Fuzzy Logic is used with Neural Networks as it mimics how a person would make decisions, only
much faster. It is done by Aggregation of data and changing it into more meaningful data by
forming partial truths as Fuzzy sets.
Crisp Sets
Crisp set is a collection of unordered distinct elements, which are derived from Universal set.
Universal set consists of all possible elements which take part in any experiment. Set is quite useful and
important way of representing data.
X = {1, 2, 3, 4, …}
Sets are always defined with respect to some universal set. Let us derive two sets A and B from this
universal set X.
Consider X represents class of students which acts as Universe of discourse. If you ask a question, “who
does have a driving license?” Obviously, all students might not have driving license. So those students
who have driving license will have membership value 1 for this particular set and rest of all will have
membership value zero.
We can define set A is equal to set of students having driving license and A will be definitely subset of
universal set X.
Crisp set is very convenient to represent and process the data. Many programing languages including
Python, R etc. supports the creation and manipulation of sets.
Fuzzy Sets
Fuzzy set is a natural way to deal with the imprecision. Many real world representation relies on
significance rather than precision. Fuzzy logic is the best way to deal with them. Fuzzy set is an
extension of crisp set.
For example if some heavy object is approaching to your friend from the top and you say that “hey
friend, 1500 kg mass is approaching to you at the speed of 45.3 m/s”. This statement is quite precise
but before your friend Interpret it, the object might have fallen on him.
But if you simply shout “hello friend, lookout” then probably statement is not so precise but it convey
quick information to your friend and he may move away from his place. In real world, we may be
looking for significance rather than precision. Fuzzy logic helps us to model imprecision into data for
many real world problems.
What if we have membership functions provided from two different people E.g. What a 6’11”
Basketball player defines as tall will differ from a 4’10” Gymnast. A guy having height 6.11 may
not be considered tall in case of Basketball, but a player with height 4.10 is considered as tall in
Gymnast. Thus, there might be ambiguity in interpretation of membership function, that is, domain
changes, interpretation also changes.
Defuzzification can produce undesired results. Different defuzzification techniques can produced
different crisp output for same fuzzy value. The produced crisp value might have large variations
in them, this creates lots of ambiguity in selection of defuzzification method.
Crisp/precise models can be more efficient and even convenient
Membership values begin to move away from expectations when chains of logic are lengthy so
this approach is not suitable for many KBS problems (e.g., medical diagnosis)
Example
If we have three linguistic representation for the temperature – called cool, nominal and warm, then
depending upon value, temperature ‘t’ has different membership in all three sets. The temperature
value t = 5 might have membership value 0.7 in cool set, 0.3 in nominal set and 0 in warm set. Because,
5 degree is considered quite cool but its not warm at all, so its membership value in cool set would be
high, where is it will be very low in warm set.
Example – 2:
Let us consider age is to be represented using fuzzy set. We will be using two fuzzy
sets Young and Very Young to represent different age range .
A = {young} ∈ [0, 90]
Let us see, how the membership value is affected by two different functions. As of now, the
mathematical description of both fuzzy sets is not important, but as a human, we can easily map that if
the range of young set is from 0 to 90, then as we move away from 0, they youngness will keep
decreasing and become 0 at the age 90. The age 30 is in upper half of the entire range and hence it has
higher membership value for being considered as young.
For set Very Young, the range is from 0 to 60, so age 30 is at the center and hence its obvious it takes
membership value 0.5.
1 Crisp set defines the value is either 0 or Fuzzy set defines the value between 0 and 1
1. including both 0 and 1.
2 It is also called a classical set. It specifies the degree to which something is true.
5 Crisp set application used for digital Fuzzy set used in the fuzzy controller.
design.
6 It is bi-valued function logic. It is infinite valued function logic
7 Full membership means totally Partial membership means true to false, yes to no,
true/false, yes/no, 0/1. 0 to 1.
Fuzzy Terminologies
https://codecrucks.com/fuzzy-terminologies-all-you-need-to-know/
The various steps involved in designing a fuzzy logic controller are as follows:
Step 1: Locate the input, output, and state variables of the plane under consideration. I
Step 2: Split the complete universe of discourse spanned by each variable into a number of fuzzy
subsets, assigning each with a linguistic label. The subsets include all the elements in the universe.
Step 3: Obtain the membership function for each fuzzy subset.
Step 4: Assign the fuzzy relationships between the inputs or states of fuzzy subsets on one side and
the output of fuzzy subsets on the other side, thereby forming the rule base.
Step 5: Choose appropriate scaling factors for the input and output variables for normalizing the
variables between [0, 1] and [-1, I] interval.
Step 6: Carry out the fuzzification process.
Step 7: Identify the output contributed from each rule using fuzzy approximate reasoning.
Step 8: Combine the fuzzy outputs obtained from each rule.
Step 9: Finally, apply defuzzification to form a crisp output.
Applications:
FLC systems find a wide range of applications in various industrial and commercial products and
systems. In several applications- related to nonlinear, time-varying, ill-defined systems and also
complex systems – FLC systems have proved to be very efficient in comparison with other
conventional control systems. The applications of FLC systems include:
1. Traffic Control
2. Steam Engine
3. Aircraft Flight Control
4. Missile Control
5. Adaptive Control
6. Liquid-Level Control
7. Helicopter Model
8. Automobile Speed Controller
9. Braking System Controller
10. Process Control (includes cement kiln control)
11. Robotic Control
12. Elevator (Automatic Lift) control;
13. Automatic Running Control
14. Cooling Plant Control
15. Water Treatment
16. Boiler Control;
17. Nuclear Reactor Control;
18. Power Systems Control;
19. Air Conditioner Control (Temperature Controller)
20. Biological Processes
21. Knowledge-Based System
22. Fault Detection Control Unit
23. Fuzzy Hardware implementation and Fuzzy Computers
1. https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.740.479&rep=rep1&type=pdf
2. http://www.jctjournal.com/gallery/30-sep2019.pdf
Introduction
Perception involves interpreting sights, sounds, smell, and touch. Action includes the ability to navigate
through the world and manipulate objects.
Most of AI is concerned only with cognition, the idea being that when intelligent programs are
developed, we will simply add sensors and effectors to them.
But problems in perception and action are substantial in their own right and are being tackled by
researchers in the field of robotics.
In the past, robotics and AI have been largely independent endeavors, and they have developed different
techniques to solve different problems.
Sl. No AI Robotics
AI programs usually operate in Robots must operate in the physical
1.
computer-simulated worlds. world.
A complete chess-playing robot,
Example: Chess, An AI program can
must be capable of grasping pieces,
search millions of nodes in a game tree
2. visually interpreting board
without ever having to sense or touch
positions, and carrying on a host of
anything in the real world.
other actions.
The input to an AI program is symbolic. The input to a robot is typically an
3. Eg., an 8-puzzle configuration or a analog signal, such as 2D video
typed English sentence. image or a speech waveform.
AI programs require only general- Robots require special hardware for
4.
purpose computers. perceiving and affecting the world.
Robots sensors are inaccurate, and
5. AI sensors are accurate. their effectors are limited in
precision.
Perception
We perceive our environment through many channels: sight, sound, touch, smell and taste. Two
extremely important sensory channels for humans are vision and spoken language. It is through these
two faculties that we gather almost all of the knowledge that drives our problem-solving behaviors.
Vision
Machine vision applications include mobile robot navigation, complex manufacturing tasks, analysis
of satellite images, and medical image processing. We investigate how we can transform raw camera
images into useful information about the world.
A video camera provides a computer with an image represented as a 2D grid of intensity levels. Each
grid element, or pixel, may store a single bit of information (black/white) or many bits (Color). A visual
image is composed of thousands of pixels. The operations that can be performed on these images are:
1. Signal Processing: Enhancing the image, either for human consumption or as input to another
program.
2. Measurement Analysis: For images containing a single object, determining the 2D extent of the
object depicted.
3. Pattern Recognition: For single object images, classifying the object into a category drawn from
finite set of possibilities.
4. Image Understanding: For images containing many objects, locating the objects in the image,
classifying them and binding a three-dimensional model of the scene.
Sometimes the problems remain unsolved because of the difficulties that include the following:
1. An image is 2D, while the world is 3D. Some information is lost when an image is created.
2. One image can contain several objects, and some objects may partially occlude others.
3. The value of a single pixel is affected by many different phenomena, including the color of the
object, the source of the light, the angle and distance of the camera, the pollution in the air, etc.
Given a single image, we could construct any number of 3D worlds that would give rise to the image.
For example consider the following image.
It is impossible to decide what 3D solid it portrays. In order to determine the most likely interpretation
of a scene, we have to apply several types of knowledge.
We may invoke knowledge about low-level image features, such as shadows and textures.
Figure shows how such knowledge can help to disambiguate the image.
Having multiple images of the same object can also be useful for recovering 3D structure.
The use of two or more cameras to acquire multiple simultaneous view of of the object is
called stereo vision.
Moving objects (or moving camera) also supply multiple views.
More information can be gathered with a laser rangefinder, a device that returns an array of
distance measures much like sonar does.
Speech Recognition
Spoken language is a more natural form of communication in many human computer interfaces. Below
are five major design issues in speech systems.
1. Speaker Dependence v/s Speaker Independence: A speaker independent system can listen to any
speaker and translate the sounds in to written text. Speaker independence is hard to achieve because
of the wide variations in pitch and accent. It is easier to build a speaker dependent system, which
can be trained on the voice patterns of a single speaker. The system will only work for that single
speaker.
2. Continuous v/s Isolated word speech: Interpreting isolated word speech, in which the speaker
pauses between each word, is easier than interpreting continuous speech. This is because boundary
effects cause words to be pronounced differently in different context. Example “Could u” contains
a j sound.
3. Real Time v/s Offline Processing: Highly interactive applications require that a sentence be
translated into text as it is being spoken, while in other situations, it is permissible to spend minutes
in computation. Real-Time speeds are hard to achieve, especially when higher-level knowledge is
involved.
4. Large v/s small vocabulary: Recognizing utterances that are confined to small vocabularies is
easier than working with large vocabularies.
5. Broad v/s Narrow Grammar: An example of a narrow grammar is phone number: S- XXXX –
XXXX , where X is any number between zero and nine.
Action
Mobility and intelligence seem to have evolved together. We study the mobility in terms of how robots
navigate through the world and manipulate objects:
Navigation
Navigation means moving around the world; planning routes, reaching desired destinations without
bumping into things.
The STRIPS system, for example, gave high level instructions to robot moving through a set of rooms,
carrying objects from one to another. Plans to solve goals like “move box A into room X” contained
operations like MOVE(Y,X). The planner did not concern itself with how this movement was to be
realized in the world.
Navigational Problems are surprisingly complex. For example, suppose that there are obstacles in the
robot’s path as shown in fig
The problem of path planning is to plot a continuous set of points connecting the initial position of the
robot to its desired position.
If the robot is so small as to be considered a point, the problem can be solved straight forwardly by
constructing a visibility graph.
Let S be the set consisting of the initial and final positions as well as the vertices of all obstacles. To
form the visibility graph, we connect every pair of points in S that are visible from one another. We can
then search an optimal path for the robot.
Most robots have bulky extent, we must take this into account when we plan paths.
Consider the problem shown in fig 21.8 where the robot has a pentagonal shape. The algorithm is as
follows: First choose a point P on the surface of the robot, then increase the size of the obstacles so that
they cover all points that P cannot enter, because of the physical size and shape of the robot. Now,
simply construct and search a visibility graph based on P and the vertices of the new obstacle.
Manipulation
Robot manipulators are able to perform simple repetitive tasks, such as bolting and fitting automobile
parts, but these robots are highly task specific. It is a long standing goal in robotics to build robots that
can be programmed to carry out a wide variety of tasks.
A manipulator is composed of a series of links and joints, usually terminating in an end-effector, which
can take the form of a two-pronged gripper, a human like hand or any of a variety of tools. One general
manipulation problem is pick-and-place., in which a robot must grasp an object and move it to a specific
location.
For example, Consider the fig below where the goal is to place a peg in a hole.
1. The first is to design a robot motion that ends with the object stably grasped between the two
fingers of the robot.
Clearly, some form of path planning can be used to move the arm toward the object. Here,
uncertainty is a critical problem. Even with the vision techniques, a robot can never be sure of the
precise location of the peg or the arm.
Therefore it would be a mistake to plan a grasp motion in which the gripper is spread only wide
enough to permit the peg to pass.
A better strategy is to open the gripper wide, then close gradually as the gripper gets near the peg.
As shown in fig 21.11
2. After the peg is stably grasped, the robot must place it in the hole.
This subtask resembles the path planning problem.
Fig 21.12 (a) shows a naïve strategy for placing the peg. Failure will result from even a slight
positioning error, because the peg will jam flatly on the outer surface. A better strategy is shown
in fig. 21.12(b) we slide the peg along the surface, applying downward pressure so that the peg
enters the hole at an angle. After this happens, we straighten the peg gradually and push it down
into the hole.
Robot Architectures
There are many decisions involved in designing an architecture that integrates perception, cognition,
and action.
1. Psychological Modeling
2. Improving Efficiency
3. Helping to organize systems in a modular fashion.
Psychological Modeling
While individual neurons is quite slow compared to digital computer circuits, there are vast
numbers of these richly interconnected components, and they all operate concurrently.
If we wish to model the brain or use it as a source of idea for AI, we must consider the
powers and constraints imposed by the brain’s architecture at the neural level.
AI programs consume significant time and space resources. It is therefore important that Ai algorithms
make use of advances in parallel computation. This can be done at 3 levels:
i. Parallelizing AI architecture
ii. Parallelizing AI Programming Languages
iii. Parallelizing AI Algorithms
Parallelizing AI Architecture
Production system have both sequential and parallel aspects. The question arises, how much speedup
can we expect from parallel processing. There are several sources of parallel speed up in production
systems:
Match-level Parallelism, in which multiple processors are used to speed up the handling of
individual match-resolve-act cycles.
o Production-level parallelism, in which all of the productions match themselves against
working memory in parallel.
o Condition-level Parallelism, in which all of the conditions of a single production are
matched in parallel.
Task-level Parallelism, in which several cycles are executed simultaneously.
1. OR-Parallelism: multiple paths for the same goal are taken in parallel.
Example:
Consider the following clauses
Could be satisfied in two different ways since john could be the sibling of Bill’s mother or of
Bill’s father. A sequential implementation would try to satisfy the first condition, and then if
failed, try the second condition.
Parallelizing AI Algorithms
Throwing more processors at an AI problem may not bring the desired benefits.
Many problems can be solved efficiently by parallel methods, but it is not always a simple matter
to convert a sequential algorithm into an efficient parallel one.
Some AI algorithms whose parallel aspects have been studied are best-first search, constraint
satisfaction, natural language parsing, and resolution theorem proving and property inheritance.
A distributed reasoning system is composed of a set of separate modules (called agents) and a set of
communication paths between them. It is a control mechanism and a shared knowledge base to ones in
which both control and knowledge are fully distributed.
1. System Modularity: It is easier to build and maintain a collection of quasi-independent modules than
one huge one.
2. Efficiency: Not all knowledge is needed for all tasks. By modularizing it, we gain the ability to focus
the problem-solving system’s efforts in ways that are most likely to pay off.
3. Fast Computer Architecture: As problem-solvers get more complex, they need more and more
cycles. Although machines continue to get faster, the real speed-ups are beginning to come not from
a single processor with a huge associated memory, but from clusters of smaller processors, each with
its own memory. Distributed systems are better able to exploit such architectures.
4. Heterogeneous Reasoning: The problem-solving techniques and knowledge representation
formalisms that are best for working on one part of a problem may not be the best for working on
another part.
5. Multiple Perspectives: The knowledge required to solve a problem may not reside in the head of a
single person. It is very difficult to get many diverse people to build a single, coherent, knowledge
base and sometimes it is impossible because their models of the domain are actually inconsistent.
6. Distributed Problems: Some problems are inherently distributed. For example, there may be
different data available in each of several distinct physical locations.
7. Reliability: If a problem is distributed across agents on different systems, problem-solving can
continue even if one system fails.