SlideShare a Scribd company logo
1 of 108
UNIT-5
Expert System & AI languages
Syllabus
• Need & Justification for expert systems- cognitive problems,
• Expert System Architectures,
• Rule based systems,
• Non production system,
• knowledge acquisition,
• Case studies of expert system.
• Ai language:
• Prolog syntax,
• Programming with prolog,
• backtracking in prolog,
• Lisp syntax,
• Lisp programming.
2 marks Question bank
1. Give characteristics features of expert system. 2
2. What do you mean by Inference engine? 2
3. What is expert system give any two example. 2
4. Enumerate the phases of a typical expert system life cycle. 2
7 marks Question bank
1. Discuss with neat diagram the rule based system architecture.
2. Enumerate the development of all well known expert systems in historical timeline. Discuss
what role the Knowledge acquisition plays in the design of expert systems.
3. What is the architecture of expert system? Give description of each module. 7
4. What is the role of expert system in Artificial intelligence? Explain expert system. 7
5. Explain the role of knowledge engineers in the development of expert systems. 7
6. Draw a block diagram of typical knowledge based system and describe briefly the role of
each block. 7
7. Illustrate the working of MYCIN expert system. What do you mean by explanation based
learning, explain with suitable example? 7
8. Illustrate the salient features of expert system ‘STELLA’.
9. Explain the following in concept of expert system
i. Expert system shell
ii. Knowledge acquisition
iii. Explanation based learning
iv. Turing test
v. Rote learning
10. Explain iteration and recursion in LISP. 8
11. Define and write a PROLOG program for the “Monkey-Banana Problem.” 7
12. Explain backtracking in PROLOG.
What is Expert Systems?
• Expert systems aimed to capture specialist human expertise
which was in short supply. Eg..,
– Medical expertise
– Computer configuration expertise.
– Expertise for oil exploration.
• Aim was to develop systems capturing this expertise, so the
knowledge could be deployed where experts were
unavailable. Expert system (ES) are knowledge intensive
programs that solve problems in a domain that requires
considerable amount of technical expertise.
• An Expert System (ES) is a computer-based system (mainly
software) that uses knowledge and facts, and apply an
appropriate reasoning technique (inferencing) to solve
problems in a given field (domain) that normally require the
services of human experts.
What is Expert Systems continued ……..
• Attempt to Imitate Expert Reasoning Processes and
Knowledge in Solving Specific Problems
• Most Popular Applied AI Technology
– Enhance Productivity
– Augment Work Forces
• Narrow Problem-Solving Areas or Tasks
• Provide Direct Application of Expertise
• Expert Systems Do Not Replace Experts, But They
– Make their Knowledge and Experience More Widely
Available
– Permit Non experts to Work Better
Need & Justification for expert
systems- cognitive problems
• Expert systems are suitable for knowledge intensive
problems that are typically solved by human experts.
• Because expert systems depend on human knowledge,
if human experts are unable to solve a given problem,
no successful expert system can be developed to solve
the problem either.
• When the demand for human expertise surpasses the
availability of experts, an expert system may be the
tool for handling the situation.
• The justification of using an expert system for a
selected problem depends on the primary goal of the
organization and the types of alternatives available.
Characteristics of ES
• Control: ES use knowledge rather than data to control the solution
process.
• Knowledge acquisition: The knowledge is encoded and maintained
as an entity separate from the control program. This permits the
incremental addition and modification of the knowledge base
without recompilation of the control programs. It is possible to use
different knowledge base with the same control programs to
produce different types of ES. Such systems are known as Expert
System Shells.
• Symbolic representation: ES use symbolic representations for
knowledge (Rules, networks, frames) and perform their inference
through symbolic computations that closely resemble manipulations
of natural language.
Characteristics of ES continued….
• High performance: The response at a level of competency
equal to or better than an expert
• Adequate response time: Perform in a reasonable time,
comparable to or better than Human Expert’s time
• Good reliability: Must be reliable and not prone to crashes
or else it will not be used
• Understandable: Have an explanation capability . ES are
capable of explaining how a particular conclusion was
reached, and why requested information is needed during
consultation.
• Flexibility: Important to have an efficient mechanism for
adding, changing, and deleting knowledge
Brief history
Early 1960
1. AI research was dominated by a believe that:
 a few laws of reasoning + powerful computers = expert or
 even superhuman performance
2. General-purpose Problem Solver (GPS):
 A procedure developed by Newell & Simon, includes:
 A set of operators
 Preconditions
 Postconditions
 Heuristic for operators to try first
 Tries to work out the steps needed to change a certain
initial situation into a desired goal
3. On this time, concentration is on problem-solving
mechanism
Brief history
Mid-1960s
1. There were special types of AI program to successfully deal
with complex problem in a narrow domain:
– Dendral (E. Feigenbaum, Standford Univ.)
– MYCIN
2. General purpose to special-purpose programs
3. Recognized that the problem-solving mechanism is only a
small part of a complete intelligent computer system
Brief history
Mid-1970s
1. Several ES had begun to emerge
2. “Knowledge” become target of study
3. Development of knowledge representation theories
4. Key insight:
– The power of an ES is derived from the specific
knowledge it posses, not from the particular formalisms
and inference schemes it employs
Brief history
Beginning of the 1980s
1. Commercial applications were built, such as:
– XCON & XSEL (at DEC)
– CATS-1 (at General Electric)
2. Effort to develop tools for speeding up the construction of
ES, such as:
– EMYCIN
– AGE
Brief history
1983
– Some tools become commercially available
– Most of the early development tools required special
hardware, e.g. LISP machine
Late 1980s
– Development software can run on regular computers
including microcomputers
Now
– ES is used in many fields
Basic Concept of ES
• Knowledge Engineering – The discipline of acquiring,
encoding and using human domain knowledge to develop a
computer application
• Expert System – A computer program that uses domain
knowledge to perform a specific task usually human experts
perform
• Knowledge Base – a set of rules and facts describing the
domain of an application
• Inference Engine – a program that imposes a general control
strategy on how the system is working
• Working memory – a set of facts describing a particular
consultation
Basic Concept of ES
• Expertise: Enable experts to make better and faster decisions
than non-experts in solving complex problem
• Experts: Degrees or levels of expertise -> mimic human
expert
• Transferring expertise: Involves 4 activities -> knowledge
acquisition, knowledge representation, knowledge inference
and knowledge transfer to user
• Inference rules: Ability to reason-> component called the
inference engine
• Rules: Problem solving procedure -> knowledge stored at
database
• Explanation capability: Ability to explain its advice or
recommendations -> components/subsystem called justifier or
explanation subsystem
Designing ES
The process of building ES is called Knowledge
Engineering, consist of three stages :
i. Knowledge acquisition : the process of getting the
knowledge from experts
ii. Knowledge representation : selecting the most
appropriate structures to represent the knowledge
iii. Knowledge validation :testing that the knowledge of
ES is correct and complete
Architecture of Expert System
The fundamental modules of an Expert System are :
1. Knowledge base
2. User Interface
3. Inference engine
4. Explanation Facility
5. Knowledge Acquisition Facility
6. External Interface
Architecture of
Expert System
1. Knowledge Base
• It is the core module of any expert system. It is the warehouse of the domain-
specific knowledge captured from the expert via the knowledge acquisition
module. The knowledge base contains the knowledge necessary for
understanding, formulating, and solving problems.
• Two Basic Knowledge Base Elements
– Facts
– Special heuristics, or rules that direct the use of knowledge
– Knowledge is the primary raw material of ES
– Incorporated knowledge representation
Using the Knowledge Base
Inputs
Computer
Outputs
Knowledge
Base
Inference
Capability
2. User Interface
• User interface provides the needed facilities for the user to
communicates with the system.
• An user, normally would like to have a consultation with the
system for the following aspects:
– To get remedies for his problem.
– To know the private knowledge of the system.
– To get some explanations for specific queries.
3. Inference Engine
• It is also called as rule interpreter or interpreter engine(IE),
perform the task of maintaining antecedents from the
responses given by the user and firing rules.
• Firing of a rule causes two major things to happen:
– Triggers another rule, thereby a network of rules is
triggered.
– Implies that an action has been carried out. This adds new
action to the database of inferred facts.
• Major task of the IE is to trace its way through a forest of
rules to conclusion.
• Basically there are two approaches i.e. forward chaining and
backward chaining.
4. Explanation facility
• The explanation module provides the user with an explanation
of the reasoning process when requested. This is done in
response to a how query or a why query.
• To respond to a how query, the explanation module traces the
chain of rules fired during consultation with the user. The
sequence of rules that led to the conclusion is then printed for
the user in an easy to understand human language style.
• This permits the user to actually see the reasoning process
followed by the system in arriving at the conclusion. If the
user does not agree with the reasoning steps presented, they
my be changed using the editor.
5. Knowledge Acquisition facility
• Knowledge acquisition is the accumulation, transfer and
transformation of problem-solving expertise from experts and/or
documented knowledge sources to a computer program for
constructing or expanding the knowledge base
• Requires a knowledge engineer
6. External interface
• This provides the communication link between the ES and the
external environment.
Expert System Shells
• An Expert system shell is a software
development environment.
• It contains the basic components of expert
systems.
• A shell is associated with a prescribed method
for building applications by configuring and
instantiating these components.
Expert System Shells
Shell components
1. knowledge acquisition,
2. knowledge Base,
3. reasoning,
4. explanation and
5. user interface
Knowledge acquisition
• A subsystem to help experts in build
knowledge bases.
• However, collecting knowledge, needed to
solve problems and build the knowledge base,
is the biggest bottleneck in building expert
systems.
Knowledge Base
• A store of factual and heuristic knowledge.
Expert system tool provides one or more
knowledge representation schemes for
expressing knowledge about the application
domain.
• Some tools use both Frames (objects) and IF-
THEN rules.
• In PROLOG the knowledge is represented as
logical statements.
Reasoning Engine
• Inference mechanisms for manipulating the
symbolic information and knowledge in the
knowledge base form a line of reasoning in
solving a problem.
• The inference mechanism can range from
simple modus ponens backward chaining of
IF-THEN rules to Case-Based reasoning.
Explanation
• A subsystem that explains the system's
actions.
• The explanation can range from how the final
or intermediate solutions were arrived at
justifying the need for additional data.
User interface
• A means of communication with the user. The
user interface is generally not a part of the
expert system technology.
• It was not given much attention in the past.
• However, the user interface can make a critical
difference in the perceived utility of an Expert
system.
Rule based system architecture
• The most common form of architecture used in expert and other types of knowledge
based system is the production system, also called the rule-based system.
• This type of system uses knowledge encoded in the form of production rules, that
is, if ….then rules.
• Each rule represents a small chunk of knowledge relating to the given domain of
expertise. A number of related rules collectively may correspond to a chain of
inferences which lead from some initially known facts to some useful conclusions.
• When the known facts support the conditions in the rule’s left side, the conclusion
or action part of the rule is then accepted as known.
• Inference in the production systems is accomplished by a process of chaining
through the rules recursively, either in a forward or backward direction, until a
conclusion is reached or until failure occurs. The selection of rules used in the
chaining process is determined by matching current facts against the domain
knowledge or variables in rules and choosing among a candidate set of rules the
ones that meet some given criteria, such as specificity.
• The inference process is typically carried out in an interactive mode with the user
providing input parameters needed to complete the rule chaining process.
Rule based system architecture
Expert System Components And Human
Interfaces
• Expert systems have a number of major
system components and interface with
individuals who interact with the system in
various roles.
Components and Interfaces
i. Knowledge base : A declarative representation
of the expertise; often in IF THEN rules ;
ii. Working storage : The data which is specific to
a problem being solved;
iii. Inference engine : The code at the core of the
system which derives recommendations from
the knowledge base and problem-specific data
in working storage;
iv. User interface : The code that controls the
dialog between the user and the system.
Component of expert system
Roles of Individuals who interact
with the system
Domain expert : another active player in the development process.
Transfers the entire knowledge about the domain to the system.
Also identifies and plugs loop holes in the system. Totally
committed for the development of the system right from the
beginning.
Knowledge engineer : An active player in the development team.
Associated with the identification phase until the implementation
of the full system. Involved in the development of the inference
engine, structure of the knowledge base and user interface if a
programming language is chosen. Helps in choosing a tool for
development by explaining the features of it to the expert. In some
systems, plays a role in eliciting the initial knowledge about the
domain and permits the expert to upgrade it.
User : a very passive element in the development process, specifies
the overall problem for which expert system is needed. Plays a
small role in problem identification and comes into picture when
the system is fully developed and implemented.
Knowledge Acquisition
• Knowledge acquisition includes the elicitation, collection,
analysis, modeling and validation of knowledge.
• A knowledge engineer interviews a domain expert to elucidate
expert knowledge, which is then translated into rules. After the
initial system is built, it must be iteratively refined until it
approximates expert level performance.
• This process is expensive and time consuming, so it is worth while
to look for more automatic ways of constructing expert knowledge
bases.
• While no totally automatic knowledge acquisition systems yet exist,
there are many programs that interact with domain experts to extract
expert knowledge efficiently. These programs provide support for
the following activities
– Entering knowledge
– Maintaining knowledge base consistency
– Ensuring knowledge base completeness
Issues in Knowledge Acquisition
i. knowledge is in the head of experts
ii. Experts have vast amounts of knowledge
iii. Experts have a lot of tacit knowledge
a. They do not know all that they know and use
b. Tacit knowledge is hard (impossible) to describe
iv. Experts are very busy and valuable people
v. One expert does not know everything
vi. Knowledge has a "shelf life"
Techniques for Knowledge Acquisition
The techniques for acquiring, analyzing and
modeling knowledge are :
i. Protocol-generation techniques,
ii. Protocol analysis techniques,
iii. Hierarchy-generation techniques,
iv. Matrix-based techniques,
v. Sorting techniques,
vi. Limited-information and constrained-processing
tasks,
vii. Diagram-based techniques
Protocol-generation techniques
• Include many types of interviews (unstructured, semi-
structured and structured), reporting and observational
techniques.
Protocol analysis techniques
• Used with transcripts of interviews or text-based information
to identify basic knowledge objects within a protocol, such as
goals, decisions, relationships and attributes.
• These act as a bridge between the use of protocol-based
techniques and knowledge modeling techniques.
Hierarchy-generation techniques
• Involve creation, reviewing and modification of hierarchical
knowledge.
• Hierarchy-generation techniques, such as laddering, are used
to build taxonomies or other hierarchical structures such as
goal trees and decision networks.
• The Ladders are of various forms like concept ladder, attribute
ladder, composition ladders.
Matrix-based techniques
• Involve the construction and filling-in a 2-D
matrix (grid, table), indicating such things, as
may be, for example, between concepts and
properties (attributes and values) or between
problems and solutions or between tasks and
resources, etc.
• The elements within the matrix can contain:
symbols (ticks, crosses, question marks ) ,
colors , numbers , text.
Sorting techniques
• Used for capturing the way people compare
and order concepts; it may reveal knowledge
about classes, properties and priorities.
Limited-information and constrained-
processing tasks
• Techniques that either limit the time and/or information
available to the expert when performing tasks.
• For example, a twenty-questions technique provides an
efficient way of accessing the key information in a domain in
a prioritized order.
Diagram-based techniques
• Include generation and use of concept maps, state transition
networks, event diagrams and process maps.
• These are particularly important in capturing the "what, how,
when, who and why" of tasks and events.
Knowledge Acquisition stages
• Knowledge acquisition has five stages throughout the
development. The stages are as following:
Identification
• This stage identifies the problems and the knowledge engineer
becomes aware of the domain, its goals and selects the correct
material.
Conceptualization
• This defines how the concepts or ideas and the associations
between them are outlined and how experts relate them.
Formalization
• Here the knowledge engineer organizes the concepts, tasks and
other information into formal and clear representation.
Knowledge Acquisition stages
Implementation
• Here the knowledge rules are put into a structured form for
the expert system tool and a prototype (trial model) is
created for testing out the design and the processes. The
knowledge engineer has to produce a written documentation
that will connect the knowledge base topics with the
original data that were created earlier.
Testing
• The prototype system is tested for its efficiency and
accuracy to see if it is working as required. In order to do
this a small scenario or problem set is tested and the results
from this system are used to alter or improve the prototype
system.
Life cycle of the expert system
There are five major stages in the development of
an expert system.
1. Identification of the problem
2. Decision about the mode of development
3. Development of a prototype
4. Planning for a full scale system
5. Final implementation, maintenance and
evolution
Life cycle of the expert system
Identification of the problem
• In this stage, the expert and the knowledge engineer interact to
identify the problem.
• The major points discussed before for the characteristics of the
problem are studied.
• The scope and the extent are pondered.
• The amount of resources needed, e.g. men, computing
resources, finance etc. are identified. The return of investment
analysis is done.
• Areas in the problem which can give much trouble are
identified and a conceptual solution for that problem and the
overall specification is made.
Decision about the mode of development
• Once the problem is identified, the immediate
step would be to decide on the vehicle for
development.
• This knowledge engineer can develop the system
from scratch using a programming language like
PROLOG and LISP or any conventional language
or adopt a shell for development,
• In this stage, various shells and tools are
identified and analyzed for the suitability.
• Those tools whose features fit the characteristics
of the problem are analyzed in detail.
Development of a prototype
Before developing a prototype, the following are the prerequisite activities:
• Decide on what concepts are needed to produce the solution. One
important factor to be decided here is the level of knowledge. Starting
with coarse granularity, the system development proceeds towards fine
granularity.
• After this, the task of knowledge acquisition begins. The knowledge
engineer and the domain expert interact frequently and the domain
specific knowledge is extracted.
• Once the knowledge is acquired, the knowledge engineer decides on the
method of representation. In the identification phase, a conceptual
picture of knowledge representation would have emerged. In this stage,
that view is either enforced or modified.
• When the knowledge representation scheme and the knowledge is
available, a prototype is constructed. This prototype undergoes the
process of testing for various problems and revision of the prototype takes
place. By this process, knowledge of fine granularity emerges and this is
effectively coded in the knowledge base.
Planning for a full scale system
• The success of the prototype provides the needs
inputs for the full scale system.
• In prototype construction, the area in the
problem which can be implemented with relative
ease is first chosen.
• In the full scale implementation, sub system
development is assigned a group leader and
schedules are drawn.
• Use of Gantt chart, PERT or CPM techniques are
welcome.
Final implementation, maintenance
and evolution
• This is the final life cycle stage of an expert system.
• The full scale system developed is implemented at the site. The
basic resource requirements at the site are fulfilled and parallel
conversion and testing techniques are adopted. The final system
undergoes rigorous testing and later handed over to the user.
• Maintenance of the system implies tuning of the knowledge base
because knowledge, the environment and types of problems that
arrive are never static. The historical database has to be maintained
and the minor modifications made on inference engine has to be
kept off. Maintenance engulf security also.
• Evaluation is difficult task for any AI programs. As mentioned
previously, solutions for AI problems are only satisfactory. Since the
yardstick for evaluation is not available, it is difficult to evaluate.
However, utmost what one can do is to supply set of problems to
the system and a human expert and compare the results.
Case Studies: MYCIN
MYCIN
• MYCIN is an expert system used for diagnosing
bacterial infections. The major characteristics
of medical domain is the uncertain and
imprecise data coupled with vast quantities of
medical knowledge.
• MYCIN was developed at Stanford University
to help physicians in identifying what bacteria
has been the cause for the infection and to
suggest remedial solutions.
MYCIN: knowledge base
• MYCIN’s “knowledge base” organized as set of production
rules. One distinguishing features of the production rule in
MYCIN is the certainty factor associated with it. Herewith, we ,
give a sample production rule in LISP and also the English
equivalent. Sample MYCIN rule
(internal representation)
PREMISE : ($AND (SAME CNTXT GRAM GRAMNEG)
(SAME CNTXT MORPH ROD)
(SAME CNTXT AIR ANAEROBIC)
ACTION : (CONCLUDE CNTXT IDENTITY BACTERIODES TALLY .6)
MYCIN: knowledge base
English representation
IF the infection is primary-bacteremia
AND the site of the culture is one of the sterile sites
AND the suspected portal of entry is the gastrointestinal tract
THEN there is suggestive evidence (0.7) that infection is bacteroid.
Apart from the production rule, the system has a collection of facts. Facts are
stored in the form
CONTEXT-PARAMETER-VALUE OR
OBJECT-AT TRIBUTE-VALUE TRIPLES
The OBJECT also called CONTEXT refers to such things as cultures taken
from the patient, the drugs administered and so on. These OBJECTS are
characterized by their ATTRIBTE or PARAMETER and the value of these
are stored in VALUE. Associated with each triple is a certainty factor
between -1 and +1. A CF of +1 indicates total belief, while a CF of -1
indicates total disbelief.
Ex: (IDENTITY ORGANISM -1 PSEUDOMONAS 0.8)
Which means “Pseudomonas is the identity of the organism-1 with certainty
0.8”.
MYCIN: Reasoning and Problem
Solving Strategy
• MYCIN could use backward chaining to find out whether a
possible bacteria was to blame.
• This was augmented with “certainty factors” that allowed an
assessment of the likelihood, if no one bacteria was certain.
• MYCIN’s problem solving strategy was simple:
– For each possible bacteria:
• Using backward chaining, try to prove that it is the
case, finding the certainty.
– Find a treatment which “covers” all the bacteria above
some level of certainty.
MYCIN: Problem Solving
• When trying to prove a goal through backward chaining,
system could ask user certain things.
– Certain facts are marked as “askable”, so if they
couldn’t be proved, ask the user.
• This results in following style of dialogue:
• MYCIN: Has the patient had neurosurgery?
USER: No.
MYCIN: Is the patient a burn patient?
USER: No.
…
MYCIN: Problem Solving
• As of today, many extensions to the MYCIN
approach have emerged. In order to minimize the
human intervention in knowledge acquisition
facility, a system called TEIRESIAS has been
developed. Through TEIRESIAS, the expert can
directly communicate with the knowledge base.
• Another system, called GUIDON has also been
developed that uses the explanation capability of
MYCIN for instructional purposes. MYCIN, as n
expert system has surpassed human physicians in
their reasoning capabilities.
LISt Processing : LISP
Introduction
• LISP was invented by John McCarthy during the late 1950s.
• It is particulary suited for AI programs becausee of its ability to
process symbolic information effectively.
• Basic building blocks of LISP are the Atom, List, and the String.
• An Atom is a number or string of contiguous characters, including
numbers and spectial characters.
• A List is sequence of atoms and/or other lists enclosed within
parentheses.
• A String is a group of characters enclosed in double.
Example of Atoms
Valid Invalid
this-is-a-symbolic abcd‘f
bill (a b)
1000234 123b
block (abc
a12345 ab cde
Example of List
Valid Invalid
(this is a list) this is not a list
(a (a b) c def) (a b) (c d
(father sam (joe bill sue)) a,b,c
(1 2 4) ((a b)(
( ) )a b c(
Example of String
Valid Invalid
“this is string“ This is not a string
“b a c $“ Bac
Numeric operation on LISP
• LISP uses prefix notations.
• Example : 5 + 6 should write (+ 5 6)
Numeric Operations
Function call Value
returned
Remarks
(+ 3 5 8 4) 20 + takes zero or more
arguments.
(- 10 12) -2 - Takes two arguments
(* 2 3 4) 24 * takes zero or more
arguments.
(/ 25 2) 12.5 / takes two arguments
Basic List manipulation functions
Function Call Value Returned Remarks
(setq x 10) 10 The number 10 evaluates to itself and bound
to x and 10 is returned
(car ‘(a b c)) a Car takes one argument, a list, and returns
the first element.
(cdr ‘(a b c)) (b c) Cdr takes one argument, a list and returns a
list with the first element removed.
(cons ‘a ‘(b c)) (a b c) Cons takes two arguments, an element, and
a list and returns a list with the element
insertedd at the begining
(list ‘a ‘(b c)) (a (b c)) List take any number of arguments and
returns a list with the arguments as elements.
Additional List Manipulation Function
Function Call Value Returned Remarks
(append ‘(a) ‘( b c)) (a b c) Merge two or more lists into a single
list.
(last ‘(a b c d)) d Returns a list containing the last
element.
(memeber ‘b ‘(a b d)) (b d) Returns remainder of second argument
list starting with element matching first
argument.
(reverse (‘a (b c) d)) (d (b c) a) Return list with top elements in reverse
order.
Defining Functions
• The format of function defination
– (defun name (parm1 parm2...) body).
• Example
– (defun averagethree(n1 n2 n3)
(/ (+ n1 n2 n3) 3))
• Calling
– (averagethree 10 20 30)
– 20
More example
• Sum of two numbers
– (defun sum(n1 n2)
(+ n1 n2))
• Area of circle
– (defun area(r)
(*(* r r) 3.14))
Predicate functions
• Predicates are functions that test their arguments for some specific
condition. It returns true(t) or false (nil), depending on the arguments.
• Common predicates are
– atom
– equal
– evenp
– greaterp
– <= and >=
– lessp
– listp
– null
– numberp
– Oddp
– zerop
Predicate Calls
Function Value return Remarks
(atom ‘aabb) T Aabb is valid atom
(equal ‘a (car ‘(a b)) T A equal a, but note that (equal 1 1.0)
returns nil
(evenp 3) Nil 3 is not a even number
(numberp 10ab) Nil 10ab is not a number
(oddp 3) T 3 is a odd number
(zerop .000000001) Nil Argument is not zero
(greaterp 2 4 12) t Arguments are succedingly larges from
left to right
(lessp 5 3 12) Nil Arguments are not successively smaller
(listp ‘(a)) T (a) is a valid list
(null nil) T Nil is empty list
Contional Cond
• Cond is like the if... Then...else construct
• The syntax for cond is
• (cond (<test1> <action1>)
(<test2> <action2>)
(<test3> <action3>)
» .
» .
» .
(<testk> <actionk>))
Example
Example 1:
(defun maximum2( a b )
(cond ((> a b) a)
( t b)
Example 2:
(defun maximum3( a b c )
(cond ((> a b) (cond ((> a c) a)
( t c)))
((> b c) b)
(t c)))
Input and output
– read :- it takes no aruments. When read appears in a
procedure, processing halts until a single expression is
entered from the keyboard.
Example: (+ 5 (read))
» 6
» 11
– print :- it takes two arugments. It prints the arugment
as it is received, and then returns the argument.
Example: print(‘(a b c))
(a b c)
(a b c)
Input and output
– Prinl: it is same as print except the new line character and
space are not provided.
Example: ((prin1 ‘(hello)) (prin1 ‘(hello)))
(hello) (hello)
– Princ: princ is just like prin1 except that the output has no
escape character.
– Terpri: It outputs a newline to output-stream.
Example
• ( defun circle-area()
(terpri)
(princ “Please enter the radius :“)
(setq radius (read))
(princ “The area of the circle is:“)
(princ(* 3.1416 (radius radius))
(terpri))
Circle-area
Please enter the radius :4
The area of the circle is: 50.2656
Format
• Format function permits us to creat cleaner output than is possible
with just the basic printing functions.
• ~ to identify it as a directive.
• The form of format is:
– (format <destination> <string> arg1 arg2....)
• ~ 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
• ~C The argument is printed as character output.
• ~%: A new line is printed
• Example
– (format t “Circle radius = ~2F% Circle area = ~3F“ radius area)
Iteration constructs
• Loop can be used in LISP
• Do statement has the form:
• (do (<var1 val1> <var-update1>)
(<var2 val2> <var-update 2>)
.
(<test> <return value>)
(<s-expression>))
Example:
• (defun factorial(n)
(do ((count n (- count 1))
(product n (* product (- count 1))
((equal 0 count) product)))
Recursion
• For any problems, recursion is the natural method of
solution.
• A recursion function is one which calls itself successively
to reduce a problem to a sequence of simpler steps.
• Recursion requires a stopping condition and a recursive
step.
Example:
(defun factorial (n)
(cond ((zerop n) 1)
(t (* n (factorial (- n 1)))))
Property List
• LISP provides facility to define the property of any atom.
• putprop is used for this purpose.
• putprop takes three arguments : an atom, a property name,
property
• Example:
– (putprop ‘car ‘ford ‘make)
– (putprop ‘car 2010 ‘year)
– (putprop ‘car ‘red‘color)
• Get function is used to retrieve a property value such as the
color of car:
• Example
– (get ‘car ‘color)
– (get ‘car ‘make)
– (get ‘car ‘year)
Array in LISP
• Array can be defined by using make-array function.
– Example
o(setf myarray (make-array (’10)))
 Contents of cells can be accessed by aref function.
– Example
o(aref myarray 9)
 To store item in the array we use the function setf
– Example
o(setf (aref myarray 0) 25)
Exercise
1. Write a program in LISP to implement manipulation function in LISP (setq,
car, last, cons, append, reverse, etc.).
2. Write a program in LISP to find greatest among three number using defun.
3. Write a program in LISP to convert Centigrade to Fahrenheit.
4. Define function to caculate area of circle.
5. Write a LISP program to solve the quadratic equation.
6. Write a LISP program to find whether the given number is even or odd.
7. Write a LISP program to calculate factorial.
8. Write a LISP program to find nth term of fibonacci series.
9. Write a LISP program for property.
10.Write a LISP program for Simple Intrest.
Introduction to Prolog
What is Prolog?
● Prolog is acronym of PROgramming in LOGic.
● Prolog program is sequence of rules and facts.
● Prolog Rule for grandfather is defined as:
father(james, robert).
gfather(X, Y) :- father(X, Z), parent(Z, Y).
Glimpse of Prolog Program
/* Rules: “X is grand father of Y if X is father of Z who is parent of Y */
gfather(X, Y) :- father(X, Z), parent(Z, Y). (1)
parent(X, Y) :- father(X, Y). (2)
parent(X, Y) :- mother(X, Y). (3)
/*Facts “James is father of robert” */
father(james, robert). (4)
father(mike, william). (5)
father(william, james). (6)
father(robert, hency). (7)
father(robert, cris). (8)
/* Goals ‘ Is abraham a grand father of mike?’*/
?- gfather(abraham, mike).
?- gfather(X, Y).
?- father(X, Y), father(Y, mike).
Back
General Syntax of Prolog
● The rules and facts in Prolog are terminated by full stop (.).
● Goal can be included in the program or given at the prompt.
● Goal can be single or conjunction of sub-goal(s) terminated by full stop.
● Constants are numerals and symbols such as, 4, mary, etc.
● String is a sequence of characters and is enclosed within single quotes
e.g., 'This is a string'.
● Predicate names must start with alphabet and are formed by using
lower case letters, numerals and underscore ( _ ).
● Variable names are formed similar to predicate names but it must start
with upper case letter. Normally, we use X, Y, Z, ... for variables.
Prolog Control Strategy
● Prolog contains three basic control
strategies.
− Forward movement
− Matching (Unification)
− Backward movement (Backtracking)
● Prolog uses depth first search strategy.
Forward Movement
● Choose a rule by
− searching sequentially in the program from top to bottom
whose head matches with the goal with possible unifier.
− Remember the position of the matched rule.
− Join the rule body in front of the sequence of sub goals to
be solved.
● Repeat until either goal is satisfied or is failed.
Forward Movement – Cont…
● Consider the following query consisting of n sub-goals.
?- G1, ... , Gi-1, Gi, ... , Gn
● Starts executing or satisfying G1
− If G1 is satisfied using some rule, put a place marker so that
next rule for G1 will be searched after the marker.
− Continue in forward direction to satisfy G2 and if it is satisfied
then continue with common bindings of the variables in sub-
goals so far satisfied.
− Such a movement is called forward
Unification
● Unification is a process of matching or finding the most
general unifier.
− Constant matches with the same constant.
− A variable can match with any constant or any another variable.
● Examples
− love(X, sita) unifies with love(ram, sita) with mgu as {X / ram}.
− love(X, Y) unify with love(ram, sita) with mgu as {X / ram, Y
/ sita} respectively.
Monkey banana problem
• We envision a room containing a monkey, a chair, and
some bananas that have been hung from the center of the
ceiling, out of reach form the monkey. If the monkey is
clever enough , he can reach the bananas by placing the
chair directly below them and climbing on top of the
chair.
Classical Monkey Banana problem
• /*Solve the classical Monkey Banana problem of AI. */
predicates
nondeterm inroom(symbol)
nondeterm canmove(symbol,symbol)
nondeterm canclimb(symbol,symbol)
nondeterm below(symbol,symbol)
nondeterm canreach(symbol,symbol)
nondeterm clever(symbol)
Classical Monkey Banana problem
clauses
inroom(monkey).
inroom(chair).
inroom(banana).
canmove(monkey,chair).
below(chair,banana).
canclimb(monkey,chair).
canreach(M,B):-
inroom(M),inroom(C),inroom(B),canmove(M,C),below(C,B),canc
limb(M,C).
clever(M):- canreach(M,B).
goal
clever(monkey).
Backtracking
● Backtracking refers to backtrack in search
process for a solution.
● In Prolog, backtracking takes place in two
situations.
− First when a sub goal fails and
− Other when the last sub goal succeeds, it backtracks to
find alternative solutions.
Types of backtracking
● Prolog has two kinds of backtracking.
− Shallow and
− Deep backtracking
● Both backtrackings take place in conjunction with each
other.
● Shallow backtracking occurs
− when alternative definition of the goal is tried.
− Suppose G1,.., Gi-1 have been satisfied with some
common bindings of the variables in sub-goals.
− While satisfying Gi., if it fails for some rule then try
another rule of Gi
− This is called shallow backtracking to rules of the same
sub-goal
Backtracking Cont…
● Deep backtracking occurs
− When sub-goal Gi fails for all rules of Gi then backtrack to Gi-1.
− This backtracking is called deep backtracking.
− Remove the bindings created earlier to satisfy Gi-1.
− Try to satisfy Gi-1 again by using an alternative rule, if it exists,
from last place marker of Gi-1. and continue the process.
− If sub goal Gi-1 is satisfied then move forward to Gi, else
backtrack to Gi-2.
− The process of backtracking continues till we reach G1.
− If G1 fails for all possible definitions, then entire query fails.
Backtracking Cont…
● If entire conjunction of sub-goals succeed, then the
solution is displayed.
● For alternative solution, the sub goal Gn is tried to be
satisfied with alternative rule, if it exist, after last place
marker (Shallow backtracking) of Gn .
● Otherwise it backtracks to previous sub goal Gn-1 (Deep
backtracking).
● Process is repeated till all possible solutions are
generated.
Conflict-Resolution
• In Prolog , if two or more rules having matching
clauses, they are tried one at a time until an
answer is reached.
• But because of recursion and the depth first
approach , the second clause would only be tried
after he first clause led to a failure.
• So if clause 1 and 2 matched, we try clause 1,
assume it leads to clauses 3, 4,5 6 matching, each
of which is tried and fails, we only try clause 2
after all that.
Conflict resolution strategies
• Specificity - If all of the conditions of two or more rules are
satisfied, choose the rule with the most specific conditions. (e.g. "it
is hot and smokey" rather than "it is hot"). Also referred to as
"degree of specialization".
• Recency - Facts are usually tagged to show how recently they were
added. When two or more rules could be chosen, favor the one that
matches the most recently added facts. This helps to utilize the
most recently relevant facts.
• Refractorizenes - If a rule's conditions are satisfied, but previously
the same rule has been satisfied by the same facts, ignore the rule.
This helps to avoid the system from entering infinite loops.
• Order - Pick the first applicable rule in order of presentation. This is
the type of strategy that Prolog uses and is one of the most
common ones.

More Related Content

What's hot

Knowledge representation In Artificial Intelligence
Knowledge representation In Artificial IntelligenceKnowledge representation In Artificial Intelligence
Knowledge representation In Artificial IntelligenceRamla Sheikh
 
Artificial Intelligence Searching Techniques
Artificial Intelligence Searching TechniquesArtificial Intelligence Searching Techniques
Artificial Intelligence Searching TechniquesDr. C.V. Suresh Babu
 
knowledge representation using rules
knowledge representation using rulesknowledge representation using rules
knowledge representation using rulesHarini Balamurugan
 
Control Strategies in AI
Control Strategies in AI Control Strategies in AI
Control Strategies in AI Bharat Bhushan
 
Knowledge representation and reasoning
Knowledge representation and reasoningKnowledge representation and reasoning
Knowledge representation and reasoningMaryam Maleki
 
Problem reduction AND OR GRAPH & AO* algorithm.ppt
Problem reduction AND OR GRAPH & AO* algorithm.pptProblem reduction AND OR GRAPH & AO* algorithm.ppt
Problem reduction AND OR GRAPH & AO* algorithm.pptarunsingh660
 
Production system in ai
Production system in aiProduction system in ai
Production system in aisabin kafle
 
Analytical learning
Analytical learningAnalytical learning
Analytical learningswapnac12
 
Problem solving agents
Problem solving agentsProblem solving agents
Problem solving agentsMegha Sharma
 

What's hot (20)

Knowledge representation In Artificial Intelligence
Knowledge representation In Artificial IntelligenceKnowledge representation In Artificial Intelligence
Knowledge representation In Artificial Intelligence
 
AI Lecture 3 (solving problems by searching)
AI Lecture 3 (solving problems by searching)AI Lecture 3 (solving problems by searching)
AI Lecture 3 (solving problems by searching)
 
Artificial Intelligence Searching Techniques
Artificial Intelligence Searching TechniquesArtificial Intelligence Searching Techniques
Artificial Intelligence Searching Techniques
 
Truth management system
Truth  management systemTruth  management system
Truth management system
 
knowledge representation using rules
knowledge representation using rulesknowledge representation using rules
knowledge representation using rules
 
Forward Backward Chaining
Forward Backward ChainingForward Backward Chaining
Forward Backward Chaining
 
Control Strategies in AI
Control Strategies in AI Control Strategies in AI
Control Strategies in AI
 
Knowledge representation and reasoning
Knowledge representation and reasoningKnowledge representation and reasoning
Knowledge representation and reasoning
 
Fuzzy expert system
Fuzzy expert systemFuzzy expert system
Fuzzy expert system
 
Rule based system
Rule based systemRule based system
Rule based system
 
Planning
Planning Planning
Planning
 
Unit8: Uncertainty in AI
Unit8: Uncertainty in AIUnit8: Uncertainty in AI
Unit8: Uncertainty in AI
 
search strategies in artificial intelligence
search strategies in artificial intelligencesearch strategies in artificial intelligence
search strategies in artificial intelligence
 
Sensor Cloud
Sensor CloudSensor Cloud
Sensor Cloud
 
Problem reduction AND OR GRAPH & AO* algorithm.ppt
Problem reduction AND OR GRAPH & AO* algorithm.pptProblem reduction AND OR GRAPH & AO* algorithm.ppt
Problem reduction AND OR GRAPH & AO* algorithm.ppt
 
Learning in AI
Learning in AILearning in AI
Learning in AI
 
Production system in ai
Production system in aiProduction system in ai
Production system in ai
 
Analytical learning
Analytical learningAnalytical learning
Analytical learning
 
Lecture 6 expert systems
Lecture 6   expert systemsLecture 6   expert systems
Lecture 6 expert systems
 
Problem solving agents
Problem solving agentsProblem solving agents
Problem solving agents
 

Similar to Artificial Intelligence Notes Unit 5

Expert System Development.pptx
Expert System Development.pptxExpert System Development.pptx
Expert System Development.pptxvrajESHsHaH33
 
1_Expertsystems.ppt
1_Expertsystems.ppt1_Expertsystems.ppt
1_Expertsystems.pptRISHI643981
 
LESSON 8 EXPERT SYSTEMS BASICS.ppt
LESSON 8 EXPERT SYSTEMS BASICS.pptLESSON 8 EXPERT SYSTEMS BASICS.ppt
LESSON 8 EXPERT SYSTEMS BASICS.pptJoyleenChemutai1
 
ai-ruba.pptx presentation artificial intelligence
ai-ruba.pptx presentation artificial intelligenceai-ruba.pptx presentation artificial intelligence
ai-ruba.pptx presentation artificial intelligenceChellamuthuHaripriya
 
BI UNIT V CHAPTER 12 Artificial Intelligence and Expert System.pptx
BI UNIT V CHAPTER 12   Artificial Intelligence and Expert System.pptxBI UNIT V CHAPTER 12   Artificial Intelligence and Expert System.pptx
BI UNIT V CHAPTER 12 Artificial Intelligence and Expert System.pptxTGCbsahil
 
A presentation on Expert System
A presentation on Expert SystemA presentation on Expert System
A presentation on Expert SystemVanga Naresh
 
Expert system 21 sldes
Expert system 21 sldesExpert system 21 sldes
Expert system 21 sldesYasir Khan
 
AI_Module_4_lecture_1.pptx
AI_Module_4_lecture_1.pptxAI_Module_4_lecture_1.pptx
AI_Module_4_lecture_1.pptxadityab33
 
Knowledge based systems
Knowledge based systemsKnowledge based systems
Knowledge based systemsYowan Rdotexe
 
expert system.pptx
expert system.pptxexpert system.pptx
expert system.pptxhoneydv1979
 
Lec 4 expert systems
Lec 4  expert systemsLec 4  expert systems
Lec 4 expert systemsEyob Sisay
 
Expert systems from rk
Expert systems from rkExpert systems from rk
Expert systems from rkramaslide
 

Similar to Artificial Intelligence Notes Unit 5 (20)

Expert System Development.pptx
Expert System Development.pptxExpert System Development.pptx
Expert System Development.pptx
 
Lecture_8.ppt
Lecture_8.pptLecture_8.ppt
Lecture_8.ppt
 
Sh ch01
Sh ch01Sh ch01
Sh ch01
 
1_Expertsystems.ppt
1_Expertsystems.ppt1_Expertsystems.ppt
1_Expertsystems.ppt
 
LESSON 8 EXPERT SYSTEMS BASICS.ppt
LESSON 8 EXPERT SYSTEMS BASICS.pptLESSON 8 EXPERT SYSTEMS BASICS.ppt
LESSON 8 EXPERT SYSTEMS BASICS.ppt
 
Expert system
Expert system Expert system
Expert system
 
Expert systems
Expert systemsExpert systems
Expert systems
 
ai-ruba.pptx presentation artificial intelligence
ai-ruba.pptx presentation artificial intelligenceai-ruba.pptx presentation artificial intelligence
ai-ruba.pptx presentation artificial intelligence
 
BI UNIT V CHAPTER 12 Artificial Intelligence and Expert System.pptx
BI UNIT V CHAPTER 12   Artificial Intelligence and Expert System.pptxBI UNIT V CHAPTER 12   Artificial Intelligence and Expert System.pptx
BI UNIT V CHAPTER 12 Artificial Intelligence and Expert System.pptx
 
5 ai lecture-05 expert system
5  ai lecture-05 expert system5  ai lecture-05 expert system
5 ai lecture-05 expert system
 
Ai lecture 05 expert system
Ai lecture 05 expert systemAi lecture 05 expert system
Ai lecture 05 expert system
 
A presentation on Expert System
A presentation on Expert SystemA presentation on Expert System
A presentation on Expert System
 
Expert system 21 sldes
Expert system 21 sldesExpert system 21 sldes
Expert system 21 sldes
 
Expert systems
Expert systemsExpert systems
Expert systems
 
AI_Module_4_lecture_1.pptx
AI_Module_4_lecture_1.pptxAI_Module_4_lecture_1.pptx
AI_Module_4_lecture_1.pptx
 
Unit 4(nlp _neural_network)
Unit 4(nlp _neural_network)Unit 4(nlp _neural_network)
Unit 4(nlp _neural_network)
 
Knowledge based systems
Knowledge based systemsKnowledge based systems
Knowledge based systems
 
expert system.pptx
expert system.pptxexpert system.pptx
expert system.pptx
 
Lec 4 expert systems
Lec 4  expert systemsLec 4  expert systems
Lec 4 expert systems
 
Expert systems from rk
Expert systems from rkExpert systems from rk
Expert systems from rk
 

More from DigiGurukul

Dempster Shafer Theory AI CSE 8th Sem
Dempster Shafer Theory AI CSE 8th SemDempster Shafer Theory AI CSE 8th Sem
Dempster Shafer Theory AI CSE 8th SemDigiGurukul
 
Fuzzy logic Notes AI CSE 8th Sem
Fuzzy logic Notes AI CSE 8th SemFuzzy logic Notes AI CSE 8th Sem
Fuzzy logic Notes AI CSE 8th SemDigiGurukul
 
Artificial Intelligence Notes Unit 4
Artificial Intelligence Notes Unit 4Artificial Intelligence Notes Unit 4
Artificial Intelligence Notes Unit 4DigiGurukul
 
Artificial Intelligence Notes Unit 3
Artificial Intelligence Notes Unit 3Artificial Intelligence Notes Unit 3
Artificial Intelligence Notes Unit 3DigiGurukul
 
Enterprise Resource Planning(ERP) Unit – v
Enterprise Resource Planning(ERP) Unit – vEnterprise Resource Planning(ERP) Unit – v
Enterprise Resource Planning(ERP) Unit – vDigiGurukul
 
Enterprise Resource Planning(ERP) Unit – i
Enterprise Resource Planning(ERP) Unit – iEnterprise Resource Planning(ERP) Unit – i
Enterprise Resource Planning(ERP) Unit – iDigiGurukul
 
Enterprise Resource Planning(ERP) Unit – iii
Enterprise Resource Planning(ERP) Unit – iiiEnterprise Resource Planning(ERP) Unit – iii
Enterprise Resource Planning(ERP) Unit – iiiDigiGurukul
 
Enterprise Resource Planning(ERP) Unit – ii
Enterprise Resource Planning(ERP) Unit – iiEnterprise Resource Planning(ERP) Unit – ii
Enterprise Resource Planning(ERP) Unit – iiDigiGurukul
 
Enterprise Resource Planning(ERP) Unit – iv
Enterprise Resource Planning(ERP) Unit – ivEnterprise Resource Planning(ERP) Unit – iv
Enterprise Resource Planning(ERP) Unit – ivDigiGurukul
 

More from DigiGurukul (9)

Dempster Shafer Theory AI CSE 8th Sem
Dempster Shafer Theory AI CSE 8th SemDempster Shafer Theory AI CSE 8th Sem
Dempster Shafer Theory AI CSE 8th Sem
 
Fuzzy logic Notes AI CSE 8th Sem
Fuzzy logic Notes AI CSE 8th SemFuzzy logic Notes AI CSE 8th Sem
Fuzzy logic Notes AI CSE 8th Sem
 
Artificial Intelligence Notes Unit 4
Artificial Intelligence Notes Unit 4Artificial Intelligence Notes Unit 4
Artificial Intelligence Notes Unit 4
 
Artificial Intelligence Notes Unit 3
Artificial Intelligence Notes Unit 3Artificial Intelligence Notes Unit 3
Artificial Intelligence Notes Unit 3
 
Enterprise Resource Planning(ERP) Unit – v
Enterprise Resource Planning(ERP) Unit – vEnterprise Resource Planning(ERP) Unit – v
Enterprise Resource Planning(ERP) Unit – v
 
Enterprise Resource Planning(ERP) Unit – i
Enterprise Resource Planning(ERP) Unit – iEnterprise Resource Planning(ERP) Unit – i
Enterprise Resource Planning(ERP) Unit – i
 
Enterprise Resource Planning(ERP) Unit – iii
Enterprise Resource Planning(ERP) Unit – iiiEnterprise Resource Planning(ERP) Unit – iii
Enterprise Resource Planning(ERP) Unit – iii
 
Enterprise Resource Planning(ERP) Unit – ii
Enterprise Resource Planning(ERP) Unit – iiEnterprise Resource Planning(ERP) Unit – ii
Enterprise Resource Planning(ERP) Unit – ii
 
Enterprise Resource Planning(ERP) Unit – iv
Enterprise Resource Planning(ERP) Unit – ivEnterprise Resource Planning(ERP) Unit – iv
Enterprise Resource Planning(ERP) Unit – iv
 

Recently uploaded

Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 

Recently uploaded (20)

Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 

Artificial Intelligence Notes Unit 5

  • 1. UNIT-5 Expert System & AI languages
  • 2. Syllabus • Need & Justification for expert systems- cognitive problems, • Expert System Architectures, • Rule based systems, • Non production system, • knowledge acquisition, • Case studies of expert system. • Ai language: • Prolog syntax, • Programming with prolog, • backtracking in prolog, • Lisp syntax, • Lisp programming.
  • 3. 2 marks Question bank 1. Give characteristics features of expert system. 2 2. What do you mean by Inference engine? 2 3. What is expert system give any two example. 2 4. Enumerate the phases of a typical expert system life cycle. 2
  • 4. 7 marks Question bank 1. Discuss with neat diagram the rule based system architecture. 2. Enumerate the development of all well known expert systems in historical timeline. Discuss what role the Knowledge acquisition plays in the design of expert systems. 3. What is the architecture of expert system? Give description of each module. 7 4. What is the role of expert system in Artificial intelligence? Explain expert system. 7 5. Explain the role of knowledge engineers in the development of expert systems. 7 6. Draw a block diagram of typical knowledge based system and describe briefly the role of each block. 7 7. Illustrate the working of MYCIN expert system. What do you mean by explanation based learning, explain with suitable example? 7 8. Illustrate the salient features of expert system ‘STELLA’. 9. Explain the following in concept of expert system i. Expert system shell ii. Knowledge acquisition iii. Explanation based learning iv. Turing test v. Rote learning 10. Explain iteration and recursion in LISP. 8 11. Define and write a PROLOG program for the “Monkey-Banana Problem.” 7 12. Explain backtracking in PROLOG.
  • 5. What is Expert Systems? • Expert systems aimed to capture specialist human expertise which was in short supply. Eg.., – Medical expertise – Computer configuration expertise. – Expertise for oil exploration. • Aim was to develop systems capturing this expertise, so the knowledge could be deployed where experts were unavailable. Expert system (ES) are knowledge intensive programs that solve problems in a domain that requires considerable amount of technical expertise. • An Expert System (ES) is a computer-based system (mainly software) that uses knowledge and facts, and apply an appropriate reasoning technique (inferencing) to solve problems in a given field (domain) that normally require the services of human experts.
  • 6. What is Expert Systems continued …….. • Attempt to Imitate Expert Reasoning Processes and Knowledge in Solving Specific Problems • Most Popular Applied AI Technology – Enhance Productivity – Augment Work Forces • Narrow Problem-Solving Areas or Tasks • Provide Direct Application of Expertise • Expert Systems Do Not Replace Experts, But They – Make their Knowledge and Experience More Widely Available – Permit Non experts to Work Better
  • 7. Need & Justification for expert systems- cognitive problems • Expert systems are suitable for knowledge intensive problems that are typically solved by human experts. • Because expert systems depend on human knowledge, if human experts are unable to solve a given problem, no successful expert system can be developed to solve the problem either. • When the demand for human expertise surpasses the availability of experts, an expert system may be the tool for handling the situation. • The justification of using an expert system for a selected problem depends on the primary goal of the organization and the types of alternatives available.
  • 8.
  • 9. Characteristics of ES • Control: ES use knowledge rather than data to control the solution process. • Knowledge acquisition: The knowledge is encoded and maintained as an entity separate from the control program. This permits the incremental addition and modification of the knowledge base without recompilation of the control programs. It is possible to use different knowledge base with the same control programs to produce different types of ES. Such systems are known as Expert System Shells. • Symbolic representation: ES use symbolic representations for knowledge (Rules, networks, frames) and perform their inference through symbolic computations that closely resemble manipulations of natural language.
  • 10. Characteristics of ES continued…. • High performance: The response at a level of competency equal to or better than an expert • Adequate response time: Perform in a reasonable time, comparable to or better than Human Expert’s time • Good reliability: Must be reliable and not prone to crashes or else it will not be used • Understandable: Have an explanation capability . ES are capable of explaining how a particular conclusion was reached, and why requested information is needed during consultation. • Flexibility: Important to have an efficient mechanism for adding, changing, and deleting knowledge
  • 11. Brief history Early 1960 1. AI research was dominated by a believe that:  a few laws of reasoning + powerful computers = expert or  even superhuman performance 2. General-purpose Problem Solver (GPS):  A procedure developed by Newell & Simon, includes:  A set of operators  Preconditions  Postconditions  Heuristic for operators to try first  Tries to work out the steps needed to change a certain initial situation into a desired goal 3. On this time, concentration is on problem-solving mechanism
  • 12. Brief history Mid-1960s 1. There were special types of AI program to successfully deal with complex problem in a narrow domain: – Dendral (E. Feigenbaum, Standford Univ.) – MYCIN 2. General purpose to special-purpose programs 3. Recognized that the problem-solving mechanism is only a small part of a complete intelligent computer system
  • 13. Brief history Mid-1970s 1. Several ES had begun to emerge 2. “Knowledge” become target of study 3. Development of knowledge representation theories 4. Key insight: – The power of an ES is derived from the specific knowledge it posses, not from the particular formalisms and inference schemes it employs
  • 14. Brief history Beginning of the 1980s 1. Commercial applications were built, such as: – XCON & XSEL (at DEC) – CATS-1 (at General Electric) 2. Effort to develop tools for speeding up the construction of ES, such as: – EMYCIN – AGE
  • 15. Brief history 1983 – Some tools become commercially available – Most of the early development tools required special hardware, e.g. LISP machine Late 1980s – Development software can run on regular computers including microcomputers Now – ES is used in many fields
  • 16. Basic Concept of ES • Knowledge Engineering – The discipline of acquiring, encoding and using human domain knowledge to develop a computer application • Expert System – A computer program that uses domain knowledge to perform a specific task usually human experts perform • Knowledge Base – a set of rules and facts describing the domain of an application • Inference Engine – a program that imposes a general control strategy on how the system is working • Working memory – a set of facts describing a particular consultation
  • 17. Basic Concept of ES • Expertise: Enable experts to make better and faster decisions than non-experts in solving complex problem • Experts: Degrees or levels of expertise -> mimic human expert • Transferring expertise: Involves 4 activities -> knowledge acquisition, knowledge representation, knowledge inference and knowledge transfer to user • Inference rules: Ability to reason-> component called the inference engine • Rules: Problem solving procedure -> knowledge stored at database • Explanation capability: Ability to explain its advice or recommendations -> components/subsystem called justifier or explanation subsystem
  • 18. Designing ES The process of building ES is called Knowledge Engineering, consist of three stages : i. Knowledge acquisition : the process of getting the knowledge from experts ii. Knowledge representation : selecting the most appropriate structures to represent the knowledge iii. Knowledge validation :testing that the knowledge of ES is correct and complete
  • 19. Architecture of Expert System The fundamental modules of an Expert System are : 1. Knowledge base 2. User Interface 3. Inference engine 4. Explanation Facility 5. Knowledge Acquisition Facility 6. External Interface
  • 21. 1. Knowledge Base • It is the core module of any expert system. It is the warehouse of the domain- specific knowledge captured from the expert via the knowledge acquisition module. The knowledge base contains the knowledge necessary for understanding, formulating, and solving problems. • Two Basic Knowledge Base Elements – Facts – Special heuristics, or rules that direct the use of knowledge – Knowledge is the primary raw material of ES – Incorporated knowledge representation
  • 22. Using the Knowledge Base Inputs Computer Outputs Knowledge Base Inference Capability
  • 23. 2. User Interface • User interface provides the needed facilities for the user to communicates with the system. • An user, normally would like to have a consultation with the system for the following aspects: – To get remedies for his problem. – To know the private knowledge of the system. – To get some explanations for specific queries.
  • 24. 3. Inference Engine • It is also called as rule interpreter or interpreter engine(IE), perform the task of maintaining antecedents from the responses given by the user and firing rules. • Firing of a rule causes two major things to happen: – Triggers another rule, thereby a network of rules is triggered. – Implies that an action has been carried out. This adds new action to the database of inferred facts. • Major task of the IE is to trace its way through a forest of rules to conclusion. • Basically there are two approaches i.e. forward chaining and backward chaining.
  • 25. 4. Explanation facility • The explanation module provides the user with an explanation of the reasoning process when requested. This is done in response to a how query or a why query. • To respond to a how query, the explanation module traces the chain of rules fired during consultation with the user. The sequence of rules that led to the conclusion is then printed for the user in an easy to understand human language style. • This permits the user to actually see the reasoning process followed by the system in arriving at the conclusion. If the user does not agree with the reasoning steps presented, they my be changed using the editor.
  • 26. 5. Knowledge Acquisition facility • Knowledge acquisition is the accumulation, transfer and transformation of problem-solving expertise from experts and/or documented knowledge sources to a computer program for constructing or expanding the knowledge base • Requires a knowledge engineer
  • 27. 6. External interface • This provides the communication link between the ES and the external environment.
  • 28. Expert System Shells • An Expert system shell is a software development environment. • It contains the basic components of expert systems. • A shell is associated with a prescribed method for building applications by configuring and instantiating these components.
  • 30. Shell components 1. knowledge acquisition, 2. knowledge Base, 3. reasoning, 4. explanation and 5. user interface
  • 31. Knowledge acquisition • A subsystem to help experts in build knowledge bases. • However, collecting knowledge, needed to solve problems and build the knowledge base, is the biggest bottleneck in building expert systems.
  • 32. Knowledge Base • A store of factual and heuristic knowledge. Expert system tool provides one or more knowledge representation schemes for expressing knowledge about the application domain. • Some tools use both Frames (objects) and IF- THEN rules. • In PROLOG the knowledge is represented as logical statements.
  • 33. Reasoning Engine • Inference mechanisms for manipulating the symbolic information and knowledge in the knowledge base form a line of reasoning in solving a problem. • The inference mechanism can range from simple modus ponens backward chaining of IF-THEN rules to Case-Based reasoning.
  • 34. Explanation • A subsystem that explains the system's actions. • The explanation can range from how the final or intermediate solutions were arrived at justifying the need for additional data.
  • 35. User interface • A means of communication with the user. The user interface is generally not a part of the expert system technology. • It was not given much attention in the past. • However, the user interface can make a critical difference in the perceived utility of an Expert system.
  • 36. Rule based system architecture • The most common form of architecture used in expert and other types of knowledge based system is the production system, also called the rule-based system. • This type of system uses knowledge encoded in the form of production rules, that is, if ….then rules. • Each rule represents a small chunk of knowledge relating to the given domain of expertise. A number of related rules collectively may correspond to a chain of inferences which lead from some initially known facts to some useful conclusions. • When the known facts support the conditions in the rule’s left side, the conclusion or action part of the rule is then accepted as known. • Inference in the production systems is accomplished by a process of chaining through the rules recursively, either in a forward or backward direction, until a conclusion is reached or until failure occurs. The selection of rules used in the chaining process is determined by matching current facts against the domain knowledge or variables in rules and choosing among a candidate set of rules the ones that meet some given criteria, such as specificity. • The inference process is typically carried out in an interactive mode with the user providing input parameters needed to complete the rule chaining process.
  • 37. Rule based system architecture
  • 38. Expert System Components And Human Interfaces • Expert systems have a number of major system components and interface with individuals who interact with the system in various roles.
  • 39. Components and Interfaces i. Knowledge base : A declarative representation of the expertise; often in IF THEN rules ; ii. Working storage : The data which is specific to a problem being solved; iii. Inference engine : The code at the core of the system which derives recommendations from the knowledge base and problem-specific data in working storage; iv. User interface : The code that controls the dialog between the user and the system.
  • 41. Roles of Individuals who interact with the system Domain expert : another active player in the development process. Transfers the entire knowledge about the domain to the system. Also identifies and plugs loop holes in the system. Totally committed for the development of the system right from the beginning. Knowledge engineer : An active player in the development team. Associated with the identification phase until the implementation of the full system. Involved in the development of the inference engine, structure of the knowledge base and user interface if a programming language is chosen. Helps in choosing a tool for development by explaining the features of it to the expert. In some systems, plays a role in eliciting the initial knowledge about the domain and permits the expert to upgrade it. User : a very passive element in the development process, specifies the overall problem for which expert system is needed. Plays a small role in problem identification and comes into picture when the system is fully developed and implemented.
  • 42. Knowledge Acquisition • Knowledge acquisition includes the elicitation, collection, analysis, modeling and validation of knowledge. • A knowledge engineer interviews a domain expert to elucidate expert knowledge, which is then translated into rules. After the initial system is built, it must be iteratively refined until it approximates expert level performance. • This process is expensive and time consuming, so it is worth while to look for more automatic ways of constructing expert knowledge bases. • While no totally automatic knowledge acquisition systems yet exist, there are many programs that interact with domain experts to extract expert knowledge efficiently. These programs provide support for the following activities – Entering knowledge – Maintaining knowledge base consistency – Ensuring knowledge base completeness
  • 43. Issues in Knowledge Acquisition i. knowledge is in the head of experts ii. Experts have vast amounts of knowledge iii. Experts have a lot of tacit knowledge a. They do not know all that they know and use b. Tacit knowledge is hard (impossible) to describe iv. Experts are very busy and valuable people v. One expert does not know everything vi. Knowledge has a "shelf life"
  • 44. Techniques for Knowledge Acquisition The techniques for acquiring, analyzing and modeling knowledge are : i. Protocol-generation techniques, ii. Protocol analysis techniques, iii. Hierarchy-generation techniques, iv. Matrix-based techniques, v. Sorting techniques, vi. Limited-information and constrained-processing tasks, vii. Diagram-based techniques
  • 45. Protocol-generation techniques • Include many types of interviews (unstructured, semi- structured and structured), reporting and observational techniques.
  • 46. Protocol analysis techniques • Used with transcripts of interviews or text-based information to identify basic knowledge objects within a protocol, such as goals, decisions, relationships and attributes. • These act as a bridge between the use of protocol-based techniques and knowledge modeling techniques.
  • 47. Hierarchy-generation techniques • Involve creation, reviewing and modification of hierarchical knowledge. • Hierarchy-generation techniques, such as laddering, are used to build taxonomies or other hierarchical structures such as goal trees and decision networks. • The Ladders are of various forms like concept ladder, attribute ladder, composition ladders.
  • 48. Matrix-based techniques • Involve the construction and filling-in a 2-D matrix (grid, table), indicating such things, as may be, for example, between concepts and properties (attributes and values) or between problems and solutions or between tasks and resources, etc. • The elements within the matrix can contain: symbols (ticks, crosses, question marks ) , colors , numbers , text.
  • 49. Sorting techniques • Used for capturing the way people compare and order concepts; it may reveal knowledge about classes, properties and priorities.
  • 50. Limited-information and constrained- processing tasks • Techniques that either limit the time and/or information available to the expert when performing tasks. • For example, a twenty-questions technique provides an efficient way of accessing the key information in a domain in a prioritized order.
  • 51. Diagram-based techniques • Include generation and use of concept maps, state transition networks, event diagrams and process maps. • These are particularly important in capturing the "what, how, when, who and why" of tasks and events.
  • 52. Knowledge Acquisition stages • Knowledge acquisition has five stages throughout the development. The stages are as following: Identification • This stage identifies the problems and the knowledge engineer becomes aware of the domain, its goals and selects the correct material. Conceptualization • This defines how the concepts or ideas and the associations between them are outlined and how experts relate them. Formalization • Here the knowledge engineer organizes the concepts, tasks and other information into formal and clear representation.
  • 53. Knowledge Acquisition stages Implementation • Here the knowledge rules are put into a structured form for the expert system tool and a prototype (trial model) is created for testing out the design and the processes. The knowledge engineer has to produce a written documentation that will connect the knowledge base topics with the original data that were created earlier. Testing • The prototype system is tested for its efficiency and accuracy to see if it is working as required. In order to do this a small scenario or problem set is tested and the results from this system are used to alter or improve the prototype system.
  • 54. Life cycle of the expert system There are five major stages in the development of an expert system. 1. Identification of the problem 2. Decision about the mode of development 3. Development of a prototype 4. Planning for a full scale system 5. Final implementation, maintenance and evolution
  • 55. Life cycle of the expert system
  • 56. Identification of the problem • In this stage, the expert and the knowledge engineer interact to identify the problem. • The major points discussed before for the characteristics of the problem are studied. • The scope and the extent are pondered. • The amount of resources needed, e.g. men, computing resources, finance etc. are identified. The return of investment analysis is done. • Areas in the problem which can give much trouble are identified and a conceptual solution for that problem and the overall specification is made.
  • 57. Decision about the mode of development • Once the problem is identified, the immediate step would be to decide on the vehicle for development. • This knowledge engineer can develop the system from scratch using a programming language like PROLOG and LISP or any conventional language or adopt a shell for development, • In this stage, various shells and tools are identified and analyzed for the suitability. • Those tools whose features fit the characteristics of the problem are analyzed in detail.
  • 58. Development of a prototype Before developing a prototype, the following are the prerequisite activities: • Decide on what concepts are needed to produce the solution. One important factor to be decided here is the level of knowledge. Starting with coarse granularity, the system development proceeds towards fine granularity. • After this, the task of knowledge acquisition begins. The knowledge engineer and the domain expert interact frequently and the domain specific knowledge is extracted. • Once the knowledge is acquired, the knowledge engineer decides on the method of representation. In the identification phase, a conceptual picture of knowledge representation would have emerged. In this stage, that view is either enforced or modified. • When the knowledge representation scheme and the knowledge is available, a prototype is constructed. This prototype undergoes the process of testing for various problems and revision of the prototype takes place. By this process, knowledge of fine granularity emerges and this is effectively coded in the knowledge base.
  • 59. Planning for a full scale system • The success of the prototype provides the needs inputs for the full scale system. • In prototype construction, the area in the problem which can be implemented with relative ease is first chosen. • In the full scale implementation, sub system development is assigned a group leader and schedules are drawn. • Use of Gantt chart, PERT or CPM techniques are welcome.
  • 60. Final implementation, maintenance and evolution • This is the final life cycle stage of an expert system. • The full scale system developed is implemented at the site. The basic resource requirements at the site are fulfilled and parallel conversion and testing techniques are adopted. The final system undergoes rigorous testing and later handed over to the user. • Maintenance of the system implies tuning of the knowledge base because knowledge, the environment and types of problems that arrive are never static. The historical database has to be maintained and the minor modifications made on inference engine has to be kept off. Maintenance engulf security also. • Evaluation is difficult task for any AI programs. As mentioned previously, solutions for AI problems are only satisfactory. Since the yardstick for evaluation is not available, it is difficult to evaluate. However, utmost what one can do is to supply set of problems to the system and a human expert and compare the results.
  • 62. MYCIN • MYCIN is an expert system used for diagnosing bacterial infections. The major characteristics of medical domain is the uncertain and imprecise data coupled with vast quantities of medical knowledge. • MYCIN was developed at Stanford University to help physicians in identifying what bacteria has been the cause for the infection and to suggest remedial solutions.
  • 63. MYCIN: knowledge base • MYCIN’s “knowledge base” organized as set of production rules. One distinguishing features of the production rule in MYCIN is the certainty factor associated with it. Herewith, we , give a sample production rule in LISP and also the English equivalent. Sample MYCIN rule (internal representation) PREMISE : ($AND (SAME CNTXT GRAM GRAMNEG) (SAME CNTXT MORPH ROD) (SAME CNTXT AIR ANAEROBIC) ACTION : (CONCLUDE CNTXT IDENTITY BACTERIODES TALLY .6)
  • 64. MYCIN: knowledge base English representation IF the infection is primary-bacteremia AND the site of the culture is one of the sterile sites AND the suspected portal of entry is the gastrointestinal tract THEN there is suggestive evidence (0.7) that infection is bacteroid. Apart from the production rule, the system has a collection of facts. Facts are stored in the form CONTEXT-PARAMETER-VALUE OR OBJECT-AT TRIBUTE-VALUE TRIPLES The OBJECT also called CONTEXT refers to such things as cultures taken from the patient, the drugs administered and so on. These OBJECTS are characterized by their ATTRIBTE or PARAMETER and the value of these are stored in VALUE. Associated with each triple is a certainty factor between -1 and +1. A CF of +1 indicates total belief, while a CF of -1 indicates total disbelief. Ex: (IDENTITY ORGANISM -1 PSEUDOMONAS 0.8) Which means “Pseudomonas is the identity of the organism-1 with certainty 0.8”.
  • 65. MYCIN: Reasoning and Problem Solving Strategy • MYCIN could use backward chaining to find out whether a possible bacteria was to blame. • This was augmented with “certainty factors” that allowed an assessment of the likelihood, if no one bacteria was certain. • MYCIN’s problem solving strategy was simple: – For each possible bacteria: • Using backward chaining, try to prove that it is the case, finding the certainty. – Find a treatment which “covers” all the bacteria above some level of certainty.
  • 66. MYCIN: Problem Solving • When trying to prove a goal through backward chaining, system could ask user certain things. – Certain facts are marked as “askable”, so if they couldn’t be proved, ask the user. • This results in following style of dialogue: • MYCIN: Has the patient had neurosurgery? USER: No. MYCIN: Is the patient a burn patient? USER: No. …
  • 67. MYCIN: Problem Solving • As of today, many extensions to the MYCIN approach have emerged. In order to minimize the human intervention in knowledge acquisition facility, a system called TEIRESIAS has been developed. Through TEIRESIAS, the expert can directly communicate with the knowledge base. • Another system, called GUIDON has also been developed that uses the explanation capability of MYCIN for instructional purposes. MYCIN, as n expert system has surpassed human physicians in their reasoning capabilities.
  • 69. Introduction • LISP was invented by John McCarthy during the late 1950s. • It is particulary suited for AI programs becausee of its ability to process symbolic information effectively. • Basic building blocks of LISP are the Atom, List, and the String. • An Atom is a number or string of contiguous characters, including numbers and spectial characters. • A List is sequence of atoms and/or other lists enclosed within parentheses. • A String is a group of characters enclosed in double.
  • 70. Example of Atoms Valid Invalid this-is-a-symbolic abcd‘f bill (a b) 1000234 123b block (abc a12345 ab cde
  • 71. Example of List Valid Invalid (this is a list) this is not a list (a (a b) c def) (a b) (c d (father sam (joe bill sue)) a,b,c (1 2 4) ((a b)( ( ) )a b c(
  • 72. Example of String Valid Invalid “this is string“ This is not a string “b a c $“ Bac
  • 73. Numeric operation on LISP • LISP uses prefix notations. • Example : 5 + 6 should write (+ 5 6)
  • 74. Numeric Operations Function call Value returned Remarks (+ 3 5 8 4) 20 + takes zero or more arguments. (- 10 12) -2 - Takes two arguments (* 2 3 4) 24 * takes zero or more arguments. (/ 25 2) 12.5 / takes two arguments
  • 75. Basic List manipulation functions Function Call Value Returned Remarks (setq x 10) 10 The number 10 evaluates to itself and bound to x and 10 is returned (car ‘(a b c)) a Car takes one argument, a list, and returns the first element. (cdr ‘(a b c)) (b c) Cdr takes one argument, a list and returns a list with the first element removed. (cons ‘a ‘(b c)) (a b c) Cons takes two arguments, an element, and a list and returns a list with the element insertedd at the begining (list ‘a ‘(b c)) (a (b c)) List take any number of arguments and returns a list with the arguments as elements.
  • 76. Additional List Manipulation Function Function Call Value Returned Remarks (append ‘(a) ‘( b c)) (a b c) Merge two or more lists into a single list. (last ‘(a b c d)) d Returns a list containing the last element. (memeber ‘b ‘(a b d)) (b d) Returns remainder of second argument list starting with element matching first argument. (reverse (‘a (b c) d)) (d (b c) a) Return list with top elements in reverse order.
  • 77. Defining Functions • The format of function defination – (defun name (parm1 parm2...) body). • Example – (defun averagethree(n1 n2 n3) (/ (+ n1 n2 n3) 3)) • Calling – (averagethree 10 20 30) – 20
  • 78. More example • Sum of two numbers – (defun sum(n1 n2) (+ n1 n2)) • Area of circle – (defun area(r) (*(* r r) 3.14))
  • 79. Predicate functions • Predicates are functions that test their arguments for some specific condition. It returns true(t) or false (nil), depending on the arguments. • Common predicates are – atom – equal – evenp – greaterp – <= and >= – lessp – listp – null – numberp – Oddp – zerop
  • 80. Predicate Calls Function Value return Remarks (atom ‘aabb) T Aabb is valid atom (equal ‘a (car ‘(a b)) T A equal a, but note that (equal 1 1.0) returns nil (evenp 3) Nil 3 is not a even number (numberp 10ab) Nil 10ab is not a number (oddp 3) T 3 is a odd number (zerop .000000001) Nil Argument is not zero (greaterp 2 4 12) t Arguments are succedingly larges from left to right (lessp 5 3 12) Nil Arguments are not successively smaller (listp ‘(a)) T (a) is a valid list (null nil) T Nil is empty list
  • 81. Contional Cond • Cond is like the if... Then...else construct • The syntax for cond is • (cond (<test1> <action1>) (<test2> <action2>) (<test3> <action3>) » . » . » . (<testk> <actionk>))
  • 82. Example Example 1: (defun maximum2( a b ) (cond ((> a b) a) ( t b) Example 2: (defun maximum3( a b c ) (cond ((> a b) (cond ((> a c) a) ( t c))) ((> b c) b) (t c)))
  • 83. Input and output – read :- it takes no aruments. When read appears in a procedure, processing halts until a single expression is entered from the keyboard. Example: (+ 5 (read)) » 6 » 11 – print :- it takes two arugments. It prints the arugment as it is received, and then returns the argument. Example: print(‘(a b c)) (a b c) (a b c)
  • 84. Input and output – Prinl: it is same as print except the new line character and space are not provided. Example: ((prin1 ‘(hello)) (prin1 ‘(hello))) (hello) (hello) – Princ: princ is just like prin1 except that the output has no escape character. – Terpri: It outputs a newline to output-stream.
  • 85. Example • ( defun circle-area() (terpri) (princ “Please enter the radius :“) (setq radius (read)) (princ “The area of the circle is:“) (princ(* 3.1416 (radius radius)) (terpri)) Circle-area Please enter the radius :4 The area of the circle is: 50.2656
  • 86. Format • Format function permits us to creat cleaner output than is possible with just the basic printing functions. • ~ to identify it as a directive. • The form of format is: – (format <destination> <string> arg1 arg2....) • ~ 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 • ~C The argument is printed as character output. • ~%: A new line is printed • Example – (format t “Circle radius = ~2F% Circle area = ~3F“ radius area)
  • 87. Iteration constructs • Loop can be used in LISP • Do statement has the form: • (do (<var1 val1> <var-update1>) (<var2 val2> <var-update 2>) . (<test> <return value>) (<s-expression>)) Example: • (defun factorial(n) (do ((count n (- count 1)) (product n (* product (- count 1)) ((equal 0 count) product)))
  • 88. Recursion • For any problems, recursion is the natural method of solution. • A recursion function is one which calls itself successively to reduce a problem to a sequence of simpler steps. • Recursion requires a stopping condition and a recursive step. Example: (defun factorial (n) (cond ((zerop n) 1) (t (* n (factorial (- n 1)))))
  • 89. Property List • LISP provides facility to define the property of any atom. • putprop is used for this purpose. • putprop takes three arguments : an atom, a property name, property • Example: – (putprop ‘car ‘ford ‘make) – (putprop ‘car 2010 ‘year) – (putprop ‘car ‘red‘color) • Get function is used to retrieve a property value such as the color of car: • Example – (get ‘car ‘color) – (get ‘car ‘make) – (get ‘car ‘year)
  • 90. Array in LISP • Array can be defined by using make-array function. – Example o(setf myarray (make-array (’10)))  Contents of cells can be accessed by aref function. – Example o(aref myarray 9)  To store item in the array we use the function setf – Example o(setf (aref myarray 0) 25)
  • 91. Exercise 1. Write a program in LISP to implement manipulation function in LISP (setq, car, last, cons, append, reverse, etc.). 2. Write a program in LISP to find greatest among three number using defun. 3. Write a program in LISP to convert Centigrade to Fahrenheit. 4. Define function to caculate area of circle. 5. Write a LISP program to solve the quadratic equation. 6. Write a LISP program to find whether the given number is even or odd. 7. Write a LISP program to calculate factorial. 8. Write a LISP program to find nth term of fibonacci series. 9. Write a LISP program for property. 10.Write a LISP program for Simple Intrest.
  • 93. What is Prolog? ● Prolog is acronym of PROgramming in LOGic. ● Prolog program is sequence of rules and facts. ● Prolog Rule for grandfather is defined as: father(james, robert). gfather(X, Y) :- father(X, Z), parent(Z, Y).
  • 94. Glimpse of Prolog Program /* Rules: “X is grand father of Y if X is father of Z who is parent of Y */ gfather(X, Y) :- father(X, Z), parent(Z, Y). (1) parent(X, Y) :- father(X, Y). (2) parent(X, Y) :- mother(X, Y). (3) /*Facts “James is father of robert” */ father(james, robert). (4) father(mike, william). (5) father(william, james). (6) father(robert, hency). (7) father(robert, cris). (8) /* Goals ‘ Is abraham a grand father of mike?’*/ ?- gfather(abraham, mike). ?- gfather(X, Y). ?- father(X, Y), father(Y, mike). Back
  • 95. General Syntax of Prolog ● The rules and facts in Prolog are terminated by full stop (.). ● Goal can be included in the program or given at the prompt. ● Goal can be single or conjunction of sub-goal(s) terminated by full stop. ● Constants are numerals and symbols such as, 4, mary, etc. ● String is a sequence of characters and is enclosed within single quotes e.g., 'This is a string'. ● Predicate names must start with alphabet and are formed by using lower case letters, numerals and underscore ( _ ). ● Variable names are formed similar to predicate names but it must start with upper case letter. Normally, we use X, Y, Z, ... for variables.
  • 96. Prolog Control Strategy ● Prolog contains three basic control strategies. − Forward movement − Matching (Unification) − Backward movement (Backtracking) ● Prolog uses depth first search strategy.
  • 97. Forward Movement ● Choose a rule by − searching sequentially in the program from top to bottom whose head matches with the goal with possible unifier. − Remember the position of the matched rule. − Join the rule body in front of the sequence of sub goals to be solved. ● Repeat until either goal is satisfied or is failed.
  • 98. Forward Movement – Cont… ● Consider the following query consisting of n sub-goals. ?- G1, ... , Gi-1, Gi, ... , Gn ● Starts executing or satisfying G1 − If G1 is satisfied using some rule, put a place marker so that next rule for G1 will be searched after the marker. − Continue in forward direction to satisfy G2 and if it is satisfied then continue with common bindings of the variables in sub- goals so far satisfied. − Such a movement is called forward
  • 99. Unification ● Unification is a process of matching or finding the most general unifier. − Constant matches with the same constant. − A variable can match with any constant or any another variable. ● Examples − love(X, sita) unifies with love(ram, sita) with mgu as {X / ram}. − love(X, Y) unify with love(ram, sita) with mgu as {X / ram, Y / sita} respectively.
  • 100. Monkey banana problem • We envision a room containing a monkey, a chair, and some bananas that have been hung from the center of the ceiling, out of reach form the monkey. If the monkey is clever enough , he can reach the bananas by placing the chair directly below them and climbing on top of the chair.
  • 101. Classical Monkey Banana problem • /*Solve the classical Monkey Banana problem of AI. */ predicates nondeterm inroom(symbol) nondeterm canmove(symbol,symbol) nondeterm canclimb(symbol,symbol) nondeterm below(symbol,symbol) nondeterm canreach(symbol,symbol) nondeterm clever(symbol)
  • 102. Classical Monkey Banana problem clauses inroom(monkey). inroom(chair). inroom(banana). canmove(monkey,chair). below(chair,banana). canclimb(monkey,chair). canreach(M,B):- inroom(M),inroom(C),inroom(B),canmove(M,C),below(C,B),canc limb(M,C). clever(M):- canreach(M,B). goal clever(monkey).
  • 103. Backtracking ● Backtracking refers to backtrack in search process for a solution. ● In Prolog, backtracking takes place in two situations. − First when a sub goal fails and − Other when the last sub goal succeeds, it backtracks to find alternative solutions.
  • 104. Types of backtracking ● Prolog has two kinds of backtracking. − Shallow and − Deep backtracking ● Both backtrackings take place in conjunction with each other. ● Shallow backtracking occurs − when alternative definition of the goal is tried. − Suppose G1,.., Gi-1 have been satisfied with some common bindings of the variables in sub-goals. − While satisfying Gi., if it fails for some rule then try another rule of Gi − This is called shallow backtracking to rules of the same sub-goal
  • 105. Backtracking Cont… ● Deep backtracking occurs − When sub-goal Gi fails for all rules of Gi then backtrack to Gi-1. − This backtracking is called deep backtracking. − Remove the bindings created earlier to satisfy Gi-1. − Try to satisfy Gi-1 again by using an alternative rule, if it exists, from last place marker of Gi-1. and continue the process. − If sub goal Gi-1 is satisfied then move forward to Gi, else backtrack to Gi-2. − The process of backtracking continues till we reach G1. − If G1 fails for all possible definitions, then entire query fails.
  • 106. Backtracking Cont… ● If entire conjunction of sub-goals succeed, then the solution is displayed. ● For alternative solution, the sub goal Gn is tried to be satisfied with alternative rule, if it exist, after last place marker (Shallow backtracking) of Gn . ● Otherwise it backtracks to previous sub goal Gn-1 (Deep backtracking). ● Process is repeated till all possible solutions are generated.
  • 107. Conflict-Resolution • In Prolog , if two or more rules having matching clauses, they are tried one at a time until an answer is reached. • But because of recursion and the depth first approach , the second clause would only be tried after he first clause led to a failure. • So if clause 1 and 2 matched, we try clause 1, assume it leads to clauses 3, 4,5 6 matching, each of which is tried and fails, we only try clause 2 after all that.
  • 108. Conflict resolution strategies • Specificity - If all of the conditions of two or more rules are satisfied, choose the rule with the most specific conditions. (e.g. "it is hot and smokey" rather than "it is hot"). Also referred to as "degree of specialization". • Recency - Facts are usually tagged to show how recently they were added. When two or more rules could be chosen, favor the one that matches the most recently added facts. This helps to utilize the most recently relevant facts. • Refractorizenes - If a rule's conditions are satisfied, but previously the same rule has been satisfied by the same facts, ignore the rule. This helps to avoid the system from entering infinite loops. • Order - Pick the first applicable rule in order of presentation. This is the type of strategy that Prolog uses and is one of the most common ones.