Download as pdf or txt
Download as pdf or txt
You are on page 1of 144

ARTIFICIAL INTELLIGENCE

(AI)

CHAPTER -1-
Introduction to Artificial Intelligence
AI – General:
• Let’s see the following:

How does How do we


the human emulate the
brain work? human brain?

How do we
create
What is intelligence?
intelligence?

Who cares? Let’s


do some cool and
useful stuff!

3/16/2021 AI @ IT- by Ayana O. Kitil 2


AI – General, Cont. …(2)
• What did you analysis?

3/16/2021 AI @ IT- by Ayana O. Kitil 3


Intelligence, Artificial:
• Artificial is produced by human art or effort.

• Intelligence is the ability to think, to learn, and solve problems.


o It is the ability to acquire knowledge and use it.

Goals of AI:

• To make computers more useful by letting them take over dangerous or tedious
tasks from human.

• Understand principles of human intelligence.

3/16/2021 AI @ IT- by Ayana O. Kitil 4


What is AI? (1)
• It is an area of computer science that emphasizes the creation of intelligent
machines that work and react like humans.

• It is the simulation of human intelligence processes by machines, especially


computer systems.

• These processes include learning (the acquisition of information and rules for
using the information), reasoning (using rules to reach approximate or definite
conclusions) and self-correction.

3/16/2021 AI @ IT- by Ayana O. Kitil 5


AI, Cont. …(2)
• Generally, there are eight definitions of AI, laid out along two dimensions.

• The definitions on TOP are concerned with thought processes and reasoning,
whereas the ones on the BOTTOM address behaviour.

• The definitions on the LEFT measure success in terms of fidelity to human


performance, whereas the ones on the RIGHT measure against an ideal
performance measure, called rationality.

• A system is rational if it does the “right thing,” given what it knows.

3/16/2021 AI @ IT- by Ayana O. Kitil 6


AI, Cont. …(3)

Fig. 1.1. Some definitions of artificial intelligence, organized into four categories .

3/16/2021 AI @ IT- by Ayana O. Kitil 7


AI, … (4)
• The above table means that:

• It is one of the newest fields in science and engineering.


• The name itself was coined in 1956 by John McCarthy.
• Art is subjective, while science is objective.
• Art depends on science, while science is the root of art.

3/16/2021 AI @ IT- by Ayana O. Kitil 8


Approaches to AI:
a. Act Humanly: The Turing Test Approach
• The Turing Test (performed by Turing Machine), proposed by Alan Turing (1950).
• 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.
• The computer would need to possess the following capabilities:
a. Natural Language Processing (NLP) to enable it to communicate successfully in English;
b. Knowledge Representation to store what it knows or hears;
c. Automated Reasoning to use the stored information to answer questions and to draw new
conclusions;
d. Machine Learning to adapt to new circumstances and to detect and extrapolate patterns.
e. Computer Vision to perceive objects, and
f. Robotics to manipulate objects and move about.

3/16/2021 AI @ IT- by Ayana O. Kitil 9


Approaches to AI, Cont. …(2)
b. Think Humanly: The Cognitive Modeling Approach
• If we are going to say that a given program thinks like a human, we must have
some way of determining how humans think.
• We need to get inside the actual workings of human minds.
• There are three ways to do this through:
a. Introspection - trying to catch our own thoughts as they go by;
b. Psychological Experiments - observing a person in action; and
c. Brain Imaging - observing the brain in action.
c. Think Rationally: The “Laws of Thought” Approach
• “Right Thinking” – is first codified by Aristotle.
• His syllogisms provided patterns for argument structures that always yielded
correct conclusions when given correct premises.

3/16/2021 AI @ IT- by Ayana O. Kitil 10


Approaches to AI, Cont. …(3)
• 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; their
study initiated the field called logic.
d. Acting Rationally: The Rational Agent Approach
• An agent is just something that acts (agent comes from the Latin agere, to do).
• All computer programs do something, but computer agents are expected to do
more:
o Operate autonomously,
o Perceive their environment,
o Persist over a prolonged time period,
o Adapt to change, &
o Create and pursue goals.

3/16/2021 AI @ IT- by Ayana O. Kitil 11


The Foundation of AI:
1. Philosophy – is the rational investigation of questions about existence and knowledge
and ethics.
o Rationalism – doing right thing.
o Dualism – to be considered in two states. Example : Humans.
o Materialism – which holds that the brain’s operation according to the laws of physics constitutes
the mind.
o Empiricism – nothing is in the understanding, which was not first in the senses.
o Induction - general rules are acquired by exposure to repeated associations between their
elements.
o Logical Positivism - it combines rationalism and empiricism.
o Confirmation Theory - attempted to analyse the acquisition of knowledge from experience.
o Generally:
 Canformal rules be used to draw valid conclusions?
 How does the mind arise from a physical brain?
 Where does knowledge come from?
 How does knowledge lead to action?

3/16/2021 AI @ IT- by Ayana O. Kitil 12


The Foundation of AI, Cont. …(2)
2. Mathematics – is about a number?
o Philosophers required a level of mathematical formalization in three fundamental
areas:
a. Logic – identification of objects and relations.
b. Computation – solve the given problems.
o Tractability - to solve a problem by dividing into sub-problems within a given time.
o The time required to solve the a given problem growths exponentially.
c. Probability – is about uncertain measurements.

3. Economics – is it about money?


o How should we make decisions so as to maximize payoff?
o How should we do this when others may not go along?
o How should we do this when the payoff may be far in the future?

3/16/2021 AI @ IT- by Ayana O. Kitil 13


The Foundation of AI, Cont. …(3)
4. Neuroscience – is the study of the nervous system, particularly the brain.
o How do brains process information?
o Mysticism – irrational thought or a religion based on mystical communion with an ultimate
reality
5. Psychology – is the science of mental life.
o How do humans and animals think and act?
6. Computer Engineering – For artificial intelligence to succeed, we need two things:
intelligence and an artifact.
o How can we build an efficient computer?
7. Control Theory and Cybernetics – designing systems that behave optimally.
o Example: Water Clock
o How can artifacts operate under their own control?

8. Linguistics – it is about NLP.


o How does language relate to thought?

3/16/2021 AI @ IT- by Ayana O. Kitil 14


Bit History of AI:
• 1950 – Alan Turing published “Computing Machinery and Intelligence,” which
proposed the idea of The Imitation Game – a question that considered if
machines can think.

• 1956 – is the birth of AI.


o John McCarthy who is the father of AI using LISP programming language.

• READ by your own!

3/16/2021 AI @ IT- by Ayana O. Kitil 15


State of Art:
• It deals with the applications of AI. Some application areas are:
o Robotic Vehicles – A driverless robotic car named STANLEY.

o Speech Recognition – capable of hearing and comprehending the language in terms of


sentences and their meanings.

o Autonomous Planning and Scheduling – operations of spacecraft.

o Game Playing – they use heuristic knowledge of possible positions like chess, tic-tac-
toe, etc.

o Spam Fighting – classify over a billion messages as spam using learning algorithms.

3/16/2021 AI @ IT- by Ayana O. Kitil 16


State of Art, Cont. …(2)
o Logistic Planning – dynamic analysis and re-planning tool for transportation.

o Robotics – able to perform the tasks given by a human.

o Machine Translation – capable of translating from one language to another.

o NLP – interacting with computers that understand spoken language.

o Machine Vision – systems understand, interpret, and comprehend visual input on the
computer.

o Handwriting Recognition – reads the text written on paper by a pen or on screen by a


stylus.

3/16/2021 AI @ IT- by Ayana O. Kitil 17


State of Art, Cont. …(3)
• Games

3/16/2021 AI @ IT- by Ayana O. Kitil 18


State of Art, Cont. …(4)
• Pedestrian Detection vs. Military Robots

3/16/2021 AI @ IT- by Ayana O. Kitil 19


Individual Assignment-1-:
1. Define AI in your own words/statement. List and explain AI types with an
example.

2. List the advantages and disadvantages of AI.

Due Date: Monday, 22 March., 2021

Submission Form: Hardcopy on -1- A4 Paper

3/16/2021 AI @ IT- by Ayana O. Kitil 20


ARTIFICIAL INTELLIGENCE
(AI)

CHAPTER -2-
Intelligent Agents
Introduction:
• We begin by examining agents, environments, and the coupling between them.

• How well an agent can behave depends on the nature of the environment; some
environments are more difficult than others.

• We give a crude categorization of environments and show how properties of an


environment influence the design of suitable agents for that environment.

3/16/2021 AI @ IT- by Ayana O. Kitil 22


Agents and Environments:
• An agent is anything that can be viewed as perceiving its environment through
sensors and acting upon that environment through actuators.

Fig. 2.1. Agents interact with environments through sensors and actuators.
3/16/2021 AI @ IT- by Ayana O. Kitil 23
Agents and Environments, Cont. …(2)
• A human agent has eyes, ears, and other organs for sensors and hands, legs,
vocal tract, and so on for actuators.
• A robotic agent might have cameras and infrared range finders for sensors and
various motors for actuators.

• The term percept to refer to the agent’s perceptual inputs at any given instant.
• An agent’s percept sequence is the complete history of everything the agent has
ever perceived.
• An agent’s behaviour is described by the agent function that maps any given
percept sequence to an action.

3/16/2021 AI @ IT- by Ayana O. Kitil 24


Agents and Environments, Cont. …(3)
• Example:
o The vacuum-cleaner world.
o It has two locations: squares A and B. It is shown here below figure.

Fig. 2.2. A vacuum-cleaner world with just two locations.

• The vacuum agent perceives which square it is in and whether there is dirt in the square.
• It can choose to move left, move right, suck up the dirt, or do nothing.
• One very simple agent function is the following: if the current square is dirty, then suck;
otherwise, move to the other square.
3/16/2021 AI @ IT- by Ayana O. Kitil 25
Agents and Environments, Cont. …(4)
• A partial tabulation of this agent function is shown in figure below.

Fig. 2.3. Partial tabulation of a simple agent function for the vacuum-cleaner world shown in fig. 2.2.

3/16/2021 AI @ IT- by Ayana O. Kitil 26


Acting of Intelligent Agents:
• A rational agent is one that does the right thing.

• When an agent is plunked down in an environment, it generates a sequence of


actions according to the precepts it receives.

• What is rational at any given time depends on four things:


o The performance measure that defines the criterion of success.

o The agent’s prior knowledge of the environment.

o The actions that the agent can perform.

o The agent’s percept sequence to date.

3/16/2021 AI @ IT- by Ayana O. Kitil 27


Nature of Environments:
a. Specifying the Task Environment:
• A group of the performance measure, the environment, and the agent’s actuators and
sensors specified are called task environment.
• Acronymically minded as PEAS (Performance, Environment, Actuators, Sensors).
• In designing an agent, the first step must always be to specify the task environment as
fully as possible.
• Example - Consider an automated taxi driver.

Fig. 2.4. PEAS description of the task environment for an automated taxi.
3/16/2021 AI @ IT- by Ayana O. Kitil 28
Nature of Environments, Cont. …(2)
b. Properties of Task Environment:
o Fully Observable vs. Partially Observable – Example: Vacuum Agent vs. Taxi
Driving
o Single Agent vs. Multi-agent- Example: Crossword Puzzle vs. Chess
 What did you think is a Taxi Driving?

o Deterministic vs. Stochastic – Example: Vacuum World vs. Taxi Driving


 Full observable  Deterministic, while partially observable  Stochastic

 The word “stochastic” generally implies that uncertainty about outcomes is quantified in
terms of probabilities;
3/16/2021 AI @ IT- by Ayana O. Kitil 29
Nature of Environments, Cont. …(3)
o Episodic vs. Sequential – Example: Music vs. Chess, Taxi Driving
o Static vs. Dynamic – Example: Crossword Puzzle vs. Taxi Driving
o Discrete vs. Continuous – Example: Chess vs. Taxi Driving
o Known vs. Unknown – Example: Solitaire Card Game vs. Video Game

3/16/2021 AI @ IT- by Ayana O. Kitil 30


Structure of Intelligent Agents:
• Behaviour is the action that is performed after any given sequence of precepts'.

• The job of AI is to design an agent program that implements the agent function -
the mapping from precepts' to actions.

• Agent = architecture + program.

• Agent Programs takes the current percept as input from the sensors, while the
agent function, which takes the entire percept history and return an action to the
actuators.

3/16/2021 AI @ IT- by Ayana O. Kitil 31


Agent Program Types:
• There are basically five basic kinds of agent programs that embody the principles
underlying almost all intelligent systems:

1. Simple Reflex Agent:

2. Model Based Reflex Agent:

3. Goal Based Agent:

4. Utility Based Agent:

5. Learning Agent:

3/16/2021 AI @ IT- by Ayana O. Kitil 32


1. Simple Reflex Agent:
• It is the simplest kind of agent.

• These agents select actions on the basis of the current percept, ignoring the rest of
the percept history.

• It works only in fully-observable environment.

• Example-1-: Vacuum Agent

Fig. 2.5. The agent program for a simple reflex agent in the two-state vacuum environment.
3/16/2021 AI @ IT- by Ayana O. Kitil 33
1. Simple Reflex Agent, Cont. …(2)
• Example--2: Taxi Driver

Fig. 2.6. Schematic diagram of a simple reflex agent.


3/16/2021 AI @ IT- by Ayana O. Kitil 34
2. Model Based Reflex Agent:
• It is used to keep track of the part of the world it can’t see now (partial observability).
• It is uses knowledge–base.
• Example: Taxi Driver

Fig. 2.7. A model-based reflex agent.

3/16/2021 AI @ IT- by Ayana O. Kitil 35


3. Goal Based Agent:
• It is an expansion of model-based reflex agent, with goal.

• Example: Taxi Driver

• Searching and Planning


Fig. 2.8. A model-based, goal-based agent.

3/16/2021 AI @ IT- by Ayana O. Kitil 36


4. Utility Based Agent:
• It is essentially an internalization of the performance measure.
• It uses partial observability and stochasticity.
• Example: Taxi Driver

Fig. 2.9. A model-based,


utility-based agent.

3/16/2021 AI @ IT- by Ayana O. Kitil 37


5. Learning Agent:
• It is used to improve the performance of their components so as to generate better actions.

• It can be divided into four conceptual components.

Fig. 2.10. A general learning agent.

3/16/2021 AI @ IT- by Ayana O. Kitil 38


5. Learning Agent, Cont. …(2)
• Learning element is responsible for making improvements.
• Performance element is responsible for selecting external actions.
• The critic tells the learning element how well the agent is doing with respect to a
fixed performance standard.
• Problem generator is responsible for suggesting actions that will lead to new and
informative experiences.
• Generally, learning in intelligent agents can be summarized as a process of
modification of each component of the agent to bring the components into closer
agreement with the available feedback information, thereby improving the overall
performance of the agent.

3/16/2021 AI @ IT- by Ayana O. Kitil 39


Important Concepts and Terms:
• How the components of agent programs work?
• To understand how the components of agent program work, it is important to
categorize into the following parts:

Fig. 2.11 Three ways to represent states and the transitions between them.

3/16/2021 AI @ IT- by Ayana O. Kitil 40


Important Concepts and Terms, Cont. …(2)
• An atomic representation each state of the world is indivisible - it has no
internal structure.
o Example: Search, and Game-Playing.

• A factored representation splits up each state into a fixed set of variables or


attributes, each of which can have a value.
o Example: Constraint Satisfaction Problem, Propositional Logic, and Machine Learning.

• A Structured representation is a state includes objects, each of which may have


attributes of its own as well as relationships to other objects.
o Example: Relational Databases, First-Order Logic, First-Order Probability Models,
Knowledge-Based Learning and Natural Language Understanding.

3/16/2021 AI @ IT- by Ayana O. Kitil 41


Group Assignment-1- [Member of -2-]:
1. Compare and contrast the five type of agents.

2. For each of the following activities, give a PEAS description of the task
environment and characterize it in terms of the properties.
a. Shopping for used AI books from Internet.

Due Date: Wednesday, 24 March., 2021


Submission Form: Hardcopy on -1- A4 Paper

3/16/2021 AI @ IT- by Ayana O. Kitil 42


ARTIFICIAL INTELLIGENCE
(AI)

CHAPTER -3-

Solving Problems by Searching and Constraint


Satisfaction Problem (CSP)
3.1. Introduction:
• This chapter describes one kind of goal-based agent called a problem-solving
agent.

• Problem-solving agents use atomic representations.

• The search algorithms used in this chapter to solve problems are uninformed
search algorithms - algorithms that are given no information about the problem
other than its definition and an informed search algorithm can do quite well
given some guidance on where to look for solutions.

3/16/2021 AI @ IT- by Ayana O. Kitil 44


3.2. Problem-Solving by Searching
1. Problem Solving Agent:
• Intelligent agents are supposed to maximize their performance measure.
• Goal formulation, based on the current situation and the agent’s performance measure, is the
first step in problem solving.
• Problem formulation is the process of deciding what actions and states to consider, given a
goal, OR the model of formulating a given problem into initial state, actions, transition model,
goal test and path cost.
• The process of looking for a sequence of actions that reaches the goal is called search.
• A search algorithm takes a problem as input and returns a solution in the form of an action
sequence. Once a solution is found, the actions it recommends can be carried out. This is called
the execution phase.

3/16/2021 AI @ IT- by Ayana O. Kitil 45


3.2. Problem-Solving by Searching, Cont. …(2)
• Thus, we have a simple “formulate, search, execute” design for the agent, as shown below.

Fig. 3.1. 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.
3/16/2021 AI @ IT- by Ayana O. Kitil 46
Map of Romania: In(Arad) --- In(Bucharest), Cont. …(3)

Fig. 3.2. A simplified road map of part of Romania.


a

3/16/2021 AI @ IT- by Ayana O. Kitil 47


3.2. Problem-Solving by Searching, Cont. …(4)
Well-Defined Problems and Solutions:

• A problem can be defined formally by five components:

1. The INITIAL STATE that the agent starts in.


o Example: Suppose from map of ROMANIA initial state as In(Arad)

2. A description of the possible ACTIONS 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.
o Example: From the state In(Arad), the applicable actions are {Go(Sibiu), Go(Timisoara),
Go(Zerind)}.

3/16/2021 AI @ IT- by Ayana O. Kitil 48


3.2. Problem-Solving by Searching, Cont. …(5)
3. 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.
o The term successor refers to any state reachable from a given state by a single action.
o Example: RESULT (In (Arad), Go (Zerind)) = In (Zerind)
o State-Space:

 It is the implicit togetherness of initial state, actions and transition model.


 It is the set of all states reachable from the initial state by any sequence of actions.
 It 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.
3/16/2021 AI @ IT- by Ayana O. Kitil 49
3.2. Problem-Solving by Searching, Cont. …(6)
4. The GOAL TEST, which determines whether a given state is a goal state.
o Example: The agent’s goal in Romania is the singleton set {In(Bucharest)}.

5. A path cost function that assigns a numeric cost to each path.


o The cost of a path is the sum of the costs of the individual actions along the path.

o The step cost of taking action a in state s to reach state sꞌ is denoted by c(s, a, sꞌ).
o We assume that step costs are non-negative.

• Therefore, the shortest path cost to reach the goal is 140 + 80 + 97 + 101 = 418.

• 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.
3/16/2021 AI @ IT- by Ayana O. Kitil 50
3.2. Problem-Solving by Searching, Cont. …(7)
2. Example – Search Problems [Toy Problem]
o The 8-Queens problem. The goal of this is to place eight queens on a chessboard such
that no queen attacks any other. (A queen attacks any piece in the same row, column or
diagonal.)

o States: Any arrangement of 0 to 8 queens on the board


is a state.
a. Initial State – no queens on the board.
b. Actions – add a queen to any empty square.
c. Transition Model – returns the board with a queen
added to the specified square.
d. Goal Test – 8 queens are on the board, none attacked.
e. Path Cost – each step costs 1, so the path cost is the
Fig. 3.3. Almost a solution to the 8-queens problem.
number of steps in the path.
3/16/2021 AI @ IT- by Ayana O. Kitil 51
3.2. Problem-Solving by Searching, Cont. …(8)
2. Example – Search Problems [Real-World Problem]
a. Route-Finding Problem:
 It is defined in terms of specified locations and transitions along links between them.
 Example: Website, Airline Travel-Planning Systems, Military Operation Planning, etc.
b. Touring Problem:
 Visit every city at least once, starting and ending at the same place.
 The actions correspond to trips between adjacent cities.
 Each state must include not just the current location but also the set of cities the agent has
visited.
 Example – Initial State – In(Bucharest), Visited({Bucharest}), Intermediate State –
In(Vaslui), Visited({Bucharest , Urziceni , Vaslui}), and the goal test would check whether the
agent is in Bucharest and all 20 cities have been visited.

3/16/2021 AI @ IT- by Ayana O. Kitil 52


3.2. Problem-Solving by Searching, Cont. …(9)
2. Example – Search Problems [Real-World Problem]
c. Travelling Salesman Problem (TSP):
 It is a touring problem in which each city must be visited exactly once.
 The aim is to find the shortest tour.
 Example: Find the shortest path if the initial and goal state is A.

Fig. 3.4. Route-finding problems in the world.


3/16/2021 AI @ IT- by Ayana O. Kitil 53
3.2. Problem-Solving by Searching, Cont. …(10)
3. Search Strategies:

• The basic structures that all search algorithms share primarily according to how
they choose which state to expand next.

• There are basically two search strategies. They are

A. Uninformed Search Strategy


o It is also called blind search.
o It is the strategies that have no additional information about states beyond that provided in the
problem definition.
o All they can do is generate successors and distinguish a goal state from a non-goal state.
o All search strategies are distinguished by the order in which nodes are expanded.
3/16/2021 AI @ IT- by Ayana O. Kitil 54
3.2. Problem-Solving by Searching, Cont. …(11)
o Example: Breadth-First Search, Uniform Cost-Search, Depth-First Search, Depth-Limited
Search, Iterative Deepening Depth-First Search, & Bidirectional Search.

1. Breadth-First Search (BFS):


o It an algorithm used to expand the shallowest unexpanded state level-wise.
o Its implementation follows queue procedure, i.e., FIFO.
o It is complete.
o It is optimal if all path costs are the same.
o Example - Find the goal state 11 using BFS.

Fig. 3.5. A tree of level-3.


3/16/2021 AI @ IT- by Ayana O. Kitil 55
3.2. Problem-Solving by Searching, Cont. …(12)
2. Depth-First Search (DFS):
o It is used to expands the deepest unexpanded state and backtracks it to find its goal state.
o Its implementation follows a stack procedure, i.e., LIFO.
o It isn’t complete because of infinite depth and loops.
o It isn’t optimal and it uses a pre-order searching strategy, i.e., Root → Left → Right.
o Example: Find the goal state 11 using DFS from the above Fig. 3.5.

EXERCISE:
•Apply the uninformed search strategy on the Romania map as per you understand!
oHint:
Change the graph into tree.
Use the concepts of frontier [Open List] and explored set [Closed List].
Consider the goal state is Bucharest.
3/16/2021 AI @ IT- by Ayana O. Kitil 56
3.2. Problem-Solving by Searching, Cont. …(13)
B. Informed Search Strategy
o It is also called Heuristic Search.

o It uses problem-specific knowledge beyond the definition of the problem itself - can find
solutions more efficiently.

o It uses a shortest-path since its cost known.

o It uses domain specific knowledge.

o Example: Best-First Search, Greedy Best-First Search, A* Search, Memory-Bounded


Heuristic Search (Recursive Best-First Search, Simplified Memory-Bounded A*), etc.

3/16/2021 AI @ IT- by Ayana O. Kitil 57


3.2. Problem-Solving by Searching, Cont. …(14)
1. A* Search:
o It evaluates nodes by combining g(n), the cost to reach the node, and h(n), the cost to
get from the node to the goal:
𝑓(𝑛) = 𝑔(𝑛) + ℎ(𝑛)
o Since g(n) gives the path cost from the start node to node n, and h(n) is the estimated
cost of the cheapest path from n to the goal (heuristic value), we have
𝑓(𝑛) = 𝑒𝑠𝑡𝑖𝑚𝑎𝑡𝑒𝑑 𝑐𝑜𝑠𝑡 𝑜𝑓 𝑡ℎ𝑒 𝑐ℎ𝑒𝑎𝑝𝑒𝑠𝑡 𝑠𝑜𝑙𝑢𝑡𝑖𝑜𝑛 𝑡ℎ𝑟𝑜𝑢𝑔ℎ 𝑛 .
o Thus, if we are trying to find the cheapest solution, a reasonable thing to try first is the
node with the lowest value of g(n) + h(n).
o It is both complete and optimal.

3/16/2021 AI @ IT- by Ayana O. Kitil 58


3.2. Problem-Solving by Searching, Cont. …(15)
o Example – Find the shortest path if the initial state is “S” and goal state is “E” using
A* algorithm based on Fig. below.

Fig. 3.6. A graph of 8-cities.

3/16/2021 AI @ IT- by Ayana O. Kitil 59


3.2. Problem-Solving by Searching, Cont. …(16)
o Answer – f(n) = g(n) + h(n)

Cycle States Children of States Path (g(n)) F(n)


1. Initial State [] S = 0+1 = 1
(S, A) = 1+5= 6
2. Expand “S” A, B
(S, B) = 2+6 = 8
(S, A, Y) = 1+7+8 = 16
3. Expand “A” X, Y
(S, A, X) = 1+4+5 = 10
4. Expand “X” E (S, A, X, E) = 1+4+2+0 = 7
5. Expand “E” [] (S, A, X, E) = 1+4+2+0 = 7

o Therefore, the best path to arrive to the goal with an actual cost = “7”.

3/16/2021 AI @ IT- by Ayana O. Kitil 60


3.4. Constraint Satisfaction Problem (CSP)
• It is a factored representation is used for each state: a set of variables, each of
which has a value.

• It is a problem solved when each variable has a value that satisfies all the
constraints on the variable.

• A constraint satisfaction problem consists of three components, X, D, and C:

• Each domain Di consists of a set of allowable values, {v1, . . ., vk} for variable Xi.

3/16/2021 AI @ IT- by Ayana O. Kitil 61


3.4. Constraint Satisfaction Problem (CSP), Cont. …(2)
• Each constraint Ci consists of a pair {scope, rel}, where scope is a tuple of variables that
participate in the constraint and rel is a relation that defines the values that those variables
can take on.

• To solve a CSP, we need to define a state space and the notion of a solution.

• Each state in a CSP is defined by an assignment of values to some or all of the variables,
{Xi = vi, Xj = vj, . . .}.

• An assignment that does not violate any constraints is called a consistent or legal
assignment.

• A complete assignment is one in which every variable is assigned, and a solution to a


CSP is a consistent, complete assignment.

• A partial assignment is one that assigns values to only some of the variables.
3/16/2021 AI @ IT- by Ayana O. Kitil 62
3.4. Constraint Satisfaction Problem (CSP), Cont. …(3)
• Example – Crypt-arithmetic, N-Queen, Crossword Puzzle, Map Colouring, Latin
Square, and Sudoku.
Map Colouring Problem:
• Suppose that at a map of Australia showing each of its states and territories shown
in the Fig. below (a).

Fig. 3.7. (a). The principal states and


territories of Australia. (b) The map-
colouring problem represented as a
constraint graph.
3/16/2021 AI @ IT- by Ayana O. Kitil 63
3.4. Constraint Satisfaction Problem (CSP), Cont. …(4)
• It is given the task of colouring each region either red, green, or blue in such a way that
no neighbouring regions have the same colour.
• To formulate this as a CSP, we define the variables to be the regions
• The domain of each variable is the set Di = {red, green, blue}.
• The constraints require neighbouring regions to have distinct colours.
• Since there are nine places where regions border, there are nine constraints:

• Here, using abbreviations; SA ≠ WA is a shortcut for {(SA, WA), SA ≠ WA}, where SA ≠


WA can be fully enumerated in turn as

3/16/2021 AI @ IT- by Ayana O. Kitil 64


3.4. Constraint Satisfaction Problem (CSP), Cont. …(5)
Variations on the CSP Formalism:
• There are three types of constraints.
a. Unary Constraint – is the simplest type which restricts the value of a single variable.
 Example: Map-Colouring like ‹(SA), SA ≠ green›.
b. Binary Constraint – it relates two variables.
 Example: SA ≠ NSW.
 A binary CSP is one with only binary constraints; it can be represented as a constraint graph, as
in Fig. 3.7. (b).
c. Higher-Order Constraint – it involves three or more variables, such as asserting that the
value of Y is between X and Z, with the ternary constraint Between (X, Y, Z).

3/16/2021 AI @ IT- by Ayana O. Kitil 65


Games as Search Problem:
• Sudoku Puzzle
o Itis a 9x9 box – variable - 81 squares, constraint - no digit appears twice in any row,
column, or 3×3 box, and domain – 1 to 9 numbers.

Fig. 3.8. (a) A Sudoku puzzle and (b) its solution.


3/16/2021 AI @ IT- by Ayana O. Kitil 66
Exercise -2- & Group Assignment-2- [Member of 2]:
1. List at least three real-world application area where we use:
a. Uninformed search strategy
b. Informed strategy

2. By using the following figure, answer the questions below with a neat and clear step.

a. Is it a tree or graph? Why? Explain.


a. What is the shortest path to travel from ‘a’ to
‘z’ using: [Assignment]
i. Breadth First Search algorithm?
ii. A* Search algorithm?

Due Date: Monday, 29 March, 2021


Submission Form: Hardcopy on -1- A4 Paper
3/16/2021 AI @ IT- by Ayana O. Kitil 67
ARTIFICIAL INTELLIGENCE
(AI)

CHAPTER -4-
Knowledge and Reasoning in AI
4.1. Introduction
• Humans, it seems, know things; and what they know helps them do things.
• These are not empty statements.
• They make strong claims about how the intelligence of humans is achieved not by
purely reflex mechanisms but by processes of reasoning that operate on internal
representations of knowledge.
• It is called knowledge-based agents.
• Knowledge-base is where knowledge were stored.
• Knowledge-based system is a system which is built around a knowledge base,
i.e. a collection of knowledge, taken from a human, and stored in such a way that
the system can reason with it.
3/16/2021 AI @ IT- by Ayana O. Kitil 69
4.2. Knowledge-Based Agents
• The central component of a knowledge-based agent is its knowledge base, or KB.

• A knowledge base is a set of sentences.

• Each sentence is expressed in a language called a knowledge representation


language and represents some assertion about the world.

• Sometimes we dignify a sentence with the name axiom, when the sentence is
taken as given without being derived from other sentences.

• There must be a way to add new sentences to the knowledge base and a way to
query what is known.

• The standard names for these operations are TELL and ASK, respectively.
3/16/2021 AI @ IT- by Ayana O. Kitil 70
4.2. Knowledge-Based Agents, Cont. …(2)
• Both operations may involve inference - that is, deriving new sentences from old.

• Inference must obey the requirement that when one ASKs a question of the
knowledge base, the answer should follow from what has been told (or TELLed)
to the knowledge base previously.

• Suppose the following knowledge-based agent program.

Fig. 4.1. A generic knowledge-based


agent. Given a percept, the agent adds
the percept to its knowledge base, asks
the knowledge base for the best action,
and tells the knowledge base that it has
in fact taken that action.
3/16/2021 AI @ IT- by Ayana O. Kitil 71
4.2. Knowledge-Based Agents, Cont. …(3)
• Each time the agent program is called, it does three things:
a. It TELLs the knowledge base what it perceives.
b. It ASKs the knowledge base what action it should perform.
o In the process of answering this query, extensive reasoning may be done about the current state of
the world, about the outcomes of possible action sequences, and so on.
c. The agent program TELLs the knowledge base which action was chosen, and the agent
executes the action, i.e., it performs the chosen actions.

• MAKE-PERCEPT-SENTENCE constructs a sentence asserting that the agent


perceived the given percept at the given time.

• MAKE-ACTION-QUERY constructs a sentence that asks what action should be done at


the current time.
3/16/2021 AI @ IT- by Ayana O. Kitil 72
4.2. Knowledge-Based Agents, Cont. …(4)
• MAKE-ACTION-SENTENCE constructs a sentence asserting that the chosen
action was executed.

• The details of the inference mechanisms are hidden inside TELL and ASK.

• There are two approaches to build a knowledge-base.


a. Declarative Approach – starting with an empty knowledge base, the agent designer
can TELL sentences one by one until the agent knows how to operate in its
environment.
b. Procedural Approach – encodes desired behaviours directly as program code.

• We can also provide a knowledge-based agent with mechanisms that allow it to


learn for itself, i.e., a learning agent can be fully autonomous.
3/16/2021 AI @ IT- by Ayana O. Kitil 73
4.3. Expert System
• It is the computer applications developed to solve complex problems in a
particular domain, at the level of extra-ordinary human intelligence and expertise.
• It is a system that uses human expertise to make complicated decisions.
• Uses expert’s knowledge as rules and data within the system.

Characteristics of Expert System


• High performance
Generally:
• Understandable  An ES is a particular kind of knowledge-
based system
• Reliable  An ES can act as a substitute for the expert
from whom the knowledge was taken.
• High responsive
3/16/2021 AI @ IT- by Ayana O. Kitil 74
4.3. Expert System, Cont. …(2)
• General architecture of expert system:

Fig. 4.2. The architecture of expert system

3/16/2021 AI @ IT- by Ayana O. Kitil 75


4.3. Expert System, Cont. …(3)
Expert:
o Has the special knowledge, judgment, experience and methods to give advice and solve
problems.
o Provides knowledge about task performance.

Knowledge-Engineer:
o Helps the expert(s) structure the problem area by interpreting and integrating human
answers to questions, drawing analogies, and bringing to light conceptual difficulties.
o Usually also called System Builder.
o It translates the knowledge into computer understandable language.
o It designs an inference engine, a reasoning structure, which can use knowledge when
needed.
3/16/2021 AI @ IT- by Ayana O. Kitil 76
4.3. Expert System, Cont. …(4)
• There are three components of expert system.
a. Knowledge Base
o It represents all the data and information imputed by experts in the field.
o Also, it is an information inside the expert system represented as a series of IF-THEN
statements.
o It is a database that holds specific information and rules about a certain subject.
o It is a collection of objects and their attributes.
o Knowledge – is the sort of information that people use to solve problems.
i. Factual KN – is the information widely accepted by the knowledge engineers and scholars
in the task domain.
ii. Heuristic KN – is about practice, accurate judgement, one’s ability of evaluation, and
guessing.

3/16/2021 AI @ IT- by Ayana O. Kitil 77


4.3. Expert System, Cont. …(5)
b. Inference Engine or Reasoning [Thinking]
o It is a part of expert system that controls the steps taken to solve the problem.
o It is a brain of an expert system.
o There are two categories of inference engine:
i. Deterministic Inference Engine
 This type of inference engine has some element of certainty associated with it, i.e., this means
that the conclusion drawn from this type of inference engine are guaranteed to be true.
 Example – What would be produced when an acid mixes with a base?
ii. Probabilistic Inference Engine
 This type of inference engine has an element of uncertainty associated with it.
 Example – If there are 134 students in the class taking an AI exam, how many of these
students will pass the exam?
3/16/2021 AI @ IT- by Ayana O. Kitil 78
4.3. Expert System, Cont. …(6)
c. User Interface
o It is used for accessing and creating the expert system.
o This component takes the user’s query in a readable form and passes it to the inference
engine.
o After that it displays the results to the user.
o In other word, it is an interface that helps the user to communicate with the expert
system.

Some Expert Systems


• MYCIN – helps physician to diagnose certain bacterial disease.
• PROSPECTOR – predicts where certain minerals deposits may be found.
• DENDRAL – hypothesis on the possible molecular structure of a compound.
3/16/2021 AI @ IT- by Ayana O. Kitil 79
4.4. Knowledge Representation in AI
• It is a method used to organize and formalize the knowledge base (KB).

• It is a form IF-THEN-ELSE rules.

• It addresses the question of what content to put into an agent’s knowledge base –
how to represent facts about the world.

• The prospect of representing everything in the world is daunting.

• There are basically four the knowledge representation techniques.

3/16/2021 AI @ IT- by Ayana O. Kitil 80


4.4.1. Logic Representation
• A knowledge bases consist of sentences.
• These sentences are expressed according to the syntax of the representation
language, which specifies all the sentences that are well formed.
• The notion of syntax is clear enough in ordinary arithmetic: “x + y = 4” is a well-
formed sentence, whereas “x4y+ =” is not.
• A logic must define the semantics or meaning of sentences.
• The semantics defines the truth of each sentence with respect to each possible
world.
• Example:
o The semantics for arithmetic specifies that the sentence “𝑥 + 𝑦 =4” is true in a world where x
is 2 and y is 2, but false in a world where x is 1 and y is 1.
o In standard logics, every sentence must be either true or false in each possible world - there is
no “in between.”
3/16/2021 AI @ IT- by Ayana O. Kitil 81
4.4.1. Logic Representation, Cont. …(2)
Inference Techniques in Logical Agents

• There are basically three:


1. Forward Chaining – it matches the set of conditions and infer results from these
conditions.
2. Backward Chaining – it is a backward search from goal to the conditions used to get the
goal.
3. Proof by Resolution – produces a new clause implied by two clauses containing
complementary literals.

3/16/2021 AI @ IT- by Ayana O. Kitil 82


4.4.1. Logic Representation, Cont. …(3)
• Example:
1. A (is true) – By Forward Chaining 2. A (is true) – By Backward Chaining
B→C B→C
A→B A→C
C→D C→D
Prove D is also True. Prove D is also True.

Solution: Starting from A, A is true then Solution: Starting from D, let D is true
B is true (A→B) then C is true (C→D).
B is true then C is True (B→C) C is true then B is True (B→C).
C is True then D is true proved (C→D). B is True then A is true Proved (A→B)

3. By Resolution Rule
A V B, ¬B V C
AV C
3/16/2021 AI @ IT- by Ayana O. Kitil 83
4.4.2. Propositional Logic
• Proposition is a statement of a fact which is either TRUE or FALSE.
• Example:
o Lucky is an honest boy. → True/False?
o 4*5+2 = 30. → True/False?
o Today is Monday. → True/False?

• A propositional logic is a declarative, compositional semantics that is context-independent


and unambiguous - and borrowing representational ideas from natural language.

• It assumes the world contains facts.

• In this, syntax and semantics - the way in which the truth of sentences is determined.

• An entailment - the relation between a sentence and another sentence that follows from it.
3/16/2021 AI @ IT- by Ayana O. Kitil 84
4.4.2. Propositional Logic, Cont. …(2)
A. Syntax:
o It defines the allowable sentences.
o The atomic sentences consist of a single proposition symbol.
o Each such symbol stands for a proposition that can be true or false.
o We use symbols that start with an uppercase letter and may contain other letters.
o Example:

 P, Q, R, W and North.
o Complex sentences are constructed from simpler sentences, using parentheses and
logical connectives.
o There are five connectives in common use:

3/16/2021 AI @ IT- by Ayana O. Kitil 85


4.4.2. Propositional Logic, Cont. …(3)
1. ¬ (not). A sentence such as ¬P is called the negation of P.
o A literal is either an atomic sentence (a positive) or a negated atomic sentence (a negative
literal).

2. ∧ (and). A sentence whose main connective is ∧, such as P ∧ Q, is called a


conjunction.
3. ∨ (or). A sentence using ∨, such as (P ∧ Q) ∨ R, is a disjunction of the
disjuncts’ (P ∧ Q) and R.
4. ⇒ (implies). A sentence such as (P ∧ Q) ⇒ ¬R is called an implication (or
conditional).
o Its premise or antecedent is (P ∧ Q), and its conclusion or consequent is ¬R.
o Implications are also known as rules or if–then statements.

5. ⇔ (if and only if). The sentence P ⇔ ¬R is a bi-conditional.


3/16/2021 AI @ IT- by Ayana O. Kitil 86
Result 1 2 4 …
ValueSymbol 20 21 22 …
4.4.2. Propositional Logic, Cont. …(4)
B. Semantic:
o It defines the rules for determining the truth of a sentence with respect to a particular
model.
o A model simply fixes the truth value - true or false - for every proposition symbol.
o Example:

 If the sentences in the knowledge base make use of the proposition symbols P, Q, and R, then
one possible model is 𝑚1 = {𝑃 = 𝑓𝑎𝑙𝑠𝑒,𝑄 = 𝑓𝑎𝑙𝑠𝑒,𝑅 = 𝑡𝑟𝑢𝑒}.
o With three proposition symbols, there are 23 = 8 possible models. This is done
recursively.
o Example:

 The sentence ¬P ∧ (Q ∨ R), evaluated in m1, gives true ∧ (false ∨ true) = true ∧ true = true.
3/16/2021 AI @ IT- by Ayana O. Kitil 87
4.4.3. First-Order Logic (FOL) or Predicate Logic
• It is an extension of propositional logic.
• The language of FOL is built around objects, relations and functions.
• It can also express facts about some or all of the objects in the universe.
• When we look at the syntax of natural language, the world contains:
o Nouns and noun-phrases are referred to as objects such as squares, pits, Wumpus’s, House, …
o Verbs and verb-phrases that refer to relations.
 Unary relations or properties such as red, round, bogus, prime, multi-storeyed, . . .
 N-ary relations such as brother of, bigger than, inside, part of, has colour, occurred after, owns,
comes between, . . .
o Some of these relations are functions - relations in which there is only one “value” for a
given “input” like father of, best friend, third inning of, one more than, beginning of , …

3/16/2021 AI @ IT- by Ayana O. Kitil 88


4.4.3. FOL, Cont. … (2)
• Example -1- “One plus two equals three.”
o Object(s) – one, two, three, one plus two;
o Relation(s) – equals;
o Function(s) – plus.

• Example -2- “Squares neighbouring the Wumpus are smelly.”


o Object(s) –Wumpus, Squares;
o Relation(s) – smelly;
o Function(s) – neighbouring.

• What is the difference between propositional logic and predicate logic?


o The Ball’s colour is Red. (Propositional Logic)
o Colour(Ball, Red). (Predicate Logic) (Colour → Predicate, Ball & Red → Objects.)
3/16/2021 AI @ IT- by Ayana O. Kitil 89
4.4.3. FOL, Cont. … (3)
• The other difference between PL vs. FOL is:

Fig. 4.3. Formal languages and their ontological and epistemological commitments.

• Ontological Commitment – is expressed through the nature of the formal models


with respect to which the truth of sentences is defined.
• Epistemological Commitment – the possible states of knowledge that it allows
with respect to each fact.
3/16/2021 AI @ IT- by Ayana O. Kitil 90
4.4.3. FOL, Cont. … (4)
Syntax and Semantics of FOL:
a. Models of FOL:
o The domain of a model is the set of objects or domain elements it contains.
o Thedomain is required to be nonempty - every possible world must contain at least one
object.
o A relation is just the set of tuples of objects that are related.
A tuple is a collection of objects arranged in a fixed order and is written with angle brackets
surrounding the objects.
o The relations can be unary, binary (relate pair of objects) or n-ary.
o Models in first-order logic require total functions, that is, there must be a value for
every input tuple.

3/16/2021 AI @ IT- by Ayana O. Kitil 91


4.4.3. FOL, Cont. … (5)
• Example:
o Chalk is white. white (chalk). (Unary Predicate).
o Lucky is a friend of Success. friend (lucky, success). (Binary Predicate).
o Lucky gave a book to Success. gave (lucky, book, success). (N-ary Predicate).

b. Symbols and Interpretations:


o It is the link between those elements and the vocabulary of the logical sentences.
o The symbols come in three kinds:
i. Constant Symbols – stand for objects;
ii. Predicate Symbols – stand for relations &
iii. Function Symbols – stand for functions.

• Each predicate and function symbol come with an arity that fixes the number of
arguments.
3/16/2021 AI @ IT- by Ayana O. Kitil 92
4.4.3. FOL, Cont. … (6)
c. Terms:
o It is a logical expression that refers to an object.
o Example:
 “King John’s left leg” rather than giving a name to his leg.
 This is what function symbols are for: instead of using a constant symbol, we use
leftleg(john).

d. Atomic Sentences:
o It is a combination of terms and predicate that state facts.
o Example:
 brother (richard, john). This states that “Richard is the brother of John.”

3/16/2021 AI @ IT- by Ayana O. Kitil 93


4.4.3. FOL, Cont. … (7)
e. Complex Sentence(s):
o The logical connectives are used to construct more complex sentences, with the same
syntax and semantics as in propositional calculus.
o Example:

 ¬brother (leftleg (richard), john)


 king (richard) ∨ king (john)
 ¬king (richard) ⇒ king (john).

f. Quantifiers:
o It is a way of expressing properties of entire or some collections of objects.
o First-order logic contains two standard quantifiers.

3/16/2021 AI @ IT- by Ayana O. Kitil 94


4.4.3. FOL, Cont. … (8)
Syntax:
1. Universal Quantifiers (Ɐ):
Ɐ<variable> <sentence>
o It makes statements about every object.
o “All kings are persons” is written in first-order logic as ∀ x king(x) ⇒ person(x).
o ∀ is usually pronounced “For all . . .”, “For all x, if x is a king, then x is a person.”
o The symbol x is called a variable.
Syntax:
2. Existential Quantifiers (Ǝ): Ǝ<variable> <sentence>
o It makes a statement about some object in the universe without naming it.

o Example:

 “King John has a crown on his head”, we write ∃ x crown(x) ∧ onhead (x, john).
 ∃x is pronounced “There exists an x such that . . .” or “For some x . . .”.

3/16/2021 AI @ IT- by Ayana O. Kitil 95


4.4.3. FOL, Cont. … (9)
g. Equality:
o It signify that two terms refer to the same object.
o Example:

 father (john) = henry Note:


  is the main connective with 
Inference in FOL:   is the main connective with 
o It can be done by converting the knowledge-base to propositional logic.
o Example:

 All students are intelligent →∀ x students(x) ⇒ intelligent(x).


 Lucky is a student →∃ x lucky(x) ∧ student(x).
 Therefore, Lucky is intelligent → ∃ x lucky(x) ∧ intelligent(x).

3/16/2021 AI @ IT- by Ayana O. Kitil 96


4.4.4. Semantic Networks
• It provides graphical aids for visualizing a knowledge base and efficient
algorithms for inferring properties of an object on the basis of its category
membership.

• Example:

Fig. 4.4. A fragment of a semantic network showing the representation of the logical assertion
Fly(Shankar, NewYork, NewDelhi, Yesterday).
3/16/2021 AI @ IT- by Ayana O. Kitil 97
Discussion – Quiz:
1. AI is a magic. [True/False]. If False, why? If True, how?

2. Is AI omniscience or autonomy?

3. Expert system replace experts. [True/False]. Justify your answer.

4. What are the human element in expert system?

5. List at least 5 AI devices familiar to you. Did you think that they are expert
system?

3/16/2021 AI @ IT- by Ayana O. Kitil 98


Exercise:
1. Use resolution to prove the sentence ¬A∧¬B.

2. Consider a vocabulary with only four propositions, A, B, C, and D. How many


models are there for the following sentences?
a. B ∨ C.
b. ¬A∨¬B ∨¬C ∨ ¬D.

3. Express the following statements in first-order logic and vice-versa:


a. Joe owns a copy of Revolver.
b. Brothers are siblings.
c. x y loves(x, y)

3/16/2021 AI @ IT- by Ayana O. Kitil 99


ARTIFICIAL INTELLIGENCE
(AI)

CHAPTER -5-
Learning in AI
5.1. Introduction
• Learning denotes changes in a system that enable a system to do the same task
more efficiently the next time, by Herbert Simon.

• Machine learning is the subfield of computer science, that gives computers the
ability to learn without being explicitly programmed, by Arthur Samuel.

• A computer program is said to learn from experience 'E' with respect to some
class of tasks 'T' and performance measure 'P', if its performance at tasks in 'T', as
measured by 'P', improves with experience 'E', by Mitchell, in 1997.

• The main purpose of machine learning is to study and design the algorithms that
can be used to produce the predicates from the given dataset.

3/16/2021 AI @ IT- by Ayana O. Kitil 101


5.1. Introduction, Cont. …(2)
• Besides these, the machine learning includes the agent’s percepts for acting as
well as to improve their future performance.

• The following tasks must be learned by an agent.


a. To predict or decide the result state for an action.
b. To know the values for each state (understand which state has high or low value).
c. To keep record of relevant percepts.

3/16/2021 AI @ IT- by Ayana O. Kitil 102


5.2. Learning from Example or Observation
• It is simply called induction.

• An agent is learning if it improves its performance on future tasks after making


observations about the world.

• Learning can range from the trivial, as exhibited by jotting down a phone
number, to the profound, as exhibited by Albert Einstein, who inferred a new
theory of the universe.

• Why would we want an agent to learn?

• If the design of the agent can be improved, why wouldn’t the designers just
program in that improvement to begin with?
3/16/2021 AI @ IT- by Ayana O. Kitil 103
5.2. Learning from Example, Cont. …(2)
Forms of Learning:

• Any component of an agent can be improved by learning from data.

• The improvements, and the techniques used to make them, depend on four major
factors:
a) Which component is to be improved?
b) What prior knowledge the agent already has?
c) What representation is used for the data and the component?
d) What feedback is available to learn from?

3/16/2021 AI @ IT- by Ayana O. Kitil 104


5.2. Learning from Example, Cont. …(3)
1. Component to be Learned:

• The components of these agents include:


a. A direct mapping from conditions on the current state to actions.
b. A means to infer relevant properties of the world from the percept sequence.
c. Information about the way the world evolves and about the results of possible actions
the agent can take.
d. Utility information indicating the desirability of world states.
e. Action-value information indicating the desirability of actions.
f. Goals that describe classes of states whose achievement maximizes the agent’s
utility.

3/16/2021 AI @ IT- by Ayana O. Kitil 105


5.2. Learning from Example, Cont. …(4)
• Each of these components can be learned.

• Example – an agent training to become a taxi driver.


o Every time the instructor shouts “Brake!” the agent might learn a condition–action rule
for when to brake (Component-1).
o By seeing many camera images that it is told contain buses (Component-2).
o By trying actions and observing the results - for example, braking hard on a wet road -
it can learn the effects of its actions (Component-3).
o Then, when it receives no tip from passengers who have been thoroughly shaken up
during the trip (Component-4).

3/16/2021 AI @ IT- by Ayana O. Kitil 106


5.2. Learning from Example, Cont. …(5)
2. Representation
o It is a factored representation.

3. Prior Knowledge
o Learning a general function or rule from specific input–output pairs is called inductive
learning, whereas analytical or deductive learning going from a known general rule to
a new rule that is logically entailed.

4. Feedback to Learn From


o There are three types of feedback that determine the three main types of learning.

3/16/2021 AI @ IT- by Ayana O. Kitil 107


5.2. Learning from Example, Cont. …(6)
a. Unsupervised Learning:
o The agent learns patterns in the input even though no explicit feedback is supplied.
o Suppose a taxi agent might gradually develop a concept of “good traffic days” and
“bad traffic days” without ever being given labelled examples of each by a teacher.
o Example – Clustering, Association, etc.

b. Reinforcement Learning:
o The agent learns from a series of reinforcements – rewards or punishments.
o Suppose the lack of a tip at the end of the journey gives the taxi agent an indication
that it did something wrong.
o The two points for a win at the end of a chess game tells the agent it did something
right.
o Example – Game Playing.
3/16/2021 AI @ IT- by Ayana O. Kitil 108
5.2. Learning from Example, Cont. …(7)
c. Supervised Learning:
o The agent observes some example input–output pairs and learns a function that maps
from input to output.
o It involves learning with some supervision from external source, (i.e., a teacher).
 In Componet-1 above, the inputs are percepts and the output are provided by a teacher who
says “Brake!” or “Turn left.”
 In Componet-2, the inputs are camera images and the outputs again come from a teacher who
says “that’s a bus.”
 In Component-3, the theory of braking is a function from states and braking actions to
stopping distance in feet. In this case the environment is the teacher.
o Example – Classification, Regression, etc.

3/16/2021 AI @ IT- by Ayana O. Kitil 109


5.3. Artificial Neural Network (ANN)
Neural Network (NN):
o It is a system composed of many simple processing elements operating in parallel
which can acquire, store, and utilize experiential knowledge.
o It is a machine learning approach that models human brain and consists of a number
of artificial neurons.

ANN:
o It is modelled after brain.
o It is usually a computational network based on biological neural networks that
construct the structure of the human brain.
o It is designed by programming computers to behave simply like interconnected brain cells.
o It is also called connectionism, parallel distributed processing, and neural computation.

3/16/2021 AI @ IT- by Ayana O. Kitil 110


5.3. ANN, Cont. …(2)
o It, in the field of Artificial intelligence where it attempts to mimic the network of
neurons makes up a human brain so that computers will have an option to understand
things and make decisions in a human-like manner.

o Similar to a human brain has neurons interconnected to each other, ANN also have
neurons that are linked to each other in various layers of the networks. These neurons
are known as nodes.

o Neurons in ANNs tend to have fewer connections than biological neurons.

o It “fires” when a linear combination of its inputs exceeds some threshold.

3/16/2021 AI @ IT- by Ayana O. Kitil 111


5.3. ANN, Cont. …(3)
• Biological Neural Network vs. Artificial Neural Network

Fig. 5.1. Biological neural network vs. artificial neural network


• Dendrites from Biological Neural Network represent Inputs in Artificial Neural
Networks, Cell Nucleus represents Nodes, Synapse represents Weights, and Axon
represents Output.
3/16/2021 AI @ IT- by Ayana O. Kitil 112
5.3. Architecture of ANN, Cont. …(4)
• It primarily consists of three layers:

1. Input Layer – it accepts inputs provided


by the programmer.
2. Hidden Layer – it presents in-between
input and output layers.
o It performs all the calculations to find
hidden features and patterns.
3. Output Layer – the input goes through a
Fig. 5.2. ANN primary layers
series of transformations using the hidden
layer, which finally results in output.

3/16/2021 AI @ IT- by Ayana O. Kitil 113


5.3. ANN, Cont. …(5)
Neural Network Structures:
o Neural networks are composed of nodes or units connected by directed links.
o The properties of the network are determined by its topology and the properties of the
“neurons.”

Fig. 5.3. A simple mathematical model


for a neuron. The unit’s output activation
is 𝑎𝑗 = g(σ𝒏𝒊=𝟎 𝒘𝒊, 𝒋𝒂𝒊), where 𝑎𝑖 is the
output activation of unit 𝑖 and 𝑤𝑖,𝑗 is the
weight on the link from unit 𝑖 to unit 𝑗.

3/16/2021 AI @ IT- by Ayana O. Kitil 114


5.3. ANN, Cont. …(6)
o It takes input and computes the weighted sum of the inputs and includes a bias.
o This computation is represented in the form of a transfer function.

o It determines weighted total is passed as an input to an activation function to produce


the output.
o Activation functions choose whether a node should fire or not.
o Only those who are fired make it to the output layer.
o There are distinctive activation functions available that can be applied upon the sort of
task we are performing.
3/16/2021 AI @ IT- by Ayana O. Kitil 115
5.3. ANN, Cont. …(7)
o If the weighted sum is equal to zero, then bias is added to make the output non-zero or
something else to scale up to the system's response.

o Bias has the same input, and weight equals to 1.

o The total of weighted inputs can be in the range of 0 to positive infinity.

o The activation function refers to the set of transfer functions used to achieve the
desired output.
o Threshold (t)– it is a point that used to determine activation or deactivation of neurons.
 Example – if > 0 → 1 and -1 otherwise.

3/16/2021 AI @ IT- by Ayana O. Kitil 116


5.3. ANN, Cont. …(8)
oA link from unit 𝒊 (external activation) to unit 𝒋 (internal units) serves to propagate the
activation 𝑎𝑖 from 𝑖 to 𝑗.
o Each link also has a numeric weight 𝑤𝑖,𝑗 associated with it, which determines the
strength and sign of the connection.
o Each unit has a dummy input 𝑎0 = 1 with an associated weight 𝑤0,𝑗.
o Each unit j first computes a weighted sum of its inputs:

Input Function

3/16/2021 AI @ IT- by Ayana O. Kitil 117


5.3. ANN, Cont. …(9)
o There are three types of activation functions.

Fig. 5.8. The three types of activation functions.

3/16/2021 AI @ IT- by Ayana O. Kitil 118


5.3. ANN, Cont. …(10)
o There are two fundamentally distinct ways to connect mathematical model of
individual neurons together to form a network.

1. A Feed-forward Network:
o It has connections only in one direction – i.e. , it forms a directed acyclic graph.
o Every node receives input from “upstream” nodes and delivers output to
“downstream” nodes.
o There are no loops.
o It
represents a function of its current input; thus, it has no internal state other than the
weights themselves.

Fig. 5.4. Feed-forward network


3/16/2021 AI @ IT- by Ayana O. Kitil 119
5.3. ANN, Cont. …(11)
• There are two types feed-forward networks.

a. Single-Layer Feed-Forward Neural Network


o It is called perceptron.
o It is a network with all the inputs connected directly to the outputs.
o It is simple model of ANN and part of supervised learning.

Fig. 5.5. A perceptron network with two inputs and two output units.
3/16/2021 AI @ IT- by Ayana O. Kitil 120
5.3. ANN, Cont. …(12)
a

Training Perceptron’s: Example – Determine the output using AND values


•Learning involves choosing and threshold value 0 (t = 0) for the following
perceptron.
values for the weights.
•The perceptron is trained as
follows:
oInitialize the inputs with
random weights (usually
between – 0.8 & 0.8).

3/16/2021 AI @ IT- by Ayana O. Kitil 121


5.3. ANN, Cont. …(13)
• Answer:

►What does -1 or 1 means?

3/16/2021 AI @ IT- by Ayana O. Kitil 122


5.3. ANN, Cont. …(14)
b. Multilayer Feed-Forward Neural Networks
o This network has one or more than two input units, hidden units, and output unit.
o Example:

Fig. 5.6. A multi-layer feed-forward neural network.


3/16/2021 AI @ IT- by Ayana O. Kitil 123
5.3. ANN, Cont. …(15)
• Given an input vector 𝑥 = (𝑥1, 𝑥2), the activations of the input units are set to (𝑎1,
𝑎2) = (𝑥1,𝑥2).
• The output at unit 5 is given by

3/16/2021 AI @ IT- by Ayana O. Kitil 124


5.3. ANN, Cont. …(16)
2. A Recurrent Network:
o It feeds its outputs back into its own inputs.
o This means that the activation levels of the network form a dynamical system that may
reach a stable state or exhibit oscillations or even chaotic behaviour.
o The response of the network to a given input depends on its initial state, which may
depend on previous inputs.
o Hence, it can support short-term memory.

Fig. 5.7. Recurrent network


3/16/2021 AI @ IT- by Ayana O. Kitil 125
Exercise:
1. What is the difference between Artificial Intelligence and Machine Learning?

2. List and explain the two types neural networks.

3. Which forms of learning feedback is mostly used? Why? Explain.

4. A 4-input neuron has weights 1, 2, 3 and 4. The activation function is linear


with the constant of proportionality being equal to 2. The inputs are 4, 10, 5 and
20 respectively.
a. Draw a neural network structure.

b. What will be the output?

3/16/2021 AI @ IT- by Ayana O. Kitil 126


ARTIFICIAL INTELLIGENCE
(AI)

CHAPTER -6-
Communicating, Perceiving and Acting in AI
6.1. Introduction
• There are two main reasons why we want our computer agents to be able to
process natural languages:
1. To communicate with humans, &
2. To acquire information from written language.

• There are over a trillion pages of information on the Web, almost all of it in
natural language.

• An agent that wants to do knowledge acquisition needs to understand (at least


partially) the ambiguous, messy languages that humans use.

3/16/2021 AI @ IT- by Ayana O. Kitil 128


6.2. Natural Language Processing (NLP)
Language Models:
• Formal languages, such as the programming languages Java or Python, have
precisely defined language models.
• A language can be defined as a set of strings.
• Example:
o “print (2 + 2)” is a legal program in the language Python, whereas “2) +(2 print” is
not.

Text Classification:
• It is also known as categorization - given a text of some kind, decide which of a
predefined set of classes it belongs to.
3/16/2021 AI @ IT- by Ayana O. Kitil 129
6.2. NLP, Cont. …(2)
• Example:
o Language identification and genre classification, as is sentiment analysis (classifying a
movie or product review as positive or negative) and spam detection (classifying an
email message as spam or not-spam).
o Since “not-spam” is awkward, researchers have coined the term ham for not-spam.
o A training set is readily available: the positive (spam) examples are in my spam folder,
the negative (ham) examples are in my inbox.

3/16/2021 AI @ IT- by Ayana O. Kitil 130


6.3. Natural Language for Communication
• Communication is the intentional exchange of information brought about by the
production and perception of signs drawn from a shared system of conventional
signs.

• Most animals use signs to represent important messages: food here, predator
nearby, approach, withdraw, let’s mate.

• In a partially observable world, communication can help agents be successful


because they can learn information that is observed or inferred by others.

• Humans are the most-chatty of all species, and if computer agents are to be
helpful, they’ll need to learn to speak the language.
3/16/2021 AI @ IT- by Ayana O. Kitil 131
6.4. Perception
• Perception provides agents with information about the world they inhabit by
interpreting the response of sensors.
• A sensor measures some aspect of the environment in a form that can be used as
input by an agent program.
o It could be as simple as a switch, or as complex as the eye.

• A variety of sensory modalities are available to artificial agents.


• Those they share with humans include vision, hearing, and touch.
• Modalities that are not available to the unaided human include radio, infrared,
GPS, and wireless signals.
• Some robots do active sensing, meaning they send out a signal, such as radar or
ultrasound, and sense the reflection of this signal off of the environment.

3/16/2021 AI @ IT- by Ayana O. Kitil 132


6.4. Perception, Cont. …(2)
• For vision, the sensor model can be broken into two components:
a. An object model describes the objects that inhabit the visual world - people, buildings, trees,
cars, etc.
 It could include a precise 3D geometric model taken from a computer-aided design (CAD) system, or it
could be vague constraints, such as the fact that human eyes are usually 5 to 7 cm apart.

b. A rendering model describes the physical, geometric, and statistical processes that produce
the stimulus from the world.
 It is quite accurate, but they are ambiguous.

o Example:
 A white object under low light may appear as the same colour as a black object under intense light.
 A small nearby object may look the same as a large distant object.
 Without additional evidence, we cannot tell if the image that fills the frame is a toy Godzilla or a real
monster.
3/16/2021 AI @ IT- by Ayana O. Kitil 133
6.5. Robotics
• Robots are physical agents that perform tasks by manipulating the physical world.

• To do so, they are equipped with effectors such as legs, wheels, joints, and grippers.

• Effectors have a single purpose:


o To assert physical forces on the environment.

• Robots are also equipped with sensors, which allow them to perceive their environment.

• Present day robotics employs a diverse set of sensors, including cameras and lasers to
measure the environment, and gyroscopes and accelerometers to measure the robot’s own
motion.

• Most of today’s robots fall into one of THREE primary categories.


3/16/2021 AI @ IT- by Ayana O. Kitil 134
6.5. Robotics, Cont. …(2)
a. Manipulators, or Robot Arms:
o It is physically anchored to their workplace.

o Example:

 In a factory assembly line or on the International Space Station.

o Manipulator motion usually involves a chain of controllable joints, enabling such


robots to place their effectors in any position within the workplace.

o The most common type of industrial robots.

o Some mobile manipulators are used in hospitals to assist surgeons.

3/16/2021 AI @ IT- by Ayana O. Kitil 135


6.5. Robotics, Cont. …(3)
a. Manipulators, or Robot Arms, …(2)

Fig. 6.1. An industrial robotic manipulator for stacking bags on a pallet.

3/16/2021 AI @ IT- by Ayana O. Kitil 136


6.5. Robotics, Cont. …(4)
b. Mobile Robots:
o It moves about their environment using wheels, legs, or similar mechanisms.
o They have been put to use delivering food in hospitals, moving containers at loading
docks, and similar tasks.
o Example:

 Unmanned Ground Vehicles (UGVs), drive autonomously on streets, highways, and off-
road.
 Unmanned Air Vehicles (UAVs), commonly used for surveillance, crop-spraying, and
military operations.
 Autonomous Underwater Vehicles (AUVs) are used in deep sea exploration.
o It delivers packages in the workplace and vacuum the floors at home.
3/16/2021 AI @ IT- by Ayana O. Kitil 137
6.5. Robotics, Cont. …(5)
b. Mobile Robots, …(2)

Fig. 6.2 (a) Predator, an unmanned aerial vehicle (UAV) used by the U.S. Military. Image courtesy of General Atomics
Aeronautical Systems. (b) NASA’s Sojourner, a mobile robot that explored the surface of Mars in July 1997.
3/16/2021 AI @ IT- by Ayana O. Kitil 138
6.5. Robotics, Cont. …(6)
c. Mobile Manipulators:
o It is a combination of mobile robots and manipulator.

o It is often called a Humanoid robot mimic the human torso.

o It can apply their effectors further a field than anchored manipulators can, but their task
is made harder because they don’t have the rigidity that the anchor provides.

3/16/2021 AI @ IT- by Ayana O. Kitil 139


6.5. Robotics, Cont. …(7)
c. Mobile Manipulators, …(2)

Fig. 6.3. Honda’s P3 and Asimo humanoid robots.

3/16/2021 AI @ IT- by Ayana O. Kitil 140


6.5. Robotics, Cont. …(8)
• The field of robotics also includes:
o Prosthetic Devices (artificial limbs, ears, and eyes for humans);
o Intelligent Environments (such as an entire house that is equipped with sensors and
effectors); and
o Multi-body Systems, wherein robotic action is achieved through swarms of small
cooperating robots.

• Real robots must cope with environments that are partially observable, stochastic,
dynamic, continuous, sequential and multi-agent.

• Partial observability and stochasticity are the result of dealing with a large,
complex world.
3/16/2021 AI @ IT- by Ayana O. Kitil 141
6.5. Robotics, Cont. …(9)
• Robot cameras cannot see around corners, and motion commands are subject to
uncertainty due to gears slipping, friction, etc.

• In a simulated environment, it is possible to use simple algorithms to learn in a


few CPU hours from millions of trials, while in a real environment, it might take
years to run these trials.

• Furthermore, real crashes really hurt, unlike simulated ones.

• Practical robotic systems need to embody prior knowledge about the robot, its
physical environment, and the tasks that the robot will perform so that the robot
can learn quickly and perform safely.
3/16/2021 AI @ IT- by Ayana O. Kitil 142
6.5. Robotics, Cont. …(10)
Robot Hardware:
o The agent architecture - sensors, effectors, and processors.
a. Sensors – is the perceptual interface between robot and environment.
 There types of sensors: Range Finder Sensors, Locations Sensors and Proprioceptive Sensors.

b. Effectors – the means by which robots move and change the shape of their bodies.
 To understand the design of effectors, it will help to talk about motion and shape in the abstract, using
the concept of a degree of freedom (DOF).

c. Processors – robots uses a microprocessor.

o The success of real robots depends at least as much on the design of sensors and
effectors that are appropriate for the task.
3/16/2021 AI @ IT- by Ayana O. Kitil 143
Exercise:
1. Define communication, natural language and robotics with your own words!

2. Differentiate the three types of robotics.

3. List the application areas of Robotics.

3/16/2021 AI @ IT- by Ayana O. Kitil 144

You might also like