Ai 1
Ai 1
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
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.
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.
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:
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.
Algorithms that generate plans to achieve specific goals, considering constraints and
resource limitations. Used in areas like robotics and project management.
Frame-Based Systems:
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
Decision trees are structures that represent decisions and their possible consequences.
In planning, decision trees are used to model decision-making processes.
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
Supervised Learning: Uses labeled training data to train models to make predictions or
classifications.
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:
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
Explainable AI (XAI):
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:
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:
AI in Healthcare:
6
IFETCE Regulation 2019A Academic Year: 2023-2024
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.
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.
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.
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
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
9
IFETCE Regulation 2019A Academic Year: 2023-2024
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.
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.
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.
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
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
To perform the mapping task four types of agent programs are there. They are:
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.
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.
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.
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
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.
19
IFETCE Regulation 2019A Academic Year: 2023-2024
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
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
➢ 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.
23
IFETCE Regulation 2019A Academic Year: 2023-2024
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
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
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
• 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.
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
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:
28
IFETCE Regulation 2019A Academic Year: 2023-2024
29
IFETCE Regulation 2019A Academic Year: 2023-2024
30
IFETCE Regulation 2019A Academic Year: 2023-2024
IFET COLLEGE OF ENGINEERING
(An Autonomous Institution)
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
Foundations of AI
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
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
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.
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
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:
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.
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.
• Transition model: Returns the board with a queen added to the specified square.
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:
• Initial state: 4.
• Actions: Apply factorial, square root, or floor operation (factorial for integers only).
• 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
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.
• 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
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.
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.
4
IFETCE Regulation 2019A Academic Year: 2023-2024
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.
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
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
• 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)
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
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
12
IFETCE Regulation 2019A Academic Year: 2023-2024
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.
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.
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.
2.2
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.
(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
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
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 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).
19
IFETCE Regulation 2019A Academic Year: 2023-2024
z child ←REPRODUCE(x,y)
A genetic algorithm.
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 .
• 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.
22
IFETCE Regulation 2019A Academic Year: 2023-2024
Figure 14
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)
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.
25
IFETCE Regulation 2019A Academic Year: 2023-2024
➢ 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.
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
28
IFETCE Regulation 2019A Academic Year: 2023-2024
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.
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
Find the most cost-effective path to reach the final state from initial state
using A* Algorithm.
IFETCE Regulation 2019A Academic Year: 2023-2024
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.
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.
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
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
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
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.
9
IFETCE R2019 Academic Year 2023-2024
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
18
IFETCE R2019 Academic Year 2023-2024
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:
19
IFETCE R2019 Academic Year 2023-2024
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.
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
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
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
23
IFETCE R2019 Academic Year 2023-2024
Hence the negation of the conclusion has been proved as a complete contradiction with
24
IFETCE R2019 Academic Year 2023-2024
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
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)
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
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
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
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
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)
(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.
(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.
15. Satisfy the query for all sequence of goals by using Prolog for the following.
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
27. Represent the following seven sentences using and extending the representations
Water is a liquid between 0 and 100 degrees.
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
∀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).
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),
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
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
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.
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
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
7
IFETCE R-2019 Academic Year: 2023 - 2024
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.
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.
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.
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.
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.
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)
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.
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
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:
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.
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.
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”
– 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
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
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:
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
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.
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.
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
• 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
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.