Professional Documents
Culture Documents
MODULE – 1
OBJECTIVES:
1. Introduction to AI
2. Problems in AI
KEYPOINTS:
1. Introduction to AI
1.1 AI definitions.
1.2 AI history.
1.3 AI techniques.
1.4 Comparison of AI programs and conventional software.
2. Problems in AI
2.1 Different methods of representing a problem.
2.2 Characteristics of AI problems.
1. INTRODUCTION TO AI
1.1 AI DEFINITIONS
- It’s a branch of computer science that deals with the automation of intelligent
behavior. It includes the data structures used in the knowledge representation,
the algorithms needed to apply that knowledge and the languages and
programming techniques used in their implementation.
i.e. the main goal of AI is to build intelligent systems that are capable
of performing tasks in an efficient and effective way.
APPLICATION AREAS:
AI includes area such as robotics, commonsense reasoning, learning
models etc.
1.2 AI HISTORY
AI began to emerge as a new field in the early 1940s and 1950s.AI
emerged as a new science from the following fields.
MATHEMATIC PHILOSOPH
PSYCHOLOG AI LINGUISTICS
COMPUTER
YEAR WORKS
5th Aristotle invented the first formal deductive reasoning system
century
17th Descartes proposed that bodies of animals are nothing more than
century complex machines.
17th Pascal created the first mechanical digital calculating machine
century
19th George Boole developed a binary algebra representing some laws of
century thought.
19th Charles Babbage worked on programmable mechanical calculating
century machines.
1943 McCulloch & Pitts: Boolean circuit model of brain
1950 A.M .Turing performed the Turing test as a way of operationalizing a test
of intelligent behavior.
1950 Emerged systems for automatic theorem proving and natural language
processing.
1957 Newell and Simon demonstrated the general problem solver architecture.
1961-65 A.L.Samuel developed a system to play checkers game.
1965 First expert system DENDRAL emerged
1968 Developed MACSYMA, a large interactive program which solves
numerous types of mathematical problems.
1969 Roger Schank (Stanford) defined conceptual dependency model for
natural language understanding
1970 Bill Woods described ATN's as a representation for natural language
understanding.
1972 Alain Colmerauer developed PROLOG
1980 AI becomes an industry
1986 Neural networks return to popularity
1987 AI becomes a science
1995 The emergence of intelligent agents
1.3 AI TECHNIQUE
1. Define the problem precisely; this definition must include the precise
specifications of what the initial situations are as well as what final situation
constitutes acceptable solutions.
2. Analyze the problem.
3. Isolate and represent the task knowledge that is necessary to solve the problem.
4. Choose the best problem solving technique and apply it to that particular
problem.
State space representation – in this method we will be listing out all the possible solutions and search
the entire space until we reach the goal.
Eg: eight way puzzle
5 7 3 INITIAL
8 1 STATE
2 6 4
5 7 3 5 7 3 5 7 3
8 6 1 8 1 8 1
2 4 2 6 4 2 6 4
………………..
…………………………………………………..
1 2 3
8 4 GOAL
7 6 5 STATE
Problem reduction method – various possibilities are represented in the form of
AND-OR graphs. The arcs between the links shows the AND operation.
Buy a TV
DAY : 2
OBJECTIVES:
3. Basics of LISP
4. Understand the various list manipulation functions
KEY POINTS:
3. Basics of LISP
3.1 Features of LISP
3.2 Building blocks of LISP: Atom
List
String
4. List manipulation functions: car,cdr,cons,list,append,last,member,reverse.
3.BASICS OF LISP
The basic building blocks of LISP are atoms, lists and string. They are called
symbolic expressions or S-expressions.
Lisp uses prefix notations. For example(+(*(/ 9 5)50)32) will return 122.Each
function call is performed in the order in which it occurs within the parentheses.
We can also write cadadr to abbreviate the sequence car cdr car cdr.
…………………………………………………………………………………………..
DAY:3
OBJECTIVES:
5. Defining a function.
6. Getting familiarized with the various predicate functions.
KEY POINTS:
5. Defining a function.
5.1 Basic structure of function: Function name
Parameters of the function
Function body
5.2 Example problems based on functions
6. Getting familiarized with the various predicate functions:
atom,equal,oddp,venp,lessp,greaterp,numberp etc
5. DEFINING A FUNCTION
Basic syntax
(defun name (param1 param2…)
body)
Eg:
( defun avg3 (a b c)
( / (+ a b c)3))
The above defined function will find the average of three numbers .defun is
the standard keyword,avg3 is the function name ,a,b and c are the three numbers
whose average is to be find out.As LISP evaluates only prefix notations ((a+b+c)/3)
will be written like (/(+ a b c)3).
6. GETTING FAMILIARIZED WITH THE VARIOUS PREDICATE
FUNCTIONS:
Predicates are functions that test their arguments for some specific condition.
Predicates return either a true (t) or a false(nil) value depending on the arguments. The
most common predicates are listed below.
…………………………………………………………………………………………..
DAY: 4
OBJECTIVES:
7. Understand the functioning of conditional statements.
KEYPOINTS:
7. Understand the functioning of conditional statements.
7.1 Use of predicates to perform branching
7.1.1 Basic structure of the conditional cond
7.1.2 Basic structure of the conditional if…then…else
7.1.3 Examples based on the branching statements.
• The symbol cond is followed by clauses. Each clause contains a test and
zero or more forms called actions.
• cond moves through the clauses, evaluating the test forms, until a test form
evaluates to non-NIL. This clause is "triggered" and its action forms are
evaluated.
• The value returned by cond is the value of the last action form in the triggered
clause.
• If all test forms are NIL, the value returned by cond is also NIL.
• The last clause is called a T-triggered clause.
• With a T-triggered clause, the final clause is used when none of the others are
triggered.
……………………………………..
(if < test > < then form > < else form >)
(defun max2 (a b)
( cond ( ( > a b) a )
( t b) ) )
Here defun is the standard keyword to define a function,max2 is the name of the
function and a and b are the arguments of the function max2.We have to find the
maximum of two numbers so we have to check whether a is greater than b ,if it is
greater then return a otherwise return b. The letter t forces the last clause to be
evaluated when the first clause is not.
(defun max3 ( a b c)
( ( > b c) b ) ( t c) ) )
………………………………………………………………………………………
DAY: 5
OBJECTIVES:
8. List out the logical functions in LISP
9. Getting familiarized with the various I/O functions in LISP
KEYPOINTS:
8.1 NOT
Example:
setf pets '(dog cat))
DOG CAT)
not (member 'dog pets))
NIL
not (member 'tiger pets))
T
8.2 AND
Example :
(setf pets '(dog cat))
(and ( member ‘dog pets ) ( member ‘ tiger pets ))
NIL
(and (member 'dog pets) (member 'cat pets))
(CAT)
8.3 OR
• OR returns NIL if all of its arguments evaluates to NIL.
• The arguments are evaluated from left to right, if any evaluates to non-NIL, none
of the remaining is evaluated, and the value returned is that non-NIL value.
• If all arguments evaluates to NIL, the value returned by OR is NIL.
• It takes any number of arguments.
Example:
(setf pets '(dog cat))
(or (member 'dingo pets) (member 'tiger pets))
NIL
(or (member 'dog pets) (member 'cat pets))
(DOG CAT)
9.1 READ
• It takes no arguments
• When it appers in aprocedure the processing halts until an s-expression is
entered from the keyboard.
• The s-expression is returned as the value of the read.
Example:
( + 5 ( read ))
6
11
9.2 PRINT
• I t takes one argument.
• It prints the argument as it is received and then returns the argument.
Example:
(print ‘(a b c))
(A B C )
(A B C )
9.3 PRINL
• It is the same as PRINT except that the new line characters and the space are
not provided.
Example:
((prinl ‘(hello))(prinl ‘(hello)))
(HELLO)(HELLO)
9.4 PRINC
• It is same as the PRINL except that it does not print the unwanted quotation
marks.
• It will eliminate the quotes but the echo still remains.(ie it will return the
argument)
Example:
(princ “hello”)
HELLO “HELLO”
9.5 TERPRI
• It takes no arguments.
• It introduces a new line.
…………………………………………………………………………………………..
DAY: 6
OBJECTIVES:
10. List out the iteration constructs in LISP
11. Recursion in LISP
KEYPOINTS:
10. List out the iteration constructs in LISP
10.1 Repeating by Iteration - DO
10.2 Repeating by Iteration – LOOP
11.Recursion in LISP
1. A list of parameter specifications, each of which creates, sets, and resets one of
the DO form's parameters:
<body form>)
2. A body that consists of DO's subforms, which are evaluated over and over
until the DO is stopped:
Example:
( defun factorial (n)
( do (( count n( - count 1))
( product n (* product (- count 1 ))
(( equal 0 count ) product )))
• On entering the DO, the list of parameters are all bound to its corresponding
value (again, a virtual fence exists to isolate these parameters from the
variables outside DO).
The parameter specifications can include update forms. The parameters are
updated accordingly in each pass.
• The 2nd part of DO is the termination test and the result form. The test is
attempted before each pass, including the 1st one. The <result form> is
evaluated as the return value of DO only when the test succeeds.
There may be zero or more <result forms> after the <test form>. They are all
evaluated when the test succeeds. However, only the last one gives the return
value of the DO. If there is none, the return value is NIL.
(loop <body>)
The body is evaluated over and over until a (RETURN <expression>) is encountered.
Again the <expression> is evaluated as the return value of the terminated LOOP.
Many LISP procedures work by repeating a particular action over and over until a
certain condition is met. A recursive function is one which calls itself successively to
reduce a problem to a sequence of simpler steps. Recursion requires stopping
condition and recursive steps .
Example:
(defun factorial (n)
(cond (( zerop n)1)
(t ( * n (factorial (- n 1))))))
……………………………………………………………………………………….
DAY: 7
OBJECTIVES:
12. Introducing the concept of property lists in LISP
13. Using arrays in LISP
KEYPOINTS:
Example:
(putprop ‘car ‘ ford ‘ make)
FORD
(putprop ‘car ‘ red ‘ color)
RED
(putprop ‘danny ‘ pets ‘(fluffy tim penny))
(FLUFFY TIM PENNY)
Example:
(get ‘car ‘ make)
FORD
(get ‘car ‘ color)
RED
Example:
(remprop ‘car ‘ make)
FORD
(remprop ‘car ‘ color)
RED
Example:
(putprop ‘car ‘ red ‘ color)
RED
(putprop ‘car ‘ blue ‘ color)
BLUE
(get ‘car ‘ color)
BLUE
This will create an array with name myarray and the size of the array will be
10.Initially the array contents will be nil. The function make-array will return a # sign
followed by A.
To store items into the array we use the function setf and to access the contents
of the cells we use the function aref which takes two arguments the name of the array
and the index value.
Example:
(aref myarray 9)
NIL
(setf (aref myarray 9) 25)
(aref myarray 9)
25
MODULE – 2
DAY: 1
Objectives:
1. Introduction to Symbolic Logic
1. The syntax of a language describes the possible configurations that can constitute
sentences. We usually describe syntax in terms of how sentences are represented on
the printed page.
2. The semantics describe the facts in the world to which the sentences refer. Without
semantics the sentence is just an arrangement or collection of marks on a page. In
logic, the meaning of a sentence is what it states about the world.
Propositional Logic
In propositional logic, symbols represent whole propositions
(facts).Propositions are elementary atomic sentences. It can be either true of false but
may take on no other value.
Example: D: The bird is dead.
This may or may not be a true proposition. The propositions can be
combined using the Boolean connectives to generate sentences with more complex
meanings.
Properties of statements
Satisfiable:
A statement is satisfiable if there is some interpretation for which it is true.Eg: P
Contradiction:
A statement is contradictory (unsatisfiable) if there is no interpretation for which it is
true.
Eg: (P & ~ P)
Valid:
A sentence is valid if it is true for every interpretation. Valid sentences are also called
tautologies.Eg :( P V~P)
Equivalence:
Two sentences are equivalent if they have the same truth value under every
interpretation.
Eg: P and ~ (~P)
Logical consequences:
A sentence is a logical consequence of another if it is satisfied by all interpretations
which satisfy the first.Eg: P is a logical consequence of (P & Q)
Note: A valid statement is satisfiable and a contradictory statement is invalid, but the
converse is not necessarily true.
…………………………………………………………………………………………
DAY: 2
Objectives:
- First order predicate logic
- Syntax and Semantics of FOPL.
Syntax of FOPL
The symbols and rules of combination permitted in FOPL are defined as follows:
Connectives:
There are five connective symbols: ~ (not or negation),& (and or conjunction), V (or
or inclusive disjunction),→(implication),↔(equivalence or if and only if).
Quantifiers:
The two quantifier symbols are existential quantification and universal
quantification.
Universal quantification - means for all
Existential quantification - for some x or there is an x.
Constants:
They are fixed value terms that belong to a given domain of discourse. They are
denoted by numbers, words and small letters near the beginning of the alphabet such
as a,b,c,5.3,-21,flight 102 and john.
Variables:
Variables are terms that can assume different values over a given domain. They are
denoted by words and small letters near the end of the alphabet, such as aircraft –type,
individuals, x, y
and z.
Functions:
Function symbols denote relations defined on a domain D. They map n elements
(n≥0) to a single element of the domain. Symbols f, g ,h and words such as father-of
,or age-of represent functions. An n-ary function is written as f (t1,t2,t3,………,
tn)where ti are terms defined over some domain.
Predicates:
Predicate symbols denote relations or functional mapping from the elements of a
domain D to the values true or false. Capital letters and capitalized words such as P,
Q, R, EQUAL and MARRIED are used to represent predicates. Like functions
predicates can have n terms for arguments.
Objectives:
- Sample problems in FOPL
- Clausal conversion procedure
Sample problems:
Problem:1
Convert the following natural language statements to FOPL statements.
1. Marcus was a man.
2. Marcus was a Pompeian.
3. All Pompeians were Romans.
4. Caesar was a ruler.
5. All Romans were either loyal to Caesar or hated him.
6. People only tried to assassinate rulers they are not loyal to.
7. Everyone is loyal to someone.
8. Marcus tried to assassinate Caesar.
1. Man (Marcus).
2. Pompeian (Marcus)
3. x Pompeian(x)→Roman(x)
4. Ruler Caesar)
5. x Roman(x)→loyalto x ,Caesar) V hated(x ,Caesar)
6. x y People(x) Ruler(y) tryassassinate(x,y)→ ┐loyalto(x,y)
7. x y loyalto(x,y)
8. tryassassinate(Marcus,Ceasar)
Problem:2
The following are a set of natural language statements .Convert them into FOPL
statements.
1. If x is on top of y, y supports x.
2. If x is above y and then they are touching each other, x is on top of y.
3. A cup is above a book.
4. A cup is touching a book.
5. Move all universal quantifiers to the left of the expression and put the expression
on the right into CNF.
6. Eliminate all universal quantifiers and conjunctions since they are retained
implicitly. The resulting expressions and the set of such expression is said to be in
clausal form.
hate(y,z)→thinkcrazy(x,y))]
2. x y( z P (f (x),y,z)→( u Q(x,u) & vR(y,v)))
…………………………………………………………………………………………
DAY:4
Objectives:
-Resolution principle
-Resolution procedure
Resolution principle
The resolution procedure is a simple iterative process, at each step two
clauses called parent clauses are compared (resolved) yielding a new clause that has
been inferred from them.
This process is similar to the process of obtaining a proof by contradiction.
Let C1,C2,C3……….Cn)be the set of given clauses and D be the clause to be proved.
To prove that D is a logical consequence of the statements C1&C2&………Cn first
we negate the D and ~ D to the set of clauses. Then, using resolution along with
factorizing we can prove that the set is unsatisfiable by deducing a contradiction. Such
a proof is called a proof by refutation.
Resolution procedure
Sample problem
Consider the statements
1. P
2. ( P Q)→ R
3. (S V T) →Q
4. T
Prove using resolution that the statement R holds.
First convert the statements into clausal form
1. P
2. ךP V ךQ V R
3. ךS V Q
4. ךT V Q
5. T
Negate R and add it to the set of clauses
6. ךR
ךPVךQVR ךR
ךPV ךQ P
ךT VQ ךQ
ךT T
NIL
Since our assumption ends up in a contradiction its inverse is true. So R
holds.
Objectives:
-Unification algorithm
- Unification problem
Unification algorithm
Any substitution that makes two or more expressions equal is called a unifier for the
expressions. Applying a substitution to an expression E produces an instance E’ of E
where E’=Eβ.Given two expressions C1 and C2 that are unifiable,let β be the unifier
with C2=C1β.We say that β is the most general unifier(mgu).Unification can be
applied to literals within the same single clause. When an mgu exists such that two or
more literals within a clause are unified, the clause remaining after deletion of all but
one of the unified literals is called a factor of the original clause.
Algorithm:
Let S be the set of expressions.
1. Set k =0 and σk = e (the empty set).
2. If the set Sσk is a singleton then stop; σk is an mgu of S.Otherwise find the
disagreement set Dk of Sσk.
3. If there is a variable v and term t in Dk such that v does not occur in t, put
σk+1= σk{t/v},set k = k+1 ,and return to step 2 .Otherwise stop .S is not
unifiable.
Example:
1. Unify the literals P(x, x) and P (y, z)
Problems:
1. Unify the literals f(x ,x) and f(g(x),g(x)).
2. Unify the literals f (Marcus) and f(Ceasar).
3. Unify the literals f (Marcus,g(x,y)) and f(x, g(Ceasar,Marcus)).
DAY: 6
Objectives :
• Introduction to nonmonotonic systems
• Architecture of a general problem solver with TMS
Key points :
INFERENCE
ENGINE TMS
KNOWLEDGE
BASE
TMS
The main job of TMS is to maintain the consistency of the
knowledge base being used by the problem solver. It will not perform any inferencing
process. TMS also gives the inference component the latitude to perform
nonmonotonic inferences. When new discoveries are made the more recent
information is can displace previous knowledge which are no longer valid. So the set
of knowledge available to the user always remains consistent.
Inference Engine
Inference Engine solves domain problems based on the current
belief set while the TMS maintains the currently active belief set. The updating
process is incremental. After each inference information is exchanged between the
inference engine and the TMS. The IE tells the TMS what inferences it has made and
the TMS in turn asks questions about the current beliefs and the reasons for failure. It
maintains a consistent set of beliefs for the IE to work with.
P P
P→ Q P→ Q
MODUS PONENS MODUS PONENS
~P
………………………………………………………………………………………….
DAY : 7
Objectives :
• Nonmonotonic reasoning methods
Keypoints :
Nonmonotonic reasoning methods
o Default reasoning
o Closed World Assumption
o Predicate Completion
o Circumscription
1. Default Reasoning
where a(x) is a pre condition wff for the conclusion wff c(x),M is the consistency
operator and b1(x),b2(x),.......... are conditions, each of which must be separately
consistent with the KB for the conclusion c(x) to hold.
Example:
ADULT(X) : MDRIVE(X)
DRIVE(X)
Default theories consists of a set of axioms and a set of default inference rules .The
theorems derivable from a default system are those that follow from first order logic
and the assumptions assumed from default rules. Default rules are especially useful in
hierarchical KB's since default rules are transitive property inheritance becomes
possible.
Completion formulas
Completion formulas are axioms which are added to the KB to
restrict the applicability of specific predicates.If it is known that only certain objects
should satisfy the given predicates , formulas which make the KB explicit are added
to the KB .This technique also needs the addition of Unique Names
Assumptions(UNA) ie formulas which state that distinguished named entries in the
KB are unique.Once completion formulas are added to the KB ordinary first order
proof methods can be used to prove the statements.Predicate completion formulas
perform the same function as that of the CWA but with respect to the completed
predicates only.It is possible to default both positive and negative statements.
Example :
OWNS(joe , ford)
STUDENT(joe)
STUDENT(jill)
OWNS(sam , bike)
PROGRAMMER(sam)
STUDENT (mary)
If it is known that Joe is the only person who owns a ford we can make the fact
explicit by adding the completion formula.
x OWNS(x,ford)→EQUAL(x,joe)
Once we add this completion formula we have to add the inequality formula
~EQUAL(a,joe) which means that it is true for all constants a which are
different from joe.
Circumscription
It is another form of default reasoning introduced by John Mc Carthy.It
is similar to predicate completion in that all objects that can be shown to have some
property P are in fact the only objects that satisfy P.
DAY : 8
Objectives :
• Modal and temporal logics
• Fuzzy logic
Keypoints :
• Modal and temporal logics
• Fuzzy logic
o Introduction to fuzzy logic
o Fuzzy sets
o Fuzzy set theory
FUZZY LOGIC
Fuzzy Logic (FL) is a multivalued logic, that allows intermediate
values to be defined between conventional evaluations like true/false,
yes/no, high/low, etc. Notions like rather tall or very fast can be formulated
mathematically and processed by computers, in order to apply a more
human-like way of thinking in the programming of computers.Additional benefits of
fuzzy logic include its simplicity and its flexibility. Fuzzy logic can handle problems
with imprecise and incomplete data, and it can model nonlinear functions of arbitrary
complexity.Fuzzy logic models, called fuzzy inference systems, consist of a number
of conditional "if-then" rules.
FUZZY SET
A Fuzzy Set is any set that allows its members to have different grades of
membership (membership function) in the interval [0,1].
The following rules which are common in classical set theory also apply to
Fuzzy set theory.
De Morgans law
Associativity
Commutativity
Distributivity
University Questions:
hate(y,z)→thinkcrazy(x,y))]
7. Explain the principle of Fuzzy logic and explain the use of Fuzzy sets(10)
8.Why precicate caculus is said to be undecidable(5)