0% found this document useful (0 votes)
256 views170 pages

Ai 1

The document provides an introduction to artificial intelligence (AI), including definitions, applications, and techniques. It defines AI as the intelligence exhibited by machines or software, and the field of study that develops intelligent computer behavior. Four categories of AI definitions are outlined: thinking humanly, thinking rationally, acting humanly, and acting rationally. The document also discusses the Turing Test for machine intelligence and chatbots that have attempted it, as well as the Chinese Room argument against the validity of the Turing Test. Traditional AI techniques like rule-based systems, expert systems, search algorithms, and knowledge representation are explained.

Uploaded by

Devanathan .S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
256 views170 pages

Ai 1

The document provides an introduction to artificial intelligence (AI), including definitions, applications, and techniques. It defines AI as the intelligence exhibited by machines or software, and the field of study that develops intelligent computer behavior. Four categories of AI definitions are outlined: thinking humanly, thinking rationally, acting humanly, and acting rationally. The document also discusses the Turing Test for machine intelligence and chatbots that have attempted it, as well as the Chinese Room argument against the validity of the Turing Test. Traditional AI techniques like rule-based systems, expert systems, search algorithms, and knowledge representation are explained.

Uploaded by

Devanathan .S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 170

IFETCE Regulation 2019A Academic Year: 2023-2024

IFET COLLEGE OF ENGINEERING


(An Autonomous Institution)
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
AND
DEPARTMENT OF INFORMATION TECHNOLOGY
SUBJECT TITLE: Foundations of AI UNIT: I
SUBJECT CODE: 19UCSPEX01 YEAR/SEM: III/VI

Unit-1 Introduction
Introduction - Definition - Future of Artificial Intelligence - Characteristics of
Intelligent Agents–Typical Intelligent Agents -AI Applications - Problem Solving
Approach to Typical AI problems.

1. Introduction
Artificial intelligence (AI) is the intelligence exhibited by machines or software. It
is also the name of the academic field of study which studies how to create computers
and computer software that are capable of intelligent behavior.

1.1 Definitions of artificial intelligence, organized into four categories.


Table 1: Definition of AI
Thinking Humanly - The cognitive Thinking Rationally - The “laws of
modeling approach thought” approach
• “The exciting new effort to make • “The study of mental faculties
computers think . . . machines through the use of computational
with minds, in the full and literal models.” (Charniak and McDermott,
sense.” (Haugeland, 1985) 1985)
• “[The automation of] activities • “The study of the computations that
that we associate with human make it possible to perceive, reason,
thinking, activities such as and act.” (Winston, 1992)
decision-making, problem
solving, learning . . .” (Bellman,
1978)
Acting Humanly - The Turing Test Acting Rationally - The rational
approach agent approach
• “The art of creating machines that • “Computational Intelligence is the
perform functions that require study of the design of intelligent
intelligence when performed by agents.” (Poole et al., 1998)
people.” (Kurzweil, 1990) • “AI . . . is concerned with intelligent
• “The study of how to make behavior in artifacts.” (Nilsson,
computers do things at which, at 1998)
the moment, people are better.”
(Rich and Knight, 1991)

1.1.1 Turing Test


• In 1950, Alan Turing introduced a test to check whether a machine can think like a
human or not, this test is known as the Turing Test. In this test, Turing proposed

1
IFETCE Regulation 2019A Academic Year: 2023-2024

that the computer can be said to be an intelligent if it can mimic human response
under specific conditions.
• Turing Test was introduced by Turing in his 1950 paper, "Computing Machinery
and Intelligence," which considered the question, "Can Machine think?".
• The Turing test is based on a party game "Imitation game," with some
modifications. This game involves three players in which one player is Computer,
another player is human responder, and the third player is a human Interrogator,
who is isolated from other two players and his job is to find that which player is
machine among two of them.
• Consider, Player A is a computer, Player B is human, and Player C is an
interrogator. Interrogator is aware that one of them is machine, but he needs to
identify this on the basis of questions and their responses.

Figure 1.1: Turing Test


• The conversation between all players is via keyboard and screen so the result
would not depend on the machine's ability to convert words as speech.
• The test result does not depend on each correct answer, but only how closely its
responses like a human answer. The computer is permitted to do everything
possible to force a wrong identification by the interrogator.
The questions and answers can be like:
• Interrogator: Are you a computer?
• Player A (Computer): No
• Interrogator: Multiply two large numbers such as (256896489*456725896)
• Player A: Long pause and give the wrong answer.
• In this game, if an interrogator would not be able to identify which is a machine
and which is human, then the computer passes the test successfully, and the
machine is said to be intelligent and can think like a human.
• "In 1991, the New York businessman Hugh Loebner announces the prize
competition, offering a $100,000 prize for the first computer to pass the Turing
test. However, no AI program to till date, come close to passing an undiluted
Turing test".

a. Chatbots to attempt the Turing test:


• ELIZA: ELIZA was a Natural language processing computer program created by
Joseph Weizenbaum. It was created to demonstrate the ability of communication

2
IFETCE Regulation 2019A Academic Year: 2023-2024

between machine and humans. It was one of the first chatterbots, which has
attempted the Turing Test.
• Parry: Parry was a chatterbot created by Kenneth Colby in 1972. Parry was
designed to simulate a person with Paranoid schizophrenia (most common chronic
mental disorder). Parry was described as "ELIZA with attitude." Parry was tested
using a variation of the Turing Test in the early 1970s.
• Eugene Goostman: Eugene Goostman was a chatbot developed in Saint
Petersburg in 2001. This bot has competed in the various number of Turing Test.
In June 2012, at an event, Goostman won the competition promoted as largest-ever
Turing test content, in which it has convinced 29% of judges that it was a
human.Goostman resembled as a 13-year old virtual boy.

b. The Chinese Room Argument:


• There were many philosophers who really disagreed with the complete concept of
Artificial Intelligence. The most famous argument in this list was "Chinese
Room."
• In the year 1980, John Searle presented "Chinese Room" thought experiment, in
his paper "Mind, Brains, and Program," which was against the validity of Turing's
Test. According to his argument, "Programming a computer may make it to
understand a language, but it will not produce a real understanding of language or
consciousness in a computer."
• He argued that Machine such as ELIZA and Parry could easily pass the Turing test
by manipulating keywords and symbol, but they had no real understanding of
language. So it cannot be described as "thinking" capability of a machine such as a
human.

Features required for a machine to pass the Turing test:

• Natural language processing: NLP is required to communicate with


Interrogator in general human language like English.
• Knowledge representation: To store and retrieve information during the test.
• Automated reasoning: To use the previously stored information for answering
the questions.
• Machine learning: To adapt new changes and can detect generalized patterns.
• Vision (For total Turing test): To recognize the interrogator actions and other
objects during a test.
• Motor Control (For total Turing test): To act upon objects if requested.

1.1.2 Techniques of AI

Traditional Techniques of AI

Traditional techniques of AI, also known as classical or symbolic AI, were prominent
before the rise of machine learning and neural networks. These methods rely on
explicit programming and knowledge representation. While they are still used in

3
IFETCE Regulation 2019A Academic Year: 2023-2024

certain applications, they are often contrasted with the more data-driven approaches of
modern AI. Some traditional AI techniques include:

Rule-Based Systems:

Systems that use a set of explicitly defined rules to make decisions or perform tasks.
These rules are typically represented as "if-then" statements.

Expert Systems:

Computer programs designed to mimic the decision-making abilities of a human


expert in a specific domain. They use a knowledge base and inference engine to draw
conclusions and solve problems.

Search Algorithms:

Techniques like depth-first search, breadth-first search, and A* search are used to
explore possible solutions in problem-solving tasks, such as game playing and route
planning.

Knowledge Representation and Ontologies:

Symbolic representation of knowledge using languages like Semantic Web languages


(e.g., RDF, OWL). Ontologies define relationships between concepts to facilitate
reasoning and inferencing.

Planning and Scheduling:

Algorithms that generate plans to achieve specific goals, considering constraints and
resource limitations. Used in areas like robotics and project management.

Frame-Based Systems:

Knowledge representation technique where information is organized into structures


called frames, consisting of attributes and values. Frames help represent complex
relationships and dependencies.

Inference Engines:

Software components that draw logical conclusions from a set of rules or facts.
Inference engines are often used in expert systems to make decisions based on the
provided knowledge.

Symbolic Reasoning:

The manipulation of symbols and logical reasoning to derive new information from
existing knowledge. It involves techniques like propositional and first-order logic.

4
IFETCE Regulation 2019A Academic Year: 2023-2024

Planning and Decision Trees:

Decision trees are structures that represent decisions and their possible consequences.
In planning, decision trees are used to model decision-making processes.

Natural Language Processing (NLP):

While NLP has evolved with machine learning, traditional AI techniques were used
for early attempts at language understanding and generation, including rule-based
approaches and syntactic parsing.

Modern techniques of AI

Modern AI techniques encompass a wide range of approaches, with a strong emphasis


on machine learning and deep learning. Here are some key modern techniques and
trends in artificial intelligence:

Machine Learning (ML):

Supervised Learning: Uses labeled training data to train models to make predictions or
classifications.

Unsupervised Learning: Extracts patterns and relationships from unlabeled data


without predefined outcomes.

Reinforcement Learning: Involves agents learning from interaction with an


environment, receiving rewards for correct actions and penalties for incorrect ones.

Deep Learning:

A subset of machine learning that uses artificial neural networks with multiple layers
(deep neural networks) to model and solve complex problems. Deep learning has
excelled in image recognition, natural language processing, and more.

Neural Networks:

Deep neural networks, including Convolutional Neural Networks (CNNs), Recurrent


Neural Networks (RNNs), and Transformer models like BERT, GPT, and others, have
shown remarkable success in various tasks such as image recognition, language
understanding, and generation.

Transfer Learning:

Leveraging pre-trained models on large datasets and fine-tuning them for specific
tasks. This approach has been instrumental in achieving state-of-the-art performance
in various domains.

5
IFETCE Regulation 2019A Academic Year: 2023-2024

Generative Adversarial Networks (GANs):

GANs consist of two neural networks, a generator, and a discriminator, trained


adversarially to generate realistic data. They have been used for image synthesis, style
transfer, and creating realistic content.

Natural Language Processing (NLP):

Modern NLP techniques involve pre-trained language models like BERT


(Bidirectional Encoder Representations from Transformers) and GPT (Generative Pre-
trained Transformer), enabling machines to understand and generate human-like text.

Reinforcement Learning Advances:

Techniques like deep reinforcement learning have enabled machines to master


complex tasks, such as playing games (e.g., AlphaGo, Dota 2) and robotic control.

Explainable AI (XAI):

Addressing the interpretability and transparency of AI models. XAI techniques aim to


make machine learning models more understandable and explainable to humans,
improving trust and accountability.

AutoML (Automated Machine Learning):

Tools and techniques that automate the process of model selection, hyperparameter
tuning, and feature engineering, making machine learning more accessible to non-
experts.

Edge AI:

Bringing AI capabilities to edge devices (e.g., smartphones, IoT devices) to process


data locally and reduce reliance on cloud computing, improving efficiency and
privacy.

1.2 FUTURE OF ARTIFICIAL INTELLIGENCE

The future of artificial intelligence (AI) holds tremendous potential and is likely
to shape various aspects of our lives. Here are some key trends and considerations for
the future of AI:

Advanced Machine Learning Techniques:


Continued advancements in machine learning algorithms, such as deep learning,
reinforcement learning, and transfer learning, will enable AI systems to become more
sophisticated in understanding and processing data.

AI in Healthcare:

6
IFETCE Regulation 2019A Academic Year: 2023-2024

AI is expected to play a significant role in revolutionizing healthcare. This


includes applications in diagnostics, drug discovery, personalized medicine, and
health monitoring.

Autonomous Vehicles:
The development and deployment of self-driving cars and other autonomous
vehicles are anticipated to increase, potentially transforming the transportation
industry. AI algorithms will play a crucial role in navigation, decision-making, and
safety.

Natural Language Processing (NLP):


Improvements in natural language processing will lead to more advanced
conversational AI systems, virtual assistants, and language translation tools. This will
enhance human-computer interactions and facilitate communication across language
barriers.

AI Ethics and Bias Mitigation:


As AI systems become more prevalent, there is a growing emphasis on addressing
ethical concerns and biases. Efforts to ensure fairness, transparency, and
accountability in AI algorithms will likely become more widespread.

AI in Cybersecurity:
AI will be increasingly used to detect and prevent cyber threats. Machine learning
algorithms can analyze vast amounts of data to identify patterns and anomalies,
enhancing the capabilities of cybersecurity systems.

Edge AI:
Edge computing, where AI processing occurs on local devices rather than in
centralized cloud servers, is gaining prominence. This approach reduces latency and
enhances privacy, making it suitable for applications like IoT devices and real-time
analytics.

AI and Creativity:
AI will continue to be integrated into creative fields such as art, music, and
literature. AI-generated content, collaborative efforts between humans and AI, and AI
tools to assist creatives will likely become more common.

AI in Education:
Personalized learning experiences, intelligent tutoring systems, and adaptive
educational platforms powered by AI will likely become more prevalent, catering to
individual student needs.

Ethical and Regulatory Frameworks:


As AI technologies advance, there will be an increased focus on establishing
ethical guidelines and regulatory frameworks to ensure responsible development and
use of AI. This includes addressing issues such as privacy, bias, and accountability.

7
IFETCE Regulation 2019A Academic Year: 2023-2024

Robotic vehicles:
• A driverless robotic car named STANLEY sped through the rough terrain of the
Mojave Desert at 22 mph, finishing the 132-mile course first to win the 2005
DARPA Grand Challenge.
• STANLEY is a Volkswagen Toured outfitted with cameras, radar, and laser
rangefinders to sense the environment and onboard software to command the
steering, braking, and acceleration
• The following year CMU’s B OSS won the Urban Challenge, safely driving in
traffic through the streets of a closed Air Force base, obeying traffic rules and
avoiding pedestrians and other vehicles.

Speech recognition:
A traveler calling United Airlines to book a flight can have the entire
conversation guided by an automated speech recognition and dialog management
system.

Autonomous planning and scheduling:


• A hundred million miles from Earth, NASA’s Remote Agent program became the
first on-board autonomous planning program to control the scheduling of
predations for a spacecraft.
• REMOTE AGENT generated plans from high-level goals specified from the
ground and monitored the execution of those plans—detecting, diagnosing, and
recovering from problems as they occurred.
• Successor program MAPGEN plans the daily operations for NASA’s Mars
Exploration Rovers, and MEXAR2 did mission planning—both logistics and
science planning—for the European Space Agency’s Mars Express mission in
2008.

Game playing:
• IBM’s D EEP B LUE became the first computer program to defeat the world
champion in a chess match when it bested Garry Kasparov by a score of 3.5 to 2.5
in an exhibition.
• Kasparov said that he felt a “new kind of intelligence” across the board from him.
Newsweek magazine described the match as “The brain’s last stand.”
• The value of IBM’s stock increased by $18 billion. Human champions studied
Kasparov’s loss and were able to draw a few matches in subsequent years, but the
most recent human-computer matches have been won convincingly by the
computer.

Spam fighting:
• Learning algorithms classify over a billion messages as spam, saving the recipient
from having to waste time deleting what, for many users, could comprise 80% or
90% of all messages, if not classified away by algorithms.
• The spammers are continually updating their tactics, it is difficult for a static

8
IFETCE Regulation 2019A Academic Year: 2023-2024

programmed approach to keep up, and learning algorithms work.

Logistics planning:
• During the Persian Gulf crisis of 1991, U.S. forces deployed a Dynamic Analysis
and Replanning Tool, DART, to do automated logistics planning and scheduling
for transportation. This involved up to 50,000 vehicles, cargo, and people at a time,
and had to account for starting points, destinations, routes, and conflict resolution
among all parameters.
• The AI planning techniques generated in hours a plan that would have taken weeks
with older methods. The Defense Advanced Research Project Agency (DARPA)
stated that this single application more than aid back DARPA’s 30-year investment
in AI.

Robotics:
• The iRobot Corporation has sold over two million Roomba robotic vacuum
cleaners for home use.
• The company also deploys the more rugged PackBot to Iraq and Afghanistan,
where it is used to handle hazardous materials, clear explosives, and identify the
location of snipers.

Machine Translation:
• A computer program automatically translates from Arabic to English, allowing an
English speaker to see the headline “Ardogan Confirms That Turkey Would Not
Accept Any Pressure, Urging Them to Recognize Cyprus.”
• The program uses a statistical model built from examples of Arabic-to-English
translations and from examples of English text totaling two trillion words .
• None of the computer scientists on the team speak Arabic, but they do understand
statistics and machine learning algorithms

1.3 Agent

➢ An agent is anything that can be viewed as perceiving its environment through


sensors and acting upon that environment through actuators (figure 1.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. A software agent
receives keystrokes, file contents, and network packets as sensory inputs and acts
on the environment by displaying on the screen, writing files, and sending
network packets.
➢ Percept - To refer to the agent’s perceptual inputs at any given instant.
➢ Percept sequence - An agent’s percept sequence is the complete history of
everything the agent has ever perceived.
➢ Agent function - An agent’s behavior is described by the agent function that
maps any given percept sequence to an action.

9
IFETCE Regulation 2019A Academic Year: 2023-2024

Figure 1.2: Agents interact with environments through sensors and


actuators.
➢ Agent program - the agent function for an artificial agent will be implemented
by an agent program.

Figure 1.3: A vacuum-cleaner world with just two locations.

Table 1: Partial tabulation of a simple agent function for the vacuum-cleaner


world

Percept sequence Action


[A, Clean] Right
[A, Dirty] Suck
[B, Clean] Left
[B, Dirty] Suck
[A, Clean], [A, Clean] Right
[A, Clean], [A, Dirty] Suck
... ...
[A, Clean], [A, Clean], [A, Right
Clean] Suck
[A, Clean], [A, Clean], [A, Dirty]
... ..

1.3.1 CONCEPT OF RATIONALITY


An agent should act as a Rational Agent. A rational agent is one that does the
right thing that is the right actions will cause the agent to be most successful in the

10
IFETCE Regulation 2019A Academic Year: 2023-2024

environment.

Performance measures
A performance measures embodies the criterion for success of an agent‘s
behavior. As a general rule, it is better to design performance measures according to
what one actually wants in the environment, rather than according to how one thinks
the agent should behave.

Rationality
Rationality depends on four things:
➢ The performance measure that defines the criterion of success.
➢ The agent‘s prior knowledge of the environment.
➢ The actions that the agent can perform.
➢ The agent‘s percept sequence to date.

This leads to a definition of a rational agent (ideal rational agent). “For each
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, that is the task of rational
agent is to improve the performance measure depends on percept sequence”. Let us
assume the following:

• The performance measure awards one point for each clean square at each time step,
over a “lifetime” of 1000 time steps.
• The “geography” of the environment is known a priori but the dirt distribution and
the initial location of the agent are not. Clean squares stay clean and sucking cleans
the current square. The Left and Right actions move the agent left and right except
when this would take the agent outside the environment, in which case the agent
remains where it is.
• The only available actions are Left, Right, and Suck.
• The agent correctly perceives its location and whether that location contains dirt.
Under these circumstances the agent is indeed rational; its expected performance is at
least as high as any other agent’s.

Omniscience, learning, and autonomy


• An omniscient agent knows the actual outcome of its actions and can act
accordingly; but omniscience is impossible in reality.
• A rational agent not only to gather information, but also to learn as much as
possible from what it perceives. The agent‘s initial configuration could reflect
some prior knowledge of the environment, but as the agent gains experience this
may be modified and augmented. Successful agents split the task of computing the
agent function into three different periods:
➢ When the agent is being designed, some of the computation is done by its
designers;
➢ When it is deliberating on its next action, the agent does more computation; and
➢ As it learns from experience, it does even more computation to decide how to

11
IFETCE Regulation 2019A Academic Year: 2023-2024

modify its behavior. A rational agent should be autonomous – it should learn what
it can to compensate for partial or incorrect prior knowledge. Concrete
implementation, running on the agent architecture.

1.3.2 NATURE OF ENVIRONMENTS

Specifying the task environment


A task environment specification includes the performance measure, the
external environment, the actuators, and the sensors. In designing an agent, the first
step must always be to specify the task environment as fully as possible. Task
environments are specified as a PAGE (Percept, Action, Goal, Environment) (or)
PEAS (Performance, Environment, Actuators, Sensors) description, both means the
same. The following table describes some of the agent types and the basic PEAS
description.

Table 2: Examples of agent types and their PEAS descriptions


Agent Performance Environment Actuators Sensors
Type Measure
Taxi Safe, fast, Roads, other Steering, Cameras,
driver legal, traffic, accelerator, sonar,
comfortable pedestrians, brake, signal, speedometer,
trip, customers horn, display GPS,
maximize odometer,
profits accelerometer,
engine sensors,
keyboard

Some Software Agents (or) Software Robots (or) Soft bots exist in rich, unlimited
domains. So,
➢ Actions are done in real time.
➢ Action is performed in the complex environment.
➢ It is designed to scan online news sources and shows the actions with natural
language processing.

Properties of task environments


➢ The range of task environments that might arise in AI is obviously vast.
➢ List the dimensions, and then we analyze several task environments to illustrate
the ideas.

Table 3: Examples of agent types and their PEAS descriptions


Agent Type Performance Environment Actuators Sensors
Measure
Medical Healthy Patient, Display of Keyboard
diagnosis patient, hospital, questions, entry
system reduced costs staff tests, of symptoms,
diagnoses, findings,

12
IFETCE Regulation 2019A Academic Year: 2023-2024

treatments, patient’s
referrals answers
Satellite Correct image Downlink Display of Color pixel
image categorization from scene arrays
analysis orbiting categorization
system satellite
Part-picking Percentage of Conveyor belt Jointed arm Camera, joint
robot parts in correct with parts; and angle sensors
bins bins hand
Refinery Purity, yield, Refinery, Valves, Temperature,
controller safety operators pumps, pressure,
heaters, chemical
displays sensors
Interactive Student’s score Set of students, Display of Keyboard
English tutor on test testing agency exercises, entry
suggestions,
corrections

1. Accessible vs. inaccessible (or) fully observable vs. partially observable


➢ If an agent‘s sensors give it access to the complete state of the environment at
each point in time, then we say that the task environment is fully observable.
Fully observable environments are convenient because the agent need not
maintain any internal state to keep track of the world.
➢ An environment might be partially observable because of noisy and inaccurate
sensors or because parts of the state are simply missing from the sensor data.
2. Deterministic vs. non-deterministic (or) stochastic
• If the next state of the environment is completely determined by the current state
and the action executed by the agent, then the environment is deterministic;
otherwise, it is stochastic.
• An agent need not worry about uncertainty in a fully observable, deterministic
environment. If the environment is partially observable, however, then it could
appear to be stochastic.
3. Episodic vs. non-episodic (or) sequential
• In an episodic environment, the agent‘s experience is divided into atomic episodes.
Each episode consists of its own percepts and actions and it does not depend on the
previous episode.
• In sequential environments, the current decision could affect all future of
decisions. Eg. Chess and taxi driving.
• Episodic environments are much simpler than sequential environments because the
agent does not need to think ahead.
4. Static vs. dynamic
• If the environment is changing for agent‘s action then the environment is dynamic
for that agent otherwise it is static.
• If the environment does not change for some time, then it changes due to agent‘s
performance is called semi dynamic environment.
E.g. Taxi driving is dynamic, Chess is semi dynamic, Crossword puzzles are static.
13
IFETCE Regulation 2019A Academic Year: 2023-2024

5. Discrete vs. continuous


➢ If the environment has limited number of distinct, clearly defined percepts and
actions then the environment is discrete. E.g. Chess
➢ If the environment changes continuously with range of value the environment is
continuous. E.g. Taxi driving.

Table 4: Examples of task environments and their characteristics.


Task Observable Agents Deterministic Deterministic Static Discrete
Environment
Crossword Fully Single Deterministic Sequential Static Discrete
puzzle

Chess with a Fully Multi Deterministic Sequential Semi Discrete


clock
Poker Partially Multi Stochastic Sequential Static Discrete

Backgammon Fully Multi Stochastic Sequential Static Discrete


Taxi driving Partially Multi Stochastic Sequential Dynamic Continuous

Medical Partially Single Stochastic Sequential Dynamic Continuous


diagnosis
Image Fully Single Deterministic Episodic Semi Continuous
analysis

Part-picking Partially Single Stochastic Episodic Dynamic Continuous


robot
Refinery Single Stochastic Sequential Dynamic Continuous Interactive
controller
Partially
Partially Multi Stochastic Sequential Dynamic Discrete
English tutor

An agent, whether AI or non-AI, refers to a system or entity that perceives its


environment, makes decisions, and takes actions to achieve specific goals. The key
difference between an agent of AI (Artificial Intelligence) and a non-AI program lies
in the level of autonomy, adaptability, and learning capabilities.

Agent of AI:
• Autonomy: AI agents have a higher degree of autonomy. They can operate and
make decisions without constant human intervention.
• Learning: AI agents often have learning capabilities, allowing them to improve
their performance over time through experience and data analysis.
• Adaptability: AI agents can adapt to changes in their environment or tasks.
They can adjust their behavior based on new information or evolving
circumstances.
• Complex Decision-Making: AI agents can handle complex decision-making
processes, leveraging algorithms, and machine learning techniques to analyze
vast amounts of data.
14
IFETCE Regulation 2019A Academic Year: 2023-2024

• Examples: Self-driving cars, virtual personal assistants (like Siri or Alexa), and
game-playing AI (like AlphaGo) are examples of AI agents.
Non-AI Program:
• Limited Autonomy: Non-AI programs typically have limited autonomy and
often require explicit instructions for each step of their operation.
• No Learning Capability: Non-AI programs do not have inherent learning
capabilities. They execute predefined instructions without adapting based on
experience or new information.
• Static Behavior: The behavior of non-AI programs is static and does not change
unless explicitly modified through programming.
• Simpler Decision-Making: Non-AI programs generally handle simpler and
more rule-based decision-making processes.
• Examples: Traditional software applications, such as word processors,
spreadsheet programs, and simple calculators, are examples of non-AI
programs.
1.3.3 Characteristics of Intelligent Agents
The agent receives some form of sensory input from its environment, and it performs
some action that changes its environment in some way. Examples of environments:
the physical world and the Internet. Intelligent agents, whether they are part of AI
systems or other computational entities, exhibit several key characteristics that
contribute to their ability to interact with their environment and achieve goals. Here
are some essential characteristics of intelligent agents:
• Autonomy: Intelligent agents have a degree of autonomy, allowing them to
operate and make decisions independently without constant human
intervention. They can execute tasks and take actions based on their own
internal processes and knowledge.
• Sensing: Intelligent agents are equipped with sensors to perceive and gather
information from their environment. These sensors provide input data that the
agent can use to make informed decisions and take appropriate actions.
• Actuation/Action: Intelligent agents have the ability to perform actions or
actuate changes in their environment. This may include physical actions, such
as movement in the case of a robot, or virtual actions, such as sending
messages or generating responses in a software application.
• Goal-Directed Behavior: Intelligent agents are designed to achieve specific
goals or objectives. They operate with a purpose and make decisions that are
aligned with those goals. Goal-directed behavior helps agents prioritize actions
to maximize their chances of success.
• Learning: Many intelligent agents are capable of learning from experience.
This involves adapting their behavior over time based on feedback, data, or
interactions with the environment. Learning allows agents to improve
performance and make better decisions in similar situations in the future.
• Adaptability: Intelligent agents can adapt to changes in their environment or
task requirements. They can adjust their strategies, behaviors, or decision-
making processes to cope with new information, uncertainties, or evolving
conditions.

15
IFETCE Regulation 2019A Academic Year: 2023-2024

• Communication: Intelligent agents often have the ability to communicate with


other agents or entities. Communication can involve sharing information,
coordinating actions, or collaborating to achieve common goals. This is
particularly important in multi-agent systems.
• Decision-Making: Intelligent agents are equipped with mechanisms for making
decisions. This can range from simple rule-based decision-making to more
complex processes involving algorithms, heuristics, or machine learning
techniques.
• Reactivity: Intelligent agents can react to immediate changes or stimuli in their
environment. They can respond in real-time to new information or events,
making them dynamic and capable of handling dynamic situations.
• Proactiveness: Intelligent agents can exhibit proactive behavior by taking
initiative to achieve goals without waiting for external stimuli. Proactiveness
allows agents to plan and execute actions to anticipate and address future
events.
1.4 Typical Intelligent Agents
An intelligent agent is a combination of Agent Program and Architecture.
Intelligent Agent = Agent Program + Architecture
Agent Program is a function that implements the agent mapping from percepts to
actions. There exists a variety of basic agent program designs, reflecting the kind of
information made explicit and used in the decision process. The designs vary in
efficiency, compactness, and flexibility. The appropriate design of the agent program
depends on the nature of the environment.

Architecture is a computing device used to run the agent program.

function TABLE -DRIVEN -AGENT ( percept ) returns an action


persistent: percepts, a sequence, initially empty
table, a table of actions, indexed by percept sequences, initially fully specified
append percept to the end of percepts
action ← L OOKUP ( percepts, table)
return action
The TABLE -DRIVEN -AGENT program is invoked for each new percept and
returns an action each time. It retains the complete percept sequence in
memory

To perform the mapping task four types of agent programs are there. They are:

1. Simple reflex agents


2. Model-based reflex agents
3. Goal-based agents
4. Utility-based agents

1.Simple reflex agents


The simplest kind of agent is the simple reflex agent. It responds directly to
percepts i.e. these agent select actions on the basis of the current percept, ignoring the

16
IFETCE Regulation 2019A Academic Year: 2023-2024

rest of the percept history. An agent describes about how the condition-action rules
allow the agent to make the connection from percept to action.

Figure 1.4: Schematic diagram of a simple reflex agent

Condition-action rule: if condition then action


Rectangle : to denote the current internal state of the agents decision process.
Oval : to represent the background information in the process.

The agent program, which is also very simple, is shown in the following figure 1.4.
function SIMPLE-REFLEX-AGENT (percept) returns an action
static: rules, a set of condition-action rules
state ← INTERPRET – INPUT(percept)
rule ← RULE – MATCH(state, rules)
action ← RULE – ACTION[rule]
return action.

INTERRUPT-INPUT – function generates an abstracted description of the current


state from the percept.
RULE-MATCH – function returns the first rule in the set of rules that matches the
given state description.
RULE-ACTION – the selected rule is executed as action of the given percept.
The agent in figure will work only ―if the correct decision can be made on the basis
of only the current percept – that is, only if the environment is fully observable‖.
Example: Medical diagnosis system- If the patient has reddish brown spots then starts
the treatment for measles.

2. Model-based reflex agents (Agents that keep track of the world)


The most effective way to handle partial observability is for the agent ―to
keep track of the part of the world it can’t see now.
That is, the agent which combines the current percept with the old internal state
to generate updated description of the current state. The current percept is combined
with the old internal state and it derives a new current state is updated in the state
description is also.
This updating requires two kinds of knowledge in the agent program. First, we
need some information about how the world evolves independently of the agent.

17
IFETCE Regulation 2019A Academic Year: 2023-2024

Second, we need some information about how the agents own actions affect the
world.
The above two knowledge implemented in simple Boolean circuits or in
complete scientific theories is called a model of the world. An agent that uses such a
model is called a model- based agent.
function REFLEX-AGENT-WITH-STATE (percept) returns an action
static: state, a description of the current world state
rules, a set of condition-action rules
action, the most recent action, initially none
state ← UPDATE-STATE(state, action, percept)
rule ← RULE-MATCH(state, rules)
action ← RULE-ACTION[rule]
return action

A model-based reflex agent. It keeps track of the current state of the world using an
internal model. It then chooses an action in the same way as the reflex agent.
UPDATE-STATE – This is responsible for creating the new internal state description
by combining percept and current state description.

Figure 1.5: A model-based reflex agent.


The above figure shows the structure of the reflex agent with internal state, showing
how the current percept id combined with the old internal state to generate the updated
description of the current state.

3. Goal-based agents
An agent knows the description of current state and also needs some sort of
goal information that describes situations that are desirable. The action matches with
the current state is selected depends on the goal state. The goal based agent is more
flexible for more than one destination also. After identifying one destination, the new
destination is specified, goal based agent is activated to come up with a new behavior.
Search and Planning are the subfields of AI devoted to finding action sequences that
achieve the agents goals. The goal-based agent appears less efficient, it is more
flexible because the knowledge that supports its decisions is represented explicitly and
18
IFETCE Regulation 2019A Academic Year: 2023-2024

can be modified. The goal-based agent‘s behavior can easily be changed to go to a


different location.

4. Utility-based agents (Utility – refers to ― the quality of being useful‖)


An agent generates a goal state with high – quality behavior (utility) that is, if
more than one sequence exists to reach the goal state then the sequence with more
reliable, safer, quicker and cheaper than others to be selected. A utility function maps
a state (or sequence of states) onto a real number, which describes the associated
degree of happiness. The utility function can be used for two different cases: First,
when there are conflicting goals, only some of which can be achieved (for e.g., speed
and safety), the utility function specifies the appropriate tradeoff. Second, when the
agent aims for several goals, none of which can be achieved with certainty, then the
success can be weighted up against the importance of the goals.

5. Learning agents
• The learning task allows the agent to operate in initially unknown environments
and to become more competent than its initial knowledge.
• A learning agent can be divided into four conceptual components, .
• Learning element – This is responsible for making improvements. It uses the
feedback from the critic on how the agent is doing and determines how the
performance element should be modified to do better in the future.
• Performance element – which is responsible for selecting external actions and it
is equivalent to agent: it takes in percepts and decides on actions.
• Critic – It tells the learning element how well the agent is doing with respect to a
fixed performance standard.
• Problem generator – It is responsible for suggesting actions that will lead to new
and informative experiences.

Figure 1.6: A model-based, utility-based agent. It uses a model of the world,


along with a utility function that measures its preferences among states of the
world. Then it chooses the action that leads to the best expected utility, where
expected utility is computed by averaging over all possible outcome states,
weighted by the probability of the outcome.

19
IFETCE Regulation 2019A Academic Year: 2023-2024

In summary, agents have a variety of components, and those components can be


represented in many ways within the agent program, so there appears to be great
variety among learning methods. 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 (All agents can improve their performance through
learning).

1.5 AI Applications
Artificial Intelligence (AI) has made significant contributions to the healthcare
industry, revolutionizing various aspects of patient care, diagnostics, and
administrative processes.

Applications of AI in healthcare:
• Medical Imaging and Diagnostics: AI algorithms can analyze medical images
like X-rays, MRIs, and CT scans, assisting radiologists in detecting
abnormalities and making faster, more accurate diagnoses. AI aids pathologists
in analyzing pathology slides, identifying patterns, and diagnosing diseases
such as cancer.
• Drug Discovery and Development: AI accelerates drug discovery by analyzing
biological data, predicting potential drug candidates, and identifying novel
targets for treatment. Machine learning models can predict the likelihood of
success for certain drug candidates, potentially reducing the time and cost of
drug development.
• Personalized Medicine: AI analyzes patient data, including genetics, lifestyle,
and environmental factors, to tailor treatment plans for individual patients.
Predictive analytics help identify patients at risk of certain diseases, enabling
proactive and personalized interventions.
• Robotic Surgery Assistance: AI-powered robotic systems assist surgeons by
enhancing precision, minimizing invasiveness, and improving outcomes in
surgeries.
• Surgical Planning: AI aids in preoperative planning by analyzing patient data
and optimizing surgical approaches.
• Virtual Health Assistants and Chatbots: AI-powered chatbots provide instant
responses to medical queries, offer health advice, and guide users on symptom
checking. Virtual health assistants can schedule appointments, send medication
reminders, and provide follow-up care instructions.
• Predictive Analytics for Patient Outcomes: AI algorithms analyze patient data
to predict disease progression, readmission risks, and potential complications.
Early identification of high-risk patients allows for timely interventions,
reducing hospital readmissions and improving overall patient outcomes.
• Administrative Workflow Automation: AI streamlines administrative tasks,
such as billing, appointment scheduling, and claims processing, improving
efficiency and reducing errors. Natural Language Processing (NLP) helps in
extracting relevant information from unstructured data in electronic health

20
IFETCE Regulation 2019A Academic Year: 2023-2024

records.
• Remote Patient Monitoring: AI enables continuous monitoring of patients with
chronic conditions using wearable devices. Real-time data analysis helps
healthcare providers track patient health, identify trends, and intervene when
necessary, leading to better disease management.
• Robotic Surgery and Assistance: AI-assisted robotic systems enhance precision
in surgery, allowing for more accurate procedures with minimal invasiveness.
Surgeons can receive real-time feedback and assistance during procedures,
improving outcomes.
• Fraud Detection and Security: AI algorithms can detect anomalies in billing
and claims data, helping to identify potential fraud and improve the overall
security of healthcare systems.
• Clinical Trials Optimization: AI assists in patient recruitment for clinical trials
by identifying eligible candidates based on specific criteria. Predictive analytics
can optimize trial design, reducing costs and expediting the development of
new treatments.

Application of AI in education
• Personalized Learning: AI systems analyze individual student data, including
learning styles, preferences, and performance, to create personalized learning
paths. Adaptive learning platforms adjust content and pace to match each
student's needs, fostering a more tailored and effective learning experience.
• Intelligent Tutoring Systems: AI-powered tutoring systems provide real-time
feedback and guidance to students, offering personalized assistance in
various subjects. These systems adapt to the student's progress, identifying
areas where additional help is needed and customizing the learning
experience accordingly.
• Automated Grading and Assessment: AI automates the grading process for
assignments, quizzes, and exams, saving teachers time and providing quicker
feedback to students. Machine learning algorithms can analyze patterns in
student performance to identify areas of improvement and recommend
targeted interventions.
• Smart Content Creation: AI tools assist in creating and curating educational
content, generating interactive materials, and adapting resources to different
learning styles. Natural Language Processing (NLP) enables the development
of chatbots and virtual assistants for answering student queries.
• Predictive Analytics for Student Success: AI analyzes historical data to
predict student success and identify those at risk of falling behind. Early
intervention strategies can be implemented to support struggling students and
improve overall retention rates.
• Language Translation and Accessibility: AI-powered translation tools help
break down language barriers, making educational content more accessible to
students worldwide. Speech-to-text and text-to-speech technologies assist
students with diverse learning needs.
• Educational Gamification: AI enhances gamified learning experiences by

21
IFETCE Regulation 2019A Academic Year: 2023-2024

adapting game dynamics to individual student progress. Gamification


elements, such as rewards and challenges, can motivate students and make
learning more engaging.
• Virtual Reality (VR) and Augmented Reality (AR): AI contributes to
creating immersive educational experiences through VR and AR
applications. Virtual simulations provide students with hands-on experiences
in subjects like science, history, and art.
• Teacher Support and Professional Development: AI assists educators in
lesson planning, suggesting resources, and identifying areas where additional
professional development may be beneficial. Chatbots and virtual assistants
can help answer administrative questions, allowing teachers to focus more on
instruction.
• Administrative Automation: AI streamlines administrative tasks within
educational institutions, including scheduling, enrollment, and resource
allocation. Predictive analytics can help optimize resource planning and
budgeting based on historical data.

Application of AI in Agriculture
• Precision Farming: AI-powered sensors, drones, and satellite imagery
analyze data on soil conditions, crop health, and weather patterns. Farmers
can make data-driven decisions about irrigation, fertilization, and pesticide
use to optimize crop yields.
• Crop Monitoring and Management: Computer vision and machine learning
algorithms can identify and monitor crop diseases, pests, and nutrient
deficiencies. AI helps in early detection, enabling timely interventions and
reducing the need for broad-spectrum treatments.
• Automated Machinery and Robotics: AI enables the development of
autonomous tractors, harvesters, and drones for various farming tasks.
Robotics equipped with AI can perform precision tasks such as planting,
weeding, and harvesting, improving efficiency and reducing labor costs.
• Predictive Analytics for Yield Forecasting: AI analyzes historical and real-
time data to predict crop yields, helping farmers plan for harvests and make
informed decisions about marketing and distribution.
• Climate Prediction and Risk Management: AI models process weather data
to predict climate patterns, extreme weather events, and potential risks to
crops. Farmers can use this information for better risk management,
including adjusting planting schedules and choosing climate-resistant crop
varieties.
• Supply Chain Optimization: AI assists in optimizing the entire agricultural
supply chain, from production to distribution. Predictive analytics help
streamline logistics, reduce waste, and ensure timely delivery of products to
market.
• Soil Health Monitoring: AI analyzes soil data to assess soil health, including
nutrient levels and organic matter content. This information aids in
developing customized soil management plans, improving crop productivity
and reducing environmental impact.
22
IFETCE Regulation 2019A Academic Year: 2023-2024

• Livestock Monitoring: AI-powered sensors and wearable devices monitor the


health and behavior of livestock. Farmers can receive real-time data on
animal well-being, detect signs of disease, and optimize feeding strategies.
• Weed Identification and Management: AI-based image recognition systems
can identify and classify weeds. This technology enables targeted and precise
application of herbicides, reducing the overall use of chemicals.
• Market Price Prediction: AI analyzes market trends, demand-supply
dynamics, and other relevant factors to predict commodity prices. Farmers
can use this information for strategic decision-making, including when to sell
their products for optimal financial returns.

1.6 PROBLEM SOLVING AGENTS


Intelligent agents are supposed to maximize its performance measure.
Achieving this can be simplified if the agent can adopt a goal and aim to satisfy it. In
Artificial Intelligence, Search techniques are universal problem-solving methods.
Rational agents or Problem-solving agents in AI mostly used these search strategies or
algorithms to solve a specific problem and provide the best result. Problem- solving
agents are the goal-based agents and use atomic representation.
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.

➢ Goal formulation - Setting goals help the agent organize its behavior by
limiting the objectives that the agent is trying to achieve and hence the actions
it needs to consider. This Goal formulation based on the current situation and
the agent’s performance measure is the first step in problem solving.
➢ Problem formulation - We consider the agent’s goal to be a set of states. The
agent’s task is to find out actions in the present and in the future that could
reach the goal state from the present state. Problem formulation is the process
of deciding what actions and states to consider, given a goal.

• “ An agent with several immediate options of unknown value can decide what to
do by first examining the future actions that eventually lead to states of known
value ”
• After Goal formulation and problem formulation, the agent has to look for a
sequence of actions that reaches the goal. This process is called Search. A search
algorithm takes a problem as input and returns a sequence of actions as output.
• After the search phase, the agent has to carry out the actions that are recommended
by the search algorithm. This final phase is called execution phase.

Formulate — Search — Execute


Thus, the agent has a formulate, search and execute design to it.

23
IFETCE Regulation 2019A Academic Year: 2023-2024

Problems and Solutions


• Before we get into more about problem formulating phase, we need to first
understand what a problem is in terms of problem solving agents.

• The problem can be defined formally in five components:


1. Initial State
2. Actions
3. Transition Model
4. Goal Test
5. Path Cost

1. Initial State
The first component that describes the problem is the initial state that the agent starts
in. For example, if a taxi agent needs to get to location(B) but the taxi is currently at
location(A) then the initial state of the problem would be location(A).

2. Actions
The second component that describes the problem is a description of the possible
actions available to the agent. Given a 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.

3. Transition Model
• The third component is the description of what each action does which is called the
transition model. It is specified by a function Result(s , a) that returns the state
that results from doing action a in state s.
• The initial state, actions and transition model together define the state space of a
problem which is a set of all states reachable from the initial state by any sequence
of actions. The state space forms a graph in which the nodes are states and the
links between the nodes are actions.

4. Goal Test
The goal test determines whether a given state is a goal state or not. Sometimes there
is an explicit set of possible goal states and the test simply checks whether the given
state is one of them. Sometimes the goal is specified by an abstract property rather
than an explicitly enumerated set of states.

5. Path Cost
• The last component of the problem is the path cost which is a function that assigns
a numeric cost to each path. The problem solving agent chooses a cost function
that reflects its own performance measure.
• The solution to the problem is an action sequence that leads from initial state to
goal state and the solution quality is measured by the path cost function. An
optimal solution has the lowest path cost among all the solutions.

24
IFETCE Regulation 2019A Academic Year: 2023-2024

An Example Problem Formulation

Let us take the example of vacuum world that was introduced in the starting of this
series, There is a vacuum cleaner agent and it can move left or right and its jump is to
suck up the dirt from the floor. The problem for vacuum world can be formulated as
follows:

• States: The state is determined by both the agent location and the dirt location.
The agent is in one of two locations, each of which might or might not contain
dirt. Therefore, there are 2 x 2² = 8 possible world states .A larger environment
would have n x 2 to the power of n states.
• Initial State: Any state can be assigned as the initial state in this case.
• Action: In this environment there are three actions, Move Left , Move Right ,
Suck up the dirt.
• Transition Model: All the actions have expected effects, except for when the
agent is in leftmost square and the action is Left, when the agent is in rightmost
square and the action is Right and the square is clean when the action is to
Suck.
• Goal Test: Goal test 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.

The vacuum world problem is a toy problem and involves only discrete locations,
discrete dirt etc. Therefore, this problem is a Toy Problem. There are many Real-
World Problems like the automated taxi world. Try to formulate problems of real
world and see what would be the states be and what actions could be chosen etc.

25
IFETCE Regulation 2019A Academic Year: 2023-2024

Figure 1.7: State Space for vacuum world

1.6 Toy Problem


1.6.1 The vacuum world
• States: The state is determined by both the agent location and the dirt locations. The
agent is in one of two locations, each of which might or might not contain dirt. Thus,
there are 2 × 22 = 8 possible world states. A larger environment with n locations has n
· 2n states.
• Initial state: Any state can be designated as the initial state.
• 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 square, moving Right in the rightmost square, and Sucking in a clean
square have no effect. The complete state space is shown in Figure 5.
• 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.

26
IFETCE Regulation 2019A Academic Year: 2023-2024

Figure 1.8: The state space for the vacuum world. Links denote actions: L =
Left, R = Right, S=Suck.

1.6.2 8-puzzle

Figure 1.9: 8-puzzle

• States: A state description specifies the location of each of the eight tiles and the
blank in one of the nine squares.
• Initial state: Any state can be designated as the initial state. Note that any given goal
can be reached from exactly half of the possible initial states .
• Actions: 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
• Path cost: Each step costs 1, so the path cost is the number of steps in the path.

1.6.3 8-queens problem

The goal of the 8-queens problem 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.) an attempted solution that fails: the queen in the rightmost column is
attacked by the queen at the top left.

27
IFETCE Regulation 2019A Academic Year: 2023-2024

Figure 1.10: Almost a solution to the 8-queens problem.

• An incremental formulation involves operators that augment the state


description, starting with an empty state; for the 8-queens problem, this means that
each action adds a queen to the state.
• A complete-state formulation starts with all 8 queens on the board and moves
them around.

The first incremental formulation one might try is the following:


• States: Any arrangement of 0 to 8 queens on the board is a state.
• Initial state: No queens on the board.
• Actions: Add a queen to any empty square.
• Transition model: Returns the board with a queen added to the specified square.
• Goal test: 8 queens are on the board, none attacked
A better formulation would prohibit placing a queen in any square that is already
attacked:
• States: All possible arrangements of n queens (0 ≤ n ≤ 8), one per column in the
leftmost n columns, with no queen attacking another.
• Actions: Add a queen to any square in the leftmost empty column such that it is not
attacked by any other queen.

The toy problem was devised by Donald Knuth (1964) and illustrates how infinite
state spaces can arise. Knuth conjectured that, starting with the number 4, a sequence
of factorial, square root, and floor operations will reach any desired positive integer.
For example, we can reach 5 from 4 as follows:

The problem definition is very simple:


• States: Positive numbers.
• Initial state: 4.
• Actions: Apply factorial, square root, or floor operation (factorial for integers
only).
• Transition model: As given by the mathematical definitions of the operations.
• Goal test: State is the desired positive integer.

1.7 Real World Problems


• The route-finding problem is defined in terms of specified locations and transitions
along links between them. Route-finding algorithms are used in a variety of
applications.
• Some, such as Web sites and in-car systems that provide driving directions, are
relatively straightforward extensions of the Romania example.
• Others, such as routing video streams in computer networks, military operations
planning, and airline travel-planning systems, involve much more complex
specifications.

28
IFETCE Regulation 2019A Academic Year: 2023-2024

Consider the airline travel problems that must be solved by a travel-planning


Web site:
• States: Each state obviously includes a location (e.g., an airport) and the current
time. Furthermore, because the cost of an action (a flight segment) may depend on
previous segments, their fare bases, and their status as domestic or international, the
state must record extra information about these “historical” aspects.

• Initial state: This is specified by the user’s query.


• Actions: Take any flight from the current location, in any seat class, leaving after the
current time, leaving enough time for within-airport transfer if needed.
• Transition model: The state resulting from taking a flight will have the flight’s
destination as the current location and the flight’s arrival time as the current time.
• Goal test: Are we at the final destination specified by the user?
• Path cost: This depends on monetary cost, waiting time, flight time, customs and
immigration procedures, seat quality, time of day, type of airplane, frequent-flyer
mileage awards, and so on.

1.7.1 Example of Real World Problems.


i) TOURING PROBLEM
• Touring problems are closely related to route-finding problems, but with an
important difference. Consider, for example, the problem “Visit every city at least
once, starting and ending in Bucharest.” As with route finding, the actions
correspond to trips between adjacent cities. The state space, however, is quite
different.
• Each state must include not just the current location but also the set of cities the
agent has visited. So the initial state would be In(Bucharest ), Visited ({Bucharest
}), a typical intermediate state would be 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.

ii) TRAVELING SALESPERSON PROBLEM


• The traveling salesperson problem (TSP) is a touring problem in which each city
must be visited exactly once. The aim is to find the shortest tour. The problem is
known to be NP-hard, but an enormous amount of effort has been expended to
improve the capabilities of TSP algorithms.
• To planning trips for traveling salespersons, these algorithms have been used for
tasks such as planning movements of automatic circuit-board drills and of stocking
machines on shop floors.

iii) VLSI LAYOUT


• A VLSI layout problem requires positioning millions of components and
connections on a chip to minimize area, minimize circuit delays, minimize stray
capacitances, and maximize manufacturing yield.
• The layout problem comes after the logical design phase and is usually split into
two parts: cell layout and channel routing.
• In cell layout, the primitive components of the circuit are grouped into cells, each

29
IFETCE Regulation 2019A Academic Year: 2023-2024

of which performs some recognized function.


➢ Each cell has a fixed footprint (size and shape) and requires a certain number of
connections to each of the other cells.
➢ The aim is to place the cells on the chip so that they do not overlap and so that
there is room for the connecting wires to be placed between the cells.
➢ Channel routing finds a specific route for each wire through the gaps between
the cells. These search problems are extremely complex, but definitely worth
solving.

iv) ROBOT NAVIGATION


• Robot navigation is a generalization of the route-finding problem described earlier.
Rather than following a discrete set of routes, a robot can move in a continuous
space with (in principle) an infinite set of possible actions and states.
• For a circular robot moving on a flat surface, the space is essentially two-
dimensional. When the robot has arms and legs or wheels that must also be
controlled, the search space becomes many-dimensional. Advanced techniques are
required just to make the search space finite.

v) AUTOMATIC ASSEMBLY SEQUENCING


• Automatic assembly sequencing of complex objects by a robot was first
demonstrated by F REDDY (Michie, 1972). Progress since then has been slow but
sure, to the point where the assembly of intricate objects such as electric motors is
economically feasible.
• In assembly problems, the aim is to find an order in which to assemble the parts of
some object. If the wrong order is chosen, there will be no way to add some part
later in the sequence without undoing some of the work already done.
• Checking a step in the sequence for feasibility is a difficult geometrical search
problem closely related to robot navigation. Thus, the generation of legal actions is
the expensive part of assembly sequencing. Any practical algorithm must avoid
exploring all but a tiny fraction of the state space.

vi) PROTEIN DESIGN


Another important assembly problem is protein design, in which the goal is to find a
sequence of amino acids that will fold into a three-dimensional protein with the right
properties to cure some disease

30
IFETCE Regulation 2019A Academic Year: 2023-2024
IFET COLLEGE OF ENGINEERING
(An Autonomous Institution)
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
Foundations of AI

SUBJECT TITLE: Foundations of AI UNIT: I


SUBJECT CODE: 19UCSPEX01 YEAR/SEM: III/VI

Unit-1 Introduction
Introduction - Definition - Future of Artificial Intelligence - Characteristics of Intelligent
Agents–Typical Intelligent Agents -AI Applications - Problem Solving Approach to Typical
AI problems.

PART-A
Introduction -Definition-- Future of Artificial Intelligence
1. What is Artificial Intelligence. 2 R
2. The missionaries and cannibals problem is usually stated as follows. Three missionaries and 2 A
three cannibals are on one side of a river, along with a boat that can hold one two people.
Find a way to get everyone to the other side without ever leaving a group of missionaries in
one place outnumbered by the cannibals in that place.
3. How does artificial intelligence differ from human intelligence? 2 R
4. What are the risks and benefits of AI? 2 R
5. Infer the process of Turing test. 2 R
6. From each point in the maze, we can move in any of the four directions until we reach a 2 A
turning point, and this is the only action we need to do. Reformulate the problem using these
actions. Do we need to keep track of the robot’s orientation now?
7. To what extent the following computer systems are instances of artificial intelligence: 2 A
• Supermarket bar code scanners.
• Web search engines
8. Give a real time use cases of AI applications. 2 U
Characteristics of Intelligent Agents–Typical Intelligent Agents
9. Define intelligent agent with an example. 2 R
10. Define rationality concept in agents. 2 R
11. Provide the PEAS description of the task environment for an automated taxi driver. 2 S
12. Tabulate the fully observable vs partially observable properties of a task environment. 2 U
13. Write the significance of performance measures in a system 2 S
14. Specify the process of specifying a task environment. 2 S
15. Criticize the task environments and characteristics of real time game playing environments. 2 A
16. Provide PEAS description for robo navigation problem. 2 S
17. Derive a simple agent program for a simple reflex agent in the two-location vacuum 2 A
environment.
18. Draw the structure of a goal planning agent 2 S
19. Sketch the Schematic diagram of a simple reflex agent 2 U
20. Design a model-based reflex agent. It keeps track of the current state of the world, using an 2 A
internal model.
21. Differentiate learning element and performance element of a general learning agent 2 U
22. List the various types of agent program. 2 U

1
IFETCE Regulation 2019A Academic Year: 2023-2024
Problem Solving Agent- Toy Problems and Real-world Problems
23. Write the ways to formulate a problem 2 U
24. Consider the sensor less version of the erratic vacuum world. Draw the belief-state space 2 A
reachable from the initial belief state {1, 2, 3, 4, 5, 6, 7, 8}, and explain why the problem is
unsolvable.
25. Build a state space for the following 8 puzzle problem. 2 A

26. What issues we will face while designing search problems? 2 S


27. Construct a problem formulation for airline travel problem 2 A
28. Construct a pseudocode for simple problem-solving agent that searches for a sequence of 2 A
actions that would solve the problem and then executes actions one at a time.
29. Illustrate a state space search for simple vacuum world problem. 2 S
30. Provide the problem definition for the below mathematical equation: 2 A

Part –B
1. Define Artificial Intelligence (AI). Explain the techniques of AI and describe the characterize 16 R
of AI
2. Consider the given problem. Describe the process involved in it. Consider the water jug 16 A
problem: You are given two jugs, a 4-gallon one and a 3-gallon one, a pump which has
unlimited water which you can use to fill the jug, and the ground on which water may be poured.
Neither jug has any measuring markings on it. How can you get exactly 2 gallons of water in
the 4-gallon jug?
3. (i) Define the task environment and their characteristics with respect to the following 10 S
problems:
• Travelling salesman problem
• 8-puzzle problem
• Tower of Hanoi
• Chess
ii) Define Agent programs and Agent functions with example. 6 R
4. (i) List the various properties of task environments. 6 U
(ii) Give the PEAS description of the following agent types and characterize its properties: 10 S
• Knitting a sweater
• Shopping for the used books in the internet
• Part-picking robot
5. i) Why an agent is important and explains in detail about intelligent agent 10 S
ii) Distinguish an agent of AI and non AI program. 6 U
6. i) For each of the following assertions, say whether it is true or false and support 8 A
your answer with examples or counterexamples where appropriate.
a. An agent that senses only partial information about the state cannot be perfectly

2
IFETCE Regulation 2019A Academic Year: 2023-2024
rational.
b. There exist task environments in which no pure reflex agent can behave
rationally.
c. There exists a task environment in which every agent is rational.
d. The input to an agent program is the same as the input to the agent function.
e. Every agent function is implementable by some program/machine combination.
f. Suppose an agent selects its action uniformly at random from the set of possible
actions.
There exists a deterministic task environment in which this agent is rational.
g. It is possible for a given agent to be perfectly rational in two distinct task
environments.
h. Every agent is rational in an unobservable environment.
i. A perfectly rational poker-playing agent never loses.
ii) Give a complete problem formulation for each of the following. Choose a 8 A
formulation that is precise enough to be implemented. Using only four colors, you
have to color a planar map in such a way that no two adjacent regions have the
same color.
a) A 3-foot-tall monkey is in a room where some bananas are suspended from the
8-foot ceiling. He would like to get the bananas. The room contains two
stackable, movable , climbable 3-foot-high crates.
b) You have a program that outputs the message “illegal input record” when fed
a certain file of input records. You know that processing of each record is
independent of the other records. You want to discover what record is illegal.
c) You have three jugs, measuring 12 gallons, 8 gallons, and 3 gallons, and a
water faucet. You can fill the jugs up or empty them out from one to another or
onto the ground. You need to measure out exactly one gallon.
7. Define Problem Solving agent. Explain in détail about how to search the solution for the 16 R
problem in AI.
8. Explain how to solve the 8-queens problem and any two from Real World Problem 16 A

3
IFETCE Regulation 2019A Academic Year: 2023-2024

IFET COLLEGE OF ENGINEERING


(An Autonomous Institution)
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

SUBJECT TITLE: Foundations of AI UNIT: I


SUBJECT CODE: 19UCSPEX01 YEAR/SEM: III/VI

Unit-1 Introduction
Introduction - Definition - Future of Artificial Intelligence - Characteristics of Intelligent
Agents–Typical Intelligent Agents -AI Applications - Problem Solving Approach to Typical AI
problems.

PART-A
2 The missionaries and cannibals problem is usually stated as follows. Three missionaries and three
cannibals are on one side of a river, along with a boat that can hold one two people. Find a way to
get everyone to the other side without ever leaving a group of missionaries in one place outnumbered
by the cannibals in that place.

Here, Actions are taken as


o 1m --- one missionary crosses the river
o 1c --- one cannibal crosses the river
o 2m ---- two missionaries cross the river
o 2c --- two cannibals cross the river
o 1m, 1c --- one missionary and one cannibal cross the river
6 From each point in the maze, we can move in any of the four directions until we reach a turning
point, and this is the only action we need to do. Reformulate the problem using these actions. Do we
need to keep track of the robot’s orientation now?
Initial state: At the center of the maze.
Goal test: At an exit node.
Successor function: Move to next intersection to the North, South, East, or West.
Cost function: Total distance moved.
It is not necessary to keep track of the robot’s orientation since it is irrelevant to predicting the outcome
of our actions, and not part of the goal test. The motor system that executes the plan will need to keep
track of the robot’s current orientation, to know when to rotate the robot.
1
IFETCE Regulation 2019A Academic Year: 2023-2024

7 To what extent the following computer systems are instances of artificial intelligence:
• Supermarket bar code scanners.
• Web search engines
• Although bar code scanning is in a sense computer vision, these are not AI systems. The problem
of reading a bar code is an extremely limited and artificial form of visual interpretation, and it has
been carefully designed to be as simple as possible, given the hardware.
• In many respects. The problem of determining the relevance of a web page to a query is a problem
in natural language understanding, Search engines like Ask.com, which group the retrieved pages
into categories, use clustering techniques Likewise, other functionalities provided by a search
engines use intelligent techniques; for instance, the spelling corrector uses a form of data mining
based on observing users’ corrections of their own spelling errors. On the other hand, the problem
of indexing billions of web pages in a way that allows retrieval in seconds is a problem in database
design, not in artificial intelligence.

11 Provide the PEAS description of the task environment for an automated taxi driver.
Agent Type Performance Environment Actuators Sensors
Measure
Taxi driver Safe, fast, legal, Roads, other Steering, Cameras, radar,
comfortable traffic, police, accelerator, brake, speedometer,
trip, maximize pedestrians, signal, horn, GPS, engine
profits, minimize customers, display, speech sensors,
impact on other weather accelerometer,
road users microphones,
touchscreen

15 Criticize the task environments and characteristics of real time game playing environments.

17 Derive a simple agent program for a simple reflex agent in the two-location vacuum environment.
function REFLEX-VACUUM-AGENT([location,status]) returns an action
if status = Dirty then return Suck
else if location = A then return Right
else if location = B then return Left
20 Design a model-based reflex agent. It keeps track of the current state of the world, using an internal
model.
function MODEL-BASED-REFLEX-AGENT(percept) returns an action
persistent: state, the agent’s current conception of the world state
transition model, a description of how the next state depends on
2
IFETCE Regulation 2019A Academic Year: 2023-2024

the current state and action


sensor model, a description of how the current world state is reflected
in the agent’s percepts
rules, a set of condition–action rules
action, the most recent action, initially none
state←UPDATE-STATE(state,action,percept,transition model,sensor model)
rule←RULE-MATCH(state,rules)
action←rule.ACTION
return action
24 Consider the sensor less version of the erratic vacuum world. Draw the belief-state space reachable
from the initial belief state {1, 2, 3, 4, 5, 6, 7, 8}.

25 Build a state space for the following 8 puzzle problem.

The standard formulation of the 8 puzzle is as follows:


• States: A state description specifies the location of each of the tiles.
• Initial state: Any state can be designated as the initial state. Note that a parity property partitions the
state space—any given goal can be reached from exactly half of the
possible initial states.
• Actions: While in the physical world it is a tile that slides, the simplest way of describing an action is to
think of the blank space moving Left, Right, Up, or Down. If the
blank is at an edge or corner then not all actions will be applicable.
• Transition model: Maps a state and action to a resulting state; for example, if we apply
Left to the start state in the given figure, the resulting state has the 5 and the blank switched.
• Goal state: Although any state could be the goal, we typically specify a state with the
3
IFETCE Regulation 2019A Academic Year: 2023-2024

numbers in order, as in the figure.


• Action cost: Each action costs 1.
27 Construct a problem formulation for airline travel problem.
• States: Each state obviously includes a location (e.g., an airport) and the current time. Furthermore,
because the cost of an action (a flight segment) may depend on previous segments, their fare bases, and
their status as domestic or international, the state must record extra information about these “historical”
aspects.
• Initial state: The user’s home airport.
• Actions: Take any flight from the current location, in any seat class, leaving after the current time,
leaving enough time for within-airport transfer if needed.
• Transition model: The state resulting from taking a flight will have the flight’s destination as the new
location and the flight’s arrival time as the new time.
• Goal state: A destination city. Sometimes the goal can be more complex, such as “arrive at the destination
on a nonstop flight.”
• Action cost: A combination of monetary cost, waiting time, flight time, customs and immigration
procedures, seat quality, time of day, type of airplane, frequent-flyer reward points, and so on.
28 Construct a pseudocode for simple problem-solving agent that searches for a sequence of actions
that would solve the problem and then executes actions one at a time.
function SIMPLE-PROBLEM-SOLVING-AGENT(percept) returns an action
persistent: seq, an action sequence, initially empty
state, some description of the current world state
goal, a goal, initially null
problem, a problem formulation

state ← UPDATE-STATE(state, percept)


if seq is empty then
goal ← FORMULATE-GOAL(state)
problem ← FORMULATE-PROBLEM(state, goal)
seq ← SEARCH(problem)
if seq = failure then return a null action
action ← FIRST(seq)
seq ← REST(seq)
return action
30 Provide the problem definition for the below mathematical equation:

The problem definition is simple:


• States: Positive real numbers.
• Initial state: 4.
• Actions: Apply square root, floor, or factorial operation (factorial for integers only).
• Transition model: As given by the mathematical definitions of the operations.
• Goal state: The desired positive integer.
• Action cost: Each action costs 1.
The state space for this problem is infinite: for any integer greater than 2 the factorial operator will
always yield a larger integer. The problem is interesting because it explores very
large numbers: the shortest path to 5 goes through (4!)! = 620,448,401,733,239,439,360,000.
Infinite state spaces arise frequently in tasks involving the generation of mathematical expressions,
circuits, proofs, programs, and other recursively defined objects.
PART-B

4
IFETCE Regulation 2019A Academic Year: 2023-2024

2. Consider the given problem. Describe the process involved in it. Consider the water jug problem:
You are given two jugs, a 4-gallon one and a 3-gallon one, a pump which has unlimited water
which you can use to fill the jug, and the ground on which water may be poured. Neither jug has
any measuring markings on it. How can you get exactly 2 gallons of water in the 4-gallon jug?

Here the initial state is (0, 0). The goal state is (2, n) for any value of n.

State Space Representation: we will represent a state of the problem as a tuple (x, y) where x
represents the amount of water in the 4-gallon jug and y represents the amount of water in the 3-gallon
jug. Note that 0 ≤ x ≤ 4, and 0 ≤ y ≤ 3.

To solve this we have to make some assumptions not mentioned in the problem. They are:

We can fill a jug from the pump.


We can pour water out of a jug to the ground.
We can pour water from one jug to another.
There is no measuring device available.
Operators — we must define a set of operators that will take us from one state to another.

6 a) For each of the following assertions, say whether it is true or false and support your answer
with examples or counterexamples where appropriate.
a. An agent that senses only partial information about the state cannot be perfectly rational.

5
IFETCE Regulation 2019A Academic Year: 2023-2024

b. There exist task environments in which no pure reflex agent can behave rationally.
c. There exists a task environment in which every agent is rational.
d. The input to an agent program is the same as the input to the agent function.
e. Every agent function is implementable by some program/machine combination.
f. Suppose an agent selects its action uniformly at random from the set of possible actions.
There exists a deterministic task environment in which this agent is rational.
g. It is possible for a given agent to be perfectly rational in two distinct task environments.
h. Every agent is rational in an unobservable environment.
i. A perfectly rational poker-playing agent never loses.

a. An agent that senses only partial information about the state cannot be perfectly rational.
False. Perfect rationality refers to the ability to make good decisions given the sensor information
received.
b. There exist task environments in which no pure reflex agent can behave rationally.
True. A pure reflex agent ignores previous percepts, so cannot obtain an optimal state estimate in a
partially observable environment. For example, correspondence chess is played by sending moves; if the
other player’s move is the current percept, a reflex agent could not keep track of the board state and would
have to respond to, say, “a4” in the same way regardless of the position in which it was played.
c. There exists a task environment in which every agent is rational.
True. For example, in an environment with a single state, such that all actions have the same reward,
it doesn’t matter which action is taken. More generally, any environment that is reward-invariant under
permutation of the actions will satisfy this property.
d. The input to an agent program is the same as the input to the agent function.
False. The agent function, notionally speaking, takes as input the entire percept sequence up to that
point, whereas the agent program takes the current percept only.
e. Every agent function is implementable by some program/machine combination.
False. For example, the environment may contain Turing machines and input tapes and the agent’s
job is to solve the halting problem; there is an agent function that specifies the right answers, but no agent
program can implement it. Another example would be an agent function that requires solving intractable
problem instances of arbitrary size in constant time.
f. Suppose an agent selects its action uniformly at random from the set of possible actions. There
exists a deterministic task environment in which this agent is rational.
True. This is a special case of (c); if it doesn’t matter which action you take, selecting randomly is
rational.
g. It is possible for a given agent to be perfectly rational in two distinct task environments.
True. For example, we can arbitrarily modify the parts of the environment that are unreachable by any
optimal policy as long as they stay unreachable.
h. Every agent is rational in an unobservable environment.
False. Some actions are stupid—and the agent may know this if it has a model of the environment—
even if one cannot perceive the environment state.
i. A perfectly rational poker-playing agent never loses.
False. Unless it draws the perfect hand, the agent can always lose if an opponent has better cards.
This can happen for game after game. The correct statement is that the agent’s expected winnings are
non-negative.
b) Give a complete problem formulation for each of the following. Choose a formulation that is
precise enough to be implemented.
i. Using only four colors, you have to color a planar map in such a way that no two adjacent
regions have the same color.

6
IFETCE Regulation 2019A Academic Year: 2023-2024

ii. A 3-foot-tall monkey is in a room where some bananas are suspended from the 8-foot ceiling.
He would like to get the bananas. The room contains two stackable, movable , climbable 3-
foot-high crates.
iii. You have a program that outputs the message “illegal input record” when fed a certain file
of input records. You know that processing of each record is independent of the other
records. You want to discover what record is illegal.
iv. You have three jugs, measuring 12 gallons, 8 gallons, and 3 gallons, and a water faucet. You
can fill the jugs up or empty them out from one to another or onto the ground. You need to
measure out exactly one gallon.
Solution:
a. Initial state: No regions colored.
Goal test: All regions colored, and no two adjacent regions have the same color.
Successor function: Assign a color to a region.
Cost function: Number of assignments.
b. Initial state: As described in the text.
Goal test: Monkey has bananas.
Successor function: Hop on crate; Hop off crate; Push crate from one spot to another;Walk from one
spot to another; grab bananas (if standing on crate).
Cost function: Number of actions.
c. Initial state: considering all input records.
Goal test: considering a single record, and it gives “illegal input” message.
Successor function: run again on the first half of the records; run again on the second half of the
records.
Cost function: Number of runs.
d. Initial state: jugs have values [0, 0, 0].
Successor function: given values [x,y,z], generate [12,y,z], [x, 8,z], [x,y, 3] (by filling); [0,y,z], [x, 0,z],
[x,y, 0] (by emptying); or for any two jugs with current values x and y, pour y into x; this changes the
jug with x to the minimum of x + y and the capacity of the jug, and decrements the jug with y by by the
amount gained by the first jug.
Cost function: Number of actions.
8 Explain how to solve the 8-queens problem and any two from Real World Problem.

1. 8-queens problem

The goal of the 8-queens problem 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.) an attempted solution that
fails: the queen in the rightmost column is attacked by the queen at the top left.

Almost a solution to the 8-queens problem.

7
IFETCE Regulation 2019A Academic Year: 2023-2024

An incremental formulation involves operators that augment the state description, starting with an
empty state; for the 8-queens problem, this means that each action adds a queen to the state.

A complete-state formulation starts with all 8 queens on the board and moves them around.

The first incremental formulation one might try is the following:

• States: Any arrangement of 0 to 8 queens on the board is a state.

• Initial state: No queens on the board.

• Actions: Add a queen to any empty square.

• Transition model: Returns the board with a queen added to the specified square.

• Goal test: 8 queens are on the board, none attacked

A better formulation would prohibit placing a queen in any square that is already attacked:

• States: All possible arrangements of n queens (0 ≤ n ≤ 8), one per column in the leftmost n columns,
with no queen attacking another.

• Actions: Add a queen to any square in the leftmost empty column such that it is not attacked by any
other queen.

Our final toy problem was devised by Donald Knuth (1964) and illustrates how infinite state spaces can
arise. Knuth conjectured that, starting with the number 4, a sequence of factorial, square root, and floor
operations will reach any desired positive integer. For example, we can reach 5 from 4 as follows:

The problem definition is very simple:

• States: Positive numbers.

• Initial state: 4.

• Actions: Apply factorial, square root, or floor operation (factorial for integers only).

• Transition model: As given by the mathematical definitions of the operations.

• Goal test: State is the desired positive integer.

2. Real World Problem

• The route-finding problem is defined in terms of specified locations and transitions along links
between them. Route-finding algorithms are used in a variety of applications.
• Some, such as Web sites and in-car systems that provide driving directions, are relatively

8
IFETCE Regulation 2019A Academic Year: 2023-2024

straightforward extensions of the Romania example.


• Others, such as routing video streams in computer networks, military operations planning, and
airline travel-planning systems, involve much more complex specifications.

Consider the airline travel problems that must be solved by a travel-planning Web site:
• States: Each state obviously includes a location (e.g., an airport) and the current time.
Furthermore, because the cost of an action (a flight segment) may depend on previous
segments, their fare bases, and their status as domestic or international, the state must
record extra information about these “historical” aspects.

• Initial state: This is specified by the user’s query.


• Actions: Take any flight from the current location, in any seat class, leaving after the current time,
leaving enough time for within-airport transfer if needed.
• Transition model: The state resulting from taking a flight will have the flight’s destination as the
current location and the flight’s arrival time as the current time.
• Goal test: Are we at the final destination specified by the user?

• Path cost: This depends on monetary cost, waiting time, flight time, customs and immigration
procedures, seat quality, time of day, type of airplane, frequent-flyer mileage awards, and so on.

9
IFETCE Regulation 2019A Academic Year: 2023-2024

IFET COLLEGE OF ENGINEERING


(An Autonomous Institution)
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

SUBJECT TITLE: Foundations of AI UNIT: II


SUBJECT CODE: 19UCSPEX01 YEAR/SEM: III/VI

UNIT-II PROBLEM SOLVING METHODS


Problem solving Methods - Search Strategies- Uninformed - Informed - Heuristics - Local
Search Algorithms and Optimization Problems - Searching with Partial Observations -
Constraint Satisfaction Problems - Constraint Propagation - Backtracking Search.
2. PROBLEM SOLVING METHODS
Problem-solving in artificial intelligence (AI) involves creating algorithms and approaches
to find solutions to complex problems. Here are some common problem-solving methods used
in AI:
1. Search Algorithms: Search algorithms in artificial intelligence are used to explore
possible solutions in a problem space. These algorithms traverse the search space
systematically to find a goal state or optimal solution. The search algorithms are:
Uninformed search:
• Breadth-first search
• Uniform cost search
• Depth-first search
• Iterative deepening depth-first search
• Bidirectional Search
Informed search
• Greedy Search
• A* Search
2. Knowledge Representation and Reasoning: Knowledge representation and reasoning
(KRR) form the core of artificial intelligence (AI) systems, enabling machines to
acquire, organize, and utilize information effectively. These processes are fundamental
for modeling the world, making decisions, and solving complex problems. Types of
Knowledge Representation are Symbolic Representation, Connectionist
Representation, Semantic Networks and Frames and Ontologies. Types of Knowledge
reasoning are Logical Reasoning, Probabilistic Reasoning, Heuristic Reasoning and
Inductive Reasoning.
3. Machine Learning: Machine Learning (ML) is a subset of artificial intelligence (AI)
that focuses on the development of algorithms and models that allow computers to learn
patterns, make predictions, and improve their performance over time without being
explicitly programmed. ML systems leverage data to discover insights, recognize
patterns, and make informed decisions. Types of learning are
• Supervised Learning
• Unsupervised Learning
• Reinforcement Learning
4. Constraint Satisfaction Problems (CSP): Constraint Satisfaction Problems (CSPs)
are a class of problems in artificial intelligence (AI) that involve finding a solution
satisfying a set of constraints. CSPs are pervasive in various domains, including
scheduling, planning, configuration, and optimization. Techniques for Solving CSPs:
• Backtracking
• Forward Checking

1
IFETCE Regulation 2019A Academic Year: 2023-2024

• Constraint Propagation
• Arc-Consistency
• Heuristic Search
5. Optimization Techniques: Optimization techniques in artificial intelligence (AI) play
a crucial role in improving the performance of algorithms, models, and systems. These
techniques aim to find the best set of parameters or configuration that minimizes or
maximizes an objective function. Optimization techniques commonly used in AI:
• Gradient Descent
• Stochastic Gradient Descent (SGD)
• Mini-Batch Gradient Descent
• Adam Optimization
• Genetic Algorithms
• Particle Swarm Optimization (PSO)
• Simulated Annealing
• Ant Colony Optimization (ACO)
• Bayesian Optimization
• Evolutionary Strategies
• Constraint Programming
2.1 Search Strategies
In artificial intelligence (AI), search algorithms are employed to explore and navigate problem
spaces to find a solution or optimize a certain objective. Search Algorithm Terminologies:
• Search: Searching is a step by step procedure to solve a search-problem in a given search
space. A search problem can have three main factors:
1. Search Space: Search space represents a set of possible solutions, which a system may
have.
2. Start State: It is a state from where agent begins the search.
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.
• Transition model: A description of what each action do, can be represented as a transition
model.
• Path Cost: It is a function which assigns a numeric cost to each path.
• 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.
2.1.1 Properties of Search Algorithms:
Following are the four essential properties of search algorithms to compare the efficiency of
these algorithms:
Completeness: A search algorithm is said to be complete if it guarantees to return a solution
if at least any solution exists for any random input.
Optimality: If a solution found for an algorithm is guaranteed to be the best solution (lowest
path cost) among all other solutions, then such a solution for is said to be an optimal solution.
Time Complexity: Time complexity is a measure of time for an algorithm to complete its
task.
Space Complexity: It is the maximum storage space required at any point during the search,
as the complexity of the problem.
Types of search algorithms: Based on the search problems we can classify the search
algorithms into uninformed (Blind search) search and informed search (Heuristic search)

2
IFETCE Regulation 2019A Academic Year: 2023-2024

algorithms.

Figure 1: Search Algorithm


Uninformed/Blind Search:
• The uninformed search does not contain any domain knowledge such as closeness, the
location of the goal.
• It operates in a brute-force way as it only includes information about how to traverse the
tree and how to identify leaf and goal nodes.
• Uninformed search applies a way in which search tree is searched without any
information about the search space like initial state operators and test for the goal, so it is
also called blind search.It examines each node of the tree until it achieves the goal node.
• It can be divided into five main types:
1. Breadth-first search
2. Uniform cost search
3. Depth-first search
4. Iterative deepening depth-first search
5. Bidirectional Search
Informed Search
• Informed search algorithms use domain knowledge. In an informed search, problem
information is available which can guide the search. Informed search strategies can find a
solution more efficiently than an uninformed search strategy. Informed search is also
called a Heuristic search.
• A heuristic is a way which might not always be guaranteed for best solutions but
guaranteed to find a good solution in reasonable time.
• Informed search can solve much complex problem which could not be solved in another
way.
• An example of informed search algorithms is a traveling salesman problem.
1. Greedy Search
2. A* Search

2.1.2 INFORMED AND UNINFORMED SEARCH STRATEGIES

Informed Search Algorithms


• Informed search algorithm contains an array of knowledge such as how far we are from the
goal, path cost, how to reach to goal node, etc. This knowledge helps agents to explore less
to the search space and find more efficiently the goal node.

3
IFETCE Regulation 2019A Academic Year: 2023-2024

• The informed search algorithm is more useful for large search space. Informed search
algorithm uses the idea of heuristic, so it is also called Heuristic search.

Heuristics function:
• Heuristic is a function which is used in Informed Search, and it finds the most promising
path.
• It takes the current state of the agent as its input and produces the estimation of how close
agent is from the goal.
• The heuristic method, however, might not always give the best solution, but it guaranteed
to find a good solution in reasonable time.
• Heuristic function estimates how close a state is to the goal. It is represented by h(n), and
it calculates the cost of an optimal path between the pair of states.
• The value of the heuristic function is always positive.
❖ An informed search makes use of heuristic functions in order to reach the goal node in a
more prominent way. Therefore, there are several pathways in a search tree to reach the
goal node from the current node. The selection of a good heuristic function matters
certainly. A good heuristic function is determined by its efficiency. More is the
information about the problem, more is the processing time.
❖ Some toy problems, such as 8-puzzle, 8-queen, tic-tac-toe, etc., can be solved more
efficiently with the help of a heuristic function. Let’s see how:
❖ Consider the following 8-puzzle problem where we have a start state and a goal state. Our
task is to slide the tiles of the current/start state and place it in an order followed in the goal
state. There can be four moves either left, right, up, or down. There can be several ways to
convert the current/start state to the goal state, but, we can use a heuristic function h(n) to
solve the problem more efficiently.

Fig.8 Heuristic function

A heuristic function for the 8-puzzle problem is defined below:


h(n)=Number of tiles out of position
So, there is total of three tiles out of position i.e., 6,5 and 4. Do not count the empty tile present
in the goal state). i.e. h(n)=3 (fig 8). Now, we require to minimize the value of h(n) =0. It is
seen from the above state space tree that the goal state is minimized from h(n)=3 to h(n)=0.
However, we can create and use several heuristic functions as per the requirement. It is also
clear from the above example that a heuristic function h(n) can be defined as the information
required to solve a given problem more efficiently. The information can be related to the nature
of the state, cost of transforming from one state to another, goal node characteristics, etc.,
which is expressed as a heuristic function. We can construct a state-space tree to minimize the
h(n) value to 0, as shown below:

4
IFETCE Regulation 2019A Academic Year: 2023-2024

Fig.9.Eight puzzle problem


Properties of a Heuristic search Algorithm
Use of heuristic function in a heuristic search algorithm leads to following properties of a
heuristic search algorithm:
• Admissible Condition: An algorithm is said to be admissible, if it returns an optimal
solution.
• Completeness: An algorithm is said to be complete, if it terminates with a solution (if
the solution exists).
• Dominance Property: If there are two admissible heuristic
algorithms A1 and A2 having h1 and h2 heuristic functions, then A1 is said to
dominate A2 if h1 is better than h2 for all the values of node n.
• Optimality Property: If an algorithm is complete, admissible, and dominating other
algorithms, it will be the best one and will definitely give an optimal solution.

Admissibility of the heuristic function is given as:


h(n) <= h*(n)

Here h(n) is heuristic cost, and h*(n) is the estimated cost. Hence heuristic cost should be less
than or equal to the estimated cost.

Pure Heuristic Search:


• Pure heuristic search is the simplest form of heuristic search algorithms. It expands nodes
based on their heuristic value h(n). It maintains two lists, OPEN and CLOSED list. In the
CLOSED list, it places those nodes which have already expanded and in the OPEN list, it
places nodes which have yet not been expanded.
• On each iteration, each node n with the lowest heuristic value is expanded and generates
all its successors and n is placed to the closed list. The algorithm continues unit a goal
state is found.

In the informed search we will discuss two main algorithms which are given below:
• Best First Search Algorithm(Greedy search)
• A* Search Algorithm
1) Best-first Search Algorithm (Greedy Search):

5
IFETCE Regulation 2019A Academic Year: 2023-2024

• Greedy best-first search algorithm always selects the path which appears best at that
moment. It is the combination of depth-first search and breadth-first search algorithms.
• It uses the heuristic function and search. Best-first search allows us to take the advantages
of both algorithms. With the help of best-first search, at each step, we can choose the
most promising node. In the best first search algorithm, we expand the node which is
closest to the goal node and the closest cost is estimated by heuristic function, i.e.
f(n) = g(n).
Were, h(n)= estimated cost from node n to the goal.
The greedy best first algorithm is implemented by the priority queue.
Best first search algorithm:
Step 1: Place the starting node into the OPEN list.
Step 2: If the OPEN list is empty, Stop and return failure.
Step 3: Remove the node n, from the OPEN list which has the lowest value of h(n), and
places it in the CLOSED list.
Step 4: Expand the node n, and generate the successors of node n.
Step 5: Check each successor of node n, and find whether any node is a goal node or not. If
any successor node is goal node, then return success and terminate the search, else proceed
to Step 6.
Step 6: For each successor node, algorithm checks for evaluation function f(n), and then
check if the node has been in either OPEN or CLOSED list. If the node has not been in both
list, then add it to the OPEN list.
Step 7: Return to Step 2.

Advantages:
• Best first search can switch between BFS and DFS by gaining the advantages of both the
algorithms.
• This algorithm is more efficient than BFS and DFS algorithms.

Disadvantages:
• It can behave as an unguided depth-first search in the worst case scenario.
• It can get stuck in a loop as DFS.
• This algorithm is not optimal.
Example: Consider the below search problem, and we will traverse it using greedy best-first
search. At each iteration, each node is expanded using evaluation function f(n)=h(n) , which
is given in the below table.

In this search example, we are using two lists which are OPEN and CLOSED Lists. Following
are the iteration for traversing the above example.

6
IFETCE Regulation 2019A Academic Year: 2023-2024

Expand the nodes of S and put in the CLOSED list


Initialization: Open [A, B], Closed [S]
Iteration 1: Open [A], Closed [S, B]
Iteration 2: Open [E, F, A], Closed [S, B]
: Open [E, A], Closed [S, B, F]
Iteration 3: Open [I, G, E, A], Closed [S, B, F]
: Open [I, E, A], Closed [S, B, F, G]
Hence the final solution path will be: S----> B----->F----> G
Time Complexity: The worst case time complexity of Greedy best first search is O(bm).
Space Complexity: The worst case space complexity of Greedy best first search is O(bm).
Where, m is the maximum depth of the search space.
Complete: Greedy best-first search is also incomplete, even if the given state space is finite.
Optimal: Greedy best first search algorithm is not optimal.

2) A* Search Algorithm:
• A* search is the most commonly known form of best-first search. It uses heuristic function
h(n), and cost to reach the node n from the start state g(n). It has combined features of UCS
and greedy best-first search, by which it solve the problem efficiently.
• A* search algorithm finds the shortest path through the search space using the heuristic
function. This search algorithm expands less search tree and provides optimal result faster.
A* algorithm is similar to UCS except that it uses g(n)+h(n) instead of g(n).
• In A* search algorithm, we use search heuristic as well as the cost to reach the node. Hence
we can combine both costs as following, and this sum is called as a fitness number.

At each point in the search space, only those node is expanded which have the lowest value of
f(n), and the algorithm terminates when the goal node is found.
Algorithm of A* search:
Step1: Place the starting node in the OPEN list.
Step 2: Check if the OPEN list is empty or not, if the list is empty then return failure and stops.
7
IFETCE Regulation 2019A Academic Year: 2023-2024

Step 3: Select the node from the OPEN list which has the smallest value of evaluation function
(g+h), if node n is goal node then return success and stop, otherwise
Step 4: Expand node n and generate all of its successors, and put n into the closed list. For each
successor n', check whether n' is already in the OPEN or CLOSED list, if not then compute
evaluation function for n' and place into Open list.
Step 5: Else if node n' is already in OPEN and CLOSED, then it should be attached to the back
pointer which reflects the lowest g(n') value.
Step 6: Return to Step 2.
Advantages:
• A* search algorithm is the best algorithm than other search algorithms.
• A* search algorithm is optimal and complete.
• This algorithm can solve very complex problems.
Disadvantages:
• It does not always produce the shortest path as it mostly based on heuristics and
approximation.
• A* search algorithm has some complexity issues.
• The main drawback of A* is memory requirement as it keeps all generated nodes in the
memory, so it is not practical for various large-scale problems.
Example:
In this example, we will traverse the given graph using the A* algorithm. The heuristic
value of all states is given in the below table so we will calculate the f(n) of each state
using the formula f(n)= g(n) + h(n), where g(n) is the cost to reach any node from start
state. Here we will use OPEN and CLOSED list.

Solution:

8
IFETCE Regulation 2019A Academic Year: 2023-2024

Initialization: {(S, 5)}


Iteration1: {(S--> A, 4), (S-->G, 10)}
Iteration2: {(S--> A-->C, 4), (S--> A-->B, 7), (S-->G, 10)}
Iteration3: {(S--> A-->C--->G, 6), (S--> A-->C--->D, 11), (S--> A-->B, 7), (S-->G, 10)}
Iteration 4 will give the final result, as S--->A--->C--->G it provides the optimal path with
cost 6.

• A* algorithm returns the path which occurred first, and it does not search for all
remaining paths.
• The efficiency of A* algorithm depends on the quality of heuristic.
• A* algorithm expands all nodes which satisfy the condition f(n) <="" li="">
Complete: A* algorithm is complete as long as:
• Branching factor is finite.
• Cost at every action is fixed.
Optimal: A* search algorithm is optimal if it follows below two conditions:
• Admissible: the first condition requires for optimality is that h(n) should be an admissible
heuristic for A* tree search. An admissible heuristic is optimistic in nature.
• Consistency: Second required condition is consistency for only A* graph-search. If the
heuristic function is admissible, then A* tree search will always find the least cost path.
• Time Complexity: The time complexity of A* search algorithm depends on heuristic function,
and the number of nodes expanded is exponential to the depth of solution d. So the time
complexity is O(b^d), where b is the branching factor.
• Space Complexity: The space complexity of A* search algorithm is O(b^d)

2.1.3 Uninformed Search Algorithms


Uninformed search is a class of general-purpose search algorithms which operates in
brute force-way. Uninformed search algorithms do not have additional information about state
or search space other than how to traverse the tree, so it is also called blind search.
Following are the various types of uninformed search algorithms:
1. Breadth-first Search
2. Depth-first Search

9
IFETCE Regulation 2019A Academic Year: 2023-2024

3. Depth-limited Search
4. Iterative deepening depth-first search
5. Uniform cost search
6. Bidirectional Search

1. Breadth-first Search:
• Breadth-first search is the most common search strategy for traversing a tree or graph.
This algorithm searches breadthwise in a tree or graph, so it is called breadth-first search.
• BFS algorithm starts searching from the root node of the tree and expands all successor
node at the current level before moving to nodes of next level.
• The breadth-first search algorithm is an example of a general-graph search algorithm.
• Breadth-first search implemented using FIFO queue data structure.
Advantages:
• BFS will provide a solution if any solution exists.
• If there are more than one solutions for a given problem, then BFS will provide the
minimal solution which requires the least number of steps.
Disadvantages:
• It requires lots of memory since each level of the tree must be saved into memory to
expand the next level.
• BFS needs lots of time if the solution is far away from the root node.

Example: In the below tree structure, we have shown the traversing of the tree using BFS
algorithm from the root node S to goal node K. BFS search algorithm traverse in layers, so it
will follow the path which is shown by the dotted arrow, and the traversed path will be:
S---> A--->B---->C--->D---->G--->H--->E---->F---->I---->K
• Time Complexity: Time Complexity of BFS algorithm can be obtained by the number of
nodes traversed in BFS until the shallowest Node. Where the d= depth of shallowest
solution and b is a node at every state.
T (b) = 1+b2+b3+.......+ bd= O (bd)
• Space Complexity: Space complexity of BFS algorithm is given by the Memory size of
frontier which is O(bd).
• Completeness: BFS is complete, which means if the shallowest goal node is at some finite
depth, then BFS will find a solution.
• Optimality: BFS is optimal if path cost is a non-decreasing function of the depth of the
node.

10
IFETCE Regulation 2019A Academic Year: 2023-2024

Figure 2: Breadth First Search

2. Depth-first Search
• Depth-first search isa recursive algorithm for traversing a tree or graph data structure.
• It is called the depth-first search because it starts from the root node and follows each path
to its greatest depth node before moving to the next path.
• DFS uses a stack data structure for its implementation.
• The process of the DFS algorithm is similar to the BFS algorithm.
Advantages:
• DFS requires very less memory as it only needs to store a stack of the nodes on the path
from root node to the current node.
• It takes less time to reach to the goal node than BFS algorithm (if it traverses in the right
path).
Disadvantages:
• There is the possibility that many states keep re-occurring, and there is no guarantee of
finding the solution.
• DFS algorithm goes for deep down searching and sometime it may go to the infinite loop.
Example: In the below search tree, we have shown the flow of depth-first search, and it will
follow the order as:
Root node--->Left node ----> right node.
It will start searching from root node S, and traverse A, then B, then D and E, after
traversing E, it will backtrack the tree as E has no other successor and still goal node is
not found. After backtracking it will traverse node C and then G, and here it will terminate
as it found goal node.
Completeness: DFS search algorithm is complete within finite state space as it will expand
every node within a limited search tree.
Time Complexity: Time complexity of DFS will be equivalent to the node traversed by the
algorithm. It is given by:
T(n)= 1+ n2+ n3 +.........+ nm=O(nm)
Where, m= maximum depth of any node and this can be much larger than d (Shallowest
solution depth)
Space Complexity: DFS algorithm needs to store only single path from the root node, hence
space complexity of DFS is equivalent to the size of the fringe set, which is O(bm).
Optimal: DFS search algorithm is non-optimal, as it may generate a large number of steps or
high cost to reach to the goal node.

11
IFETCE Regulation 2019A Academic Year: 2023-2024

Figure 3: Depth First Search

3. Depth-Limited Search Algorithm:


• A depth-limited search algorithm is similar to depth-first search with a predetermined
limit. Depth-limited search can solve the drawback of the infinite path in the Depth-first
search. In this algorithm, the node at the depth limit will treat as it has no successor
nodes further.
• Depth-limited search can be terminated with two Conditions of failure:
➢ Standard failure value: It indicates that problem does not have any solution.
➢ Cutoff failure value: It defines no solution for the problem within a given depth limit.
Advantages:
Depth-limited search is Memory efficient.
Disadvantages:
• Depth-limited search also has a disadvantage of incompleteness.
• It may not be optimal if the problem has more than one solution.
Example:

Figure 4: Depth-limited search


Completeness: DLS search algorithm is complete if the solution is above the depth-limit.
Time Complexity: Time complexity of DLS algorithm is O(bℓ).
Space Complexity: Space complexity of DLS algorithm is O(b×ℓ).
Optimal: Depth-limited search can be viewed as a special case of DFS, and it is also not
optimal even if ℓ>d.

12
IFETCE Regulation 2019A Academic Year: 2023-2024

4. Uniform-cost Search Algorithm:


• Uniform-cost search is a searching algorithm used for traversing a weighted tree or graph.
This algorithm comes into play when a different cost is available for each edge.
• The primary goal of the uniform-cost search is to find a path to the goal node which has
the lowest cumulative cost.
• Uniform-cost search expands nodes according to their path costs form the root node. It
can be used to solve any graph/tree where the optimal cost is in demand.
• A uniform-cost search algorithm is implemented by the priority queue. It gives maximum
priority to the lowest cumulative cost. Uniform cost search is equivalent to BFS algorithm
if the path cost of all edges is the same.
Advantages:
• Uniform cost search is optimal because at every state the path with the least cost is chosen.
Disadvantages:
• It does not care about the number of steps involve in searching and only concerned about
path cost. Due to which this algorithm may be stuck in an infinite loop.
Example:
Completeness: Uniform-cost search is complete, such as if there is a solution, UCS will find
it.
Time Complexity: Let C* is Cost of the optimal solution, and ε is each step to get closer to
the goal node. Then the number of steps is = C*/ε+1. Here we have taken +1, as we start from
state 0 and end to C*/ε. Hence, the worst-case time complexity of Uniform-cost search isO(b1
+ [C*/ε])/.

Space Complexity: The same logic is for space complexity so, the worst-case space
complexity of Uniform-cost search is O(b1 + [C*/ε]).
Optimal: Uniform-cost search is always optimal as it only selects a path with the lowest path
cost.

Figure 5: Uniform-cost search


5. Iterative deepening depth-first Search:
• The iterative deepening algorithm is a combination of DFS and BFS algorithms. This
search algorithm finds out the best depth limit and does it by gradually increasing the limit
until a goal is found.

13
IFETCE Regulation 2019A Academic Year: 2023-2024

• This algorithm performs depth-first search up to a certain "depth limit", and it keeps
increasing the depth limit after each iteration until the goal node is found.
• This Search algorithm combines the benefits of Breadth-first search's fast search and depth-
first search's memory efficiency.
• The iterative search algorithm is useful uninformed search when search space is large, and
depth of goal node is unknown.
Advantages:
• It combines the benefits of BFS and DFS search algorithm in terms of fast search and
memory efficiency.
Disadvantages:
• The main drawback of IDDFS is that it repeats all the work of the previous phase.
Example: Following tree structure is showing the iterative deepening depth-first search.
IDDFS algorithm performs various iterations until it does not find the goal node. The
iteration performed by the algorithm is given as:
1'st Iteration-----> A
2'nd Iteration----> A, B, C
3'rd Iteration------>A, B, D, E, C, F, G
4'th Iteration------>A, B, D, H, I, E, C, F, K, G
In the fourth iteration, the algorithm will find the goal node.

Figure 6: iterative deepening depth-first search


Completeness: This algorithm is complete is ifthe branching factor is finite.
Time Complexity: Let's suppose b is the branching factor and depth is d then the worst-case
time complexity is O(bd).
Space Complexity: The space complexity of IDDFS will be O(bd).
Optimal: IDDFS algorithm is optimal if path cost is a non- decreasing function of the depth
of the node.
6. Bidirectional Search Algorithm:
Bidirectional search algorithm runs two simultaneous searches, one form initial state called as
forward-search and other from goal node called as backward-search, to find the goal node.
Bidirectional search replaces one single search graph with two small subgraphs in which one
starts the search from an initial vertex and other starts from goal vertex. The search stops when
these two graphs intersect each other. Bidirectional search can use search techniques such as
BFS, DFS, DLS, etc.

14
IFETCE Regulation 2019A Academic Year: 2023-2024

Advantages:
• Bidirectional search is fast.
• Bidirectional search requires less memory
Disadvantages:
• Implementation of the bidirectional search tree is difficult.
• In bidirectional search, one should know the goal state in advance.
Example: In the below search tree, bidirectional search algorithm is applied. This algorithm
divides one graph/tree into two sub-graphs. It starts traversing from node 1 in the forward
direction and starts from goal node 16 in the backward direction.
The algorithm terminates at node 9 where two searches meet.

Figure 7: Bidirectional Search


Completeness: Bidirectional Search is complete if we use BFS in both searches.
Time Complexity: Time complexity of bidirectional search using BFS is O(bd).
Space Complexity: Space complexity of bidirectional search is O(bd).
Optimal: Bidirectional search is Optimal.

2.2

2.3 LOCAL SEARCH ALGORITHMS AND OPTIMIZATION PROBLEMS


Local search algorithms are optimization algorithms that iteratively explore
the solution space by making incremental changes to a current solution. These
algorithms focus on improving the quality of solutions through local movements,
gradually moving towards an optimal or near-optimal solution. Local search is
particularly useful for optimization problems where the entire solution space is too
large to explore exhaustively.
In many optimization problems, the path to the goal is irrelevant; the goal state itself
is the solution. For example, in the 8-queens problem, what matters is the final configuration
of queens, not the order in which they are added. In such cases, we can use local search
algorithms. They operate using a single current state (rather than multiple paths) and
generally move only to neighbors of that state. The important applications of these class of

15
IFETCE Regulation 2019A Academic Year: 2023-2024

problems are (a) integrated-circuit design, (b) Factory-floor layout, (c) job-shop scheduling,
(d) automatic programming, (e) telecommunications network optimization, (f) Vehicle
routing, and (g) portfolio management.

Key advantages of Local Search Algorithms

(1) They use very little memory – usually a constant amount; and

(2) they can often find reasonable solutions in large or infinite(continuous) state spaces
for which systematic algorithms are unsuitable.
2.3.1 OPTIMIZATION PROBLEMS

In addition to finding goals, local search algorithms are useful for solving pure
optimization problems, in which the aim is to find the best state according to an objective
function.
State Space Landscape

Figure 10 A one dimensional state space landscape in which elevation


corresponds to the objective function. The aim is to find the global maximum.
Hill climbing search modifies the current state to try to improve it, as shown
by the arrow. The various topographic features are defined in the text
To understand local search, it is better explained using state space landscape as shown
in Figure 10. A landscape has both “location” (defined by the state) and “elevation” (defined
by the value of the heuristic cost function or objective function).
If elevation corresponds to cost, then the aim is to find the lowest valley – a global
minimum; if elevation corresponds to an objective function, then the aim is to find the highest
peak – a global maximum.
Local search algorithms explore this landscape. A complete local search algorithm
always finds a goal if one exists; an optimal algorithm always finds a global
minimum/maximum.

16
IFETCE Regulation 2019A Academic Year: 2023-2024

Hill-climbing search
The hill-climbing search algorithm as shown in figure, is simply a loop that continually
moves in the direction of increasing value – that is, uphill. It terminates when it reaches a
“peak” where no neighbor has a higher value.
function HILL-CLIMBING( problem) return a state that is a local maximum
input: problem, a problem
local variables: current, a node.
neighbor, a node.
current ←MAKE-NODE(INITIAL-STATE[problem])
loop do
neighbor ← a highest valued successor of current
if VALUE [neighbor] ≤ VALUE[current] then return STATE[current]
current ←neighbor

The hill-climbing search algorithm (steepest ascent version), which is the most basic
local search technique. At each step the current node is replaced
by the best neighbor; the neighbor with the highest VALUE. If the heuristic cost
estimate h is used, we could find the neighbor with the lowest h.
Hill-climbing is sometimes called greedy local search because it grabs a good neighbor
state without thinking ahead about where to go next. Greedy algorithms often perform quite
well.
Hill-climbing often gets stuck for the following reasons :
• Local maxima: a local maximum is a peak that is higher than each of its neighbouring
states, but lower than the global maximum. Hill-climbing algorithms that reach the
vicinity of a local maximum will be drawn upwards towards the peak, but will then be
stuck with nowhere else to go
• Ridges: A ridge is shown in Figure10. Ridges results in a sequence of local maxima
that is very difficult for greedy algorithms to navigate.
• Plateaux: A plateau is an area of the state space landscape where the evaluation
function is flat. It can be a flat local maximum, from which no uphill exit exists, or a
shoulder, from which it is possible to make progress.

17
IFETCE Regulation 2019A Academic Year: 2023-2024

Figure 11 Illustration of why ridges cause difficulties for hill-climbing. The grid of
states(dark circles) is superimposed on a ridge rising from left to right, creating a
sequence of local maxima that are not directly connected to each other. From each
local maximum, all the available options point downhill.

Hill-climbing variations
 Stochastic hill-climbing
 Random selection among the uphill moves.
o The selection probability can vary with the steepness of the uphill move.
 First-choice hill-climbing cfr.
 stochastic hill climbing by generating
successors randomly until a better one is found.
 Random-restart hill-climbing
 Tries to avoid getting stuck in local maxima.
Simulated annealing search
A hill-climbing algorithm that never makes “downhill” moves towards states with
lower value (or higher cost) is guaranteed to be incomplete, because it can stuck on a local
maximum. In contrast, a purely random walk –that is, moving to a successor choosen
uniformly at random from the set of successors – is complete, but extremely inefficient.
Simulated annealing is an algorithm that combines hill-climbing with a random walk
in someway that yields both efficiency and completeness.
Figure shows simulated annealing algorithm. It is quite similar to hill climbing. Instead
of picking the best move, however, it picks the random move. If the move improves the
situation, it is always accepted. Otherwise, the algorithm accepts the move with some
probability less than 1. The probability decreases exponentially with the “badness” of the
move – the amount E by which the evaluation is worsened. Simulated annealing was first
used extensively to solve VLSI layout problems in the early 1980s. It has been applied widely
to factory scheduling and other large-scale optimization tasks.

18
IFETCE Regulation 2019A Academic Year: 2023-2024

The simulated annealing search algorithm, a version of stochastic hill climbing


where some downhill moves are allowed.

Genetic algorithms

A Genetic algorithm (or GA) is a variant of stochastic beam search in which successor
states are generated by combining two parent states, rather than by modifying a single state

Like beam search, Gas begin with a set of k randomly generated states, called the
population. Each state, or individual, is represented as a string over a finite alphabet – most
commonly, a string of 0s and 1s. For example, an 8 8-quuens state must specify the positions
of 8 queens, each in a column of 8 squares, and so requires 8 x log2 8 = 24 bits.

Figure 12 Genetic algorithm

Figure 12 shows a population of four 8-digit strings representing 8-queen states. The
production of the next generation of states is shown in Figure

In (b) each state is rated by the evaluation function or the fitness function.

In (c),a random choice of two pairs is selected for reproduction, in accordance with
the probabilities in (b).

this describes the algorithm that implements all these steps.

19
IFETCE Regulation 2019A Academic Year: 2023-2024

function GENETIC_ALGORITHM( population, FITNESS-FN) return an individual


input: population, a set of individuals
FITNESS-FN, a function which determines the quality of the
individual repeat new_population←empty set
loop for ifrom 1 to SIZE(population) do
x ←RANDOM_SELECTION(population, FITNESS_FN)
y ←RANDOM_SELECTION(population,FITNESS_FN)

z child ←REPRODUCE(x,y)

if (small random probability) then child


MUTATE(child ) add child to new_population
population ←new_population until some individual is fit
enough or enough time has elapsed return the best individual

A genetic algorithm.

2.4 SEARCHING WITH PARTIAL OBSERVATIONS


Now turn to the problem of partial observability, where the agent’s percepts do not
suffice to pin down the exact state. If the agent is in one of several possible states, then an
action may lead to one of several possible outcomes—even if the environment is
deterministic. The key concept required for solving partially observable problems is the
belief state, representing the agent’s current belief about the possible physical states it might
be in, given the sequence of actions and percepts up to that point. We begin with the
simplest scenario for studying belief states, which is when the agent has no sensors at all;
then we add in partial sensing as well as nondeterministic actions.

2.4.1 Searching with no observation


❖ When the agent’s percepts provide no information at all, we have what is called a sensor-
less problem or sometimes a conformant problem. At first, one might think the sensorless
❖ agent has no hope of solving a problem if it has no idea what state it’s in; in fact, sensorless
problems are quite often solvable.
❖ Moreover, sensorless agents can be surprisingly useful, primarily because they don’t rely
on sensors working properly. In manufacturing systems, for example, many ingenious
methods have been developed for orienting parts correctly from an unknown initial
position by using a sequence of actions with no sensing at all.
❖ The high cost of sensing is another reason to avoid it: for example, doctors often prescribe
a broad- spectrum antibiotic rather than using the contingent plan of doing an expensive
blood test, then waiting for the results to come back, and then prescribing a more specific
antibiotic and perhaps hospitalization because the infection has progressed too far.
❖ We can make a sensorless version of the vacuum world. Assume that the agent knows the
geography of its world, but doesn’t know its location or the distribution of dirt. In that case,
its initial state could be any element of the set {1, 2, 3, 4, 5, 6, 7, 8}. Now, consider what
happens if it tries the action Right.
❖ This will cause it to be in one of the states {2, 4, 6, 8}—the agent now has more
information! Furthermore, the action sequence [Right,Suck] will always end up in one of

20
IFETCE Regulation 2019A Academic Year: 2023-2024

the states {4, 8}. Finally, the sequence [Right,Suck,Left,Suck] is guarante to reach the goal
state 7 no matter what the start state. We say that the agent can coerce the world into
state 7.
❖ To solve sensorless problems, we search in the space of belief states rather than
physical states. Notice that in belief-state space (figure 13), the problem is fully observable
because the agent always knows its own belief state. Furthermore, the solution (if any) is
always a sequence of actions.

Figure 13
❖ This is because, the precepts received after each action are completely predictable—
they’re always empty! So there are no contingencies to plan for. This is true even if the
environment is non-deterministic.
❖ It is instructive to see how the belief-state search problem is constructed. Suppose the
underlying physical problem P is defined by ACTIONSP , RESULTP , GOAL-TEST P ,
and STEP-COST P .

Then we can define the corresponding sensorless problem as follows:

• Belief states: The entire belief-state space contains every possible set of physical states.
If P has N states, then the sensorless problem has up to 2N states, although many may
be unreachable from the initial state.
• Initial state: Typically the set of all states in P , although in some cases the agent will
have more knowledge than this.

21
IFETCE Regulation 2019A Academic Year: 2023-2024

• Goal test: The agent wants a plan that is sure to work, which means that a belief state
satisfies the goal only if all the physical states in it satisfy GOAL-TESTP . The agent may
accidentally achieve the goal earlier, but it won’t know that it has done so.
• Path cost: This is also tricky. If the same action can have different costs in different states,
then the cost of taking an action in a given belief state could be one of several values.

Searching with observations


• For a general partially observable problem, they have to specify how the environment
generates percepts for the agent. For example, they might define the local-sensing
vacuum world to be one in which the agent has a position sensor and a local dirt sensor
but has no sensor capable of detecting dirt in other squares.
• The formal problem specification includes a PERCEPT(s) function that returns the
percept received in a given state. (If sensing is nondeterministic, then they use a
PERCEPTS function that returns a set of possible percepts.) For example, in the local-
sensing vacuum world, the PERCEPT in state 1 is [A, Dirty]. Fully observable
problems are a special case in which PERCEPT(s) = s for every state s, while
sensorless problems are a special case in which PERCEPT(s) = null.
• When observations are partial, it will usually be the case that several states could have
produced any given percept. For example, the percept [A, Dirty] is produced by state
3 as well as by state 1. Hence, given this as the initial percept, the initial belief state
for the local-sensing vacuum world will be {1, 3}. The ACTIONS, STEP-COST, and
GOAL-TEST are constructed from the underlying physical problem just as for
sensorless problems, but the transition model is a bit more complicated. We can think
of transitions from one belief state to the next for a particular action as occurring in
three stages, as shown in Figure 14:

22
IFETCE Regulation 2019A Academic Year: 2023-2024

Figure 14

2.5 CONSTRAINT SATISFACTION PROBLEMS


Constraint satisfaction is a technique where a problem is solved when its values satisfy
certain constraints or rules of the problem. Such type of technique leads to a deeper
understanding of the problem structure as well as its complexity.
A constraint satisfaction problem consists of three components, X, D, and C:
• X is a set of variables, {X1, . . . , Xn}.
• D is a set of domains, {D1, . . . , Dn}, one for each variable.
• C is a set of constraints that specify allowable combinations of values.
Each domain Di consists of a set of allowable values, {v1, . . . , vk } for variable Xi.
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. A relation can be represented as an explicit list of all tuples of values that satisfy the
constraint, or as an abstract relation that supports two operations: testing if a tuple is a member
of the relation and enumerating the members of the relation. For example, if X1 and X2 both
have the domain {A,B}, then the constraint saying the two variables must have different values
can be written as (X1 , X2), [(A, B), (B, A)] or as (X1 , X2), X1 = X2 .
To solve a CSP, a state space and the notion of a solution should be defined. 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
23
IFETCE Regulation 2019A Academic Year: 2023-2024

to a CSP is a consistent, complete assignment. A partial assignment is one that assigns values
to only some of the variables.
Example problem: Map colouring
For 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
X = {WA,NT,Q,NSW,V,SA,T} .
The domain of each variable is the set Di = {red , green, blue}. The constraints require
neighboring regions to have distinct colors. Since there are nine places where regions border,
there are nine constraints:
= {SA = WA, SA = NT, SA = Q, SA = NSW,SA = V, WA = NT,NT = Q,Q
= NSW,NSW = V} .
Here we are using abbreviations; SA = WA is a shortcut for (SA, WA), SA = WA , where
SA = WA can be fully enumerated in turn as {(red , green), (red , blue), (green , red ), (green
, blue), (blue, red ), (blue, green)} .
There are many possible solutions to this problem, such as
{WA = red , NT = green, Q = red , NSW = green, V = red , SA = blue, T = red }.
It can be helpful to visualize a CSP as a constraint graph, as the nodes of the
graph correspond to variables of the problem, and a link connects any two variables that
participate in a constraint.

Figure 15 The principal states and territories of Australia. Colouring this map can be
viewed as a constraint satisfaction problem (CSP)

An example is provided by cryptarithmetic puzzles. Each letter in a cryptarithmetic


puzzle represents a different digit as shown in the Figure 3.2. For the case in this would be
represented as the global constraint Alldiff (F, T , U, W, R, O). The addition constraints on the
four columns of the puzzle can be written as the following n-ary constraints:
O+O=R+10•C10
C10+W +W =U +10•C100
C100+T +T =O+10•C1000
C1000 = F ,
where C10, C100, and C1000 are auxiliary variables representing the digit carried
over into the tens, hundreds, or thousands column. These constraints can be represented in a
constraint hypergraph, such as the one shown in Figure 3.2. A hypergraph consists of ordinary
nodes (the circles in the figure) and hypernodes (the squares), which represent n-ary
constraints. Every finite-domain constraint can be reduced to a set of binary constraints if
enough auxiliary variables are introduced, so it transforms any CSP into one with only binary
constraints; this makes the algorithms simpler. Another way to convert an n-ary CSP to a
binary one is the dual graph transformation is to create a new graph in which there will be
one variable for each constraint in the original graph, and one binary constraint for each pair
of constraints in the original graph that share variables.
24
IFETCE Regulation 2019A Academic Year: 2023-2024

For example, if the original graph has variables {X, Y, Z} and constraints (X, Y, Z),
C1 and (X, Y), C2 then the dual graph would have variables {C1, C2} with the binary
constraint (X, Y), R1, where (X,Y) are the shared variables and R1 is a new relation that
defines the constraint between the shared variables, as specified by the original C1 and C2.

Figure 15 A cryptarithmetic problem and the constraint hypergraph for the


cryptarithmetic problem

2.6 CONSTRAINT PROPAGATION


CSP gives a choice of an algorithm can search (choose a new variable assignment
from several possibilities) or do a specific type of inference called constraint propagation:
using the constraints to reduce the number of legal values for a variable, which in turn can
reduce the legal values for another variable, and so on. Constraint propagation may be
intertwined with search, or it may be done as a pre-processing step, before search starts.
Sometimes this pre-processing can solve the whole problem, so no search is required at all.
2.6.1 Node consistency
A single variable (corresponding to a node in the CSP network) is node-consistent
if all the values in the variable’s domain satisfy the variable’s unary constraints. It is always
possible to eliminate all the unary constraints in a CSP by running node consistency. It is also
possible to transform all n-ary constraints into binary ones.
2.6.2 Arc consistency
A variable in a CSP is arc-consistent if every value in its domain satisfies the
variable’s binary constraints. More formally, Xi is arc-consistent with respect to another
variable Xj if for every value in the current domain Di there is some value in the domain Dj
that satisfies the binary constraint on the arc (Xi, Xj). A network is arc-consistent if every
variable is arc consistent with every other variable.
For example, consider the constraint Y = X2 where the domain of both X and Y is
the set of digits. The explicit constraint will be as
(X, Y), {(0, 0), (1, 1), (2, 4), (3, 9))} .
To make X arc-consistent with respect to Y, X’s domain will be reduced to {0, 1, 2,
3}. The Y arc-consistent with respect to X, then Y’s domain becomes {0, 1, 4, 9} and the
whole CSP is arc-consistent. On the other hand, arc consistency can do nothing for the
Australia map-colouring problem.
Consider the following inequality constraint on (SA, WA):
{(red, green), (red, blue), (green, red), (green, blue), (blue, red), (blue, green)}.

25
IFETCE Regulation 2019A Academic Year: 2023-2024

Figure 15 The arc-consistency algorithm AC-3

➢ No matter what value you choose for SA (or for WA), there is a valid value for the
other variable. So applying arc consistency has no effect on the domains of either
variable.
➢ The most popular algorithm for arc consistency is called AC-3 to make every variable
arc-consistent; the AC-3 algorithm maintains a queue of arcs to consider.
➢ Initially, the queue contains all the arcs in the CSP. AC-3 then pops off an arbitrary
arc (Xi, Xj) from the queue and makes Xi arc-consistent with respect to Xj.
➢ If this leaves Di unchanged, the algorithm just moves on to the next arc. The
complexity of AC-3 can be analysed as follows. Assume a CSP with n variables, each
with domain size at most d, and with c binary constraints (arcs).
➢ Each arc (Xk, Xi) can be inserted in the queue only d times because Xi has at most d
values to delete. Checking consistency of an arc can be done in O(d2) time, so we get
O(cd3) total worst-case time.
➢ A variable Xi is generalized arc consistent with respect to an n-ary constraint if for
every value v in the domain of Xi there exists a tuple of values that is a member of the
constraint, has all its values taken from the domains of the corresponding variables,
and has its Xi component equal to v.
➢ For example, if all variables have the do-main {0, 1, 2, 3}, then to make the variable
X consistent with the constraint X < Y < Z, we would have to eliminate 2 and 3 from
the domain of X because the constraint cannot be satisfied when X is 2 or 3.
2.6.3 Path consistency
➢ Path consistency is a property similar to arc consistency, but considers pairs of variables
instead of only one. A pair of variables is path-consistent with a third variable if each
consistent evaluation of the pair can be extended to the other variable in such a way that
all binary constraints are satisfied.
2.6.4 K-consistency
A CSP is k-consistent if, for any set of k − 1 variables and for any consistent
assignment to those variables, a consistent value can always be assigned to any kth variable.
1-consistency says that, given the empty set, we can make any set of one variable consistent:

26
IFETCE Regulation 2019A Academic Year: 2023-2024

this is what we called node consistency. 2-consistency is the same as arc consistency. For
binary constraint networks, 3-consistency is the same as path consistency.
A CSP is strongly k-consistent if it is k-consistent and is also (k − 1)-consistent, (k
− 2)-consistent, all the way down to 1-consistent. Now suppose we have a CSP with nodes
and make it strongly n-consistent (i.e., strongly k-consistent for k = n).
2.6.5 Global constraints
Global constraints occur frequently in real problems and can be handled by special-
purpose algorithms that are more efficient than the general-purpose methods described so far.
For example, the Alldiff constraint says that all the variables involved must have distinct
values (as in the crypt arithmetic problem above and Sudoku puzzles be-low). One simple
form of inconsistency detection for Alldiff constraints works as follows: if m variables are
involved in the constraint, and if they have n possible distinct values alto-gather, and m > n,
then the constraint cannot be satisfied.
This leads to the following simple algorithm: First, remove any variable in the constraint that
has a singleton domain, and delete that variable’s value from the domains of the remaining
variables. Repeat as long as there are singleton variables. If at any point an empty domain is
produced or there are more variables than domain values left, then an inconsistency has been
detected.

2.6.6 Sudoku example


The popular Sudoku puzzle has introduced millions of people to constraint
satisfaction problems, although they may not recognize it. A Sudoku board consists of 81
squares, some of which are initially filled with digits from 1 to 9. The puzzle is to fill in all
the remaining squares such that no digit appears twice in any row, column, or 3 × 3 box (see
Figure 16). A row, column, or box is called a unit. A Sudoku puzzle can be considered a CSP
with 81 variables, one for each square. We use the variable names A1 through A9 for the top
row (left to right), down to I1 through I9 for the bottom row. The empty squares have the
domain {1, 2, 3, 4, 5, 6, 7, 8, 9} and the pre-filled squares have a domain consisting of a single
value. In addition, there are 27 different.
Alldiff constraints: one for each row, column, and box of 9 squares.

Alldiff (A1, A2, A3, A4, A5, A6, A7, A8, A9)
Alldiff (B1, B2, B3, B4, B5, B6, B7, B8, B9)
•••
Alldiff (A1, B1, C1, D1, E1, F 1, G1, H1, I1)
Alldiff (A2, B2, C2, D2, E2, F 2, G2, H2, I2)
•••
Alldiff (A1, A2, A3, B1, B2, B3, C1, C2, C3)
Alldiff (A4, A5, A6, B4, B5, B6, C4, C5, C6)
•••

All the strategies—arc consistency, path consistency, etc.—apply generally to all CSPs, not
just to Sudoku problems. Even, naked triples are really a strategy for enforcing consistency
of Alldiff constraints and have nothing to do with Sudoku. This is the power of the CSP
formalism: for each new problem area, need to define the problem in terms of constraints;
then the general constraint-solving mechanisms can take over.

27
IFETCE Regulation 2019A Academic Year: 2023-2024

Figure 16 Sudoku Puzzle

2.7 BACKTRACKING SEARCH FOR CSPS


Backtracking search: A depth-first search that chooses values for one variable at a time
and backtracks when a variable has no legal values left to assign. Backtracking algorithm
repeatedly chooses an unassigned variable, and then tries all values in the domain of that
variable in turn, trying to find a solution. Sudoku problems are designed to be solved by
inference over constraints. But many other CSPs cannot be solved by inference alone. The
following methods are also followed to make it work.
2.7.1 Commutativity
A problem is commutative if the order of application of any given set of actions
has no effect on the outcome. CSPs are commutative because when assigning values to
variables, we reach the same partial assignment regardless of order. The consideration of a
single variable at each node in the search tree. For example, at the root node of a search tree
for colouring the map of Australia, we might make a choice between SA = red, SA = green,
and SA = blue, but we would never choose between SA = red and WA = blue. With this
restriction, the number of leaves is dn, as we would hope.

Figure 17 A simple backtracking algorithm for constraint satisfaction


problems
Addition of some sophistication to the unspecified functions by using them to address the
following questions:

28
IFETCE Regulation 2019A Academic Year: 2023-2024

Figure 18 Part of the search tree for the map-coloring problem

• What inferences should be performed at each step in the search (INFERENCE)?


• When the search arrives at an assignment that violates a constraint, can the search avoid
repeating this failure?
The subsections that follow answer each of these questions in turn.
Variable and value ordering
The backtracking algorithm contains the line
var ← SELECT-UNASSIGNED-VARIABLE(csp) .
The simplest strategy for select-unassigned-variable is to choose the next unassigned
variable in order, {X1, X2 . . .}. This static variable ordering seldom results in the most
efficient search. For example, after the assignments for WA = red and NT = green in Figure
18, there is only one possible value for SA, so it makes sense to assign SA = blue next rather
than assigning Q. In fact, after SA is assigned, the choices for Q, NSW, and V are all forced.
This intuitive idea—choosing the variable with the fewest “legal” values—is called the
minimum-remaining-values (MRV) heuristic. It also has been called the “most constrained
variable” or “fail-first” heuristic, the latter because it picks a variable that is most likely to
cause a failure soon, thereby pruning the search tree. Once a variable has been selected, the
algorithm must decide on the order in which to examine its values. For this, the least-
constraining-value heuristic can be effective in some cases. It prefers the value that rules out
the fewest choices for the neighbouring variables in the constraint graph.
3.7.2 Interleaving search and inference
➢ One of the simplest forms of inference is called forward checking. Whenever a variable
X is assigned, the forward-checking process establishes arc consistency for it: for each
unassigned variable Y that is connected to X by a constraint, delete from Y’s domain
any value that is inconsistent with the value chosen for X.
➢ Because forward checking only does arc consistency inferences, there is no reason to
do forward checking if we have already done arc consistency as a pre-processing step.
There are two important points to notice in Figure 3.7.
➢ First, notice that after WA = red and Q = green are assigned, the domains of NT and
SA are reduced to a single value; we have eliminated branching on these variables
altogether by propagating information from WA and Q.
➢ A second point to notice is that after V = blue, the do-main of SA is empty. Hence,
forward checking has detected that the partial assignment {WA = red, Q = green, V =
blue} is inconsistent with the constraints of the problem, and the algorithm will
therefore backtrack immediately.

29
IFETCE Regulation 2019A Academic Year: 2023-2024

For many problems the search will be more effective if we combine the MRV heuristic
with forward checking. In Figure 19 after assigning {WA = red}. Intuitively, it seems that that
assignment constrains its neighbours, NT and SA, so we should handle those variables next,
and then all the other variables will fall into place. That’s exactly what hap-pens with MRV:
NT and SA have two values, so one of them is chosen first, then the other, then Q, NSW, and
V in order. Finally T still has three values, and any one of them works. We can view forward
checking as an efficient way to incrementally compute the information that the MRV heuristic
needs to do its job.

Figure 19 The progress of a map-colouring search with forward checking

Although forward checking detects many inconsistencies, it does not detect all of them.
The problem is that it makes the current variable arc-consistent, but doesn’t look ahead and
make all the other variables arc-consistent. For example, consider the third row of Figure 3.7.
It shows that when WA is red and Q is green, both NT and SA are forced to be blue. Forward
checking does not look far enough ahead to notice that this is an inconsistency: NT and SA
are adjacent and so cannot have the same value.
The algorithm called MAC (for Maintaining Arc Consistency (MAC)) detects this
inconsistency. After a variable Xi is assigned a value, the INFERENCE procedure calls AC-
3, but instead of a queue of all arcs in the CSP, we start with only the arcs (Xj , Xi) for all Xj
that are unassigned variables that are neighbours of Xi. From there, AC-3 does constraint
propagation in the usual way, and if any variable has its domain reduced to the empty set, the
call to AC-3 fails and we know to backtrack immediately. MAC is strictly more powerful than
forward checking because forward checking does the same thing as MAC on the initial arcs
in MAC’s queue; but unlike MAC, forward checking does not recursively propagate
constraints when changes are made to the domains of variables.

30
IFETCE Regulation 2019A Academic Year: 2023-2024

IFET COLLEGE OF ENGINEERING


(An Autonomous Institution)
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

SUBJECT TITLE: Foundations of AI UNIT: II


SUBJECT CODE: 19UCSPEX01 YEAR/SEM: III/VI

UNIT-II PROBLEM SOLVING METHODS


Problem solving Methods - Search Strategies- Uninformed - Informed - Heuristics - Local
Search Algorithms and Optimization Problems - Searching with Partial Observations -
Constraint Satisfaction Problems - Constraint Propagation - Backtracking Search
PART-A
Problem solving Methods - Search Strategies- Uninformed - Informed – Heuristics
1. State why problem formulation must follow goal formulation. 2 U
2. Give the elements of a search-based problem solver with their meaning 2 U
3. What are the performance measures used for analysing the search 2 U
algorithms?
4. List some of the uniformed search techniques. 2 R
5. Differentiate between uniformed and informed search algorithms 2 U
6. Will breadth first search always find the minimal solution. Why? 2 A
7. Give an example of a problem for which breadth- first search would work 2 A
better than depth first search.
8. How DFS may expand the same state many times via different paths in an 2 A
acyclic state space?
9. Differentiate BFS and DFS. 2 U
10. What is the advantage and disadvantage of the best first search technique? 2 U
11. Define heuristics function. 2 R
12. Write the significance of using heuristic function in search algorithm 2 S
13. What is the importance of optimal solution? 2 R
14. Create a graph on Depth-first search on a binary tree. 2 A
15. Give the real time application of A*. 2 A
16. Is a way to leverage machine learning to reduce DFS/BFS search time on a 2 A
tree graph?
17. The missionaries and cannibals problem is usually stated as follows. Three 2 A
missionaries and three cannibals are on one side of a river, along with a
boat that can hold one two people. Find a way to get everyone to the other
side without ever leaving a group of missionaries in one place outnumbered
by the cannibals in that place.
IFETCE Regulation 2019A Academic Year: 2023-2024

Local Search Algorithms and Optimization Problems - Searching with Partial


Observations
18. Evaluate consistent and complete assignment 2 U
19. Give five examples of symbols in the map language. 2 S
20. Write down the uses of constraint propagation. 2 R
21. Write short notes on Arc consistency. 2 R
22. How can you say that the arc consistency will not make enough inferences? 2 A
Justify it.
23. Justify your answer by relating Sudoku to constraint satisfaction problem? 2 A
24. Justify your answer on how hard is it to solve CSPs? 2 A
25. Enumerate the steps to do CSP search? 2 S
26. How does min-conflicts solve n-queens problem? 2 S
Constraint Satisfaction Problems - Constraint Propagation - Backtracking Search
27. List the way to formulate constraint satisfaction problem. 2 U
28. List out the classification of CSP with respect to constraints. 2 U
29. What is backtracking search? 2 R
30. Provide a sudoku puzzle problem how the backtracking algorithm helps to 2 A
finding a solution.
PART-B
1. i) What is uniformed search? Explain depth first search and 10 R
breadth first search with an example
ii) Give the algorithm for best first search with an example. 6 R
2. Explain backtrack searching for constraint satisfaction problem for Map 16 U
Coloring problem.
3. Explain the constraint satisfaction procedure to solve the cryptarithmetic 16 A
problem
C R O S S
+ R O A D S
D A N G E R
4. i) How will you solve n-Queens problem using backtracking 8 S
method? Explain the algorithm and state space tree that is
generated.
ii) State the constraint satisfaction problem. Outline local search 8 U
for constraint satisfation problem with an example.
5. A farmer has to cross a river with his fox, goose and grain. Each trip, his 16 A
boat can only carry himself and one of his possessions. How can he cross
the river if an unguarded fox eats can he cross the river if an unguarded fox
eats the goose and an unguarded goose the grain
i. Find a good representation.
ii. Perform Depth-first search (search tree)
iii. Perform Breadth-first search (search tree)
6. i) What is simulated annealing? Explain the use of stimulated 8 S
annealing in solving any real-world problem.
ii) Explain the Iterative deepening depth first search algorithm with 8 U
an example.
7. For the below given search graph, answer the following: 16 S
Here S is the start node and G is the goal node
i) What is the path found by the BFS algorithm?
ii) List the order in which the depth first search algorithm inspects
the nodes.
IFETCE Regulation 2019A Academic Year: 2023-2024

iii) What is the path found by DFS algorithm?


iv) What is the path found by DFID algorithm?

8. Slove the 8-Puzzle problem using A* algorithm 16 A

Find the most cost-effective path to reach the final state from initial state
using A* Algorithm.
IFETCE Regulation 2019A Academic Year: 2023-2024

IFET COLLEGE OF ENGINEERING


(An Autonomous Institution)
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

SUBJECT TITLE: Foundations of AI UNIT: II


SUBJECT CODE: 19UCSPEX01 YEAR/SEM: III/VI

UNIT-II PROBLEM SOLVING METHODS


Problem solving Methods - Search Strategies- Uninformed - Informed - Heuristics - Local
Search Algorithms and Optimization Problems - Searching with Partial Observations -
Constraint Satisfaction Problems - Constraint Propagation - Backtracking Search
PART-A
6. Will breadth first search always find the minimal solution. Why?
Completeness: BFS is complete for finite graphs, meaning it will always find a
solution if one exists.
Minimal Spanning Tree: BFS can be used to find the minimal spanning tree of a graph,
which is a tree that spans all the nodes with the minimum possible number of edges.
Connectivity: BFS can be employed to determine the connectivity of a graph,
identifying whether there are disjoint components and how they are connected.
8. How DFS may expand the same state many times via different paths in an acyclic
state space?
• For acyclic state spaces it may end up expanding the same state many times via
different paths, but will (eventually) systematically explore the entire space. Let's
say we have this search space, where you start at AA and the goal is EE.
A -> B -> C -> D
A -> C -> D
A -> E
• If the nodes are at the same depth, let's assume that you expand them
alphabetically; so, in the search space above, you expand first B and then C,
because B comes before C (in the English alphabet).
• It can go directly to C from A or it can go to C by first going to B. C has a child.
When you expand C, basically, you try the possible actions from C. In this case,
there's only one action, i.e. going to D. So, without keeping track that you
expanded C, when you got there from B, after you backtracked from D the first
time, you will try again to expand C. In the graph search, this would not be
possible because, the first time we expand C, we add it to the explored set, so we
don't expand it again.
14 Create a graph on Depth-first search on a binary tree.
IFETCE Regulation 2019A Academic Year: 2023-2024

15 Give the real time application of A*.


Network Routing: A* is applied in computer networks for routing packets from a
source to a destination. It helps determine the most efficient path through the
network, considering factors like latency and bandwidth.
Traffic Engineering: A* can be employed in traffic engineering to optimize traffic
signal timings and control systems. It assists in finding the most efficient routes for
minimizing congestion and improving traffic flow.
Biomedical Image Processing: A* can be applied in biomedical image processing
for tracing pathways in biological structures, such as blood vessels or neural
networks. It aids in analyzing complex structures within medical images.
16 Is a way to leverage machine learning to reduce DFS/BFS search time on a tree
graph?

And then inserted into a tree graph according to similarity. A new node is
created with an edge connecting the most similar vertex node found in the entire tree
graph.

17 The missionaries and cannibals problem is usually stated as follows. Three


missionaries and three cannibals are on one side of a river, along with a boat
that can hold one two people. Find a way to get everyone to the other side
without ever leaving a group of missionaries in one place outnumbered by the
cannibals in that place.
IFETCE Regulation 2019A Academic Year: 2023-2024

Here, Actions are taken as

22 How can you say that the arc consistency will not make enough inferences? Justify
it.
➢ Problem structures have been proven that limited higher order consistency
processing is sufficient to leave only back track free search. However, the
efficiency of obtaining even moderately high order consistency processing can
be problematic in practice.
➢ Inference methods utilize very restricted forms of higher order consistency.
Partial higher order consistency in a manner targeted to take advantage of the
semantic and syntactic structure of a specific class of problems. Transitivity
method implements a form of partial path consistency. Other methods can
implement even higher order consistency in a restricted manner that limits
their complexity.

23 Justify your answer by relating Sudoku to constraint satisfaction problem?


• Variables: The variables will be each cell on the grid.
• Domain: The domain will be any digit from 1 to GRIDSIZE. If GRIDSIZE >9, I will
use letters from 'A' to.. However much I need, where 'A' equals to 10, 'B' to 11, and so
on.
• Constraints: The constraints are:
o i. Same digit (or letter) can't appear twice (or more) in the same row.
o ii. Same digit (or letter) can't appear twice (or more) in the same column.
Iii. Same digit (or letter) can't appear twice (or more) in the same region.
24 Justify your answer on how hard is it to solve CSPs?
➢ CSP often exhibits high complexity, requiring a combination
of heuristics and combinatorial search methods to be solved in a reasonable
time.
➢ Even the simplest problem of determining whether or not a model exists in a
general CSP with finite domains is NP-hard.
➢ There is no known algorithm with worst case polynomial runtime and hope to
find an algorithm that is polynomial for all CSPs.
Finding efficient (polynomial) consistency algorithms that reduce the size of the
search space identify special cases for which algorithms are efficient work on
IFETCE Regulation 2019A Academic Year: 2023-2024

approximation algorithms that can find good solutions quickly, even though they
may offer no theoretical guarantees find algorithms that are fast on typical (not worst
case) cases.
30 Provide a sudoku puzzle problem how the backtracking algorithm helps to finding
a solution.
Backtracking search is employed to systematically explore the solution space by
making assignments to variables and backtracking when a constraint is violated. The
algorithm explores different possible combinations until a valid assignment for the
entire Sudoku grid is found.

PART-B
3 Explain the constraint satisfaction procedure to solve the cryptarithmetic A
problem
C R O S S
+ R O A D S
D A N G E R
Solution
IFETCE Regulation 2019A Academic Year: 2023-2024

5 A farmer has to cross a river with his fox, goose and grain. Each trip, his boat 16
can only carry himself and one of his possessions. How can he cross the river if
an unguarded fox eats can he cross the river if an unguarded fox eats the goose
and an unguarded goose the grain
i. Find a good representation.
ii. Perform Depth-first search (search tree)
iii. Perform Breadth-first search (search tree)
IFETCE Regulation 2019A Academic Year: 2023-2024
IFETCE Regulation 2019A Academic Year: 2023-2024

8 Slove the 8-Puzzle problem using A* algorithm

Find the most cost-effective path to reach the final state from initial state using
A* Algorithm.
Solution-
Consider g(n) = Depth of node and h(n) = Number of misplaced tiles
• A* Algorithm maintains a tree of paths originating at the initial state.
• It extends those paths one edge at a time.
• It continues until final state is reached.
IFETCE Regulation 2019A Academic Year: 2023-2024
IFETCE R2019 Academic Year 2023-2024

IFET COLLEGE OF ENGINEERING


(An Autonomous Institution)
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

SUBJECT TITLE: Foundations of AI UNIT: II


SUBJECT CODE: 19UCSPEX01 YEAR/SEM: III/VI

UNIT-III KNOWLEDGE REPRESENTATION


First Order Predicate Logic – Prolog Programming – Unification – Forward Chaining-
Backward Chaining – Resolution – Knowledge Representation – Ontological Engineering-
Categories and Objects – Events – Mental Events and Mental Objects – Reasoning Systems for
Categories – Reasoning with Default Information
3.1 First order predicate logic
FOL is a mode of representation in Artificial Intelligence. It is an extension of PL. FOL
represents natural language statements in a concise way. FOL is also called predicate logic. It
is a powerful language used to develop information about an object and express the relationship
between objects.
FOL not only assumes that does the world contains facts (like PL does), but it also assumes
the following:
o Objects: A, B, people, numbers, colors, wars, theories, squares, pit, etc.
o Relations: It is unary relation such as red, round, sister of, brother of, etc.
o Function: father of, best friend, third inning of, end of, etc.
First order logic is specifying more precisely the way in which the possible worlds of first-
order logic reflect the ontological commitment to objects and relations. Then we introduce the
various elements of the language.
Models for first-order logic
• The models of a logical language are the formal structures that constitute the possible
worlds under consideration. Each model links the vocabulary of the logical sentences to
elements of the possible world, so that the truth of any sentence can be determined.
• Thus, models for propositional logic link proposition symbols to predefined truth values.
Models for first-order logic are much more interesting.
• The domain of a model is the set of objects or domain elements it contains. The do- main
is required to be nonempty—every possible world must contain at least one object.
• Mathematically speaking, it doesn’t matter what these objects are—all that matters is how
many there are in each particular model—but for pedagogical purposes we’ll use a concrete
example.
• Figure 3.1 shows a model with five objects: Richard the Lionheart, King of England from
1189 to 1199; his younger brother, the evil King John, who ruled from 1199 to 1215; the
left legs of Richard and John; and a crown.
• The objects in the model may be related in various ways. In the figure, Richard and John
are brothers. Formally speaking, a relation is just the set of tuples of objects that are related.

1
IFETCE R2019 Academic Year 2023-2024

Figure 3.1 A model containing five objects, two binary relations, three unary relations
(indicated by labels on the objects), and one unary function, left-leg.
• Thus, the brotherhood relation in this model is the set
{Richard the Lionheart, King John, King John, Richard the Lionheart} (1)
• The crown is on King John’s head, so the “on head” relation contains just one tuple, the
crown, King John. The “brother” and “on head” relations are binary relations—that is, they
relate pairs of objects. The model also contains unary relations, or properties: the “person”
property is true of both Richard and John; the “king” property is true only of John
(presumably because Richard is dead at this point); and the “crown” property is true only
of the crown.
• Certain kinds of relationships are best considered as functions, in that a given object must
be related to exactly one object in this way. For example, each person has one left leg, so
the model has a unary “left leg” function that includes the following mappings:
{Richard the Lionheart} → Richard’s left leg
{King John} → John’s left leg . (2)
• Strictly speaking, models in first-order logic require total functions, that is, there must be a
value for every input tuple. Thus, the crown must have a left leg and so must each of the
left legs.
• There is a technical solution to this awkward problem involving an additional “invisible”
object that is the left leg of everything that has no left leg, including itself. Fortunately, as
long as one makes no assertions about the left legs of things that have no left legs, these
technicalities are of no import.
Symbols and interpretations
• The impatient reader can obtain a complete description from the formal grammar. The basic
syntactic elements of first-order logic are the symbols that stand for objects, relations, and
functions. The symbols, therefore, come in three kinds: constant symbols, which stand for

2
IFETCE R2019 Academic Year 2023-2024

objects; predicate symbols, which stand for relations; and function symbols, which stand
for functions.
• We adopt the convention that these symbols will begin with uppercase letters. For example,
we might use the constant symbols Richard and John; the predicate symbols Brother ,
OnHead, Person, King, and Crown; and the function symbol LeftLeg.
• As with proposition symbols, the choice of names is entirely up to the user. Each predicate
and function symbol comes with an arity that fixes the number of arguments.
• As in propositional logic, every model must provide the information required to determine
if any given sentence is true or false. Thus, in addition to its objects, relations, and
functions, each model includes an interpretation that specifies exactly which objects,
relations and functions are referred to by the constant, predicate, and function symbols.
• One possible interpretation for our example—which a logician would call the intended
interpretation— is as follows:
✓ Richard refers to Richard the Lionheart and John refers to the evil King John.
✓ Brother refers to the brotherhood relation, that is, the set of tuples of objects given
in Equation (1); OnHead refers to the “on head” relation that holds between the
crown and King John; Person, King, and Crown refer to the sets of objects that
are persons, kings, and crowns.
✓ LeftLeg refers to the “left leg” function, that is, the mapping given in Equation
(2).

Figure 3.2 The syntax of first-order logic with equality, specified in Backus–Naur form
• There are many other possible interpretations, of course. For example, one
interpretation maps Richard to the crown and John to King John’s left leg.

3
IFETCE R2019 Academic Year 2023-2024

• There are five objects in the model, so there are 25 possible interpretations just for the
constant symbols Richard and John.
• Notice that not all the objects need have a name—for example, the intended
interpretation does not name the crown or the legs. It is also possible for an object to
have several names; there is an interpretation under which both Richard and John refer
to the crown.

Figure 3.3 Some members of the set of all models for a language with two constant
symbols, R and J, and one binary relation symbol.
• If you find this possibility confusing, remember that, in propositional logic, it is
perfectly possible to have a model in which Cloudy and Sunny are both true; it is the
job of the knowledge base to rule out models that are inconsistent with our knowledge.
• In summary, a model in first-order logic consists of a set of objects and an interpretation
that maps constant symbols to objects, predicate symbols to relations on those objects,
and function symbols to functions on those objects. Just as with propositional logic,
entailment, validity, and so on are defined in terms of all possible models.
• It shows that models vary in how many objects they contain—from one up to infinity—
and in the way the constant symbols map to objects. If there are two constant symbols
and one object, then both symbols must refer to the same object; but this can still happen
even with more objects. When there are more objects than constant symbols, some of
the objects will have no names.
• Because the number of possible models is unbounded, checking entailment by the
enumeration of all possible models is not feasible for first-order logic (unlike
propositional logic). Even if the number of objects is restricted, the number of
combinations can be very large. For the example in Figure 4.9, there are
137,506,194,466 models with six or fewer objects.
Terms
• A term is a logical expression that refers to an object. Constant symbols are therefore
terms, but it is not always convenient to have a distinct symbol to name every object.
• For example, in English we might use the expression “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).
• In the general case, a complex term is formed by a function symbol followed by a
parenthesized list of terms as arguments to the function symbol. It is important to
remember that a complex term is just a complicated kind of name. It is not a “subroutine
call” that “returns a value.” There is no LeftLeg subroutine that takes a person as input
and returns a leg.

4
IFETCE R2019 Academic Year 2023-2024

• We can reason about left legs (e.g., stating the general rule that everyone has one and
then deducing that John must have one) without ever providing a definition of LeftLeg.
• This is something that cannot be done with subroutines in programming languages. The
formal semantics of terms is straightforward. Consider a term f(t1, . . . , tn). The function
symbol f refers to some function in the model (call it F); the argument terms refer to
objects in the domain (call them d1, . . . , dn); and the term as a whole refers to the
object that is the value of the function F applied to d1, . . . , dn.
• For example, suppose the LeftLeg function symbol refers to the function shown in
Equation (8.2) and John refers to King John, then LeftLeg(John) refers to King John’s
left leg. In this way, the interpretation fixes the referent of every term.
Atomic sentences
• We have both terms for referring to objects and predicate symbols for referring to
relations, we can put them together to make atomic sentences that state facts. An atomic
sentence (or atom for short) is formed from a predicate symbol optionally followed by
a parenthesized list of terms, such as
Brother (Richard, John).
• This states, under the intended interpretation given earlier, that Richard the Lionheart
is the brother of King John. Atomic sentences can have complex terms as arguments.
Thus,
Married(Father (Richard),Mother (John))
states that Richard the Lionheart’s father is married to King John’s mother.
• An atomic sentence is true in a given model if the relation referred to by the predicate
symbol holds among the objects referred to by the arguments.
Complex sentences
• We can use logical connectives to construct more complex sentences, with the same
syntax and semantics as in propositional calculus.
• Here are four sentences that are true in the model of Figure 8.2 under our intended
interpretation:
¬Brother (LeftLeg(Richard), John)
Brother (Richard, John) ∧ Brother (John,Richard)
King(Richard) ∨ King(John)
¬King(Richard) ⇒ King(John) .
Quantifiers
Once we have a logic that allows objects, it is only natural to want to express properties
of entire collections of objects, instead of enumerating the objects by name. Quantifiers let us
do this. First-order logic contains two standard quantifiers, called universal and existential.
Universal quantification (∀)
• The expression of general rules in propositional logic. Rules such as “Squares
neighboring the wumpus are smelly” and “All kings are persons” are the bread and
butter of first-order logic.
• The second rule, “All kings are persons,” is written in first-order logic as
∀ x King(x) ⇒ Person(x) .

5
IFETCE R2019 Academic Year 2023-2024

• ∀ is usually pronounced “For all . . .”. (Remember that the upside-down A stands for
“all.”) Thus, the sentence says, “For all x, if x is a king, then x is a person.” The symbol
x is called a variable.
• By convention, variables are lowercase letters. A variable is a term all by itself, and as
such can also serve as the argument of a function—for example, LeftLeg(x). A term
with no variables is called a ground term.
• Intuitively, the sentence ∀ x P, where P is any logical expression, says that P is true for
every object x. More precisely, ∀ x P is true in a given model if P is true in all possible
extended interpretations constructed from the interpretation given in the model, where
each extended interpretation specifies a domain element to which x refers.
• This sounds complicated, but it is really just a careful way of stating the intuitive
meaning of universal quantification.
Existential quantification (∃)
• Universal quantification makes statements about every object. Similarly, we can make
a statement about some object in the universe without naming it, by using an existential
quantifier.
• To say, for example, that 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 . . .”.
• Intuitively, the sentence ∃ x P says that P is true for at least one object x. More precisely,
∃ x P is true in a given model if P is true in at least one extended interpretation that
assigns x to a domain element. That is, at least one of the following is true:
Richard the Lionheart is a crown ∧ Richard the Lionheart is on John’s head;
King John is a crown ∧ King John is on John’s head;
Richard’s left leg is a crown ∧ Richard’s left leg is on John’s head;
John’s left leg is a crown ∧ John’s left leg is on John’s head;
The crown is a crown ∧ the crown is on John’s head.
• The fifth assertion is true in the model, so the original existentially quantified sentence
is true in the model. Notice that, by our definition, the sentence would also be true in a
model in which King John was wearing two crowns. This is entirely consistent with the
original sentence “King John has a crown on his head.”
Nested quantifiers
• To express more complex sentences using multiple quantifiers. The simplest case is
where the quantifiers are of the same type. For example, “Brothers are siblings” can be
written as
∀ x ∀ y Brother (x, y) ⇒ Sibling(x, y) .
• Consecutive quantifiers of the same type can be written as one quantifier with several
variables.
• For example, to say that siblinghood is a symmetric relationship, we can write
∀ x, y Sibling(x, y) ⇔ Sibling(y, x) .
• In other cases we will have mixtures. “Everybody loves somebody” means that for
every person, there is someone that person loves:

6
IFETCE R2019 Academic Year 2023-2024

∀ x ∃ y Loves(x, y) .
• On the other hand, to say “There is someone who is loved by everyone,” we write
∃ y ∀ x Loves(x, y) .
• The order of quantification is therefore very important. It becomes clearer if we insert
parentheses. ∀ x (∃ y Loves(x, y)) says that everyone has a particular property, namely,
the property that they love someone.
• On the other hand, ∃ y (∀ x Loves(x, y)) says that someone in the world has a particular
property, namely the property of being loved by everybody.
Equality
• First-order logic includes one more way to make atomic sentences, other than using a
predicate and terms as described earlier. We can use the equality symbol to signify that
two terms refer to the same object.
• For example,
Father (John)=Henry
says that the object referred to by Father (John) and the object referred to by Henry are
the same. Because an interpretation fixes the referent of any term, determining the truth
of an equality sentence is simply a matter of seeing that the referents of the two terms
are the same object.
• The equality symbol can be used to state facts about a given function, as we just did for the
Father symbol. It can also be used with negation to insist that two terms are not the same
object.
• To say that Richard has at least two brothers, we would write
∃ x, y Brother (x,Richard) ∧ Brother (y,Richard) ∧ ¬(x=y) .
• The sentence
∃ x, y Brother (x,Richard) ∧ Brother (y,Richard)
does not have the intended meaning. In particular, it is true in the model of Figure 4.10,
where Richard has only one brother. To see this, consider the extended interpretation
in which both x and y are assigned to King John. The addition of ¬(x=y) rules out such
models. The notation x 6= y is sometimes used as an abbreviation for ¬(x=y).
3.2 A Logical Language: PROLOG
• Prolog has been proposed as the answer to the problem of programming in logic. Why isn't
it accepted as the universal representation language? Probably because Prolog is a
compromise between a representation language and a programming language.
• Given two specifications that are logically equivalent, one can be an efficient Prolog
program, while the other is not. Kowalski's famous equation "algonthm = logic + control"
expresses the limits of logic alone: logic = algorithm - control Many problems (especially
in AI) have large or infinite search spaces, and if Prolog is not given some advice on how
to search that space, it will not come up with the answer in any reasonable length of time.
• Prolog's problems fall into three classes.
✓ First, in order to make the language efficient, its expressiveness was restricted.
It is not possible to assert that a person's name is either Jan or John in Prolog

7
IFETCE R2019 Academic Year 2023-2024

(although it is possible to ask if the person's name is one of those). Similarly, it


is not possible to assert that a fact is false; Prolog does not distinguish between
false and unknown.
✓ Second, Prolog's inference mechanism is neither sound nor complete. Because
it does not check for circular unification, it can give incorrect answers, and
because it searches depth-first it can miss correct answers.
✓ Third, Prolog has no good way of adding control information to the underlying
logic, making it inefficient on certain problems.
3.2.1 Variables
Variables can be used in the head or body of a clause and in goals entered at the system
prompt. However, their interpretation depends on where they are used.
Variables in Goals
• Variables in goals can be interpreted as meaning 'find values of the variables that make
the goal satisfied'.
• For example, the goal ?-large_animal(A) can be read as 'find a value of A such that
large_animal(A) is satisfied'.
• A third version of the Animals Program is given below:
/* Animals Program 3 */
/* As Animals Program 2 but with the additional rules
given below */
chases(X,Y):-
dog(X),cat(Y),
write(X),write(' chases '),write(Y),nl.
/* chases is a predicate with two arguments*/
go:-chases(A,B).
/* go is a predicate with no arguments */
• A goal such as ?-chases(X,Y). means find values of variables X and Y to satisfy
chases(X,Y).
• To do this, Prolog searches through all the clauses defining the predicate chases (there
is only one in this case) from top to bottom until a matching clause is found. It then
works through the goals in the body of that clause one by one, working from left to
right, attempting to satisfy each one in turn.
• The output produced by loading Animals Program 3 and entering some typical goals at
the prompt is as follows.
?-consult('animals3.pl'). System prompt
# 0.01 seconds to consult animals3.pl animals3.pl loaded
?- chases(X,Y). User backtracks to find first two solutions
only.
fido chases mary
X = fido ,
Y = mary ;
fido chases harry
X = fido ,

8
IFETCE R2019 Academic Year 2023-2024

Y = harry
Note use of write and nl predicates
-chases(D,henry). Nothing chases henry
no
?-go. Note that no variable values are output. (All
output is from the write and nl predicates.)
Because of this, the user has no opportunity to
backtrack.

fido chases mary


yes
• It should be noted that there is nothing to prevent the same answer being generated
more than once by backtracking. For example if the program is
chases(fido,mary):-fchasesm.
chases(fido,john).
chases(fido,mary):-freallychasesm.
fchasesm.
freallychasesm.
• The query ?-chases(fido,X) will produce two identical answers out of three by
backtracking.
?- chases(fido,X).
X = mary ;
X = john ;
X = mary
?-
Binding Variables
• Initially all variables used in a clause are said to be unbound, meaning that they do not
have values. When the Prolog system evaluates a goal some variables may be given
values such as dog, -6.4 etc. This is known as binding the variables.
• A variable that has been bound may become unbound again and possibly then bound to
a different value by the process of backtracking.
Lexical Scope of Variables
• In a clause such as
parent(X,Y):-father(X,Y).
the variables X and Y are entirely unrelated to any other variables with the same name used
elsewhere.
• All occurrences of variables X and Y in the clause can be replaced consistently by any other
variables, e.g. by First_person and Second_person giving
parent(First_person,Second_person):-
father(First_person,Second_person).
• This does not change the meaning of the clause (or the user's program) in any way. This is
often expressed by saying that the lexical scope of a variable is the clause in which it
appears.

9
IFETCE R2019 Academic Year 2023-2024

Universally Quantified Variables


• If a variable appears in the head of a rule or fact it is taken to indicate that the rule or fact
applies for all possible values of the variable. For example, the rule
large_animal(X):-dog(X),large(X).
can be read as 'for all values of X, X is a large animal if X is a dog and X is large'.
Variable X is said to be universally quantified.
Existentially Quantified Variables
• Suppose now that the database contains the following clauses:
person(frances,wilson,female,28,architect).
person(fred,jones,male,62,doctor).
person(paul,smith,male,45,plumber).
person(martin,williams,male,23,chemist).
person(mary,jones,female,24,programmer).
person(martin,johnson,male,47,solicitor).
man(A):-person(A,B,male,C,D).
• The first six clauses (all facts) comprise the definition of predicate person/5, which has
five arguments with obvious interpretations, i.e. the forename, surname, sex, age and
occupation of the person represented by the corresponding fact.
• The last clause is a rule, defined using the person predicate, which also has a natural
interpretation, i.e. 'for all A, A is a man if A is a person whose sex is male'. As explained
previously, the variable A in the head of the clause (representing forename in this case)
stands for 'for all A' and is said to be universally quantified.
The Anonymous Variable
• In order to find whether there is a clause corresponding to anyone called paul in the
database, it is only necessary to enter a goal such as:
?- person(paul,Surname,Sex,Age,Occupation).
at the prompt. Prolog replies as follows:
Surname = smith ,
Sex = male ,
Age = 45 ,
Occupation = plumber
• In many cases it may be that knowing the values of some or all of the last four variables is
of no importance. If it is only important to establish whether there is someone with
forename paul in the database an easier way is to use the goal:
?- person(paul,_,_,_,_).
yes
• The underscore character _ denotes a special variable, called the anonymous variable. This
is used when the user does not care about the value of the variable If only the surname of
any people named paul is of interest, this can be found by making the other three variables
anonymous in a goal, e.g.
?- person(paul,Surname,_,_,_).
Surname = smith

10
IFETCE R2019 Academic Year 2023-2024

• Similarly, if only the ages of all the people named martin in the database are of interest, it
would be simplest to enter the goal:
?- person(martin,_,_,Age,_).
This will give two answers by backtracking.
Age = 23 ;
Age = 47
• The three anonymous variables are not bound, i.e. given values, as would normally be
expected. Note that there is no assumption that all the anonymous variables have the same
value (in the above examples they do not). Entering the alternative goal
?- person(martin,X,X,Age,X).
with variable X instead of underscore each time, would produce the answer
no
as there are no clauses with first argument martin where the second, third and fifth
arguments are identical.
3.2.2 Operators
• Up to now, the notation used for predicates is the standard one of a functor followed by a
number of arguments in parentheses, e.g. likes(john,mary).
• As an alternative, any user-defined predicate with two arguments (a binary predicate) can
be converted to an infix operator. This enables the functor (predicate name) to be written
between the two arguments with no parentheses, e.g.john likes mary.
• Some Prolog users may find this easier to read. Others may prefer the standard notation.
Any user-defined predicate with one argument (a unary predicate) can be converted to a
prefix operator. This enables the functor to be written before the argument with no
parentheses, e.g. isa_dog fred instead of isa_dog(fred).
• Alternatively, a unary predicate can be converted to a postfix operator. This enables the
functor to be written after the argument, e.g. fred isa_dog
• Operator notation can also be used with rules to aid readability. Some people may find a
rule such as
likes(john,X):-is_female(X),owns(X,Y),isa_cat(Y).
easier to understand if it is written as
john likes X:- X is_female, X owns Y, Y isa_cat.
• The standard bracketed 'functor and arguments' notation, e.g. likes(john,X) can still be used
with operators if preferred. 'Mixed' notation is also permitted, e.g. if likes/2, is_female/1,
owns/2 and isa_cat/1 are all operators
likes(john,X):-is_female(X),X owns Y,isa_cat(Y).
is a valid form of the previous rule.
• Any user-defined predicate with one or two arguments can be converted to an operator by
entering a goal using the op predicate at the system prompt. This predicate takes three
arguments, for example
?-op(150,xfy,likes).
• The first argument is the 'operator precedence', which is an integer from 0 upwards. The
range of numbers used depends on the particular implementation. The lower the number,
the higher the precedence.

11
IFETCE R2019 Academic Year 2023-2024

• Operator precedence values are used to determine the order in which operators will be
applied when more than one is used in a term. The most important practical use of this is
for operators used for arithmetic, as will be explained later. In most other cases it will
suffice to use an arbitrary value such as 150.
• The second argument should normally be one of the following three atoms:
✓ xfy meaning that the predicate is binary and is to be converted to an infix
operator.
✓ fy meaning that the predicate is unary and is to be converted to an prefix operator
xf meaning that the predicate is unary and is to be converted to a postfix operator.
✓ The third argument specifies the name of the predicate that is to be converted to
an operator.
• A predicate can also be converted to an operator by placing a line such as
?-op(150,xfy,likes).
in a Prolog program file to be loaded using consult or reconsult.
• Note that the prompt (the two characters ?-) must be included. When a goal is used in this
way, the entire line is known as a directive. In this case, the directive must be placed in the
file before the first clause that uses the operator likes.
• Several built-in predicates have been pre-defined as operators. These include relational
operators for comparing numerical values, including < denoting 'less than' and > denoting
'greater than'.
• Thus the following are valid terms, which may be included in the body of a rule:
X>4
Y<Z
A=B
• Bracketed notation may also be used with built-in predicates that are defined as operators,
e.g. >(X,4) instead of X>4.
Arithmetic
• Although the examples used are non-numerical (animals which are mammals etc.), Prolog
also provides facilities for doing arithmetic using a notation similar to that which will
already be familiar to many users from basic algebra.
• This is achieved using the built-in predicate is/2, which is predefined as an infix operator
and thus is written between its two arguments.
• The most common way of using is/2 is where the first argument is an unbound variable.
Evaluating the goal X is –6.5 will cause X to be bound to the number –6.5 and the goal to
succeed.
• The second argument can be either a number or an arithmetic expression e.g. X is 6*Y+Z-
3.2+P-Q/4 (* denotes multiplication).
• Any variables appearing in an arithmetic expression must already be bound (as a result of
evaluating a previous goal) and their values must be numerical.
• Provided they are, the goal will always succeed and the variable that forms the first
argument will be bound to the value of the arithmetic expression. If not, an error message
will result.
?- X is 10.5+4.7*2.

12
IFETCE R2019 Academic Year 2023-2024

X = 19.9
?- Y is 10,Z is Y+1.
Y = 10 ,
Z = 11
• Symbols such as + - * / in arithmetic expressions are a special type of infix operator known
as arithmetic operators. Unlike operators used elsewhere in Prolog they are not predicates
but functions, which return a numerical value.
• As well as numbers, variables and operators, arithmetic expressions can include arithmetic
functions, written with their arguments in parentheses (i.e. not as operators). Like arithmetic
operators these return numerical values, e.g. to find the square root of 36:
?- X is sqrt(36).
X=6
• The arithmetic operator - can be used not only as a binary infix operator to denote the
difference of two numerical values, e.g. X-6, but also as a unary prefix operator to denote
the negative of a numerical value, e.g.
?- X is 10,Y is -X-2.
X = 10 ,
Y = -12
• It below shows some of the arithmetic operators and arithmetic functions available in
Prolog.
X+Y the sum of X and Y
X-Y the difference of X and Y
X*Y the product of X and Y
X/Y the quotient of X and Y
X//Y the 'integer quotient' of X and Y (the result is truncated to the nearest
integer between it and zero)
X^Y X to the power of Y
-X the negative of X
abs(X) the absolute value of X
sin(X) the sine of X (for X measured in degrees)
cos(X) the cosine of X (for X measured in degrees)
max(X,Y) the larger of X and Y
sqrt(X) the square root of X
Example
?- X is 30,Y is 5,Z is X+Y+X*Y+sin(X).
X = 30 ,
Y=5,
Z = 185.5
• Although the is predicate is normally used in the way described here, the first argument can
also be a number or a bound variable with a numerical value. In this case, the numerical
values of the two arguments are calculated. The goal succeeds if these are equal. If not, it
fails.
?- X is 7,X is 6+1.

13
IFETCE R2019 Academic Year 2023-2024

X=7
?- 10 is 7+13-11+9.
no
?- 18 is 7+13-11+9.
yes
Relational Operators
• The infix operators =:= =\= > >= < =< are a special type known as relational operators.
They are used to compare the value of two arithmetic expressions.
• The goal succeeds if the value of the first expression is equal to, not equal to, greater
than, greater than or equal to, less than or less than or equal to the value of the second
expression, respectively. Both arguments must be numbers, bound variables or
arithmetic expressions.
?- 88+15-3=:=110-5*2.
yes
?- 100=\=99.
Yes
Equality Operators
There are three types of relational operator for testing equality and inequality available
in Prolog. The first type is used to compare the values of arithmetic expressions. The other two
types are used to compare terms.
Arithmetic Expression Equality =:=
E1=:=E2 succeeds if the arithmetic expressions E1 and E2 evaluate to the same value.
?- 6+4=:=6*3-8.
yes
?- sqrt(36)+4=:=5*11-45.
yes
Arithmetic Expression Inequality =\=
E1=\=E2 succeeds if the arithmetic expressions E1 and E2 do not evaluate to the same
value
?- 10=\=8+3.
Yes
Terms Identical ==
Both arguments of the infix operator == must be terms. The goal Term1==Term2
succeeds if and only if Term1 is identical to Term2. Any variables used in the terms may or
may not already be bound, but no variables are bound as a result of evaluating the goal.
?- likes(X,prolog)==likes(X,prolog).
X=_
?- likes(X,prolog)==likes(Y,prolog).
no
(X and Y are different variables)
?- X is 10,pred1(X)==pred1(10).
X = 10
?- X==0.

14
IFETCE R2019 Academic Year 2023-2024

no
?- 6+4==3+7.
no
The value of an arithmetic expression is only evaluated when used with the is/2
operator. Here 6+4 is simply a term with functor + and arguments 6 and 4. This is entirely
different from the term 3+7.
Terms Not Identical \==
Term1\==Term2 tests whether Term1 is not identical to Term2. The goal succeeds if
Term1==Term2 fails. Otherwise it fails.
?- pred1(X)\==pred1(Y).
X=_,
Y=_
Terms Identical With Unification =
• The term equality operator = is similar to == with one vital (and often very useful)
difference. The goal Term1=Term2 succeeds if terms Term1 and Term2 unify, i.e. there is
some way of binding variables to values which would make the terms identical
?- pred1(X)=pred1(10).
X = 10
?- likes(X,prolog)=likes(john,Y).
X = john ,
Y = prolog
?- X=0,X=:=0.
X=0
?- 6+4=3+7.
no
?- 6+X=6+3.
X=3
?- likes(X,prolog)=likes(Y,prolog).
X=Y=_
?- likes(X,prolog)=likes(Y,ada).
no
Non-Unification Between Two Terms \=
• The goal Term1\=Term2 succeeds if Term1=Term2 fails, i.e. the two terms cannot be
unified. Otherwise it fails.
?- 6+4\=3+7.
Yes
?- likes(X,prolog)\=likes(john,Y).
no
3.3 UNIFICATION
Unification:
✓ Unification is a process of making two different logical atomic expressions identical
by finding a substitution. Unification depends on the substitution process.
✓ It takes two literals as input and makes them identical using substitution.

15
IFETCE R2019 Academic Year 2023-2024

✓ Let Ψ1 and Ψ2 be two atomic sentences and 𝜎 be a unifier such that, Ψ1𝜎 = Ψ2𝜎,
then it can be expressed as UNIFY(Ψ1, Ψ2).
Example: Find the MGU for Unify{King(x), King(John)}
Let Ψ1 = King(x), Ψ2 = King(John),
Substitution θ = {John/x} is a unifier for these atoms and applying this substitution,
and both expressions will be identical.
✓ The UNIFY algorithm is used for unification, which takes two atomic sentences and
returns a unifier for those sentences (If any exist).
✓ Unification is a key component of all first-order inference algorithms. It returns fail if
the expressions do not match with each other.
✓ The substitution variables are called Most General Unifier or MGU.
Example. Let's say there are two different expressions, P(x, y), and P(a, f(z)).
In this example, need to make both above statements identical to each other. For this,will
perform the substitution.
P(x, y) .......... (i)
P(a, f(z)) ......... (ii)
✓ Substitute x with a, and y with f(z) in the first expression, and it will be represented as
a/x and f(z)/y.
✓ With both the substitutions, the first expression will be identical to the second
expression and the substitution set will be: [a/x, f(z)/y].
Conditions for Unification:
Following are some basic conditions for unification:
• Predicate symbol must be same, atoms or expression with different predicate
symbol can never be unified.
• Number of Arguments in both expressions must be identical.
• Unification will fail if there are two similar variables present in the same expression.
Unification Algorithm:
Algorithm: Unify(Ψ1, Ψ2)
Step. 1: If Ψ1 or Ψ2 is a variable or constant, then:
a) If Ψ1 or Ψ2 are identical, then return NIL.
b) Else if Ψ1is a variable,
a. then if Ψ1 occurs in Ψ2, then return FAILURE
b. Else return { (Ψ2/ Ψ1)}.
c) Else if Ψ2 is a variable,
a. If Ψ2 occurs in Ψ1 then return FAILURE,
b. Else return {( Ψ1/ Ψ2)}.
d) Else return FAILURE.
Step.2: If the initial Predicate symbol in Ψ1 and Ψ2 are not same, then
return FAILURE.
Step. 3: IF Ψ1 and Ψ2 have a different number of arguments, then
return FAILURE.
Step. 4: Set Substitution set(SUBST) to NIL.
Step. 5: For i=1 to the number of elements in Ψ1.

16
IFETCE R2019 Academic Year 2023-2024

a) Call Unify function with the ith element of Ψ1 and ith element of Ψ2, and put the
result into S.
b) If S = failure then returns Failure
c) If S ≠ NIL then do,
a. Apply S to the remainder of both L1 and L2.
b. SUBST= APPEND(S, SUBST).
Step.6: Return SUBST.
Implementation of the Algorithm
Step.1: Initialize the substitution set to be empty.
Step.2: Recursively unify atomic sentences:
a) Check for Identical expression match.
b) If one expression is a variable vi, and the other is a term ti which does not contain
variable vi, then:
a. Substitute ti / vi in the existing substitutions
b. Add ti /vi to the substitution setlist.
c. If both the expressions are functions, then function name must be similar, and
the number of arguments must be the same in both the expression.
For each pair of the following atomic sentences find the Most General Unifier.
1. Find the MGU of {p(f(a), g(Y)) and p(X, X)}
Sol: S0 => Here, Ψ1 = p(f(a), g(Y)),
and Ψ2 = p(X, X)
SUBST θ= {f(a) / X}
S1 => Ψ1 = p(f(a), g(Y)), and
Ψ2 = p(f(a), f(a)) SUBST θ=
{f(a) / g(y)}, Unification
failed.
Unification is not possible for these expressions.
2. Find the MGU of {p(b, X, f(g(Z))) and p(Z, f(Y), f(Y))}
Here, Ψ1 = p(b, X, f(g(Z))) , and Ψ2 = p(Z, f(Y), f(Y))
S0 =>{ p(b, X, f(g(Z))); p(Z, f(Y), f(Y))}
SUBST θ={b/Z}
S1 =>{ p(b, X,
f(g(b))); p(b, f(Y),
f(Y))} SUBST
θ={f(Y) /X}
S2 =>{ p(b, f(Y), f(g(b))); p(b,
f(Y), f(Y))} SUBST θ= {g(b)
/Y}
S2 =>{ p(b, f(g(b)), f(g(b)); p(b, f(g(b)), f(g(b))}
Unified Successfully. And Unifier = { b/Z, f(Y) /X
, g(b) /Y}.
3. Find the MGU of {p (X, X),
and p (Z, f(Z))} Here,

17
IFETCE R2019 Academic Year 2023-2024

Ψ1 = {p (X, X), and Ψ2


= p (Z, f(Z)) S0 => {p
(X, X), p (Z, f(Z))}
SUBST θ= {X/Z}
S1 => {p (Z, Z), p (Z, f(Z))}
SUBST θ= {f(Z) / Z}, Unification Failed.
Hence, unification is not possible for these expressions.
3.4 FORWARD CHAINING
Forward chaining is also known as a forward deduction or forward reasoning method
when using an inference engine. Forward chaining is a form of reasoning which start with
atomic sentences in the knowledge base and applies inference rules (Modus Ponens) in the
forward direction to extract more data until a goal is reached.
The Forward-chaining algorithm starts from known facts, triggers all rules whose
premises are satisfied, and add their conclusion to the known facts. This process repeats until
the problem is solved.
Properties of Forward-Chaining:
• It is a down-up approach, as it moves from bottom to top.
• It is a process of making a conclusion based on known facts or data, by
starting from the initial state and reaches the goal state.
• Forward-chaining approach is also called as data-driven as reach to the goal
using available data.
Example:
"As per the law, it is a crime for an American to sell weapons to hostile nations. Country
A, an enemy of America, has some missiles, and all the missiles were sold to it by Robert,
who is an American citizen." Prove that "Robert is criminal."
To solve the above problem, first, convert all the above facts into first-order definite
clauses, and then use a forward-chaining algorithm to reach the goal.
Facts Conversion into FOL:
It is a crime for an American to sell weapons to hostile nations. (Let's say p, q,
and r are variables) American (p) ∧ weapon(q) ∧ sells (p, q, r) ∧ hostile(r) →
Criminal(p) ...(1)
Country A has some missiles. p Owns(A, p) ∧ Missile(p). It can be written in two
definite clauses by using Existential Instantiation, introducing new Constant T1.
Owns(A, T1) .................. (2)
Missile(T1) ................... (3)
All of the missiles were sold to country A by Robert.
p Missiles(p) ∧ Owns (A, p) → Sells (Robert, p, A) ............. (4)
Missiles are weapons.
Missile(p) → Weapons (p) ................... (5)
Enemy of America is known as hostile.
Enemy(p, America)
→Hostile(p) .................................................... (6)
Country A is an enemy of America.

18
IFETCE R2019 Academic Year 2023-2024

Enemy (A, America) (7)


Robert is
American
American(Rober
t) .................................................. (8)
Forward chaining proof:
Step-1:
In the first step the known facts and will choose the sentences which do not have
implications, such as: American(Robert), Enemy(A, America), Owns(A, T1), and
Missile(T1). All these facts will be represented as below.

Step-2:
At the second step, see those facts which infer from available facts and with satisfied
premises.
▪ Rule-(1) does not satisfy premises, so it will not be added in the first iteration.
▪ Rule-(2) and (3) are already added.
▪ Rule-(4) satisfy with the substitution {p/T1}, so Sells (Robert, T1, A) is added, which
infers from the conjunction of Rule (2) and (3).
▪ Rule-(6) is satisfied with the substitution(p/A), so Hostile(A) is added and which
infers from Rule- (7).

Step-3:

At step-3, as we can check Rule-(1) is satisfied with the substitution {p/Robert,


q/T1, r/A}, so add Criminal(Robert) which infers all the available facts. And
hence reached goal statement.
Hence it is proved that Robert is Criminal using forward chaining approach.

19
IFETCE R2019 Academic Year 2023-2024

3.5 BACKWARD CHAINING


Backward-chaining is also known as a backward deduction or backward reasoning
method when using an inference engine. A backward chaining algorithm is a form of
reasoning, which starts with the goal and works backward, chaining through rules to
find known facts that support the goal.
Properties of backward chaining:
✓ It is known as a top-down approach.
✓ Backward-chaining is based on modus ponens inference rule.
✓ In backward chaining, the goal is broken into sub-goal or sub-goals to prove the facts
true.
✓ It is called a goal-driven approach, as a list of goals decides which rules are selected and
used.
Example:
In backward-chaining, use the same above example, and will rewrite all the rules.
American (p) ∧ weapon(q) ∧ sells (p, q, r) ∧ hostile(r) → Criminal(p) ...(1)
Owns(A, T1)........................ (2)
Missile(T1)………………….(3)
p Missiles(p) ∧ Owns (A, p) → Sells (Robert, p, A) .................. (4)
Missile(p) → Weapons (p) ....................... (5)
Enemy(p, America) →Hostile(p) ........................ (6)
Enemy (A, America) ......................... (7)
American(Robert) ........................... (8)
Backward-Chaining proof:
In Backward chaining, start with our goal predicate, which is Criminal(Robert), and then
infer further rules.
Step-1:
At the first step, take the goal fact. And from the goal fact, infer other facts, and
at last, prove those facts true. So goal fact is "Robert is Criminal," so following is
the predicate of it.

Step-2: At the second step, infer other facts form goal fact which satisfies the rules. So as in
Rule-1, the goal predicate Criminal (Robert) is present with substitution {Robert/P}. So add all
the conjunctive facts below the first level and will replace p with Robert.

Here can see American (Robert) is a fact, so it is proved here.

20
IFETCE R2019 Academic Year 2023-2024

Step-3: At step-3, will extract further fact Missile(q) which infer from Weapon(q), as it
satisfies Rule-(5). Weapon (q) is also true with the substitution of a constant T1 at q.

Step-4: At step-4, can infer facts Missile(T1) and Owns(A, T1) form Sells(Robert, T1, r)
which satisfies the Rule- 4, with the substitution of A in place of r. So these two statements
are proved here.

Step-5: At step-5, can infer the fact Enemy(A, America) from Hostile(A) which satisfies
Rule- 6. And hence all the statements are proved true using backward chaining.

21
IFETCE R2019 Academic Year 2023-2024

S. Forward Chaining Backward Chaining


No.

1. Forward chaining starts from known Backward chaining starts from the goal and
facts and applies inference rule to works backward through inference rules to
extract more data unit it reaches to find the required facts that support the goal.
the goal.
2. It is a bottom-up approach It is a top-down approach

3. Forward chaining is known as data- Backward chaining is known as goal-


driven inference technique as we reach driven technique as we start from the goal
to the goal using the available data. and divide into sub-goal to extract the facts.
4. Forward chaining reasoning Backward chaining reasoning applies a
applies a breadth-first search depth- first search strategy.
strategy.
5. Forward chaining tests for all the Backward chaining only tests for few
available rules required rules.
6. Forward chaining is suitable Backward chaining is suitable for
for the planning, monitoring, diagnostic, prescription, and debugging
control, and interpretation application.
application.
7. Forward chaining can generate an Backward chaining generates a finite
infinite number of possible number of possible conclusions.
conclusions.
8. It operates in the forward direction. It operates in the backward direction.

9. Forward chaining is aimed for Backward chaining is only aimed for the
any conclusion. required data.

3.5 RESOLUTION
• Resolution is a theorem proving technique that proceeds by building refutation proofs,
i.e., proofs by contradictions. It was invented by a Mathematician John Alan Robinson
in the year 1965.
• Resolution is used, if there are various statements are given, and need to prove a
conclusion of those statements. Unification is a key concept in proofs by resolutions.
Resolution is a single inference rule which can efficiently operate on the conjunctive
normal form or clausal form.
• Clause: Disjunction of literals (an atomic sentence) is called a clause. It is also known
as a unit clause.
Steps for Resolution:
• Conversion of facts into first-order logic.
• Convert FOL statements into CNF

22
IFETCE R2019 Academic Year 2023-2024

• Negate the statement which needs to prove (proof by contradiction)


• Draw resolution graph (unification).
Example:
John likes all kind of food.
Apple and vegetable are food
Anything anyone eats and not killed is food.
Anil eats peanuts and still alive
Harry eats everything that Anil eats.
Prove by resolution that: John likes peanuts.
Step-1: Conversion of Facts into FOL
In the first step convert all the given statements into its first order logic.

Step-2: Conversion of FOL into CNF


In First order logic resolution, it is required to convert the FOL into CNF as
CNF form makes easier for resolution proofs.
Eliminate all implication (→) and rewrite
a. ∀x ¬ food(x) V likes(John, x)
b. food(Apple) Λ food(vegetables)
c. ∀x ∀y ¬ [eats(x, y) Λ ¬ killed(x)] V food(y)
d. eats (Anil, Peanuts) Λ alive(Anil)
e. ∀x ¬ eats(Anil, x) V eats(Harry, x)
f. ∀x¬ [¬ killed(x) ] V alive(x)
g. ∀x ¬ alive(x) V ¬ killed(x)
h. likes(John, Peanuts)
Move negation (¬)inwards and rewrite
a. ∀x ¬ food(x) V likes(John, x)
b. food(Apple) Λ food(vegetables)
c. ∀x ∀y ¬ eats(x, y) V killed(x) V food(y)
d. eats (Anil, Peanuts) Λ alive(Anil)
e. ∀x ¬ eats(Anil, x) V eats(Harry, x)
f. ∀x ¬killed(x) ] V alive(x)
g. ∀x ¬ alive(x) V ¬ killed(x)
h. likes(John, Peanuts).

23
IFETCE R2019 Academic Year 2023-2024

Rename variables or standardize variables


a. ∀x ¬ food(x) V likes(John, x)
b. food(Apple) Λ food(vegetables)
c. ∀y ∀z ¬ eats(y, z) V killed(y) V food(z)
d. eats (Anil, Peanuts) Λ alive(Anil)
e. ∀w¬ eats(Anil, w) V eats(Harry, w)
f. ∀g ¬killed(g) ] V alive(g)
g. ∀k ¬ alive(k) V ¬ killed(k)
h. likes(John, Peanuts).
Drop Universal quantifiers.
In this step will drop all universal quantifier since all the statements are not implicitly
quantified so we don't need it.
a. ¬ food(x) V likes(John, x)
b. food(Apple)
c. food(vegetables)
d. ¬ eats(y, z) V killed(y) V food(z)
e. eats (Anil, Peanuts)
f. alive(Anil)
g. ¬ eats(Anil, w) V eats(Harry, w)
h. killed(g) V alive(g)
i. ¬ alive(k) V ¬ killed(k)
j. likes(John, Peanuts).
Step-3: Negate the statement to be proved
In this statement, apply negation to the conclusion statements, which will be written as
¬likes(John, Peanuts).
Step-4: Draw Resolution graph:Now in this step, will solve the problem by
resolution tree using substitution. For the above problem, it will be given as follows

Hence the negation of the conclusion has been proved as a complete contradiction with

24
IFETCE R2019 Academic Year 2023-2024

the given set of statements.


Explanation of Resolution graph
• In the first step of resolution graph, ¬likes(John, Peanuts) , and likes(John,
x) get resolved(canceled) by substitution of {Peanuts/x}, and we are left with ¬
food(Peanuts)
• In the second step of the resolution graph, ¬ food(Peanuts) , and food(z) get
resolved (canceled) by substitution of { Peanuts/z}, and we are left with ¬ eats(y,
Peanuts) V killed(y) .
• In the third step of the resolution graph, ¬ eats(y, Peanuts) and eats (Anil,
Peanuts) get resolved by substitution {Anil/y}, and we are left with Killed(Anil)
.
• In the fourth step of the resolution graph, Killed(Anil) and ¬ killed(k) get resolve
by substitution
{Anil/k}, and we are left with ¬ alive(Anil) .
In the last step of the resolution graph ¬ alive(Anil) and alive(Anil) get resolved.
3.6 ONTOLOGICAL ENGINEERING

Figure 3.4 The upper ontology of the world


Concepts such as Events, Time, Physical Objects, and Beliefs— that occur in many
different domains. Representing these abstract concepts is sometimes called ontological
engineering.
The general framework of concepts is called an upper ontology because of the
convention of drawing graphs with the general concepts at the top and the more specific
concepts below them, as figure 3.4
3.6.1 Categories and Objects
The organization of objects into categories is a vital part of knowledge representation.
Although interaction with the world takes place at the level of individual objects, much
reasoning takes place at the level of categories. For example, a shopper would normally have
the goal of buying a basketball, rather than a particular basketball such as BB9.
There are two choices for representing categories in first-order logic: predicates and
objects. That is, we can use the predicate Basketball (b), or we can reify1 the category as an
object, Basketballs. We could then say Member(b, Basketballs ), which we will abbreviate as
b∈ Basketballs, to say that b is a member of the category of basketballs. We say
Subset(Basketballs, Balls), abbreviated as Basketballs ⊂ Balls, to say that Basketballs is a
subcategory of Balls.

25
IFETCE R2019 Academic Year 2023-2024

Categories serve to organize and simplify the knowledge base through inheritance.
If we say that all instances of the category Food are edible, and if we assert that Fruit is a
subclass of Food and Apples is a subclass of Fruit , then we can infer that every apple is
edible. We say that the individual apples inherit the property of edibility, in this case from
their membership in the Food category.
First-order logic makes it easy to state facts about categories, either by relating objects
to categories or by quantifying over their members. Here are some types of facts, with
examples of each:
• An object is a member of a category.
BB9 ∈ Basketballs
• A category is a subclass of another category.
Basketballs ⊂ Balls
• All members of a category have some properties.
(x∈ Basketballs) ⇒ Spherical (x)
• Members of a category can be recognized by some properties.
Orange(x) ∧ Round (x) ∧ Diameter(x)=9.5 ∧ x∈ Balls ⇒ x∈ Basketballs
• A category as a whole has some properties.
Dogs ∈DomesticatedSpecies
Notice that because Dogs is a category and is a member of DomesticatedSpecies , the
latter must be a category of categories.
Categories can also be defined by providing necessary and sufficient conditions for
membership. For example, a bachelor is an unmarried adult male:
x∈ Bachelors ⇔ Unmarried(x) ∧ x∈ Adults ∧ x∈Males
3.6.2 Physical Composition
• We use the general PartOf relation to say that one thing is part of another. Objects can be
grouped into part of hierarchies, reminiscent of the Subset hierarchy:
PartOf (Bucharest , Romania)
PartOf (Romania, EasternEurope)
PartOf (EasternEurope, Europe)
PartOf (Europe, Earth)
• The PartOf relation is transitive and reflexive; that
is, PartOf (x, y) ∧ PartOf (y, z) ⇒ PartOf (x, z)
PartOf (x,x)
Therefore, we can conclude
PartOf (Bucharest , Earth).
• For example, if the apples are Apple1, Apple2, and Apple3, then
BunchOf ({Apple1,Apple2,Apple3}) denotes the composite object with the three apples as
parts (not elements).
• We can define BunchOf in terms of the PartOf relation. Obviously, each element of s is
part of BunchOf (s):
∀x x∈ s ⇒ PartOf (x, BunchOf (s))
• Furthermore, BunchOf (s) is the smallest object satisfying this condition. In other words,
BunchOf (s) must be part of any object that has all the elements of s as parts:
∀ y [∀x x∈ s ⇒ PartOf (x, y)] ⇒ PartOf (BunchOf (s), y)
3.6.3 Measurements
• In both scientific and commonsense theories of the world, objects have height, mass, cost,
and so on. The values that we assign for these properties are called measures.
Length(L1)=Inches(1.5)=Centimeters(3.81)
• Conversion between units is done by equating multiples of one unit to another:

26
IFETCE R2019 Academic Year 2023-2024

Centimeters(2.54 ×d)=Inches(d)
• Similar axioms can be written for pounds and kilograms, seconds and days, and dollars and
cents. Measures can be used to describe objects as follows:
Diameter(Basketball12)=Inches(9.5)
ListPrice(Basketball12)=$(19)
d∈ Days ⇒ Duration(d)=Hours(24)
3.6.4 Time Intervals

Figure 3.5 Predicates on time intervals.


• Event calculus opens us up to the possibility of talking about time, and time intervals. We
will consider two kinds of time intervals: moments and extended intervals. The distinction
is that only moments have zero duration:
Partition({Moments,ExtendedIntervals},Intervals)
i∈Moments ⇔ Duration(i)=Seconds(0)
• The functions Begin and End pick out the earliest and latest moments in an interval, and
the function Time delivers the point on the time scale for a moment. The function Duration
gives the difference between the end time and the start time.
Interval (i) ⇒ Duration(i)=(Time(End(i)) − Time(Begin(i)))
Time(Begin(AD1900))=Seconds(0)
Time(Begin(AD2001))=Seconds(3187324800)
Time(End(AD2001))=Seconds(3218860800)
Duration(AD2001)=Seconds(31536000)
• Two intervals Meet if the end time of the first equals the start time of the second. The
complete set of interval relations, as proposed by Allen (1983), is shown graphically in
Figure 5.2 and logically below:
Meet(i,j) ⇔ End(i)=Begin(j)
Before(i,j) ⇔ End(i) < Begin(j)
After (j,i) ⇔ Before(i, j)
During(i,j) ⇔ Begin(j) < Begin(i) < End(i) < End(j)
Overlap(i,j) ⇔ Begin(i) < Begin(j) < End(i) < End(j)
Begins(i,j) ⇔ Begin(i) = Begin(j)
Finishes(i,j) ⇔ End(i) = End(j)
Equals(i,j) ⇔ Begin(i) = Begin(j) ∧ End(i) = End(j)

27
IFETCE R2019 Academic Year 2023-2024

3.6 EVENTS
• Event calculus reifies fluents and events. The fluent At(Shankar , Berkeley) is an object that
refers to the fact of Shankar being in Berkeley, but does not by itself say anything about
whether it is true. To assert that a fluent is actually true at some point in time we use the
predicate T, as in T(At(Shankar , Berkeley), t).
• Events are described as instances of event categories. The event E1 of Shankar flying from
San Francisco to Washington, D.
• C. is described as
E1 ∈ Flyings ∧ Flyer (E1, Shankar ) ∧ Origin(E1, SF) ∧ Destination(E1,DC)
• we can define an alternative three-argument version of the category of flying events and
say
E1 ∈ Flyings(Shankar , SF,DC)
• We then use Happens(E1, i) to say that the event E1 took place over the time interval i, and
we say the same thing in functional form with Extent(E1)=i. We represent time intervals
by a (start, end) pair of times; that is, i = (t1, t2) is the time interval that starts at t1 and ends
at t2. The complete set of predicates for one version of the event calculus is
T(f, t) Fluent f is true at time t
Happens(e, i) Event e happens over the time interval i
Initiates(e, f, t) Event e causes fluent f to start to hold at time t
Terminates(e, f, t) Event e causes fluent f to cease to hold at time t
Clipped(f, i) Fluent f ceases to be true at some point during time interval i
Restored (f, i) Fluent f becomes true sometime during time interval i
• We assume a distinguished event, Start , that describes the initial state by saying which
fluents are initiated or terminated at the start time. We define T by saying that a fluent holds
at a point in time if the fluent was initiated by an event at some time in the past and was not
made false (clipped) by an intervening event.
• A fluent does not hold if it was terminated by an event and not made true (restored) by
another event. Formally, the axioms are:
Happens(e, (t1, t2)) ∧ Initiates(e, f, t1) ∧ ¬Clipped(f, (t1, t)) ∧ t1 < t T(f, t)
Happens(e, (t1, t2)) ∧ Terminates(e, f, t1)∧ ¬Restored (f, (t1, t)) ∧ t1 < t ¬T(f,
t) where Clipped and Restored are defined by
Clipped(f, (t1, t2)) ⇔ ∃ e, t, t3 Happens(e, (t, t3)) ∧ t1 ≤ t < t2 ∧ Terminates(e, f, t)
Restored (f, (t1, t2)) ⇔ ∃ e, t, t3 Happens(e, (t, t3)) ∧ t1 ≤ t < t2 ∧ Initiates(e, f, t)

3.7 MENTAL EVENTS AND MENTAL OBJECTS


A mental event is any event that happens within the mind of a conscious individual.
Examples include thoughts, feelings, decisions, dreams, and realizations. Some believe that
mental events are not limited to human thought but can be associated with animals and artificial
intelligence as well. What we need is a model of the mental objects that are in someone’s head
(or something’s knowledge base) and of the mental processes that manipulate those mental
objects. The model does not have to be detailed. We do not have to be able to predict how many
milliseconds it will take for a particular agent to make a deduction. We will be happy just to be
able to conclude that mother knows whether or not she is sitting.
We begin with the propositional attitudes that an agent can have toward mental objects:
attitudes such as Believes, Knows, Wants, Intends, and Informs. The difficulty is that these
attitudes do not behave like “normal” predicates. For example, suppose we try to assert that
Lois knows that Superman can fly:
Knows(Lois, CanFly(Superman))

28
IFETCE R2019 Academic Year 2023-2024

One minor issue with this is that we normally think of CanFly(Superman) as a sentence,
but here it appears as a term. That issue can be patched up just be reifying CanFly(Superman);
making it a fluent. A more serious problem is that, if it is true that Superman is Clark Kent,
then we must conclude that Lois knows that Clark can fly:
(Superman = Clark) ∧ Knows(Lois , CanFly(Superman)) |= Knows(Lois,
CanFly(Clark ))
Modal logic is designed to address this problem. Regular logic is concerned with a
single modality, the modality of truth, allowing us to express “P is true.” Modal logic includes
special modal operators that take sentences (rather than terms) as arguments. For example,
“A knows P” is represented with the notation KAP, where K is the modal operator for
knowledge. It takes two arguments, an agent (written as the subscript) and a sentence. The
syntax of modal logic is the same as first-order logic, except that sentences can also be formed
with modal operators.
In first-order logic a model contains a set of objects and an interpretation that maps
each name to the appropriate object, relation, or function. In modal logic we want to be able
to consider both the possibility that Superman’s secret identity is Clark and that it isn’t.
Therefore, we will need a more complicated model, one that consists of a collection
of possible worlds rather than just one true world. The worlds are connected in a graph by
accessibility relations, one relation for each modal operator.

Figure 3.6 Possible worlds with accessibility relations KSuperman (solid arrows) and
KLois (dotted arrows).
We say that world w1 is accessible from world w0 with respect to the modal operator
KA if everything in w1 is consistent with what A knows in w0, and we write this as
Acc(KA,w0,w1). In diagrams such as Figure 5.3 we show accessibility as an arrow between
possible worlds.
In general, a knowledge atom KAP is true in world w if and only if P is true in every
world accessible from w. The truth of more complex sentences is derived by recursive
application of this rule and the normal rules of first-order logic.
That means that modal logic can be used to reason about nested knowledge sentences:
what one agent knows about another agent’s knowledge. For example, we can say that, even
though Lois doesn’t know whether Superman’s secret identity is Clark Kent, she does know
that Clark knows:
KLois [KClark Identity(Superman, Clark ) ∨ KClark¬Identity(Superman,
Clark )]

29
IFETCE R2019 Academic Year 2023-2024

In the TOP-LEFT diagram, it is common knowledge that Superman knows his own
identity, and neither he nor Lois has seen the weather report. So in w0 the worlds w0 and w2
are accessible to Superman; maybe rain is predicted, maybe not.
For Lois all four worlds are accessible from each other; she doesn’t know anything
about the report or if Clark is Superman. But she does know that Superman knows whether
he is Clark, because in every world that is accessible to Lois, either Superman knows I, or he
knows ¬I. Lois does not know which is the case, but either way she knows
Superman knows.
In the TOP-RIGHT diagram it is common knowledge that Lois has seen the weather
report. So in w4 she knows rain is predicted and in w6 she knows rain is not predicted.
Superman does not know the report, but he knows that Lois knows, because in every world
that is accessible to him, either she knows R or she knows ¬R.
In the BOTTOM diagram we represent the scenario where it is common knowledge
that Superman knows his identity, and Lois might or might not have seen the weather report.
We represent this by combining the two top scenarios, and adding arrows to show that
Superman does not know which scenario actually holds.
Lois does know, so we don’t need to add any arrows for her. In w0 Superman still
knows I but not R, and now he does not know whether Lois knows R. From what Superman
knows, he might be in w0 or w2, in which case Lois does not know whether R is true, or he
could be in w4, in which case she knows R, or w6, in which case she knows ¬R.
3.8 REASONING SYSTEMS FOR CATEGORIES
It describes systems specially designed for organizing and reasoning with categories.
There are two closely related families of systems: semantic networks provide graphical aids
for visualizing a knowledge base and efficient algorithms for inferring properties of an object
on the basis of its category membership; and description logics provide a formal language for
constructing and combining category definitions and efficient algorithms for deciding subset
and superset relationships between categories.
3.8.1 SEMANTIC NETWORKS
• A semantic network is a knowledge structure that depicts how concepts are related to one
another and illustrates how they interconnect. Semantic networks use artificial intelligence
(AI) programming to mine data, connect concepts and call attention to relationships.
• There are many variants of semantic networks, but all are capable of representing individual
objects, categories of objects, and relations among objects. A typical graphical notation
displays object or category names in ovals or boxes, and connects them with labeled links.
• For example, Figure 5.4 has a MemberOf link between Mary and FemalePersons ,
corresponding to the logical assertion Mary ∈FemalePersons ; similarly, the SisterOf link
between Mary and John corresponds to the assertion SisterOf (Mary, John). We can connect
categories using SubsetOf links, and so on.
• We know that persons have female persons as mothers, so can we draw a HasMother link
from Persons to FemalePersons? The answer is no, because HasMother is a relation
between a person and his or her mother, and categories do not have mothers. For this reason,
we have used a special notation—the double-boxed link—in Figure 12.5. This link asserts
that
∀x x∈ Persons ⇒ [∀ y HasMother (x, y) ⇒ y ∈ FemalePersons ]
• We might also want to assert that persons have two legs—that is,
∀x x∈ Persons ⇒ Legs(x, 2)
• The semantic network notation makes it convenient to perform inheritance reasoning . For
example, by virtue of being a person, Mary inherits the property of having two legs. Thus,
to find out how many legs Mary has, the inheritance algorithm follows the MemberOf link

30
IFETCE R2019 Academic Year 2023-2024

from Mary to the category she belongs to, and then follows SubsetOf links up the hierarchy
until it finds a category for which there is a boxed Legs link—in this case, the Persons
category.

Figure 3.6 A semantic network with four objects (John, Mary, 1, and 2) and four
categories.
• Inheritance becomes complicated when an object can belong to more than one category or
when a category can be a subset of more than one other category; this is called multiple
inheritance. The drawback of semantic network notation, compared to first-order logic:
the fact that links between bubbles represent only binary relations. For example, the
sentence
Fly(Shankar , NewYork,
NewDelhi ,Yesterday) cannot be asserted directly in a semantic network. Nonetheless,
we can obtain the effect of n-ary assertions by reifying the proposition itself as an event
belonging to an appropriate event category.

Figure 3.7 A fragment of a semantic network showing the representation of the logical
assertion Fly(Shankar ,NewYork,NewDelhi ,Yesterday).
• Figure 3.7 shows the semantic network structure for this particular event. Notice that the
restriction to binary relations forces the creation of a rich ontology of reified concepts.
• One of the most important aspects of semantic networks is their ability to represent default
values for categories. Examining Figure 5.5 carefully, one notices that John has one leg,
despite the fact that he is a person and all persons have two legs. In a strictly logical KB,
this would be a contradiction, but in a semantic network, the assertion that all persons have
two legs has only default status; that is, a person is assumed to have two legs unless this is
contradicted by more specific information.
3.8.2 Description logics
• The syntax of first-order logic is designed to make it easy to say things about objects.
Description logics are notations that are designed to make it easier to describe definitions
and properties of categories.
• Description logic systems evolved from semantic networks in response to pressure to
formalize what the networks mean while retaining the emphasis on taxonomic structure as
an organizing principle.

31
IFETCE R2019 Academic Year 2023-2024

Figure 3.8 The syntax of descriptions in a subset of the CLASSIC language


• The principal inference tasks for description logics are subsumption (checking if one
category is a subset of another by comparing their definitions) and classification
(checking whether an object belongs to a category).. Some systems also include
consistency of a category definition—whether the membership criteria are logically
satisfiable.
• The CLASSIC language is a typical description logic. The syntax of CLASSIC
descriptions. For example, to say that bachelors are unmarried adult males we would
write
Bachelor = And(Unmarried,Adult ,Male) .
• The equivalent in first-order logic would be
Bachelor (x) ⇔ Unmarried(x) ∧ Adult(x) ∧Male(x) .
• Notice that the description logic has an an algebra of operations on predicates, which of
course we can’t do in first-order logic. Any description in CLASSIC can be
translated into an equivalent first-order sentence, but some descriptions are more
straightforward in CLASSIC.
• For example, to describe the set of men with at least three sons who are all unemployed
and married to doctors, and at most two daughters who are all professors in physics or
math departments, we would use
And(Man,AtLeast (3, Son),AtMost(2,Daughter ),
All(Son,And(Unemployed,Married,All(Spouse,Doctor ))),
All(Daughter ,And(Professor ,Fills(Department ,Physics,Math)))) .
• We leave it as an exercise to translate this into first-order logic.
3.9 REASONING WITH DEFAULT INFORMATION
Default reasoning is a form of nonmonotonic reasoning where plausible conclusions
are inferred based on general rules which may have exceptions (defaults). Circumscription and
default logic and Truth maintenance systems.
3.9.1 Circumscription and default logic
We have seen two examples of reasoning processes that violate the monotonicity
property of logic. we saw that a property inherited by all members of a category in a semantic
network could be overridden by more specific information for a subcategory.
we saw that under the closed-world assumption, if a proposition _ is not mentioned in
KB then KB |= ¬_, but KB ∧ _ |= _.
Simple introspection suggests that these failures of monotonicity are widespread in
commonsense reasoning. It seems that humans often “jump to conclusions.” For example,
when one sees a car parked on the street, one is normally willing to believe that it has four
wheels even though only three are visible.

32
IFETCE R2019 Academic Year 2023-2024

Now, probability theory can certainly provide a conclusion that the fourth wheel exists
with high probability, yet, for most people, the possibility of the car’s not having four wheels
does not arise unless some new evidence presents itself. Thus, it seems that the four-wheel
conclusion is reached by default, in the absence of any reason to doubt it. If new evidence
arrives—for example, if one sees the owner carrying a wheel and notices that the car is jacked
up—then the conclusion can be retracted. This kind of reasoning is said to exhibit
nonmonotonicity, because the set of beliefs does not grow monotonically over time as new
evidence arrives. Nonmonotonic logics have been devised with modified notions of truth and
entailment in order to capture such behavior.
There are two such logics that have been studied extensively: circumscription and
default logic. Circumscription can be seen as a more powerful and precise version of the
closedworld assumption. The idea is to specify particular predicates that are assumed to be “as
false as possible”—that is, false for every object except those for which they are known to be
true.
For example, suppose we want to assert the default rule that birds fly. A predicate, say
Abnormal 1(x), and write
Bird(x) ∧ ¬Abnormal 1(x) ⇒ Flies(x) .
If we say that Abnormal 1 is to be circumscribed, a circumscriptive reasoner is entitled
to assume ¬Abnormal 1(x) unless Abnormal 1(x) is known to be true. This allows the
conclusion
Flies(Tweety) to be drawn from the premise Bird(Tweety), but the conclusion no
longer holds if Abnormal 1(Tweety) is asserted.
Circumscription can be viewed as an example of a model preference logic. In such
logics, a sentence is entailed (with default status) if it is true in all preferred models of the KB,
as opposed to the requirement of truth in all models in classical logic. For circumscription,
one model is preferred to another if it has fewer abnormal objects.
The standard example for which multiple inheritance is problematic is called the
“Nixon diamond.” It arises from the observation that Richard Nixon was both a Quaker (and
hence by default a pacifist) and a Republican (and hence by default not a pacifist). We can write
this as follows:
Republican(Nixon) ∧ Quaker(Nixon) .
Republican(x) ∧ ¬Abnormal 2(x) ⇒ ¬Pacifist(x) .
Quaker (x) ∧ ¬Abnormal 3(x) ⇒ Pacifist(x) .
If we circumscribe Abnormal 2 and Abnormal 3, there are two preferred models: one in
which Abnormal 2(Nixon) and Pacifist(Nixon) hold and one in which Abnormal (Nixon)
and ¬Pacifist(Nixon) hold. Thus, the circumscriptive reasoner remains properly agnostic as
to whether Nixon was a pacifist. If we wish, in addition, to assert that religious beliefs take
precedence over political beliefs, we can use a formalism called prioritized circumscription
to give preference to models where Abnormal 3 is minimized.
Default logic is a formalism in which default rules can be written to generate
contingent, nonmonotonic conclusions. A default rule looks like this:
Bird(x) : Flies(x)/Flies(x) .
This rule means that if Bird(x) is true, and if Flies(x) is consistent with the knowledge
base, then Flies(x) may be concluded by default. In general, a default rule has the form P : J1,
. . . , Jn/C where P is called the prerequisite, C is the conclusion, and Ji are the justifications—
if any one of them can be proven false, then the conclusion cannot be drawn.

33
IFETCE R2019 Academic Year 2023-2024

Any variable that appears in Ji or C must also appear in P. The Nixon-diamond example
can be represented in default logic with one fact and two default rules:
Republican(Nixon) ∧ Quaker(Nixon) .
Republican(x) : ¬Pacifist(x)/¬Pacifist(x) .
Quaker (x) : Pacifist(x)/Pacifist (x) .
To interpret what the default rules mean, we define the notion of an EXTENSION
extension of a default theory to be a maximal set of consequences of the theory. That is, an
extension S consists of the original known facts and a set of conclusions from the default rules,
such that no additional conclusions can be drawn from S and the justifications of every default
conclusion in S are consistent with S.
As in the case of the preferred models in circumscription, we have two possible extensions
for the Nixon diamond: one wherein he is a pacifist and one wherein he is not. Prioritized
schemes exist in which some default rules can be given precedence over others, allowing some
ambiguities to be resolved.
5.2 Truth maintenance systems
Many of the inferences drawn by a knowledge representation system will have only
default status, rather than being absolutely certain. Inevitably, some of these inferred facts will
turn out to be wrong and will have to be retracted in the face of new information. This process
is called belief revision.
Suppose that a knowledge base KB contains a sentence P—perhaps a default conclusion
recorded by a forward-chaining algorithm, or perhaps just an incorrect assertion—and we want
to execute TELL(KB, ¬P). To avoid creating a contradiction, we must first execute
RETRACT(KB, P). This sounds easy enough. Problems arise, however, if any additional
sentences were inferred from P and asserted in the KB.
For example, the implication P ⇒ Q might have been used to add Q. The obvious
“solution”—retracting all sentences inferred from P—fails because such sentences may have
other justifications besides P. For example, if R and R ⇒ Q are also in the KB, then Q does not
have to be removed after all. Truth maintenance systems, or TMSs, are designed to handle
exactly these kinds of complications.
One simple approach to truth maintenance is to keep track of the order in which sentences
are told to the knowledge base by numbering them from P1 to Pn. When the call
RETRACT(KB, Pi) is made, the system reverts to the state just before Pi was added, thereby
removing both Pi and any inferences that were derived from Pi. The sentences Pi+1 through
Pn can then be added again.
This is simple, and it guarantees that the knowledge base will be consistent, but retracting
Pi requires retracting and reasserting n − i sentences as well as undoing and redoing all the
inferences drawn from those sentences. For systems to which many facts are being added—
such as large commercial databases—this is impractical.
A more efficient approach is the justification-based truth maintenance JTMS system, or
JTMS. In a JTMS, each sentence in the knowledge base is annotated with a justification
consisting of the set of sentences from which it was inferred. For example, if the knowledge
base already contains P ⇒ Q, then TELL(P) will cause Q to be added with the justification
{P, P ⇒ Q}. In general, a sentence can have any number of justifications.
Justifications make retraction efficient. Given the call RETRACT(P), the JTMS will
delete exactly those sentences for which P is a member of every justification. So, if a sentence
Q had
the single justification {P, P ⇒ Q}, it would be removed; if it had the additional justification
{P, P ∨ R ⇒ Q}, it would still be removed; but if it also had the justification
{R, P ∨R ⇒ Q}, then it would be spared. In this way, the time required for retraction of P

34
IFETCE R2019 Academic Year 2023-2024

depends only on the number of sentences derived from P rather than on the number of other
sentences added since P entered the knowledge base.

35
IFETCE R2019 Academic Year 2022-
2023

36
IFETCE Regulation: 2019A Academic Year: 2023 - 2024

IFET COLLEGE OF ENGINEERING


(An Autonomous Institution)
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

SUBJECT TITLE: Foundations of AI UNIT: III


SUBJECT CODE: 19UCSPEX01 YEAR/SEM: III/VI

UNIT III KNOWLEDGE REPRESENTATION


First Order Predicate Logic – Prolog Programming – Unification – Forward Chaining-Backward
Chaining – Resolution – Knowledge Representation – Ontological Engineering-Categories and
Objects – Events – Mental Events and Mental Objects – Reasoning Systems for Categories –
Reasoning with Default Information

PART A (2MARKS)
First-Order Predicate Logic
1. Define First order Logic. 2 R
2. Does the fact ¬ Spouse(George, Laura) follow from the facts Jim = George and 2 A
Spouse(Jim, Laura)? If so, give a proof; if not, supply additional axioms as
needed. What happens if we use Spouse as a unary function symbol instead of a
binary predicate?
3. How can one characterize the logic? 2 U
4. Specify the syntax of First-order logic in BNF form. 2 S
5. Explain what is wrong with the following proposed definition of the set 2 A
membership predicate ∈ :
∀ x, s x ∈ {x|s}
∀ x, s x ∈ s ⇒ ∀ y x ∈ {y|s} .
6. Represent the sentence “All Germans speak the same language” in predicate 2 A
calculus. Use speaks(x,l), meaning that person x speaks language l.
7. Here are two sentences in the language of first-order logic: 2 A
(A) ∀x ∃ y (x >=y)
(B) ∃y ∀x (x >=y)
a. Assume that the variables range over all the natural numbers 0, 1, 2, . . . and that
the “>=” predicate means “is greater than or equal to.” Under this interpretation,
translate (A) and (B) into English.
b. Is (A) true under this interpretation?
8. What are quantifiers? 2 R
9. Explain the connection between ∀ and ∃. 2 U
10. Write down the connections between universal and existential quantifiers 2 R
11. From Likes(Jerry, IceCream) it seems reasonable to infer ∃ x Likes(x, IceCream). 2 A
Write down a general inference rule, Existential Introduction, which sanctions this
inference. State carefully the conditions that must be satisfied by the variables and
terms involved.
PROLOG programming
12. What is PROLOG? 2 R

1
IFETCE Regulation: 2019A Academic Year: 2023 - 2024

13. How to create the variable in PROLOG? 2 S


14. Construct the clause tree for factorial(3, W) where W=6 2 A
15. Satisfy the query for all sequence of goals by using Prolog for the following. 2 A
?- parent(josh, Child), write('The child is '), write(Child), nl.
16. Create a program to read the data using the following predicates of Prolog: 2 A
i. seeing(File)
ii. see(File)
iii. read(Data)
iv. seen
Unification , Forward Chaining, Backward Chaining, Resolution
17. What is meant the Unification? R
18. Write down the algorithm for forward-chaining. 2 S
19. Write down the algorithm for backward-chaining . 2 S
20. What is resolution? Write down the steps for resolution. 2 S
21. Represent the following seven sentences using and extending the representations 2 A
developed in the
a. Water is a liquid between 0 and 100 degrees.
b. Water boils at 100 degrees.
c. The water in John’s water bottle is frozen.
d. Perrier is a kind of water.
e. John has Perrier in his water bottle.
Knowledge Representation – Ontological Engineering-Categories and Objects –
Events – Mental Events and Mental Objects – Reasoning Systems for Categories
– Reasoning with Default Information
22. What is Ontological Engineering? 2 R
23. How to categories are useful in Knowledge representation? 2 U
24. Define event calculus. 2 R
25. What are semantic networks? 2 R
26. Semantic networks are capable of representing individual objects, categories of 2 A
objects, and relation among objects. Objects or Ctegory names are represented in
ovals and are connected by labeled arcs.
27. Represent the following seven sentences using and extending the representations 2 A
a) Water is a liquid between 0 and 100 degrees.
b) Water boils at 100 degrees.
28. Write event calculus axioms to describe the actions in the wumpus world. 2 S
29. Create the a fragment of a semantic network showing the representation of the logical 2 A
assertion Fly(Shankar ,NewYork,NewDelhi ,Yesterday).
30. What is the purpose of propositional attitudes for mental object? 2 S
PART – B
1. Explain Resolution and Unification algorithm with an example. 16 U
2. i) Describe about the mental objects and modal logic with an example R 8
ii) How to categories the reasoning systems in Knowledge representation U 8
3. Describe about forward and backward chaining with suitable example. 16 R
4. Explain about the ontological engineering with an example. 16 R
5. Illustrate the syntactic elements of first-Order logic 16 U

2
IFETCE Regulation: 2019A Academic Year: 2023 - 2024

6. (a) Prove that Universal Instantiation is sound and that Existential Instantiation 16 A
produces an inferentially equivalent knowledge base.
(b) From Likes(Jerry,IceCream) it seems reasonable to infer ∃x Likes (x,IceCream).
Write down a general inference rule, that sanctions this inference.
c)Suppose a knowledge base contains just one sentence, ∃x
AsHighAs(x,Everest).Which of the following are legitimate results of applying
Existential Instantiation?
AsHighAs(Everest,Everest).
✓ AsHighAs(Kilimanjaro,Everest)
AsHighAs(Kilimanjaro,Everest) ∧ AsHighAs(BenNevis,Everest)\ (after two
applications).
7. i) From “Horses are animals,”it follows that “The head of a horse is the head of an 8 A
animal.” Demonstrate that this inference is valid by carrying out the following steps:
a. Translate the premise and the conclusion into the language of first-order logic.
Use three predicates: HeadOf(h, x) (meaning “h is the head of x”), Horse(x), and
Animal(x).
b. Negate the conclusion, and convert the premise and the negated conclusion
into conjunctive normal form.
c. Use resolution to show that the conclusion follows from the premise.
ii) Complete the following exercises about logical senntences:
a. Translate into good, natural English (no xs or ys!): 8 A
∀x,y,lSpeaksLanguage(x,l) ∧ SpeaksLanguage(y,l) ⇒ Understands(x,y) ∧
Understands(y,x).
b. Explain why this sentence is entailed by the sentence
∀x,y,lSpeaksLanguage(x,l) ∧ SpeaksLanguage(y,l) ⇒ Understands(x,y).
c. Translate into first-order logic the following sentences:
(i) Understanding leads to friendship.
(ii) Friendship is transitive.
Remember to define all predicates, functions, and constants you use.
8. In mathematics, the famous problem was coloring adjacent planar regions. Two 16 A
adjacent regions cannot have the same color no matter whatever color we choose. Two
regions which share some boundary line are considered adjacent to each other. In the
following map, the region is shown by some numerical names.
Solve this problem by using Map Coloring in Prolog.

3
IFETCE Regulation: 2019A Academic Year: 2023 - 2024

4
IFETCE Regulation: 2019A Academic Year: 2023 - 2024

IFET COLLEGE OF ENGINEERING


(An Autonomous Institution)
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

SUBJECT TITLE: Foundations of AI UNIT: III


SUBJECT CODE: 19UCSPEX01 YEAR/SEM: III/VI

UNIT III KNOWLEDGE REPRESENTATION


First Order Predicate Logic – Prolog Programming – Unification – Forward Chaining-
Backward Chaining – Resolution – Knowledge Representation – Ontological Engineering-
Categories and Objects – Events – Mental Events and Mental Objects – Reasoning Systems for
Categories – Reasoning with Default Information
Application solved

PART-A
2. Does the fact ¬ Spouse(George, Laura) follow from the facts Jim = George and
Spouse(Jim, Laura)? If so, give a proof; if not, supply additional axioms as
needed. What happens if we use Spouse as a unary function symbol instead of a
binary predicate?
The fact ¬Spouse(George, Laura) does not follow. We need to assert that at most one person
can be the spouse of any given person:
∀x,y,z Spouse(x,z) ∧ Spouse(y,z) ⇒ x = y .
With this axiom, a resolution proof of ¬Spouse(George, Laura) is straightforward. If Spouse
is a unary function symbol, then the question is whether ¬Spouse(Laura) = George follows
from Jim 6= George and Spouse(Laura) = Jim. The answer is yes, it does follow.
They could not both be the value of the function applied to the same argument if they
were different objects.

5. Explain what is wrong with the following proposed definition of the set membership
predicate ∈ :
∀ x, s x ∈ {x|s}
∀x, s x ∈ s ⇒∀ y x ∈ {y|s} .
Although these axioms are sufficient to prove set membership when x is in fact a member of
a given set, they have nothing to say about cases where x is not a member. For example, it is
not possible to prove that x is not a member of the empty set. These axioms may therefore be
suitable for a logical system, such as Prolog, that uses negation-as-failure.

6. Represent the sentence “All Germans speak the same language” in predicate calculus.
Use speaks(x,l), meaning that person x speaks language l.
To speaks(x,l), meaning that person x speaks language l.
Representation of predicate calculus are:
A(x, y, l) German (x) ^ German (y) ^ Speaks (x, l) => Speaks (y,l)

7. Here are two sentences in the language of first-order logic:

(A) ∀x ∃ y (x >=y)

(B) ∃y ∀x (x >=y)
IFETCE Regulation: 2019A Academic Year: 2023 - 2024

a. Assume that the variables range over all the natural numbers 0, 1, 2, . . . and that the
“>=” predicate means “is greater than or equal to.” Under this interpretation, translate
(A) and (B) into English.

b. Is (A) true under this interpretation?

(A) translates to “For every natural number there is some other natural number that is smaller
than or equal to it.”

(B) translates to “There is a particular natural number that is smaller than or equal to any
natural number.” b. Yes, (A) is true under this interpretation. You can always pick the number
itself for the “some other” number.

11. From Likes(Jerry, IceCream) it seems reasonable to infer ∃ x Likes(x, IceCream).


Write down a general inference rule, Existential Introduction, that sanctions this
inference. State carefully the conditions that must be satisfied by the variables and terms
involved.
For any sentence α containing a ground term g and for any variable v not occurring in α, we
have α/∃ v S UBST∗({g/v},α)
where S UBST∗ is a function that substitutes any or all of the occurrences of g with v. Notice
that substituting just one occurrence and applying the rule multiple times is not the same,
because it results in a weaker conclusion. For example, P(a,a) should entail ∃ x P(x,x)
rather than the weaker ∃x,y P(x,y).

14. Construct the clause tree for factorial(3, W) where W=6.


• Each branch can be determined by a clause under a node.
• Using the instance of head of clause, the node of the tree can be determined. In the
clause tree, the children of the node can be determined by the body literals of the clause.

15. Satisfy the query for all sequence of goals by using Prolog for the following.

?- parent(josh, Child), write('The child is '), write(Child), nl.


Firstly, for variable Child, Prolog finds one or more possible values. It starts with the first
goal parent(josh, Child). Prolog tries to unify the first goal with the head of each clause, which
defines the predicate parent/2 in turn. To unify this, Prolog works from top to bottom. Clause
[P1] and [P2] firstly search, but Prolog fails to match the goal with either of them. Now, Prolog
searches the clause [P3], and this time Prolog is successful in unifying the goal with the clause's
head, with A is bound to josh, and variable B is bound to variable Child.
[P3] parent(josh, B) :- write('mother?'), nl, mother(josh, B), write('mother!'), nl.
It will succeed with A is bound to josh, and variable B is bound to variable Child.
IFETCE Regulation: 2019A Academic Year: 2023 - 2024

16. Create a program to read the data using the following predicates of Prolog:
i. seeing(File)
ii. see(File)
iii. read(Data)
iv. seen
To provide the input source, File= 'user ' will choose the keyboard. Otherwise, File should be
the existing file disk name. The following program shows a program to read the file data and
print it to the screen as follows:
browse(File) :-
seeing(Old), /*It will save for later */
see(File), /* It will open this file */
repeat,
read(Data), /* It will read from the file */
process(Data),
seen, /* It will close the file */
seen(Old), /* It will show the previous read source */
! / * It means stop now */
process(end-of-file) :- ! .
process(Data) :- write(Data), nl, fail.

21. Represent the following seven sentences using and extending the representations
developed in the
a. Water is a liquid between 0 and 100 degrees.
b. Water boils at 100 degrees.
c. The water in John’s water bottle is frozen.
d. Perrier is a kind of water.
e. John has Perrier in his water bottle.
a. ∀w,s w ∈ Water ⇒
(Centigrade(0) < Temperature(w,s) < Centigrade(100)) ⇔
T(w ∈Liquid,s)
b. SBoilingPoint(c,bp) ⇔
∀x,s x∈ c ⇒
(∀ t T(Temperature(x,t),s) ∧ t >bp⇒ T(x∈Gas,s))
c. ∃ b ∀ w w∈ Water ∧b∈WaterBottles∧Has(John,b,Now)
∧ Inside(w,b,Now) ⇒ (w ∈Solid,Now)
d. Perrier ⊂ Water
e. ∃ b ∀ w w∈ Water ∧b∈WaterBottles∧Has(John,b,Now)
∧ Inside(w,b,Now) ⇒ w ∈ Perrier

26. Semantic networks are capable of representing individual objects, categories of


objects, and relation among objects. Objects or Ctegory names are represented in ovals
and are connected by labeled arcs.
IFETCE Regulation: 2019A Academic Year: 2023 - 2024

27. Represent the following seven sentences using and extending the representations
Water is a liquid between 0 and 100 degrees.

(w ⊂ Water) ⇒ (Degrees(0) < Temp(w) < Degrees(100))^Liquid(w)

b) Water boils at 100 degrees.

(w ⊂ Water) ^ Boiling(w) ⇒ Temp(w) ≥ Degrees(100)

29. Create the a fragment of a semantic network showing the representation of the
logical assertion Fly(Shankar ,NewYork,NewDelhi ,Yesterday).

PART-B

6. c) Prove that Universal Instantiation is sound and that Existential Instantiation produces an 16 A
inferentially equivalent knowledge base.
d) From Likes(Jerry,IceCream) it seems reasonable to infer ∃x Likes (x,IceCream). Write
down a general inference rule, , that sanctions this inference.
e) Suppose a knowledge base contains just one sentence, ∃x AsHighAs(x,Everest).Which of the
following are legitimate results of applying Existential Instantiation?
✓ AsHighAs(Everest,Everest)
✓ AsHighAs(Kilimanjaro,Everest)
✓ AsHighAs(Kilimanjaro,Everest)∧AsHighAs(BenNevis,Everest)\ (after two
applications).
IFETCE Regulation: 2019A Academic Year: 2023 - 2024

a. We want to show that any sentence of the form ∀v α entails any universal instantiation of the
sentence. The sentence ∀v α asserts that α is true in all possible extended interpretations. For any
model specifying the referent of ground term g, the truth of SUBST({v/g}, α) must be identical to
the truth value of some extended interpretation in which v is assigned to an object, and in all such
interpretations α is true.
EI states: for any sentence α, variable v, and constant symbol k that does not appear elsewhere in
the knowledge base, ∃v α SUBST({v/k}, α)
If the knowledge base with the original existentially quantified sentence is KB and the result of EI
is KB′, then we need to prove that KB is satisfiable iff KB′ is satisfiable. Forward: if KB is
satisfiable, it has a model M for which an extended interpretation assigning v to some object o
renders α true. Hence, we can construct a model M′ that satisfies KB′ by assigning
K to refer to o; since k does not appear elsewhere, the truth values of all other sentences are
unaffected. Backward: if KB′ is satisfiable, it has a model M′ with an assignment for k to some
object o. Hence, we can construct a model M that satisfies KB with an extended interpretation
assigning v to o; since k does not appear elsewhere, removing it from the model leaves the truth
values of all other sentences are unaffected.
b. For any sentence α containing a ground term g and for any variable v not occuring in α, we have
α/ ∃v SUBST∗({g/v}, α) where SUBST* is a function that substitutes any or all of the occurrences
of g with v. Notice that substituting just one occurrence and applying the rule multiple times is not
the same, because it results in a weaker conclusion. For example, P(a, a) should entail ∃x P(x, x)
rather than the weaker ∃x, y P(x, y).
c. Both b and c are sound conclusions; a is unsound because it introduces the previously used
symbol Everest. Note that c does not imply that there are two mountains as high as Everest,
because nowhere is it stated that BenNevis is different from Kilimanjaro (or Everest, for that
matter).

7.(i) From “Horses are animals,” it follows that “The head of a horse is the head of an 8 A
animal.” Demonstrate that this inference is valid by carrying out the following steps:
a. Translate the premise and the conclusion into the language of first-order logic. Use three
predicates: HeadOf(h, x) (meaning “h is the head of x”), Horse(x), and Animal(x).
b. Negate the conclusion, and convert the premise and the negated conclusion into
conjunctive normal form.
c. Use resolution to show that the conclusion follows from the premise.
This is a form of inference used to show that Aristotle’s syllogisms could not captureall sound
inferences.
a. ∀ x Horse(x) ⇒ Animal(x)
∀ x,h Horse(x) ∧ HeadOf(h,x) ⇒ ∃ y Animal(y) ∧ HeadOf(h,y)
b. A. ¬Horse(x) ∨ Animal(x)
B. Horse(G)
C. HeadOf(H,G)
D. ¬Animal(y) ∨ ¬HeadOf(H,y)
(Here A. comes from the first sentence in a. while the others come from the second. H and G are
Skolem constants.)
c. Resolve D and C to yield ¬Animal(G). Resolve this with A to give ¬Horse(G).Resolve this
with B to obtain a contradiction.
IFETCE Regulation: 2019A Academic Year: 2023 - 2024

7(ii) Complete the following exercises about logical senntences: 8 A


a. Translate into good, natural English (no xs or ys!):
∀x,y,lSpeaksLanguage(x,l) ∧SpeaksLanguage(y,l)
⇒ Understands(x,y) ∧ Understands(y,x).
b. Explain why this sentence is entailed by the sentence

∀x,y,lSpeaksLanguage(x,l) ∧SpeaksLanguage(y,l)
⇒ Understands(x,y).
c. Translate into first-order logic the following sentences:
(i) Understanding leads to friendship.
(ii) Friendship is transitive.
Remember to define all predicates, functions, and constants you use.
a. People who speak the same language understand each other.
b. Suppose that an extended interpretation with x → A and y → B satisfy
SpeaksLanguage(x,l) ∧SpeaksLanguage(y,l)
for some l. Then from the second sentence we can conclude Understands(A,B). The
extended interpretation with x → B and y → A also must satisfy
SpeaksLanguage(x,l) ∧SpeaksLanguage(y,l) ,
allowing us to conclude Understands(B,A). Hence, whenever the second sentence
holds, the first holds.
c. Let Understands(x,y) mean that x understands y, and let Friend(x,y) mean that x
is a friend ofy.
(i) It is not completely clear if the English sentence is referring to mutual understanding and
mutual friendship, but let us assume that is what is intended:
∀x,y Understands(x,y)∧Understands(y,x) ⇒ (Friend(x,y)∧Friend(y,x)).
(ii) ∀x,y,z Friend(x,y) ∧ Friend(y,z) ⇒ Friend(x,z).

8. In mathematics, the famous problem was coloring adjacent planar regions. Two 16
adjacent regions cannot have the same color no matter whatever color we choose. Two
regions which share some boundary line are considered adjacent to each other. In the
following map, the region is shown by some numerical names. How to solve this
problem by using Map Coloring in Prolog.

The above numerical name shows which regions are adjacent. Now we are going to consider
the following graph:
IFETCE Regulation: 2019A Academic Year: 2023 - 2024

In the above graph, the original boundaries are erased. Now, we have an arc between the two
regions name. The arc shows that both regions are adjacent in the original drawing. All the
original adjacency information is conveyed by the adjacency graph. Using the following facts
or unit clause, the adjacent information can represent in Prolog.
adjacent(1,2). adjacent(2,1).

adjacent(1,3). adjacent(3,1).

adjacent(1,4). adjacent(4,1).

adjacent(1,5). adjacent(5,1).

adjacent(2,3). adjacent(3,2).

adjacent(2,4). adjacent(4,2).

adjacent(3,4). adjacent(4,3).

adjacent(4,5). adjacent(5,4).

In prolog, if we load these clauses, we will get the following behavior for some goals.
?- adjacent(2, 3)

yes

?- adjacent(5, 3)

no

?- adjacent(3, 1)

no

?- adjacent(3,2)

no

In prolog, one could declare coloring for the regions. It will also use unit clauses.
color(1, orange, x). color(1, orange, y).

color(2, pink, x). color(2, pink, y).


IFETCE Regulation: 2019A Academic Year: 2023 - 2024

color(3, purple, x). color(3, purple, y).

color(4, red, x). color(4, pink, y).

color(5, pink, x). color(5, purple, y).

Here 'x' and 'y' colorings are encoded. In prolog, two adjacent regions which have the same
color show the definition of conflictive coloring. The following example shows the prolog
rule or clause to that effect.
conflict(R1, R2, Coloring) :-

adjacent(R1, R2),

color(R1, Color, Coloring),

color(R2, Color, Coloring).

Prolog distinguishes the two definitions of 'conflict'. 1st definition defines 1 logical
parameter. The 2nd definition defines 3 parameters. Now we have,
?- conflict(R1, R2, y)

R1=2 R2=4

?- conflict(R1, R2, y), color(R1, Z, y).

R1= 2 R2=4 Z = blue

The above example shows that region 2 and region 4 both are adjacent. It also shows that
regions 2 and 4 both are blue. The consequences of prolog program are shown by grounded
instance conflict(2, 4, y). One way to demonstrate such a consequence is to draw a program
clause tree. In which, root of the tree contains the consequence, to branch the tree, it uses the
clause of the program, and lastly, it will produce a finite tree which has all true leaves. Using
the fully grounded instance of the clause, we can construct the clause tree, which is shown
as follows:

In the above tree, the bottom leftmost branch corresponds to the unit clause.
adjacent(2,4)
In prolog, this branch is equivalent to the clause

adjacent(2,4) :- true

In prolog, the consequence of the program is not shown by 'conflict(1, 3, b)' because we can
construct a finite clause tree using grounded clauses of P, which contains all 'true' leaves.
Likewise, a consequence of the program is shown by 'conflict(a)'. To compute all possible
colorings, we will develop a program in prolog. The famous four-color conjecture states that
IFETCE Regulation: 2019A Academic Year: 2023 - 2024

to color regions of the tree, we don't require more than four colors. The following example
shows that we require at least four colors:
IFETCE R-2019 Academic Year: 2023 - 2024
IFET COLLEGE OF ENGINEERING
(An Autonomous Institution)
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

SUBJECT TITLE: Foundations of AI UNIT: IV


SUBJECT CODE: 19UCSPEX01 YEAR/SEM: III/VI

UNIT IV SOFTWARE AGENTS


Architecture for Intelligent Agents – Agent communication – Negotiation and Bargaining –
Argumentation among Agents – Trust and Reputation in Multi-agent systems.
4.1 Architecture for Intelligent Agents
Agent architectures, like software architectures, are formally a description of the elements from which
a system is built and the manner in which they communicate. Further, these elements can be defined
from patterns with specific constraints. [Shaw/Garlin 1996]
1. A number of common architectures exist that go by the names pipe-and filter or layered architecture.
2. These define the interconnections between components.
3. Pipe-and-Filter defines a model where data is moved through a set of one or more objects that
perform a transformation.
4. Layered simply means that the system is comprised of a set of layers that provide a specific set of
logical functionalities and that connectivity is commonly restricted to the layers contiguous to one
another.
Types of Architectures
Based on the goals of the agent application, a variety of agent architectures exist to help. This section will
introduce some of the major architecture types and applications for which they can be used.
1. Reactive architectures
2. Deliberative architectures
3. Blackboard architectures
4. Belief-desire-intention (BDI) architecture
5. Hybrid architectures
6. Mobile architectures
4.1.1 REACTIVE ARCHITECTURES
1. A reactive architecture is the simplest architecture for agents.
2. In this architecture, agent behaviors are simply a mapping between stimulus and response.
3. The agent has no decision-making skills, only reactions to the environment in which it exists.
4. The agent simply reads the environment and then maps the state of the environment to one or more
actions. Given the environment, more than one action may be appropriate, and therefore the agent must
choose.

1
IFETCE R-2019 Academic Year: 2023 - 2024
5. The advantage of reactive architectures is that they are extremely fast.
6. This kind of architecture can be implemented easily in hardware, or fast in software lookup.
7. The disadvantage of reactive architectures is that they apply only to simple environments.
8. Sequences of actions require the presence of state, which is not encoded into the mapping function.

4.1.2 DELIBERATIVE ARCHITECTURES

1. A deliberative architecture, as the name implies, is one that includes some deliberation over the action
to perform given the current set of inputs.
2. Instead of mapping the sensors directly to the actuators, the deliberative architecture considers the
sensors, state, prior results of given actions, and other information in order to select the best action to
perform.
3. The mechanism for action selection as is undefined. This is because it could be a variety of mechanisms
including a production system, neural network, or any other intelligent algorithm.
4. The advantage of the deliberative architecture is that it can be used to solve much more complex
problems than the reactive architecture.
5. It can perform planning, and perform sequences of actions to achieve a goal.

2
IFETCE R-2019 Academic Year: 2023 - 2024
6. The disadvantage is that it is slower than the reactive architecture due to the deliberation for the action
to select.
4.1.3 BLACKBOARD ARCHITECTURES
1. The blackboard architecture is a very common architecture that is also very interesting.
2. The first blackboard architecture was HEARSAY-II, which was a speech understanding system. This
architecture operates around a global work area call the blackboard.
3. The blackboard is a common work area for a number of agents that work cooperatively to solve a given
problem.
4. The blackboard therefore contains information about the environment, but also intermediate work
results by the cooperative agents.
5. In this example, two separate agents are used to sample the environment through the available sensors
(the sensor agent) and also through the available actuators (action agent).
6. The blackboard contains the current state of the environment that is constantly updated by the sensor
agent, and when an action can be performed (as specified in the blackboard), the action agent translates
this action into control of the actuators.
7. The control of the agent system is provided by one or more reasoning agents.
8. These agents work together to achieve the goals, which would also be contained in the blackboard.
9. In this example, the first reasoning agent could implement the goal definition behaviors, where the
second reasoning agent could implement the planning portion (to translate goals into sequences of
actions).
10. Since the blackboard is a common work area, coordination must be provided such that agents don’t
step over one another.
11. For this reason, agents are scheduled based on their need. For example, agents can monitor the
blackboard, and as information is added, they can request the ability to operate.
13. The scheduler can then identify which agents desire to operate on the blackboard, and then invoke
them accordingly.
14. The blackboard architecture, with its globally available work area, is easily implemented with a
multithreading system.
15. Each agent becomes one or more system threads. From this perspective, the blackboard architecture
is very common for agent and non-agent systems.

3
IFETCE R-2019 Academic Year: 2023 - 2024

4.1.4. BELIEF-DESIRE-INTENTION (BDI) ARCHITECTURE

1. BDI, which stands for Belief-Desire-Intention, is an architecture that follows the theory of human
reasoning as defined by Michael Bratman.
2. Belief represents the view of the world by the agent (what it believes to be the state of the environment
in which it exists). Desires are the goals that define the motivation of the agent (what it wants to achieve).
3. The agent may have numerous desires, which must be consistent. Finally, Intentions specify that the
agent uses the Beliefs and Desires in order to choose one or more actions in order to meet the desires.
4. As we described above, the BDI architecture defines the basic architecture of any deliberative agent. It
stores a representation of the state of the environment (beliefs), maintains a set of goals (desires), and
finally, an intentional element that maps desires to beliefs (to provide one or more actions that modify the
state of the environment based on the agent’s needs).
4.1.5. HYBRID ARCHITECTURES
1. As is the case in traditional software architecture, most architectures are hybrids.
2. For example, the architecture of a network stack is made up of a pipe-and-filter architecture and a
layered architecture.

4
IFETCE R-2019 Academic Year: 2023 - 2024
3. This same stack also shares some elements of a blackboard architecture, as there are global elements
that are visible and used by each component of the architecture.
4. The same is true for agent architectures. Based on the needs of the agent system, different architectural
elements can be chosen to meet those needs.
4.1.6. MOBILE ARCHITECTURES
1. The final architectural pattern is the mobile agent architecture.
2. This architectural pattern introduces the ability for agents to migrate themselves between hosts. The
agent architecture includes the mobility element, which allows an agent to migrate from one host to
another.
3. An agent can migrate to any host that implements the mobile framework.
4. The mobile agent framework provides a protocol that permits communication between hosts for agent
migration.
5. This framework also requires some kind of authentication and security, to avoid a mobile agent
framework from becoming a conduit for viruses. Also implicit in the mobile agent framework is a means
for discovery.
6. For example, which hosts are available for migration, and what services do they provide?
Communication is also implicit, as agents can communicate with one another on a host, or across hosts in
preparation for migration.
7. The mobile agent architecture is advantageous as it supports the development of intelligent distributed
systems. But a distributed system that is dynamic, and whose configuration and loading is defined by the
agents themselves.

ARCHITECTURE DESCRIPTIONS
1. Subsumption Architecture (Reactive Architecture)
2. Behavior Networks (Reactive Architecture)

5
IFETCE R-2019 Academic Year: 2023 - 2024
3. ATLANTIS (Deliberative Architecture)
4. Homer (Deliberative Arch)
5. BB1 (Blackboard)
6. Open Agent Architecture (Blackboard)
7. Procedural Reasoning System (BDI)
8. Aglets (Mobile)
9. Messengers (Mobile)
10. Soar (Hybrid)
SUBSUMPTION ARCHITECTURE (REACTIVE ARCHITECTURE)
1. The Subsumption architecture, originated by Rodney Brooks in the late 1980s, was created out of
research in behavior-based robotics.
2. The fundamental idea behind subsumption is that intelligent behavior can be created through a
collection of simple behavior modules.
3. These behavior modules are collected into layers. At the bottom are behaviors that are reflexive in
nature, and at the top, behaviors that are more complex.
4. At the bottom (level 0) exist the reflexive behaviors (such as obstacle avoidance). If these behaviors are
required, then level 0 consumes the inputs and provides an action at the output. But no obstacles exist, so
the next layer up is permitted to subsume control.
5. At each level, a set of behaviors with different goals compete for control based on the state of the
environment.
6. To support this capability levels can be inhibited (in other words, their outputs are disabled). Levels can
also be suppressed such that sensor inputs are routed to higher layers. As shown the figure 4.6.
subsumption is a parallel and distributed architecture for managing sensors and actuators. The basic
premise is that we begin with a simple set of behaviors, and once we’ve succeeded there, we extend with
additional levels and higher- level behaviors.
7. For example, we begin with obstacle avoidance and then extend for object seeking. From this
perspective, the architecture takes a more evolutionary design approach.
8. Subsumption does have its problems. It is simple, but it turns out not to be extremely extensible. As
new layers are added, the layers tend to interfere with one another, and then the problem becomes how to
layer the behaviors such that each has the opportunity to control when the time is right.
9. Subsumption is also reactive in nature, meaning that in the end, the architecture still simply maps inputs
to behaviors (no planning occurs, for example). What subsumption does provide is a means to choose
which behavior for a given environment.

6
IFETCE R-2019 Academic Year: 2023 - 2024

BEHAVIOR NETWORKS (REACTIVE ARCHITECTURE)


1. Behavior networks, created by Pattie Maes in the late 1980s, is another reactive architecture that is
distributed in nature. Behavior networks attempt to answer the question, which action is best suited for a
given situation.
2. As the name implies, behavior networks are networks of behaviors that include activation links and
inhibition links.
3. An example behavior network for a game agent is shown in Figure 11.14. As shown in the legend,
behaviors are rectangles and define the actions that the agent may take (attack, explore, reload, etc.).
4. The ovals specify the preconditions for actions to be selected, which are inputs from the environment.
5. Preconditions connect to behaviors through activation links (they promote the behavior to be
performed) or inhibition links (that inhibit the behavior from being performed).
6. The environment is sampled, and then the behavior for the agent is selected based on the current state
of the environment. The first thing to note is the activation and inhibition links. For example, when the
agent’s health is low, attack and exploration are inhibited, leaving the agent to find the nearest shelter.
Also, while exploring, the agent may come across medkits or ammunition.
7. If a medkit or ammunition is found, it’s used. Maes’ algorithm referred to competence modules, which
included preconditions (that must be fulfilled before the module can activate), actions to be performed, as
well as a level of activation.
8. The activation level is a threshold that is used to determine when a competence module may activate.
9. The algorithm also includes decay, such that activiations dissipate over time. Like the subsumption
architecture, behavior networks are instances of Behavior-Based Systems (BBS). The primitive actions
produced by these systems are all behaviors, based on the state of the environment.
10. Behavior networks are not without problems. Being reactive, the architecture does not support
planning or higher- level behaviors. The architecture can also suffer when behaviors are highly inter-
dependent. With many competing goals, the behavior modules can grow dramatically in order to realize
the intended behaviors. But for simpler architecture, such as the FPS game agent this algorithm is ideal.

7
IFETCE R-2019 Academic Year: 2023 - 2024

➢ ATLANTIS (Deliberative Architecture)

1. The goal of ATLANTIS (A Three-Layer Architecture for Navigating Through Intricate Situations), was
to create a robot that could navigate through dynamic and imperfect environments in pursuit of explicitly
stated high-level goals.
2. ATLANTIS was to prove that a goal-oriented robot could be built from a hybrid architecture of lower-
level reactive behaviors and higher- level deliberative behaviors.
3. Where the subsumption architecture allows layers to subsume control, ATLANTIS operates on the
assumption that these behaviors are not exclusive of one another. The lowest layer can operate in a reactive
fashion to the immediate needs of the environment, while the uppermost layer can support planning and
more goal-oriented behaviors.
4. In ATLANTIS, control is performed from the bottom- up. At the lowest level (the control layer) are the
reactive behaviors.

8
IFETCE R-2019 Academic Year: 2023 - 2024
5. These primitive level actions are capable of being executed first, based on the state of the environment.
At the next layer is the sequencing layer. This layer is responsible for executing plans created by the
deliberative layer.
6. The deliberative layer maintains an internal model of the environment and creates plans to satisfy goals.
7. The sequencing layer may or may not complete the plan, based on the state of the environment. This
leaves the deliberation layer to perform the computationally expensive tasks. This is another place that
the architecture is a hybrid.
8. The lower- level behavior-based methods (in the controller layer) are integrated with higher- level
classical AI mechanisms (in the deliberative layer). Interestingly, the deliberative layer does not control
the sequencing layer, but instead simply advises on sequences of actions that it can perform.
9. The advantage of this architecture is that the low- level reactive layer and higher- level intentional layers
are asynchronous. This means that while deliberative plans are under construction, the agent is not
susceptible to the dynamic environment. This is because even though planning can take time at the
deliberative layer, the controller can deal with random events in the environment.

➢ HOMER (DELIBERATIVE ARCH)


1. Homer is another interesting deliberative architecture that is both modular and integrated. Homer was
created by Vere and Bickmore in 1990 as a deliberative architecture with some very distinct differences
to other architectures.
2. At the core of the Homer architecture is a memory that is divided into two parts. The first part contains
general knowledge (such as knowledge about the environment). The second part is called episodic
knowledge, which is used to record experiences in the environment (perceptions and actions taken).
3. The natural language processor accepts human input via a keyboard, and parses and responds using a
sentence generator. The temporal planner creates dynamic plans to satisfy predefined goals, and is
capable of replanning if the environment requires.
4. The architecture also includes a plan executor (or interpreter), which is used to execute the plan at the
actuators. The architecture also included a variety of monitor processes. The basic idea behind Homer
was an architecture for general intelligence.
5. The keyboard would allow regular English language input, and a terminal would display generated
English language sentences. The user could therefore communicate with Homer to specify goals and
receive feedback via the terminal.
6. Homer could log perceptions of the world, with timestamps, to allow dialogue with the user and rational
answers to questions. Reflective (monitor) processes allow Homer to add or remove knowledge from
the episodic memory.
7. Homer is an interesting architecture implementing a number of interesting ideas, from natural language
processing to planning and reasoning. One issue found in Homer is that when the episodic memory
grows large, it tends to slow down the overall operation of the agent.

9
IFETCE R-2019 Academic Year: 2023 - 2024

➢ BB1 (BLACKBOARD)
1. BB1 is a domain- independent blackboard architecture for AI systems created by Barbara Hayes- Roth.
The architecture supports control over problem solving as well as explaining its actions. The architecture
is also able to learn new domain knowledge.
2. BB1 includes two blackboards; a domain blackboard which acts as the global database and a control
blackboard, which is used for generating a solution to the given control problem.
3. The key behind BB1 is its ability to incrementally plan. Instead of defining a complete plan for a given
goal, and then executing that plan, BB1 dynamically develops the plan and adapts to the changes in the
environment. This is key for dynamic environments, where unanticipated changes can lead to brittle plans
that eventually fail.
4. As a blackboard architecture, knowledge sources introduce new knowledge to the blackboard for one
or more users. The change of knowledge in a blackboard serves as a trigger for operation by users.
5. In BB1, control solutions are dynamically generated using knowledge from the domain blackboard
from control knowledge in the control blackboard. A scheduler manages which blackboard users should
get the ability to execute.

➢ OPEN AGENT ARCHITECTURE (BLACKBOARD)


1. The Open Agent Architecture (or OAA) is a blackboard architecture in which all agents communicate
through the blackboard (via a server process).
2. The server process acts in a number of roles. It coordinates activities between the client agents (deciding
which can act on knowledge on the blackboard) as well as providing communication between client
agents.
3. When knowledge is applied to the blackboard (through the server), the server decides which agent
should be notified and then schedules them accordingly.
4. The language used to communicate between agents in OAA is an extension of Prolog. A new agent
registers itself with the server, and can install triggers that monitor incoming data into the blackboard.

10
IFETCE R-2019 Academic Year: 2023 - 2024
5. The trigger serves as a request such that when knowledge arrives, the server can route the data to the
agent for further processing. Agents may also communicate with other agents through the server.
6. This can be done for the purpose of requesting activities of other agents. The server (and blackboard)
also provide the means for broadcast communications to globally coordinate between the agents.
7. The OAA is a useful generic architecture for multi-agent programming with a common communication
structure. The agent communication language, using Prolog, makes it useful to communicate not only
generic requests and responses, but also knowledge and semantic queries.

➢PROCEDURAL REASONING SYSTEM (BDI)


1. The Procedural Reasoning System (PRS) is a general-purpose architecture that’s ideal for reasoning
environments where actions can be defined by predetermined procedures (action sequences).
2. PRS is also a BDI architecture, mimicking the theory on human reasoning. PRS integrates both reactive
and goal-directed deliberative processing in a distributed architecture.
3. The architecture is able to build a world-model of the environment (beliefs) through interacting with
environment sensors.
4. Actions can also be taken through an intentions module. At the core is an interpreter (or reasoner) which
selects a goal to meet (given the current set of beliefs) and then retrieves a plan to execute to achieve that
goal. PRS iteratively tests the assumptions of the plan during its execution. This means that it can operate
in dynamic environments where classical planners are doomed to fail.
5. Plans in PRS (also called knowledge areas) are predefined for the actions that are possible in the
environment. This simplifies the architecture because it isn’t required to generate plans, only select them
based on the environment and the goals that must be met.
6. While planning is more about selection than search or generation, the interpreter ensures that changes
to the environment do not result in inconsistencies in the plan. Instead, a new plan is selected to achieve
the specific goals.
7. PRS is a useful architecture when all necessary operations can be predefined. It’s also very efficient
due to lack of plan generation. This makes PRS an ideal agent architecture for building agents such as
those to control mobile robots.

11
IFETCE R-2019 Academic Year: 2023 - 2024

➢ AGLETS (MOBILE)
1. Aglets is a mobile agent framework designed by IBM Tokyo in the 1990s. Aglets is based on the Java
programming language, as it is well suited for a mobile agents framework. First, the applications are
portable to any system (both homogeneous and heterogeneous) that is capable of running a Java Virtual
Machine (JVM). Second, a JVM is an ideal platform for migration services.
2. Java supports serialization, which is the aggregation of a Java application’s program and data into a
single object that is restart able.
3. In this case, the Java application is restarted on a new JVM. Java also provides a secure environment
(sandbox) to ensure that a mobile agent framework doesn’t become a virus distribution system. The Aglets
framework is shown in Figure 11.18. At the bottom of the framework is the JVM (the virtual machine that
interprets the Java byte codes). The agent runtime environment and mobility protocol are next. The
mobility protocol, called Aglet Transport Protocol (or ATP), provides the means to serialize agents and
then transport them to a host previously defined by the agent.
4. The agent API is at the top of the stack, which in usual Java fashion, provides a number of API classes
that focus on agent operation. Finally, there are the various agents that operate on the framework.
5. The agent API and runtime environment provide a number of services that are central to a mobile agent
framework. Some of the more important functions are agent management, communication, and security.
Agents must be able to register themselves on a given host to enable communication from outside agents.

12
IFETCE R-2019 Academic Year: 2023 - 2024

➢ MESSENGERS (MOBILE)
1. Messengers is a runtime environment that provides a form of process migration (mobile agency).
2. One distinct strength of the messengers environment is that it supports strong migration, or the ability
to migrate at arbitrary points within the mobile application.
3. The messengers environment provides the hop statement which defines when and where to migrate
to a new destination.
4. After migration is complete, the messengers agent restarts in the application at the point after the
previous hop statement. The end result is that the application moves to the data, rather than using a
messaging protocol to move the data to the agent.
5. There are obvious advantages to this when the data set is large and the migration links are slow. The
messengers model provides what the authors call Navigational Programming, and also Distributed
Sequential Computing (DSC).
6. What makes these concepts interesting is that they support the common model of programming that
is identical to the traditional flow of sequential programs. This makes them easier to develop and
understand.
7. Let’s now look at an example of DSC using the messengers environment. Listing 11.5 provides a
simple program. Consider an application where on a series of hosts, we manipulate large matrices which
are held in their memory.
SOAR (HYBRID)
1. Soar, which originally was an acronym for State-Operator-And-Result, is a symbolic cognitive
architecture.
2. Soar provides a model of cognition along with an implementation of that model for building general-
purpose AI systems.

13
IFETCE R-2019 Academic Year: 2023 - 2024
3. The idea behind Soar is from Newell’s unified theories of cognition. Soar is one of the most widely
used architectures, from research into aspects of human behavior to the design of game agents for first
person- shooter games.
4. The goal of the Soar architecture is to build systems that embody general intelligence. While Soar
includes many elements that support this goal (for example, representing knowledge using procedural,
episodic, and declarative forms), but Soar lacks some important aspects. These include episodic memories
and also a model for emotion. Soar’s underlying problem-solving mechanism is based on a production
system (expert system).
5. Behavior is encoded in rules similar to the if-then form. Solving problems in Soar can be most simply
described as problem space search (to a goal node). If this model of problem solving fails, other methods
are used, such as hill climbing.
6. When a solution is found, Soar uses a method called chunking to learn a new rule based on this
discovery. If the agent encounters the problem again, it can use the rule to select the action to take instead
of performing problem solving again.
4.2 AGENT COMMUNICATION
In the domain of multi-agent systems, communication is an important characteristic to support both
coordination and the transfer of information. Agents also require the ability to communicate actions or
plans. But how the communication takes place is a function of its purpose.
1. Agents communicate in order to achieve better the goals of themselves or of the society/system in
which they exist.
2. Communication can enable the agents to coordinate their actions and behavior, resulting in systems
that are more coherent.
3. Coordination is a property of a system of agents performing some activity in a shared environment.
4. The degree of coordination is the extent to which they avoid extraneous activity by reducing resource
contention, avoiding live lock and deadlock, and maintaining applicable safety conditions.
5. Cooperation is coordination among non-antagonistic agents, while negotiation is coordination among
competitive or simply self-interested agents.

14
IFETCE R-2019 Academic Year: 2023 - 2024
6. Typically, to cooperate successfully, each agent must maintain a model of the other agents, and also
develop a model of future interactions. This presupposes sociability Coherence is how well a system
behaves as a unit. A problem for a multiagent system is how it can maintain global coherence without
explicit global control. In this case, the agents must be able on their own to determine goals they share
with other agents, determine common tasks, avoid unnecessary conflicts, and pool knowledge and
evidence. It is helpful if there is some form of organization among the agents.
Dimensions of Meaning
There are three aspects to the formal study of communication: syntax (how the symbols of
communication are structured), semantics (what the symbols denote), and pragmatics (how the symbols
are interpreted). Meaning is a combination of semantics and pragmatics. Agents communicate in order to
understand and be understood, so it is important to consider the different dimensions of meaning that are
associated with communication.
1. Descriptive vs. Prescriptive. Some messages describe phenomena, while others prescribe behavior.
Descriptions are important for human comprehension, but are difficult for agents to mimic. Appropriately,
then, most agent communication languages are designed for the exchange of information about activities
and behavior.
2. Personal vs. Conventional Meaning. An agent might have its own meaning for a message, but this
might differ from the meaning conventionally accepted by the other agents with which the agent
communicates. To the greatest extent possible, multiagent systems should opt for conventional meanings,
especially since these systems are typically open environments in which new agents might be introduced
at any time.
3. Subjective vs. Objective Meaning Similar to conventional meaning, where meaning is determined
external to an agent, a message often has an explicit effect on the environment, which can be perceived
objectively. The effect might be different than that understood internally, i.e., subjectively, by the sender
or receiver of the message.
4. Speaker's vs. Hearer's vs. Society's Perspective Independent of the conventional or objective meaning
of a message, the message can be expressed according to the viewpoint of the speaker or hearer or other
observers.
5. Semantics vs. Pragmatics The pragmatics of a communication are concerned with how the
communicators use the communication. This includes considerations of the mental states of the
communicators and the environment in which they exist, considerations that are external to the syntax and
semantics of the communication.
6. Contextuality Messages cannot be understood in isolation, but must be interpreted in terms of the
mental states of the agents, the present state of the environment, and the environment's history: how it
arrived at its present state. Interpretations are directly affected by previous messages and actions of the
agents.
7. Coverage Smaller languages are more manageable, but they must be large enough so that an agent can
convey the meanings it intends.
8. Identity When a communication occurs among agents, its meaning is dependent on the identities and
roles of the agents involved, and on how the involved agents are specified. A message might be sent to a
particular agent, or to just any agent satisfying a specified criterion.
9. Cardinality A message sent privately to one agent would be understood differently than the same
message broadcast publicly.
MESSAGE TYPES
1. It is important for agents of different capabilities to be able to communicate. Communication must
therefore be defined at several levels, with communication at the lowest level used for communication
with the least capable agent.
2. In order to be of interest to each other, the agents must be able to participate in a dialogue. Their role
in this dialogue may be either active, passive, or both, allowing them to function as a master, slave, or
peer, respectively.

15
IFETCE R-2019 Academic Year: 2023 - 2024
3. In keeping with the above definition for and assumptions about an agent, we assume that an agent
can send and receive messages through a communication network.
4. The messages can be of several types, as defined next.
5. There are two basic message types: assertions and queries. Every agent, whether active or passive,
must have the ability to accept information. In its simplest form, this information is communicated to the
agent from an external source by means of an assertion. In order to
assume a passive role in a dialog, an agent must additionally be able to answer questions, i.e., it must
be able to 1) accept a query from an external source and 2) send a reply to the source by making an
assertion. Note that from the standpoint of the communication network, there is no distinction between an
unsolicited assertion and an assertion made in reply to a query.
6. In order to assume an active role in a dialog, an agent must be able to issue queries and make
assertions. With these capabilities, the agent then can potentially control another agent by causing it to
respond to the query or to accept the information asserted. This means of control can be extended to the
control of subagents, such as neural networks and databases.
7. An agent functioning as a peer with another agent can assume both active and passive roles in a
dialog. It must be able to make and accept both assertions and queries

SPEECH ACTS
Spoken human communication is used as the model for communication among computational
agents. A popular basis for analyzing human communication is speech act theory [1, 39]. Speech act theory
views human natural language as actions, such as requests, suggestions, commitments, and replies. For
example, when you request something, you are not simply making a statement, but creating the request
itself. When a jury declares a defendant guilty, there is an action taken: the defendant's social status is
changed.
A speech act has three aspects:
1. Locution, the physical utterance by the speaker
2. Illocution, the intended meaning of the utterance by the speaker
3. Perlocution, the action that results from the locution.

KQML (Knowledge Query and Manipulation Language)


1. The KQML is an interesting example of communication from a number of facets. For example,
communication requires the ability to locate and engage a peer in a conversation (communication layer).
2. A method for packaging the messages is then necessary (messaging layer), and finally an internal
format that represents the messages and is sufficiently expressive to convey not only information but
requests, responses, and plans (content layer).
3. In a network of KQML-speaking agents, there exists programs to support communication. These
consist of facilitators that can serve as name servers to KQML components, and help find other agents
that can satisfy a given agent’s request.
4. A KQML router supports the routing of messages and is a front-end to a specific KQML agent. As
KQML was originally written in Common LISP, it’s message representation follows the LISP example
(balanced parentheses).
5. A KQML message can be transferred to any particular transport (such as sockets) and has a format
that consists of a performative and a set of arguments for that performative. The performative defines the
speech act which defines the purpose of the message (assertion, command, request, etc.).
6. The performative- name defines the particular message type to be communicated (evaluate, ask- if,
stream-about, reply, tell, deny, standby, advertise, etc.). The sender and receiver define the unique names
of the agents in the dialogue. The content is information specific to the performative being performed.
7. This content is defined in a language (how to represent the content), and an ontology that describes
the vocabulary (and meaning) of the content. Finally, the agent can attach a context which the response
will contain (in-reply-to) in order to correlate the request with the response. The structure of a KQML
message.

16
IFETCE R-2019 Academic Year: 2023 - 2024
(performative-name
: sender X
: receiver Y
: content Z
: language L
: ontology Y
: reply-with R
: in-reply-to Q
)
Let’s now look at an example conversation between two KQML agents. In this example, an agent requests
the current value of a temperature sensor in a system. The request is for the temperature of
TEMP_SENSOR_1A that’s sampled at the temperature-server agent. The content is the request, defined
in the prolog language. Our agent making the request is called thermal-control-appl.
(ask-one
:sender thermal-control-appl
:receiver temperature-server
:language prolog
:ontology CELSIUS-DEGREES
:content “temperature(TEMP_SENSOR_1A ?temperature)”
:reply-with request-102
)
Our agent would then receive a response from the temperature-server, defining the temperature of the
sensor of interest.
(reply
:sender temperature-server
:receiver thermal-control-appl
:language prolog
:ontology CELSIUS-DEGREES
:content “temperature(TEMP_SENSOR_1A 45.2)”
:in-reply-to request-102
)
KQML is very rich in its ability to communicate information as well higher-level requests that address
the communication layer. Table 11.6 provides a short list of some of the other KQML per formatives.

KQML PERFORMATIVES

PERFORMATIVES DESCRIPTION
evaluate Evaluate the content of the message
ask-one Request for the answer to a question
reply Communicate a reply to a question
stream-about Provide multiple responses to a question
sorry Return an error (can’t respond)
Tell Inform an agent of a sentence
achieve A request of something to achieve by the
receiver
advertise Advertise the ability to process a performative
subscribe Subscribe to changes of information
forward Route a message
➢ KQML is a useful language to communicate not only data, but the meaning of the data (in terms
of a language and ontology).
17
IFETCE R-2019 Academic Year: 2023 - 2024
➢ KQML provides a rich set of capabilities that cover basic speech acts, and more complex acts
including data streaming and control of information transfer.
ACL (FIPA AGENT COMMUNICATION LANGUAGE)
1. Where KQML is a language defined in the context of a university, the FIPA ACL is a consortium-
based language for agent communication.
2. ACL simply means Agent Communication Language and it was standardized through the Foundation
for Intelligent Physical Agents consortium. As with KQML, ACL is a speech- act language defined by a
set of per formatives.
3. The FIPA, or Foundation for Intelligent Physical Agents, is a non-profit organization that promotes
the development of agent-based systems. It develops specifications to maximize the portability of agent
systems (including their ability to communicate using the ACL).
4. The FIPA ACL is very similar to the KQML, even adopting the inner and outer content layering for
message construction (meaning and content).
5. The ACL also clarifies certain speech-acts, or performatives. For example, communication primitives
are called communicative acts, which are separate from the performative acts.
6. The FIPA ACL also uses the Semantic Language, or SL, as the formal language to define ACL
semantics. This provides the means to support BDI themes (beliefs, desires, intentions). In other words,
SL allows the representation of persistent goals (intentions), as well as propositions and objects. Each
agent language has its use, and while both have their differences, they can also be viewed as
complementary.
XML
1. XML is the Extensible Markup Language and is an encoding that represents data and meta- data
(meaning of the data). It does this with a representation that includes tags that encapsulate the data.
2. The tags explicitly define what the data represents. For example, consider the ask-one request from
KQML. This can be represented as XML as shown below:
<msg>
<performative>ask-one</performative>
<sender>thermal-control-appl</sender>
<receiver>temperature-server</receiver>
<sensor-request>TEMP_SENSOR_1A</sensor-request>
<reply-with>request-102</reply-with>
</msg>
1. There are some obvious similarities to XML and KQML. In KQML, the tags exist, but use different
syntax than is defined for XML. One significant difference is that KQML permits the layering of tags.
2. Note here that the <msg> tag is the outer layer of the performative and its arguments. XML is very
flexible in its format and permits very complex arrangements of both data and meta-data.
3. XML is used in a number of protocols, including XML-RPC (Remote Procedure Call) and also SOAP
(Simple Object Access Protocol). Each of these use the Hyper Text Transport Protocol (HTTP) as its
transport.

4.3 TRUST AND REPUTATION


It depends on the level we apply it:
1. User confidence
• Can we trust the user behind the agent?
– Is he/she a trustworthy source of some kind of knowledge? (e.g. an expert
in a field)
– Does he/she acts in the agent system (through his agents in a trustworthy way?
2. Trust of users in agents
• Issues of autonomy: the more autonomy, less trust

18
IFETCE R-2019 Academic Year: 2023 - 2024
• How to create trust?
– Reliability testing for agents
– Formal methods for open MAS
– Security and verifiability
3. Trust of agents in agents
• Reputation mechanisms
• Contracts
• Norms and Social Structures What is Trust?
1. In closed environments, cooperation among agents is included as part of the designing process:
2. The multi- agent system is usually built by a single developer or a single team of developers and the
chosen developers, option to reduce complexity is to ensure cooperation among the agents they build
including it as an important system requirement.
3. Benevolence assumption: an agent AI requesting information or a certain service from agent aj can
be sure that such agent will answer him if AI has the capabilities and the resources needed, otherwise aj
will inform AI that it cannot perform the action requested.
4. It can be said that in closed environments trust is implicit. Trust can be computed as 1. A binary value
(1=‘I do trust this agent’, 0=‘I don’t trust this agent’)
2. A set of qualitative values or a discrete set of numerical values (e g ‘trust always’ ‘trust conditional
to X’ ‘no trust’) e.g. always , X , trust ) (e.g. ‘2’, ‘1’, ‘0’, ‘-1’, ‘-2’)
3. A continuous numerical value (e.g. [-300..300])
4. A probability distribution
5. Degrees over underlying beliefs and intentions (cognitive approach)

HOW TO COMPUTE TRUST

1. Trust values can be externally defined


• by the system designer: the trust values are pre-defined
• by the human user: he can introduce his trust values about the humans behind the other agents

19
IFETCE R-2019 Academic Year: 2023 - 2024
2. Trust values can be inferred from some existing representation about the interrelations between
the agents
• Communication patterns, cooperation history logs, e-mails, webpage connectivity mapping…
3. Trust values can be learnt from current and past experiences
• Increase trust value for agent AI if behaves properly with us
• Decrease trust value for agent AI if it fails/defects us
4. Trust values can be propagated or shared through a MAS
• Recommender systems, Reputation mechanisms.

Direct experiences are the most relevant and reliable information source for individual trust/reputation
1. Type 1: Experience based on direct interaction with the
2. Type 1: Experience with the partner
1. Used by almost all models
2. How to:
• trust value about that partner increases with good experiences,
• it decreases with bad ones
3. Problem: how to compute trust if there is no previous interaction?
3. Type 2: Experience based on observed interaction of other members
1. Used only in scenarios prepared for this.
2. How to: depends on what an agent can observe
• agents can access to the log of past interactions of other agents
• agents can access some feedback from agents about their past interactions (e.g., in eBay)
3. Problem: one has to introduce some noise handling or
4. confidence level on this information
4. Prior-derived: agents bring with them prior beliefs about strangers
Used by some models to initialize trust/reputation values How-to:
• designer or human user assigns prior values
• a uniform distribution for reputation priors is set
Give new agents the lowest possible reputation value there is no incentive to throw away a
cyberidentity when an agent’s reputation fallls below a starting point.
• Assume neither good nor bad reputation for unknown agents.
• Avoid lowest reputation for new, valid agents as an obstacle for other agents to realize that they are
valid.
5. Group-derived:
• Models for groups can been extended to provide prior reputation estimates for agents in social groups.
• Mapping between the initial individual reputation of a stranger and the group from which he or she
comes from.
• Problem: highly domain-dependent and model-dependent.
6. Propagated:
• Agent can attempt to estimate the stranger’s reputation based on information garnered from others in
the environment Also called word of mouth.
• Problem: The combination of the different reputation values tends to be an ad-hoc solution with no
social basis.

TRUST AND REPUTATION MODELS


1. Not really for MAS, but can be applied to MAS
2. Idea: For serious life / business decisions, you want the
• opinion of a trusted e pert trusted expert

20
IFETCE R-2019 Academic Year: 2023 - 2024
3. If an expert not personally known, then want to find a reference to one via a chain of friends and
colleagues
4. Referral-chain provides:
• Way to judge quality of expert's advice
• Reason for the expert to respond in a trustworthy manner • Finding good referral-chains is slow, time-
consuming, but vital business gurus on “networking”
• Set of all possible referral-chains = a social network
5. Model integrates information from
• Official organizational charts (online)
• Personal web pages (+ crawling)
• External publication databases
• Internal technical document databases
6. Builds a social network based in referral chains
• Each node is a recommender agent
• Each node provides reputation values for specific areas
o E.g. Frieze is good in mathematics
• Searches in the referral network are
• made by areas
E.g. browsing the network’s “mathematics” recommendation chains
7. Trust Model Overview
• 1-to-1 asymmetric trust relationships.
• Direct trust and recommender trust.
• Trust categories and trust values
• [-1,0,1,2,3,4].
8. Conditional transitivity.
Alice trusts Bob.&. Bob trusts Cathy
Alice trusts Cathy
Alice trusts.rec Bob.&. Bob says Bob trusts Cathy
Alice may trust Cathy
Alice trusts.rec Bob value X. &. Bob says Bob trusts Cathy value Y
Alice may trust Cathy value f(X, Y)
9. Recommendation protocol
1.Alice ->Bob: RRQ(Eric)
2. Bob ->Cathy: RRQ(Eric)
3. Cathy -> Bob: Rec(Eric,3)
4. Bob ->Alice: Rec(Eric,3)

21
IFETCE R-2019 Academic Year: 2023 - 2024

12. Direct Trust:


◼ ReGreT assumes that there is no difference between direct interaction and direct observation in terms
of reliability of the information. It talks about direct experiences.
◼ The basic element to calculate a direct trust is the outcome.
◼ An outcome of a dialog between two agents can beeither:
• An initial contract to take a particular course of action and the actual result of the actions taken, or
• An initial contract to x the terms and conditions of a transaction and the actual values of the terms of
the transaction.
13. Reputation Model: Witness reputation
a. First step to calculate a witness reputation is to identify the set of witnesses that will be taken into
account by the agent to perform the calculation.
b. The initial set of potential witnesses might be
i. the set of all agents that have interacted with the target agent in the past.
ii. This set, however, can be very big and the information provided by its members probably suffer from
the correlated evidence problem.
c. Next step is to aggregate these values to obtain a single value for the witness reputation.
The importance of each piece of information in the final reputation value will be proportional to the
witness credibility
14. Reputation Model: Witness reputation
a. Two methods to evaluate witness credibility:
i. ReGreT uses fuzzy rules to calculate how the structure of social relations influences the credibility
on the information. The antecedent of each rule is the type and degree of a social relation (the edges in a
sociogram) and the consequent is the credibility of the witness from the point of view of that social
relation.

22
IFETCE R-2019 Academic Year: 2023 - 2024
ii The second method used in the ReGreT system to calculate the credibility of a witness is to evaluate
the accuracy of previous pieces of information sent by that witness to the agent. The agent is using the
direct trust value to measure the truthfulness of the information received from witnesses.
15. Reputation Model: Neighbourhood Reputation
a. Neighbourhood in a MAS is not related with the physical location of the agents but with the links
created through interaction.
b. The main idea is that the behaviour of these neighbours and the kind of relation they have with the
target agent can give some clues about the behaviour of the target agent.
c. To calculate a Neighbourhood Reputation the ReGreT system uses fuzzy rules.
i. The antecedents of these rules are one or several direct trusts associated to different behavioural
aspects and the relation between the target agent and the neighbour.
ii. The consequent is the value for a concrete reputation (that can be associated to the same behavioural
aspect of the trust values or not).
16. Reputation Model: System Reputation
a. To use the common knowledge about social groups and the role that the agent is playing in the society
as a mechanismto assign default reputations to the agents.
b. ReGreT assumes that the members of these groups have one or several observable features that
unambiguously identify their membership.
c. Each time an agent performs an action we consider that it is playing a single role.
i. E.g. an agent can play the role of buyer and seller but when it is selling a product only the role of seller
is relevant.
17. System reputations are calculated using a table for each social group where the rows are the roles the
agent can play for that group, and the columns the behavioural aspects.
18. Reputation Model: Default Reputation
a. To the previous reputation types we have to add a fourth one, the reputation assigned to a third party
agent when there is no information at all: the default reputation.
b. Usually this will be a fixed value
19. Reputation Model: Combining reputations
a. Each reputation type has different characteristics and there are a lot of heuristics that can be used to
aggregate the four reputation values to obtain a single and representative reputation value.
b. In ReGreT this heuristic is based on the default and calculated reliability assigned to each type.
c. Assuming we have enough information to calculate all the reputation types, we have the stance that
a. witness reputation is the first type that should be considered, followed by
b. the neighbourhood reputation,
c. system reputation
d. the default reputation.
20. Main criticism to Trust and Reputation research:
a. Proliferation of ad-hoc models weakly grounded in social theory
b. No general, cross-domain model for reputation
c. Lack of integration between models
i. Comparison between models unfeasible
ii. Researchers are trying to solve this by, e.g. the ART competition

4.4 NEGOTIATION
1. A frequent form of interaction that occurs among agents with different goals is termed negotiation.
2. Negotiation is a process by which a joint decision is reached by two or more agents, each trying to
reach an individual goal or objective. The agents first communicate their positions, which might conflict,
and then try to move towards agreement by making concessions or searching for alternatives.

23
IFETCE R-2019 Academic Year: 2023 - 2024
3. The major features of negotiation are (1) the language used by the participating agents, (2) the
protocol followed by the agents as they negotiate, and (3) the decision process that each agent uses to
determine its positions, concessions, and criteria for agreement.
4. Many groups have developed systems and techniques for negotiation. These can be either
environment-centered or agent-centered. Developers of environment-centered techniques focus on the
following problem: "How can the rules of the environment be designed so that the agents in it, regardless
of their origin, capabilities, or intentions, will interact productively and fairly?" The resultant negotiation
mechanism should ideally have the following attributes:
• Efficiency: the agents should not waste resources in coming to an agreement. Stability: no agent
should have an incentive to deviate from agreed- upon strategies.
• Simplicity: the negotiation mechanism should impose low computational and bandwidth demands on
the agents.
• Distribution: the mechanism should not require a central decision maker.
• Symmetry: the mechanism should not be biased against any agent for arbitrary or inappropriate
reasons.
5. An articulate and entertaining treatment of these concepts is found in [36]. In particular, three types
of environments have been identified: worth-oriented domains, state-oriented domains, and task-oriented
domains.
6. A task-oriented domain is one where agents have a set of tasks to achieve, all resources needed to
achieve the tasks are available, and the agents can achieve the tasks without help or interference from
each other. However, the agents can benefit by sharing some of the tasks. An example is the "Internet
downloading domain," where each agent is given a list of documents that it must access over the
Internet. There is a cost associated with downloading, which each agent would like to minimize. If a
document is common to several agents, then they can save downloading cost by accessing the document
once and then sharing it.
7. The environment might provide the following simple negotiation mechanism and constraints:
(1) each agent declares the documents it wants
(2) documents found to be common to two or more agents are assigned to agents based on the toss of a
coin,
(3) agents pay for the documents they download, and
(4) agents are granted access to the documents they download. as well as any in their common sets. This
mechanism is simple, symmetric, distributed, and efficient (no document is downloaded twice). To
determine stability, the agents' strategies must be considered.
8. An optimal strategy is for an agent to declare the true set of documents that it needs, regardless of
what strategy the other agents adopt or the documents they need. Because there is no incentive for an
agent to diverge from this strategy, it is stable.
9. For the first approach, speech-act classifiers together with a possible world semantics are used to
formalize negotiation protocols and their components. This clarifies the conditions of satisfaction for
different kinds of messages. To provide a flavor of this approach, we show in the following example how
the commitments that an agent might make as part of a negotiation are formalized

10. This rule states that an agent forms and maintains its commitment to achieve ø individually iff (1) it
has not precommitted itself to another agent to adopt and achieve ø, (2) it has a goal to achieve ø
individually, and (3) it is willing to achieve ø individually. The chapter on "Formal Methods in DAI"
provides more information on such descriptions.

24
IFETCE R-2019 Academic Year: 2023 - 2024
11. The second approach is based on an assumption that the agents are economically rational. Further,
the set of agents must be small, they must have a common language and common problem abstraction,
and they must reach a common solution. Under these assumptions, Rosenschein and Zlotkin [37]
developed a unified negotiation protocol. Agents that follow this protocol create a deal, that is, a joint
plan between the agents that would satisfy all of their goals. The utility of a deal for an agent is the amount
he is willing to pay minus the cost of the deal. Each agent wants to maximize its own utility. The agents
discuss a negotiation set, which is the set of all deals that have a positive utility for every agent.
In formal terms, a task-oriented domain under this approach becomes a tuple
<T, A, c>
where T is the set of tasks, A is the set of agents, and c(X) is a monotonic function for the cost of executing
the tasks X. A deal is a redistribution of tasks. The utility of deal d for agent k is
Uk(d) = c(Tk) - c(dk)
The conflict deal D occurs when the agents cannot reach a deal. A deal d is individually rational if d > D.
Deal d is pareto optimal if there is no deal d' > d. The set of all deals that are individually rational and
pareto optimal is the negotiation set, NS. There are three possible situations:
1. conflict: the negotiation set is empty
2. compromise: agents prefer to be alone, but since they are not, they will agree to a negotiated deal
3. cooperative: all deals in the negotiation set are preferred by both agents over achieving their goals
alone.
When there is a conflict, then the agents will not benefit by negotiating—they are better off acting
alone. Alternatively, they can "flip a coin" to decide which agent gets to satisfy its goals. Negotiation is
the best alternative in the other two cases.
Since the agents have some execution autonomy, they can in principle deceive or mislead each
other. Therefore, an interesting research problem is to develop protocols or societies in which the effects
of deception and misinformation can be constrained. Another aspect of the research problem is to
develop protocols under which it is rational for agents to be honest with each other. The connections
of the economic approaches with human-oriented negotiation and argumentation have not yet been fully
worked out.
4.7 Bargaining
A bargaining problem is defined as a pair (S,d). A bargaining solution is a function f that maps
every bargaining problem (S,d) to an outcome in S, i.e., f : (S,d) → S

Thus the solution to a bargaining problem is a pair in R2. It gives the values of the game to the
two players and is generated through the function called bargaining function. Bargaining function maps
the set of possible outcomes to the set of acceptable ones.

Bargaining Solution

In a transaction when the seller and the buyer value a product differently, a surplus is created. A
bargaining solution is then a way in which buyers and sellers agree to divide the surplus. For example,
consider a house made by a builder A. It costed him Rs.10 Lacs. A potential buyer is interested in the
house and values it at Rs.20 Lacs. This transaction can generate a surplus of Rs.10 Lacs. The builder and
the buyer now need to trade at a price. The buyer knows that the cost is less than 20 Lacs and the seller
knows that the value is greater than 10 Lacs. The two of them need to agree at a price. Both try to maximize
their surplus. Buyer would want to buy it for 10 Lacs, while the seller would like to sell it for 20 Lacs.
They bargain on the price, and either trade or dismiss. Trade would result in the generation of surplus,
whereas no surplus is created in case of no-trade. Bargaining Solution provides an acceptable way to
divide the surplus among the two parties. Formally, a Bargaining Solution is defined as, F : (X,d) → S,

25
IFETCE R-2019 Academic Year: 2023 - 2024
where X R2 and S,d R2. X represents the utilities of the players in the set of possible bargaining
agreements. d represents the point of disagreement. In the above example, price [10,20], bargaining set
is simply x + y 10, x 0, y 0. A point (x,y) in the bargaining set represents the case, when seller gets
a surplus of x, and buyer gets a surplus of y, i.e. seller sells the house at 10 + x and the buyer pays 20 − y.

1. the set of payoff allocations that are jointly feasible for the two players in the process of negotiation
or arbitration, and

2. the payoffs they would expect if negotiation or arbitration were to fail to reach a settlement.

Based on these assumptions, Nash generated a list of axioms that a reasonable solution ought to
satisfy. These axioms are as follows:

Axiom 1 (Individual Rationality) This axiom asserts that the bargaining solution should give
neither player less than what it would get from disagree ment, i.e., f(S,d) ≥ d.

Axiom 2 (Symmetry) As per this axiom, the solution should be independent of the names of the
players, i.e., who is named a and who is named b. This means that when the players’ utility functions and
their disagreement utilities are the same, they receive equal shares. So any symmetries in the final payoff
should only be due to the differences in their utility functions or their disagreement outcomes.

Axiom 3 (Strong Efficiency) This axiom asserts that the bargaining solution should be feasible
and Pareto optimal.

Axiom 4 (Invariance) According to this axiom, the solution should not change as a result of linear
changes to the utility of either player. So, for example, if a player’s utility function is multiplied by 2, this
should not change the solution. Only the player will value what it gets twice as much.

Axiom 5 (Independence of Irrelevant Alternatives) This axiom asserts that eliminating feasible
alternatives (other than the disagreement point) that would not have been chosen should not affect the
solution, i.e., for any closed convex set

Nash proved that the bargaining solution that satisfies the above five axioms is given

by:

NON-COOPERATIVE MODELS OF SINGLE-ISSUE NEGOTATION

Table 4.2
Cooperative Game Non Cooperative Game

The players are allowed to communicate Each player independently chooses its
before choosing their strategies and playing strategy.
the game.

The basic modeling unit is the group The basic modeling unit is the individual.

Players can enforce cooperation in the group The cooperation between individuals is
through a third party. selfenforcing.

26
IFETCE R-2019 Academic Year: 2023 - 2024
4.8 GAME-THEORETIC APPROACHES FOR MULTI-ISSUE NEGOTIATION

The following are the four key procedures for bargaining over multiple issue:

1. Global bargaining: Here, the bargaining agents directly tackle the global problem in which all the
issues are addressed at once. In the context of non-cooperative theory, the global bargaining procedure is
also called the package deal procedure. In this procedure, an offer from one agent to the other would
specify how each one of the issues is to be resolved.

2. Independent/separate bargaining: Here negotiations over the individual issues are totally separate and
independent, with each having no effect on the other. This would be the case if each of the two parties
employed m agents (for negotiating over m issues), with each agent in charge of negotiating one issue.
For example, in negotiations between two countries, each issue may be resolved by representatives from
the countries who care only about their individual issue.

3. Sequential bargaining with independent implementation: Here the two parties consider one issue at a
time. For instance, they may negotiate over the first issue, and after reaching an agreement on it, move on
to negotiate the second, and so on. Here, the parties may not negotiate an issue until the previous one is
resolved. There are several forms of the sequential procedure. These are defined in terms of the agenda
and the implementation rule. For sequential bargaining, the agenda3 specifies the order in which the issues
will be bargained. The implementation rule specifies when an agreement on an individual issue goes into
effect. There are two implementation rules:
the rule of independent implementation and the rule of simultaneous implementation.

4. Sequential bargaining with simultaneous implementation: This is similar to the previous case except
that now an agreement on an issue does not take effect until an agreement is reached on all the subsequent
issues.

Cooperative Models of Multi-Issue Negotiation

1. Simultaneous implementation agenda independence: This axiom states that global bargaining and
sequential bargaining with simultaneous implementation yield the same agreement.

2. Independent implementation agenda independence: This axiom states that global bargaining and
sequential bargaining with independent implementation yield the same agreement.

3. Separate/global equivalence: This axiom states that global bargaining and separate bargaining yield
the same agreement.

Non-Cooperative Models of Multi-Issue Negotiation

An agent’s cumulative utility is linear and additive. The functions Ua and Ub give the cumulative utilities
for a and b respectively at time t and are defined as follows.

(4.1)

27
IFETCE R-2019 Academic Year: 2023 - 2024

(4.2)

Where wa R+m denotes an m element vector of constants for agent a and wb R+m such a vector b. These
vectors indicate how the agents prefer different issuers. For example, if wac> wac+1, then agent a values
issue c more than issue c+ 1. Like for agent b.

4.9 ARGUMENTATION

➢ “A verbal and social activity of reason aimed at increasing (or decreasing) the acceptability of a
controversial standpoint for the listener or reader, by putting forward a constellation of propositions (i.e.
arguments) intended to justify (or refute) the standpoint before a rational judge”

➢ Argumentation can be defined as an activity aimed at convincing of the acceptability of a standpoint


by putting forward propositions justifying or refuting the standpoint.

➢ Argument: Reasons / justifications supporting a conclusion

➢ Represented as: support ->conclusion

– Informational arguments: Beliefs -> Belief e.g. If it is cloudy, it might rain.

– Motivational args: Beliefs, Desires ->Desire e.g. If it is cloudy and you want to get out then you don’t
want to get wet.

– Practical arguments: Belief, Sub-Goals -> Goal e.g. If it is cloudy and you own a raincoat then put
the raincoat.

– Social arguments: Social commitments-> Goal, Desire e.g. I will stop at the corner because the law
say so. e.g I can’t do that, I promise to my mother that won’t.

Process of Argumentation

1. Constructing arguments (in favor of / against a “statement”) from available information.


A: “Tweety is a bird, so it flies”
B: “Tweety is just a cartoon!”
2. Determining the different conflicts among the arguments.
“Since Tweety is a cartoon, it cannot fly!” (B attacks A)
Evaluating the acceptability of the different arguments
“Since we have no reason to believe otherwise, we’ll assume Tweety is a cartoon.” (accept B). “But then,
this means despite being a bird he cannot fly.” (reject A).
3. Concluding, or defining the justified conclusions.
“We conclude that Tweety cannot fly!” Computational Models of Argumentation:

28
IFETCE R-2019 Academic Year: 2023 - 2024
1. Given the definition of arguments over a content language (and its logic), the models allow to:
• Compute interactions between arguments: attacks, defeat, support,...
• Valuation of arguments: assign weights to arguments in order to compare them. Intrinsic value of an
argument Interaction-based value of an argument
2. Selection of acceptable argument (conclusion)
• Individual acceptability
• Collective acceptability

4.10 OTHER ARCHITECTURES

LAYERED ARCHITECTURES

Given the requirement that an agent be capable of reactive and pro-active behavior, an obvious
decomposition involves creating separate subsystems to deal with these different types of behaviors. This
idea leads naturally to a class of architectures in which the various subsystems are arranged into a
hierarchy of interacting layers. In this section, we will consider some general aspects of layered
architectures, and then go on to consider two examples of such architectures:

INTERRAP and TOURINGMACHINES

Typically, there will be at least two layers, to deal with reactive and pro-active behaviors
respectively. In principle, there is no reason why there should not be many more layers. However many
layers there are, a useful typology for such architectures is by the information and control flows within
them. Broadly speaking, we can identify two types of control flow within layered architectures (see
Figure):

• Horizontal layering. In horizontally layered architectures (Figure (a)), the software layers are each
directly connected to the sensory input and action output. In effect, each layer itself acts like an agent,
producing suggestions as to what action to perform.

• Vertical layering. In vertically layered architectures (Figure (b) and (c)), sensory input
and action output are each dealt with by at most one layer each.
The great advantage of horizontally layered architectures is their conceptual simplicity: if we need an
agent to exhibit n different types of behavior, then we implement n different layers.

However, because the layers are each in effect competing with one-another to generate action
suggestions, there is a danger that the overall behavior of the agent will not be coherent. In order to
ensure that horizontally layered architectures are consistent, they generally include a mediator function,
which makes decisions about which layer has ''control" of the agent at any given time.

The need for such central control is problematic: it means that the designer must potentially
consider all possible interactions between layers. If there are n layers in the architecture, and each layer is
capable of suggesting m possible actions, then this means there are mn such interactions to be considered.
This is clearly difficult from a design point of view in any but the simplest system. The introduction of a
central control system also introduces a bottleneck into the agent's decision making

29
IFETCE R-2019 Academic Year: 2023 - 2024

Figure 4.12 INTERRAP and TOURINGMACHINES

ABSTRACT ARCHITECTURE

1. We can easily formalize the abstract view of agentgs presented so far. First, we will assume that the
state of the agent’s environment can be characterized as a set S = {s1, s2,…) of environment states.

2. At any given instant, the environment is assumed to be in one of these states. The effectoric capability
of an agent is assumed to be represented by a set A = (a1, a2,…) of actions. Then abstractly, an agent can
be viewed as a function

Action S* → A

3. Which maps sequences of enviornment states to actions. We will refer to an agent modelled by a
function of this form as a standard agent. The intuition is that an agent decides what action to perform on
the basis of its history – its experiences to date. These experiences are represented as a sequence of
environment states – those that the agent has thus for encountered.

4. The (non-determinstic) behaviour of an environment can be modelled as a function env:

S x A → P (S)

Which takes the current state of the environment s S and an action (perfrmed by the agent), and maps them to
a set of environment state env(s,a) – those that could result from performing action a in state s. If all the
sets in the rnage of env are all sigletons, (i.e., if the result of performing any action in any state in a set
containing a single member), then the environment is deterministic, and its behaviour can be accrately
predicted.

5. We can represented the interaction of agent and environment as a history. A history h is a sequence:
h:: s0 ⎯⎯a0→s1 ⎯⎯a1→s2 ⎯⎯a2→s3 ⎯⎯a3→...⎯a⎯⎯u−1→su ⎯⎯au→...

30
IFETCE R-2019 Academic Year: 2023 - 2024
where so is the initial state of the environment (i.e., its state when the agent starts executing), au is the uth action
that the agent chose to perform, and su is the uth environment state (which is one of the possible results of
executing action au-2 in state su-1). S* → A is an agent, env: S x S → p(S) is an environment, and so is
the initial state of environment.

6. The characteristic behaviour of an agent action S* → A is an envioronment env : is the set of all the
histories that satisfy these properties. If some property holds of all these histories, this property can be
regarded as an invariant property of the agent in the environment. For example, if our agent is a nuclear
reactor controller, (i.e., the environment is a nuclear reactr), and in all possible histories of the
contrller/reactor, the reactor does not below up, then this can be regarded as a (desirable) invariant
property. We will denote by hist(agent, environment) the set of all histories of agent in environment. Two
agentws ag1 and ag2 are said to be behaviorally equivalent with respect to enviroment env iff hist(ag1,
env) = hist(ag2, env) and simply behaviorally equivalent iffr they are behaviorally equivalent with respect
of all environments.

4.11 CONCRETE ARCHITECTURES FOR INTELLIGENT AGENTS

1. We have considered agents only in the abstract. So, while we have examined the properties of agents that do
and do not maintain state, we have not stopped to consider what this state might look like. Similarly, we
have modelled an agent's decision making as an abstract function action, which somehow manages to
indicate which action to perform—but we have not discussed how this function might be implemented.
In this section, we will rectify this omission. We will consider four classes of agents:

• logic based agents—in which decision making is realized through logical deduction;

• reactive agents—in which decision making is implemented in some form of direct mapping from
situation to action;

• belief-desire-intention agents—in which decision making depends upon the manipulation of data
structures representing the beliefs, desires, and intentions of the agent; and finally,

• layered architectures—in which decision making is realized via various software layers, each of
which is more-or- less explicitly reasoning about the environment at different levels of abstraction.

In each of these cases, we are moving away from the abstract view of agents, and beginning to
make quite specific commitments about the internal structure and operation of agents. Each section
explains the nature of these commitments, the assumptions upon which the architectures depend, and the
relative advantages and disadvantages of each.

31
IFETCE Regulation: 2019 Academic Year: 2023 - 2024

IFET COLLEGE OF ENGINEERING


(An Autonomous Institution)
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

SUBJECT TITLE: Foundations of AI UNIT: IV


SUBJECT CODE: 19UCSPEX01 YEAR/SEM: III/VI

UNIT IV SOFTWARE AGENTS


Architecture for Intelligent Agents – Agent communication – Negotiation and Bargaining
– Argumentation among Agents – Trust and Reputation in Multi-agent systems.
Architecture for Intelligent Agents – Agent communication
1. Define software agent R
2. Write about anatomy of agent. U
3. Give example for software agent S
4. List out the properties of agent U
5. What do you mean by Agent Architectures? R
6. List out the types of Intelligent Agents Architectures? U
7. How do sensors contribute to the functioning of intelligent agents? A
8. Infer the languages used to develop Agents. A
9. Compare and contrast the reactive and deliberative agent U
architectures.
10. What do you understand about the term agent communication? U
11. How can intelligent agents be applied in the domain of smart A
homes?
12. Can you provide an example application of intelligent agents in the A
real world?
13. How do intelligent agents contribute to customer support in e- A
commerce?
14. What challenges are associated with agent communication? U
15. Can you provide an example scenario of agent communication? A
16. What are the main purposes of agent communication? U
17. What are the typical communication models used in multi-agent U
systems?
18. What is the role of communication languages in agent U
communication?
19. How do agents handle communication failures? S
20. In autonomous vehicle systems, how do software agents A
communicate to ensure safe and efficient navigation?
Negotiation and Bargaining – Argumentation among Agents –
Trust and Reputation in Multi-agent systems.
21. What are the attributes of negotiation? U
22. What do you mean by bargaining? R
23. List the characteristics of multi agent systems. U
24. What are the components of communicating agent? U
25. What happened if Coherent value is low? S
IFETCE Regulation: 2019 Academic Year: 2023 - 2024

26. Give the Diagrammatic Representation of Trust and Reputation S


Models for Multiagent Systems.
27. What is argumentation among agents? R
28. How can software agents learn from past negotiations to improve A
future interactions?
29. How does trust influence negotiation between software agents? A
30. How do software agents make decisions during bargaining? A
PART-B
1. Explain briefly on Concrete architecture for intelligent agents U 16
2. Elaborate on the negotiation and bargaining process in software R 16
agent
3. Explain the expected problems to build an intelligent automation A 16
system to change the manual functionalities your college library
into an automatic one. What are steps would you follow to
overcome those problems? (Assume minimum of two
functionalities)
4. Create and design the architecture of intelligence agent with an S 16
example.
5. With diagrammatic representation, explain Trust and reputation in U 16
Multiagent systems in detail.
6. Give a brief analysis of how planning and acting happens in real S 16
world. Explain through an example.
7 i) How communications are handled among agents? U 8
Explain with an example.
ii) Explain on the components to build up the Intelligent U 8
Agents with a block diagram.
8 In the children’s game of rock-paper-scissors, each player reveals at A 16
the same time a choice of rock, paper or scissors. Paper wraps the
rock, rock blunts scissors and scissors cut paper. In the extended
version rock-paper-scissors-fire-water, fire beats rock, paper and
scissors; rock, paper and scissors beat water and water beats fire.
Write out the payoff matrix and find a mixed strategy solution to
this game
IFETCE Regulation: 2019 Academic Year: 2023 - 2024

IFET COLLEGE OF ENGINEERING


(An Autonomous Institution)
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

SUBJECT TITLE: Foundations of AI UNIT: IV


SUBJECT CODE: 19UCSPEX01 YEAR/SEM: III/VI

UNIT IV SOFTWARE AGENTS


Architecture for Intelligent Agents – Agent communication – Negotiation and Bargaining
– Argumentation among Agents – Trust and Reputation in Multi-agent systems.
Application solved
7. How do sensors contribute to the functioning of intelligent agents?
Sensors contribute to intelligent agents by providing crucial environmental data. They act as
the agents' sensory input, capturing information such as visuals, sounds, or tactile feedback.
This data allows agents to perceive and understand their surroundings. Sensors enable real-
time feedback, aiding agents in adapting to dynamic environments. Ultimately, sensors play a
pivotal role in enhancing the decision-making and interaction capabilities of intelligent
agents.
8.Infer the languages used to develop Agents.
• Telescript
• Aglets
• Obliq
• Agent TCL
11. How can intelligent agents be applied in the domain of smart homes?
Intelligent agents in smart homes use sensors to monitor the environment, reasoning algorithms
to make decisions about home automation tasks, and actuators to control devices like
thermostats and lights.
12. Can you provide an example application of intelligent agents in the real world?
One example application is autonomous vehicles. Intelligent agents, in the form of self-driving
cars, use sensors to perceive the environment, reasoning algorithms to make decisions like
navigating and avoiding obstacles, and actuators to control the vehicle. This showcases the
integration of intelligent agent architecture in a practical scenario.
13. How do intelligent agents contribute to customer support in e-commerce?
Intelligent agents play a significant role in e-commerce customer support by providing chatbots
or virtual assistants. These agents use natural language processing and machine learning to
understand customer queries and respond appropriately, enhancing user experience and
resolving issues efficiently. This application showcases the use of intelligent agent architecture
in customer service settings.
IFETCE Regulation: 2019 Academic Year: 2023 - 2024

15. Can you provide an example scenario of agent communication?


Consider a multi-agent system for traffic management. Traffic signal agents communicate with
vehicle agents to optimize traffic flow. Vehicle agents might send their current location and
speed to the traffic signal agents, which, in turn, adjust signal timings based on the traffic
conditions.
20.In autonomous vehicle systems, how do software agents communicate to ensure safe
and efficient navigation?
Software agents in autonomous vehicles communicate with sensors, other vehicles, and traffic
infrastructure. This communication is vital for sharing real-time data on road conditions,
avoiding collisions, and optimizing route planning for safe and efficient navigation.
28. How can software agents learn from past negotiations to improve future interactions?
Software agents can learn from past negotiations by analyzing the outcomes, identifying
successful strategies, and adapting their behavior based on the lessons learned. This iterative
learning process enhances their negotiation capabilities over time.
29. How does trust influence negotiation between software agents?
Trust is essential in negotiation as it affects the willingness of agents to cooperate. Agents may
consider each other's reputations, past behaviors, and performance in previous negotiations
when deciding whether to trust and collaborate.
30. How do software agents make decisions during bargaining?
During bargaining, software agents make decisions by evaluating proposed agreements against
their goals and preferences. They consider factors such as the utility of the proposed outcome,
the credibility of the counterpart, and the potential for long-term cooperation.
PART-B
3. Explain the expected problems to build an intelligent automation system to change
the manual functionalities your college library into an automatic one. What are steps
would you follow to overcome those problems?
Transitioning from manual to intelligent automation in a college library presents several
challenges:
1. Technological Hurdles:
• Integration with Existing Systems: Legacy systems might not seamlessly integrate
with new automation software, requiring data migration and potential compatibility
issues.
• Hardware and Infrastructure: Upgrading hardware and network infrastructure might
be necessary to support data-driven automation processes.
• Security and Privacy: Securely storing and managing student data and library
resources raises concerns about data breaches and privacy violations.
2. Change Management:
IFETCE Regulation: 2019 Academic Year: 2023 - 2024

• Staff Training and Reskilling: Existing staff may need training to adapt to new
workflows and technologies, potentially causing resistance or disruptions.
• Student Adaptation: Students accustomed to traditional library systems might struggle
with new interfaces and self-service functionalities, requiring clear communication
and user education.
• Accessibility Concerns: Ensure inclusivity for students with disabilities by
incorporating accessible technologies and interfaces.
3. Financial and Resource Constraints:
• Automation costs: Implementing and maintaining an intelligent automation system
can be expensive, requiring budget allocation and resource management.
• Return on Investment: Demonstrating the long-term benefits of automation
(e.g., increased efficiency, improved data collection) to secure funding.
• Maintenance and Support: Ongoing maintenance of the system and access to technical
support are crucial for smooth operation.
4. Data quality and reliability:
• Accurate data entry: Inaccurate data will negatively impact the effectiveness and
efficiency of the automated system.
• Data standardization: Different formats and inconsistencies in existing data can
impede successful integration and analysis.
• Data security and privacy: Secure data storage and access protocols are crucial to
avoid breaches and misuse of sensitive information.
Steps to Overcome Challenges:
1. Comprehensive Planning and Analysis:
• Conduct a thorough assessment of existing library operations, workflows, and data to
identify automation opportunities and challenges.
• Define clear goals and objectives for automation, aligning them with the library's
mission and needs.
• Research and compare different automation solutions, considering factors like
budget, compatibility, and scalability.
2. Stakeholder Engagement and Communication:
• Involve librarians, staff, and students in the planning and implementation process to
address concerns and ensure buy-in.
• Provide ongoing training and support to staff and students to build confidence and
facilitate smooth adaptation.
• Communicate the benefits of automation to stakeholders to garner support and ensure
a successful transition.
IFETCE Regulation: 2019 Academic Year: 2023 - 2024

3. Phased Implementation and Scalability:


• Pilot automation in specific areas initially and gradually expand based on success and
feedback.
• Choose modular systems that can be easily upgraded and scaled to accommodate
future growth and changing needs.
• Regularly evaluate the system's performance and make necessary adjustments to
optimize its effectiveness.
4. Data Management and Security:
• Implement robust data quality control measures to ensure accuracy and consistency.
• Establish data security protocols and access controls to protect sensitive information.
• Invest in cybersecurity measures to prevent unauthorized access and data breaches.
5. Financial Sustainability and Resource Management:
• Secure funding for initial implementation and ongoing maintenance of the automated
system.
• Explore cost-effective solutions and consider partnering with other institutions for
resource sharing.
• Monitor the system's impact on cost-efficiency and demonstrate its return on
investment to sustain financial support.

8. In the children’s game of rock-paper-scissors, each player reveals at the same time a
choice of rock, paper or scissors. Paper wraps the rock; rock blunts scissors and scissors
cut paper. In the extended version rock-paper-scissors-fire-water, fire beats rock, paper
and scissors; rock, paper and scissors beat water and water beats fire. Write out the
payoff matrix and find a mixed strategy solution to this game.

Your
Choice Rock Paper Scissors Fire Water
Rock 0 1 1 -1 1
Paper -1 0 1 1 1
Scissors -1 -1 0 1 1
Fire 1 -1 -1 0 -1
Water -1 -1 -1 1 0
This matrix shows the payoffs for each combination of choices. A positive payoff means you
win, a negative payoff means you lose, and a 0 means a tie.
Finding a Mixed Strategy Solution
IFETCE Regulation: 2019 Academic Year: 2023 - 2024

To find a mixed strategy solution, we need to find probabilities for each player's choices that
will minimize their maximum loss (maximize their minimum gain). This can be done using
Linear Programming.
Step 1: Set up the constraints.
• Each player's probability sum must be 1:
o P(Rock) + P(Paper) + P(Scissors) + P(Fire) + P(Water) = 1
• Each player's expected payoff against any choice from the other player must be at least
equal to their minimum value (minimizing maximum loss):
o (0P(Rock) + 1P(Paper) + 1P(Scissors) - 1P(Fire) + 1P(Water))Q(Rock) + ... +
(1P(Fire) - 1P(Water))*Q(Water) >= V
o Repeat the above for each player's choice (Rock, Paper, Scissors, Fire, Water)
Step 2: Solve the linear program.
This will give you the optimal probabilities for each player's choices, which represent their
mixed strategy solution.
Example Solution:
Using a solver, we can find an approximate solution where:
• Player 1: P(Rock) = 0.2, P(Paper) = 0.2, P(Scissors) = 0.2, P(Fire) = 0.2, P(Water) =
0.2
• Player 2: Q(Rock) = 0.3, Q(Paper) = 0.2, Q(Scissors) = 0.2, Q(Fire) = 0.2, Q(Water) =
0.1
Interpretation:
In this solution, both players should play each choice with equal probability (20%). This
prevents the other player from predicting their next move easily, making it difficult to exploit
any weaknesses.
However, it's important to note that this is just one possible solution and the optimal
probabilities may vary depending on the specific assumptions and constraints of the game.

You might also like