AI Unit - 1 Notes
AI Unit - 1 Notes
1
COURSE OBJECTIVES
To understand the various characteristics of Intelligent agents.
To learn the different search strategies in AI.
To learn to represent knowledge in solving AI problems.
To know about the various applications of AI.
2
COURSE OUTCOMES
Artificial Intelligence (KCS071)
At the end of course , the student will be able to understand
Course Outcome ( CO) Bloom’s Knowledge Level
(KL)
CO1 Understand thebasics of the theory and practice of K2
Artificial Intelligence as a discipline and about
intelligent agents
CO 2 Understand search techniques and gaming theory. K2, K3
3
UNIT 1
RODUCTION
FINITION=
The study of how to make computers do things at which at the moment, people are better.
“Artificial Intelligence is the ability of a computer to act like a human being”.
Figure 1.1 Some definitions of artificial intelligence, organized into four categories
4
(a) Intelligence - Ability to apply knowledge in order to perform better in an environment.
(b) Artificial Intelligence - Study and construction of agent programs that perform well
in a given environment, for a given agent architecture.
(c) Agent - An entity that takes action in response to precepts from an environment.
(d) Rationality - property of a system which does the “right thing” given what it knows.
(e) Logical Reasoning - A process of deriving new sentences from old, such that the new
sentences are necessarily true if the old ones are true.
The Turing Test, proposed by Alan Turing (1950), was designed to provide a
satisfactory operational definition of intelligence. A computer passes the test if a human
interrogator, after posing some written questions, cannot tell whether the written responses
come from a person or from a computer.
5
Total Turing Test includes a video signal so that the interrogator can test the
subject’s perceptual abilities, as well as the opportunity for the interrogator to pass physical
objects “through the hatch.” To pass the total Turing Test, the computer will need
• computer vision to perceive objects, and robotics to manipulate objects and move
about.
Analyse how a given program thinks like a human, we must have some way of
determining how humans think. The interdisciplinary field of cognitive science brings
together computer models from AI and experimental techniques from psychology to try to
construct precise and testable theories of the workings of the human mind.
The Greek philosopher Aristotle was one of the first to attempt to codify ``right
thinking,'' that is, irrefutable reasoning processes. famous syllogisms provided patterns for
argument structures that always gave correct conclusions given correct premises.
For example, ``Socrates is a man; all men are mortal; therefore Socrates is mortal.''
These laws of thought were supposed to govern the operation of the mind, and
initiated the field of logic.
Acting rationally means acting so as to achieve one's goals, given one's beliefs. An
agent is just something that perceives and acts.
The right thing: that which is expected to maximize goal achievement, given the
available information
For Example - blinking reflex- but should be in the service of rational action.
6
TURE OF ARTIFICIAL INTELLIGENCE
Education: Textbooks are digitized with the help of AI, early-stage virtual tutors
assist human instructors and facial analysis gauges the emotions of students to help
determine who’s struggling or bored and better tailor the experience to their
individual needs.
Media: Journalism is harnessing AI, too, and will continue to benefit from it.
Bloomberg uses Cyborg technology to help make quick sense of complex financial
reports. The Associated Press employs the natural language abilities of Automated
Insights to produce 3,700 earning reports stories per year — nearly four times more
than in the recent past
Customer Service: Last but hardly least, Google is working on an AI assistant that
can place human-like calls to make appointments at, say, your neighborhood hair
salon. In addition to words, the system understands context and nuance.
Artificial Intelligence has become an important part of human life as we are now highly dependent on machines. Artificial
Intelligence is a very important technology to develop and build new computer programs and systems, which can be used
to simulate various intelligence processes like learning, reasoning, etc.
o Python
7
o R
o Lisp
o Java
o C++
o Julia
o Prolog
1. Python
Python is one of the most powerful and easy programming languages that anyone can start to learn. Python is initially developed
in the early stage of 1991. Most of the developers and programmers choose Python as their favourite programming language for
developing Artificial Intelligence solutions. Python is worldwide popular among all developers and experts because it has more
career opportunities than any other programming language.
Python also comes with some default sets of standards libraries and also provides better community support to its users. Further,
Python is a platform-independent language and also provides an extensive framework for Deep Learning, Machine Learning,
and Artificial Intelligence.
Python is also a portable language as it is used on various platforms such as Linux, Windows, Mac OS, and UNIX.
Features of Python
o It is easy to learn than any other programming language.
o It is also a dynamically-typed language.
o Python is an Object-oriented language.
o It provides extensive community support and a framework for ML and DL.
o Open-source.
o Large standard sets of libraries.
o Interpreted language.
Python is an ideal programming language used for Machine Language, Natural Processing Language (NLP), and Neural
networks, etc. Due to the flexible nature of Python, it can be used for AI development. It contains various pre-existing libraries
such as Pandas, SciPy and nltk, etc. Further, Python also contains simple syntax and easy coding, which makes Python the first
choice of AI developers and programmers.
There are some standard Libraries in Python used for Artificial Intelligence as follows:
2. Java
8
Java is also the most widely used programming language by all developers and programmers to develop machine learning
solutions and enterprise development. Similar to Python, Java is also a platform-independent language as it can also be easily
implemented on various platforms. Further, Java is an object-oriented and scalable programming language. Java allows virtual
machine technology that helps to create a single version of the app and provides support to your business. The best thing about
Java is once it is written and compiled on one platform, then you do not need to compile it again and again. This is known as
WORA (Once Written Read/Run Anywhere) principle.
Features of Java
Java has so many features which make Java best in industry and to develop artificial intelligence applications:
o Portability
o Cross-platform.
o Easy to learn and use.
o Easy-to-code Algorithms.
3. Prolog
Prolog is one of the oldest programming languages used for Artificial Intelligence solutions. Prolog stands for "Programming
in Logic", which was developed by French scientist Alain Colmerauer in 1970.
For AI programming in Prolog, developers need to define the rules, facts, and the end goal. After defining these three, the prolog
tries to discover the connection between them. Programming in AI using Prolog is different and has several advantages and
disadvantages.
It may seem like a bizarre language to learn for those programmers who are from a C++ background.
Prolog may not be a great programming language to build something big, but it's a great language to study and think about
problems in more logical ways rather than procedural.
Features of Prolog
9
o Automatic backtracking.
o Prolog is a declarative language rather than imperative.
4. Lisp
Lisp has been around for a very long time and has been widely used for scientific research in the fields of natural languages,
theorem proofs, and to solve artificial intelligence problems. Lisp was originally created as a practical mathematical notation for
programs but eventually became a top choice of developers in the field of AI.
Although Lisp programming language is the second oldest language after Fortran, it is still being used because of its crucial
features. The inventor of LISP programming was John McCarthy, who coined the term Artificial Intelligence.
LISP is one of the most efficient programming languages for solving specific problems. Currently, it is mainly used for machine
learning and inductive logic problems. It has also influenced the creation of other programming languages for AI, and some
worth examples are R and Julia.
However, though being so flexible, it has various deficiencies, such as lack of well-known libraries, not so-human-friendly
syntax, etc. Due to this reason, it is not preferred by the programmers.
Features of LISP
o The program can be easily modified, similar to data.
o Make use of recursion for control structure rather than iteration.
o Garbage Collection is necessary.
o We can easily execute data structures as programs.
o An object can be created dynamically.
5. R
R is one of the great languages for statistical processing in programming. However, R supports free, open-source programming
language for data analysis purposes. It may not be the perfect language for AI, but it provides great performance while dealing
with large numbers.
Some inbuilt features such as built-in functional programming, object-oriented nature, and vectorial computation make it
a worthwhile programming language for AI.
10
What is an Agent
An agent is anything that can viewed as perceiving its environment through sensors and
acting upon that environment through effectors. environment agent percepts actions Sensors:
eyes, camera, … Effectors: hands, motors, … Examples: a human driver a robot driver a
driver based on programs
Human Sensors:
Eyes, ears, and other organs for sensors.
Human Actuators:
Hands, legs, mouth, and other body parts.
Robotic Sensors:
Mic, cameras and infrared range finders for sensors
Robotic Actuators:
Motors, Display, speakers etc An agent can be:
Human-Agent: A human agent has eyes, ears, and other organs which work for
sensors and hand, legs, vocal tract work for actuators.
Robotic Agent: A robotic agent can have cameras, infrared range finder, NLP for
sensors and various motors for actuators.
Software Agent: Software agent can have keystrokes, file contents as sensory input
and act on those inputs and display output on the screen.
Hence the world around us is full of agents such as thermostat, cell phone, camera,
and even we are also agents. Before moving forward, we should first know about sensors,
effectors, and actuators.
11
Sensor: Sensor is a device which detects the change in the environment and sends the
sensors.
Actuators: Actuators are the component of machines that converts energy into
motion. The actuators are only responsible for moving and controlling a system. An actuator
can be an electric motor, gears, rails, etc.
Effectors: Effectors are the devices which affect the environment. Effectors can be
legs, wheels, arms, fingers, wings, fins, and display screen.
12
PROPERTIES OF ENVIRONMENT
An environment is everything in the world which surrounds the agent, but it is not a
part of an agent itself. An environment can be described as a situation in which an agent is
present.
The environment is where agent lives, operate and provide the agent with something
to sense and act upon it.
If an agent sensor can sense or access the complete state of an environment at each
point of time then it is a fully observable environment, else it is partially observable.
Example: chess – the board is fully observable, as are opponent’s moves. Driving
– what is around the next bend is not observable and hence partially observable.
1. Deterministic vs Stochastic
If an agent's current state and selected action can completely determine the next state
of the environment, then such environment is called a deterministic environment.
In a deterministic, fully observable environment, agent does not need to worry about
uncertainty.
2. Episodic vs Sequential
In an episodic environment, there is a series of one-shot actions, and only the current
percept is required for the action.
3. Single-agent vs Multi-agent
If only one agent is involved in an environment, and operating by itself then such an
environment is called single agent environment.
13
However, if multiple agents are operating in an environment, then such an
environment is called a multi-agent environment.
The agent design problems in the multi-agent environment are different from single
agent environment.
4. Static vs Dynamic
If the environment can change itself while an agent is deliberating then such
environment is called a dynamic environment else it is called a static environment.
Static environments are easy to deal because an agent does not need to continue
looking at the world while deciding for an action.
However for dynamic environment, agents need to keep looking at the world at each
action.
5. Discrete vs Continuous
If in an environment there are a finite number of precepts and actions that can be
performed within it, then such an environment is called a discrete environment else it
is called continuous environment.
A chess game comes under discrete environment as there is a finite number of moves
that can be performed.
14
6. Known vs Unknown
Known and unknown are not actually a feature of an environment, but it is an agent's
state of knowledge to perform an action.
In a known environment, the results for all actions are known to the agent. While in
unknown environment, agent needs to learn how it works in order to perform an
action.
If an agent can obtain complete and accurate information about the state's
environment, then such an environment is called an Accessible environment else it is
called inaccessible.
Task environments, which are essentially the "problems" to which rational agents
are the "solutions."
Intelligent Agents:
An intelligent agent is an autonomous entity which act upon an environment using sensors and actuators for
achieving goals. An intelligent agent may learn from the environment to achieve their goals. A thermostat is an
example of an intelligent agent.
The agent receives some form of sensory input from its environment, and it performs
some action that changes its environment in some way.
Autonomy
The agent can act without direct intervention by humans or other agents and that it has
control over its own actions and internal state.
15
Adaptivity
Sociability
This type of characteristic means that the agent is capable of interacting in a peer-to-peer manner
16
Rational Agent - A system is rational if it does the “right thing”.. A rational agent is said to
perform the right things. AI is about creating rational agents to use for game theory and decision
theory for various real-world scenarios.
For every possible percept sequence, a rational agent should select an action that is
expected to maximize its performance measure, given the evidence provided by the percept
sequence and whatever built-in knowledge the agent has.
Rationality:
Performance
The output which we get from the agent. All the necessary results that an agent gives
after processing comes under its performance.
Environment
17
All the surrounding things and conditions of an agent fall in this section. It basically
consists of all the things under which the agents work.
Actuators
The devices, hardware or software through which the agent performs any actions or
processes any information to produce a result are the actuators of the agent.
Sensors
The devices through which the agent observes and perceives its environment are the
sensors of the agent.
18
TYPES OF AGENTS
Agents can be grouped into four classes based on their degree of perceived
intelligence and capability :
The Simple reflex agents are the simplest agents. These agents take decisions on the
basis of the current percepts and ignore the rest of the percept history (past State).
The Simple reflex agent does not consider any part of percepts history during their
decision and action process.
The Simple reflex agent works on Condition-action rule, which means it maps the
current state to action. Such as a Room Cleaner agent, it works only if there is dirt in
the room.
19
o Mostly too big to generate and to store.
The Model-based agent can work in a partially observable environment, and track the
situation.
A model-based agent has two important factors:
o Model: It is knowledge about "how things happen in the world," so it is called a
Model-based agent.
o Internal State: It is a representation of the current state based on percept history.
These agents have the model, "which is knowledge of the world" and based on the
model they perform actions.
Updating the agent state requires information about:
o How the world evolves
o How the agent's action affects the world.
20
Figure 1.7 A model-based reflex agent
o The knowledge of the current state environment is not always sufficient to decide for
an agent to what to do.
o The agent needs to know its goal which describes desirable situations.
o Goal-based agents expand the capabilities of the model-based agent by having the
"goal" information.
o These agents may have to consider a long sequence of possible actions before
deciding whether the goal is achieved or not. Such considerations of different scenario
are called searching and planning, which makes an agent proactive.
21
Utility Based Agents
o These agents are similar to the goal-based agent but provide an extra component of
utility measurement (“Level of Happiness”) which makes them different by
providing a measure of success at a given state.
o Utility-based agent act based not only goals but also the best way to achieve the goal.
o The Utility-based agent is useful when there are multiple possible alternatives, and an
agent has to choose in order to perform the best action.
o The utility function maps each state to a real number to check how efficiently each
action achieves the goals.
o A learning agent in AI is the type of agent which can learn from its past experiences,
or it has learning capabilities.
o It starts to act with basic knowledge and then able to act and adapt automatically
through learning.
b. Critic: Learning element takes feedback from critic which describes that how
well the agent is doing with respect to a fixed performance standard.
22
d. Problem generator: This component is responsible for suggesting actions that
will lead to new and informative experiences.
o Hence, learning agents are able to learn, analyze performance, and look for new ways
to improve the performance.
agents
Some of the most popularly used problem solving with the help of artificial
intelligence are:
1. Chess.
2. Travelling Salesman Problem.
3. Tower of Hanoi Problem.
4. Water-Jug Problem.
5. N-Queen Problem.
Problem Searching
23
Searching is the most commonly used technique of problem solving in artificial
intelligence.
Problem: Problems are the issues which comes across any system. A solution is needed to
solve that particular problem.
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.
1. Analyzing The Problem: Analyzing the problem and its requirement must be done as
few features can have immense impact on the resulting solution.
3. Choosing a Solution: From all the identified solutions, the best solution is chosen
basis on the results produced by respective solutions.
24
Completeness: Is the algorithm guaranteed to find a solution when there is one?
Optimality: Does the strategy find the optimal solution?
Time complexity: How long does it take to find a solution?
Space complexity: How much memory is needed to perform the search?
1. Search Space: Search space represents a set of possible solutions, which a system
may have.
3. Goal test: It is a function which observe the current state and returns whether the
goal state is achieved or not.
Search tree: A tree representation of search problem is called Search tree. The root of
the search tree is the root node which is corresponding to the initial state.
Actions: It gives the description of all the available actions to the agent.
Solution: It is an action sequence which leads from the start node to the goal node.
Optimal Solution: If a solution has the lowest cost among all solutions.
Example Problems
Toy Problems
Vacuum World
States: The state is determined by both the agent location and the dirt locations. The
agent is in one of the 2 locations, each of which might or might not contain dirt. Thus there
are 2*2^2=8 possible world states.
25
Actions: In this simple environment, each state has just three actions: Left, Right, and
Suck. Larger environments might also include Up and Down.
Transition model: The actions have their expected effects, except that moving Left in
the leftmost squ are, moving Right in the rightmost square, and Sucking in a clean square
have no effect. The complete state space is shown in Figure.
Goal test: This checks whether all the squares are clean.
Path cost: Each step costs 1, so the path cost is the number of steps in the path.
1) 8- Puzzle Problem
States: A state description specifies the location of each of the eight tiles and the
blank in one of the nine squares.
26
Initial state: Any state can be designated as the initial state. Note that any given goal
can be reached from exactly half of the possible initial states.
The simplest formulation defines the actions as movements of the blank space Left,
Right, Up, or Down. Different subsets of these are possible depending on where the blank is.
Transition model: Given a state and action, this returns the resulting state; for
example, if we apply Left to the start state in Figure 3.4, the resulting state has the 5 and the
blank switched.
Goal test: This checks whether the state matches the goal configuration shown in
Figure. Path cost: Each step costs 1, so the path cost is the number of steps in the path.
Queens Problem
27
28