0% found this document useful (0 votes)
20 views

ai Unit full

The document outlines the foundational concepts of Artificial Intelligence (AI), including its definitions, techniques, and applications. It emphasizes the importance of problem-solving, intelligent agents, and various AI methodologies such as search, knowledge representation, and learning. Additionally, it discusses the advantages and disadvantages of AI, along with its interdisciplinary foundations in fields like psychology, mathematics, and computer engineering.

Uploaded by

xynab.3333
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

ai Unit full

The document outlines the foundational concepts of Artificial Intelligence (AI), including its definitions, techniques, and applications. It emphasizes the importance of problem-solving, intelligent agents, and various AI methodologies such as search, knowledge representation, and learning. Additionally, it discusses the advantages and disadvantages of AI, along with its interdisciplinary foundations in fields like psychology, mathematics, and computer engineering.

Uploaded by

xynab.3333
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 818

18CSC305J

ARTIFICIAL INTELLIGENCE
UNIT – 1

CLR1 : Provide a broad understanding of the basic techniques for building intelligent computer systems and an understanding of
how AI is applied to problems.

CLO1 : Formulate a problem and build intelligent agents


Unit 1 List of Topics
• Introduction to AI -AI techniques
• Problem solving with AI •Types of agents
•Other aspects of agents
• AI Models, Data acquisition and
learning aspects in AI •Constraint satisfaction
• Problem solving- Problem solving problems(CSP)
process, Formulating problems •Crypto arithmetic puzzles

• Problem types and characteristics •CSP as a search


• Problem space and search problem-constrains and
representation
• Intelligent agent •CSP-Backtracking, Role of
• Rationality and Rational agent with heuristic
performance measures
•CSP-Forward checking and
• Flexibility and Intelligent agents
constraint propagation
•CSP-Intelligent backtracking
• Task environment and its properties
What is Artificial Intelligence?

• A.I. is the study of how to make computers do


things at which, at the moment, people are better.
Intelligence vs Artificial Intelligence

• Intelligence is a property/ability attributed to people, such as to know, to think, to


talk, to learn, to understand.

Intelligence = Knowledge + ability to perceive, feel, comprehend,process,


communicate, judge, learn.

• Artificial Intelligence is an interdisciplinary field aiming at developing techniques


and tools for solving problems that people are good at.
Intelligence
Definitions of AI

Existing definitions advocate everything from replicating human intelligence to simply


solving knowledge-intensive tasks. Examples:

• “Artificial Intelligence is the design, study and construction of computer programs


that behave intelligently.” --Tom Dean.
• “Artificial Intelligence is the enterprise of constructing a physical symbol system that
can reliably pass the Turing test.” --Matt Ginsberg.
What is Artificial Intelligence ?

THOUGHT Systems that thinkSystems that think


like humans rationally

Systems that act Systems that act


BEHAVIOUR like humans rationally

HUMAN RATIONAL
Systems that act like humans:
Turing Test

• “The art of creating machines that perform


functions that require intelligence when
performed by people.” (Kurzweil)
• “The study of how to make computers do
things at which, at the moment, people are
better.” (Rich and Knight)
Systems that act like humans

?
• You enter a room which has a computer
terminal. You have a fixed period of time to
type what you want into the terminal, and
study the replies. At the other end of the line is
either a human being or a computer system.
• If it is a computer system, and at the end of the
period you cannot reliably determine whether
it is a system or a human, then the system is
deemed to be intelligent.
Systems that act like humans

• The Turing Test approach


– a human questioner cannot tell if
• there is a computer or a human answering his
question, via teletype (remote communication)
– The computer must behave intelligently
• Intelligent behavior
– to achieve human-level performance in all
cognitive tasks
Systems that act like humans

• These cognitive tasks include:


– Natural language processing
• for communication with human
– Knowledge representation
• to store information effectively & efficiently
– Automated reasoning
• to retrieve & answer questions using the stored
information
– Machine learning
• to adapt to new circumstances
The total Turing Test

• Includes two more issues:


– Computer vision

• to perceive objects (seeing)

– Robotics

• to move objects (acting)


What is Artificial Intelligence ?

THOUGHT Systems that thinkSystems that think


like humans rationally

Systems that act Systems that act


BEHAVIOUR like humans rationally

HUMAN RATIONAL
Systems that think like humans:
cognitive modeling

• Humans as observed from ‘inside’


• How do we know how humans think?
– Introspection vs. psychological experiments
• Cognitive Science
• “The exciting new effort to make computers
think … machines with minds in the full and
literal sense” (Haugeland)
• “[The automation of] activities that we associate
with human thinking, activities such as
decision-making, problem solving, learning …”
(Bellman)
What is Artificial Intelligence ?

THOUGHT Systems that thinkSystems that think


like humans rationally

Systems that act Systems that act


BEHAVIOUR like humans rationally

HUMAN RATIONAL
Systems that think ‘rationally’
"laws of thought"

• Humans are not always ‘rational’


• Rational - defined in terms of logic?
• Logic can’t express everything (e.g. uncertainty)
• Logical approach is often not feasible in terms of
computation time (needs ‘guidance’)
• “The study of mental facilities through the use of
computational models” (Charniak and
McDermott)
• “The study of the computations that make it
possible to perceive, reason, and act” (Winston)
What is Artificial Intelligence ?

THOUGHT Systems that thinkSystems that think


like humans rationally

Systems that act Systems that act


BEHAVIOUR like humans rationally

HUMAN RATIONAL
Systems that act rationally:
“Rational agent”
• Rational behavior: doing the right thing
• The right thing: that which is expected to
maximize goal achievement, given the
available information
• Giving answers to questions is ‘acting’.
• I don't care whether a system:
– replicates human thought processes
– makes the same decisions as humans
– uses purely logical reasoning
Systems that act rationally

• Logic only part of a rational agent, not all of


rationality
– Sometimes logic cannot reason a correct
conclusion
– At that time, some specific (in domain) human
knowledge or information is used
• Thus, it covers more generally different situations of
problems
– Compensate the incorrectly reasoned conclusion
Systems that act rationally

•Study AI as rational agent –


2 advantages:
– It is more general than using logic only
• Because: LOGIC + Domain knowledge
– It allows extension of the approach with more
scientific methodologies
Rational agents

⚫ An agent is an entity that perceives and acts


⚫ This course is about designing rational agents
⚫ Abstractly, an agent is a function from percept histories to
actions:
[f: P* A]
⚫ For any given class of environments and tasks, we seek the
agent (or class of agents) with the best performance
⚫ Caveat: computational limitations make perfect rationality
unachievable
⚫ design best program for given machine resources
• Artificial
– Produced by human art or effort, rather than
originating naturally.
• Intelligence
• is the ability to acquire knowledge and use it"
[Pigford and Baur]
• So AI was defined as:
– AI is the study of ideas that enable
computers to be intelligent.
– AI is the part of computer science concerned
with design of computer systems that exhibit
human intelligence(From the Concise Oxford
Dictionary)
From the above two definitions, we can see
that AI has two major roles:
– Study the intelligent part concerned with
humans.
– Represent those actions using computers.
Goals of AI

• To make computers more useful by letting


them take over dangerous or tedious tasks
from human
• Understand principles of human intelligence
The Foundation of AI

• Philosophy
– At that time, the study of human intelligence
began with no formal expression
– Initiate the idea of mind as a machine and its
internal operations
The Foundation of AI

⚫ Mathematics formalizes the three main area of


AI: computation, logic, and probability
⚫ Computation leads to analysis of the problems that
can be computed
⚫ complexity theory
⚫ Probability contributes the “degree of belief” to
handle uncertainty in AI
⚫ Decision theory combines probability theory and
utility theory (bias)
The Foundation of AI

• Psychology
– How do humans think and act?
– The study of human reasoning and acting
– Provides reasoning models for AI
– Strengthen the ideas
• humans and other animals can be considered as
information processing machines
The Foundation of AI

• Computer Engineering
– How to build an efficient computer?
– Provides the artifact that makes AI application
possible
– The power of computer makes computation of
large and difficult problems more easily
– AI has also contributed its own work to computer
science, including: time-sharing, the linked list
data type, OOP, etc.
The Foundation of AI

• Control theory and Cybernetics


– How can artifacts operate under their own
control?
– The artifacts adjust their actions
• To do better for the environment over time
• Based on an objective function and feedback from
the environment
– Not limited only to linear systems but also other
problems
• as language, vision, and planning, etc.
The Foundation of AI

• Linguistics
– For understanding natural languages
• different approaches has been adopted from the
linguistic work
– Formal languages
– Syntactic and semantic analysis
– Knowledge representation
The main topics in AI

Artificial intelligence can be considered under a number of


headings:
– Search (includes Game Playing).
– Representing Knowledge and Reasoning with it.
– Planning.
– Learning.
– Natural language processing.
– Expert Systems.
– Interacting with the Environment
(e.g. Vision, Speech recognition, Robotics)
Some Advantages of Artificial Intelligence

– more powerful and more useful computers


– new and improved interfaces
– solving new problems
– better handling of information
– relieves information overload
– conversion of information into knowledge
The Disadvantages

– increased costs
– difficulty with software development - slow and
expensive
– few experienced programmers
– few practical products have reached the market
as yet.
AI – Social Companion
AI in Movies
AI Applications
AI Defined

● Textbook definition:

– AI may be defined as the branch of computer science


that is concerned with the automation of intelligent
behavior
Applied Areas of AI

• Heuristic Search
• Computer Vision
• Adversarial Search (Games)
• Fuzzy Logic
• Natural Language Processing
• Knowledge Representation
• Planning
• Learning
Examples

• Playing chess • Recognizing speech


• Driving on the highway • Diagnosing diseases
• Mowing the lawn • Translating languages
• Answering questions • Data mining
Unit 1 List of Topics
• Introduction to AI- AI techniques
• Problem solving with AI •Types of agents
•Other aspects of agents
• AI Models, Data acquisition and
learning aspects in AI •Constraint satisfaction
• Problem solving- Problem solving problems(CSP)
process, Formulating problems •Crypto arithmetic puzzles

• Problem types and characteristics •CSP as a search


• Problem space and search problem-constrains and
representation
• Intelligent agent •CSP-Backtracking, Role of
• Rationality and Rational agent with heuristic
performance measures
•CSP-Forward checking and
• Flexibility and Intelligent agents
constraint propagation
•CSP-Intelligent backtracking
• Task environment and its properties
AI Techniques

• AI technique is a method that achieves knowledge. The main AI techniques are:


– Search

– Use of knowledge

– Abstraction
1. Search:-
• Search provides a way of solving problems for which no more direct approach is available as
well as a framework into which any direct techniques that are available can be embedded.
A search program finds a solutions for a problem by trying various sequences of actions or
operators until a solution is found.
Advantages
• It is the best way so far as no better way has been found to solve the problems.
• To solve a problem using search, it is only necessary to code the operator that can be used;
the search will find the sequence of actions that will provide the desired results.
Disadvantages
• Most problems have search spaces so large that it is impossible to search for the whole
space.
AI Techniques

2. Use of knowledge:-
• The use of knowledge provides a way of solving complicated problems by manipulating the structures
of the objects that are concerned.
• The way in which knowledge can be represented for usage in AI techniques:
• AI technique is a method that achieves knowledge that should be represented in such a way that:-
• Knowledge captures generalization. This meaning grouping situations that share important properties
rather than representing each situation separately with such an arrangement of knowledge, an
unreasonable amount of memory, and updating will no longer be required. Anything without this
property is called data rather than knowledge.
• It should be represented in such a way that it can be understood by the people who must prepare it.
For many programs, the size of the data can be achieved automatically by taking a reading from a
number of instruments, but in many AI areas, most of the knowledge a program has must be provided
by people in terms that they understand it.
• It could easily be adjusted to correct errors end to demonstrate changes in the world.
• It can be used to overcome its own through volume by helping to restrict the range of possibilities that
must usually be considered or discussed.
• It could be used in different situations even though it may not entirely be complete.
3. Abstraction:-
• Abstraction finds a way of separating important features and notifications from the unimportant ones
AI Techniques
AI technique is a method that exploits knowledge that should be represented in
such a way that:
1. The knowledge captures generalizations
2. It can be understood by people who must
provide it.
3. It can easily be modified to correct errors
4. It can be used in a great many situations even if
it is not totally accurate or complete
5. It can be used to help overcome its own sheer
bulk by helping to narrow the range of
possibilities that must usually be considered.
AI Techniques

• An AI technique is a method that exploits knowledge that is represented so that:


The knowledge captures generalizations that share properties, are grouped
together, rather than being allowed separate representation.
• It can be understood by people who must provide it—even though for many
programs bulk of the data comes automatically from readings.
• In many AI domains, how the people understand the same people must supply
the knowledge to a program.
• It can be easily modified to correct errors and reflect changes in real conditions.
• It can be widely used even if it is incomplete or inaccurate.
• It can be used to help overcome its own sheer bulk by helping to narrow the
range of possibilities that must be usually considered. In order to characterize an
AI technique let us consider initially OXO or tic-tac-toe and use a series of
different approaches to play the game. The programs increase in complexity,
their use of generalizations, the clarity of their knowledge and the extensibility of
their approach. In this way they move towards being representations of AI
techniques.
Unit 1 List of Topics
• Introduction to AI-AI techniques
• Problem solving with AI •Types of agents
•Other aspects of agents
• AI Models, Data acquisition and
learning aspects in AI •Constraint satisfaction
• Problem solving- Problem solving problems(CSP)
process, Formulating problems •Crypto arithmetic puzzles

• Problem types and characteristics •CSP as a search


• Problem space and search problem-constrains and
representation
• Intelligent agent •CSP-Backtracking, Role of
• Rationality and Rational agent with heuristic
performance measures
•CSP-Forward checking and
• Flexibility and Intelligent agents
constraint propagation
•CSP-Intelligent backtracking
• Task environment and its properties
Problem Solving with AI
Problem Solving In AI : Introduction

• Problem Solving in games such as “Sudoku” can be an example. It can be done by building
an artificially intelligent system to solve that particular problem. To do this, one needs to
define the problem statements first and then generating the solution by keeping the
conditions in mind.
• Some of the most popularly used problem solving with the help of artificial intelligence
are:
– Chess.
– Travelling Salesman Problem.
– Tower of Hanoi Problem.
– Water-Jug Problem.
– N-Queen Problem.
• Problem Searching
• In general, searching refers to as finding information one needs.
• Searching is the most commonly used technique of problem solving in artificial
intelligence.
• The searching algorithm helps us to search for solution of particular problem.
Problem Solving In AI : Introduction

• Problem
• Problems are the issues which comes
across any system. A solution is
needed to solve that particular
problem.
• Steps : Solve Problem Using Artificial
Intelligence
• The process of solving a problem
consists of five steps. These are:
Problem Solving In AI : Introduction

• Defining The Problem: The definition of the problem must be included


precisely. It should contain the possible initial as well as final situations
which should result in acceptable solution.
• Analyzing The Problem: Analyzing the problem and its requirement
must be done as few features can have immense impact on the
resulting solution.
• Identification Of Solutions: This phase generates reasonable amount of
solutions to the given problem in a particular range.
• Choosing a Solution: From all the identified solutions, the best solution
is chosen basis on the results produced by respective solutions.
• Implementation: After choosing the best solution, its implementation is
done.
Broad Categorisation of AI problems

Structured Problem
Well structed – Yield a right answer
Ill structed – Do not yield a particular answer
Unstructured Problem
Very hard to formulate the problem
Ambiguous in nature
Linear Problem
Have clear solution
All kind of classification problems
Non linear Problem
Relationships between input and output is non linear
Further decision can’t be taken like in linear problem

50
Unit 1 List of Topics
• Introduction to AI-AI techniques •Types of agents
• Problem solving with AI •Other aspects of agents

• AI Models, Data acquisition and •Constraint satisfaction


learning aspects in AI problems(CSP)
• Problem solving- Problem solving •Crypto arithmetic puzzles
process, Formulating problems
•CSP as a search
• Problem types and characteristics problem-constrains and
• Problem space and search representation
•CSP-Backtracking, Role of
• Intelligent agent heuristic
• Rationality and Rational agent with
performance measures
•CSP-Forward checking and
constraint propagation
• Flexibility and Intelligent agents
•CSP-Intelligent backtracking
• Task environment and its properties
AI Models

• One important aspect of building AI solutions


is modelling the problem.
(i) Dunker introduced ‘Maze Hypothesis’.
(ii) logic theory machines.

52
AI Models

iii) Advent of NLP & man-machine dialogue.


iv) Formal models proposed to solve AI
problems.
V) Human behaviour & psychological
study-based inductive dynamic models for
creative problem solving slowly became
popular.

53
AI Models

• Semiotic Models
- Based on Sign processes / signification and communication.
- Code is specific which gives meaning to each sign based on the sound or letters
that human use to form words or movements.

• Statistical Models
- Refers to representation and formulation of relationships through statistical
techniques.
- Statistical model employs probabilistic approaches and is typically a collection of
probability density function and distribution functions.

54
Unit 1 List of Topics
• Introduction to AI-AI techniques
• Problem solving with AI •Types of agents
•Other aspects of agents
• AI Models, Data acquisition and
learning aspects in AI •Constraint satisfaction
• Problem solving- Problem solving problems(CSP)
process, Formulating problems •Crypto arithmetic puzzles

• Problem types and characteristics •CSP as a search


• Problem space and search problem-constrains and
representation
• Intelligent agent •CSP-Backtracking, Role of
• Rationality and Rational agent with heuristic
performance measures
•CSP-Forward checking and
• Flexibility and Intelligent agents
constraint propagation
•CSP-Intelligent backtracking
• Task environment and its properties
Data acquisition and learning aspects in AI

Various AI –related topics on data acquisition and machine learning

• Knowledge discovery – Data mining and machine learning


• Computational learning theory (COLT)
• Neural and evolutionary computation
• Intelligent agents and multi-agent systems
• Multi-perspective integrated intelligence
Unit 1 List of Topics
• Introduction to AI-AI techniques
• Problem solving with AI •Types of agents
•Other aspects of agents
• AI Models, Data acquisition and
learning aspects in AI •Constraint satisfaction
• Problem solving- Problem solving problems(CSP)
process, Formulating problems •Crypto arithmetic puzzles

• Problem types and characteristics •CSP as a search


• Problem space and search problem-constrains and
representation
• Intelligent agent •CSP-Backtracking, Role of
• Rationality and Rational agent with heuristic
performance measures
•CSP-Forward checking and
• Flexibility and Intelligent agents
constraint propagation
•CSP-Intelligent backtracking
• Task environment and its properties
Problem – Solving

Problem Solving – Is an area to deal with finding answer for some unknown situations.

It involves

Understanding
Representation
Formulation
Solving

May be SIMPLE or COMPLEX Problems.

METHODS OF PROBLEM SOLVING:

1. General Purpose
2. Special purpose

Problem – Solving also assist in planning and decision making.


Problem – Solving Process
Example: Travelling in Romania
Scenario : On holiday in Romania; currently in
Arad Flight leaves tomorrow from Bucharest.

Goal : Be in Bucharest
Formulate problem :
States: various cities
Actions: drive between cities
Solution:
Appropriate sequence of cities
e.g.: Arad, Sibiu, Fagaras, Bucharest
Problem Solving with AI
“ Formulate , Search , Execute “ design for agent

A simple problem-solving agent. It first formulates a goal and a problem,


searches for a sequence of actions that would solve the problem, and then executes the actions
one at a time. When this is complete, it formulates another goal and starts over.
Problem Solving with AI
Components of a problem – Example
A simplified road map of part of Romania.
Problem Solving with AI
Components of a problem
A problem can be defined formally by five components:

• The initial state that the agent starts in /Starting state which agent knows
itself.
• Ex- The initial state for our agent in Romania might be described as In(Arad)

• A description of the possible actions/operators available to the agent. Given a


particular state s, ACTIONS(s) returns the set of actions that can be executed in s. We
say that each of these actions is applicable in s.
• Ex- from the state In(Arad), the applicable actions are {Go(Sibiu), Go(Timisoara),
Go(Zerind)}.
• A description of what each action does; the formal name for this is the transition
model, specified by a function RESULT(s, a) that returns the state that results from
doing action a in state s. We also use the term successor to refer to any state reachable
from a given state by a single action.
• Ex- RESULT(In(Arad),Go(Zerind)) = In(Zerind)
Problem Solving with AI
Components of a problem

• Together, the initial state, actions, and transition model implicitly


define the state space of the problem—the set of all states
reachable from the initial state by any sequence of actions. The state
space forms a directed network or graph in which the nodes are
states and the links between nodes are actions. A path in the state
space is a sequence of states connected by a sequence of actions.
• Ex- The map of Romania shown can be interpreted as a state-space graph if we view each
road as standing for two driving actions, one in each direction.
• The goal test, which determines whether a given state is a goal
state. Sometimes there is an explicit set of possible goal states, and
the test simply checks whether the given state is one of them.
• Ex- The agent’s goal in Romania is the singleton set {In(Bucharest )}
Problem Solving with AI
Components of a problem
• A path cost function that assigns a numeric cost to each path. The
problem-solving agent chooses a cost function that reflects its own
performance measure.

• The step cost of taking action a to go from one state ‘s’ to reach state ‘y’ is
denoted by c(s, a, y).

Ex- For the agent trying to get to Bucharest, time is of the essence, so the cost of a
path might be its length in kilometres. We assume that the cost of a path can be
described as the sum of the costs of the individual actions along the path. The step
costs for Romania are shown in Figure as route distances. We assume that step costs
are nonnegative.

• A solution to a problem is an action sequence that leads from the initial state
to a goal state. Solution quality is measured by the path cost function, and an
optimal solution has the lowest path cost among all solutions.
Formulating Problems

• Problem Formulation : Choosing relevant set of states &


feasible set of operators for moving from one state to another.

• Search : Is a process of imagining sequences of


operators(actions) applied to initial state and to see which state
reaches goal state.
Unit 1 List of Topics
• Introduction to AI-AI techniques
• Problem solving with AI •Types of agents
•Other aspects of agents
• AI Models, Data acquisition and
learning aspects in AI •Constraint satisfaction
• Problem solving- Problem solving problems(CSP)
process, Formulating problems •Crypto arithmetic puzzles

• Problem types and characteristics •CSP as a search


• Problem space and search problem-constrains and
representation
• Intelligent agent •CSP-Backtracking, Role of
• Rationality and Rational agent with heuristic
performance measures
•CSP-Forward checking and
• Flexibility and Intelligent agents
constraint propagation
•CSP-Intelligent backtracking
• Task environment and its properties
Problem Types

1. Deterministic or observable (single-state)


2. Non-observable (multiple-state)
3. Non-deterministic or partially observable
4. Unknown state space
Problem Types
1. Deterministic or observable(Single-state
problems)
• Each state is fully observable and it goes to
one definite state after any action.
• Here , the goal state is reachable in one single
action or sequence of actions.
• Deterministic environments ignore
uncertainty.
• Ex- Vacuum cleaner with sensor.

69
Problem Types
2. Non-observable(Multiple-state problems) /
conformant problems
• Problem – solving agent does not have any
information about the state.
• Solution may or may not be reached.
• Ex- In case of vacuum cleaner , the goal state is to clean the floor rather
clean floor. Action is to suck if there is dirt. So , in non-observable condition
, as there is no sensor , it will have to suck the dirt , irrespective of whether
it is towards right or left . Here , the solution space is the states specifying
its movement across the floor.
Problem Types
3. Non-deterministic(partially observable) problem
• The effect of action is not clear.
• Percepts provide new information about the current
state.
• Ex- If we take Vacuum cleaner , and now assume that the
sensor is attached to it , then it will suck if there is dirt.
Movement of the cleaner will be based on its current
percept.
Problem Types

Fully observable/ partially observable / Single agent/ Multiagent


unobservable

Static, Discrete: Crossword puzzle.


Dynamic, Continuous: Taxi Driving

Competitive/ Cooperative
Problem Types
4. Unknown state space problems
• Typically exploration problems
• States and impact of actions are not
known
• Ex- online search that involves acting without compete knowledge
of the next state or scheduling without map.
Problem Characteristics
1. Is the problem decomposable ?
2. Can Solution steps be ignored or undone ?
3. Is the Universe Predictable?
4. Is a good solution absolute or relative ?
5. Is the solution a state or a path?
6. What is the role of knowledge?
7. Does the task require interaction with a
person ?
Problem Characteristics- 1. Is the problem decomposable ?
BLOCKS WORLD
Problem Characteristics: 2. Can Solution steps be ignored or undone ?
The 8 – Puzzle

● How would you use AI techniques to


solve the 8-puzzle problem?
Important Classes of Problem

• Ignorable Ex. Theorem Proving


• Recoverable Ex. The 8-Puzzle
• Irrecoverable Ex. Chess
Problem Characteristics
3. Is the Universe Predictable?

❖ Difference between certain outcome (e.g. 8-Puzzle)


and uncertain outcome (e.g. play bridge ) .
❖ In case of certain outcome, we can make a plan to
generate a sequence of operation that guaranteed to
lead to a solution. So, that the outcome is very
certain.
❖ In case of uncertain outcome problems, we follow
the process of plan revision as the plan is carried
out and the necessary feedback is provided. The
disadvantage is that the planning in this case is
often very expensive.
Problem Characteristics
4. Is a good solution absolute or relative ?
● The facts can be represented using a
formal language called “Predicate
Logic”.
● There may be “n” different solutions. If
one solution is found , there is no need
to go back and see if some path might
also lead to a solution.
● Ex: P -> Q
●If marks = 92 -> Grade = O
RELATIVE SOLUTION : Ex. TSP
(Explore all possible solutions)
Problem Characteristics
5. Is the solution a state or a path ?
● To solve a problem, of finding
interpretation, we need to produce
only the interpretation itself.
Record of processing by how the
interpretation was arrived is NOT
required.
Ex: The President ate Food with a
fork.
● In contrast, if we must produce,
the final state along with the path
that we found to that state along
with sequence of operations to
produce the final state.
Problem Characteristics
6. What is the role of knowledge ?
Is the lots of knowledge required to solve a problem or is knowledge only
to constrain solutions?

● Ex: Newspaper reading (by a computer) illustrate difference between


problems for which a lot of knowledge is important only to constrain a
search for solution and those for which a lot of knowledge is required
to recognise a solution.
● Ex: Scanning newspapers to find who support Party A or Party B in
upcoming elections.
● Assume unlimited computer power.
● The following has to be known at the time to arrive at an answer
– (i) Name of Party candidates
– (ii) Taxes lowered
– (iii) Improved education, etc.
Problem Characteristics
7. Does the task require interaction with a person ?

There are 2 types of problems:


● Solitary : in which computer is given a problem
description and with NO DEMAND FOR
EXPLANATION of the reasoning process.
● Conversational: in which there is intermediate
communication between a person and the
computer either to provide additional assistance to
computer or to provide additional information to
user or both.
Unit 1 List of Topics
• Introduction to AI-AI techniques
• Problem solving with AI •Types of agents
•Other aspects of agents
• AI Models, Data acquisition and
learning aspects in AI •Constraint satisfaction
• Problem solving- Problem solving problems(CSP)
process, Formulating problems •Crypto arithmetic puzzles

• Problem types and characteristics •CSP as a search


• Problem space and search problem-constrains and
representation
• Intelligent agent •CSP-Backtracking, Role of
• Rationality and Rational agent with heuristic
performance measures
•CSP-Forward checking and
• Flexibility and Intelligent agents
constraint propagation
•CSP-Intelligent backtracking
• Task environment and its properties
Formal Description of a Problem
• In AI, we will formally define a problem as
– a space of all possible configurations where each
configuration is called a state
• thus, we use the term state space
– an initial state
– one or more goal states
– a set of rules/operators which move the problem from one
state to the next
• In some cases, we may enumerate all possible states
(see monkey & banana problem on the next slide)
– but usually, such an enumeration will be overwhelmingly
large so we only generate a portion of the state space, the
portion we are currently examining
The Monkey & Bananas Problem
• A monkey is in a cage and bananas are suspended from
the ceiling, the monkey wants to eat a banana but cannot
reach them
– in the room are a chair and a stick
– if the monkey stands on the chair and waves the stick, he can
knock a banana down to eat it
– what are the actions the monkey should take?

Initial state:
monkey on
ground
with empty hand
bananas
suspended
Goal state:
monkey eating
Actions:
climb chair/get
off
grab X
• • Problem solving: The term, Problem Solving relates to analysis in AI.
Problem solving may be characterized as a systematic search through a
range of possible actions to reach some predefined goal or solution.
Problem-solving methods are categorized as special purpose and general
purpose.
• • A special-purpose method is tailor-made for a particular problem, often
exploits very specific features of the situation in which the problem is
embedded.
• • A general-purpose method is applicable to a wide variety of problems.
One General-purpose technique used in AI is ‘means-end analysis’: a
step-bystep, or incremental, reduction of the difference between current
state and final goal.
Example – Toy Problems
Vacuum Cleaner World
Program implements the agent function tabulated

Function Reflex-Vacuum-Agent([location,status]) return


an action
If status = Dirty then return Suck
else if location = A then return Right
else if location = B then return left
Toy Problems vs Real-world Problems

• A toy problem is intended to illustrate or exercise


various problem solving methods. It can be given a
concise, exact description.

• A real world problem is one whose solutions


people actually care about. Such problems tend not to
have a single agreed-upon description, but we can give the
general flavor of their formulations.

89
Toy Problem- 1
Vacuum Cleaner World -Problem Formulation

• State - agent is in one of two locations, each of which might or might


not contain dirt. Thus there are 2 × 22 = 8 possible world states. A
larger environment with n locations has n ・ 2n states

• Initial State
– Any one of 8 states

• Actions
– In this simple environment, each state has just three actions: Left , Right ,Suck.
Larger environments might also include Up , Down
Toy Problem- 1
Vacuum Cleaner World -Problem Formulation

• Transition model: The actions have their expected effects, except that
moving Left in the leftmost square, moving Right in the rightmost square,
and Sucking in a clean square have no effect. The complete state space is
shown in the figure .

• State Space for the Vacuum World


Labels on Arcs denote L: Left, R: Right, S: Suck

• Goal Test
– This checks whether all the squares are clean
• Path Cost
– Number of steps (each step costs a value of 1)
Toy Problem- 2
The 8-Puzzle (Sliding Block Puzzle)

The 8-puzzle, an instance of which is shown below, consists of a


3×3 board with eight numbered tiles and a blank space. A tile
adjacent to the blank space can slide into the space. The object is
to reach a specified goal state, such as the one shown on the right
of the figure.
Toy Problem- 2
The 8-Puzzle (Sliding Block Puzzle)

States: A state description specifies the location of each of the eight


tiles and the blank in one of the nine squares.

Initial state: Any state can be designated as the initial state.

Successor function: This generates the legal states that result from
trying the four actions (blank moves Left, Right, Up, or Down).

Goal test: This checks whether the state matches the goal
configuration (Other goal configurations are possible.)

Path cost: Each step costs 1, so the path cost is the number of steps
in the path.
Toy Problem- 2
The 8-Puzzle (Sliding Block Puzzle) - Solution
• hf= +1 for every correct position
• Solution of this problem is “movement of tiles” in order to reach
goal state.
• The transition function or legal move is any one tile movement
by one space in any direction.
Toy Problem- 2
The 8-Puzzle (Sliding Block Puzzle) - Solution
Toy Problem- 2
The 8-Puzzle (Sliding Block Puzzle) - Solution
Toy Problem- 3
Water – Jug Problem

A Water Jug Problem: You are given two


jugs, a 4-gallon one and a 3-gallon one, a
pump which has unlimited water which you
can use to fill the jug, and the ground on
which water may be poured. Neither jug has
any measuring markings on it. How can you
get exactly 2 gallons of water in the 4-gallon
jug?
Toy Problem- 3
Water – Jug Problem
Solution:
The state space for this problem can be described as the set of ordered pairs
of integers (x,y)

Where,

X represents the quantity of water in the 4-gallon jug X= 0,1,2,3,4


Y represents the quantity of water in 3-gallon jug Y=0,1,2,3

Note
0 ≤ X ≤ 4, and 0 ≤ Y ≤ 3

Start State: (0,0)


Goal State: (2, n) for any n. Attempting to end up in a goal state.(
since the problem doesn‘t specify the quantity of water
in 3-gallon jug)
Toy Problem- 3
Water – Jug Problem
Generate production rules for the water jug problem
Production Rules:

1. (x,y) -> (4,y) Fill x


2. (x,y) -> (x,3) Fill y
3. (x,y) -> (x-d, y) Pour water out from X
4. (x,y) -> (x,y-d) Pour water from y
5. (x,y) -> (0,y) Empty x
6. (x,y) -> (x,0) Empty y
7. (x,y) -> (4,y-(4-x)) Pour water from y into x until x is full
8. (x,y) -> (x – (3-y), 3) Pour water from x into y until y is full.
9. (x,y) -> (x+y, 0) Pour all water from y to x
10. (x,y) -> (0, x+y) Pour all water from x to y
11. (0,2) -> (2,0) Pour 2 Gallon of water from y to x
12. (2, y) -> (0,y) Pour 2 Gallon of water from x to ground.
Toy Problem- 3
Water – Jug Problem

First solution
1. (x,y) -> (4,y) Fill x
2. (x,y) -> (x,3) Fill y
3. (x,y) -> (x-d, y) Pour water out from X
4. (x,y) -> (x,y-d) Pour water from y
Initial
5. (x,y) -> (0,y) Empty x
R2 6. (x,y) -> (x,0) Empty y
R9 7. (x,y) -> (4,y-(4-x)) Pour water from y into x until
R2 x is full
8. (x,y) -> (x – (3-y), 3) Pour water from x into y until
R7
y is full.
R5 9. (x,y) -> (x+y, 0) Pour all water from y to x
R9 10. (x,y) -> (0, x+y) Pour all water from x to y
11. (0,2) -> (2,0) Pour 2 Gallon of water from y to x
12. (2, y) -> (0,y) Pour 2 Gallon of water from x to
ground.
Toy Problem- 4(a)
4-queens problem

The N Queen is the problem of placing N chess queens on an N×N chessboard so


that no two queens attack each other.
Given a 4 x 4 chessboard and number the rows and column of the
chessboard 1 through 4.

Since, we have to place 4 queens such as q1 q2 q3 and q4 on the


chessboard, such that no two queens attack each other. In such a
conditional each queen must be placed on a different row, i.e., we put
queen "i" on row "i."
Toy Problem- 4(a)
4-queens problem
One possible solution for the 4-queens problem is (2,4,1,3) i.e ,
Toy Problem- 4(a)
4-queens problem
The implicit tree for 4 - queen problem for a solution (2, 4, 1, 3) is as follows:
Toy Problem- 4(a)
4-queens problem

Another solution for 4 - queens problems is (3, 1, 4, 2) i.e


Toy Problem- 4(b)
8-queens problem
“We have 8 queens and an 8x8 Chess board having
alternate black and white squares. The queens are
placed on the chessboard.

Any queen can attack any other queen placed on


same row, or column or diagonal. We have to find
the proper placement of queens on the Chess board
in such a way that no queen attacks other queen”.
Toy Problem- 4(b)
8-queens problem
possible board configuration of 8 queen problem

In figure , the possible board configuration for 8-queen problem has been shown. The board
has alternative black and white positions on it. The different positions on the board hold the
queens. The production rule for this game is you cannot put the same queens in a same row
or same column or in same diagonal. After shifting a single queen from its position on the
board, the user have to shift other queens according to the production rule. Starting from the
first row on the board the queen of their corresponding row and column are to be moved
from their original positions to another position. Finally the player has to be ensured that no
rows or columns or diagonals of on the table is same.
Toy Problem- 4(b)
8-queens problem
The first incremental formulation one might try is the following:
• States: Any arrangement of 0 to 8 queens on the board is a
state.
• Initial state: No queens on the board.
• Actions/Successor function : Add a queen to any empty
square.
• Transition model: Returns the board with a queen added to the
specified square.
• Goal test: 8 queens are on the board, none attacked.
• Path cost: Zero (search cost only exists)
In this formulation, we have 64 ・ 63 ・ ・ ・ 57 ≈ 1.8×1014 possible sequences to
investigate.
Toy Problem- 5
BLOCK WORLD
What is the Blocks World? -- The world consists of:
•A flat surface such as a tabletop
•An adequate set of identical blocks which are identified by
letters.
•The blocks can be stacked one on one to form towers of
apparently unlimited height.
•The stacking is achieved using a robot arm which has
fundamental operations and states which can be assessed using
logic and combined using logical operations.
•The robot can hold one block at a time and only one block can
be moved at a time.
Toy Problem- 5
Toy Problem- 5
Blocks World Problem – Ex .

hf = -10 hf = +10

Heuristic
Toy Problem- 5
Blocks World Problem – Ex .
Step 1
Toy Problem- 5
Blocks World Problem – Ex .
Step 2
Toy Problem- 5
Blocks World Problem – Ex .
Step 3

hf = -1
Toy Problem- 5
Blocks World Problem – Ex .
Step 4
Toy Problem- 5
Blocks World Problem – Ex .
Step 5

hf = +3
Toy Problem- 5
Blocks World Problem – Ex .
Step 6

hf = +10

Global solution for block world


Toy Problem- 5
BLOCK WORLD - STRIPS
(STanford Research Institute Problem Solver)

• STRIPS - an action-centric representation ,for


each action , specifies the effect of an action.
Toy Problem- 5
BLOCK WORLD - STRIPS
(STanford Research Institute Problem Solver)

• STRIPS - an action-centric representation ,for


each action , specifies the effect of an action.
The STRIPS representation for an action consists of three lists,
• Pre_Cond list contains predicates which have to be true
before operation.
• ADD list contains those predicates which will be true after
operation
• DELETE list contain those predicates which are no longer true
after operation
Toy Problem- 6
Tic Tac Toe
The game Tic Tac Toe is also known as Noughts and Crosses or Xs
and Os ,the player needs to take turns marking the spaces in a 3x3 grid
with their own marks,
if 3 consecutive marks (Horizontal, Vertical,Diagonal) are formed then
the player who owns these moves get won.

Assume ,
So,a player who gets 3 consecutive
Player 1 - X marks first,they will win the game .
Player 2 - O
Toy Problem- 7
Missionaries and Cannibals
Let Missionary is denoted by ‘M’ and Cannibal, by ‘C’.
These rules are described below:

All or some of these production rules will have to be used in a particular


sequence to find the solution of the problem.
Toy Problem- 7
Missionaries and Cannibals
Rules applied and their sequence in Missionaries and Cannibals problem
Toy Problem- 7
Formalization of the M&C Problem

State space: triple (x,y,z) with 0 ≤ x,y,z ≤ 3, where x,y, and


z represent the number of missionaries, cannibals and
boats currently on the original bank.
Initial State: (3,3,1)
Successor function: From each state, either bring one
missionary, one cannibal, two missionaries, two cannibals,
or one of each type to the other bank.
Note: Not all states are attainable (e.g., (0,0,1)), and some
are illegal.
Goal State: (0,0,0) Path Costs: 1 unit per crossing
Toy Problem- 8
Travelling Salesman Problem(Path Finding Problems)

“Given ‘n’ cities connected by roads, and distances between each


pair of cities. A sales person is required to travel each of the cities
exactly once. We are required to find the route of salesperson so
that by covering minimum distance, he can travel all the cities and
come back to the city from where the journey was started”.

Diagrammatically, it is shown below

Fig : Cities and paths connecting these


Toy Problem- 8
Travelling Salesman Problem(Path Finding Problems)

The basic travelling salesperson problem comprises of computing the shortest route
through a given set of cities.

Following Table shows number of cities and the possible routes mentioned
against them.
Toy Problem- 9
Monkey Banana Problem

“A monkey is in a room. A bunch of bananas is


hanging from the ceiling. The monkey cannot
reach the bananas directly. However , in the room
there is one chair and a stick. The monkey can
reach the banana standing on the chair. We have to
find the sequence of events by which monkey can
reach the bananas.”
Toy Problem- 9
Monkey Banana Problem
Solution of this problem means finding the sequence of actions for the monkey
to reach the banana.

Monkey standing on the chair and catching the bananas with the stick.
Summary of Problem Solving with AI –
Toy Problems

1. Block World
2. 4 Queens/ 8 Queens
3. Tic Tac Toe
4. Water Jug
5. Monkey Banana
6. 8 Puzzle
7. TSP
8. Vacuum Cleaner
9. Missionaries and Cannibals
Unit 1 List of Topics
• Introduction to AI-AI techniques
• Problem solving with AI •Types of agents
•Other aspects of agents
• AI Models, Data acquisition and
learning aspects in AI •Constraint satisfaction
• Problem solving- Problem solving problems(CSP)
process, Formulating problems •Crypto arithmetic puzzles

• Problem types and characteristics •CSP as a search


• Problem space and search problem-constrains and
representation
• Intelligent agent •CSP-Backtracking, Role of
• Rationality and Rational agent with heuristic
performance measures
•CSP-Forward checking and
• Flexibility and Intelligent agents
constraint propagation
•CSP-Intelligent backtracking
• Task environment and its properties
Agent
• An agent is anything that can be viewed as
perceiving its environment through sensors and
acting upon that environment through actuators
Diagram of an Agent

What AI
should fill
Intelligent Agents
Intelligent Agent – Is an entity that works without
assistance, interprets the input, senses the
environment, makes choices and ultimately acts to
achieve a goal.

• Human agent: eyes, ears, and other organs for


sensors; hands,legs, mouth, and other body parts for
actuators
• Robotic agent: cameras and infrared range finders
for sensors; various motors for actuators
• Software Agent:
Software Agents

• Sometimes, the environment may not be the


real world
● E.g., flight simulator, video games, Internet
● They are all artificial but very complex
environments
● Those agents working in these environments
are called
●Softwareagent (softbots)
●Because all parts of the agent are software
Agent and Environment Relationship
Agents and Environment

Percept
● Agent’s perceptual inputs at any given instant
Percept sequence
● Complete history of everything that the agent
has ever perceived.
Agents and Environment

• The agent function maps from percept histories


to actions:
[f: P* A]
• The agent program runs on the physical
architecture to produce f
• agent = architecture + program
Representation of Agent Function as a Subset of
Agent Program

Example: Auto-door opening and closing system.


Two cameras, one inside and other outside, cover this area.
A simple agent function is that if any person is standing in that area, open the door or else
close.
So, a function is like
• If area is empty, then close the door.
• If area is occupied, then open the door.
An agent program uses this function to achieve this complete expected behaviour. The program
takes care of following activities:
• Continuous scanning of this area
• Opening or closing of the door or keeping it in the same position based on the output of
function
• Handling all combinations and possible issues
• Handling the exceptions to ensure the smooth functioning
• Ultimately achieving the results in all possible scenarios
Unit 1 List of Topics
• Introduction to AI-AI techniques
• Problem solving with AI •Types of agents
•Other aspects of agents
• AI Models, Data acquisition and
learning aspects in AI •Constraint satisfaction
• Problem solving- Problem solving problems(CSP)
process, Formulating problems •Crypto arithmetic puzzles

• Problem types and characteristics •CSP as a search


• Problem space and search problem-constrains and
representation
• Intelligent agent •CSP-Backtracking, Role of
• Rationality and Rational agent with heuristic
performance measures
•CSP-Forward checking and
• Flexibility and Intelligent agents
constraint propagation
•CSP-Intelligent backtracking
• Task environment and its properties
Rationality

• Rationality. Rationality is nothing but status of


being reasonable, sensible, and having good sense
of judgment.
• Rationality is concerned with expected actions and
results depending upon what the agent has
perceived.
• Rationality is a normative concept that stands for
acting based on logical reasoning.
• Performing actions with the aim of obtaining useful
information is an important part of rationality.
What is a Rational Agent?

• A rational agent is an agent that behaves logically and does the right
things.
• In artificial intelligence and even in other disciplines like economics,
game theory, decision theory, a rational agent is an agent that chooses to
perform an action which leads to an expected optimal result.
• Along with all sensors and actuators, the agent is provided with complete
specifications of the problem and the task to be performed.
• Based on this information, the agent performs the most logical actions.
• Rational actions are those which can make an agent the most successful.
• A rational agent provides or makes rational rather logical decisions.
• Typical examples of rational agent : A person, governing body, decision
authority, firm, machine or software.
What is Ideal Rational Agent?

An ideal rational agent is the one, which is capable of doing expected actions to
maximize its performance measure, on the basis of −
• Its percept sequence
• Its built-in knowledge base
Rationality of an agent depends on the following −
• The performance measures, which determine the degree of success.
• Agent’s Percept Sequence till now.
• The agent’s prior knowledge about the environment.
• The actions that the agent can carry out.
A rational agent always performs right action, where the right action
means the action that causes the agent to be most successful in the
given percept sequence. The problem the agent solves is characterized
by Performance Measure, Environment, Actuators, and Sensors
(PEAS).
Rational Agents

• What is rational depends on four things:


– Performance measure
– Percept sequence: everything agent has seen so far
– Knowledge agent has about environment
– Actions agent is capable of performing
• Ideal Rational Agent
– Does whatever action is expected to maximize its
performance measure, based on percept sequence and
built-in knowledge
Ideal Mapping

• Ideal mapping describes behavior of ideal


agents
The Mapping Table
• In most cases, mapping is explosively too

large to write down explicitly


• In some cases, mapping can be defined via a

specification
– Example: agent to sort a list of numbers
– Sample table for such an agent
– Lisp code
Unit 1 List of Topics
• Introduction to AI-AI techniques
• Problem solving with AI •Types of agents
•Other aspects of agents
• AI Models, Data acquisition and
learning aspects in AI •Constraint satisfaction
• Problem solving- Problem solving problems(CSP)
process, Formulating problems •Crypto arithmetic puzzles

• Problem types and characteristics •CSP as a search


• Problem space and search problem-constrains and
representation
• Intelligent agent •CSP-Backtracking, Role of
• Rationality and Rational agent with heuristic
performance measures
•CSP-Forward checking and
• Flexibility and Intelligent agents
constraint propagation
•CSP-Intelligent backtracking
• Task environment and its properties
Real-world Problems

Example of rational action performed by any intelligent


agent:
Automated Taxi Driver:
Performance Measure: Safe, fast, legal, comfortable
trip, maximize profits.
Environment: Roads, other traffic, customers.
Actuators: Steering wheel, accelerator, brake, signal,
horn.
Sensors: Cameras, sonar, speedometer, GPS,
odometer, engine sensors, keyboard.
Concept of Rationality

• Rational agent
● One that does the right thing
● = every entry in the table for the agent
function is correct (rational).
• What is correct?
● The actions that cause the agent to be most
successful
● So we need ways to measure success.
Performance measure

• Performance measure
● An objective function that determines
● How the agent does successfully
● E.g., 90% or 30% ?
• An agent, based on its percepts
● action sequence :
if desirable, it is said to be performing well.
● No universal performance measure for all
agents
Performance measure

• A general rule:
● Design performance measures according to
● What one actually wants in the environment
● Rather than how one thinks the agent should
behave
• E.g., in vacuum-cleaner world
● We want the floor clean, no matter how the
agent behave
● We don’t restrict how the agent behaves
Example of a rational agent

• Performance measure
● Awards one point for each clean square
● at each time step, over 10000 time steps
• Prior knowledge about the environment
● The geography of the environment
● Only two squares
● The effect of the actions
Example of a rational agent

• Actions that can perform


● Left, Right, Suck and NoOp
• Percept sequences
● Where is the agent?
● Whether the location contains dirt?

• Under this circumstance, the agent is


rational.
Omniscience

• An omniscient agent
● Knows the actual outcome of its actions in
advance
● No other possible outcomes
● However, impossible in real world
• An example
● crossing a street but died of the fallen
cargo door from 33,000ft irrational?
Omniscience

• Based on the circumstance, it is rational.


• As rationality maximizes
● Expected performance
• Perfection maximizes
● Actual performance
• Hence rational agents are not omniscient.
Learning

• Does a rational agent depend on only


current percept?
● No, the past percept sequence should also be
used
● This is called learning
● After experiencing an episode, the agent
● should adjust its behaviors to perform better for
the same job next time.
Autonomy

• If an agent just relies on the prior knowledge of its


designer rather than its own percepts then the
agent lacks autonomy
A rational agent should be autonomous- it should
learn what it can to compensate for partial or
incorrect prior knowledge.
• E.g., a clock
● No input (percepts)
● Run only but its own algorithm (prior knowledge)
● No learning, no experience, etc.
Unit 1 List of Topics
•Flexibility and Intelligent agents
• Introduction to AI-AI techniques •Task environment and its
properties
• Problem solving with AI
•Types of agents
• AI Models, Data acquisition and •Other aspects of agents
learning aspects in AI
• Problem solving- Problem solving •Constraint satisfaction
process, Formulating problems problems(CSP)
•Crypto arithmetic puzzles

• Problem types and characteristics •CSP as a search problem-constrains


• Problem space and search and representation
•CSP-Backtracking, Role of heuristic
• Intelligent agent •CSP-Forward checking and
• Rationality and Rational agent constraint propagation
with performance measures •CSP-Intelligent backtracking
Intelligent Agents

• What is an agent ?
● An agent is anything that perceiving its
environment through sensors and acting upon
that environment through actuators
● Example:
● Human is an agent
● A robot is also an agent with cameras and motors
● A thermostat detecting room temperature.
Intelligent Agents
Diagram of an agent

What AI should fill


Simple Terms

• Percept
● Agent’s perceptual inputs at any given instant
• Percept sequence
● Complete history of everything that the agent has
ever perceived.
Agent function & program

• Agent’s behavior is mathematically


described by
● Agent function
● A function mapping any given percept
sequence to an action
• Practically it is described by
● An agent program
● The real implementation
Vacuum-cleaner world

• Perception: Clean or Dirty? where it is in?


• Actions: Move left, Move right, suck, do
nothing
Program implements the agent function tabulated in Fig.

Function Reflex-Vacuum-Agent([location,status]) return an


action
If status = Dirty then return Suck
else if location = A then return Right
else if location = B then return left
Unit 1 List of Topics
•Flexibility and Intelligent agents
• Introduction to AI-AI techniques •Task environment and its
properties
• Problem solving with AI
•Types of agents
• AI Models, Data acquisition and •Other aspects of agents
learning aspects in AI
• Problem solving- Problem solving •Constraint satisfaction
process, Formulating problems problems(CSP)
•Crypto arithmetic puzzles

• Problem types and characteristics •CSP as a search problem-constrains


• Problem space and search and representation
•CSP-Backtracking, Role of heuristic
• Intelligent agent •CSP-Forward checking and
• Rationality and Rational agent constraint propagation
with performance measures •CSP-Intelligent backtracking
Task environments

• Task environments are the problems


● While the rational agents are the solutions
• Specifying the task environment
● PEAS description as fully as possible
● Performance
● Environment
● Actuators
● Sensors
In designing an agent, the first step must always be to specify
the task environment as fully as possible.
• Use automated taxi driver as an example
Task environments

• Performance measure
● How can we judge the automated driver?
● Which factors are considered?
● getting to the correct destination
● minimizing fuel consumption
● minimizing the trip time and/or cost
● minimizing the violations of traffic laws
● maximizing the safety and comfort, etc.
Task environments

• Environment
● A taxi must deal with a variety of roads
● Traffic lights, other vehicles, pedestrians,
stray animals, road works, police cars, etc.
● Interact with the customer
Task environments

• Actuators (for outputs)


● Control over the accelerator, steering, gear
shifting and braking
● A display to communicate with the
customers
• Sensors (for inputs)
● Detect other vehicles, road situations
● GPS (Global Positioning System) to know
where the taxi is
● Many more devices are necessary
Task environments

• A sketch of automated taxi driver


Properties of task environments

• Fully observable vs. Partially observable


● If an agent’s sensors give it access to the
complete state of the environment at each point
in time then the environment is effectively and
fully observable
● if the sensors detect all aspects
● That are relevant to the choice of action
Properties of task environments

• Partially observable
An environment might be Partially observable
because of noisy and inaccurate sensors or
because parts of the state are simply missing
from the sensor data.
Example:
● A local dirt sensor of the cleaner cannot tell
● Whether other squares are clean or not
Properties of task environments

• Deterministic vs. stochastic


● next state of the environment Completely
determined by the current state and the actions
executed by the agent, then the environment is
deterministic, otherwise, it is Stochastic.
● Strategic environment: deterministic except for
actions of other agents
-Cleaner and taxi driver are:
●Stochastic because of some unobservable aspects noise or
unknown
Properties of task environments

• Episodic vs. sequential


● An episode = agent’s single pair of perception & action
● The quality of the agent’s action does not depend on
other episodes
●Every episode is independent of each other
● Episodic environment is simpler
●The agent does not need to think ahead
• Sequential
● Current action may affect all future decisions
-Ex. Taxi driving and chess.
Properties of task environments

• Static vs. dynamic


● A dynamic environment is always changing
over time
●E.g., the number of people in the street
● While static environment
●E.g., the destination
• Semidynamic
● environment is not changed over time
● but the agent’s performance score does
Properties of task environments

• Discrete vs. continuous


● If there are a limited number of distinct
states, clearly defined percepts and actions,
the environment is discrete
● E.g., Chess game
● Continuous: Taxi driving
Properties of task environments

• Single agent VS. multiagent


● Playing a crossword puzzle – single agent
● Chess playing – two agents
● Competitive multiagent environment
●Chess playing
● Cooperative multiagent environment
●Automated taxi driver
●Avoiding collision
Properties of task environments

• Known vs. unknown


This distinction refers not to the environment itslef but to
the agent’s (or designer’s) state of knowledge about the
environment.
-In known environment, the outcomes for all actions are
given. ( example: solitaire card games).
- If the environment is unknown, the agent will have to learn
how it works in order to make good decisions.( example:
new video game).
Examples of task environments
Unit 1 List of Topics
•Flexibility and Intelligent agents
• Introduction to AI-AI techniques •Task environment and its
properties
• Problem solving with AI
•Types of agents
• AI Models, Data acquisition and •Other aspects of agents
learning aspects in AI
• Problem solving- Problem solving •Constraint satisfaction
process, Formulating problems problems(CSP)
•Crypto arithmetic puzzles

• Problem types and characteristics •CSP as a search problem-constrains


• Problem space and search and representation
•CSP-Backtracking, Role of heuristic
• Intelligent agent •CSP-Forward checking and
• Rationality and Rational agent constraint propagation
with performance measures •CSP-Intelligent backtracking
Structure of agents

• Agent = architecture + program


● Architecture = some sort of computing device
(sensors + actuators)
● (Agent) Program = some function that
implements the agent mapping = “?”
● Agent Program = Job of AI
Agent programs

• Input for Agent Program


● Only the current percept
• Input for Agent Function
● The entire percept sequence
● The agent must remember all of them
• Implement the agent program as
● A look up table (agent function)
Agent programs

• Skeleton design of an agent program


Agent programs

• P = the set of possible percepts


• T= lifetime of the agent
● The total number of percepts it receives
• Size of the look up table
• Consider playing chess
● P =10, T=150
● Will require a table of at least 10150 entries
Agent programs

• Despite of huge size, look up table does what


we want.
• The key challenge of AI
● Find out how to write programs that, to the
extent possible, produce rational behavior
● From a small amount of code
● Rather than a large amount of table entries
● E.g., a five-line program of Newton’s Method
● V.s. huge tables of square roots, sine, cosine, …
Types of agent programs

• Four types
● Simple reflex agents
● Model-based reflex agents
● Goal-based agents
● Utility-based agents
Simple reflex agents

• It uses just condition-action rules


● The rules are like the form “if … then …”
● efficient but have narrow range of applicability
● Because knowledge sometimes cannot be stated
explicitly
● Work only
● if the environment is fully observable
Simple reflex agents
Simple reflex agents
A Simple Reflex Agent in Nature

percepts
(size, motion)

RULES:
(1) If small moving object,
then activate SNAP
(2) If large moving object,
then activate AVOID and inhibit SNAP
ELSE (not moving) then NOOP
needed for
completeness Action: SNAP or AVOID or
Model-based Reflex Agents

• For the world that is partially observable


● the agent has to keep track of an internal state
● That depends on the percept history
● Reflecting some of the unobserved aspects
● E.g., driving a car and changing lane
• Requiring two types of knowledge
● How the world evolves independently of the agent
● How the agent’s actions affect the world
Example Table Agent
With Internal State

IF THEN
Saw an object ahead, Go straight
and turned right, and
it’s now clear ahead
Saw an object Ahead, Halt
turned right, and object
ahead again
See no objects ahead Go straight

See an object ahead Turn randomly


Example Reflex Agent With Internal State:
Wall-Following

start

Actions: left, right, straight, open-door


Rules:
1. If open(left) & open(right) and open(straight) then
choose randomly between right and left
2. If wall(left) and open(right) and open(straight) then straight
3. If wall(right) and open(left) and open(straight) then straight
4. If wall(right) and open(left) and wall(straight) then left
5. If wall(left) and open(right) and wall(straight) then right
6. If wall(left) and door(right) and wall(straight) then open-door
7. If wall(right) and wall(left) and open(straight) then straight.
8. (Default) Move randomly
Model-based Reflex Agents

The agent is with memory


Model-based Reflex Agents
Goal-based agents

• Current state of the environment is always


not enough
• The goal is another issue to achieve
● Judgment of rationality / correctness
• Actions chosen goals, based on
● the current state
● the current percept
Goal-based agents

• Conclusion
● Goal-based agents are less efficient
● but more flexible
● Agent Different goals different tasks
● Search and planning
● two other sub-fields in AI
● to find out the action sequences to achieve its goal
Goal-based agents
Utility-based agents

• Goals alone are not enough


● to generate high-quality behavior
● E.g. meals in Canteen, good or not ?
• Many action sequences the goals
● some are better and some worse
● If goal means success,
● then utility means the degree of success (how
successful it is)
Utility-based agents(4)
Utility-based agents

• it is said state A has higher utility


● If state A is more preferred than others
• Utility is therefore a function
● that maps a state onto a real number
● the degree of success
Utility-based agents (3)

• Utility has several advantages:


● When there are conflicting goals,
● Only some of the goals but not all can be achieved
● utility describes the appropriate trade-off
● When there are several goals
● None of them are achieved certainly
● utility provides a way for the decision-making
Unit 1 List of Topics
•Flexibility and Intelligent agents
• Introduction to AI-AI techniques •Task environment and its
properties
• Problem solving with AI
•Types of agents
• AI Models, Data acquisition and •Other aspects of agents
learning aspects in AI
• Problem solving- Problem solving •Constraint satisfaction
process, Formulating problems problems(CSP)
•Crypto arithmetic puzzles

• Problem types and characteristics •CSP as a search problem-constrains


• Problem space and search and representation
•CSP-Backtracking, Role of heuristic
• Intelligent agent •CSP-Forward checking and
• Rationality and Rational agent constraint propagation
with performance measures •CSP-Intelligent backtracking
Learning Agents

• After an agent is programmed, can it work


immediately?
● No, it still need teaching
• In AI,
● Once an agent is done
● We teach it by giving it a set of examples
● Test it by using another set of examples
• We then say the agent learns
● A learning agent
Learning Agents

• Four conceptual components


● Learning element
● Making improvement
● Performance element
● Selecting external actions
● Critic
● Tells the Learning element how well the agent is doing with
respect to fixed performance standard.
(Feedback from user or examples, good or not?)
● Problem generator
● Suggest actions that will lead to new and informative
experiences.
Learning Agents
Unit 1 List of Topics
•Flexibility and Intelligent agents
• Introduction to AI-AI techniques •Task environment and its
properties
• Problem solving with AI
•Types of agents
• AI Models, Data acquisition and •Other aspects of agents
learning aspects in AI
• Problem solving- Problem solving •Constraint satisfaction
process, Formulating problems problems(CSP)
•Crypto arithmetic puzzles

• Problem types and characteristics •CSP as a search problem-constrains


• Problem space and search and representation
•CSP-Backtracking, Role of heuristic
• Intelligent agent •CSP-Forward checking and
• Rationality and Rational agent constraint propagation
with performance measures •CSP-Intelligent backtracking
Constraint satisfaction problems (CSPs)

• CSP:
– state is defined by variables Xi with values from domain Di
– goal test is a set of constraints specifying allowable combinations of
values for subsets of variables

• Allows useful general-purpose algorithms with more power


than standard search algorithms

209
Unit 1 List of Topics
•Flexibility and Intelligent agents
• Introduction to AI-AI techniques •Task environment and its
properties
• Problem solving with AI
•Types of agents
• AI Models, Data acquisition and •Other aspects of agents
learning aspects in AI
• Problem solving- Problem solving •Constraint satisfaction
process, Formulating problems problems(CSP)
•Crypto arithmetic puzzles

• Problem types and characteristics •CSP as a search problem-constrains


• Problem space and search and representation
•CSP-Backtracking, Role of heuristic
• Intelligent agent •CSP-Forward checking and
• Rationality and Rational agent constraint propagation
with performance measures •CSP-Intelligent backtracking
Example: Map-Coloring

• Variables WA, NT, Q, NSW, V, SA, T

• Domains Di = {red,green,blue}

• Constraints: adjacent regions must have different colors


• e.g., WA ≠ NT
211
Example: Map-Coloring

• Solutions are complete and consistent assignments,


e.g., WA = red, NT = green,Q = red,NSW = green,V =
red,SA = blue,T = green

212
Constraint graph

• Binary CSP: each constraint relates two variables


• Constraint graph: nodes are variables, arcs are constraints

213
Varieties of CSPs

• Discrete variables
– finite domains:
• n variables, domain size d O(d n) complete assignments
• e.g., 3-SAT (NP-complete)
– infinite domains:
• integers, strings, etc.
• e.g., job scheduling, variables are start/end days for each job
• need a constraint language, e.g., StartJob1 + 5 ≤ StartJob3

• Continuous variables
– e.g., start/end times for Hubble Space Telescope observations
– linear constraints solvable in polynomial time by linear programming

214
Varieties of constraints

• Unary constraints involve a single variable,


– e.g., SA ≠ green

• Binary constraints involve pairs of variables,


– e.g., SA ≠ WA

• Higher-order constraints involve 3 or more


variables,
– e.g., SA ≠ WA ≠ NT

215
Unit 1 List of Topics
•Flexibility and Intelligent agents
• Introduction to AI-AI techniques •Task environment and its
properties
• Problem solving with AI
•Types of agents
• AI Models, Data acquisition and •Other aspects of agents
learning aspects in AI
• Problem solving- Problem solving •Constraint satisfaction
process, Formulating problems problems(CSP)
•Crypto arithmetic puzzles

• Problem types and characteristics •CSP as a search problem-constrains


• Problem space and search and representation
•CSP-Backtracking, Role of heuristic
• Intelligent agent •CSP-Forward checking and
• Rationality and Rational agent constraint propagation
with performance measures •CSP-Intelligent backtracking
Cryptarithmetic

• SEND+MORE = MONEY
• Initial State: no variable has a value
• Operators:
– assign a variable a digit (0..9) (no dups)
– unassign a variable
• Goal: arithmetic statement is true.
• Example of Constraint Satisfaction Problem
Cryptarithmetic , An example
Rule 1 : 0 to 9
Rule 2: 1 Letter no 2 nos
1 no no 2 letters
Rule 3: maximum carry over is one

M = Need a carry 1 NC
Possibility 1
M=1
S E N D
4th column:
O:

10 to 19 possible except number 11. Bz O Will


Get value 1 which is already assigned for M. M O R E
So possibilities are

10, 12 to 19
1
NC : No CARRY M O N E Y
1
Assume S = 9:

W/O Carry:
S + M = 10 + O
1 NC
9 + 1 = 10
With Carry:
C+S+ M = 10 + O
S E N D
1+ 9 + 1 = 10 + O
-------------------------------
Assume S = 8:
w/o Carry : M O R E
8+ 1 = 10 + O
1 0
With Carry:
1+8+1 = 10 + O M O N E Y

1 0
3rd Column:

w/o carry:
E+O=N
E + 0 = N (Any number + 0 = same num) 1 1 NC
So this not allowed because both N and O
Will get same number) S E N D
With Carry:

C+ E + O = N
M O R E
1+ E + 0 = N

1+ E = N ------ Eq. 1
1 0

M O N E Y

1 0
2nd
Column:
With Carry:
C+N+R = 10+E
1+N+R = 10+ E ------- Eq.2
Sub Eq.1 in eq. 2
1+1+E+R = 10 +E
R=8 1 NC 1 NC
Without Carry:
N+R = 10+E S E N D
1+E +R = 10+E
R=9

Now in 3rd column, lets finalize the value of E.


If E = 9 (highest possible no), then 1+9 = 10 which
makes N as ‘0’ . But ‘0’ already allotted for
M O R E
ALPHABET ‘O’. So E cannot be 9.
1 0 8
If E = 8 (Next highest possible no),
then 1 + 8 = 9 (A single digit no) .
M O N E Y
SO For E, any value 8 till 2 ( 1 and 0 already allotted) is
possible. In that case, in 4th column No Carry (NC) will come.
1 0
Coming to 4th column again to find S:

Since no carry for 4th column, S should be 9 ,not 8. 1 NC 1 NC


Since S + M = 10 + O, if we put S = 8, we will get S E N D
8 + 1 = 10 + 0 [which is only 9 not 10,
So S=9 is fixed] 9
Now, we will get a two digit number
(i,e) 10 as result and carry will be
M O R E
forwarded to next (5th ) column. 1 0 8
M O N E Y
1 0
1st
column:

D + E = 10 + Y

10
11 1 NC 1 1 NC
12 3+9, 4+8, 5+7
13 1+12, 2+11, 3+10, 4+9, 5+8, 6+7
14
S E N D
15
16
9 5 6 7
17
18 M O R E
19
All other combinations will be ruled out since its 1 0 8 5
not satisfying constraints. So finally we will get
5+7 M O N E Y
6 +7
1 0 6 5 2
1st
column:
D + E = 10 + Y
Two possibilities : 5+7, 6 +7
Common number : 7
Now we want to check, value 7 should be assigned
to either D or E.
1 NC 1 1 NC
If we take E = 7, in 3rd column we will get
1+7+0 = 8 (But 8 already allotted to R) S E N D
So D =7 is fixed.

Now for E, we want to check, whether it can be be 9 5 6 7


assigned with 5 or 6.
If we put E = 6, in 3rd column we will get M O R E
1+6+0 = 7 (But 7 already allotted to D)
So E = 5 is fixed. 1 0 8 5
Now 1st column is filled which gives Y = 2 3rd column
Is also filled which gives N = 6.
M O N E Y
1 0 6 5 2
Example: Cryptarithmetic

• Variables: F T U W R O X 1 X 2 X3
• Domains: {0,1,2,3,4,5,6,7,8,9} {0,1}
• Constraints: Alldiff (F,T,U,W,R,O)
– O + O = R + 10 · X1
– X1 + W + W = U + 10 · X2
– X2 + T + T = O + 10 · X3
– X3 = F, T ≠ 0, F ≠ 0
225
Real-world CSPs

226
Unit 1 List of Topics
•Flexibility and Intelligent agents
• Introduction to AI-AI techniques •Task environment and its
properties
• Problem solving with AI
•Types of agents
• AI Models, Data acquisition and •Other aspects of agents
learning aspects in AI
• Problem solving- Problem solving •Constraint satisfaction
process, Formulating problems problems(CSP)
•Crypto arithmetic puzzles

• Problem types and characteristics •CSP as a search problem-constrains


• Problem space and search and representation
•CSP-Backtracking, Role of heuristic
• Intelligent agent •CSP-Forward checking and
• Rationality and Rational agent constraint propagation
with performance measures •CSP-Intelligent backtracking
CSP – As a search problem
• Initial state
• Successor function
• Goal test
• Path cost

CSP Solution : Complete assignment with no


exception
Representation as a Search
problem
Search tree generation : Snapshot
BACKTRACKING SEARCH FOR CSP
1 NC 1 1

S E N D

9 5 6 7

M O R E

1 0 8 5

M O N E Y

1 0 6 5 2
Unit - 2
Searching Techniques
17-03-2021 18CSC305J_AI_UNIT3 1
Knowledge and Reasoning
Table of Contents
• Knowledge and reasoning-Approaches and issues of knowledge reasoning-Knowledge
base agents
• Logic Basics-Logic-Propositional logic-syntax ,semantics and inferences-Propositional
logic- Reasoning patterns
• Unification and Resolution-Knowledge representation using rules-Knowledge
representation using semantic nets
• Knowledge representation using frames-Inferences-
• Uncertain Knowledge and reasoning-Methods-Bayesian probability and belief network
• Probabilistic reasoning-Probabilistic reasoning over time-Probabilistic reasoning over time
• Other uncertain techniques-Data mining-Fuzzy logic-Dempster -shafer theory

17-03-2021 18CSC305J_AI_UNIT3 2
Knowledge Representation & Reasoning
• The second most important concept in AI
• If we are going to act rationally in our environment, then we must have some way of
describing that environment and drawing inferences from that representation.
• how do we describe what we know about the world ?
• how do we describe it concisely ?
• how do we describe it so that we can get hold of the right piece of knowledge when
we need it ?
• how do we generate new pieces of knowledge ?
• how do we deal with uncertain knowledge ?
Knowledge Representation & Reasoning
Knowledge

Declarative Procedural
• Declarative knowledge deals with factoid questions (what is the capital of
India? Etc.)
• Procedural knowledge deals with “How”
• Procedural knowledge can be embedded in declarative knowledge
Planning
Given a set of goals, construct a sequence of actions that achieves
those goals:
• often very large search space
• but most parts of the world are independent of most other
parts
• often start with goals and connect them to actions
• no necessary connection between order of planning and order
of execution
• what happens if the world changes as we execute the plan
and/or our actions don’t produce the expected results?
Learning

• If a system is going to act truly appropriately, then it must


be able to change its actions in the light of experience:
• how do we generate new facts from old ?
• how do we generate new concepts ?
• how do we learn to distinguish different situations in
new environments ?
What is knowledge representation?

•Knowledge representation and reasoning (KR, KRR) is the part of Artificial


intelligence which concerned with AI agents thinking and how thinking contributes
to intelligent behavior of agents.
•It is responsible for representing information about the real world so that a
computer can understand and can utilize this knowledge to solve the complex real
world problems such as diagnosis a medical condition or communicating with
humans in natural language.
•It is also a way which describes how we can represent knowledge in artificial
intelligence. Knowledge representation is not just storing data into some database,
but it also enables an intelligent machine to learn from that knowledge and
experiences so that it can behave intelligently like a human.
17-03-2021 18CSC305J_AI_UNIT3 7
What to Represent?
Following are the kind of knowledge which needs to be represented in AI systems:
•Object: All the facts about objects in our world domain. E.g., Guitars contains
strings, trumpets are brass instruments.
•Events: Events are the actions which occur in our world.
•Performance: It describe behavior which involves knowledge about how to do
things.
•Meta-knowledge: It is knowledge about what we know.
•Facts: Facts are the truths about the real world and what we represent.
•Knowledge-Base: The central component of the knowledge-based agents is the
knowledge base. It is represented as KB. The Knowledgebase is a group of the
Sentences (Here, sentences are used as a technical term and not identical with the
English language).
17-03-2021 18CSC305J_AI_UNIT3 8
Approaches to knowledge Representation
• Representational adequacy the ability to represent all of the kinds of
knowledge that are needed in that domain.
• Inferential Adequacy: - the ability to manipulate the representation structures
in such a way as to derive new structures corresponding to new knowledge
inferred from ol.
• Inferential Efficiency: - the ability to incorporate into the knowledge structure
additional information that can be used to focus the attention of the inference
mechanism in the most promising directions.
• Acquisitioned Efficiency: - the ability to acquire new information easily. The
simplest case involves direct insertion by a person of new knowledge into the
database.
Knowledge Representation Issues
• It becomes clear that particular knowledge representation models allow for more specific more powerful
problem solving mechanisms that operate on them.
• Examine specific techniques that can be used for representing & manipulating knowledge within programs.
• Representation & Mapping
• Facts :- truths in some relevant world
• These are the things we want to represent.
• Representations of facts in some chosen formalism.
• Things we are actually manipulating. Structuring these entities is as two levels.
• The knowledge level, at which facts concluding each agents behavior & current goals are described.
Facts Internal Representations

English understanding English generation


English Representations
Knowledge and Reasoning
Table of Contents
• Knowledge and reasoning-Approaches and issues of knowledge reasoning-Knowledge
base agents
• Logic Basics-Logic-Propositional logic-syntax ,semantics and inferences-Propositional
logic- Reasoning patterns
• Unification and Resolution-Knowledge representation using rules-Knowledge
representation using semantic nets
• Knowledge representation using frames-Inferences-
• Uncertain Knowledge and reasoning-Methods-Bayesian probability and belief network
• Probabilistic reasoning-Probabilistic reasoning over time-Probabilistic reasoning over
time
• Other uncertain techniques-Data mining-Fuzzy logic-Dempster -shafer theory
17-03-2021 18CSC305J_AI_UNIT3 11
A KNOWLEDGE-BASED AGENT
• A knowledge-based agent includes a knowledge base and an inference system.
• A knowledge base is a set of representations of facts of the world.
• Each individual representation is called a sentence.
• The sentences are expressed in a knowledge representation language.
• The agent operates as follows:
1. It TELLs the knowledge base what it perceives.
2. It ASKs the knowledge base what action it should perform.
3. It performs the chosen action.

12
17-03-2021 18CSC305J_AI_UNIT3
Requirements for a Knowledge-Based Agent
1. \what it already knows" [McCarthy '59]
A knowledge base of beliefs.
2. \it must rst be capable of being told" [McCarthy '59]
A way to put new beliefs into the knowledge base.
3. \automatically deduces for itself a suciently wide class of
immediate consequences" [McCarthy '59]
A reasoning mechanism to derive new beliefs from ones already
in the knowledge base.

17-03-2021 18CSC305J_AI_UNIT3 13
ARCHITECTURE OF A KNOWLEDGE-BASED
AGENT
• Knowledge Level.
• The most abstract level: describe agent by saying what it knows.
• Example: A taxi agent might know that the Golden Gate Bridge connects San
Francisco with the Marin County.
• Logical Level.
• The level at which the knowledge is encoded into sentences.
• Example: Links(GoldenGateBridge, SanFrancisco, MarinCounty).
• Implementation Level.
• The physical representation of the sentences in the logical level.
• Example: ‘(links goldengatebridge sanfrancisco marincounty)

14
17-03-2021 18CSC305J_AI_UNIT3
THE WUMPUS WORLD ENVIRONMENT
• The Wumpus computer game
• The agent explores a cave consisting of rooms connected by passageways.
• Lurking somewhere in the cave is the Wumpus, a beast that eats any agent that
enters its room.
• Some rooms contain bottomless pits that trap any agent that wanders into the
room.
• Occasionally, there is a heap of gold in a room.
• The goal is to collect the gold and exit the world without being eaten

15
17-03-2021 18CSC305J_AI_UNIT3
A TYPICAL WUMPUS WORLD
• The agent always starts in the
field [1,1].
• The task of the agent is to
find the gold, return to the
field [1,1] and climb out of
the cave.

17-03-2021
16 18CSC305J_AI_UNIT3
AGENT IN A WUMPUS WORLD: PERCEPTS
• The agent perceives
• a stench in the square containing the Wumpus and in the adjacent squares (not
diagonally)
• a breeze in the squares adjacent to a pit
• a glitter in the square where the gold is
• a bump, if it walks into a wall
• a woeful scream everywhere in the cave, if the wumpus is killed
• The percepts are given as a five-symbol list. If there is a stench and a breeze, but no
glitter, no bump, and no scream, the percept is
[Stench, Breeze, None, None, None]

17
17-03-2021 18CSC305J_AI_UNIT3
WUMPUS WORLD ACTIONS
• go forward
• turn right 90 degrees
• turn left 90 degrees
• grab: Pick up an object that is in the same square as the agent
• shoot: Fire an arrow in a straight line in the direction the agent is facing. The arrow
continues until it either hits and kills the wumpus or hits the outer wall. The agent
has only one arrow, so only the first Shoot action has any effect
• climb is used to leave the cave. This action is only effective in the start square
• die: This action automatically and irretrievably happens if the agent enters a square
with a pit or a live wumpus

18
17-03-2021 18CSC305J_AI_UNIT3
ILLUSTRATIVE EXAMPLE: WUMPUS WORLD
•Performance measure
• gold +1000,
• death -1000
(falling into a pit or being eaten by the wumpus)
• -1 per step, -10 for using the arrow
•Environment
• Rooms / squares connected by doors.
• Squares adjacent to wumpus are smelly
• Squares adjacent to pit are breezy
• Glitter iff gold is in the same square
• Shooting kills wumpus if you are facing it
• Shooting uses up the only arrow
• Grabbing picks up gold if in same square
• Releasing drops the gold in same square
• Randomly generated at start of game. Wumpus only senses current room.
•Sensors: Stench, Breeze, Glitter, Bump, Scream [perceptual inputs]
•Actuators: Left turn, Right turn, Forward, Grab, Release, Shoot
17-03-2021 18CSC305J_AI_UNIT3 19
WUMPUS WORLD CHARACTERIZATION
Fully Observable No – only local perception

Deterministic Yes – outcomes exactly specified

Static Yes – Wumpus and Pits do not move

Discrete Yes

Single-agent? Yes – Wumpus is essentially a “natural feature.”

17-03-2021 18CSC305J_AI_UNIT3 20
EXPLORING A WUMPUS WORLD
The knowledge base of the agent
consists of the rules of the
Wumpus world plus the percept
“nothing” in [1,1]

Boolean percept
feature values:
<0, 0, 0, 0, 0>

None, none, none, none, none

Stench, Breeze, Glitter, Bump, Scream

17-03-2021 18CSC305J_AI_UNIT3 21
EXPLORING A WUMPUS WORLD

T=0 The KB of the agent consists of


None, none, none, none, none the rules of the Wumpus world plus
the percept “nothing” in [1,1].
Stench, Breeze, Glitter, Bump, Scream By inference, the agent’s knowledge
base also has the information that
World “known” to agent [2,1] and [1,2] are okay.
at time = 0. Added as propositions.

17-03-2021 18CSC305J_AI_UNIT3 22
EXPLORING A WUMPUS WORLD
T=0 T=1

P?

A/B P?
V

None, breeze, none, none, none


None, none, none, none, none A – agent
V – visited
Stench, Breeze, Glitter, Bump, Scream B - breeze
Where next? @ T = 1 What follows?
Pit(2,2) or Pit(3,1)
17-03-2021 18CSC305J_AI_UNIT3 23
EXPLORING A WUMPUS WORLD
4 T=3
W
3 S
P
S P?
2
P
1 P?

1 2 3 4
Stench, none, none, none, none

Stench, Breeze, Glitter, Bump, Scream


Where is Wumpus? Wumpus cannot be in (1,1) or in (2,2) (Why?) Wumpus in (1,3)
Not breeze in (1,2)  no pit in (2,2); but we know there is
pit in (2,2) or (3,1)  pit in (3,1)

17-03-2021 18CSC305J_AI_UNIT3 24
EXPLORING A WUMPUS WORLD
We reasoned about the possible states the Wumpus world can be in,
given our percepts and our knowledge of the rules of the Wumpus
world.
I.e., the content of KB at T=3.
W
What follows is what holds true in all those worlds that satisfy what is
known at that time T=3 about the particular Wumpus world we are in.
P
Example property: P_in_(3,1)

Models(KB) Models(P_in_(3,1)) P

Essence of logical reasoning:


Given all we know, Pit_in_(3,1) holds.
(“The world cannot be different.”)
17-03-2021 18CSC305J_AI_UNIT3 25
NO INDEPENDENT ACCESS TO THE WORLD
• The reasoning agent often gets its knowledge about the facts of the world as a sequence of
logical sentences and must draw conclusions only from them without independent access to
the world.
• Thus it is very important that the agent’s reasoning is sound!

26
17-03-2021 18CSC305J_AI_UNIT3
SUMMARY OF KNOWLEDGE BASED AGENTS
• Intelligent agents need knowledge about the world for making good decisions.
• The knowledge of an agent is stored in a knowledge base in the form of sentences in a
knowledge representation language.
• A knowledge-based agent needs a knowledge base and an inference mechanism. It
operates by storing sentences in its knowledge base, inferring new sentences with the
inference mechanism, and using them to deduce which actions to take.
• A representation language is defined by its syntax and semantics, which specify the
structure of sentences and how they relate to the facts of the world.
• The interpretation of a sentence is the fact to which it refers. If this fact is part of the
actual world, then the sentence is true.

27
17-03-2021 18CSC305J_AI_UNIT3
Knowledge and Reasoning
Table of Contents
• Knowledge and reasoning-Approaches and issues of knowledge reasoning-Knowledge base
agents
• Logic Basics-Logic-Propositional logic-syntax ,semantics and inferences-Propositional logic-
Reasoning patterns
• Unification and Resolution-Knowledge representation using rules-Knowledge representation
using semantic nets
• Knowledge representation using frames-Inferences-
• Uncertain Knowledge and reasoning-Methods-Bayesian probability and belief network
• Probabilistic reasoning-Probabilistic reasoning over time-Probabilistic reasoning over time
• Other uncertain techniques-Data mining-Fuzzy logic-Dempster -shafer theory

17-03-2021 18CSC305J_AI_UNIT3 28
What is a Logic?
• A language with concrete rules
• No ambiguity in representation (may be other errors!)
• Allows unambiguous communication and processing
• Very unlike natural languages e.g. English
• Many ways to translate between languages
• A statement can be represented in different logics
• And perhaps differently in same logic
• Expressiveness of a logic
• How much can we say in this language?
• Not to be confused with logical reasoning
• Logics are languages, reasoning is a process (may use logic)

18CSC305J_AI_UNIT3 29
17-03-2021
Syntax and Semantics
• Syntax
• Rules for constructing legal sentences in the logic
• Which symbols we can use (English: letters, punctuation)
• How we are allowed to combine symbols
• Semantics
• How we interpret (read) sentences in the logic
• Assigns a meaning to each sentence
• Example: “All lecturers are seven foot tall”
• A valid sentence (syntax)
• And we can understand the meaning (semantics)
• This sentence happens to be false (there is a counterexample)
Propositional Logic
• Syntax
• Propositions, e.g. “it is wet”
• Connectives: and, or, not, implies, iff (equivalent)

• Brackets, T (true) and F (false)


• Semantics (Classical AKA Boolean)
• Define how connectives affect truth
• “P and Q” is true if and only if P is true and Q is true
• Use truth tables to work out the truth of statements
Predicate Logic
• Propositional logic combines atoms
• An atom contains no propositional connectives
• Have no structure (today_is_wet, john_likes_apples)
• Predicates allow us to talk about objects
• Properties: is_wet(today)
• Relations: likes(john, apples)
• True or false
• In predicate logic each atom is a predicate
• e.g. first order logic, higher-order logic
First Order Logic

• More expressive logic than propositional


• Used in this course (Lecture 6 on representation in FOL)
• Constants are objects: john, apples
• Predicates are properties and relations:
• likes(john, apples)
• Functions transform objects:
• likes(john, fruit_of(apple_tree))
• Variables represent any object: likes(X, apples)
• Quantifiers qualify values of variables
• True for all objects (Universal): X. likes(X, apples)
• Exists at least one object (Existential): X. likes(X, apples)
Example: FOL Sentence
• “Every rose has a thorn”

• For all X
• if (X is a rose)
• then there exists Y
• (X has Y) and (Y is a thorn)
Example: FOL Sentence
• “On Mondays and Wednesdays I go to John’s house for dinner”

 Note the change from “and” to “or”


– Translating is problematic
Higher Order Logic
• More expressive than first order
• Functions and predicates are also objects
• Described by predicates: binary(addition)
• Transformed by functions: differentiate(square)
• Can quantify over both
• E.g. define red functions as having zero at 17

• Much harder to reason with


Beyond True and False
• Multi-valued logics
• More than two truth values
• e.g., true, false & unknown
• Fuzzy logic uses probabilities, truth value in [0,1]
• Modal logics
• Modal operators define mode for propositions
• Epistemic logics (belief)
• e.g. p (necessarily p), p (possibly p), …
• Temporal logics (time)
• e.g. p (always p), p (eventually p), …
Knowledge and Reasoning
Table of Contents
• Knowledge and reasoning-Approaches and issues of knowledge reasoning-
Knowledge base agents
• Logic Basics-Logic-Propositional logic-syntax ,semantics and inferences-
Propositional logic- Reasoning patterns
• Unification and Resolution-Knowledge representation using rules-Knowledge
representation using semantic nets
• Knowledge representation using frames-Inferences-
• Uncertain Knowledge and reasoning-Methods-Bayesian probability and belief
network
• Probabilistic reasoning-Probabilistic reasoning over time-Probabilistic
reasoning over time
• Other uncertain techniques-Data mining-Fuzzy logic-Dempster -shafer theory
17-03-2021 18CSC305J_AI_UNIT3 38
Knowledge and Reasoning
Table of Contents
• Knowledge and reasoning-Approaches and issues of knowledge reasoning-
Knowledge base agents
• Logic Basics-Logic-Propositional logic-syntax ,semantics and inferences-
Propositional logic- Reasoning patterns
• Unification and Resolution-Knowledge representation using rules-Knowledge
representation using semantic nets
• Knowledge representation using frames-Inferences-
• Uncertain Knowledge and reasoning-Methods-Bayesian probability and belief
network
• Probabilistic reasoning-Probabilistic reasoning over time-Probabilistic
reasoning over time
• Other uncertain techniques-Data mining-Fuzzy logic-Dempster -shafer theory
17-03-2021 18CSC305J_AI_UNIT3 39
Propositional logic
• Propositional logic consists of:
• The logical values true and false (T and F)
• Propositions: “Sentences,” which
• Are atomic (that is, they must be treated as indivisible units, with
no internal structure), and
• Have a single logical value, either true or false
• Operators, both unary and binary; when applied to logical values, yield
logical values
• The usual operators are and, or, not, and implies

40
17-03-2021 18CSC305J_AI_UNIT3
Truth tables

• Logic, like arithmetic, has operators, which apply to one, two, or more
values (operands)
• A truth table lists the results for each possible arrangement of operands
• Order is important: x op y may or may not give the same result as y op x
• The rows in a truth table list all possible sequences of truth values for n
operands, and specify a result for each sequence
• Hence, there are 2n rows in a truth table for n operands

41
17-03-2021 18CSC305J_AI_UNIT3
Unary operators
• There are four possible unary operators:
X Identity, (X)
X Constant true, (T) T T
T T F F
F T
X Negation, ¬X
X Constant false, (F)
T F
T F
F T
F F
• Only the last of these (negation) is widely used (and has a symbol,¬ ,for the operation
42
17-03-2021 18CSC305J_AI_UNIT3
Combined tables for unary operators

X Constant T Constant F Identity ¬X


T T F T F
F T F F T

43
Binary operators
• There are sixteen possible binary operators:

X Y
T T T T T T T T T T F F F F F F F F
T F T T T T F F F F T T T T F F F F
F T T T F F T T F F T T F F T T F F
F F T F T F T F T F T F T F T F T F

• All these operators have names, but I haven’t tried to fit them in
• Only a few of these operators are normally used in logic
44
17-03-2021 18CSC305J_AI_UNIT3
Useful binary operators
• Here are the binary operators that are traditionally used:

AND OR IMPLIES BICONDITIONAL


X Y XY XY XY XY
T T T T T T
T F F T F F
F T F T T F
F F F F T T

• Notice in particular that material implication () only approximately means the same as the
English word “implies”
• All the other operators can be constructed from a combination of these (along with unary
not,
45
¬)
17-03-2021 18CSC305J_AI_UNIT3
Logical expressions
• All logical expressions can be computed with some combination of and (),
or (), and not () operators
• For example, logical implication can be computed this way:

X Y X X  Y XY
T T F T T
T F F F F
F T T T T
F F T T T
• Notice that X  Y is equivalent to X  Y
46
17-03-2021 18CSC305J_AI_UNIT3
Another example
• Exclusive or (xor) is true if exactly one of its operands is true

X Y X Y X  Y X  Y (XY)(XY) X xor Y
T T F F F F F F
T F F T F T T T
F T T F T F T T
F F T T F F F F

• Notice that (XY)(XY) is equivalent to X xor Y

47
17-03-2021 18CSC305J_AI_UNIT3
World
• A world is a collection of prepositions and logical expressions relating those
prepositions
• Example:
• Propositions: JohnLovesMary, MaryIsFemale, MaryIsRich
• Expressions:
MaryIsFemale  MaryIsRich  JohnLovesMary
• A proposition “says something” about the world, but since it is atomic (you
can’t look inside it to see component parts), propositions tend to be very
specialized and inflexible

48
17-03-2021 18CSC305J_AI_UNIT3
Models
A model is an assignment of a truth value to each proposition, for example:
• JohnLovesMary: T, MaryIsFemale: T, MaryIsRich: F
• An expression is satisfiable if there is a model for which the expression is true
• For example, the above model satisfies the expression
MaryIsFemale  MaryIsRich  JohnLovesMary
• An expression is valid if it is satisfied by every model
• This expression is not valid:
MaryIsFemale  MaryIsRich  JohnLovesMary
because it is not satisfied by this model:
JohnLovesMary: F, MaryIsFemale: T, MaryIsRich: T
• But this expression is valid:
MaryIsFemale  MaryIsRich  MaryIsFemale
49
17-03-2021 18CSC305J_AI_UNIT3
Inference rules in propositional logic
• Here are just a few of the rules you can apply when reasoning in propositional logic:

50
17-03-2021 18CSC305J_AI_UNIT3
Implication elimination
• A particularly important rule allows you to get rid of
the implication operator,  :
• X  Y  X  Y
• We will use this later on as a necessary tool for
simplifying logical expressions
• The symbol  means “is logically equivalent to”

51
17-03-2021 18CSC305J_AI_UNIT3
Conjunction elimination
• Another important rule for simplifying logical expressions
allows you to get rid of the conjunction (and) operator,  :
• This rule simply says that if you have an and operator at the
top level of a fact (logical expression), you can break the
expression up into two separate facts:
• MaryIsFemale  MaryIsRich
• becomes:
• MaryIsFemale
• MaryIsRich

52
17-03-2021 18CSC305J_AI_UNIT3
Inference by computer
• To do inference (reasoning) by computer is basically a search process,
taking logical expressions and applying inference rules to them
• Which logical expressions to use?
• Which inference rules to apply?
• Usually you are trying to “prove” some particular statement
• Example:
• it_is_raining  it_is_sunny
• it_is_sunny  I_stay_dry
• it_is_rainy  I_take_umbrella
• I_take_umbrella  I_stay_dry
53• To prove: I_stay_dry
17-03-2021 18CSC305J_AI_UNIT3
Knowledge and Reasoning
Table of Contents
• Knowledge and reasoning-Approaches and issues of knowledge reasoning-
Knowledge base agents
• Logic Basics-Logic-Propositional logic-syntax ,semantics and inferences-
Propositional logic- Reasoning patterns
• Unification and Resolution-Knowledge representation using rules-Knowledge
representation using semantic nets
• Knowledge representation using frames-Inferences-
• Uncertain Knowledge and reasoning-Methods-Bayesian probability and belief
network
• Probabilistic reasoning-Probabilistic reasoning over time-Probabilistic
reasoning over time
• Other uncertain techniques-Data mining-Fuzzy logic-Dempster -shafer theory
17-03-2021 18CSC305J_AI_UNIT3 54
Reasoning Patterns
• Inference in propositional logic is NP-complete!
• However, inference in propositional logic shows
monoticity:
• Adding more rules to a knowledge base does not
affect earlier inferences
Forward and backward reasoning
• Situation: You have a collection of logical expressions (premises), and
you are trying to prove some additional logical expression (the
conclusion)
• You can:
• Do forward reasoning: Start applying inference rules to the logical
expressions you have, and stop if one of your results is the
conclusion you want
• Do backward reasoning: Start from the conclusion you want, and
try to choose inference rules that will get you back to the logical
expressions you have
• With the tools we have discussed so far, neither is feasible
56
17-03-2021 18CSC305J_AI_UNIT3
Example
• Given:
• it_is_raining  it_is_sunny
• it_is_sunny  I_stay_dry
• it_is_raining  I_take_umbrella
• I_take_umbrella  I_stay_dry
• You can conclude:
• it_is_sunny  it_is_raining
• I_take_umbrella  it_is_sunny
• I_stay_dry  I_take_umbrella
• Etc., etc. ... there are just too many things you can conclude!
57
17-03-2021 18CSC305J_AI_UNIT3
Predicate calculus
• Predicate calculus is also known as “First Order Logic” (FOL)
• Predicate calculus includes:
• All of propositional logic
• Logical values true, false
• Variables x, y, a, b,...
• Connectives , , , , 
• Constants KingJohn, 2, Villanova,...
• Predicates Brother, >,...
• Functions Sqrt, MotherOf,...
• Quantifiers , 
58
17-03-2021 18CSC305J_AI_UNIT3
Constants, functions, and predicates
• A constant represents a “thing”--it has no truth value, and it
does not occur “bare” in a logical expression
• Examples: DavidMatuszek, 5, Earth, goodIdea
• Given zero or more arguments, a function produces a
constant as its value:
• Examples: motherOf(DavidMatuszek), add(2, 2),
thisPlanet()
• A predicate is like a function, but produces a truth value
• Examples: greatInstructor(DavidMatuszek),
59 isPlanet(Earth), greater(3, add(2, 2))
17-03-2021 18CSC305J_AI_UNIT3
Universal quantification
• The universal quantifier, , is read as “for each”
or “for every”
• Example: x, x2  0 (for all x, x2 is greater than or equal to zero)
• Typically,  is the main connective with :
x, at(x,Villanova)  smart(x)
means “Everyone at Villanova is smart”
• Common mistake: using  as the main connective with :
x, at(x,Villanova)  smart(x)
means “Everyone is at Villanova and everyone is smart”
• If there are no values satisfying the condition, the result is true
• Example: x, isPersonFromMars(x)  smart(x) is true
60
17-03-2021 18CSC305J_AI_UNIT3
Existential quantification
• The existential quantifier, , is read “for some” or “there exists”
• Example: x, x2 < 0 (there exists an x such that x2 is less than zero)
• Typically,  is the main connective with :
x, at(x,Villanova)  smart(x)
means “There is someone who is at Villanova and is smart”
• Common mistake: using  as the main connective with :
x, at(x,Villanova)  smart(x)
This is true if there is someone at Villanova who is smart...
...but it is also true if there is someone who is not at Villanova
By the rules of material implication, the result of F  T is T
61
17-03-2021 18CSC305J_AI_UNIT3
Properties of quantifiers
• x y is the same as y x
• x y is the same as y x

• x y is not the same as y x


• x y Loves(x,y)
• “There is a person who loves everyone in the world”
• More exactly: x y (person(x)  person(y)  Loves(x,y))
• y x Loves(x,y)
• “Everyone in the world is loved by at least one person”

• Quantifier duality: each can be expressed using the other


• x Likes(x,IceCream) x Likes(x,IceCream)
• x Likes(x,Broccoli) x Likes(x,Broccoli)

62
17-03-2021 18CSC305J_AI_UNIT3
Parentheses
• Parentheses are often used with quantifiers
• Unfortunately, everyone uses them differently, so don’t be upset at any
usage you see
• Examples:
• (x) person(x)  likes(x,iceCream)
• (x) (person(x)  likes(x,iceCream))
• (x) [ person(x)  likes(x,iceCream) ]
• x, person(x)  likes(x,iceCream)
• x (person(x)  likes(x,iceCream))
• I prefer parentheses that show the scope of the quantifier
• x (x > 0)  x (x < 0)
63
17-03-2021 18CSC305J_AI_UNIT3
More rules
• Now there are numerous additional rules we can apply!
• Here are two exceptionally important rules:
• x, p(x)  x, p(x)
“If not every x satisfies p(x), then there exists a x that does not satisfy
p(x)”
• x, p(x)  x, p(x)
“If there does not exist an x that satisfies p(x), then all x do not satisfy
p(x)”
• In any case, the search space is just too large to be feasible
• This was the case until 1970, when J. Robinson discovered resolution
64
17-03-2021 18CSC305J_AI_UNIT3
Knowledge and Reasoning
Table of Contents
• Knowledge and reasoning-Approaches and issues of knowledge reasoning-
Knowledge base agents
• Logic Basics-Logic-Propositional logic-syntax ,semantics and inferences-
Propositional logic- Reasoning patterns
• Unification and Resolution-Knowledge representation using rules-Knowledge
representation using semantic nets
• Knowledge representation using frames-Inferences-
• Uncertain Knowledge and reasoning-Methods-Bayesian probability and belief
network
• Probabilistic reasoning-Probabilistic reasoning over time-Probabilistic
reasoning over time
• Other uncertain techniques-Data mining-Fuzzy logic-Dempster -shafer theory
17-03-2021 18CSC305J_AI_UNIT3 65
Logic by computer was infeasible
• Why is logic so hard?
• You start with a large collection of facts (predicates)
• You start with a large collection of possible transformations (rules)
• Some of these rules apply to a single fact to yield a new fact
• Some of these rules apply to a pair of facts to yield a new fact
• So at every step you must:
• Choose some rule to apply
• Choose one or two facts to which you might be able to apply the rule
• If there are n facts
• There are n potential ways to apply a single-operand rule
• There are n * (n - 1) potential ways to apply a two-operand rule
• Add the new fact to your ever-expanding fact base
66
17-03-2021 18CSC305J_AI_UNIT3
• The search space is huge!
The magic of resolution
• Here’s how resolution works:
• You transform each of your facts into a particular form, called a clause
(this is the tricky part)
• You apply a single rule, the resolution principle, to a pair of clauses
• Clauses are closed with respect to resolution--that is, when you
resolve two clauses, you get a new clause
• You add the new clause to your fact base
• So the number of facts you have grows linearly
• You still have to choose a pair of facts to resolve
• You never have to choose a rule, because there’s only one

67
17-03-2021 18CSC305J_AI_UNIT3
The fact base
• A fact base is a collection of “facts,” expressed in predicate calculus, that are presumed to be true (valid)
• These facts are implicitly “anded” together
• Example fact base:
• seafood(X)  likes(John, X) (where X is a variable)
• seafood(shrimp)
• pasta(X)  likes(Mary, X) (where X is a different variable)
• pasta(spaghetti)
• That is,
• (seafood(X)  likes(John, X))  seafood(shrimp) 
(pasta(Y)  likes(Mary, Y))  pasta(spaghetti)
• Notice that we had to change some Xs to Ys
• The scope of a variable is the single fact in which it occurs

68
17-03-2021 18CSC305J_AI_UNIT3
Clause form
• A clause is a disjunction ("or") of zero or more literals, some or all of
which may be negated
• Example:
sinks(X)  dissolves(X, water)  ¬denser(X, water)
• Notice that clauses use only “or” and “not”—they do not use “and,”
“implies,” or either of the quantifiers “for all” or “there exists”
• The impressive part is that any predicate calculus expression can be
put into clause form
• Existential quantifiers, , are the trickiest ones

69
17-03-2021 18CSC305J_AI_UNIT3
Unification
• From the pair of facts (not yet clauses, just facts):
• seafood(X)  likes(John, X) (where X is a variable)
• seafood(shrimp)
• We ought to be able to conclude
• likes(John, shrimp)
• We can do this by unifying the variable X with the constant shrimp
• This is the same “unification” as is done in Prolog
• This unification turns seafood(X)  likes(John, X) into
seafood(shrimp)  likes(John, shrimp)
• Together with the given fact seafood(shrimp), the final deductive
70
17-03-2021 18CSC305J_AI_UNIT3
step is easy
The resolution principle
• Here it is:
• From X  someLiterals
and X  someOtherLiterals
----------------------------------------------
conclude: someLiterals  someOtherLiterals
• That’s all there is to it!
• Example:
• broke(Bob)  well-fed(Bob)
¬broke(Bob)  ¬hungry(Bob)
--------------------------------------
well-fed(Bob)  ¬hungry(Bob)

71
17-03-2021 18CSC305J_AI_UNIT3
A common error
• You can only do one resolution at a time
• Example:
• broke(Bob)  well-fed(Bob)  happy(Bob)
¬broke(Bob)  ¬hungry(Bob) ∨ ¬happy(Bob)
• You can resolve on broke to get:
• well-fed(Bob)  happy(Bob)  ¬hungry(Bob)  ¬happy(Bob)  T
• Or you can resolve on happy to get:
• broke(Bob)  well-fed(Bob)  ¬broke(Bob)  ¬hungry(Bob)  T
• Note that both legal resolutions yield a tautology (a trivially true statement, containing X
 ¬X), which is correct but useless
• But you cannot resolve on both at once to get:
• well-fed(Bob)  ¬hungry(Bob)

72
17-03-2021 18CSC305J_AI_UNIT3
Contradiction
• A special case occurs when the result of a resolution (the resolvent) is
empty, or “NIL”
• Example:
• hungry(Bob)
¬hungry(Bob)
----------------
NIL
• In this case, the fact base is inconsistent
• This will turn out to be a very useful observation in doing resolution
theorem proving

73
17-03-2021 18CSC305J_AI_UNIT3
A first example
• “Everywhere that John goes, Rover goes. John is at school.”
• at(John, X)  at(Rover, X) (not yet in clause form)
• at(John, school) (already in clause form)
• We use implication elimination to change the first of these into clause
form:
• at(John, X)  at(Rover, X)
• at(John, school)
• We can resolve these on at(-, -), but to do so we have to unify X with
school; this gives:
• at(Rover, school)

74
17-03-2021 18CSC305J_AI_UNIT3
Refutation resolution
• The previous example was easy because it had very few clauses
• When we have a lot of clauses, we want to focus our search on the
thing we would like to prove
• We can do this as follows:
• Assume that our fact base is consistent (we can’t derive NIL)
• Add the negation of the thing we want to prove to the fact base
• Show that the fact base is now inconsistent
• Conclude the thing we want to prove

75
17-03-2021 18CSC305J_AI_UNIT3
Example of refutation resolution
• “Everywhere that John goes, Rover goes. John is at school. Prove that Rover is
at school.”
1. at(John, X)  at(Rover, X)
2. at(John, school)
3. at(Rover, school) (this is the added clause)
• Resolve #1 and #3:
4. at(John, X)
• Resolve #2 and #4:
5. NIL
• Conclude the negation of the added clause: at(Rover, school)
• This seems a roundabout approach for such a simple example, but it works well
for larger problems

76
17-03-2021 18CSC305J_AI_UNIT3
A second example
• Start with:
• it_is_raining  it_is_sunny
• it_is_sunny  I_stay_dry
• it_is_raining  I_take_umbrella
• I_take_umbrella  I_stay_dry
• Proof:
• Convert to clause form:
6. (5, 2) it_is_sunny
1. it_is_raining  it_is_sunny
2. it_is_sunny  I_stay_dry 7. (6, 1) it_is_raining
3. it_is_raining  I_take_umbrella 8. (5, 4) I_take_umbrella
4. I_take_umbrella  I_stay_dry 9. (8, 3) it_is_raining
• Prove that I stay dry: 10. (9, 7) NIL
5. I_stay_dry  Therefore, (I_stay_dry)
 I_stay_dry

77
17-03-2021 18CSC305J_AI_UNIT3
Converting sentences to CNF
1. Eliminate all ↔ connectives
(P ↔ Q)  ((P  Q) ^ (Q  P))
2. Eliminate all  connectives
(P  Q)  (P  Q)
3. Reduce the scope of each negation symbol to a single predicate
P  P
(P  Q)  P  Q
(P  Q)  P  Q
(x)P  (x)P
(x)P  (x)P
4. Standardize variables: rename all variables so that each quantifier has its own
unique variable name
78
17-03-2021 18CSC305J_AI_UNIT3
Converting sentences to clausal form Skolem
constants and functions
5. Eliminate existential quantification by introducing Skolem
constants/functions
(x)P(x)  P(c)
c is a Skolem constant (a brand-new constant symbol that is not used in any
other sentence)
(x)(y)P(x,y)  (x)P(x, f(x))
since  is within the scope of a universally quantified variable, use a Skolem
function f to construct a new value that depends on the universally
quantified variable
f must be a brand-new function name not occurring in any other sentence in
the KB.
E.g., (x)(y)loves(x,y)  (x)loves(x,f(x))
In this case, f(x) specifies the person that x loves
79
17-03-2021 18CSC305J_AI_UNIT3
Converting sentences to clausal form

6. Remove universal quantifiers by (1) moving them all to the left end;
(2) making the scope of each the entire sentence; and (3) dropping
the “prefix” part
Ex: (x)P(x)  P(x)
7. Put into conjunctive normal form (conjunction of disjunctions) using
distributive and associative laws
(P  Q)  R  (P  R)  (Q  R)
(P  Q)  R  (P  Q  R)
8. Split conjuncts into separate clauses
9. Standardize variables so each clause contains only variable names
that do not occur in any other clause
80
17-03-2021 18CSC305J_AI_UNIT3
An example
(x)(P(x)  ((y)(P(y)  P(f(x,y)))  (y)(Q(x,y)  P(y))))
2. Eliminate 
(x)(P(x)  ((y)(P(y)  P(f(x,y)))  (y)(Q(x,y)  P(y))))
3. Reduce scope of negation
(x)(P(x)  ((y)(P(y)  P(f(x,y))) (y)(Q(x,y)  P(y))))
4. Standardize variables
(x)(P(x)  ((y)(P(y)  P(f(x,y))) (z)(Q(x,z)  P(z))))
5. Eliminate existential quantification
(x)(P(x) ((y)(P(y)  P(f(x,y))) (Q(x,g(x))  P(g(x)))))
6. Drop universal quantification symbols
(P(x)  ((P(y)  P(f(x,y))) (Q(x,g(x))  P(g(x)))))
81
17-03-2021 18CSC305J_AI_UNIT3
Example
7. Convert to conjunction of disjunctions
(P(x)  P(y)  P(f(x,y)))  (P(x)  Q(x,g(x))) 
(P(x)  P(g(x)))
8. Create separate clauses
P(x)  P(y)  P(f(x,y))
P(x)  Q(x,g(x))
P(x)  P(g(x))
9. Standardize variables
P(x)  P(y)  P(f(x,y))
P(z)  Q(z,g(z))
P(w)  P(g(w))

82
17-03-2021 18CSC305J_AI_UNIT3
Running example
• All Romans who know Marcus either hate Caesar or
think that anyone who hates anyone is crazy

• x, [ Roman(x)  know(x, Marcus) ] 


[ hate(x, Caesar) 
(y, z, hate(y, z)  thinkCrazy(x, y))]

83
17-03-2021 18CSC305J_AI_UNIT3
Step 1: Eliminate implications
• Use the fact that x  y is equivalent to x  y

• x, [ Roman(x)  know(x, Marcus) ] 


[ hate(x, Caesar) 
(y, z, hate(y, z)  thinkCrazy(x, y))]

• x, [ Roman(x)  know(x, Marcus) ] 


[hate(x, Caesar) 
(y, (z, hate(y, z)  thinkCrazy(x, y))]

84
17-03-2021 18CSC305J_AI_UNIT3
Step 2: Reduce the scope of 
• Reduce the scope of negation to a single term, using:
• (p)  p
• (a  b)  (a  b)
• (a  b)  (a  b)
• x, p(x)  x, p(x)
• x, p(x)  x, p(x)

• x, [ Roman(x)  know(x, Marcus) ] 


[hate(x, Caesar) 
(y, (z, hate(y, z)  thinkCrazy(x, y))]

• x, [ Roman(x)  know(x, Marcus) ] 


[hate(x, Caesar) 
(y, z, hate(y, z)  thinkCrazy(x, y))]

85
17-03-2021 18CSC305J_AI_UNIT3
Step 3: Standardize variables apart
• x, P(x)  x, Q(x)
becomes
x, P(x)  y, Q(y)
• This is just to keep the scopes of variables from
getting confused
• Not necessary in our running example

86
17-03-2021 18CSC305J_AI_UNIT3
Step 4: Move quantifiers
• Move all quantifiers to the left, without changing their relative
positions

• x, [ Roman(x)  know(x, Marcus) ] 


[hate(x, Caesar) 
(y, z, hate(y, z)  thinkCrazy(x, y)]

• x, y, z,[ Roman(x)  know(x, Marcus) ] 


[hate(x, Caesar) 
(hate(y, z)  thinkCrazy(x, y))]
87
17-03-2021 18CSC305J_AI_UNIT3
Step 5: Eliminate existential quantifiers

• We do this by introducing Skolem functions:


• If x, p(x) then just pick one; call it x’
• If the existential quantifier is under control of a
universal quantifier, then the picked value has to be
a function of the universally quantified variable:
• If x, y, p(x, y) then x, p(x, y(x))
• Not necessary in our running example

88
17-03-2021 18CSC305J_AI_UNIT3
Step 6: Drop the prefix (quantifiers)
• x, y, z,[ Roman(x)  know(x, Marcus) ] 
[hate(x, Caesar)  (hate(y, z)  thinkCrazy(x, y))]
• At this point, all the quantifiers are universal quantifiers
• We can just take it for granted that all variables are
universally quantified
•[ Roman(x)  know(x, Marcus) ] 
[hate(x, Caesar)  (hate(y, z)  thinkCrazy(x, y))]

89
17-03-2021 18CSC305J_AI_UNIT3
Step 7: Create a conjunction of disjuncts

• [ Roman(x)  know(x, Marcus) ] 


[hate(x, Caesar)  (hate(y, z)  thinkCrazy(x, y))]

becomes

Roman(x)  know(x, Marcus) 


hate(x, Caesar)  hate(y, z)  thinkCrazy(x, y)

90
17-03-2021 18CSC305J_AI_UNIT3
Step 8: Create separate clauses
• Every place we have an , we break our expression up
into separate pieces
• Not necessary in our running example

91
17-03-2021 18CSC305J_AI_UNIT3
Step 9: Standardize apart
• Rename variables so that no two clauses have the same
variable
• Not necessary in our running example

• Final result:
Roman(x)  know(x, Marcus) 
hate(x, Caesar)  hate(y, z)  thinkCrazy(x, y)

• That’s it! It’s a long process, but easy enough to do


92mechanically
17-03-2021 18CSC305J_AI_UNIT3
Resolution
• Resolution is a sound and complete inference procedure for FOL
• Reminder: Resolution rule for propositional logic:
• P1  P2  ...  Pn
• P1  Q2  ...  Qm
• Resolvent: P2  ...  Pn  Q2  ...  Qm
• Examples
• P and  P  Q : derive Q (Modus Ponens)
• ( P  Q) and ( Q  R) : derive  P  R
• P and  P : derive False [contradiction!]
• (P  Q) and ( P   Q) : derive True

93
17-03-2021 18CSC305J_AI_UNIT3
Resolution in first-order logic
• Given sentences
P1  ...  Pn
Q1  ...  Qm
• in conjunctive normal form:
• each Pi and Qi is a literal, i.e., a positive or negated predicate symbol with its
terms,
• if Pj and Qk unify with substitution list θ, then derive the resolvent sentence:
subst(θ, P1 ...  Pj-1  Pj+1 ... Pn  Q1  …Qk-1  Qk+1 ...  Qm)
• Example
• from clause P(x, f(a))  P(x, f(y))  Q(y)
• and clause P(z, f(a))  Q(z)
• derive resolvent P(z, f(y))  Q(y)  Q(z)
• using θ = {x/z}
94
17-03-2021 18CSC305J_AI_UNIT3
Resolution refutation
• Given a consistent set of axioms KB and goal sentence Q, show that KB
|= Q
• Proof by contradiction: Add Q to KB and try to prove false.
i.e., (KB |- Q) ↔ (KB  Q |- False)
• Resolution is refutation complete: it can establish that a given sentence
Q is entailed by KB, but can’t (in general) be used to generate all logical
consequences of a set of sentences
• Also, it cannot be used to prove that Q is not entailed by KB.
• Resolution won’t always give an answer since entailment is only
semidecidable
• And you can’t just run two proofs in parallel, one trying to prove Q and the
other trying to prove Q, since KB might not entail either one
96
17-03-2021 18CSC305J_AI_UNIT3
Refutation resolution proof tree
allergies(w) v sneeze(w) cat(y) v ¬allergic-to-cats(z)  allergies(z)
w/z

cat(y) v sneeze(z)  ¬allergic-to-cats(z) cat(Felix)

y/Felix

sneeze(z) v ¬allergic-to-cats(z) allergic-to-cats(Lise)

z/Lise

sneeze(Lise) sneeze(Lise)

false

negated query
97
17-03-2021 18CSC305J_AI_UNIT3
We need answers to the following questions

• How to convert FOL sentences to conjunctive normal form (a.k.a. CNF,


clause form): normalization and skolemization
• How to unify two argument lists, i.e., how to find their most general
unifier (mgu) unification
• How to determine which two clauses in KB should be resolved next
(among all resolvable pairs of clauses) : resolution (search) strategy

98
17-03-2021 18CSC305J_AI_UNIT3
Unification
• Unification is a “pattern-matching” procedure
• Takes two atomic sentences, called literals, as input
• Returns “Failure” if they do not match and a substitution list, θ, if they do
• That is, unify(p,q) = θ means subst(θ, p) = subst(θ, q) for two atomic
sentences, p and q
• θ is called the most general unifier (mgu)
• All variables in the given two literals are implicitly universally
quantified
• To make literals match, replace (universally quantified) variables by
terms

99
17-03-2021 18CSC305J_AI_UNIT3
Unification algorithm
procedure unify(p, q, θ)
Scan p and q left-to-right and find the first corresponding
terms where p and q “disagree” (i.e., p and q not equal)
If there is no disagreement, return θ (success!)
Let r and s be the terms in p and q, respectively,
where disagreement first occurs
If variable(r) then {
Let θ = union(θ, {r/s})
Return unify(subst(θ, p), subst(θ, q), θ)
} else if variable(s) then {
Let θ = union(θ, {s/r})
Return unify(subst(θ, p), subst(θ, q), θ)
} else return “Failure”
end
100
17-03-2021 18CSC305J_AI_UNIT3
Unification: Remarks
• Unify is a linear-time algorithm that returns the most
general unifier (mgu), i.e., the shortest-length substitution
list that makes the two literals match.
• In general, there is not a unique minimum-length
substitution list, but unify returns one of minimum length
• A variable can never be replaced by a term containing that
variable
Example: x/f(x) is illegal.
• This “occurs check” should be done in the above pseudo-
code before making the recursive calls
101
17-03-2021 18CSC305J_AI_UNIT3
Unification examples
• Example:
• parents(x, father(x), mother(Bill))
• parents(Bill, father(Bill), y)
• {x/Bill, y/mother(Bill)}
• Example:
• parents(x, father(x), mother(Bill))
• parents(Bill, father(y), z)
• {x/Bill, y/Bill, z/mother(Bill)}
• Example:
• parents(x, father(x), mother(Jane))
• parents(Bill, father(y), mother(y))
102 • Failure
17-03-2021 18CSC305J_AI_UNIT3
Resolution example
Practice example : Did Curiosity kill the cat
• Jack owns a dog. Every dog owner is an animal lover. No animal lover
kills an animal. Either Jack or Curiosity killed the cat, who is named
Tuna. Did Curiosity kill the cat?
• These can be represented as follows:
A. (x) Dog(x)  Owns(Jack,x)
B. (x) ((y) Dog(y)  Owns(x, y))  AnimalLover(x)
C. (x) AnimalLover(x)  ((y) Animal(y)  Kills(x,y))
D. Kills(Jack,Tuna)  Kills(Curiosity,Tuna)
E. Cat(Tuna)
F. (x) Cat(x)  Animal(x) GOAL
G. Kills(Curiosity, Tuna)

17-03-2021 18CSC305J_AI_UNIT3
103
• Convert to clause form
D is a skolem constant
A1. (Dog(D))
A2. (Owns(Jack,D))
B. (Dog(y), Owns(x, y), AnimalLover(x))
C. (AnimalLover(a), Animal(b), Kills(a,b))
D. (Kills(Jack,Tuna), Kills(Curiosity,Tuna))
E. Cat(Tuna)
F. (Cat(z), Animal(z))
• Add the negation of query:
G: (Kills(Curiosity, Tuna))

104
17-03-2021 18CSC305J_AI_UNIT3
• The resolution refutation proof
R1: G, D, {} (Kills(Jack, Tuna))
R2: R1, C, {a/Jack, b/Tuna} (~AnimalLover(Jack),
~Animal(Tuna))
R3: R2, B, {x/Jack} (~Dog(y), ~Owns(Jack, y),
~Animal(Tuna))
R4: R3, A1, {y/D} (~Owns(Jack, D),
~Animal(Tuna))
R5: R4, A2, {} (~Animal(Tuna))
R6: R5, F, {z/Tuna} (~Cat(Tuna))
R7: R6, E, {} FALSE

105
17-03-2021 18CSC305J_AI_UNIT3
• The proof tree
G D
{}
R1: K(J,T) C
{a/J,b/T}
R2: AL(J)  A(T) B
{x/J}
R3: D(y)  O(J,y)  A(T) A1
{y/D}
R4: O(J,D), A(T) A2
{}
R5: A(T) F

{z/T}
R6: C(T) A
{}
R7: FALSE
106
17-03-2021 18CSC305J_AI_UNIT3
Knowledge and Reasoning
Table of Contents
• Knowledge and reasoning-Approaches and issues of knowledge reasoning-
Knowledge base agents
• Logic Basics-Logic-Propositional logic-syntax ,semantics and inferences-
Propositional logic- Reasoning patterns
• Unification and Resolution
• Knowledge representation using rules-Knowledge representation using semantic
nets
• Knowledge representation using frames-Inferences-
• Uncertain Knowledge and reasoning-Methods-Bayesian probability and belief
network
• Probabilistic reasoning-Probabilistic reasoning over time-Probabilistic reasoning
over time
• Other uncertain techniques-Data mining-Fuzzy logic-Dempster -shafer theory
17-03-2021 18CSC305J_AI_UNIT3 107
Production Rules
• Condition-Action Pairs
• IF this condition (or premise or antecedent) occurs,
THEN some action (or result, or conclusion, or
consequence) will (or should) occur
• IF the traffic light is red AND you have stopped,
THEN a right turn is OK
Production Rules
• Each production rule in a knowledge base represents an
autonomous chunk of expertise
• When combined and fed to the inference engine, the set of rules
behaves synergistically
• Rules can be viewed as a simulation of the cognitive behaviour
of human experts
• Rules represent a model of actual human behaviour
• Predominant technique used in expert systems, often in
conjunction with frames
Forms of Rules
• IF premise, THEN conclusion
• IF your income is high, THEN your chance of being
audited by the Inland Revenue is high
• Conclusion, IF premise
• Your chance of being audited is high, IF your income
is high
Forms of Rules
• Inclusion of ELSE
• IF your income is high, OR your deductions are unusual, THEN
your chance of being audited is high, OR ELSE your chance of
being audited is low
• More complex rules
• IF credit rating is high AND salary is more than £30,000, OR
assets are more than £75,000, AND pay history is not "poor,"
THEN approve a loan up to £10,000, and list the loan in category
"B.”
• Action part may have more information: THEN "approve the loan"
and "refer to an agent"
Characteristics of Rules
First Part Second Part

Names Premise Conclusion


Antecedent Consequence
Situation Action
IF THEN
Nature Conditions, similar to declarative knowledge Resolutions, similar to procedural knowledge

Size Can have many IFs Usually only one conclusion

Statement AND statements All conditions must be true for a conclusion to be true

OR statements If any condition is true, the conclusion is true


Rule-based Inference
• Production rules are typically used as part of a
production system
• Production systems provide pattern-directed control of
the reasoning process
• Production systems have:
• Productions: set of production rules
• Working Memory (WM): description of current state
of the world
• Recognise-act cycle
Production Systems
Production
Rules

C1→A1 Working
Environment
C2→A2 Memory
C3→A3

Cn→An

Conflict Conflict
Set Resolution
Recognise-Act Cycle
• Patterns in WM matched against production rule conditions
• Matching (activated) rules form the conflict set
• One of the matching rules is selected (conflict resolution) and
fired
• Action of rule is performed
• Contents of WM updated
• Cycle repeats with updated WM
Conflict Resolution
• Reasoning in a production system can be viewed as a type of
search
• Selection strategy for rules from the conflict set controls
search
• Production system maintains the conflict set as an agenda
• Ordered list of activated rules (those with their conditions
satisfied) which have not yet been executed
• Conflict resolution strategy determines where a newly-
activated rule is inserted
Salience
• Rules may be given a precedence order by assigning a
salience value
• Newly activated rules are placed in the agenda above all rules
of lower salience, and below all rules with higher salience
• Rule with higher salience are executed first
• Conflict resolution strategy applies between rules of the
same salience
• If salience and the conflict resolution strategy can ’ t
determine which rule is to be executed next, a rule is chosen
at random from the most highly ranked rules
Conflict Resolution Strategies
• Depth-first: newly activated rules placed above other rules in the
agenda
• Breadth-first: newly activated rules placed below other rules
• Specificity: rules ordered by the number of conditions in the LHS
(simple-first or complex-first)
• Least recently fired: fire the rule that was last fired the longest time
ago
• Refraction: don’t fire a rule unless the WM patterns that match its
conditions have been modified
• Recency: rules ordered by the timestamps on the facts that match
their conditions
Salience
• Salience facilitates the modularization of expert systems
in which modules work at different levels of abstraction
• Over-use of salience can complicate a system
• Explicit ordering to rule execution
• Makes behaviour of modified systems less predictable
• Rule of thumb: if two rules have the same salience, are
in the same module, and are activated concurrently,
then the order in which they are executed should not
matter
Common Types of Rules
• Knowledge rules, or declarative rules, state all the facts
and relationships about a problem
• Inference rules, or procedural rules, advise on how to
solve a problem, given that certain facts are known
• Inference rules contain rules about rules (metarules)
• Knowledge rules are stored in the knowledge base
• Inference rules become part of the inference engine

17-03-2021 18CSC305J_AI_UNIT3 120


Major Advantages of Rules
• Easy to understand (natural form of knowledge)
• Easy to derive inference and explanations
• Easy to modify and maintain
• Easy to combine with uncertainty
• Rules are frequently independent

17-03-2021 18CSC305J_AI_UNIT3 121


Major Limitations of Rules
• Complex knowledge requires many rules
• Search limitations in systems with many rules

17-03-2021 18CSC305J_AI_UNIT3 122


Knowledge and Reasoning
Table of Contents
• Knowledge and reasoning-Approaches and issues of knowledge reasoning-
Knowledge base agents
• Logic Basics-Logic-Propositional logic-syntax ,semantics and inferences-
Propositional logic- Reasoning patterns
• Unification and Resolution
• Knowledge representation using rules-Knowledge representation using semantic
nets
• Knowledge representation using frames-Inferences-
• Uncertain Knowledge and reasoning-Methods-Bayesian probability and belief
network
• Probabilistic reasoning-Probabilistic reasoning over time-Probabilistic reasoning
over time
• Other uncertain techniques-Data mining-Fuzzy logic-Dempster -shafer theory
17-03-2021 18CSC305J_AI_UNIT3 123
Semantic Networks
• A semantic network is a structure for representing
knowledge as a pattern of interconnected nodes and
arcs
• Nodes in the net represent concepts of entities,
attributes, events, values
• Arcs in the network represent relationships that hold
between the concepts

17-03-2021 18CSC305J_AI_UNIT3 124


Semantic Networks
• Semantic networks can show inheritance
• Relationship types – is-a, has-a
• Semantic Nets - visual representation of relationships
• Can be combined with other representation methods

17-03-2021 18CSC305J_AI_UNIT3 125


Semantic Networks
Bird
is-a is-a Canary
Can fly
Can sing
Has wings
Is yellow
Has feathers

Animal Ostrich
Can breathe is-a Runs fast
Can eat Cannot fly
Has skin Is tall

Fish Salmon
is-a Can swim is-a Swims upstream
Has fins Is pink
Has gills Is edible

17-03-2021 18CSC305J_AI_UNIT3 126


Semantic Networks
moves
ANIMAL is a

breathes DOG is a works sheep


is a
SHEEPDOG

tracks HOUND has tail


barks is a
is a size: medium

BEAGLE COLLIE

instance
size: small FICTIONAL
instance CHARACTER instance
instance

SNOOPY instance
LASSIE

friend of
17-03-2021 CHARLIE BROWN
18CSC305J_AI_UNIT3 127
Semantic Networks
What does or should a node represent?
• A class of objects?
• An instance of an class?
• The canonical instance of a class?
• The set of all instances of a class?

17-03-2021 18CSC305J_AI_UNIT3 128


Semantic Networks
• Semantics of links that define new objects and links that relate
existing objects, particularly those dealing with ‘intrinsic’
characteristics of a given object
• How does one deal with the problems of comparison between
objects (or classes of objects) through their attributes?
• Essentially the problem of comparing object instances
• What mechanisms are there are to handle quantification in
semantic network formalisms?

17-03-2021 18CSC305J_AI_UNIT3 129


Transitive inference, but…
• Clyde is an elephant, an elephant is a mammal: Clyde is a
mammal.

• The US President is elected every 4 years, Bush is US President:


Bush is elected every 4 years
• My car is a Ford, Ford is a car company: my car is a car
company

17-03-2021 18CSC305J_AI_UNIT3 130


Knowledge and Reasoning
Table of Contents
• Knowledge and reasoning-Approaches and issues of knowledge reasoning-
Knowledge base agents
• Logic Basics-Logic-Propositional logic-syntax ,semantics and inferences-
Propositional logic- Reasoning patterns
• Unification and Resolution
• Knowledge representation using rules-Knowledge representation using semantic
nets
• Knowledge representation using frames-Inferences-
• Uncertain Knowledge and reasoning-Methods-Bayesian probability and belief
network
• Probabilistic reasoning-Probabilistic reasoning over time-Probabilistic reasoning
over time
• Other uncertain techniques-Data mining-Fuzzy logic-Dempster -shafer theory
17-03-2021 18CSC305J_AI_UNIT3 131
Frames
• A frame is a knowledge representation formalism based on the idea of a
frame of reference.
• A frame is a data structure that includes all the knowledge about a
particular object
• Frames organised in a hierarchy Form of object-oriented programming for
AI and ES.
• Each frame describes one object
• Special terminology

M. Minsky (1974) A Framework for Representing Knowledge,


MIT-AI Laboratory Memo 306

17-03-2021 18CSC305J_AI_UNIT3 132


Frames
• There are two types of frame:
• Class Frame
• Individual or Instance Frame
• A frame carries with it a set of slots that can represent
objects that are normally associated with a subject of
the frame.

17-03-2021 18CSC305J_AI_UNIT3 133


Frames
• The slots can then point to other slots or frames. That
gives frame systems the ability to carry out inheritance
and simple kinds of data manipulation.
• The use of procedures - also called demons in the
literature - helps in the incorporation of substantial
amounts of procedural knowledge into a particular
frame-oriented knowledge base

17-03-2021 18CSC305J_AI_UNIT3 134


Frame-based model of semantic
memory
• Knowledge is organised in a data structure
• Slots in structure are instantiated with particular values for a
given instance of data
• ...translation to OO terminology:
• frames == classes or objects
• slots == variables/methods

17-03-2021 18CSC305J_AI_UNIT3 135


General Knowledge as Frames

DOG COLLIE
Fixed Fixed
legs: 4 breed of: DOG
type: sheepdog
Default
diet: carnivorous Default
sound: bark size: 65cm

Variable Variable
size: colour:
colour:

17-03-2021 18CSC305J_AI_UNIT3 136


General Knowledge as Frames
MAMMAL:
subclass: ANIMAL
has_part: head

ELEPHANT
subclass: MAMMAL
colour: grey
size: large

Nellie
instance: ELEPHANT
likes: apples

17-03-2021 18CSC305J_AI_UNIT3 137


Logic underlies Frames
• ∀x mammal(x) ⇒ has_part(x, head)
• ∀x elephant(x) ⇒ mammal(x)

• elephant(clyde)

mammal(clyde)
has_part(clyde, head)

17-03-2021 18CSC305J_AI_UNIT3 138


Logic underlies Frames
MAMMAL:
subclass: ANIMAL
has_part: head
*furry: yes

ELEPHANT
subclass: MAMMAL
has_trunk: yes
*colour: grey
*size: large
*furry: no

Clyde
instance: ELEPHANT
colour: pink
owner: Fred

Nellie
instance: ELEPHANT
size:
17-03-2021 small 18CSC305J_AI_UNIT3 139
Frames (Contd.)
• Can represent subclass and instance relationships (both
sometimes called ISA or “is a”)
• Properties (e.g. colour and size) can be referred to as slots and
slot values (e.g. grey, large) as slot fillers
• Objects can inherit all properties of parent class (therefore
Nellie is grey and large)
• But can inherit properties which are only typical (usually called
default, here starred), and can be overridden
• For example, mammal is typically furry, but this is not so for an
elephant

17-03-2021 18CSC305J_AI_UNIT3 140


Frames (Contd.)
• Provide a concise, structural representation of knowledge in a
natural manner
• Frame encompasses complex objects, entire situations or a
management problem as a single entity
• Frame knowledge is partitioned into slots
• Slot can describe declarative knowledge or procedural
knowledge
• Hierarchy of Frames: Inheritance

17-03-2021 18CSC305J_AI_UNIT3 141


Capabilities of Frames
• Ability to clearly document information about a domain model;
for example, a plant's machines and their associated attributes
• Related ability to constrain allowable values of an attribute
• Modularity of information, permitting ease of system expansion
and maintenance
• More readable and consistent syntax for referencing domain
objects in the rules

17-03-2021 18CSC305J_AI_UNIT3 142


Capabilities of Frames
• Platform for building graphic interface with object graphics
• Mechanism to restrict the scope of facts considered during
forward or backward chaining
• Access to a mechanism that supports the inheritance of
information down a class hierarchy
• Used as underlying model in standards for accessing KBs (Open
Knowledge Base Connectivity - OKBC)

17-03-2021 18CSC305J_AI_UNIT3 143


Summary
• Frames have been used in conjunction with other, less well-
grounded, representation formalisms, like production systems,
when used to build to pre-operational or operational expert
systems
• Frames cannot be used efficiently to organise ‘a whole
computation

17-03-2021 18CSC305J_AI_UNIT3 144


Knowledge and Reasoning
Table of Contents
• Knowledge and reasoning-Approaches and issues of knowledge
reasoning-Knowledge base agents
• Logic Basics-Logic-Propositional logic-syntax ,semantics and
inferences-Propositional logic- Reasoning patterns
• Unification and Resolution-Knowledge representation using rules-
Knowledge representation using semantic nets
• Knowledge representation using frames-Inferences-
• Uncertain Knowledge and reasoning-Methods-Bayesian probability and
belief network
• Probabilistic reasoning-Probabilistic reasoning over time
• Other uncertain techniques-Data mining-Fuzzy logic-Dempster -shafer theory
17-03-2021 18CSC305J_AI_UNIT3 145
Types of Inference

• Deduction
• Induction
• Abduction

17-03-2021 15CS401-Artificial Intelligence 146


Deduction

• Deriving a conclusion from given axioms and facts


• Also called logical inference or truth preservation
Axiom – All kids are naughty
Fact/Premise – Riya is a kid
Conclusion – Riya is naughty

17-03-2021 15CS401-Artificial Intelligence 147


Induction

• Deriving general rule or axiom from background knowledge and


observations
• Riya is a kid
• Riya is naughty
General axiom which is derived is:
Kids are naughty

17-03-2021 15CS401-Artificial Intelligence 148


Abduction

• A premise is derived from a known axiom and some observations


• All kids are naughty
• Riya is naughty
Inference
Riya is a kid

17-03-2021 15CS401-Artificial Intelligence 149


Knowledge and Reasoning
Table of Contents
• Knowledge and reasoning-Approaches and issues of knowledge
reasoning-Knowledge base agents
• Logic Basics-Logic-Propositional logic-syntax ,semantics and
inferences-Propositional logic- Reasoning patterns
• Unification and Resolution-Knowledge representation using rules-
Knowledge representation using semantic nets
• Knowledge representation using frames-Inferences-
• Uncertain Knowledge and reasoning-Methods-Bayesian probability and
belief network
• Probabilistic reasoning-Probabilistic reasoning over time
• Other uncertain techniques-Data mining-Fuzzy logic-Dempster -shafer theory
17-03-2021 18CSC305J_AI_UNIT3 150
Uncertain knowledge and reasoning

• In real life, it is not always possible to determine the state of the environment as it might not be clear. Due
to partially observable or non-deterministic environments, agents may need to handle uncertainty and deal
with it.
• Uncertain data: Data that is missing, unreliable, inconsistent or noisy
• Uncertain knowledge: When the available knowledge has multiple causes leading to multiple effects or
incomplete knowledge of causality in the domain
• Uncertain knowledge representation: The representations which provides a restricted model of the real
system, or has limited expressiveness
• Inference: In case of incomplete or default reasoning methods, conclusions drawn might not be completely
accurate. Let’s understand this better with the help of an example.
• IF primary infection is bacteria cea
• AND site of infection is sterile
• AND entry point is gastrointestinal tract
• THEN organism is bacteriod (0.7).
• In such uncertain situations, the agent does not guarantee a solution but acts on its own
assumptions and probabilities and gives some degree of belief that it will reach the required
solution.

17-03-2021 18CSC305J_AI_UNIT3 151


Uncertain knowledge and reasoning

• For example, In case of Medical diagnosis consider the rule Toothache = Cavity. This
is not complete as not all patients having toothache have cavities. So we can write a
more generalized rule Toothache = Cavity V Gum problems V Abscess… To make this
rule complete, we will have to list all the possible causes of toothache. But this is not
feasible due to the following rules:
• Laziness- It will require a lot of effort to list the complete set of antecedents and
consequents to make the rules complete.
• Theoretical ignorance- Medical science does not have complete theory for the
domain
• Practical ignorance- It might not be practical that all tests have been or can be
conducted for the patients.
• Such uncertain situations can be dealt with using
Probability theory
Truth Maintenance systems
Fuzzy logic.
17-03-2021 18CSC305J_AI_UNIT3 152
Uncertain knowledge and reasoning

Probability
• Probability is the degree of likeliness that an event will occur. It provides a certain degree of belief
in case of uncertain situations. It is defined over a set of events U and assigns value P(e) i.e.
probability of occurrence of event e in the range [0,1]. Here each sentence is labeled with a real
number in the range of 0 to 1, 0 means the sentence is false and 1 means it is true.
• Conditional Probability or Posterior Probability is the probability of event A given that B has
already occurred.
• P(A|B) = (P(B|A) * P(A)) / P(B)
• For example, P(It will rain tomorrow| It is raining today) represents conditional probability of it
raining tomorrow as it is raining today.
• P(A|B) + P(NOT(A)|B) = 1
• Joint probability is the probability of 2 independent events happening simultaneously like rolling
two dice or tossing two coins together. For example, Probability of getting 2 on one dice and 6 on
the other is equal to 1/36. Joint probability has a wide use in various fields such as physics,
astronomy, and comes into play when there are two independent events. The full joint probability
distribution specifies the probability of each complete assignment of values to random variables.

17-03-2021 18CSC305J_AI_UNIT3 153


Uncertain knowledge and reasoning

Bayes Theorem
• It is based on the principle that every pair of features being
classified is independent of each other. It calculates probability
P(A|B) where A is class of possible outcomes and B is given
instance which has to be classified.
• P(A|B) = P(B|A) * P(A) / P(B)
• P(A|B) = Probability that A is happening, given that B has
occurred (posterior probability)
• P(A) = prior probability of class
• P(B) = prior probability of predictor
• P(B|A) = likelihood
17-03-2021 18CSC305J_AI_UNIT3 154
Uncertain knowledge and reasoning

Consider the following data.


Depending on the weather
(sunny, rainy or overcast), the
children will play(Y) or not
play(N).
Here, the total number of
observations = 14
Probability that children will
play given that weather is
sunny :
P( Yes| Sunny) = P(Sunny |
Yes) * P(Yes) / P(Sunny)
= 0.33 * 0.64 / 0.36
= 0.59
17-03-2021 18CSC305J_AI_UNIT3 155
Uncertain knowledge and reasoning

It is a probabilistic graphical model for


representing uncertain domain and to
reason under uncertainty. It consists of
nodes representing variables, arcs
representing direct connections between
them, called causal correlations. It
represents conditional dependencies
between random variables through a
Directed Acyclic Graph (DAG). A belief
network consist of:
1. A DAG with nodes labeled with variable
names,
2. Domain for each random variable,
3. Set of conditional probability tables for
each variable given its parents, including
prior probability for nodes with no
parents.

17-03-2021 18CSC305J_AI_UNIT3 156


Uncertain knowledge and reasoning

• Let’s have a look at the steps followed.


1. Identify nodes which are the random variables and the possible
values they can have from the probability domain. The nodes can be
boolean (True/ False), have ordered values or integral values.
2. Structure- It is used to represent causal relationships between the
variables. Two nodes are connected if one affects or causes the other
and the arc points towards the effect. For instance, if it is windy or
cloudy, it rains. There is a direct link from Windy/Cloudy to Rains.
Similarly, from Rains to Wet grass and Leave, i.e., if it rains, grass will
be wet and leave is taken from work.

17-03-2021 18CSC305J_AI_UNIT3 157


Uncertain knowledge and reasoning

3. Probability- Quantifying relationship between nodes. Conditional


Probability:
• P(A^B) = P(A|B) * P(B)
• P(A|B) = P(B|A) * P(A)
• P(B|A) = P(A|B) * P(B) / P(A)
• Joint probability:
4. Markov property- Bayesian Belied Networks require assumption of
Markov property, i.e., all direct dependencies are shown by using arcs.
Here there is no direct connection between it being Cloudy and Taking a
leave. But there is one via Rains. Belief Networks which have Markov
property are also called independence maps.

17-03-2021 18CSC305J_AI_UNIT3 158


Uncertain knowledge and reasoning

Inference in Belief Networks


• Bayesian Networks provide various types of representations of probability distribution over their
variables. They can be conditioned over any subset of their variables, using any direction of
reasoning.
• For example, one can perform diagnostic reasoning, i.e. when it Rains, one can update his belief
about the grass being wet or if leave is taken from work. In this case reasoning occurs in the
opposite direction to the network arcs. Or one can perform predictive reasoning, i.e., reasoning
from new information about causes to new beliefs about effects, following direction of the arcs.
For example, if the grass is already wet, then the user knows that it has rained and it might have
been cloudy or windy. Another form of reasoning involves reasoning about mutual causes of a
common effect. This is called inter causal reasoning.
• There are two possible causes of an effect, represented in the form of a ‘V’. For example, the
common effect ‘Rains’ can be caused by two reasons ‘Windy’ and ‘Cloudy.’ Initially, the two
causes are independent of each other but if it rains, it will increase the probability of both the
causes. Assume that we know it was windy. This information explains the reasons for the rainfall
and lowers probability that it was cloudy. 18CSC305J_AI_UNIT3
17-03-2021 159
Knowledge and Reasoning
Table of Contents
• Knowledge and reasoning-Approaches and issues of knowledge
reasoning-Knowledge base agents
• Logic Basics-Logic-Propositional logic-syntax ,semantics and
inferences-Propositional logic- Reasoning patterns
• Unification and Resolution-Knowledge representation using rules-
Knowledge representation using semantic nets
• Knowledge representation using frames-Inferences-
• Uncertain Knowledge and reasoning-Methods-Bayesian probability and
belief network
• Probabilistic reasoning-Probabilistic reasoning over time
• Other uncertain techniques-Data mining-Fuzzy logic-Dempster -shafer theory
17-03-2021 18CSC305J_AI_UNIT3 160
Bayesian probability and belief network
• Bayesian belief network is key computer technology for dealing with
probabilistic events and to solve a problem which has uncertainty. We
can define a Bayesian network as:
• "A Bayesian network is a probabilistic graphical model which
represents a set of variables and their conditional dependencies using
a directed acyclic graph."
• It is also called a Bayes network, belief network, decision network,
or Bayesian model.

17-03-2021 18CSC305J_AI_UNIT3 161


Bayesian probability and belief network
• Bayesian networks are probabilistic, because these networks are built from
a probability distribution, and also use probability theory for prediction and
anomaly detection.
• Real world applications are probabilistic in nature, and to represent the
relationship between multiple events, we need a Bayesian network. It can also be
used in various tasks including prediction, anomaly detection, diagnostics,
automated insight, reasoning, time series prediction, and decision making
under uncertainty.
• Bayesian Network can be used for building models from data and experts
opinions, and it consists of two parts:
Directed Acyclic Graph
Table of conditional probabilities.
• The generalized form of Bayesian network that represents and solve decision
problems under uncertain knowledge is known as an Influence diagram.
17-03-2021 18CSC305J_AI_UNIT3 162
Bayesian probability and belief network
Directed Acyclic Graph
A Bayesian network graph is made up of nodes
and Arcs (directed links), where:
Each node corresponds to the random variables,
and a variable can be continuous or discrete.
Arc or directed arrows represent the causal
relationship or conditional probabilities between
random variables. These directed links or arrows
connect the pair of nodes in the graph.
These links represent that one node directly
influence the other node, and if there is no
directed link that means that nodes are
independent with each other
In the above diagram, A, B, C, and D are
random variables represented by the nodes
of the network graph.
If we are considering node B, which is
connected with node A by a directed arrow,
then node A is called the parent of Node B.
Node C is independent of node A.

17-03-2021 18CSC305J_AI_UNIT3 163


Bayesian probability and belief network

CONDITIONAL PROBABILITY
• The Bayesian network has mainly two components:
Causal Component
Actual numbers
• Each node in the Bayesian network has condition probability
distribution P(Xi |Parent(Xi) ), which determines the effect of the
parent on that node.
• Bayesian network is based on Joint probability distribution and
conditional probability. So let's first understand the joint probability
distribution:

17-03-2021 18CSC305J_AI_UNIT3 164


Bayesian probability and belief network

Joint probability distribution:


• If we have variables x1, x2, x3,....., xn, then the probabilities of a
different combination of x1, x2, x3.. xn, are known as Joint probability
distribution.
• P[x1, x2, x3,....., xn], it can be written as the following way in terms of
the joint probability distribution.
• = P[x1| x2, x3,....., xn]P[x2, x3,....., xn]
• = P[x1| x2, x3,....., xn]P[x2|x3,....., xn]....P[xn-1|xn]P[xn].
• In general for each variable Xi, we can write the equation as:
• P(Xi|Xi-1,........., X1) = P(Xi |Parents(Xi ))
17-03-2021 18CSC305J_AI_UNIT3 165
Bayesian probability and belief network

Explanation of Bayesian network:


• Let's understand the Bayesian network through an example by creating a
directed acyclic graph:
Example: Harry installed a new burglar alarm at his home to detect burglary.
The alarm reliably responds at detecting a burglary but also responds for
minor earthquakes. Harry has two neighbors David and Sophia, who have
taken a responsibility to inform Harry at work when they hear the alarm.
David always calls Harry when he hears the alarm, but sometimes he got
confused with the phone ringing and calls at that time too. On the other
hand, Sophia likes to listen to high music, so sometimes she misses to hear
the alarm. Here we would like to compute the probability of Burglary
Alarm.

17-03-2021 18CSC305J_AI_UNIT3 166


Bayesian probability and belief network

Problem:
• Calculate the probability that alarm has sounded, but there is neither a burglary, nor an
earthquake occurred, and David and Sophia both called the Harry.
Solution:
• The Bayesian network for the above problem is given below. The network structure is showing
that burglary and earthquake is the parent node of the alarm and directly affecting the probability
of alarm's going off, but David and Sophia's calls depend on alarm probability.
• The network is representing that our assumptions do not directly perceive the burglary and also
do not notice the minor earthquake, and they also not confer before calling.
• The conditional distributions for each node are given as conditional probabilities table or CPT.
• Each row in the CPT must be sum to 1 because all the entries in the table represent an exhaustive
set of cases for the variable.
• In CPT, a boolean variable with k boolean parents contains 2K probabilities. Hence, if there are
two parents, then CPT will contain 4 probability values

17-03-2021 18CSC305J_AI_UNIT3 167


Bayesian probability and belief network
List of all events occurring in this network:
• Burglary (B)
• Earthquake(E)
• Alarm(A)
• David Calls(D)
• Sophia calls(S)
We can write the events of problem statement in the form of probability: P[D, S, A, B, E], can
rewrite the above probability statement using joint probability distribution:
• P[D, S, A, B, E]= P[D | S, A, B, E]. P[S, A, B, E]
• =P[D | S, A, B, E]. P[S | A, B, E]. P[A, B, E]
• = P [D| A]. P [ S| A, B, E]. P[ A, B, E]
• = P[D | A]. P[ S | A]. P[A| B, E]. P[B, E]
• = P[D | A ]. P[S | A]. P[A| B, E]. P[B |E]. P[E]

17-03-2021 18CSC305J_AI_UNIT3 168


Bayesian probability and belief network
Let's take the observed probability for
the Burglary and earthquake
component:
P(B= True) = 0.002, which is the
probability of burglary.
P(B= False)= 0.998, which is the
probability of no burglary.
P(E= True)= 0.001, which is the
probability of a minor earthquake
P(E= False)= 0.999, Which is the
probability that an earthquake not
occurred.

17-03-2021 18CSC305J_AI_UNIT3 169


Bayesian probability and belief network

We can provide the


B E P(A= True) P(A= False)
conditional probabilities as
per the below tables: True True 0.94 0.06

Conditional probability table True False 0.95 0.04


for Alarm A: False True 0.31 0.69

The Conditional probability of False False 0.001 0.999


Alarm A depends on Burglar
and earthquake:

17-03-2021 18CSC305J_AI_UNIT3 170


Bayesian probability and belief network
Conditional probability table
A P(D= True) P(D= False)
for David Calls:
The Conditional probability of
True 0.91 0.09
David that he will call
depends on the probability of False 0.05 0.95
Alarm.

17-03-2021 18CSC305J_AI_UNIT3 171


Bayesian probability and belief network

Conditional probability
A P(S= True) P(S= False)
table for Sophia Calls:
The Conditional
True 0.75 0.25
probability of Sophia that
she calls is depending on
False 0.02 0.98
its Parent Node "Alarm."

AP(S= True)P(S=
False)True0.750.25False0.020.98 AP(S=
17-03-2021 18CSC305J_AI_UNIT3
True)P(S=
Bayesian probability and belief network
• From the formula of joint distribution, we can write the problem statement in the form of
probability distribution:
• P(S, D, A, ¬B, ¬E) = P (S|A) *P (D|A)*P (A|¬B ^ ¬E) *P (¬B) *P (¬E).
= 0.75* 0.91* 0.001* 0.998*0.999
= 0.00068045.
Hence, a Bayesian network can answer any query about the domain by using Joint distribution.
• The semantics of Bayesian Network:
• There are two ways to understand the semantics of the Bayesian network, which is given below:
1. To understand the network as the representation of the Joint probability distribution.
• It is helpful to understand how to construct the network.
2. To understand the network as an encoding of a collection of conditional independence
statements.
• It is helpful in designing inference procedure.

17-03-2021 18CSC305J_AI_UNIT3 173


Bayes' theorem in Artificial intelligence

Bayes' theorem:
• Bayes' theorem is also known as Bayes' rule, Bayes' law, or Bayesian
reasoning, which determines the probability of an event with uncertain
knowledge.
• In probability theory, it relates the conditional probability and marginal
probabilities of two random events.
• Bayes' theorem was named after the British mathematician Thomas Bayes.
The Bayesian inference is an application of Bayes' theorem, which is
fundamental to Bayesian statistics.
• It is a way to calculate the value of P(B|A) with the knowledge of P(A|B).
• Bayes' theorem allows updating the probability prediction of an event by
observing new information of the real world.

17-03-2021 18CSC305J_AI_UNIT3 174


Bayes' theorem in Artificial intelligence
Example: If cancer corresponds to one's age then by using Bayes' theorem, we can determine the probability of cancer more accurately with
the help of age.
• Bayes' theorem can be derived using product rule and conditional probability of event A with known event B:
• As from product rule we can write:
• P(A ⋀ B)= P(A|B) P(B) or
• Similarly, the probability of event B with known event A:
• P(A ⋀ B)= P(B|A) P(A)
• Equating right hand side of both the equations, we will get:
The above equation (a) is called as Bayes' rule or Bayes' theorem. This equation is basic of most modern AI systems for probabilistic inference.
• It shows the simple relationship between joint and conditional probabilities. Here,
• P(A|B) is known as posterior, which we need to calculate, and it will be read as Probability of hypothesis A when we have occurred an
evidence B.
• P(B|A) is called the likelihood, in which we consider that hypothesis is true, then we calculate the probability of evidence.
• P(A) is called the prior probability, probability of hypothesis before considering the evidence
• P(B) is called marginal probability, pure probability of an evidence.
• In the equation (a), in general, we can write P (B) = P(A)*P(B|Ai), hence the Bayes' rule can be written as:
•17-03-2021
Where A1, A2, A3,........, An is a set of mutually exclusive and 18CSC305J_AI_UNIT3
exhaustive events. 175
Applying Bayes'
Applying Bayes'theorem
rule: in Artificial intelligence
• Bayes' rule allows us to compute the single term P(B|A) in terms of P(A|B), P(B), and P(A). This is very useful
in cases where we have a good probability of these three terms and want to determine the fourth one.
Suppose we want to perceive the effect of some unknown cause, and want to compute that cause, then the
Bayes' rule becomes:
Example-1:
Question: what is the probability that a patient has diseases meningitis with a stiff neck?
• Given Data:
A doctor is aware that disease meningitis causes a patient to have a stiff neck, and it occurs 80% of
the time. He is also aware of some more facts, which are given as follows:
The Known probability that a patient has meningitis disease is 1/30,000.
The Known probability that a patient has a stiff neck is 2%.
Let a be the proposition that patient has stiff neck and b be the proposition that patient has meningitis. , so we
can calculate the following as:
P(a|b) = 0.8
P(b) = 1/30000
P(a)= .02
• Hence, we can assume that 1 patient out of 750 patients has meningitis disease with a stiff neck.

17-03-2021 18CSC305J_AI_UNIT3 176


Applying Bayes' theorem in Artificial
intelligence
Example-2:
Question: From a standard deck of playing cards, a single card is drawn. The probability that the
card is king is 4/52, then calculate posterior probability P(King|Face), which means the drawn
face card is a king card.
Solution:

P(king): probability that the card is King= 4/52= 1/13


P(face): probability that a card is a face card= 3/13
P(Face|King): probability of face card when we assume it is a king = 1
Putting all values in equation (i) we will get:

17-03-2021 18CSC305J_AI_UNIT3 177


Application of Bayes' theorem in Artificial
intelligence:
Following are some applications of Bayes' theorem:
• It is used to calculate the next step of the robot when the already
executed step is given.
• Bayes' theorem is helpful in weather forecasting.
• It can solve the Monty Hall problem.

17-03-2021 18CSC305J_AI_UNIT3 178


Knowledge and Reasoning
Table of Contents
• Knowledge and reasoning-Approaches and issues of knowledge
reasoning-Knowledge base agents
• Logic Basics-Logic-Propositional logic-syntax ,semantics and
inferences-Propositional logic- Reasoning patterns
• Unification and Resolution-Knowledge representation using rules-
Knowledge representation using semantic nets
• Knowledge representation using frames-Inferences-
• Uncertain Knowledge and reasoning-Methods-Bayesian probability and
belief network
• Probabilistic reasoning-Probabilistic reasoning over time
• Other uncertain techniques-Data mining-Fuzzy logic-Dempster -shafer theory
17-03-2021 18CSC305J_AI_UNIT3 179
Probabilistic reasoning
Uncertainty:
• Till now, we have learned knowledge representation using first-order logic and propositional logic with
certainty, which means we were sure about the predicates. With this knowledge representation, we might
write A→B, which means if A is true then B is true, but consider a situation where we are not sure about
whether A is true or not then we cannot express this statement, this situation is called uncertainty.
• So to represent uncertain knowledge, where we are not sure about the predicates, we need uncertain
reasoning or probabilistic reasoning.
Causes of uncertainty:
Following are some leading causes of uncertainty to occur in the real world.
• Information occurred from unreliable sources.
• Experimental Errors
• Equipment fault
• Temperature variation
• Climate change.

17-03-2021 18CSC305J_AI_UNIT3 180


Probabilistic reasoning
Probabilistic reasoning:
• Probabilistic reasoning is a way of knowledge representation where we apply the concept of probability to indicate the uncertainty
in knowledge. In probabilistic reasoning, we combine probability theory with logic to handle the uncertainty.
• We use probability in probabilistic reasoning because it provides a way to handle the uncertainty that is the result of someone's
laziness and ignorance.
• In the real world, there are lots of scenarios, where the certainty of something is not confirmed, such as "It will rain today,"
"behavior of someone for some situations," "A match between two teams or two players." These are probable sentences for which
we can assume that it will happen but not sure about it, so here we use probabilistic reasoning.
Need of probabilistic reasoning in AI:
• When there are unpredictable outcomes.
• When specifications or possibilities of predicates becomes too large to handle.
• When an unknown error occurs during an experiment.
In probabilistic reasoning, there are two ways to solve problems with uncertain knowledge:
• Bayes' rule
• Bayesian Statistics

17-03-2021 18CSC305J_AI_UNIT3 181


Probabilistic reasoning
As probabilistic reasoning uses probability and related terms, so before understanding probabilistic reasoning, let's
understand some common terms:
Probability: Probability can be defined as a chance that an uncertain event will occur. It is the numerical measure of the
likelihood that an event will occur. The value of probability always remains between 0 and 1 that represent ideal
uncertainties.
0 ≤ P(A) ≤ 1, where P(A) is the probability of an event A.
P(A) = 0, indicates total uncertainty in an event A.
P(A) =1, indicates total certainty in an event A.
We can find the probability of an uncertain event by using the below formula.
P(¬A) = probability of a not happening event.
P(¬A) + P(A) = 1.
• Event: Each possible outcome of a variable is called an event.
• Sample space: The collection of all possible events is called sample space.
• Random variables: Random variables are used to represent the events and objects in the real world.
• Prior probability: The prior probability of an event is probability computed before observing new information.
• Posterior Probability: The probability that is calculated after all evidence or information has taken into account. It is a
combination of prior probability and new information.

17-03-2021 18CSC305J_AI_UNIT3 182


Probabilistic reasoning
Conditional probability:
• Conditional probability is a probability of occurring an event when another event
has already happened.
Let's suppose, we want to calculate the event A when event B has already occurred,
"the probability of A under the conditions of B", it can be written as:
P(A/B)=P(A ⋀B)/P(B)
• Where P(A⋀B)= Joint probability of a and B
• P(B)= Marginal probability of B.
• If the probability of A is given and we need to find the probability of B, then it will
be given as: P(B/A)=P(A ⋀B)/P(A)
• It can be explained by using the below Venn diagram, where B is occurred event,
so sample space will be reduced to set B, and now we can only calculate event A
when event B is already occurred by dividing the probability of P(A⋀B) by P( B ).
17-03-2021 18CSC305J_AI_UNIT3 183
Probabilistic reasoning
Example:
In a class, there are 70% of the
students who like English and 40% of
the students who likes English and
mathematics, and then what is the
percent of students those who like
English also like mathematics?
Solution:
Let, A is an event that a student likes
Mathematics
B is an event that a student likes
English.
Hence, 57% are the students who
like English also like Mathematics.

17-03-2021 18CSC305J_AI_UNIT3 184


Knowledge and Reasoning
Table of Contents
• Knowledge and reasoning-Approaches and issues of knowledge
reasoning-Knowledge base agents
• Logic Basics-Logic-Propositional logic-syntax ,semantics and
inferences-Propositional logic- Reasoning patterns
• Unification and Resolution-Knowledge representation using rules-
Knowledge representation using semantic nets
• Knowledge representation using frames-Inferences-
• Uncertain Knowledge and reasoning-Methods-Bayesian probability and
belief network
• Probabilistic reasoning-Probabilistic reasoning over time
• Other uncertain techniques-Data mining-Fuzzy logic-Dempster -shafer theory
17-03-2021 18CSC305J_AI_UNIT3 185
Probabilistic reasoning over time
Definition
• Probabilistic reasoning is the representation of knowledge where the concept of probability is applied to indicate the uncertainty
in knowledge.
Reasons to use Probabilistic Reasoning in AI
• Some reasons to use this way of representing knowledge is given below:
• When we are unsure of the predicates.
• When the possibilities of predicates become too large to list down.
• When during an experiment, it is proven that an error occurs.
• Probability of a given event = Chances of that event occurring / Total number of Events.
Notations and Properties
• Consider the statement S: March will be cold.
• Probability is often denoted as P(predicate).
• Considering the chances of March being cold is only 30%, therefore, P(S) = 0.3
• Probability always takes a value between 0 and 1. If the probability is 0, then the event will never occur and if it is 1, then it will
occur for sure.
• Then, P(¬S) = 0.7
• This means, the probability of March not being cold is 70%.
• Property 1: P(S) + P(¬S) = 1

17-03-2021 18CSC305J_AI_UNIT3 186


Probabilistic reasoning over time

Consider the statement T: April will be cold.


• Then, P(S∧T) means Probability of S AND T, i.e., Probability of March and April being cold.
• P(S∨T) means Probability of S OR T, i.e., Probability of March or April being cold.
• Property 2: P(S∨T) = P(S) + P(T) - P(S∧T)
• Proofs for the properties are not given here and you can work them out by yourselves using Venn
Diagrams.
Conditional Property
• Conditional Property is defined as the probability of a given event given another event. It is
denoted by P(B|A) and is read as: ''Probability of B given probability of A.''
• Property 3: P(B|A) = P(B∧A) / P(A).
Bayes' Theorem
• Given P(A), P(B) and P(A|B), then
• P(B|A) = P(A|B) x P(B) / P(A)

17-03-2021 18CSC305J_AI_UNIT3 187


Probabilistic reasoning over time

Bayesian Network
When designing a Bayesian Network, we keep
the local probability table at each node.
Bayesian Network - Example
Consider a Bayesian Network as given below:

This Bayesian Network tells us the reason a


particular person cannot study. It may be
either because of no electricity or because of
his lack of interest. The corresponding
probabilities are written in front of the causes.

17-03-2021 18CSC305J_AI_UNIT3 188


Probabilistic reasoning over time
Now, as you can see no cause No Electricity Not interested P(Cannot Study)
is dependent on each other P(No electricity = F) x P(Not
and they directly contribute F F Interested = F) = 0.8 x 0.7 =
0.56
to the person's inability to
P(No electricity = F) x P(Not
study. To plot the third table, F T Interested = T) = 0.8 x 0.3 =
we consider four cases. Since, 0.24
the causes are independent, P(No electricity = T) x
their corresponding T F P(Not Interested = F) = 0.2
x 0.7 = 0.14
probabilities can be
P(No electricity = T) x
multiplied directly. T T P(Not Interested = T) = 0.2
x 0.3 = 0.06

17-03-2021 18CSC305J_AI_UNIT3 189


Probabilistic reasoning over time

The updated
Bayesian Network
is:

17-03-2021 18CSC305J_AI_UNIT3 190


Knowledge and Reasoning
Table of Contents
• Knowledge and reasoning-Approaches and issues of knowledge
reasoning-Knowledge base agents
• Logic Basics-Logic-Propositional logic-syntax ,semantics and
inferences-Propositional logic- Reasoning patterns
• Unification and Resolution-Knowledge representation using rules-
Knowledge representation using semantic nets
• Knowledge representation using frames-Inferences-
• Uncertain Knowledge and reasoning-Methods-Bayesian probability and
belief network
• Probabilistic reasoning-Probabilistic reasoning over time
• Other uncertain techniques-Data mining-Fuzzy logic-Dempster -shafer theory
17-03-2021 18CSC305J_AI_UNIT3 191
Data Mining
• In artificial intelligence and machine learning, data mining, or knowledge discovery in databases, is the nontrivial
extraction of implicit, previously unknown and potentially useful information from data. Statistical methods are used that
enable trends and other relationships to be identified in large databases.
• The major reason that data mining has attracted attention is due to the wide availability of vast amounts of data, and the
need for turning such data into useful information and knowledge. The knowledge gained can be used for applications
ranging from risk monitoring, business management, production control, market analysis, engineering, and science
exploration.
In general, three types of data mining techniques are used: association, regression, and classification.
Association analysis
• Association analysis is the discovery of association rules showing attribute-value conditions that occur frequently together
in a given set of data. Association analysis is widely used to identify the correlation of individual products within shopping
carts.
Regression analysis
• Regression analysis creates models that explain dependent variables through the analysis of independent variables. As an
example, the prediction for a product’s sales performance can be created by correlating the product price and the average
customer income level.
Classification and prediction
• Classification is the process of designing a set of models to predict the class of objects whose class label is unknown. The
derived model may be represented in various forms, such as if-then rules, decision trees, or mathematical formulas.

17-03-2021 18CSC305J_AI_UNIT3 192


Data Mining
• A decision tree is a flow-chart-like tree structure where each node denotes a test on an attribute
value, each branch represents an outcome of the test, and each tree leaf represents a class or
class distribution. Decision trees can be converted to classification rules.
• Classification can be used for predicting the class label of data objects. Prediction encompasses
the identification of distribution trends based on the available data.
The data mining process consists of an iterative sequence of the following steps:
• Data coherence and cleaning to remove noise and inconsistent data
• Data integration such that multiple data sources may be combined
• Data selection where data relevant to the analysis are retrieved
• Data transformation where data are consolidated into forms appropriate for mining
• Pattern recognition and statistical techniques are applied to extract patterns
• Pattern evaluation to identify interesting patterns representing knowledge
• Visualization techniques are used to present mined knowledge to users

17-03-2021 18CSC305J_AI_UNIT3 193


Data Mining
Limits of Data Mining
• GIGO (garbage in garbage out) is almost always referenced with respect to data mining, as the
quality of the knowledge gained through data mining is dependent on the quality of the historical
data. We know data inconsistencies and dealing with multiple data sources represent large
problems in data management.
• Data cleaning techniques are used to deal with detecting and removing errors and inconsistencies
to improve data quality; however, detecting these inconsistencies is extremely difficult. How can
we identify a transaction that is incorrectly labeled as suspicious? Learning from incorrect data
leads to inaccurate models.
• Another limitation of data mining is that it only extracts knowledge limited to the specific set of
historical data, and answers can only be obtained and interpreted with regards to previous trends
learned from the data.
• This limits one’s ability to benefit from new trends. Because the decision tree is trained
specifically on the historical data set, it does not account for personalization within the
tree. Additionally, data mining (decision trees, rules, clusters) are non-incremental and do not
adapt while in production.

17-03-2021 18CSC305J_AI_UNIT3 194


Knowledge and Reasoning
Table of Contents
• Knowledge and reasoning-Approaches and issues of knowledge
reasoning-Knowledge base agents
• Logic Basics-Logic-Propositional logic-syntax ,semantics and
inferences-Propositional logic- Reasoning patterns
• Unification and Resolution-Knowledge representation using rules-
Knowledge representation using semantic nets
• Knowledge representation using frames-Inferences-
• Uncertain Knowledge and reasoning-Methods-Bayesian probability and
belief network
• Probabilistic reasoning-Probabilistic reasoning over time
• Other uncertain techniques-Data mining-Fuzzy logic-Dempster -shafer theory
17-03-2021 18CSC305J_AI_UNIT3 195
Operation of Fuzzy System
Crisp Input

Fuzzification Input Membership Functions

Fuzzy Input

Rule Evaluation Rules / Inferences

Fuzzy Output

Defuzzification Output Membership Functions

Crisp Output 196


Building Fuzzy Systems
 Fuzzification
 Inference
 Composition
 Defuzzification

197
Fuzzification
 Establishes the fact base of the fuzzy system. It identifies the input and output of the
system, defines appropriate IF THEN rules, and uses raw data to derive a
membership function.
 Consider an air conditioning system that determine the best circulation level by
sampling temperature and moisture levels. The inputs are the current temperature
and moisture level. The fuzzy system outputs the best air circulation level: “none”,
“low”, or “high”. The following fuzzy rules are used:
1. If the room is hot, circulate the air a lot.
2. If the room is cool, do not circulate the air.
3. If the room is cool and moist, circulate the air slightly.
 A knowledge engineer determines membership functions that map temperatures
to fuzzy values and map moisture measurements to fuzzy values.
198
Inference
 Evaluates all rules and determines their truth values. If an input does not
precisely correspond to an IF THEN rule, partial matching of the input data is
used to interpolate an answer.
 Continuing the example, suppose that the system has measured temperature
and moisture levels and mapped them to the fuzzy values of .7 and .1
respectively. The system now infers the truth of each fuzzy rule.
 To do this a simple method called MAX-MIN is used. This method sets the
fuzzy value of the THEN clause to the fuzzy value of the IF clause. Thus, the
method infers fuzzy values of 0.7, 0.1, and 0.1 for rules 1, 2, and 3
respectively.

199
Composition
 Combines all fuzzy conclusions obtained by inference into a single conclusion.
Since different fuzzy rules might have different conclusions, consider all rules.
 Continuing the example, each inference suggests a different action
 rule 1 suggests a "high" circulation level
 rule 2 suggests turning off air circulation
 rule 3 suggests a "low" circulation level.
 A simple MAX-MIN method of selection is used where the maximum fuzzy value
of the inferences is used as the final conclusion. So, composition selects a fuzzy
value of 0.7 since this was the highest fuzzy value associated with the inference
conclusions.
200
Defuzzification
 Convert the fuzzy value obtained from composition into a “crisp” value. This
process is often complex since the fuzzy set might not translate directly into a
crisp value.Defuzzification is necessary, since controllers of physical systems
require discrete signals.
 Continuing the example, composition outputs a fuzzy value of 0.7. This
imprecise value is not directly useful since the air circulation levels are “none”,
“low”, and “high”. The defuzzification process converts the fuzzy output of
0.7 into one of the air circulation levels. In this case it is clear that a fuzzy
output of 0.7 indicates that the circulation should be set to “high”.

201
Defuzzification
 There are many defuzzification methods. Two of the more common
techniques are the centroid and maximum methods.
 In the centroid method, the crisp value of the output variable is
computed by finding the variable value of the center of gravity of the
membership function for the fuzzy value.
 In the maximum method, one of the variable values at which the fuzzy
subset has its maximum truth value is chosen as the crisp value for the
output variable.

202
Example: Design of Fuzzy Expert System – Washing
Machine

FDP on AI & Advanced Machine Learning using Data


203
Science, 22/11/19
Fuzzification

Given inputs x1 and x2, find the weight


values associated with each input
membership function.
NM NS Z PS PM

0.7

0.2

X1

W = [0, 0, 0.2, 0.7, 0]


Fuzzy Rules
Not Greasy Medium Greasy

Small Dirt Time= Vshort Medium Long

Medium Dirt Short Medium Long

Large Dirt Medium Long Very Long

Demystifying AI algorithms
DeFuzzification
Washing Time Long = (Y- 30)/(40-30)
Washing Time Medium = (Y- 20)/(30-20)

Very short Short Medium Long Very Long

5 10 20 30 40 60
(Y – 20)/(30-20) = 0.5
X1 and X2 = 0.5 Y – 20 = 0.5* 10 = 5
Y = 25 Mins
Demystifying AI algorithms
Knowledge and Reasoning
Table of Contents
• Knowledge and reasoning-Approaches and issues of knowledge reasoning-
Knowledge base agents
• Logic Basics-Logic-Propositional logic-syntax ,semantics and inferences-
Propositional logic- Reasoning patterns
• Unification and Resolution-Knowledge representation using rules-Knowledge
representation using semantic nets
• Knowledge representation using frames-Inferences-
• Uncertain Knowledge and reasoning-Methods-Bayesian probability and belief
network
• Probabilistic reasoning-Probabilistic reasoning over time
• Other uncertain techniques-Data mining-Fuzzy logic-Dempster -shafer theory
17-03-2021 18CSC305J_AI_UNIT3 207
Dempster Shafer Theory
• Dempster Shafer Theory is given by Arthure P.Dempster in 1967 and his student
Glenn Shafer in 1976.
This theory is being released because of following reason:-
• Bayesian theory is only concerned about single evidences.
• Bayesian probability cannot describe ignorance.
• DST is an evidence theory, it combines all possible outcomes of the problem.
Hence it is used to solve problems where there may be a chance that a different
evidence will lead to some different result.
The uncertainity in this model is given by:-
• Consider all possible outcomes.
• Belief will lead to believe in some possibility by bringing out some evidence.
• Plausibility will make evidence compatibility with possible outcomes.

17-03-2021 18CSC305J_AI_UNIT3 208


Dempster Shafer Theory
For eg:-
let us consider a room where four person are presented A, B, C, D(lets say) And suddenly lights out and
when the lights come back B has been died due to stabbing in his back with the help of a knife. No one came
into the room and no one has leaved the room and B has not committed suicide. Then we have to find out
who is the murdrer?
To solve these there are the following possibilities:
• Either {A} or{C} or {D} has killed him.
• Either {A, C} or {C, D} or {A, C} have killed him.
• Or the three of them kill him i.e; {A, C, D}
• None of the kill him {o}(let us say).
These will be the possible evidences by which we can find the murderer by measure of plausibIlity.
Using the above example we can say :
Set of possible conclusion (P): {p1, p2….pn}
where P is set of possible conclusion and cannot be exhaustive means at least one (p)i must be true.
(p)i must be mutually exclusive.
Power Set will contain 2n elements where n is number of elements in the possible set.
For eg:-
If P = { a, b, c}, then Power set is given as
{o, {a}, {b}, {c}, {a, b}, {b, c}, {a, c}, {a, b, c}}= 23 elements.
17-03-2021 18CSC305J_AI_UNIT3 209
Dempster Shafer Theory
• Mass function m(K): It is an interpretation of m({K or B}) i.e; it means there is
evidence for {K or B} which cannot be divided among more specific beliefs for K
and B.
• Belief in K: The belief in element K of Power Set is the sum of masses of element
which are subsets of K. This can be explained through an example
Lets say K = {a, b, c}
Bel(K) = m(a) + m(b) + m(c) + m(a, b) + m(a, c) + m(b, c) + m(a, b, c)
• Plaausiblity in K: It is the sum of masses of set that intersects with K.
i.e; Pl(K) = m(a) + m(b) + m(c) + m(a, b) + m(b, c) + m(a, c) + m(a, b, c)
Characteristics of Dempster Shafer Theory:
• It will ignorance part such that probability of all events aggregate to 1.
• Ignorance is reduced in this theory by adding more and more evidences.
• Combination rule is used to combine various types of possibIlities.

17-03-2021 18CSC305J_AI_UNIT3 210


Dempster Shafer Theory
Advantages:
• As we add more information, uncertainty interval reduces.
• DST has much lower level of ignorance.
• Diagnose Hierarchies can be represented using this.
• Person dealing with such problems is free to think about evidences.
Disadvantages:
• In this computation effort is high, as we have to deal with 2n of sets.

17-03-2021 18CSC305J_AI_UNIT3 211


•P(

) = ({

Dempster Shafer Problem


Example: 4 people (B, J, S and K) are locked in a room when light goes out .
When light comes on, K is dead, staffed whit a knife.
Not suicide (staffed in the back)
No one entered room.
Assume only one killer

P(ϴ) = ({
Detectives after receiving the crime scene, assign mass probabilities to various elements of the
power set:
Event Mass
No one is guilty 0
B is guilty 0.1
J is guilty 0.2
S is guilty 0.1
Either B or J is guilty 0.1
Either B or S is guilty 0.1
Either S or J is guilty 0.3
One of the 3 is guilty 0.1
17-03-2021 18CSC305J_AI_UNIT3 212
Dempster Shafer Problem
Belief in A:
The belief in an element A of the power set is the sum of the masses of
elements which are subsets of A (including A itself)
Ex: Given A= {q1, q2, q3}
Bet (A)
={m(q1)+m(q2)+m(q3)+m(q1,q2)+m(q2,q3),m(q1,q3)+m(q1,q2,q3)}
Ex: Given the above mass assignments,
Bel(B) = m(B) =0.1
Bel (B,J) = m(B)+m(J)+m(B,J) = 0.1+0.2=0.1 0.4
RESULT: A {B} {J} {S} {B,J} {B,S} {S,J} {B,J,S}

M(A) 0.1 0.2 0.1 0.1 0.1 0.3 0.1

Bel (A) 0.1 0.2 0.1 0.4 0.3 0.6 1.0

17-03-2021 18CSC305J_AI_UNIT3 213


Dempster Shafer Problem
Plausibility of A: pl(A)
The plausibility of an element A, pl(a), is the sum of all the masses of
the sets that instruct with the
Set A : Ex:Pl (B,J) =M(B) +m(J)+M(B,J)+M(B,S)+M(J,S)+M(B,J,S)=0.9
All Result:
A {B} {J} {S} {B,J} {B,S} {S,J} {B,J,S}

M(A) 0.1 0.2 0.1 0.1 0.1 0.3 0.1

Pl (A) 0.4 0.7 0.6 0.9 0.8 0.9 1.0

17-03-2021 18CSC305J_AI_UNIT3 214


Dempster Shafer Problem
Disbelief (or Doubt) in A: dis (A)
The disbelief in A is simply bel (7A)
It is calculated by summing all masses of elements which do not intersect with A
D is (A) = 1-pl (A)
Or
A {B} {J} {S} {B,J} {B,S} {S,J} {B,J,S}
Pl (A) = 1-Dis (A)
Pl(A) 0.4 0.7 0.6 0.9 0.8 0.9 1.0

Dis(A) 0.6 0.3 0.4 0.1 0.2 0.1 0.0


Belief Interval of A:
The certainty associated with a give subset A is defined by the belief interval: [bel(A) p(A)]
Ex . The belief interval of (B,S) IS [0.3,08]

A {B} {J} {S} {B,J} {B,S} {S,J} {B,J,S}


M(A) 0.1 0.2 0.1 0.1 0.1 0.3 0.1
Bel (A) 0.1 0.2 0.1 0.4 0.3 0.6 1.0
Pl(A) 0.4 0.7 0.6 0.9 0.8 0.9 1.0

17-03-2021 18CSC305J_AI_UNIT3 215


Dempster Shafer Problem
P(A) represents the maximum share of the evidence. We could possibly have, if for all its that intouects with A, the part that intracts actually
valid. So, Pl(A) is the max possible value of prof(A).
Belief intervals and Probability
The probability in A falls some ware between bel (A) and pl(A).
-bel (A) represents the evidence. We have for a directly So proof (A) cannot be less than this value.
- PL(A) represents the maximum share of the evidence we could possibly have. If, for all sets that intersects with A, the part that intersects is
actually valid. So, PL(A) is the max possible value of proof(A).
Belief intervals allow Dempster, Shaffer theory to reason about the degree of certainity or certainity of our beliefs.
A small difference between belief and plausibility shows that we are curtain about our belief.
A large difference shows that we are uncertain about our belief.
however, even with a ‘O’ interval, this does not mean we know which conclusion is right.
A {B} {J} {S} {B,J} {B,S} {S,J} {B,J,S}

M(A) 0.1 0.2 0.1 0.1 0.1 0.3 0.1

Bel (A) 0.1 0.2 0.1 0.4 0.3 0.6 1.0

Pl(A) 0.4 0.7 0.6 0.9 0.8 0.9 1.0

Belief {0.1,0.4} {0.2,0.7} {0.1,0.6} {0.4,0.9} {0.3,0.8} {0.6,0.9} {1,1}


17-03-2021 18CSC305J_AI_UNIT3 216
interval
Thank You
17-03-2021 18CSC305J_AI_UNIT3 217
Unit 4

Planning
4/7/2021 1
What is Planning?
• The task of coming up with a sequence of
actions that will achieve a goal is called
planning.
• Planning Environments
1. Classical Planning Environments
• Fully observable, deterministic, finite, static and
discrete.
2. Non classical Planning Environments
• Partially observable, stochastic with different
algorithms and agent designs.
4/7/2021 2
Planning (Contd..)
• Difficulty in problem-solving agent
– Performs irrelevant actions
• Have to explore all the states
• Ex: buy book with 10-digit ISBN 1010 actions
– Finding heuristics function
• Problem-solving agent lacks autonomy because it
depends on human to supply heuristic function for
each new problem.
– No problem decomposition
• All these problems are overcome by planning agent by
representing the goal as conjunction of subgoals.
4/7/2021 3
PLANNING PROBLEM
The planning problem is actually the question how to go to next state or the
goal state from the current state. It involves two things 'how' and 'when'.
• The planning problem is defined with:
1. Domain model
2. Initial state
3. Goal state (next state)

The domain model defines the actions along with the objects. It is necessary
to specify the operators too that actually describe the action. Along with this,
information about actions and state constraints while acting should also be
given. This entirely formulates the domain model.
The initial state is the state where any action is yet to take place (the stage
when the exam schedule is put up!).
The final state or the goal state is the state which the plan is intended to
achieve.
4/7/2021 4
Planning Problem
• Find sequence of actions - achieves a given
goal from a given initial world state.
– a set of operator descriptions
– an initial state description, and
– a goal state description or predicate,
• compute a plan
– a sequence of operator instances,
– executing them in the initial state will change the
world to a state satisfying the goal-state
description.
• Goals - specified as a conjunction of subgoals
to be achieved
4/7/2021 5
Simple Planning Agent
 An agent interacts with real world via perception and
actions
 Perception - sense the world and assess the situation
 Actions - what the agent does in the domain.
 Planning involves reasoning about actions that the agent
intends to carry out
 This reasoning involves the representation of the world
that the agent has - representation of its actions.
 Hard constraints - objectives have to be achieved
completely for success
 The objectives - soft constraints, or preferences, to be
achieved as much as possible

4/7/2021 6
Planning vs. Problem solving
• Planning agent is very similar to problem solving agent
– Constructs plans to achieve goals, then executes them
• Planning is more powerful because of the
representations and methods used
• Search - proceeds through plan space rather than state
space
• Sub-goals - planned independently, it reduce the
complexity of the planning problem

4/7/2021 7
Planning Agents
• problem-solving agents are able to plan ahead - to
consider the consequences of sequences of actions -
before acting.
• knowledge- based agents can select actions based on
explicit, logical representations of the current state
and the effects of actions.
– This allows the agent to succeed in complex,
inaccessible environments that are too difficult for
a problem-solving agent
– Problem Solving Agents + Knowledge-based Agents
= Planning Agents

4/7/2021 8
Simple Planning Agent
• A simple planning agent is very similar to problem-solving agents in that it
constructs plans that achieve its goals, and then executes them.
• The limitations of the problem- solving approach motivates the design of
planning systems.
To solve a planning problem using a state-space search approach we would
let the:
• initial state = initial situation
• goal-test predicate = goal state description
• successor function computed from the set of operators
• once a goal is found, solution plan is the sequence of operators in the path
from the start node to the goal node

4/7/2021 9
Simple Planning Agent
• Planning can be viewed as a type of problem solving in which the
agent uses beliefs about actions and their consequences to search
for a solution over the more abstract space of plans, rather than
over the space of situations.
Algorithm of a simple planning agent:

1. Generate a goal to achieve


2. Construct a plan to achieve goal from current state
3. Execute plan until finished
4. Begin again with new goal
• The agent first generates a goal to achieve, and then constructs a
plan to achieve it from the current state. Once it has a plan, it
keeps executing it until the plan is finished, then begins again with
a new goal.
4/7/2021 10
Key Ideas Behind Planning
• Planning emphasizes what is in operator and goal
representations.
There are three key ideas behind planning:
• to "open up" the representations of state, goals, and
operators so that a reasoner can more intelligently select
actions when they are needed
• the planner is free to add actions to the plan wherever they
are needed, rather than in an incremental sequence starting
at the initial state
• most parts of the world are independent of most other parts
which makes it feasible to take a conjunctive goal and solve it
with a divide-and-conquer strategy
4/7/2021 11
Planning Languages
• Languages must represent..
– States
– Goals
– Actions
• Languages must be
– Expressive for ease of representation
– Flexible for manipulation by algorithms

12
State Representation
• A state is represented with a conjunction of positive
literals
• Using
– Logical Propositions: Poor  Unknown
– FOL literals: At(Plane1,OMA)  At(Plan2,JFK)
• FOL literals must be ground & function-free
– Not allowed: At(x,y) or At(Father(Fred),Sydney)
• Closed World Assumption
– What is not stated are assumed false

13
Goal Representation
• Goal is a partially specified state
• A proposition satisfies a goal if it contains all
the atoms of the goal and possibly others..
– Example: Rich  Famous  Miserable satisfies the
goal Rich  Famous

14
Action Representation
At(WHI,LNK),Plane(WHI),
• Action Schema Airport(LNK), Airport(OHA)
– Action name Fly(WHI,LNK,OHA)
– Preconditions
At(WHI,OHA),  At(WHI,LNK)
– Effects
• Example
Action(Fly(p,from,to),
PRECOND: At(p,from)  Plane(p)  Airport(from)  Airport(to)
EFFECT: At(p,from)  At(p,to))

• Sometimes, Effects are split into ADD list and DELETE


list

15
Languages for Planning Problems

• STRIPS
– Stanford Research Institute Problem Solver
– Historically important
• ADL
– Action Description Languages
• PDDL
– Planning Domain Definition Language

16
Planning languages
• A language is the one that should be expressive.
• Three Languages
– I. Stanford Research Institute Problem Solver (STRIPS)
– 2. Action Description Language (ADL)
– 3. Planning Domain Description Language (PDDL)
1) Stanford Research Institute Problem Solver (STRIPS) :
Makes use of the first order predicates.
STRIPS allows function-free literals.
Example of a robot: The example involves a robot, a cup tea, guest and two
rooms. We want the robot to get the tea and give it to the guest.
The planning with STRIPS is done as follows:
Let us begin with the STRIPS representation for this example.
Initial and final states are depicted in figure.

4/7/2021 17
Example of a robot

4/7/2021 18
Block World
• There are ‘N’ number of Blocks resting on
table with specified sequence.
• Goal is to arrange in desired sequence.
• Available moves
– Put block on table
– Put a block on another block top
• State is represented using sequence of blocks
in current pos.
4/7/2021 19
STRIPS
• STRIPS stands for "STanford Research Institute Problem
Solver," was the planner used in Shakey, one of the first robots
built using AI technology ,which is an action-centric
representation ,for each action , specifies the effect of an
action.

The STRIPS representation for an action consists of


• the precondition, which is a set of assignments of values to
features that must be true for the action to occur, and
• the effect, which is a set of resulting assignments of values to
those primitive features that change as the result of the action.

4/7/2021 20
Block World Problem
• Action List:
SNo Action Precondition Effect

1 Pickup(x) Arm Empty Holding(x)


On(x, Table)
Clear(x)
2 Putdown (x) Holding(x) Arm Empty
On(x, Table)
Clear(x)
3 Stack(x,y) Holding(x) On(x,y)
Clear(y) Clear(x)
Arm Empty
4 Unstack(x,y) On(x,y) Holding(x)
Clear(x) Clear(y)
Arm Empty
4/7/2021 21
Block World Problem
• Start State:

• Goal State:

4/7/2021 22
Block World Problem
Solution:
• Start State: On(A,B)
– On(A, table)
– On(B, table)
• Goal State: Stack(A,B)(

– On(A,B) Preconditions:
Holding(A) Pickup(A)
Clear(B)
Preconditions:
Arm Empty
On(A, Table)
Clear(A)

4/7/2021 23
Means - Ends Analysis
• Search strategies either reason forward of backward
• Mixed strategy - solve the major parts of problem first and
solve the smaller problems that arise when combining them
together.
• Such a technique is called "Means - Ends Analysis".
• Means-Ends Analysis is problem-solving techniques used in
Artificial intelligence for limiting search in AI programs.
• It is a mixture of Backward and forward search technique.
• The means -ends analysis process centers around finding the
difference between current state and goal state.

4/7/2021 24
Means - Ends Analysis
How means-ends analysis Works:
• The means-ends analysis process can be applied recursively
for a problem. It is a strategy to control search in problem-
solving.
Following are the main Steps which describes the working of
MEA technique for solving a problem.
1. First, evaluate the difference between Initial State and final
State.
2. Select the various operators which can be applied for each
difference.
3. Apply the operator at each difference, which reduces the
difference between the current state and goal state.
4/7/2021 25
MEA Algorithm
• Step 1: Compare CURRENT to GOAL, if there are no differences between
both then return Success and Exit.
• Step 2: Else, select the most significant difference and reduce it by doing
the following steps until the success or failure occurs.
a. Select a new operator O which is applicable for the current
difference, and if there is no such operator, then signal failure.
b. Attempt to apply operator O to CURRENT. Make a description of two
states.
i) O-Start, a state in which O?s preconditions are satisfied.
ii) O-Result, the state that would result if O were applied In O-start.
c. If
(First-Part <------ MEA (CURRENT, O-START)
And
(LAST-Part <----- MEA (O-Result, GOAL), are successful, then signal
Success and return the result of combining FIRST-PART, O, and LAST-
PART.
4/7/2021 26
Example of Mean-Ends Analysis:
• Apply MEA to get the goal state.

• Solution:
• To solve the above problem, first find the differences between initial states
and goal states, and for each difference, generate a new state and will
apply the operators. The operators we have for this problem are:
• Move
• Delete
• Expand

4/7/2021 27
Example of Mean-Ends Analysis:
Step 1: Evaluate Initial State
Step 3: Apply Move Operator

Step 2: Apply Delete Operator Step 1: Apply Expand Operator

4/7/2021 28
NON-LINEAR PLANNING
• A plan that consists of sub-problems, which are solved
simultaneously is said non-linear plan.
• In case of the goal stack planning there are some problems. To
achieve any goal, it could have an impact on the one that has
been achieved.

4/7/2021 29
NON-LINEAR PLANNING (Contd..)
There is a concept of constraint posting that
comes with non-linear planning. The constraint
posting states that the plan can be built by
• 1. Addition of operators or suggesting
operators
• 2. Ordering them
• 3. Binding the variables to the operators

4/7/2021 30
Conditional Planning
• Conditional planning has to work regardless of the outcome of
an action.
• The outcome of actions cannot be determined so the
environment is said to be nondeterministic.
• It’s a way to deal with uncertainty by checking what is actually
happening in the environment at predetermined points in the
plan. (Conditional Steps)
Example:
Check whether SFO airport (San Francisco International
Airport) is operational. If so, fly there; otherwise, fly to some
other place.

4/7/2021 31
Conditional Planning
• Three kind of Environments
Fully Observable
• The agent always knows the current state
Partially Observable
• The agent knows only a certain amount about
the actual state. (much more common in real
world)
Unknown
• The agent knows nothing about the current
state
4/7/2021 32
Conditional Planning in Fully
Observable Environments
• Agent used conditional steps to check the
state of the environment to decide what to do
next.
• Plan information stores in a library Ex:
Action(Left) Clean v Right

Syntax: If then plan_A else plan_B

4/7/2021 33
Reactive Planning
• Reactive planning is planning under uncertainty.
• Makes use of the if-then rules.
• The reactive planners are based on the concept that they should be able
to handle an unknown situation too. So, the reaction rules are used that
help them in doing so.
• A rule selection is based on the priority and a holding condition that
maximises the priority.
• The rule which is at present in execution is said to be active whereas the
and the ones with holding priority (we can call them possible competitors)
are pre-active others are inactive.
• A B-tree structure is used in reactive planning, where the things are
algorithm selects the rule. Sometimes, no rule can be selected. In such a
case, dependent on the algorithm implementation for rule selection.

4/7/2021 34
LEARNING
learning consists of various activities like
understanding, memorisation, knowledge
acquisition and inference.
Learning is a continuous process
Learning from observation is required to
construct meaningful classification of
observed objects and situations.
MACHINE LEARNING
ACTIVE LEARNING MECHANISM
Perceptual learning
– learning of new objects , categories , relations.
Episodic Learning
– Learning of events like What , where and when
Procedural learning
– actions and their sequences to accomplish a task.

Machine Learning
Machine learning is building and exploring of methods for
programming computer to make them Learn.
Machine learning Vs Human Learning
Machine Learning approach
Scope of machine learning
GOALS OF MACHINE LEARNING
• To produce learning algorithms with practical
value.
• Development and enhancement of computer
algorithms and models to meet the decision
making requirements in practical scenarios.
• To facilitate in building intelligent systems (IS)
that can be used in solving real time problems.
Challenges of Machine Learning
• Avaliability of limited learning data and
unknown perspectives.
• Aquiring Accurate , compact and precise
knowledge building.
• Require large working memory to store data.
• Focusing Too Much on Algorithms and Theories
• Monitoring and maintenance
Learning Concepts , methods and
models
Computational structure used in Machine
learning:
1. Functions.

2. Logic programs and rule sets

3. Finite state machines

4. Grammars

5. Problem solving system


Traditional paradigm

• Rote learning
• Learning from observations
• Supervised learning
• unsupervised learning
• semi-supervised learning
• ensemble learning
• Discovery based learning
• Learning by problem solving
Rote learning

● Rote learning is rudimentary form of


learning, which focuses on memorization.
● Storing or memorizing the results improves

the performance of a system


● saves a significant amount of time.

● Example selective paging catching


Learning from observations
Types of learning
• learning from agents
• inductive learning
• decision tree learning
Learning from agents

•An agent is defined the computational entity which is capable of receiving the
environment and can act based on the situation.
•The agent is composed of learning element performance element and a curiosity
element.
•Based on the coordination between these elements the outcome of the agents
behaviour is measured.
Inductive Learning
● Inductive learning involves learning generalized rules from specific examples (can
think of this as the “inverse” of deduction)
● Main task: given a set of examples, each classified as positive or negative produce a
concept description that matches exactly the positive examples.
● The examples are coded in some representation language, e.g. they are coded by a
finite set of real-valued features.
● The concept description is in a certain language that is presumably a superset of
the language of possible example encodings.
● A “correct” concept description is one that classifies correctly ALL possible
examples, not just those given in the training set.
Decision Tree Learning

•The learned function is represented by a decision tree.


•In terms of programming it is also represented as if then rules.
•Decision tree depicts the simple learning from the observation, method.
•Based on the observation, at every node, decision is taken.
Supervised learning
•Based on the labelled data set.
•supervised learning is the learning algorithm that is provided
with the set of training data and the algorithm further induces
the classifier to classify the unseen or new data.
• A line (hyperplane) which is generated after learning
separating two classes class A and class the in two parts the
classifier and the decision-making engine minimize the false
positives and false negative.
Unsupervised Learning
● Use unlabeled dataset.
● Learning is more based on similarities
and differences which are visible. These
differences and similarities are
mathematically represented in
unsupervised learning
● Grouping and categorisation of the
objects is based on the understanding of
similarities and visualisation of their
relations
● Unsupervised learning performs
hierarchical clustering.
Semi - Supervised Learning
● Semi supervised learning is developed to cope up
with the issues of learning in supervised or
unsupervised mode in isolation.
● Semi-supervised learning tries to learn from the
labelled as well as unlabeled data.
● Let U be a set of unlabeled data and L be a set of
labelled data.
● As the learning process the learning approach
identifies the unlabeled data U with reference to a
labelled data L and keeps on labelling the
unlabeled data.
● This method is also called as self training in semi
supervised learning.
Discovery based learning
On the basis of past experience and
knowledge tries to discover the outcomes
Learning by Problem Solving
Various parameters related to solution and
problem are considered. These parameters are
used and effectively desirability of a particular
outcome or decision is determined
Learning Methods
•Artificial neural network based learning-Back
propagation
•Support vector machines
•Reinforcement learning
•Adaptive learning
•Multi_agent based learning
•Ensemble learning
•Learning for decision making
•Distributed learning
•Speedup learning
Artificial neural network based
learning
ANN is a computational model that performs simulation of the
human biological neurons.
The simulation is concerned with the functioning of neurons.
Artificial neurons have different inputs which are weighted as
per the strength of signal and then computed by mathematical
function which determines the activation of the neurons.
ANNs combined artificial neurons in order to process
information the hidden layer is the one that Learns to recode
for the input .
Back- propagation Algorithm

Back-propagation is the essence of neural net training.


It is the method of fine-tuning the weights of a neural net based on the
error rate obtained in the previous epoch (i.e., iteration).
Proper tuning of the weights allows you to reduce error rates and to make
the model reliable by increasing its generalization.
Backpropagation Algorithm
Backpropagation Algorithm
1. Inputs X, arrive through the preconnected path
2. Input is modeled using real weights W. The weights are usually randomly selected.
3. Calculate the output for every neuron from the input layer, to the hidden layers, to the output layer.
4. Calculate the error in the outputs.
ErrorB= Actual Output – Desired Output

5. Travel back from the output layer to the hidden layer to adjust the weights such that the error is
decreased.

Keep repeating the process until the desired output is achieved.


Backpropagation Algorithm

Forward pass:
computes ‘functional signal’, feed forward
propagation of input pattern signals through
network
Backward pass phase:
computes ‘error signal’, propagates the error
backwards through network starting at output
units (where the error is the difference
between actual and desired output values)
Support Vector Machines (SVM)
 Supervised learning methods for classification and regression
relatively new class of successful learning methods -

they can represent non-linear functions and they have an efficient


training algorithm

 derived from statistical learning theory by Vapnik and Chervonenkis


(COLT-92)

 SVM got into mainstream because of their exceptional performance in


Handwritten Digit Recognition
•1.1% error rate which was comparable to a very carefully
constructed (and complex) ANN
Motivation for Support Vector
Machines
• The problem to be solved is one of the supervised binary
classification. That is, we wish to categorize new unseen
objects into two separate groups based on their properties
and a set of known examples, which are already categorized.
• A good example of such a system is classifying a set of new
documents into positive or negative sentiment groups, based
on other documents which have already been classified as
positive or negative.
• Similarly, we could classify new emails into spam or non-
spam, based on a large corpus of documents that have
already been marked as spam or non-spam by humans. SVMs
are highly applicable to such situations.
60
Motivation for Support Vector
Machines
• A Support Vector Machine models the situation by creating
a feature space, which is a finite-dimensional vector space, each
dimension of which represents a "feature" of a particular object.
In the context of spam or document classification, each "feature"
is the prevalence or importance of a particular word.
• The goal of the SVM is to train a model that assigns new unseen
objects into a particular category.
• It achieves this by creating a linear partition of the feature space
into two categories.
• Based on the features in the new unseen objects (e.g.
documents/emails), it places an object "above" or "below" the
separation plane, leading to a categorization (e.g. spam or non-
spam). This makes it an example of a non-probabilistic linear
classifier. It is non-probabilistic, because the features in the new
objects fully determine its location in feature space and there is
no stochastic element involved.
61
OBJECTIVES
• Support vector machines (SVM) are supervised
learning models with associated learning algorithms that
analyze data used for classification and regression analysis.
• It is a machine learning approach.
• They analyze the large amount of data to identify patterns
from them.
• SVMs are based on the idea of finding a hyperplane that
best divides a dataset into two classes, as shown in the
image below.

62
Support Vectors
• Support Vectors are simply the co-ordinates of individual
observation. Support Vector Machine is a frontier which best
segregates the two classes (hyper-plane/ line).
• Support vectors are the data points that lie closest to the
decision surface (or hyperplane)
• They are the data points most difficult to classify
• They have direct bearing on the optimum location of the
decision surface
• We can show that the optimal hyperplane stems from the
function class with the lowest “capacity” (VC dimension).
• Support vectors are the data points nearest to the hyperplane,
the points of a data set that, if removed, would alter the position
of the dividing hyperplane. Because of this, they can be
considered the critical elements of a data set.

63
What is a hyperplane?
• As a simple example, for a classification task with
only two features, you can think of a hyperplane as a
line that linearly separates and classifies a set of
data.
• Intuitively, the further from the hyperplane our data
points lie, the more confident we are that they have
been correctly classified. We therefore want our data
points to be as far away from the hyperplane as
possible, while still being on the correct side of it.
• So when new testing data are added, whatever side
of the hyperplane it lands will decide the class that
we assign to it. 64
4/7/2021 65
How do we find the right
hyperplane?
• How do we best segregate the two classes within the data?
• The distance between the hyperplane and the nearest data
point from either set is known as the margin. The goal is to
choose a hyperplane with the greatest possible margin
between the hyperplane and any point within the training
set, giving a greater chance of new data being classified
correctly. There will never be any data point inside the
margin.

66
But what happens when there is
no clear hyperplane?
• Data are rarely ever as clean as our simple example above. A dataset will
often look more like the jumbled balls below which represent a linearly
non separable dataset.

• In order to classify a dataset like the one above it’s necessary to move
away from a 2d view of the data to a 3d view. Explaining this is easiest
with another simplified example. Imagine that our two sets of colored
balls above are sitting on a sheet and this sheet is lifted suddenly,
launching the balls into the air. While the balls are up in the air, you use
the sheet to separate them. This ‘lifting’ of the balls represents the
mapping of data into a higher dimension. This is known as kernelling.
67
Because we are now in three dimensions, our
hyperplane can no longer be a line. It must now be a
plane as shown in the example above. The idea is
that the data will continue to be mapped into higher
and higher dimensions until a hyperplane can be
formed to segregate it. 68
How does it work? How can we
identify the right hyper-plane?

• You need to remember a thumb rule to


identify the right hyper-plane:
“Select the hyper-plane which segregates
the two classes better”.

69
Identify the right hyperplane
(Scenario-1):
• Here, we have three hyperplanes (A, B and C). Now,
identify the right hyperplane to classify star and circle.

• Hyperplane “B” has excellently performed this job.

70
Identify the right hyperplane
(Scenario-2):
• Here, we have three hyperplanes (A, B and C)
and all are segregating the classes well. Now,
how can we identify the right hyperplane?

Here, maximizing the


distances between nearest
data point (either class)
and hyperplane will help us
to decide the right
hyperplane.
71
Scenario-2
This distance is called as Margin. Let’s look at the
below snapshot:
We can see that the margin for
hyperplane C is high as compared to
both A and B. Hence, we name
the right hyperplane as C. Another
lightning reason for selecting the
hyperplane with higher margin is
robustness. If we select a hyperplane
having low margin then there is high
chance of missclassification.
72
Identify the right hyperplane
(Scenario-3)

• Some of you may have selected the hyper-plane B as it has higher margin
compared to A. But, here is the catch, SVM selects the hyperplane which
classifies the classes accurately prior to maximizing margin. Here,
hyperplane B has a classification error and A has classified all correctly.
Therefore, the right hyperplane is A.

73
Can we classify two classes (Scenario-4)?

• We are unable to segregate the two classes using a straight line, as one of
star lies in the territory of other (circle) class as an outlier.
• One star at other end is like an outlier for star class. SVM has a feature to
ignore outliers and find the hyperplane that has maximum margin. Hence,
we can say, SVM is robust to outliers.

74
Find the hyperplane to segregate
to classes (Scenario-5)
• In the scenario below, we can’t have linear hyperplane
between the two classes, so how does SVM classify these two
classes? Till now, we have only looked at the linear
hyperplane.

SVM can solve this


problem. It solves this
problem by
introducing additional
feature. Here, we will
add a new feature
z=x2+y2.
75
Scenario-5
• Now, let’s plot the data points on axis x and z:

• In above plot, points to consider are:


• All values for z would be positive always because z is the
squared sum of both x and y
• In the original plot, red circles appear close to the origin of
x and y axes, leading to lower value of z and star relatively
away from the origin result to higher value of z.
76
Scenario-5
• In SVM, it is easy to have a linear hyperplane between these
two classes. But, another burning question which arises
is, should we need to add this feature manually to have a
hyperplane. No, SVM has a technique called the kernel trick.
• These are functions which takes low dimensional input space
and transform it to a higher dimensional space i.e. it converts
not separable problem to separable problem, these functions
are called kernels. It is mostly useful in non-linear separation
problem. Simply put, it does some extremely complex data
transformations, then find out the process to separate
the data based on the labels or outputs you’ve defined.

77
Scenario-5
• When we look at the hyperplane in original
input space it looks like a circle:

4/7/2021 78
Two Class Problem: Linear Separable
Case

Class 2
• Many decision
boundaries can
separate these
two classes
• Which one should
Class 1 we choose?
Example of Bad Decision
Boundaries

Class 2 Class 2

Class 1 Class 1
Good Decision Boundary: Margin Should Be
Large
• The decision boundary should be as far away
from the data of both classes as possible
–We should maximize the margin, m 2
m
w.w
Support vectors
datapoints that the margin
pushes up against

Class 2
The maximum margin linear
classifier is the linear classifier

Class 1
m with the maximum margin.
This is the simplest kind of
SVM (Called an Linear SVM)
What is Reinforcement Learning?
• Learning from interaction with an environment to
achieve some long-term goal that is related to the
state of the environment
• The goal is defined by reward signal, which must
be maximised.
• Agent must be able to partially/fully sense the
environment state and take actions to influence
the environment state
• The state is typically described with a feature-
vector
Reinforcement learning

4/7/2021 83
Exploration versus Exploitation
• We want a reinforcement learning agent to earn lots of
reward
• The agent must prefer past actions that have been
found to be effective at producing reward
• The agent must exploit what it already knows to obtain
reward
• The agent must select untested actions to discover
reward-producing actions
• The agent must explore actions to make better action
selections in the future
• Trade-off between exploration and exploitation
Reinforcement Learning Systems
• Reinforcement learning systems have 4 main
elements:
– Policy
– Reward signal
– Value function
– Optional model of the environment
Policy
• A policy is a mapping from the perceived
states of the environment to actions to be
taken when in those states
• A reinforcement learning agent uses a policy
to select actions given the current
environment state
On-policy versus Off-policy
• An on-policy agent learns only about the
policy that it is executing
• An off-policy agent learns about a policy or
policies different from the one that it is
executing
Reward Signal
• The reward signal defines the goal
• On each time step, the environment sends a
single number called the reward to the
reinforcement learning agent
• The agent’s objective is to maximise the total
reward that it receives over the long run
• The reward signal is used to alter the policy
Value Function (1)
• The reward signal indicates what is good in the
short run while the value function indicates what
is good in the long run
• The value of a state is the total amount of reward
an agent can expect to accumulate over the
future, starting in that state
• Compute the value using the states that are likely
to follow the current state and the rewards
available in those states
• Future rewards may be time-discounted with a
factor in the interval [0, 1]
Value Function (2)
• Use the values to make and evaluate decisions
• Action choices are made based on value
judgements
• Prefer actions that bring about states of highest
value instead of highest reward
• Rewards are given directly by the environment
• Values must continually be re-estimated from the
sequence of observations that an agent makes
over its lifetime
Model-free versus Model-based
• A model of the environment allows inferences to be made
about how the environment will behave
• Example: Given a state and an action to be taken while in
that state, the model could predict the next state and the
next reward
• Models are used for planning, which means deciding on a
course of action by considering possible future situations
before they are experienced
• Model-based methods use models and planning. Think of
this as modelling the dynamics p(s’ | s, a)
• Model-free methods learn exclusively from trial-and-error
(i.e. no modelling of the environment)
• This presentation focuses on model-free methods
Advantages of Reinforcement Learning
• It can solve higher-order and complex problems. Also, the solutions
obtained will be very accurate.
• The reason for its perfection is that it is very similar to the human learning
technique.
• Due to it’s learning ability, it can be used with neural networks. This can be
termed as deep reinforcement learning.
• Since the model learns constantly, a mistake made earlier would be
unlikely to occur in the future.
• Various problem-solving models are possible to build using reinforcement
learning.
• When it comes to creating simulators, object detection in automatic cars,
robots, etc., reinforcement learning plays a great role in the models.
• The best part is that even when there is no training data, it will learn
through the experience it has from processing the training data.
• For various problems, which might seem complex to us, it provides the
perfect models to tackle them.
4/7/2021 92
Disadvantages of Reinforcement Learning

• The usage of reinforcement learning models for solving simpler problems


won’t be correct. The reason being, the models generally
tackle complex problems.
• We will be wasting unnecessary processing power and space by using it for
simpler problems.
• We need lots of data to feed the model for computation. Reinforcement
Learning models require a lot of training data to develop accurate results.
• This consumes time and lots of computational power.
• When it comes to building models on real-world examples, the
maintenance cost is very high.
• Like for building driverless vehicles, robots, we would require a lot of
maintenance for both hardware and software.
• Excessive training can lead to overloading of the states of the model. This
will result in the model for getting the result.
• This may happen if too much memory space goes out in processing the
training data.
4/7/2021 93
Adaptive learning
• No learning method is complete in itself. So
• Need to select the learning method based on
the requirements.
• Need to develop a combination of some of the
existing methods based on requirements.
• Adaptive machine learning algorithms are the
machine learning models, where the changes
in the environment help in selecting the
algorithm or learning method.
94
Adaptive learning (Contd..)
• As per the scenario, most suitable algorithm is selected.
• Moreover the development of especially fast adapting
algorithms poses many different issues like selection of
choices, handling equilibrium states and so on.
• The adaptive learning solves some of the complex
problems for which a single learning method is not
enough.
• This method is even more appropriate when the
environment is continuously changing and real time
response is expected.

4/7/2021 95
What is a Multi-Agent System?
• A system with multiple autonomous entities, with
distributed information, computational ability, and
possibly divergent interests.

• Agents :: artificial or human, cooperative or self-


interested
Multiagent Systems, a Definition
• A multiagent system is one that consists of
a number of agents, which interact with
one-another
• In the most general case, agents will be
acting on behalf of users with different
goals and motivations
• To successfully interact, they will require
the ability to cooperate, coordinate, and
negotiate with each other, much as people
do
Overview of an agent
Learning in Multiagent Systems
• Intersection of DAI and ML

• Why bring them together?


– There is a strong need to equip Multiagent
systems with learning abilities
– The extended view of ML as Multiagent learning is
qualitatively different from traditional ML and can
lead to novel ML techniques and algorithms
99
Need for Multi agent Learning

• A single agent cannot handle learning in case


of applications
• A team or group of agents possesses the
potential to overcome the limitation of single
agent and work in in coordination to
accomplish a task.
• This can be two cases in multi agent based
learning:
4/7/2021 100
Multi agent based learning
1) Where the agent tries to maximize its own utility
• Eg: Consider a manufacturing industry domain. The task are
built and assigned where each agent works in co-operation to
build the end product. This is the case to achieve a common
goal.
2) Where they worked in collaboration to achieve some common
goals.
• Eg: Game playing. In that gaming environment, multiple
agents are in Operation to select the best strategy.
• Can be related with the reinforcement learning, Where for
each strategy of the agent some reward is achieved this is
where each agent tries to maximize his own utility function.
4/7/2021
• 101
Ensemble Learning

4/7/2021 102
Ensemble Learning (Contd…)
Ensemble learning method is the one where multiple learners or
learning algorithms are trained.
• In most of the learning algorithms a single hypothesis drives
the learning.
• In ensemble learning method the whole collection or
ensemble of hypothesis is selected from the hypothesis space
and their predictions are combined.
• In this approach, the learners or referred to as base learners.
• The most commonly used ensemble learning methods are
1) Boosting
2) Bagging.
4/7/2021 103
Ensemble Learning (Contd..)
Boosting:
• Boosting can probably be defined as the method for
generating accurate predictions by combining the rules that
are comparatively inaccurate.
• Boosting works on the weighted training sets. The weights of
the training example reflects the importance of training
examples.
Bagging:
• In Bagging, the training data is resampled. This is referred to
as bootstrap sampling, where the training data with
replacement is taken in the learning approaches.

104
Learning for decision making
• It is observed from different learning mechanisms that
Capability to take decisions is increased.
• speaking about the supervisor and unsupervised methodologies
the decisions taken are not sequential in nature.
• That is, if the system make a mistake on one decision, this has
no bearing on the subsequent decisions.
• To cope up with this dynamic situation there is a need to
understand the perspective of decision making.
• Another aspect is environment and system Learning, which also
needs to be looked upon during decision making. While taking
decisions one specific learning approach may not be suitable.
• The learning approach is dependent on decision scenario.
105
Distributed learning
• In distributed learning the task of learning is distributed.
• Need for distributed learning - Arises due to large data sets
and time constraints.
• More than one agent in different parts of the data set. There
will be distributed learning algorithms taken part in each
partition to get the desired outcome, which would then be
combined.
• Efficiency of distributed learning is affected to look at. it is
extremely important that outcome of distributed learning
matches with the ones acheived under the absence of
distributed environment.
• Multi agent systems can be thought of as a subset of
distributed learning.
4/7/2021 106

Speedup learning
• Speed learning typically deals with speeding up
problem solving by effective use of problem
solving experience. Hence, Prayer problem solving
experience is an input for speed of learning.
• In this learning,
1) There is no option with the environment.
2) New problems cannot be solved.
So, speed up learning accelerates the process
experiences And prior observations.

4/7/2021
Speedup learning (Contd..)

4/7/2021 108
Generalized learning
• Another dimension to the speed up learning is generalized
learning. this is also known as explanation based learning.
• There are a number of issues with explanation based learning,
as it is implemented and embedded in system to solve real
life problems and is suitable for a particular set of problems
where the sequential processes once developed can be used
again and again.
• But this is not the case in many real life problems, where
dynamic change in environment demands the improvement in
the established scenarios and even there is a need to keep on
learning based on the new findings

4/7/2021 109
18CSC305J-Artificial Intelligence
Unit- V

22-04-2021 1
• Expert System Architecture • Advance topics in Artificial Intelligence- Cloud
Pros and cons of Expert system Computing and Intelligent agent
• Rule based systems • Business Intelligence and Analytics
Frame based expert system • Sentiment Analysis
• Case study • Deep Learning Algorithms
• NLP – levels of NLP • Planning and Logic in intelligent Agents
• Syntactic and Semantic Analysis
Information Retrieval
• Information Extraction
Machine Translation
• NLP Applications

22-04-2021 2
Expert Systems

22-04-2021 3
Expert Systems - Objectives

• Learn the meaning of an expert system


• Understand the problem domain and knowledge domain
• Learn the advantages of an expert system
• Understand the stages in the development of an expert
system
• Examine the general characteristics of an expert system

22-04-2021 4
Objectives
• Examine earlier expert systems which have given rise to
today’s knowledge-based systems
• Explore the applications of expert systems in use today
• Examine the structure of a rule-based expert system
• Learn the difference between procedural and
nonprocedural paradigms
• What are the characteristics of artificial neural systems

22-04-2021 5
What is an expert system?
“An expert system is a computer system that emulates, or acts in all
respects, with the decision-making capabilities of a human expert.”

Professor Edward Feigenbaum


Stanford University

22-04-2021 6
Architecture of Expert Systems

22-04-2021 7
Architecture of Expert Systems
Knowledge Base
Stores all relevant information, data, rules, cases, and
relationships used by the expert system.
Uses
•Rules
•If-then Statements
•Fuzzy Logic

Inference Engine
Seeks information and relationships from the knowledge
base and provides answers, predictions, and suggestions
the way a human expert would.
Uses
•Backward Chaining
•Forward Chaining

22-04-2021 8
Architecture of Expert Systems
Explanation Facility
Allows a user to understand how the expert system arrived at certain conclusions or results.
For example: it allows a doctor to find out the logic or rationale of the diagnosis made by a medical expert
system

Knowledge acquisition facility


Provide convenient and efficient means of capturing and storing all the components of the knowledge base.
Acts as an interface between experts and the knowledge base.

User Interface
Specialized user interface software employed for designing, creating, updating, and using expert
systems.
The main purpose of the user interface is to make the development and use of an expert system easier
for users and decision makers

22-04-2021 9
General Methods of Inferencing
• Forward chaining (data-driven)– reasoning from facts to the conclusions
resulting from those facts – best for prognosis, monitoring, and control.
– Examples: CLIPS, OPS5

• Backward chaining (query/Goal driven)– reasoning in reverse from a


hypothesis, a potential conclusion to be proved to the facts that support the
hypothesis – best for diagnosis problems.
– Examples: MYCIN

22-04-2021 10
Expert Systems Development

22-04-2021 11
Expert system technology may include:

• Special expert system languages – CLIPS

• Programs

• Hardware designed to facilitate the implementation of those


systems

22-04-2021 12
Problem Domain vs. Knowledge Domain

• An expert’s knowledge is specific to one problem domain –


medicine, finance, science, engineering, etc.
• The expert’s knowledge about solving specific problems is called
the knowledge domain.
• The problem domain is always a superset of the knowledge
domain.

22-04-2021 13
Problem and Knowledge Domain Relationship

22-04-2021 14
Advantages of Expert Systems

22-04-2021 15
Disadvantages of Expert Systems

22-04-2021 16
Representing the Knowledge

The knowledge of an expert system can be represented


in a number of ways, including IF- THEN rules:

IF you are hungry THEN eat

22-04-2021 17
Knowledge Engineering
The process of building an expert system:

1. The knowledge engineer establishes a dialog with


the human expert to elicit knowledge.
2. The knowledge engineer codes the knowledge
explicitly in the knowledge base.
3. The expert evaluates the expert system and gives a
critique to the knowledge engineer.

22-04-2021 18
Development of an Expert System

22-04-2021 19
The Role of AI

• An algorithm is an ideal solution guaranteed to yield a solution in


a finite amount of time.
• When an algorithm is not available or is insufficient, we rely on
artificial intelligence (AI).
• Expert system relies on inference – we accept a “reasonable
solution.”

22-04-2021 20
Uncertainty
• Both human experts and expert systems must be able to deal with
uncertainty.
• It is easier to program expert systems with shallow knowledge
than with deep knowledge.
• Shallow knowledge – based on empirical and heuristic
knowledge.
• Deep knowledge – based on basic structure, function, and
behavior of objects.

22-04-2021 21
Early Expert Systems
• DENDRAL – used in chemical mass spectroscopy to identify
chemical constituents

• MYCIN – medical diagnosis of illness

• DIPMETER – geological data analysis for oil

• PROSPECTOR – geological data analysis for minerals

• XCON/R1 – configuring computer systems

22-04-2021 22
Broad Classes of Expert Systems

22-04-2021 23
Problems with Algorithmic Solutions

• Conventional computer programs generally solve problems having


algorithmic solutions.

• Algorithmic languages include C, Java, and C#.

• Classical AI languages include LISP and PROLOG.

22-04-2021 24
Considerations for Building Expert Systems
• Can the problem be solved effectively by conventional
programming?
• Is there a need and a desire for an expert system?
• Is there at least one human expert who is willing to cooperate?
• Can the expert explain the knowledge to the knowledge
engineer can understand it.
• Is the problem-solving knowledge mainly heuristic and
uncertain?

22-04-2021 25
Languages, Shells, and Tools

• Expert system languages are post-third generation.


• Procedural languages (e.g., C) focus on techniques to
represent data.
• More modern languages (e.g., Java) focus on data abstraction.
• Expert system languages (e.g. CLIPS) focus on ways to represent
knowledge.

22-04-2021 26
Production Rules
• Knowledge base is also called production memory.
• Production rules can be expressed in IF-THEN pseudocode format.
• In rule-based systems, the inference engine determines which rule
antecedents are satisfied by the facts.

22-04-2021 27
Rule-Based Expert System
• A rule based expert system is the simplest form of artificial intelligence and uses prescribed knowledge
based rules to solve a problem
• The aim of the expert system is to take knowledge from a human expert and convert this into a number of
hardcoded rules to apply to the input data
• In their most basic form, the rules are commonly conditional statements (if a, then do x, else if b, then do
y)
• These systems should be applied to smaller problems, as the more complex a system is, the more rules
that are required to describe it, and thus increased difficulty to model for all possible outcomes

Example:
A very basic example of rule based expert system would be a program to direct the management of
abdominal aneurysms The system would input the diameter of an aneurysm Using conditional arguments,
the input diameter would be stratified to recommend whether immediate intervention was required, and if
not what appropriate follow up is recommended
Note: with problems related to radiological images, often preprocessing of the images is required prior to the expert
system being applied.
22-04-2021 28
Structure of a Rule-Based Expert System

22-04-2021 29
Rule-Based ES

22-04-2021 30
Example Rules

22-04-2021 31
Inference Engine Cycle

22-04-2021 32
Foundation of Expert Systems

22-04-2021 33
Markov Algorithm
• An ordered group of productions applied in order or priority to an input
string.

• If the highest priority rule is not applicable, we apply the next, and so on.

• inefficient algorithm for systems with many rules.

• Termination on (1) last production not applicable to a string, or (2)


production ending with period applied
• Can be applied to substrings, beginning at left
22-04-2021 34
Markov Algorithm

22-04-2021 35
Rete Algorithm
• Markov: too inefficient to be used with many rules
• Functions like a net – holding a lot of information.
• Much faster response times and rule firings can occur compared to a large
group of IF-THEN rules which would have to be checked one-by-one in
conventional program.
• Takes advantage of temporal redundancy and structural similarity.
• Looks only for changes in matches (ignores static data)
• Drawback is high memory space requirements.

22-04-2021 36
Frame-Based Expert System

• The expert systems which make use of frames for the knowledge are called
frame-based expert systems.
• What is a frame? – A frame is a data structure with typical knowledge
about the object or concept.
• Frame has its name and set of attributes
• Example : A car frame can have make, type, color and so on as
slots/attributes in the frame
• Each slot/ attribute has unique value associated to it

22-04-2021 37
Frame-Based Expert System
We can have the following included in the slot

1. Frame Name
2. Relationship with other frames
3. Values or Ranges
4. Procedural information

Represents the frame structure for Class and Instance


22-04-2021 38
Frame-Based Expert System
• Relationship – hierarchy, or to be specific, the
inheritance is depicted

• Values & Ranges – Represent the actual/default values


or specified ranges

• Procedural information – the slot is attached to a


procedure that is executed when any event is
triggered such as change in value for the slot

• Instance Frame refers to an object and Class frame


refers to group
Frames : Class and Instance

22-04-2021 39
Working of Frame-Based Expert System
• Method – A method is a procedure that is executed
when requested

• Demon – makes use of if-then structure

• Frames that have the knowledge representation, the


methods or the demons essentially add actions to
them.

• As an example, how the process of an expert system When needed and when required methods : Snapshot

works to check the eligibility of a student appearing


for an exam is explained in the picture

22-04-2021 40
Guidelines to build a Frame-Based Expert System

22-04-2021 41
MYCIN

22-04-2021 42
MYCIN
•MYCIN was an early expert system that used artificial intelligence to
identify bacteria causing severe infections.
•recommend antibiotics, with the dosage adjusted for patient's body weight
•The MYCIN system was also used for the diagnosis of blood clotting
diseases.
•MYCIN was developed over five or six years in the early 1970s at Stanford
University.
•It was written in Lisp

22-04-2021 43
MYCIN
•MYCIN was a stand alone system that required a user to enter all relevant
information about a patient by typing in responses to questions MYCIN posed.
•MYCIN operated using a fairly simple inference engine, and a knowledge base of
~600 rules.
•It would query the physician running the program via along series of simple yes/no
or textual questions.

22-04-2021 44
Tasks and Domain
•Disease DIAGNOSIS and Therapy SELECTION

•Advice for non-expert physicians with time considerations and

incomplete evidence on:

–Bacterial infections of the blood

–Expanded to meningitis and other ailments

–Meet time constraints of the medical field

22-04-2021 45
Consultation System

22-04-2021 46
Consultation “Control Structure”
•Goal-directed Backward-chaining Depth-first Tree Search
•High-level Algorithm:
1.Determine if Patient has significant infection
2.Determine likely identity of significant organisms
3.Decide which drugs are potentially useful
4.Select best drug or coverage of drugs

22-04-2021 47
Static Database

22-04-2021 48
Dynamic Database

22-04-2021 49
Explanation System

22-04-2021 50
Xcon
•The R1 (internally called XCON, for eXpertCONfigurer) program was a production rule based system written
in OPS5 by John P. McDermott of CMU in 1978.
–configuration of DEC VAX computer systems
•ordering of DEC's VAX computer systems by automatically selecting the computer system components based
on the customer's requirements.
•XCON first went into use in 1980 in DEC's plant in Salem, New Hampshire. It eventually had about 2500 rules.
•By 1986, it had processed 80,000 orders, and achieved 9598% accuracy.
•It was estimated to be saving DEC $25M a year by reducing the need to give customers free components
when technicians made errors, by speeding the assembly process, and by increasing customer satisfaction.
•XCON interacted with the sales person, asking critical questions before printing out a coherent and workable
system specification/order slip.
•XCON's success led DEC to rewrite XCON as XSEL a version of XCON intended for use by DEC's salesforce to
aid a customer in properly configuring their VAX.
22-04-2021 51
XCON: Expert Configurer

22-04-2021 52
Natural Language
Processing (NLP)

22-04-2021 53
Natural language
• Natural languages are languages that living creatures use for

communication,

• A machine is considered to be really intelligent only when it can understand

and interpret or speak the matter of natural language.

• The capability to understand, interpret and communicate through natural

language is a very important criteria of intelligent behavior.

22-04-2021 54
Why Natural language processing?
• Huge amount of data?
– Internet=at least 2.5 billion pages
• Applications for processing large amounts of texts.
– Classify text into categories
– Index and search large texts
– Automatic translation
– Speech understanding: Understanding phone conversation
– Information extraction: Extract useful information from
resumes
– Automatic summarization
– Question answering
– Knowledge acquisition: knowledge from expert
– Text generations/dialogs
• All these requires natural language expertise.
22-04-2021 55
NLP Tasks

22-04-2021 56
Levels of NLP

22-04-2021 57
Syntactic Analysis
• Rules of syntax (grammar) specify the possible organization of words in
sentences and allows us to determine sentence’s structure(s)

• “John saw Mary with a telescope”


• John saw (Mary with a telescope)
• John (saw Mary with a telescope)

• Parsing: given a sentence and a grammar

• Checks that the sentence is correct according with the grammar and if so
returns a parse tree representing the structure of the sentence

22-04-2021 58
Syntactic Analysis - Grammar
• sentence -> noun_phrase, verb_phrase
• noun_phrase -> proper_noun
• noun_phrase -> determiner, noun
• verb_phrase -> verb, noun_phrase
• proper_noun -> [mary]
• noun -> [apple]
• verb -> [ate]
• determiner -> [the]

22-04-2021 59
Syntactic Analysis - Parsing

22-04-2021 60
Syntactic Analysis – Complications (1)

• Number (singular vs. plural) and gender


• sentence-> noun_phrase(n),verb_phrase(n)
• proper_noun(s) -> [mary]
• noun(p) -> [apples]
• Adjective
• noun_phrase-> determiner,adjectives,noun
• adjectives-> adjective, adjectives
• adjective->[ferocious]
• Adverbs, …

22-04-2021 61
Syntactic Analysis – Complications (2)

• Handling ambiguity
• Syntactic ambiguity: “fruit flies like a banana”

• Having to parse syntactically incorrect sentences

22-04-2021 62
Semantic Analysis
• Syntax analysis is doing the parsing activity
• But we need to understand the meaning of the words and it is done
by semantic analysis
• For example,
• ‘Keep the book on the table’ – Here table refers physical object
• ‘Learn the table of number 23’ – here table refers mathematics concept of
table

22-04-2021 63
Lexical Processing
• In lexical processing, the meaning of the tokens is found out
• Word sense disambiguation: Understanding the meaning of a
particular word in the context
• It is concerned with the sense where it would be operational
• It would be done with the help of semantic marker
• Semantic marker: ‘Keep’ in sentence 1
• Semantic marker: ‘Learn’ in sentence 2

22-04-2021 64
Semantic grammars

• Example,
• ‘The pen is on the ceiling’
• Solution is,
• S -> Action the Food
• Action -> eat|drink|shallow|chew – Set of words
• Food -> burger|sandwich|coke|pizza – Set of words

22-04-2021 65
Case Grammar

• Case grammar is also called as Fillmore grammar


• Elements of the sentence are:
• Object (thing on which it is acted)
• Agent/actor (Someone who carries out the action or the event)
• Dative (Someone who is affected by the event)
• Location (place where the event/action occurs)
• Time (date or time at which the action/event takes place)
• Example,
• Rohit will meet Kunal at Mall

22-04-2021 66
Conceptual Dependency

• ATRANS: Transfer of some relationship for verb (e.g.) ’give’


• PTRANS: Transfer of location of an object, say the verb ‘go’
• GRASP: This primitive occurs with verb like ‘throw’
• SPEAK: This primitive has some sound production, say the verb
‘speak’ or ‘say’

22-04-2021 67
Information retrieval

22-04-2021 68
Information retrieval - Models

22-04-2021 69
Information retrieval - Models

22-04-2021 70
Information retrieval - Models

22-04-2021 71
Information retrieval - Models

22-04-2021 72
Information Extraction

22-04-2021 73
Information Extraction

22-04-2021 74
• Advance topics in Artificial Intelligence- Cloud Computing and
Intelligent agent
• Business Intelligence and Analytics
• Sentiment Analysis
• Deep Learning Algorithms
• Planning and Logic in intelligent Agents

22-04-2021 75
Advance topics in Artificial Intelligence- Cloud
Computing and Intelligent agent
Cloud computing
The practice of using a network of remote servers hosted on the
Internet
to:
store,
manage,
and process data,
rather than a local server or a personal computer.

22-04-2021 76
Cloud computing and
AI(contd.)
Cloud computing and AI
While artificial intelligence (A.I.) has struggled to gain
footholds in other niches, it is finding its place in the
world of cloud computing, a sort of revolution within the
revolution that could rapidly change the face of businesses
using cloud computing solutions over the next few years.

22-04-2021 77
Cloud computing and
AI(contd.)
In three areas of cloud computing, A.I. is taking long strides.
Those areas are

Parallel processing

Machine Learning-ML Algorithms

Big Data

22-04-2021 78
What’s parallel processing and how it work in
cloud
•Parallel processing means more than one microprocessor handling
parts of the same overall task. Parallel processing essentially means
that multiple processors shoulder the load. To have multiple processors
working on the same problem at the same time, there are two big
things you need:

Latency

Bandwidth
22-04-2021 79
What’s parallel processing and
how it work in cloud(contd.)
Latency
it refers to the amount of time it takes for a processor to send results back
to the system. The longer the wait, the longer it will take the entire system
to process the problem.

Bandwidth
Bandwidth is a more common term, referring to how much data a processor
can send in a given length of time.

22-04-2021 80
ML algorithms for cloud
applications
Machine learning (ML) is a type of artificial
intelligence (AI) that allows software applications to
become more accurate in predicting outcomes
without being explicitly programmed

For cloud applications Machine Learning algorithms


are built

22-04-2021 81
ML algorithms for cloud applications(contd.)
ML algorithms for cloud applications involve:
Cognitive computing(to combine different patterns together; i.e. voice,
imagery or other such data; for mimicking human behavior)

Chatbots and virtual assistants (they are getting smarter every time they
have a conversation)
Internet of things-IoT (It connects every potentially “smart” machine in the
world to the cloud and add that massive amount of data to the conversation)

22-04-2021 82
How AI uses big data
As business enterprises increasingly need a massive data-
crunching champion, cloud computing companies have begun
to deploy Artificial Intelligence as a service (AIaaS). Once
AIaaS is deployed, it can begin crunching data at a faster
rate than any single microprocessor or human mind could
ever hope to compete with.

22-04-2021 83
AI has not come to take over our world, but to improve
the way we harness technology to make everything
better. Consider the surface of AI finally scratched. ??

22-04-2021 84
Business Intelligence and Analytics

22-04-2021 85
So, how does AI actually work
in the business world? let’s try
to understand what artificial
intelligence is and why it is so
important for today’s business
corporations.

22-04-2021 86
What is Business Intelligence (BI)?

Business intelligence systems are used to maintain, optimize and streamline current
operations. BI improves and maintains operational efficiency and helps businesses increase
organizational productivity. Business intelligence software confers many benefits, notably
powerful reporting and data analysis capabilities. Using BI’s rich visualization mechanisms,
managers are able to generate intuitive, readable reports that contain relevant, actionable
data.

Popular business intelligence solutions include; SAP BusinessObjects, QlikView, IBM Cognos,
Microstrategy, etc.

https://selecthub.com/business-intelligence/business-intelligence-vs-business-an
alytics/

22-04-2021 87
What is Business Analytics (BA)?

Like business intelligence, BA collects and analyzes data, employs predictive


analytics and generates richly visualized reports, helping identify and address an
organization’s weak points. That’s where similarities end. Business analytics software
is used to explore and analyze historical and current data. It utilizes statistical
analysis, data mining and quantitative analysis to identify past business trends.

Popular business analytics solutions include; SAP Business Analytics Suite, Pentaho BA, Birst BI and Tableau BIg
Data Analytics.

https://selecthub.com/business-intelligence/business-intelligence-vs-business-an
alytics/

22-04-2021 88
Business Analytics vs. Business Intelligence
• What will happen?
• What if and Why did it
Vision, happen?

Busine Mission
Statemen


Predictive Modeling
Simulation/Optimization
ts • Advanced Statistic Models
ss Business
“Sustainability
” “Efficiency”
“Innovation”
• Data Mining (Text,
Multimedia)

Analyti
• Data Science
Services &
Ne Optimized
w Business
Servic Retired

cs
Services
es
Objectives
Digital
Services • Who did that task?
Organization • What happened?
CM CEO
CO CF • Dashboards, Alerts
O O O • Scorecards

B
Monitoring
Business Process as a
More Flexible More Control • Slice & Dice,
Service Drilling
Digital
I New Customers,
Channels Initiatives
Business Process
Enterprise
Metamorphos
is
• Reports

Data IoT, Smart Smart


Optimization/Outsourcing
Monetization Devices Workforce

Digital • DWH
Big Platform Digital
Securit
• Data
Data Lake
Cloud y

Danairat,
22-04-2021 2016 89
Choosing between Business Intelligence (BI)
and Business Analytics (BA)

While superficially similar, the difference between business intelligence vs business


analytics is clear:
- BI uses past and current data to optimize the present for current success.
- BA uses the past and analyzes the present to prepare businesses for the future.

Choosing the solution for your business depends on your aims.


- If you are satisfied with your business model as a whole and mainly wish to improve
operations, increase efficiency and meet organizational goals, business
intelligence may be an optimal solution.
- If you intend to change your business model and need to know where to
start, business analytics might be the best option.

https://selecthub.com/business-intelligence/business-intelligence-vs-business-an
alytics/

22-04-2021 90
Choosing between Business Intelligence (BI)
and Business Analytics (BA)

Business Intelligence (BI)


BI has the added advantages of targeting a business’s weak areas and providing actionable
solutions to those problems. Business Intelligence software is an excellent solution for managers
who want to improve decision making and understand their organization’s productivity, work
processes and employees. And, with that understanding, improve their business from the
ground up.

Business Analytics (BA)


If your organization is a new entity, or in the midst of significant changes, business analytics
software is a serious contender. BA uses historical data, current information, and projected trends
to ensure your business makes the right changes. Business analytics is the solution if you want to
analyze your company, your market, and your industry with the dual goals of optimizing
current performance and predicting business trends to help you remain competitive in the
future.
Most businesses want a combination of current success and future preparation. Alone or together, business
analytics and business intelligence can help you take your business where you want it to go.

https://selecthub.com/business-intelligence/business-intelligence-vs-business-an
alytics/

22-04-2021 91
1. (Re)Identifying your
-
vision and missions
Strategic and Top Decision Making:-
Political and Policy Reports Vision,
- Economic Reports Mission
- Customer Analytic Statemen
Trends ts
- Technology Trends “Sustainability
” “Efficiency”
- Economic Value Business
“Innovation”

Services &
Ne Optimized
w Business
Servic Retired
es Services
Objectives
Services

Digital
Big Platform Digital
Securit
Data
Cloud y

22-04-2021 92
2. Identifying Business
Services and Objectives
Vision,
Business Services/Objectives:- Mission
- Social Listening Analytics Statemen
- Customer Experiences / UX ts
- Discover Unman Customers “Sustainability
” “Efficiency”
- Demographic Analytics Business
“Innovation”
- Voice of Customers Services &
- Objectives/Measurement Ne Optimized
w Business
Servic Retired
s Results es Services
Objectives
Services

Digital
Big Platform Digital
Securit
Data
Cloud y

22-04-2021 93
3. Identifying BI for Management Level
Vision,
Mission
Management BI:- Statemen
• Promotion Impact Report ts
• Channel Productivity “Sustainability
” “Efficiency”
• Operational Efficiency Business
“Innovation”

• Profit and Loss Report Services &


Ne Optimized
• Compliance Reports w Business
Servic Retired
• Internal Policy Adoption es Services
Objectives
Digital
Services
Organization
CM CEO
CO CF
O O O

Digital
Big Platform Digital
Securit
Data
Cloud y

22-04-2021 94
Digital Organization
CE
O

CM CO CF
O O O

• CEO : combine all successes from all


C-Level
• CMO: innovation for new products offering
• COO : operation and automation
• CFO : finance, budgeting, HR, Audit, QA
and IT
• Put the right skill on the right role
• Promote paperless policy organization
22-04-2021 95
Top Business Questions from CMO

CM
O

Chief Marketing Officer (CMO), Innovation, Sales and


Promotion:-
• Which customers should we target?
• What has caused the change in my pipeline?
• Which are my most profitable campaigns/region?
• Did store sales spike when we advertised in the local
paper or launched the campaign?
• What is the most profitable sales channel and how
has that changed over time?

22-04-2021 96
Top Business Questions from COO

CO
O

Chief Operation Officer (COO):-


• Lead time and cost of production for each
products
• Which order processing processes are most
inefficient?
• Which vendors are best at delivering on time
and on budget?–
• How many additional personnel do we need to
add per branch?
• Percent of error or defect trend for each product

22-04-2021 97
Top Business Questions from CFO

CF
O

Chief Financial Officer (CFO):-


• What is the fully loaded cost of new
products deployment?
• What are the current trends in cash flow,
accounts payable and accounts receivable
and how do they compare with plan?
• What is the expected annual profit/loss
based on current marketing and sales
forecasts?
• How are forecasts trending against the annual
plan?
22-04-2021 98
4. Identifying Operational BI
Vision,
Mission
Statemen
ts
“Sustainability
” “Efficiency”
“Innovation”
Operational BI:-
Business - Task Tracking
- Alerts on Progression
Status
Services & - Error correction and
Ne Optimized
w Business
Servic Retired recommendation
Services
es
Objectives
Digital
Services
Organization
CM CEO
CO CF
O O O

Business Process as a Service


More Flexible More Control
Digital
Enterprise
New Customers,
Channels Initiatives Metamorphos
is
Business Process
Data IoT, Smart Smart
Optimization/Outsourcing
Monetization Devices Workforce

Digital
Big Platform Digital
Securit
Data
Cloud y

22-04-2021 99
Key Questions Type in each level of enterprise

Vision,
Mission Wh
Statemen y
ts
“Sustainability
” “Efficiency”
Business
“Innovation”

Services & Whe


Ne Optimized
w Business
Servic Retired
n
Services
es
Objectives
Digital
Services
Organization Wh
CM CEO
CO CF
O O O o
Business Process as a
More Flexible More Control
Service
Digital Ho
Enterprise w
New Customers,
Channels Initiatives Metamorphos
is
Business Process
Data IoT, Smart Smart
Optimization/Outsourcing
Monetization Devices Workforce

Digital Wha
Big Platform Digital
Securit t
Data
Cloud y

Danairat,
22-04-2021 2016 100
5. Identifying BI and BA Platform
Vision,
Mission
Statemen
ts
“Sustainability
” “Efficiency”
Business
“Innovation”

Services &
Ne Optimized
w Business
Servic Retired
BI &
es Services
Objectives
Digital
Services
Business
Organization Analytics
CM
O
CEO
CO
O
CF
O
Platforms :-
• Traditional BI
Business Process as a • Big Data
More Flexible More Control
Service • Cloud
Digital • Digital Security
Enterprise
New Customers,
Channels Initiatives Metamorphos
is
Business Process
Data IoT, Smart Smart
Optimization/Outsourcing
Monetization Devices Workforce

Digital
Big Platform Digital
Securit
Data
Cloud y

22-04-2021 101
Summary
• What will happen?
• What if and Why did it
Vision, happen?

Busine Mission
Statemen


Predictive Modeling
Simulation/Optimization
ts • Advanced Statistic Models
ss Business
“Sustainability
” “Efficiency”
“Innovation”
• Data Mining (Text,
Multimedia)

Analyti
• Data Science
Services &
Ne Optimized
w Business
Servic Retired

cs
Services
es
Objectives
Digital
Services • Who did that task?
Organization • What happened?
CM CEO
CO CF • Dashboards, Alerts
O O O • Scorecards

B
Monitoring
Business Process as a
More Flexible More Control • Slice & Dice,
Service Drilling
Digital
I New Customers,
Channels Initiatives
Business Process
Enterprise
Metamorphos
is
• Reports

Data IoT, Smart Smart


Optimization/Outsourcing
Monetization Devices Workforce

Digital • DWH
Big Platform Digital
Securit
• Data
Data Lake
Cloud y

Danairat,
22-04-2021 2016 102
Big Data for Business Analytics Platform

Custome Staff Managers Expert Executiv


rs s Partners s es
Big Data
Next Applications Cybe Talen
BI/Repor
Best Analysis
Fraud Security
r t
t
Action Searc
h
Big Data Platform
Descriptive/ Predicti Prescripti
Diagnose ve ve
Analytics
Analytic Analytic
Monitoring,
Resource Parallel Data Processing, s
s
Security
Managemen Refinery and
t and Distributed Data Store, Data Lake Control
Metadata Framewor
Framework k
Ingestion and
Acquisition

Big Data Infrastructure


Compute Storage, Network

22-04-2021 103
Internet of Things and Real-time Data Feeds
Applicatio
n
Areas
Smart Smart Smar Smart E-Health Retail Logistics Industria
Cities Environme t Agricultur l
nt Energ e Control
y

Monika, 37
2015
22-04-2021 104
Smart Home

Monika, 38
2015
22-04-2021 105
Chatbots, virtual assistants, and
Based on these business intelligence bots
capabilities, we
have seen
Targeted online
multiple advertising
applications of
artificial Predictive
analytics
intelligence in
business in the Voice
form of: recognition

Pattern
22-04-2021
recognition 106
Sentiment Analysis

22-04-2021 107
Sentiment Sentiment Analysis

A thought, view, or attitude, especially one based mainly on emotion


instead of reasonSentiment Analysisaka opinion mininguse of natural
language processing (NLP) and computational techniques to automate
the extraction or classification of sentiment from typically unstructured
text

22-04-2021 108
22-04-2021 109
22-04-2021 110
22-04-2021 111
Sentiment analysis has many other
names
• Opinion extraction
• Opinion mining
• Sentiment mining
• Subjectivity
11
2
analysis

22-04-2021
What is SA & OM?
• Identify the orientation of opinion in a piece of text

The movie The movie The movie


was fabulous! stars Mr. X was horrible!
• Can be generalized to a wider set of emotions

22-04-2021 113
Positive or negative movie
review?
• unbelievably disappointing
• Full of zany characters and richly applied satire, and
some great plot twists
• this is the greatest screwball comedy ever filmed
• It was pathetic. The worst part about it was the
11
4 boxing scenes.

22-04-2021
Why sentiment
analysis?
• Movie:is this review positive or negative?
• Products: what do people think about the new iPhone?
• Public sentiment: how is consumer confidence? Is
despair increasing?
• Politics: what do people think about this candidate or
11
5
issue?
• Prediction: predict election outcomes or market
trends from sentiment
22-04-2021
Why compute affective
meaning?
• Detecting:
• sentiment towards politicians, products, countries, ideas
• frustration of callers to a help line
• stress in drivers or pilots
• depression and other medical conditions
• confusion in students talking to e-‐tutors
• emotions in novels (e.g., for studying groups that are feared over
time)
• Could we generate:
• emotions or moods for literacy tutors in the children’s storybook
domain
22-04-2021 116
Scherer’s typology of affective
states
Emotion: relatively brief episode of synchronized response of all or most
organismic subsystems in response to the evaluation of an event as being of
major significance
angry, sad, joyful, fearful, ashamed, proud, desperate
Mood: diffuse affect state …change in subjective feeling, of low intensity but
relatively long duration, ojen without apparent cause
cheerful, gloomy, irritable, listless, depressed, buoyant
Interpersonal stance: affective stance taken toward another person in a specific
interaction, coloring the interpersonal exchange
distant, cold, warm, supportive, contemptuous
A]tudes: relatively enduring, affectively colored beliefs, preferences
predispositions towards objects or persons
liking, loving, hating, valuing, desiring
Personality
22-04-2021 traits: emotionally laden, stable personality dispositions and 117
Google Product
Search
• a

11
8

22-04-2021
TwiGer
sentiment:
Johan Bollen, Huina Mao, Xiaojun Zeng.
2011.
Twitter mood predicts the stock
market,
Journal of Computational Science 2:1,
1-‐8. 10.1016/j.jocs.2010.12.007.
11
9

22-04-2021
Bollen et al.
(2011)
• CALM
predicts
DJIA 3 days
Jones
Dow
later
• At least one
12
0
current
CAL

hedge fund
uses this
M

algorithm
22-04-2021
22-04-2021 121
22-04-2021 122
22-04-2021 123
DEEP LEARNING

22-04-2021 124
22-04-2021
125
22-04-2021 126
MACHINE LEARNING

• Train machine by ourselves


• Extract feature and feed to the machine
then apply algorithm to train it

22-04-2021 127
ML VS DL

22-04-2021 128
DEEP LEARNING
•It’s a type of ML inspired by
human brain.

•In DL, the structure is called


artificial neural network.
•In DL, machine learns itself
using artificial neural
network that mimics
22-04-2021 biological neural network. 129
22-04-2021 130
CONVOLUTIONAL
NEURAL NETWORK

22-04-2021 131
CONVOLUTIONAL
NEURAL NETWORK (CNN)

• Image
recognition

• Image
classification

• Object detection

22-04-2021 132
CNN LAYER

22-04-2021 133
CONVOLUTION LAYER

• An image matrix (volume) of dimension (h x w x d)


• A filter (fh x fw x fd)
• Out put a volume dimension

22-04-2021 134
Image Filter Convolved
Matrix Matrix Feature

22-04-2021 135
STRID
E

22-04-2021 136
PADDING

•Pad the picture with


zero-padding so that it fits.
•Drop part where image did not
if. This called valid padding
which keep only valid part of
image.

22-04-2021 137
SEPARABLE
CONVOLUTION LAYER

• The spatial separable convolution


is so named because it deals
primarily with the spatial
dimensions of an image and
kernel: the width and the height.
(The other dimension, the “depth”
dimension, is the number of
channels of each image).
I also use
this layer
in my
project too

22-04-2021 138

You might also like