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

Unit - 3

Adversarial Search and Games


Q1) What is game theory?
A1) Game theory
Adversarial search is a sort of search that examines the problem that arises when we attempt to
plan ahead of the world while other agents plan against us.
• In previous topics, we looked at search strategies that are purely associated with a single
agent attempting to find a solution, which is often stated as a series of activities.
• However, in game play, there may be moments when more than one agent is looking for
the same answer in the same search field.
• A multi-agent environment is one in which there are multiple agents, each of which is an
opponent to the others and competes against them. Each agent must think about what
another agent is doing and how that activity affects their own performance.
• Adversarial searches, also referred to as Games, are searches in which two or more players
with conflicting goals try to find a solution in the same search space.
• The two fundamental variables that contribute in the modeling and solving of games in AI
are a Search problem and a heuristic evaluation function.

Q2) What are the type of games in AI?


A2) Types of Games in AI
• Perfect information: A game with perfect information is one in which agents have
complete visibility of the board. Agents can see each other's movements and have access
to all game information. Examples include chess, checkers, go, and other games.
• Imperfect information: Tic-tac-toe, Battleship, blind, Bridge, and other games with
incomplete information are known as such because the agents do not have all of the
information and are unaware of what is going on.
• Deterministic games: Deterministic games have no element of chance and follow a strict
pattern and set of rules. Examples include chess, checkers, go, tic-tac-toe, and other
games.
• Non-deterministic games: Non-deterministic games are those with a number of
unpredictable events and a chance or luck aspect. Dice or cards are used to introduce the
element of chance or luck. These are unpredictably generated, and each action reaction is
unique. Stochastic games are another name for these types of games.
Example: Backgammon, Monopoly, Poker, etc.

Q3) How to search for games?


A3) Searches in which two or more players with conflicting goals are trying to explore the same
search space for the solution, are called adversarial searches, often known as Games.
Games are modeled as a Search problem and heuristic evaluation function, and these are the two
main factors which help to model and solve games in AI.
Types of Games in AI:

• Perfect information: A game with the perfect information is that in which agents can look
into the complete board. Agents have all the information about the game, and they can see
each other moves also. Examples are Chess, Checkers, Go, etc.
• Imperfect information: If in a game agent do not have all information about the game and
not aware with what's going on, such type of games are called the game with imperfect
information, such as tic-tac-toe, Battleship, blind, Bridge, etc.
• Deterministic games: Deterministic games are those games which follow a strict pattern
and set of rules for the games, and there is no randomness associated with them. Examples
are chess, Checkers, Go, tic-tac-toe, etc.
• Non-deterministic games: Non-deterministic are those games which have various
unpredictable events and has a factor of chance or luck. This factor of chance or luck is
introduced by either dice or cards. These are random, and each action response is not
fixed. Such games are also called as stochastic games.
Example: Backgammon, Monopoly, Poker, etc.

Zero-Sum Game
• Zero-sum games are adversarial search which involves pure competition.
• In Zero-sum game each agent's gain or loss of utility is exactly balanced by the losses or
gains of utility of another agent.
• One player of the game try to maximize one single value, while other player tries to
minimize it.
• Each move by one player in the game is called as ply.
• Chess and tic-tac-toe are examples of a Zero-sum game.

Zero-sum game: Embedded thinking


The Zero-sum game involved embedded thinking in which one agent or player is trying to figure
out:
• What to do.
• How to decide the move
• Needs to think about his opponent as well
• The opponent also thinks what to do
Each of the players is trying to find out the response of his opponent to their actions. This
requires embedded thinking or backward reasoning to solve the game problems in AI.

Formalization of the problem:


A game can be defined as a type of search in AI which can be formalized of the following
elements:
• Initial state: It specifies how the game is set up at the start.
• Player(s): It specifies which player has moved in the state space.
• Action(s): It returns the set of legal moves in state space.
• Result(s, a): It is the transition model, which specifies the result of moves in the state
space.
• Terminal-Test(s): Terminal test is true if the game is over, else it is false at any case. The
state where the game ends is called terminal states.
• Utility(s, p): A utility function gives the final numeric value for a game that ends in
terminal states s for player p. It is also called payoff function. For Chess, the outcomes are
a win, loss, or draw and its payoff values are +1, 0, ½. And for tic-tac-toe, utility values
are +1, -1, and 0.

Q4) What do you mean optimal decision in games?


A4) Optimal decision in multiplayer games
A dependent strategy, which defines MAX's move in the initial state, then MAX's movements in
the states resulting from every probable response by MIN (the opponent), and so on, is the optimal
solution in adversarial search.

One move deep: If a game ends after one MAX and MIN move each, we say the tree is one move
deep, with two half-moves, each referred to as a ply.

Minimax value: The node's minimax value is the utility (for MAX) of being in the corresponding
state, assuming that both players play optimally from there until the game ends. The minimax value
of a terminal state determines its utility.
Given a game tree, the optimal strategy can be computed using the minimax value of each node,
i.e., MINIMAX (n).
MAX likes to get to the highest value state, whereas MIN prefers to go to the lowest value state.
Fig 1: Two ply game tree

Multiplayer games
Each node's single value must be replaced by a vector of values. A vector VA, VB, VC> is
associated with each node in a three-player game with players A, B, and C, for example.
From each actor's perspective, this vector indicates the utility of a terminal circumstance.
In nonterminal states, the backed-up value of a node n is always the utility vector of the successor
state with the highest value for the player choosing at n.

Fig 2: Three piles of a game tree with three players (A, B, C)

Q5) Explain heuristic alpha beta tree search?


A5) Alpha-beta pruning is a modified version of the minimax algorithm. It is an optimization
technique for the minimax algorithm.
● As we have seen in the minimax search algorithm that the number of game states it has to
examine are exponential in depth of the tree. Since we cannot eliminate the exponent, but we can
cut it to half. Hence there is a technique by which without checking each node of the game tree we
can compute the correct minimax decision, and this technique is called pruning. This involves two
threshold parameter Alpha and beta for future expansion, so it is called alpha-beta pruning. It is
also called as Alpha-Beta Algorithm.
● Alpha-beta pruning can be applied at any depth of a tree, and sometimes it not only prune the
tree leaves but also entire sub-tree.
● The two-parameter can be defined as:
1. Alpha: The best (highest-value) choice we have found so far at any point along the path of
Maximizer. The initial value of alpha is -∞.
2. Beta: The best (lowest-value) choice we have found so far at any point along the path of
Minimizer. The initial value of beta is +∞.
● The Alpha-beta pruning to a standard minimax algorithm returns the same move as the
standard algorithm does, but it removes all the nodes which are not really affecting the final
decision but making algorithm slow. Hence by pruning these nodes, it makes the algorithm fast.

Condition for Alpha-beta pruning:


The main condition which required for alpha-beta pruning is:
α>=β

Pseudo-code for Alpha-beta Pruning:


1. Function minimax(node, depth, alpha, beta, maximizingPlayer) is
2. If depth ==0 or node is a terminal node then
3. Return static evaluation of node
4. If MaximizingPlayer then // for Maximizer Player
5. MaxEva= -infinity
6. For each child of node do
7. Eva= minimax(child, depth-1, alpha, beta, False)
8. MaxEva= max(maxEva, eva)
9. Alpha= max(alpha, maxEva)
10.If beta<=alpha
11.Break
12.Return maxEva
13.Else // for Minimizer player
14.MinEva= +infinity
15.For each child of node do
16.Eva= minimax(child, depth-1, alpha, beta, true)
17.MinEva= min(minEva, eva)
18.Beta= min(beta, eva)
19.If beta<=alpha
20.Break
21.Return minEva

Q6) Explain the working of alpha beta pruning?


A6) Working of Alpha-Beta Pruning:
Let's take an example of two-player search tree to understand the working of Alpha-beta pruning
Step 1: At the first step the, Max player will start first move from node A where α= -∞ and β= +∞,
these value of alpha and beta passed down to node B where again α= -∞ and β= +∞, and Node B
passes the same value to its child D.
Step 2: At Node D, the value of α will be calculated as its turn for Max. The value of α is compared
with firstly 2 and then 3, and the max (2, 3) = 3 will be the value of α at node D and node value
will also 3.

Step 3: Now algorithm backtrack to node B, where the value of β will change as this is a turn of
Min, Now β= +∞, will compare with the available subsequent nodes value, i.e. min (∞, 3) = 3,
hence at node B now α= -∞, and β= 3.

In the next step, algorithm traverse the next successor of Node B which is node E, and the values of
α= -∞, and β= 3 will also be passed.
Step 4: At node E, Max will take its turn, and the value of alpha will change. The current value of
alpha will be compared with 5, so max (-∞, 5) = 5, hence at node E α= 5 and β= 3, where α>=β, so
the right successor of E will be pruned, and algorithm will not traverse it, and the value at node E
will be 5.

Step 5: At next step, algorithm again backtrack the tree, from node B to node A. At node A, the
value of alpha will be changed the maximum available value is 3 as max (-∞, 3)= 3, and β= +∞,
these two values now passes to right successor of A which is Node C.
At node C, α=3 and β= +∞, and the same values will be passed on to node F.

Step 6: At node F, again the value of α will be compared with left child which is 0, and max(3,0)=
3, and then compared with right child which is 1, and max(3,1)= 3 still α remains 3, but the node
value of F will become 1.
Step 7: Node F returns the node value 1 to node C, at C α= 3 and β= +∞, here the value of beta will
be changed, it will compare with 1 so min (∞, 1) = 1. Now at C, α=3 and β= 1, and again it satisfies
the condition α>=β, so the next child of C which is G will be pruned, and the algorithm will not
compute the entire sub-tree G.

Step 8: C now returns the value of 1 to A here the best value for A is max (3, 1) = 3. Following is
the final game tree which is the showing the nodes which are computed and nodes which has never
computed. Hence the optimal value for the maximizer is 3 for this example.
Move Ordering in Alpha-Beta pruning:
The effectiveness of alpha-beta pruning is highly dependent on the order in which each node is
examined. Move order is an important aspect of alpha-beta pruning.
It can be of two types:
● Worst ordering: In some cases, alpha-beta pruning algorithm does not prune any of the leaves
of the tree, and works exactly as minimax algorithm. In this case, it also consumes more time
because of alpha-beta factors, such a move of pruning is called worst ordering. In this case, the best

move occurs on the right side of the tree. The time complexity for such an order is O(b m).
● Ideal ordering: The ideal ordering for alpha-beta pruning occurs when lots of pruning happens
in the tree, and best moves occur at the left side of the tree. We apply DFS hence it first search left
of the tree and go deep twice as minimax algorithm in the same amount of time. Complexity in

ideal ordering is O(b m/2).


Rules to find good ordering:
Following are some rules to find good ordering in alpha-beta pruning:
● Occur the best move from the shallowest node.
● Order the nodes in the tree such that the best nodes are checked first.
● Use domain knowledge while finding the best move. Ex: for Chess, try order: captures first, then
threats, then forward moves, backward moves.
● We can bookkeep the states, as there is a possibility that states may repeat.

Q7) Describe monte carlo search tree?


A7) Monte Carlo Tree Search (MCTS) is an artificial intelligence (AI) search strategy (AI). It's a
probabilistic and heuristic-driven search method that blends traditional tree search implementations
with reinforcement learning machine learning principles.
There's always the risk that the current best action isn't the most optimal action in tree search. In
such instances, the MCTS algorithm comes in handy since it continues to assess other options
occasionally during the learning phase by executing them instead of the currently perceived
optimal approach. The "exploration-exploitation trade-off" is what it's called. It takes advantage of
the actions and tactics that have been determined to be the most effective up to this point, but it
must also continue to investigate the local space of alternative decisions to see if they may replace
the present best.
Exploration aids in the exploration and discovery of the tree's unexplored areas, which may lead to
the discovery of a more ideal path. To put it another way, inquiry broadens the tree's width rather
than its depth. Exploration can help ensure that MCTS isn't missing out on any possibly better
options. However, in cases involving a high number of steps or repeats, it quickly becomes
inefficient. To avoid this, exploitation is used to balance things out.
Exploitation remains focused on a single path with the highest estimated value. This is a greedy
technique, as it will increase the depth of the tree rather than its breadth. In basic terms, when
applied to trees, the UCB formula helps to balance the exploration-exploitation trade-off by
regularly examining relatively unknown nodes of the tree and discovering possibly more optimum
paths than the one it is currently exploiting.
For this characteristic, MCTS becomes particularly useful in making optimal decisions in Artificial
Intelligence (AI) problems.

Monte Carlo Tree Search (MCTS) algorithm:


The building blocks of the search tree in MCTS are nodes. These nodes are created using the
results of several simulations. Monte Carlo Tree Search is divided into four steps: selection,
expansion, simulation, and back propagation. Each of these steps is described in greater depth
below:
Selection - The MCTS method uses a specific technique to explore the current tree from the root
node. To choose the nodes with the highest estimated value, the technique employs an evaluation
function. To traverse the tree, MCTS uses the Upper Confidence Bound (UCB) formula applied to
trees as the approach in the selection process. It strikes a balance between exploration and
exploitation. A node is chosen during tree traversal based on some parameters that return the
highest value. The parameters are defined by the formula below, which is commonly used for this
purpose.
Where;
Si = value of a node i
Xi = empirical mean of a node i
C = a constant
t = total number of simulations
The child node that returns the biggest value from the above equation will be selected when
traversing a tree during the selection phase. When a child node that is also a leaf node is detected
during traversal, the MCTS enters the expansion stage.
Expansion - A new child node is added to the tree to the node that was optimally attained during
the selection process in this process.

Simulation - A simulation is carried out in this process by selecting moves or strategies until a
desired result or condition is obtained.

Backpropagation - The remaining tree must be modified after finding the value of the newly
inserted node. As a result, the backpropagation process is carried out, in which the new node
propagates back to the root node. The amount of simulations kept in each node is increased during
the procedure. The number of wins is also increased if the new node's simulation results in a win.
The actions outlined above can be visualised using the graphic below:

Fig 3: Outlined visualised graphics

These algorithms are especially beneficial in turn-based games like Tic Tac Toe, Connect 4,
Checkers, Chess, Go, and others where there is no element of chance in the game rules. Artificial
Intelligence Programs, such as AlphaGo, have lately employed this to compete against the world's
best Go players. However, its use isn't confined to video games. It can be applied to any situation
with state-action pairings and simulations to predict outcomes.

Q8) Define stochastic games?


A8) Stochastic games are simulations of dynamic interactions in which the environment changes in
response to the activities of the participants. "In a stochastic game, the play progresses by steps
from position to position, according to transition probabilities determined jointly by the two
players," Shapley writes.
A group of participants participates in a stochastic game. At each stage of the game, the action
takes place in a specific state (or position, in Shapley's terminology), and each player selects an
action from a list of options. The stage payoff that each player receives is determined by the
collection of actions that the players choose, as well as the current state, as well as a probability
distribution for the subsequent state that the game will visit.
Stochastic games apply von Neumann's model of strategic-form games to dynamic settings in
which the environment varies in response to the players' decisions. They also use the Markov
decision problem model, which was created by numerous RAND Corporation researchers in 1949–
1952, to competitive scenarios with multiple decision makers.
The complexity of stochastic games arises from the fact that the players' decisions have two,
sometimes opposing, consequences. First, the players' actions, in combination with the present
state, determine the immediate payment that each player receives. Second, the present state and the
players' activities influence the next state selection, which influences future reward possibilities.
Each player, in particular, must balance these factors when deciding on his actions, which might be
a difficult decision.
Although this dichotomy is also present in one-player sequential decision problems, the presence of
additional players who maximize their own goals adds complexity to the analysis of the situation.

Two player Games


For modelling and analysis of discrete systems functioning in an uncertain (adversarial)
environment, stochastic two-player games on directed graphs are commonly employed. As vertices,
a system's and its environment's possible configurations are represented, and transitions correspond
to the system's, its environment's, or "nature's" actions. An infinite path in the graph corresponds to
a run of the system. As a result, a system and its environment can be viewed as two hostile players,
with one player (the system) aiming to maximise the probability of "good" runs and the other
player (the environment) aiming to maximise the chance of "bad" runs.
Although there may be an equilibrium value for this probability in many circumstances, there may
not be optimal solutions for both parties.
We go over some of the fundamental notions and algorithmic concerns that have been studied in
this field, as well as some long-standing outstanding difficulties. Then we'll go through a few
recent findings.

Application
Economic theory, evolutionary biology, and computer networks all use stochastic games. They are
generalizations of repeated games that correspond to the unique case of a single state.

Q9) Write short notes on partially observable games?


A9) A partially observable stochastic game (POSG) is a tuple

0 i i i
{I, S, {b }, {A }, {O },P, {R }i, where
● I is a finite set of agents (or controllers) indexed 1, . . . , n.
● S is a finite set of states.

● b 0 ∈ ∆(S) represents the initial state distribution


● Ai is a finite set of actions available to agent i and A~ = ×i ∈IAi is the set of joint actions (i.e.,
action profiles), where ~a = ha1, . . . , ani denotes a joint action
i
● O is a finite set of observations for agent i and O~ = ×i ∈IOi is the set of joint observations,
where ~o = ho1, . . . , oni denotes a joint observation
● P is a set of Markovian state transition and observation probabilities, where P(s 0 , ~o|s, ~a)
denotes the probability that taking joint action ~a in state s results in a transition to state s 0 and
joint observation ~o

i
● R : S × A → < ~ is a reward function for agent i

A game unfolds across a finite or infinite number of stages, with the number of stages referred to as
the game's horizon. We focus on finite-horizon POSGs in this study; some of the issues of solving
the infinite-horizon situation are highlighted at the end. At each level, all agents choose an action at
the same time and are rewarded and observed. Each agent's goal is to maximize the expected sum
of prizes it will receive during the game. The reward functions determine whether agents compete
or cooperate in their quest for a reward. A decentralized partially observable Markov decision
process is one in which the agents share the same reward function.

Q10) Write the limitation of game search algorithms?


A10) Limitations of game search algorithms
● The process of obtaining the goal is slower due to the large branching factor.
● The engine's performance and efficiency suffer as a result of evaluating and searching all
conceivable nodes and branches.
● Both players have an excessive number of options from which to choose.
● It is impossible to investigate the complete tree if there is a time and space constraint.
● The biggest disadvantage of the minimax algorithm is that it becomes extremely slow while
playing complex games like chess or go. This style of game contains a lot of branching, and the
player has a lot of options to choose from.
The algorithm, however, can be enhanced by Alpha-Beta Pruning.

Q11) What is CSP?


A11) A constraint satisfaction problem (CSP) consists of
● A set of variables,
● A domain for each variable, and
● A set of constraints.

The aim is to choose a value for each variable so that the resulting possible world satisfies the
constraints; we want a model of the constraints.
A finite CSP has a finite set of variables and a finite domain for each variable. Many of the
methods considered in this chapter only work for finite CSPs, although some are designed for
infinite, even continuous, domains.
The multidimensional aspect of these problems, where each variable can be seen as a separate
dimension, makes them difficult to solve but also provides structure that can be exploited.
Given a CSP, there are a number of tasks that can be performed:
● Determine whether or not there is a model.
● Find a model.
● Find all of the models or enumerate the models.
● Count the number of models.
● Find the best model, given a measure of how good models are.
● Determine whether some statement holds in all models.

This mostly considers the problem of finding a model. Some of the methods can also determine if
there is no solution. What may be more surprising is that some of the methods can find a model if
one exists, but they cannot tell us that there is no model if none exists.
CSPs are very common, so it is worth trying to find relatively efficient ways to solve them.
Determining whether there is a model for a CSP with finite domains is NP-hard and no known
algorithms exist to solve such problems that do not use exponential time in the worst case.
However, just because a problem is NP-hard does not mean that all instances are difficult to solve.
Many instances have structure that can be exploited.

Q12) Describe constraints propagation?


A12) The constraints are used in a number of inference approaches to determine which
variable/value combinations are consistent and which are not. Node, arc, path, and k-consistent are
examples of these.
Constraint propagation: Using constraints to reduce the number of permissible values for one
variable, which then reduces the number of legal values for another variable, and so on.

Local consistency: If we treat each variable as a node in a graph and each binary constraint as an
arc, the act of enforcing local consistency in each area of the graph eliminates inconsistent values
across the board.
Different types of local consistency exist:
Node consistency
● If all of the values in the variable's domain fulfil the variable's unary constraint, the variable is
node-consistent (a node in the CSP network).
● If every variable in a network is node-consistent, we call it a node-consistent network.

Arc consistency
● If every value in a variable's domain fulfils the variable's binary constraints, the variable is arc-
consistent in a CSP.

j
● If there is some value in the domain D that satisfies the binary constraint on the arc for every

value in the current domain Di, then Xi is arc-consistent with regard to another variable X (X ,j i
j
X ).
● If every variable in a network is arc-consistent with every other variable, it is said to be arc-
consistent.
● Using the arcs, arc consistency tightens the domains (unary constraint) (binary constraints).

AC-3 algorithm
Function AC-3(csp) returns false if an inconsistency is found and true otherwise
Inputs: csp, a binary CSP with components (X, D, C)
Local variables: queue, a queue of arcs, initially all the arcs in csp
While queue is not empty do

If REVISE(csp, ) then
If size of then return false

For each in NEIGHBORS - do

Add to queue
Return true

Function REVISE (csp, returns true iff we revise the domain of

Revised false

For each x in do

If no value in allows (x,y) to satisfy the constraint between and then

Delete from

Revised true
Return revised
This is arc consistency algorithm

● AC-3 keeps an arc queue that initially contains all of the arcs in the CSP.
● Then, from the queue, AC-3 selects an arbitrary arc (Xi, Xj) and makes Xi arc-consistent with
respect to Xj.
● If Di remains unchanged, continue on to the next arc; if Di is revised, add any arcs (Xk, Xi)
where Xk is a neighbour of Xi to the queue.
● If Di is reduced to zero, the entire CSP will collapse since there is no consistent answer.
● Otherwise, keep checking and removing values from variable domains until there are no more
arcs in the queue.
● As a result, an arc-consistent CSP with smaller domains has the same solutions as the original.

The complexity of AC-3:


Assume a CSP with n variables, each with domain size at most d, and with c binary constraints
(arcs). Checking consistency of an arc can be done in O(d2) time, total worst-case time is O(cd3)

Path consistency
● A two-variable set Xi, Xj is path-consistent with regard to a third variable Xm if there is an
assignment to Xm that fulfils the constraints on Xi, Xm, and Xm, Xj for every assignment Xi = a,
Xj = b consistent with the constraint on Xi, Xj.
● The binary restrictions are tightened by path consistency, which uses implicit constraints inferred
from triples of variables.

K-consistency
● A CSP is k-consistent if a consistent value can always be assigned to any kth variable for any
collection of k-1 variables and for any consistent assignment to those variables.
● 1-consistency = node consistency; 2-consistency = arc consistency; 3-consistency = path
consistency.
● If a CSP is k-consistent and also (k – 1)-consistent, (k – 2)-consistent,... All the way down to 1-
consistent, it is very k-consistent.
● We can ensure that if we take a CSP with n nodes and make it strongly n-consistent, we will

2
discover a solution in time O(n d). However, in the worst situation, the procedure for establishing
n-consistency must take time exponential in n and demand space exponential in n.

Global constraints
A global constraint is one that applies to an infinite number of variables (but not necessarily all
variables). Special-purpose algorithms that are more efficient than general-purpose approaches can
manage global constraints.
1) inconsistency detection for Alldiff constraints
A straightforward formula is as follows: Remove any variable with a singleton domain from the
constraint and delete its value from the domains of the remaining variables. Repeat for as long as
singleton variables exist. An inconsistency has been discovered if an empty domain is formed at
any stage or if there are more variables than domain values left.
Applying arc consistency to an analogous collection of binary constraints is sometimes more
effective than using a simple consistency approach for a higher-order constraint.

2) inconsistency detection for resource constraint (the atmost constraint)


● By calculating the total of the current domains' minimum values, we may find inconsistencies.
● e.g., Atmost(10, P1, P2, P3, P4): a total of no more than 10 workers is assigned.
● The Atmost constraint cannot be met if each variable has the domain 3, 4, 5, 6.
● We can ensure consistency by eliminating any domain's maximum value if it differs from the
minimum values of the other domains.
● For example, if the domains of each variable in the example are 2, 3, 4, 5, 6, the values 5 and 6
can be removed from each domain.
3) inconsistency detection for bounds consistent
Domains are represented by upper and lower limits and handled via bounds propagation for big
resource-limited issues with integer values.
e.g - In an airline-scheduling problem, imagine there are two flights F1 and F2, each with a
capacity of 165 and 385 passengers. The initial domains for passenger numbers on each aircraft are
D1 = [0, 165] and D2 = [0, 385].
Assume we also have the limitation that the two flights must each carry 420 passengers: F1 + F2 =
420. We reduce the domains to, by propagating bounds constraints.
D1 = [35, 165] and D2 = [255, 385].
If there is a value of Y that fulfills the constraint between X and Y for every variable Y, and for
both the lower-bound and upper-bound values of X, a CSP is bound consistent.

Q13) Define backtracking search for CSP?


A13) CSPs are frequently solved via backtracking search, a type of depth-first search. Inference
and search can be combined.
Commutativity: All CSPs are commutative. A issue is commutative if the sequence in which a
series of activities is carried out has no bearing on the outcome.

Backtracking search: A depth-first search that assigns values to one variable at a time and then
backtracks when there are no more legal values to assign to that variable.
The backtracking algorithm selects an unassigned variable each time and then attempts all of the
values in that variable's domain in order to discover a solution. If an inconsistency is found,
BACKTRACK fails, leading the previous call to try a different value.
There is no need to provide a domain-specific initial state, action function, transition model, or goal
test to BACKTRACKING-SEARCH.
BACKTRACKING-SEARCH maintains only one representation of a state and modifies it rather
than producing new ones.
Function BACTRACKING-SEARCH(csp) returns a solution, or failure
Return BACTRACK({}, csp)
Var SELECT-UNASSIGNED-VARIABLE(csp)
For each value in ORDER-DOMAIN-VALUES(var,assignement,csp) do
If value is consistent with assignment then
Add{var=value} to assignment
Inferences INFERENCE(csp,var,value)
If inferences failure then
Add inferences to assignment
Result BACKTRACK (assignment, csp)
If result failure then
Return result
Remove {var=value} and inferences from assignment
Return failure
This is simple backtracking algorithm for CSP
Address the following questions to efficiently answer CSPs without domain-specific knowledge:
Which variable should be assigned next, according to the SELECT-UNASSIGNED-VARIABLE
function?
What order should the values of the ORDER-DOMAIN-VALUES function be tested in?

2)INFERENCE FUNCTION: What inferences should be made at each stage of the search?
3)Can the search avoid repeating its failure when it comes across an assignment that violates a
constraint?

1. Variable and value ordering

SELECT-UNASSIGNED-VARIABLE
Variable selection—fail-first

Minimum-remaining-values (MRV) heuristic: The concept of selecting the variable having the
smallest number of "legal" values. The "most constrained variable" or "fail-first" heuristic selects a
variable that is most likely to cause a failure soon, allowing the search tree to be pruned. If a
variable X has no more permissible values, the MRV heuristic will select X, and failure will be
noticed instantly, avoiding the need for fruitless searches through other variables.
For example, since there is only one potential value for SA after WA=red and NT=green, it makes
logical to assign SA=blue next rather than Q.

Degree heuristic: By selecting the variable that is implicated in the greatest number of constraints
on other unassigned variables, the degree heuristic seeks to lower the branching factor on future
decisions.
SA, for example, has the highest degree of 5; the other variables have degrees of 2 or 3; and T has a
degree of 0.
ORDER-DOMAIN-VALUES
Value selection—fail-last
If we're looking for all possible solutions to a problem (rather than simply the first one), the order
doesn't matter.
Least-constraining-value heuristic: chooses the value that eliminates the fewest options for the
constraint graph's surrounding variables. (Leave as much freedom as possible for subsequent
variable assignments.)
For example, we've created a partial assignment with WA=red and NT=green, and Q is our next
option. Because blue eliminates the final lawful value available for Q's neighbour, SA, who prefers
red to blue, it is a negative decision.
In a backtracking search, the minimum-remaining-values and degree heuristics are domain-
independent approaches for determining which variable to choose next. The least-constraining-
value heuristic aids in determining which value for a given variable to try first.

2. Interleaving search and inference


INFERENCE
Forward chaining - [One of the simplest forms of inference is forward checking.] When a variable
X is assigned, the forward-checking method creates arc consistency for it: delete from Y's domain
any value that is inconsistent with the value chosen for X for each unassigned variable Y that is
associated to X by a constraint.
If we've previously done arc consistency as a preprocessing step, there's no reason to do forward
checking.

Fig 4: Progress of a map coloring search with forward checking

Advantage: Combining the MRV heuristic with forward checking will make the search more
effective for many issues.

Disadvantages: Forward checking only makes the current variable arc-consistent, not all the other
variables.

MAC (Maintaining Arc Consistency) algorithm: [Detect this inconsistency more effectively than
forward checking.] The INFERENCE function invokes AC-3 once a variable Xi is allocated a
value, but instead of a queue of all arcs in the CSP, we only start with the arcs(Xj, Xi) for those Xj
that are unassigned variables that are neighbours of Xi. The call to AC-3 then proceeds as usual,
with the exception that if any variable's domain is reduced to the empty set, the call to AC-3 fails
and we know to retrace immediately.

3. Intelligent backtracking
Fig 5: (a) Principal states and territories of Australia. Colouring this map can be viewed as CSP. (b)
the map coloring problem represented as a constraint graph

Chronological backtracking: Figure shows the BACKGRACING-SEARCH. If a branch of the


search fails, go back to the previous variable and try a different value for it. (The most recent point
of decision is revisited.)
For example, consider the partial assignment Q=red, NSW=green, V=blue, T=red.
When we attempt the next variable, SA, we notice that every value breaks a constraint.
We go back to T and try a different hue, but it doesn't work.

Intelligent backtracking: Return to the variable that caused one of the possible values of the
following variable (e.g. SA) to be impossible.
A collection of assignments for a variable that are in conflict with some value for that variable.
(For example, the conflict set for SA is Q=red, NSW=green, V=blue.)
Backtracks to the most recent assignment in the conflict set using the backjumping approach.
(e.g - Backjumping, for example, would leap over T and try a different value for V.)
Forward checking can supply the conflict set with no extra work.
Add X=x to Y's conflict set whenever forward checking based on an assignment X=x deletes a
value from Y's domain.
If the last value in Y's domain is removed, the assignments in Y's conflict set are added to X's
conflict set.
In reality, forward checking prunes every branch cut by backjumping. In a forward-checking search
or a search that uses stronger consistency checking, basic backjumping is thus superfluous (such as
MAC).

Q14) Where is the game theory now?


A14) Game Theory is increasingly becoming a part of the real-world in its various applications in
areas like public health services, public safety, and wildlife. Currently, game theory is being used in
adversary training in GANs, multi-agent systems, and imitation and reinforcement learning. In the
case of perfect information and symmetric games, many Machine Learning and Deep Learning
techniques are applicable. The real challenge lies in the development of techniques to handle
incomplete information games, such as Poker. The complexity of the game lies in the fact that there
are too many combinations of cards and the uncertainty of the cards being held by the various
players.
Unit - 4
Knowledge
Q1) What do you mean by knowledge based agents?
A1) An intelligent agent needs knowledge of the real world in order to make effective decisions
and reasoning.
● Knowledge-based agents are capable of retaining an internal state of knowledge, reasoning
about it, updating it in response to observations, and acting on it. These agents can represent the
world and operate intelligently using some type of formal representation.
● Two major components make up knowledge-based agents:
○ Knowledge-base and
○ Inference system.

The following tasks must be performed by a knowledge-based agent:


● Agents should be able to represent states, actions, and other things.
● A representative new percept should be able to be incorporated.
● The internal representation of the world can be updated by an agent.
● The internal representation of the world can be deduced by an agent.
● An agent can deduce the best course of action.

The Architecture of knowledge-based agents

Fig 1: Architecture of knowledge-based agents

The graphic above shows a general design for a knowledge-based agent. The knowledge-based
agent (KBA) collects input from the environment by monitoring it. The agent's inference engine
processes the data and communicates with KB to make judgments based on the knowledge
contained in KB. The learning component of KBA keeps the knowledge base current by learning
new material.
Q2) Describe the wumpus world?
A2) The Wumpus world is a basic world example that demonstrates the value of a knowledge-
based agent and how knowledge representation is represented. It was inspired by Gregory Yob's
1973 video game Hunt the Wumpus.
The Wumpus world is a cave with four rooms and pathways connecting them. As a result, there are
a total of 16 rooms that are interconnected. We now have a knowledge-based AI capable of
progressing in this world. There is an area in the cave with a beast named Wumpus who eats
everybody who enters. The agent can shoot the Wumpus, but he only has a single arrow. There are
some Pits chambers in the Wumpus universe that are bottomless, and if an agent falls into one, he
will be stuck there indefinitely.
The intriguing thing about this cave is that there is a chance of finding a gold heap in one of the
rooms. So the agent's mission is to find the gold and get out of the cave without getting eaten by
Wumpus or falling into Pits. If the agent returns with gold, he will be rewarded, but if he is
devoured by Wumpus or falls into the pit, he will be penalised.
A sample diagram for portraying the Wumpus planet is shown below. It depicts some rooms with
Pits, one room with Wumpus, and one agent in the world's (1, 1) square position.

There are some elements that can assist the agent in navigating the cave. The following are the
components:
● The rooms adjacent to the Wumpus room are stinky, thus there is a stench there.
● The room next to PITs has a breeze, so if the agent gets close enough to PIT, he will feel it.
● If and only if the room contains gold, there will be glitter.
● If the agent is facing the Wumpus, the agent can kill it, and the Wumpus will cry horribly, which
can be heard throughout the cave.

PEAS description of Wumpus world:


Performance Measures, Environment, Actuators, and Sensors (PEAS) are acronyms for
Performance Measures, Environment, Actuators, and Sensors. The PEAS description aids in the
classification of the agents.

The Wumpus World problem has the following PEAS description:


Performance measures:
● Agent gets the gold and return back safe = +1000 points
● Agent dies = -1000 points
● Each move of the agent = -1 point
● Agent uses the arrow = -10 points

Environment:
● There are 16(4x4) rooms in this cave.
● The rooms opposite to the Wumpus (not diagonally) stink.
● Rooms adjacent to the pit (but not diagonally) are cool.
● The gold-studded chamber gleams.
● Agent's first position is in Room[1, 1], facing the right side.
● Wumpus, gold, and the three pits can be found anywhere except in Room[1, 1].

Actuators:
Devices that enable the agent to carry out the operations listed below in the surroundings.
● Move forward
● Turn right
● Turn left
● Shoot
● Grab
● Release

Sensors:
Devices that assist the agent in detecting the following from their surroundings.
● Breeze
● Stench
● Glitter
● Scream (When the Wumpus is killed)
● Bump (when the agent hits a wall)

Q3) Write the property of wumpus world?


A3) The Wumpus world Properties:
● Partially observable: Because the agent can only observe the immediate environment, such as a
nearby room, the Wumpus universe is only partially visible.
● Deterministic: It is deterministic since the world's consequence and outcome are already known.
● Sequential: It is sequential because the order is critical.
● Static: Wumpus and Pits aren't moving, thus it's static.
● Discrete: The setting is distinct.
● One agent: We only have one agent, and Wumpus is not regarded as an agent, hence the
environment is single agent.

Q4) Define logic?


A4) A logic is a formal language that allows sound inference and has well defined syntax and
semantics. There are various logics that allow you to represent various types of things and allow for
more or less efficient inference. Different varieties of logic exist, such as propositional logic,
predicate logic, temporal logic, and description logic. However, expressing something in logic may
not be natural, and conclusions may be ineffective.

Example of logic
Language of numerical constraints:
● A sentence:
x + 3 ≤ z x,
z - variable symbols (primitives in the language)

● An interpretation:
I: x = 5, z = 2
Variables mapped to specific real numbers

● Valuation (meaning) function V:


V (x + 3 ≤ z, I) is False for I: x = 5, z = 2
Is True for I: x = 5, z = 10

Fig 2: Logic

Types of logic
● Different types of logics possible
● Propositional logic
● First-order logic
● Temporal logic
● Numerical constraints logic
● Map-coloring logic

Q5) Describe propositional logic?


A5) Propositional logic (PL) is the simplest form of logic where all the statements are made by
propositions. A proposition is a declarative statement which is either true or false. It is a technique
of knowledge representation in logical and mathematical form.

Example:
1. a) It is Sunday.
2. b) The Sun rises from West (False proposition)
3. c) 3+3= 7(False proposition)
4. d) 5 is a prime number.

Following are some basic facts about propositional logic:


● Propositional logic is also called Boolean logic as it works on 0 and 1.
● In propositional logic, we use symbolic variables to represent the logic, and we can use any
symbol for a representing a proposition, such A, B, C, P, Q, R, etc.
● Propositions can be either true or false, but it cannot be both.
● Propositional logic consists of an object, relations or function, and logical connectives.
● These connectives are also called logical operators.
● The propositions and connectives are the basic elements of the propositional logic.
● Connectives can be said as a logical operator which connects two sentences.
● A proposition formula which is always true is called tautology, and it is also called a valid
sentence.
● A proposition formula which is always false is called Contradiction.
● A proposition formula which has both true and false values is called
● Statements which are questions, commands, or opinions are not propositions such as "Where is
Rohini", "How are you", "What is your name", are not propositions.

Syntax of propositional logic:


The syntax of propositional logic defines the allowable sentences for the knowledge representation.
There are two types of Propositions:
1. Atomic Propositions
2. Compound propositions

1. Atomic Proposition: Atomic propositions are the simple propositions. It consists of a single
proposition symbol. These are the sentences which must be either true or false.
Example:
1. a) 2+2 is 4, it is an atomic proposition as it is a true fact.
2. b) "The Sun is cold" is also a proposition as it is a false fact.

2. Compound proposition: Compound propositions are constructed by combining simpler or atomic


propositions, using parenthesis and logical connectives.
Example:
1. a) "It is raining today, and street is wet."
2. b) "Ankit is a doctor, and his clinic is in Mumbai."

Logical Connectives:
Logical connectives are used to connect two simpler propositions or representing a sentence
logically. We can create compound propositions with the help of logical connectives. There are
mainly five connectives, which are given as follows:
1. Negation: A sentence such as ¬ P is called negation of P. A literal can be either Positive
literal or negative literal.
2. Conjunction: A sentence which has ∧connective such as, P ∧ Q is called a conjunction.
Example: Rohan is intelligent and hardworking. It can be written as,
P= Rohan is intelligent, Q= Rohan is hardworking. → P∧ Q.
3. Disjunction: A sentence which has ∨ connective, such as P ∨ Q. Is called disjunction,
where P and Q are the propositions.
Example: "Ritika is a doctor or Engineer",
Here P= Ritika is Doctor. Q= Ritika is Doctor, so we can write it as P ∨ Q.
4. Implication: A sentence such as P → Q, is called an implication. Implications are also known as
if-then rules. It can be represented as
If it is raining, then the street is wet.
Let P= It is raining, and Q= Street is wet, so it is represented as P → Q
5. Biconditional: A sentence such as P⇔ Q is a Biconditional sentence, example If I am breathing,
then I am alive
P= I am breathing, Q= I am alive, it can be represented as P ⇔ Q.

Following is the summarized table for Propositional Logic Connectives:

Truth Table:
In propositional logic, we need to know the truth values of propositions in all possible scenarios.
We can combine all the possible combination with logical connectives, and the representation of
these combinations in a tabular format is called Truth table. Following are the truth table for all
logical connectives:
For negation

For conjunction

For disjunction

For implication

For Biconditional
Truth table with three propositions:
We can build a proposition composing three propositions P, Q, and R. This truth table is made-up
of 8n Tuples as we have taken three proposition symbols.

Precedence of connectives:
Just like arithmetic operators, there is a precedence order for propositional connectors or logical
operators. This order should be followed while evaluating a propositional problem. Following is
the list of the precedence order for operators:
Note: For better understanding use parenthesis to make sure of the correct interpretations. Such as
¬R∨ Q, It can be interpreted as (¬R) ∨ Q.

Logical equivalence:
Logical equivalence is one of the features of propositional logic. Two propositions are said to be
logically equivalent if and only if the columns in the truth table are identical to each other.
Let's take two propositions A and B, so for logical equivalence, we can write it as A ⇔B. In below
truth table we can see that column for ¬A∨ B and A→B, are identical hence A is Equivalent to B

Properties of Operators:
Commutativity:
• P∧ Q= Q ∧ P, or
• P ∨ Q = Q ∨ P.

Associativity:
• (P ∧ Q) ∧ R= P ∧ (Q ∧ R),
• (P ∨ Q) ∨ R= P ∨ (Q ∨ R)

Identity element:
• P ∧ True = P,
• P ∨ True= True.

Distributive:
• P∧ (Q ∨ R) = (P ∧ Q) ∨ (P ∧ R).
• P ∨ (Q ∧ R) = (P ∨ Q) ∧ (P ∨ R).

DE Morgan's Law:
• ¬ (P ∧ Q) = (¬P) ∨ (¬Q)
• ¬ (P ∨ Q) = (¬ P) ∧ (¬Q).

Double-negation elimination:
• ¬ (¬P) = P.

Limitations of Propositional logic:


● We cannot represent relations like ALL, some, or none with propositional logic.
Example:
All the girls are intelligent.
Some apples are sweet.
● Propositional logic has limited expressive power.
● In propositional logic, we cannot describe statements in terms of their properties or logical
relationships.

Q6) Explain propositional theorem proving?


A6) Using logical principles of inference to produce logical implications is an alternative method
to using logic to solve problems.
This can be less work than model-checking (creating a truth table) or even SAT solving in some
circumstances.
Furthermore, logical inference rules are at the level of logical reasoning that humans deliberately
strive for.
Entailment is a topic of interest in theorem-proving; for example, given a logical sentence A and a
logical phrase B, we can ask if A entails B.
The main notion is that sentence A is what the agent already knows, and sentence B is what the
agent can deduce from what it already knows.
The complete "brain" of an agent could be encoded in logic in sentence A.
The deduction theorem is a fundamental fact in logic that states:
If and only if A => B (A implies B) is a tautology, A entails B. (i.e. valid for all assignments of
values to its variables).
Such that we can respond to the question "Does A imply B?" by demonstrating that the phrase A =>
B is a tautology
Remember that a phrase is unsatisfiable if it cannot be made true by assigning values to its
variables.
So A => B is a tautology, then !(A=>B) is unsatisfiable, and !(A=>B) == !(!(A & !B)) == A & !B.
As a result, we can rewrite the deduction theorem as follows:
If and only if, A &!B is unsatisfactory, A entails B.
This means you can figure out entailment using a SAT solver!

Rules of Inference
Remember that proofs, or chains of accurate inferences, can be created using a variety of inference
procedures.
Modus ponens, for example, is an inference rule that states:
A, A => B
--------- modus ponens
B

This rule states that if you're given a sentence A and a sentence A => B, you can infer B. For
example, and-elimination is a set of rules that states:
A&B
----- and-elimination
A

A&B
-----
B

These two rules encode the (obvious!) fact that if the sentences A and B are both true, then A and B
are both true.
Inference rules can also be used to express logical equivalences, such as:
A <==> B
---------------
(A=>B) & (B=>A)

There are many different inference rules, and selecting an acceptable set of rules for a theorem-
prover is crucial.
● The application of a rule of inference can be thought of as an action taken on the state of the
world, in which the rule of inference adds more facts to the knowledge base.
● If there are several inference rules to pick from, knowledge (i.e. heuristics) is required to assist in
the decision-making process.
○ Alternatively, we could use backtracking, which entails picking a rule at random, applying it,
and continuing until it "appears" that no proof is being achieved.
● Furthermore, how do we know that the inference rules we're employing are complete, i.e., how
do we know that if a proof exists, our set of inference rules will locate it?
○ Is it enough to prove any entailment in propositional logic if the two and-elimination rules are
our only rules of inference?
■ no!
■ for example, (P | P) -> P is clearly true, but and-elimination doesn’t apply to this sentence

Q7) Write the effectiveness of propositional model checking?


A7) Given a fixed propositional vocabulary, the collection of viable models is small, hence
entailment can be checked by enumerating models. Backtracking and local search methods are two
efficient model-checking inference algorithms for propositional logic that can typically solve
enormous problems fast.
Based on model checking, there are two families of methods addressing the SAT problem:
a. Based on backtracking
b. Based on local hill-climbing search

1. A complete backtracking algorithm


David-Putnam algorithm (DPLL):
Function DPLL-SATISFIABLE?(s) returns true or false
Inputs: s, a sentence in propositional logic
Clauses the set of clauses in the CNF representation of s
Symbols a list of the proposition symbols in s
Return DPLL (clauses, symbols, {})
Function DPLL (clauses, symbols, model) returns true or false
If every clause in clauses is true in model then return true
If some clause in clauses in clauses is false in model then return false
P, value FIND-UNIT-CLAUSE (clauses, model)
If P is non-null then return DPLL (clauses, symbols – P, model ∪ {P=value} )
P FIRST(symbols): rest REST(symbols)
Return DPLL(clauses, rest, model ∪ {P=true}) or
DPLL(clauses, rest, model ∪ {P=true})

DPLL algorithm for checking satisfiability of a sentence in propositional logic.

DPLL incorporates three enhancements over the TT-ENTAILS scheme: Early termination, pure
symbol heuristic, and unit clause heuristic are all examples of heuristics.
Component analysis, variable and value ordering, intelligent backtracking, random restarts, and
creative indexing are some of the tricks that SAT solvers use to scale up to huge problems.

Local search algorithms


Local search techniques can be easily applied to the SAT issue if the appropriate evaluation
function is used. (An evaluation function that counts the amount of unsatisfied clauses can be
used.)
These algorithms work by flipping the truth value of one symbol at a time in the space of full
assignments.
Local minima are common in space, and escaping them necessitates various sorts of
randomization.
WALKSAT and other local search methods can be utilised to identify solutions. These algorithms
are sound, but they aren't complete.

WALKSAT: is one of the most basic and successful algorithms available.


Function WALKSAT (clauses, p, max, flips) returns a satisfying model or failure
Inputs: clauses, a set of clauses in propositional logic
p, the probability of choosing to do a “random walk” move, typically around 0.5
Max, flips, number of flips allowed before giving up
Model a random assignment of true/false to the symbols in clauses
For i=1 to max flips do
If model satisfies clauses then return model
Clause a randomly selected clause from clauses that is false in model
With probability p flip the value in model of a randomly selected symbol from clause
Else flip whichever symbol in clause maximizes the number of satisfied clauses
Return failure

This is the WALKSAT algorithm for checking satisfiability by randomly flipping the value of
variables

Every iteration, the algorithm selects an unsatisfied sentence and alternates between two methods
for selecting a symbol to flip:
Either a. a "min-conflicts" step that reduces the number of unsatisfied clauses in the new state; or b.
a "min-conflicts" step that reduces the number of unsatisfied clauses in the new state.
Alternatively, there is a "random walk" step that selects the symbol at random.
The input sentence is satisfied when the algorithm returns a model.
There are two possible reasons for the algorithm's failure:
Either a. The sentence is unsatisfiable;
Or b. We need to give the algorithm more time.
If we set max_flips=∞, p>0, the algorithm will:
Either a. If a model exists, eventually return it
Alternatively, b. If the statement is unsatisfactory, never end it.
As a result, WALKSAT is useful when we assume a solution but are unable to detect
unsatisfiability.

The landscape of random SAT problems


When looking at satisfiability problems in CNF, an under constrained problem is one that has a
small number of clauses confining the variables.
An issue that is over constrained has a large number of clauses compared to the number of
variables and is likely to have no solutions.

k
The notation CNF (m, n) denotes a k-CNF sentence with m clauses and n symbols. (with n
variables and k literals per clause).
Given a set of random sentences, choose clauses consistently, independently, and without
replacement from among those clauses with k distinct literals that are either positive or negative at
random.
Hardness: problems right at the threshold > over constrained problems > under constrained
problems
Fig 3: (a) graph showing the probability that random 3-CNF sentence with n = 50 symbols is
satisfiable. (b) graph of the median run time on random 3-CNF sentences.

Satisfiability threshold conjecture: According to one hypothesis, there is a threshold ratio rk for
any k3, such that when n approaches infinity, the likelihood that CNFk(n, rn) is satisfiable becomes
1 for all values or r below the threshold, and 0 for all values or r beyond the threshold.

Q8) What is an agent based on propositional logic?


A8) 1. The current state of the world
To avoid contradiction, we can link propositions to timestamps.
e.g. ¬ Stench, Stench

Fluent - Fluently refers to a changing aspect of the world. (For example, Ltx,y)
Atemporal variables - Symbols that represent eternal characteristics of the world do not require a
time superscript.
Effect Axioms - define the result of an action at the following time step.

Frame problem - Because the effect axioms fail to define what remains unchanged as a result of
an action, significant information is lost.
Solution: explicitly assert all the premises that remain the same by adding frame axioms.

Representation frame problem: In a universe with m distinct actions and n fluents, the
proliferation of frame axioms is inefficient; the set of frame axioms will be O(mn).
Solution: Because the world is mobile, there is a solution (for humans each action typically
changes no more than some number k of those fluents.) Instead of using a collection of axioms of
size O(mk), define the transition model with a set of axioms of size O(mn).

Inferential frame problem: The difficulty of projecting the consequences of a t-step lan of action
forward in time O(kt) rather than O(kt) (nt).
Solution: Change your focus from writing axioms about actions to writing axioms about fluents as
a solution.
We'll have an axiom for each fluent F that describes the truth value of Ft+1 in terms of fluents at
time t and possible actions at time t.

The truth value of F t+1 can be set in one of 2 ways:


Either a. At time t, the action causes F to be true at time t+1.
Or b. F was already true at time t, and the activity at time t did not change that.
A successor-state axiom is a type of axiom that has the following schema:
Action causes
Qualification problem: Specifying any exceptional exceptions that could result in the action
failing.

2. A hybrid agent
Hybrid agent: mixes condition-action rules and problem-solving algorithms to determine various
aspects of the state of the world.
As a current plan, the agent maintains and updates KB.
The atemporal axioms are found in the first KB. (Don't rely on t.)
Each time step adds a new percept sentence, as well as all the axioms that are dependent on t. (such
as the successor-state axioms).
The agent then employs logical inference by ASKING the KB questions (to work out which
squares are safe and which have yet to be visited).
The agent program's main body creates a plan based on a diminishing priority of goals:
1. If there is a glint, devise a strategy for grabbing the gold, returning to the original place, and
climbing out of the cave;
2. If there is no current plan, plan a route (using A* search) to the nearest safe square that has not
yet been visited, ensuring that the path passes through only safe squares;
3. If there are no safe squares to investigate and you still have an arrow, try shooting at one of the
available wumpus spots to create a safe square.
4. If this doesn't work, look for a square to explore that isn't shown to be dangerous.
5. If the job is difficult because there is no such square, return to the original spot and climb out of
the cave.

Function HYBRID-WUMPUS_AGENT(percept) returns an action


Inputs: percept, a list, [stench, breeze, glitter, bump, scream]
Persisten: KB, a knowledge base, initially the atemporal “wumpus physics” t, a counter, initially 0,
indicating time plan, an action sequence, initially empty
TELL(KB, MAKE-PERCEPT-SENTENCE(percept, t))
TELL the KB the temporal “physics” sentences for time t

Safe

t
If ASK(KB, Glitter )=true then

If plan is empty then


If plan is empty and ASK(KB, HaveArro then
Possible_wumpus
Plan
If plan is empty then //no choice but to take a risk

Plan PLAN-ROUTE(current, unvisited ∩ not-unsafe, safe)


If plan is empty then

Plan PLAN-ROUTE(current, {[1,1]}, safe) +[Climb]


Action
TELL(KB, MAKE-ACTION-SENTENCE(action, t))

Return action
Function PLAN_ROUTE(current, goals, allowed) returns an action sequence
Inputs: currents, the agent’s current position
Goals, a set of squares; try to plan a route to one of them
Allowed, a set of squares that can form part of the route

Problem ROUTE-PROBLEM (current, goals, allowed) (problem)


Return - GRAPH-SEARCH (problem)

This is the hybrid agent program for the wumpus world.

Weakness: The computational expense goes up as time goes by.

3. Logical state estimation


To maintain a consistent update time, we must cache the inference result.
Belief state: Some representation of the set of all current world states that could exist. (used to
replace the previous history of percepts and all of its repercussions.)

The proposition symbols linked with the current time step and the temporal symbols are used in a
logical phrase.
Maintaining a logical statement that represents the set of probable states consistent with the
observation history is required for logical state estimation. Each update step necessitates inference
using the environment's transition model, which is comprised of successor-state axioms that define
how each fluent changes.
State estimation: The process of updating one's belief state as new information becomes available.
Exact state estimation may necessitate logical formulations with exponentially increasing symbol
counts.
One typical method for approximating state estimation is to characterise belief states as literal
conjunctions (1-CNF formulas).
Given the belief state at t-1, the agent simply tries to prove Xt and Xt for each symbol Xt.
The new belief state is formed by the conjunction of verifiable literals, and the previous belief state
is discarded.
(As time passes, this scheme may lose some information.)
Given the whole percept history, the set of feasible states represented by the 1-CNF belief state
comprises all states that are in fact possible. The 1-CNF belief state serves as a conservative
approximation or outer envelope.

Fig 4: Depiction of 1-CNF belief state as a simply representable, conservative approximation to the
exact belief state.

4. Making plans by propositional inference


Instead of using A* search, we can develop plans using logical inference.
Basic idea:
1. Make a sentence that incorporates the following elements:
a) Init0: a set of statements about the initial state; b) Init1: a set of assertions about the initial state;
c) Init2:
b) Transition1,..., Transitiont: The successor-state axioms for all feasible actions at each time
interval up to a maximum time interval t;
c) Have Goldt Climbed Outt: The claim that the goal has been reached at time t.
2. Use a SAT solver to complete the sentence. The aim can be achieved if the solver discovers a
satisfying model; else, planning is impossible.
3. Assuming you've established a model, extract the variables that describe actions and set them to
true.
They constitute a strategy for achieving the objectives when taken together.
SAT solution, or identifying feasible models detailing future action sequences that meet the
objective, can be used to make decisions within a logical agent. This method only works in totally
visible or sensor-free environments.
SATPLAN: is an acronym for "propositional planning." (Cannot be used in an environment that is
just partially visible.
SATPLAN looks for models in a sentence that includes the beginning state, aim, successor-state
axioms, and action exclusion axioms.
(Because the agent has no idea how many steps it will take to attain the goal, the algorithm tries
every number of steps t up to some maximum plausible plan length Tmax.)
Function SATPLAN(init, transition, goal, returns solution or failure
Inputs: init, transition, goal, constitute a description of the problem
an upper limit for plan length
For t=0 to do

Cnf TRANSLATE-TO-SAT(init, transition, goat, t)

Model SAT-SOLVER(cnf)
If model is null then
Return EXTRACT-SOLUTION(model)
Return failure

This is the SATPlan algorithm.

Precondition axioms: added to avoid creating plans containing illegal actions, saying that an action
occurrence requires the preconditions to be satisfied.
Action exclusion axioms were included to prevent the formation of plans that had many
simultaneous activities that interfered with one another.
Because it lacks the expressive power to deal concisely with time, space, and universal patterns of
relationships among things, propositional logic does not scale to unbounded settings.

Q9) Describe first order logic?


A9) In the topic of Propositional logic, we have seen how to represent statements using
propositional logic. But unfortunately, in propositional logic, we can only represent the facts, which
are either true or false. PL is not sufficient to represent complex sentences or natural language
statements. The propositional logic has very limited expressive power. Consider the following
sentence, which we cannot represent using PL logic.
● "Some humans are intelligent", or
● "Sachin likes cricket."

To represent the above statements, PL logic is not sufficient, so we required some more powerful
logic, such as first-order logic.
First-Order logic:
● First-order logic is another way of knowledge representation in artificial intelligence. It is an
extension to propositional logic.
● FOL is sufficiently expressive to represent the natural language statements in a concise way.
● First-order logic is also known as Predicate logic or First-order predicate logic. First-order logic
is a powerful language that develops information about the objects in a more easy way and can also
express the relationship between those objects.
● First-order logic (like natural language) does not only assume that the world contains facts like
propositional logic but also assumes the following things in the world:
• Objects: A, B, people, numbers, colors, wars, theories, squares, pits, wumpus, ......
• Relations: It can be unary relation such as: red, round, is adjacent, or n-any relation such
as: the sister of, brother of, has color, comes between
• Function: Father of, best friend, third inning of, end of, ......
● As a natural language, first-order logic also has two main parts:
• Syntax
• Semantics

Syntax of First-Order logic:


The syntax of FOL determines which collection of symbols is a logical expression in first-order
logic. The basic syntactic elements of first-order logic are symbols. We write statements in short-
hand notation in FOL.

Basic Elements of First-order logic:


Following are the basic elements of FOL syntax:
Constant 1, 2, A, John, Mumbai, cat,....
Variables x, y, z, a, b,....
Predicates Brother, Father, >,....
Function Sqrt, LeftLegOf, ....
Connectives ∧, ∨, ¬, ⇒, ⇔
Equality ==
Quantifier ∀, ∃

Atomic sentences:
● Atomic sentences are the most basic sentences of first-order logic. These sentences are formed
from a predicate symbol followed by a parenthesis with a sequence of terms.
● We can represent atomic sentences as Predicate (term1, term2, ......, term n).
Example: Ravi and Ajay are brothers: => Brothers(Ravi, Ajay).
Chinky is a cat: => cat (Chinky).

Complex Sentences:
● Complex sentences are made by combining atomic sentences using connectives.

First-order logic statements can be divided into two parts:


● Subject: Subject is the main part of the statement.
● Predicate: A predicate can be defined as a relation, which binds two atoms together in a
statement.

Consider the statement: "x is an integer.", it consists of two parts, the first part x is the subject of
the statement and second part "is an integer," is known as a predicate.

Properties of Quantifiers:
● In universal quantifier, ∀x∀y is similar to ∀y ∀x.
● In Existential quantifier, ∃x∃y is similar to ∃y ∃x.
● ∃x∀y is not similar to ∀y∃x.

Q10) Write about quantifier in first order logic?


A10) Quantifiers in First-order logic:
● A quantifier is a language element which generates quantification, and quantification specifies
the quantity of specimen in the universe of discourse.
● These are the symbols that permit to determine or identify the range and scope of the variable in
the logical expression. There are two types of quantifier:
1. Universal Quantifier, (for all, everyone, everything)
2. Existential quantifier, (for some, at least one).

Universal Quantifier:
Universal quantifier is a symbol of logical representation, which specifies that the statement within
its range is true for everything or every instance of a particular thing.
The Universal quantifier is represented by a symbol ∀, which resembles an inverted A.
Note: In universal quantifier we use implication "→".
If x is a variable, then ∀x is read as:
● For all x
● For each x
● For every x.

Example:
All man drink coffee.
Let a variable x which refers to a cat so all x can be represented in UOD as below:
∀x man(x) → drink (x, coffee).
It will be read as: There are all x where x is a man who drink coffee.

Existential Quantifier:
Existential quantifiers are the type of quantifiers, which express that the statement within its scope
is true for at least one instance of something.
It is denoted by the logical operator ∃, which resembles as inverted E. When it is used with a
predicate variable then it is called as an existential quantifier.
Note: In Existential quantifier we always use AND or Conjunction symbol ( ∧).
If x is a variable, then existential quantifier will be ∃x or ∃(x). And it will be read as:
● There exists a 'x.'
● For some 'x.'
● For at least one 'x.'

Example:
Some boys are intelligent.

∃x: boys(x) ∧ intelligent(x)


It will be read as: There are some x where x is a boy who is intelligent.

Points to remember:
● The main connective for universal quantifier ∀ is implication →.
● The main connective for existential quantifier ∃ is and ∧.

Q11) Write some example of FOl using quantifier?


A11) Some Examples of FOL using quantifier:
1. All birds fly.
In this question the predicate is "fly(bird)."
And since there are all birds who fly so it will be represented as follows.
∀x bird(x) →fly(x).

2. Every man respects his parent.


In this question, the predicate is "respect(x, y)," where x=man, and y= parent.
Since there is every man so will use ∀, and it will be represented as follows:
∀x man(x) → respects (x, parent).

3. Some boys play cricket.


In this question, the predicate is "play(x, y)," where x= boys, and y= game. Since
There are some boys so we will use ∃, and it will be represented as:
∃x boys(x) → play(x, cricket).

4. Not all students like both Mathematics and Science.


In this question, the predicate is "like(x, y)," where x= student, and y= subject.
Since there are not all students, so we will use ∀ with negation, so following representation for this:
¬∀ (x) [ student(x) → like(x, Mathematics) ∧ like(x, Science)].

5. Only one student failed in Mathematics.


In this question, the predicate is "failed(x, y)," where x= student, and y= subject.
Since there is only one student who failed in Mathematics, so we will use following representation
for this:
∃(x) [ student(x) → failed (x, Mathematics) ∧∀ (y) [¬(x==y) ∧ student(y) → ¬failed (x,
Mathematics)].

Free and Bound Variables:


The quantifiers interact with variables which appear in a suitable way. There are two types of
variables in First-order logic which are given below:
Free Variable: A variable is said to be a free variable in a formula if it occurs outside the scope of
the quantifier.
Example: ∀x ∃(y)[P (x, y, z)], where z is a free variable.
Bound Variable: A variable is said to be a bound variable in a formula if it occurs within the scope
of the quantifier.
Example: ∀x [A (x) B( y)], here x and y are the bound variables.

Q12) What do you mean by representation revisited?


A12) Programming languages (such as C++, Java, and Lisp) are by far the most widely used formal
languages.
This procedural method contrasts with propositional logic's declarative character, in which
knowledge and inference are separated and inference is domain-independent.
They lack the expressiveness required to deal with incomplete data.
● Using disjunction and negation, propositional logic has enough expressive capability to deal with
partial knowledge.
● Compositionality is a third characteristic of propositional logic that is useful in representation
languages.

The meaning of a sentence in a compositional language is determined by the meaning of its


constituent elements.
For example, ―S1,4 ^ S1,2‖ is related to the meanings of ―S1,4 ‖ and ―S1,2 ‖.

Propositional logic lacks the expressive power to succinctly explain a complex environment with
numerous items.
For example, we were compelled to establish a distinct regulation for each square regarding
breezes and pits, such as
B 1,1⇔(P 1,2 or P 2,1)

In English, though, it seems simple enough to state unequivocally that squares near to pits are airy.
Natural languages are also non-compositional, in the sense that the meaning of a statement like
"Then she saw it" might be influenced by the context created by numerous preceding and following
sentences.
Finally, natural languages contain ambiguity, which can make thinking harder.

The following are the most obvious features of natural language syntax:
● Object-referential nouns and noun phrases ( squares , pits, wumpuses ).
● Verbs and verb phrases that allude to object relationships (is breezy, is adjacent to, shoots).
● Some of these relationships are functions, meaning they have only one value for each input. It's
simple to start a list of objects, relations, and functions:

Objects: People, houses, numbers, theories, Ronald McDonald, colors, baseball games, wars,
centuries….
Relation: These can be unary relations or properties like red, round, bogus, prime, multi-
storied............, or more general n-ary relations like brother of, bigger than, within, part of, has
colour, happened after, owns, comes between, etc.
Functions: father of, closest friend, third inning of, more than, and the start of.
● The first-order logic language has a syntax and semantics based on objects and relations.
● First-order logic can also be used to convey facts about some or all of the universe's items.
● This allows generic laws or norms to be represented, such as the sentence "Squares adjacent to
the Wumpus are stinky."

The ontological commitment made by each language—that is, what it assumes about the nature of
reality—is the basic difference between propositional and first-order logic.
● Propositional logic, for example, assumes that there are facts in the world that either hold or do
not hold. There are two possible states for each fact: true or untrue.
● Temporal logic assumes that facts are true at specific moments and that those times (which can
be points or intervals) are in chronological sequence.

Higher-order logic considers the first-order logic's relations and functions to be objects in and of
themselves. This enables claims to be made about all object relations. A talent for dealing with
logical notation is required of an AI student.

Table 9: Formal language and their ontological and epistemological commitments

Q13) Explain the syntax of first order logic?


A13) First-order logic is a type of knowledge representation used in artificial intelligence. It's a
propositional logic variation.
• FOL is expressive enough to convey natural language statements in a concise manner.
• First-order logic is sometimes known as predicate logic or first-order predicate logic.
First-order logic is a complex language for constructing information about objects and
expressing relationships between them.
• First-order logic (as does natural language) assumes not just that the world contains facts,
as propositional logic does, but also that the world has the following:
○ Objects: People, numbers, colors, conflicts, theories, squares, pits, wumpus,
○ Relation: It can be a unary relation like red, round, or nearby, or an n-any relation like sister
of, brother of, has color, or comes between.
○ Functions: Father of, best friend, third inning of, last inning of......
• First-order logic contains two basic pieces as a natural language:
○ Syntax
○ Semantics

Syntax
Syntax has to do with what ‘things’ (symbols, notations) one is allowed to use in the language and
in what way; there is/are a(n):
● Alphabet
● Language constructs
● Sentences to assert knowledge

Logical connectives (⇒, ∧, ∨, and ⇐⇒), negation (¬), and parentheses. These will be used to
recursively build complex formulas, just as was done for propositional logic.
Constants symbols are strings that will be interpreted as representing objects, e.g., Bob might be a
constant.
Variable symbols will be used as “place holders” for quantifying over objects.
Predicate symbols Each has an arity (number of arguments) associated with it, which can be zero
or some other finite value. Predicates will be used to represent object characteristics and
relationships.
Zero-arity Because predicate symbols are viewed as propositions in first-order logic, propositional
logic is subsumed. These assertions can be thought of as world properties.
Predicates with a single parameter can be thought of as specifying object attributes. If Rich is a
single-arity predicate, then Rich (Bob) is used to indicate that Bob is wealthy. Multi-arity
predicates are used to describe relationships between items.

Formula PrimitiveFormula
| (Formula Connective Formula)
| Sentence
| Qualifier Variable Formula
PrimitiveFormula Predicate(Term,…,Term)
Term Function(Term,…,Term)
| Constant
| Variable
Connectifier
Quantifier
Constant any string that is not used as a variable predicate or function
Variable any string that is not used as a constant predicate or function
Predicate any string that is not used as a constant variable or function
Function any string that is not used as a constant predicate or constant
Function symbols Each has a specific arity (number of input arguments) and is understood as a
function that maps the stated number of input objects to objects. Allowing FatherOf to be a single-
arity function symbol, the natural interpretation of FatherOf (Bob) is Bob's father.
Zero-arity function symbols are considered to be constants.

Universal and existential quantifier symbols will be used to quantify over objects. For example,
∀ x Alive(x) ⇒ Breathing(x) is a universally quantified statement that uses the variable x as a
placeholder.

Q14) What is the semantics of first order logic?


A14) Semantics of First-Order Logic
As with all logics, the first step in determining the semantics of first-order logic is to define the
models of first-order logic. Remember that one of the benefits of using first-order logic is that it
allows us to freely discuss objects and their relationships. As a result, our models will comprise
objects as well as information about their properties and interactions with other items.

First order model


A first-order model is a tuple hD, Ii, where D denotes a non-empty object domain and I denote an
interpretation function. D is nothing more than a collection of items or elements that can be finite,
infinite, or uncountable. The interpretation function I gives each of the available constant, function,
and predicate symbols a meaning or interpretation as follows:
• If c is a constant symbol, then I(c) is an object in D. Thus, given a model, a constant can
be viewed as naming an object in the domain.
• If f is a function symbol of arity n, then I(f) is a total function from Dn to D. That is the
interpretation of f is a function that maps n domain objects to the domain D.
• If p is a predicate symbol of arity n > 0, then I(p) is a subset of Dn; that is, a predicate

1 n
symbol is interpreted as a set of tuples from the domain. If a tuple O = (o , · · · , o ) is in
I(p) then we say that p is true for the object tuple O.
• If p is a predicate symbol of arity 0, i.e., a simple proposition, then I(p) is equal to either
true or false.

Assume we have a single predicate TallerThan, a single function FatherOf, and a single constant
Bob. The following could be a model M1 for these symbols:
D = {BOB, JON, NULL}
I(Bob) = BOB
I(TallerThan) = {hBOB, JONi}
Because I(FatherOf) is a function, we'll only show the value for each argument to give the FatherOf
meaning.
I(FatherOf)(BOB) = JON
I(FatherOf)(JON) = NULL
I(FatherOf)(NULL) = NULL
M2 could also be interpreted as follows,
D = { BOB, JON }
I(Bob) = BOB
I(TallerThan) = { hBOB, JONi,hJON, BOBi }
I(FatherOf)(BOB) = BOB
I(FatherOf)(JON) = JON
It's vital to highlight the difference between Bob, which is a constant (a syntactic entity), and BOB,
which is a domain object (a semantic entity). The second interpretation isn't exactly what we're
looking for (the objects are dads of themselves, and TallerThan is inconsistent), but it's still a viable
model. By imposing proper limitations on the symbols, the knowledge base can rule out such
unexpected models from consideration.

Q15) Describe knowledge engineering in first order logic?


A15) Inference is used in First-Order Logic to generate new facts or sentences from current ones.
It's crucial to understand some basic FOL terms before diving into the FOL inference rule.
Substitution:
Substitution is a fundamental approach for modifying phrases and formulations. All first-order
logic inference systems contain it. The substitution becomes more difficult when there are
quantifiers in FOL. We refer to the replacement of a constant "a" for the variable "x" when we
write F[a/x].

Equality:
Atomic sentences are generated in First-Order Logic not only through the employment of predicate
and words, but also through the application of equality. We can do this by using equality symbols,
which indicate that the two terms relate to the same thing.

FOL inference rules for quantifier:


Because inference rules in first-order logic are comparable to those in propositional logic, below
are some basic inference rules in FOL:
● Universal Generalization
● Universal Instantiation
● Existential Instantiation
● Existential introduction

Universal Generalization:
• Universal generalization is a valid inference rule that states that if premise P(c) is true for
any arbitrary element c in the universe of discourse, we can arrive at the conclusion x P.
(x).

• It can be represented as:


• If we want to prove that every element has a similar property, we can apply this rule.
• x must not be used as a free variable in this rule.
Example: Let's represent, P(c): "A byte contains 8 bits", so for ∀ x P(x) "All bytes contain 8
bits.", it will also be true.

Universal Instantiation:
• Universal instantiation, often known as universal elimination or UI, is a valid inference
rule. It can be used numerous times to add more sentences.
• The new knowledge base is logically equivalent to the previous one.
• We can infer any phrase by replacing a ground word for the variable, according to the UI.
• According to the UI rule, any phrase P(c) can be inferred by substituting a ground term c
(a constant inside domain x) for any object in the universe of discourse in x P(x).

• It can be represented as:


Example: IF "Every person like ice-cream"=> ∀x P(x) so we can infer that
"John likes ice-cream" => P(c)

Existential Instantiation:
• Existential Elimination, also known as Existential Instantiation, is a valid first-order logic
inference rule.
• It can only be used once to substitute for the existential sentence.
• Despite the fact that the new KB is not conceptually identical to the previous KB, it will
suffice if the old KB was.
• This rule states that one can infer P(c) from the formula given in the form of ∃x P(x) for a
new constant symbol c.
• The only constraint with this rule is that c must be a new word for which P(c) is true.

• It can be represented as:

Existential introduction
• An existential generalization, also known as an existential introduction, is a valid
inference rule in first-order logic.
• If some element c in the world of discourse has the characteristic P, we can infer that
something else in the universe has the attribute P, according to this rule.

• It can be represented as:


Example: Let's say that,
"Pritisha got good marks in English."
"Therefore, someone got good marks in English."

Propositional vs. First-Order Inference


Previously, inference in first order logic was checked via propositionalization, which is the act of
turning the Knowledge Base included in first order logic into propositional logic and then utilizing
any of the propositional logic inference mechanisms to check inference.

Q16) Write the difference between propositional logic and first order logic?
A16) Key differences between PL and FOL
● Propositional Logic converts a complete sentence into a symbol and makes it logical whereas in
First-Order Logic relation of a particular sentence will be made that involves relations, constants,
functions, and constants.
● The limitation of PL is that it does not represent any individual entities whereas FOL can easily
represent the individual establishment that means if you are writing a single sentence then it can be
easily represented in FOL.
● PL does not signify or express the generalization, specialization or pattern for example
‘QUANTIFIERS’ cannot be used in PL but in FOL users can easily use quantifiers as it does
express the generalization, specialization, and pattern.

Q17) Write the difference between propositional logic and predicate logic?
A17) Difference between propositional logic and predicate logic
Unit - 5
Reasoning
Q1) What do you mean by inference in first order logic?
A1) Inference in First-Order Logic is used to deduce new facts or sentences from existing
sentences. Before understanding the FOL inference rule, let's understand some basic terminologies
used in FOL.
Substitution:
Substitution is a fundamental operation performed on terms and formulas. It occurs in all inference
systems in first-order logic. The substitution is complex in the presence of quantifiers in FOL. If
we write F[a/x], so it refers to substitute a constant "a" in place of variable "x".
Note: First-order logic is capable of expressing facts about some or all objects in the universe.

Equality:
First-Order logic does not only use predicate and terms for making atomic sentences but also uses
another way, which is equality in FOL. For this, we can use equality symbols which specify that
the two terms refer to the same object.
Example: Brother (John) = Smith.
As in the above example, the object referred by the Brother (John) is similar to the object referred
by Smith. The equality symbol can also be used with negation to represent that two terms are not
the same objects.
Example: ¬(x=y) which is equivalent to x ≠y.

FOL inference rules for quantifier:


As propositional logic we also have inference rules in first-order logic, so following are some basic
inference rules in FOL:
● Universal Generalization
● Universal Instantiation
● Existential Instantiation
● Existential introduction

1. Universal Generalization:
● Universal generalization is a valid inference rule which states that if premise P(c) is true for any
arbitrary element c in the universe of discourse, then we can have a conclusion as ∀ x P(x).

● It can be represented as:


● This rule can be used if we want to show that every element has a similar property.
● In this rule, x must not appear as a free variable.
Example: Let's represent, P(c): "A byte contains 8 bits", so for ∀ x P(x) "All bytes contain 8 bits.",
it will also be true.

2. Universal Instantiation:
● Universal instantiation is also called as universal elimination or UI is a valid inference rule. It
can be applied multiple times to add new sentences.
● The new KB is logically equivalent to the previous KB.
● As per UI, we can infer any sentence obtained by substituting a ground term for the variable.
● The UI rule state that we can infer any sentence P(c) by substituting a ground term c (a constant
within domain x) from ∀ x P(x) for any object in the universe of discourse.

● It can be represented as: .


Example:1.
IF "Every person like ice-cream"=> ∀x P(x) so we can infer that
"John likes ice-cream" => P(c)

Example: 2.
Let's take a famous example,
"All kings who are greedy are Evil." So let our knowledge base contains this detail as in the form
of FOL:
∀x king(x) ∧ greedy (x) → Evil (x),
So from this information, we can infer any of the following statements using

Universal Instantiation:
● King(John) ∧ Greedy (John) → Evil (John),
● King(Richard) ∧ Greedy (Richard) → Evil (Richard),
● King(Father(John)) ∧ Greedy (Father(John)) → Evil (Father(John)),

3. Existential Instantiation:
● Existential instantiation is also called as Existential Elimination, which is a valid inference rule
in first-order logic.
● It can be applied only once to replace the existential sentence.
● The new KB is not logically equivalent to old KB, but it will be satisfiable if old KB was
satisfiable.
● This rule states that one can infer P(c) from the formula given in the form of ∃x P(x) for a new
constant symbol c.
● The restriction with this rule is that c used in the rule must be a new term for which P(c ) is true.

● It can be represented as:

Example:
From the given sentence: ∃x Crown(x) ∧ OnHead(x, John),
So we can infer: Crown(K) ∧ OnHead( K, John), as long as K does not appear in the knowledge
base.
● The above used K is a constant symbol, which is called Skolem constant.
● The Existential instantiation is a special case of Skolemization process.
4. Existential introduction
● An existential introduction is also known as an existential generalization, which is a valid
inference rule in first-order logic.
● This rule states that if there is some element c in the universe of discourse which has a property
P, then we can infer that there exists something in the universe which has the property P.

● It can be represented as:


● Example: Let's say that,
"Priyanka got good marks in English."
"Therefore, someone got good marks in English."

Q2) Compare propositional and first order logic?


A2) Propositional vs. First-Order Inference
Previously, inference in first order logic was checked via propositionalization, which is the act of
turning the Knowledge Base included in first order logic into propositional logic and then utilizing
any of the propositional logic inference mechanisms to check inference.

Inference rules for quantifiers:


To get sentences without quantifiers, several inference techniques can be applied to sentences
containing quantifiers. We'll be able to make the conversion if we follow these requirements.

Universal Instantiation (UI):


The rule states that by substituting a ground word (a term without variables) for the variable, we
can deduce any sentence. Let SUBST () stand for the outcome of the substitution on the sentence a.
The rule is then written.

For any v and g ground term combinations. For example, in the knowledge base, there is a
statement that states that all greedy rulers are Evil.

For the variable x, with the substitutions like {x/John}, {x/Richard} the following sentences can be
inferred

As a result, the set of all potential instantiations can be used to substitute a globally quantified
phrase.

Existential Instantiation (EI):


The existential statement states that there is some object that fulfills a requirement, and that the
instantiation process is simply giving that object a name that does not already belong to another
object. A Skolem constant is the moniker given to this new name. Existential Instantiation is a
subset of a broader process known as "skolemization."
If the statement a, variable v, and constant symbol k do not occur anywhere else in the knowledge
base,

For example, from the sentence

So we can infer the sentence

As long as C1 does not appear elsewhere in the knowledge base. Thus, an existentially quantified
sentence can be replaced by one instantiation
Elimination of Universal and Existential quantifiers should give new knowledge base which can be
shown to be inferentially equivalent to old in the sense that it is satisfiable exactly when the
original knowledge base is satisfiable.

Q3) Explain unification?


A3) Unification is the process of finding a substitute that makes two separate logical atomic
expressions identical. The substitution process is necessary for unification.
• It accepts two literals as input and uses substitution to make them identical.

• 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 both phrases will be identical after this
replacement.
• For unification, the UNIFY algorithm is employed, which takes two atomic statements and
returns a unifier for each of them (If any exist).
• All first-order inference techniques rely heavily on unification.
• If the expressions do not match, the result is failure.
• The replacement variables are referred to as MGU (Most General Unifier).

Example: Let's say there are two different expressions, P (x, y), and P (a, f(z)).
In this example, we need to make both above statements identical to each other. For this, we 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:


The following are some fundamental requirements for unification:
• Atoms or expressions with various predicate symbols can never be united since they have
different predicate symbols.
• Both phrases must have the same number of arguments.
• If two comparable variables appear in the same expression, unification will fail.

Generalized Modus Ponens:


For atomic sentences pi, pi ', and q, where there is a substitution θ such that SU θ, pi) = SUBST (θ,
pi '), for all i

N + 1 premises = N atomic sentences + one implication. Applying SUBST (θ, q) yields the
conclusion we seek.
p1’ = King (John) p2’ = Greedy(y)
p1 = King(x) p2 = Greedy(x)
θ = {x / John, y/ John} q = Evil(x)
SUBST (θ, q) is Evil (John)

Generalized Modus Ponens = lifted Modus Ponens


Lifted - transformed from:
Propositional Logic → First-order Logic

Unification Algorithms
Algorithm: Unify (L1, L2)
1. If L1 or L2 are both variables or constants, then:
1. If L1 and L2 are identical, then return NIL.
2. Else if L1 is a variable, then if L1 occurs in L2 then return {FAIL}, else return (L2/L1).
3. Also, Else if L2 is a variable, then if L2 occurs in L1 then return {FAIL}, else return (L1/L2). d.
Else return {FAIL}.
2. If the initial predicate symbols in L1 and L2 are not identical, then return {FAIL}.
3. If LI and L2 have a different number of arguments, then return {FAIL}.
4. Set SUBST to NIL. (At the end of this procedure, SUBST will contain all the substitutions used
to unify L1 and L2.)
5. For I ← 1 to the number of arguments in L1:
1. Call Unify with the ith argument of L1 and the ith argument of L2, putting the result in S.
2. If S contains FAIL, then return {FAIL}.
3. If S is not equal to NIL, then:
2. Apply S to the remainder of both L1 and L2.
3. SUBST: = APPEND (S, SUBST).
6. Return SUBST.

Q4) Define first order inferences?


A4) Inference in first order logic was checked via propositionalization, which is the act of turning
the Knowledge Base included in first order logic into propositional logic and then utilizing any of
the propositional logic inference mechanisms to check inference.
Inference rules for quantifiers:
To get sentences without quantifiers, several inference techniques can be applied to sentences
containing quantifiers. We'll be able to make the conversion if we follow these requirements.

Universal Instantiation (UI):


The rule states that by substituting a ground word (a term without variables) for the variable, we
can deduce any sentence. Let SUBST () stand for the outcome of the substitution on the sentence a.
The rule is then written.

For any v and g ground term combinations. For example, in the knowledge base, there is a
statement that states that all greedy rulers are Evil.

For the variable x, with the substitutions like {x/John},{x/Richard}the following sentences can be
inferred

As a result, the set of all potential instantiations can be used to substitute a globally quantified
phrase.

Existential Instantiation (EI):


The existential statement states that there is some object that fulfills a requirement, and that the
instantiation process is simply giving that object a name that does not already belong to another
object. A Skolem constant is the moniker given to this new name. Existential Instantiation is a
subset of a broader process known as "skolemization."
If the statement a, variable v, and constant symbol k do not occur anywhere else in the knowledge
base,

For example, from the sentence

So we can infer the sentence

As long as C1 does not appear elsewhere in the knowledge base. Thus an existentially quantified
sentence can be replaced by one instantiation
Elimination of Universal and Existential quantifiers should give new knowledge base which can be
shown to be inferentially equivalent to old in the sense that it is satisfiable exactly when the
original knowledge base is satisfiable.

Q5) Define forward chaining?


A5) Forward chaining is also known as forward deduction or forward reasoning when using an
inference engine. Forward chaining is a method of reasoning that begins with atomic sentences in a
knowledge base and uses inference rules to extract more information in the forward direction until
a goal is reached.
Beginning with known facts, the Forward-chaining algorithm activates all rules with satisfied
premises and adds their conclusion to the known facts. This procedure is repeated until the problem
is resolved.
It's a method of inference that starts with sentences in the knowledge base and generates new
conclusions that may then be utilized to construct subsequent inferences. It's a plan based on data.
We start with known facts and organize or chain them to get to the query. The ponens modus
operandi is used. It begins with the data that is already accessible and then uses inference rules to
extract new data until the goal is achieved.

Example: To determine the color of Fritz, a pet who croaks and eats flies, for example. The
Knowledge Base contains the following rules:
If X croaks and eats flies — → Then X is a frog.
If X sings — → Then X is a bird.
If X is a frog — → Then X is green.
If x is a bird — -> Then X is blue.
In the KB, croaks and eating insects are found. As a result, we arrive at rule 1, which has an
antecedent that matches our facts. The KB is updated to reflect the outcome of rule 1, which is that
X is a frog. The KB is reviewed again, and rule 3 is chosen because its antecedent (X is a frog)
corresponds to our newly confirmed evidence. The new result is then recorded in the knowledge
base (i.e., X is green). As a result, we were able to determine the pet's color based on the fact that it
croaks and eats flies.

Properties of forward chaining


• It is a down-up approach since it moves from bottom to top.
• It is a process for reaching a conclusion based on existing facts or data by beginning at the
beginning and working one's way to the end.
• Because it helps us to achieve our goal by exploiting current data, forward-chaining is also
known as data-driven.
• The forward-chaining methodology is often used in expert systems, such as CLIPS,
business, and production rule systems.

Q6) Write the property of forward chaining?


A6) Properties of forward chaining
• It is a down-up approach since it moves from bottom to top.
• It is a process for reaching a conclusion based on existing facts or data by beginning at the
beginning and working one's way to the end.
• Because it helps us to achieve our goal by exploiting current data, forward-chaining is also
known as data-driven.
• The forward-chaining methodology is often used in expert systems, such as CLIPS,
business, and production rule systems.

Q7) Describe backward chaining?


A7) Backward-chaining is also known as backward deduction or backward reasoning when using
an inference engine. A backward chaining algorithm is a style of reasoning that starts with the goal
and works backwards through rules to find facts that support it.
It's an inference approach that starts with the goal. We look for implication phrases that will help us
reach a conclusion and justify its premises. It is an approach for proving theorems that is goal-
oriented.

Example: Fritz, a pet that croaks and eats flies, needs his color determined. The Knowledge Base
contains the following rules:
If X croaks and eats flies — → Then X is a frog.
If X sings — → Then X is a bird.
If X is a frog — → Then X is green.
If x is a bird — -> Then X is blue.
The third and fourth rules were chosen because they best fit our goal of determining the color of
the pet. For example, X may be green or blue. Both the antecedents of the rules, X is a frog and X
is a bird, are added to the target list. The first two rules were chosen because their implications
correlate to the newly added goals, namely, X is a frog or X is a bird.
Because the antecedent (If X croaks and eats flies) is true/given, we can derive that Fritz is a frog.
If it's a frog, Fritz is green, and if it's a bird, Fritz is blue, completing the goal of determining the
pet's color.

Q8) Write the property of backward chaining?


A8) Properties of backward chaining
• A top-down strategy is what it's called.
• Backward-chaining employs the modus ponens inference rule.
• In backward chaining, the goal is broken down into sub-goals or sub-goals to ensure that
the facts are true.
• Because a list of objectives decides which rules are chosen and implemented, it's known as
a goal-driven strategy.
• The backward-chaining approach is utilized in game theory, automated theorem proving
tools, inference engines, proof assistants, and other AI applications.
• The backward-chaining method relied heavily on a depth-first search strategy for proof.
Q9) Describe a resolution?
A9) 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 we 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.
Conjunctive Normal Form: A sentence represented as a conjunction of clauses is said to be
conjunctive normal form or CNF.

The resolution inference rule:


The resolution rule for first-order logic is simply a lifted version of the propositional rule.
Resolution can resolve two clauses if they contain complementary literals, which are assumed to be
standardized apart so that they share no variables.

Where li and mj are complementary literals.


This rule is also called the binary resolution rule because it only resolves exactly two literals.

Example:
We can resolve two clauses which are given below:
[Animal (g(x) V Loves (f(x), x)] and [¬ Loves(a, b) V ¬Kills(a, b)]
Where two complimentary literals are: Loves (f(x), x) and ¬ Loves (a, b)
These literals can be unified with unifier θ= [a/f(x), and b/x], and it will generate a resolvent
clause:
[Animal (g(x) V ¬ Kills(f(x), x)].

Steps for Resolution:


1. Conversion of facts into first-order logic.
2. Convert FOL statements into CNF
3. Negate the statement which needs to prove (proof by contradiction)
4. Draw resolution graph (unification).

To better understand all the above steps, we will take an example in which we will apply
resolution.
Example:
John likes all kind of food.
Apple and vegetable are food
Anything anyone eats and not killed is food.
Anil eats peanuts and still alive
1. Harry eats everything that Anil eats.
Prove by resolution that:
John likes peanuts.

Step-1: Conversion of Facts into FOL


In the first step we will convert all the given statements into its first order logic.
a.
b.
c.
d.
e.
f.
g.
h.
Here f and g are added predicates.

Step-2: Conversion of FOL into CNF


In First order logic resolution, it is required to convert the FOL into CNF as CNF form makes
easier for resolution proofs.
Eliminate all implication (→) and rewrite
1. ∀x ¬ food(x) V likes(John, x)
2. Food(Apple) Λ food(vegetables)
3. ∀x ∀y ¬ [eats(x, y) Λ¬ killed(x)] V food(y)
4. Eats (Anil, Peanuts) Λ alive(Anil)
5. ∀x ¬ eats(Anil, x) V eats(Harry, x)
6. ∀x¬ [¬ killed(x) ] V alive(x)
7. ∀x ¬ alive(x) V ¬ killed(x)
8. Likes(John, Peanuts).

Move negation (¬)inwards and rewrite


9. ∀x ¬ food(x) V likes(John, x)
10. Food(Apple) Λ food(vegetables)
11. ∀x ∀y ¬ eats(x, y) V killed(x) V food(y)
12. Eats (Anil, Peanuts) Λ alive(Anil)
13. ∀x ¬ eats(Anil, x) V eats(Harry, x)
14. ∀x ¬killed(x) ] V alive(x)
15. ∀x ¬ alive(x) V ¬ killed(x)
16. Likes(John, Peanuts).

Rename variables or standardize variables


17. ∀x ¬ food(x) V likes(John, x)
18. Food(Apple) Λ food(vegetables)
19. ∀y ∀z ¬ eats(y, z) V killed(y) V food(z)
20. Eats (Anil, Peanuts) Λ alive(Anil)
21. ∀w¬ eats(Anil, w) V eats(Harry, w)
22. ∀g ¬killed(g) ] V alive(g)
23. ∀k ¬ alive(k) V ¬ killed(k)
24. Likes(John, Peanuts).

● Eliminate existential instantiation quantifier by elimination.


In this step, we will eliminate existential quantifier ∃, and this process is known as Skolemization.
But in this example problem since there is no existential quantifier so all the statements will remain
same in this step.
● Drop Universal quantifiers.
In this step we will drop all universal quantifier since all the statements are not implicitly
quantified so we don't need it.
1. ¬ food(x) V likes(John, x)
2. Food(Apple)
3. Food(vegetables)
4. ¬ eats(y, z) V killed(y) V food(z)
5. Eats (Anil, Peanuts)
6. Alive(Anil)
7. ¬ eats(Anil, w) V eats(Harry, w)
8. Killed(g) V alive(g)
9. ¬ alive(k) V ¬ killed(k)
10.Likes(John, Peanuts).

Note: Statements "food(Apple) Λ food(vegetables)" and "eats (Anil, Peanuts) Λ alive(Anil)"


can be written in two separate statements.
● Distribute conjunction ∧ over disjunction ¬.
This step will not make any change in this problem.

Step-3: Negate the statement to be proved


In this statement, we will apply negation to the conclusion statements, which will be written as
¬likes(John, Peanuts)

Step-4: Draw Resolution graph:


Now in this step, we will solve the problem by resolution tree using substitution. For the above
problem, it will be given as follows:
Hence the negation of the conclusion has been proved as a complete contradiction with the given
set of statements.

Explanation of Resolution graph:


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

Q10) What do you mean by knowledge representation?


A10) Humans are best at understanding, reasoning, and interpreting knowledge. Humans know
things, which is that of the knowledge and as per that of their knowledge they perform several of
the actions in that of the real world. But how machines do all of these things come under the
knowledge representation and the reasoning. Hence we can describe that of the Knowledge
representation as follows they are:
● Knowledge representation and the reasoning (KR, KRR) is the part of Artificial intelligence
which concerned with AI agents thinking and how thinking contributes to intelligent behavior of
agents.
● It is responsible for representing information about the real world so that a computer can
understand and then can utilize that of the knowledge to solve that of the complex real world
problems for instance diagnosis a medical condition or communicating with humans in natural
language.
● It is also a way which describes that how we can represent that of the knowledge in that of the
artificial intelligence. Knowledge representation is not just that of the storing data into some of the
database, but it also enables of an intelligent machine to learn from that of the knowledge and
experiences so that of the it can behave intelligently like that of a human.

What to Represent:
Following are the kind of knowledge which needs to be represented in that of the AI systems:
● Object: All the facts about that of the objects in our world domain. Example Guitars contains
strings, trumpets are brass instruments.
● Events: Events are the actions which occur in our world.
● Performance: It describes that of the behaviour which involves the knowledge about how to do
things.
● Meta-knowledge: It is knowledge about what we know.
● Facts: Facts are the truths about the real world and what we represent.
● Knowledge-Base: The central component of the knowledge-based agents is the knowledge
base. It is represented as KB. The Knowledgebase is a group of the Sentences (Here, sentences are
used as a technical term and not identical with the English language).

Knowledge: Knowledge is the awareness or familiarity gained by that of the experiences of facts,
data, and situations. Following are the types of knowledge in artificial intelligence:

The relation between knowledge and intelligence they are as follows:


Knowledge of real-worlds plays a very important role in the intelligence and the same for creating
the artificial intelligence. Knowledge plays an important role in that of the demonstrating
intelligent behavior in the AI agents. An agent is the only able to accurately act on some of the
input when he has some of the knowledge or the experience about that of the input.
Let's suppose if you met some of the person who is speaking in that of a language which you don't
know, then how you will able to act on that. The same thing applies to that of the intelligent
behavior of the agents.
As we can see in below diagram, there is one decision maker which act by sensing that of the
environment and using the knowledge. But if the knowledge part will not present then, it cannot
display intelligent behavior.
Q11) What are the types of knowledge?
A11) Types of knowledge
Following are the various types of knowledge:

1. Declarative Knowledge:
● Declarative knowledge is to know about something.
● It includes the concepts, the facts, and the objects.
● It is also called descriptive knowledge and expressed in declarative sentences.
● It is simpler than procedural language.

2. Procedural Knowledge
● It is also known as imperative knowledge.
● Procedural knowledge is a type of knowledge which is responsible for knowing how to do
something.
● It can be directly applied to any task.
● It includes rules, strategies, procedures, agendas, etc.
● Procedural knowledge depends on the task on which it can be applied.

3. Meta-knowledge:
● Knowledge about the other types of that of the knowledge is known as Meta-knowledge.

4. Heuristic knowledge:
● Heuristic knowledge is representing knowledge of some experts in a filed or subject.
● Heuristic knowledge is the rules of the thumb based on the previous experiences, awareness of
the approaches, and which are good to that of the work but not guaranteed.

5. Structural knowledge:
● Structural knowledge is basic knowledge to problem-solving.
● It describes relationships between various concepts such as kind of, part of, and grouping of
something.
● It describes the relationship that exists between concepts or objects.

Q12) How to approach knowledge representation?


A12) Approaches to knowledge representation:
There are mainly four approaches to knowledge representation, which are given below:
1. Simple relational knowledge:
● It is the simplest way of that of the storing facts which uses that of the relational method and
each fact about that of a set of the object is set out systematically in that of the columns.
● This approach of the knowledge representation is famous in the database systems where the
relationship between that of the different entities is represented.
● This approach has little opportunity for that of the inference.

Example: The following is the simple relational knowledge representation.


Player Weight Age
Player1 65 23
Player2 58 18
24
Player3 75

2.Inheritable knowledge:
● In the inheritable knowledge approach, all the data must be stored into that of a hierarchy of the
classes.
● All classes should be arranged in that of a generalized form or a hierarchal manner.
● In this approach, we apply the inheritance property.
● Elements inherit values from the other members of a class.
● This approach contains the inheritable knowledge which shows that of a relation between
instance and the class, and it is known as instance relation.
● Every individual frame can represent that of the collection of attributes and its value.
● In this approach, objects and the values are represented in the Boxed nodes.
● We use Arrows which point from that of the objects to their values.

Example:
3. Inferential knowledge:
● Inferential knowledge approach represents the knowledge in the form of the formal logics.
● This approach can be used to derive more that of the facts.
● It guaranteed the correctness.
● Example: Let's suppose there are two statements:
1. Marcus is a man
2. All men are mortal
Then it can represent as;
Man(Marcus)
∀x = man (x) ----------> mortal (x)s

4. Procedural knowledge:
● Procedural knowledge approach uses that of the small programs and codes which describes how
to do specific things, and how to proceed.
● In this approach, one important rule is used which is If-Then rule.
● In this knowledge, we can use various coding languages such as LISP language and Prolog
language.
● We can easily represent heuristic or domain-specific knowledge using this approach.
● But it is not necessary that we can represent all cases in this approach.

Requirements for knowledge Representation system:


A good knowledge representation system must possess the following properties.
1. Representational Accuracy:
KR system should have that of the ability to represent that the all kind of the required
knowledge.
2. Inferential Adequacy:
KR system should have ability to manipulate that of the representational structures to produce that
of the new knowledge corresponding to the existing structure.
3. Inferential Efficiency:
The ability to direct the inferential knowledge mechanism into the most productive directions by
storing appropriate guides.
4. Acquisitioned efficiency- The ability to acquire the new knowledge easily using automatic
methods.

Q13) What is AI knowledge cycle?


A13) AI knowledge cycle:
An Artificial intelligence system has that of the following components for displaying intelligent
behavior they are as follows:
● Perception
● Learning
● Knowledge Representation and Reasoning
● Planning
● Execution

The above diagram is showing how that of an AI system can interacts with that of the real world
and what the components help it to show the intelligence. AI system has the Perception component
by which it retrieves information from that of its environment. It can be visual, audio or another
form of the sensory input. The learning component is that the responsible for learning from data
captured by the Perception comportment.
In the complete cycle, the main components are the knowledge representation and the Reasoning.
These two components are involved in showing that of the intelligence in machine-like humans.
These two components are independent with each other but also coupled together. The planning
and execution depend on analysis of that of the Knowledge representation and the reasoning.

Q14) What do you mean by categories and objects?


A14) Categories and Objects
● Sorting the items into categories.
● At the level of categories, some reasoning takes happen.
● "I'd like to eat an apple," says the narrator.
● Member(x, Apple) and Subset(x, Apple) are Apple(x) and Member(x, Apple) respectively
(Apple, Food).
● The categories create a hierarchy, or simply a network, in which each class inherits the properties
of the parent (apples are both food and fruit).
● A taxonomy is made up of the categories of a class.

The organisation of items into categories is required by KR.


● Interaction at the object level;
● Reasoning at the category level

Categories play a role in predictions about objects


● Based on perceived properties

FOL can represent categories in two ways (First Order Logic)


● Predicates: apple(x)
● Reification of categories into objects: apples

Category = set of its members.


Category organization

Relation = inheritance:
● Food is edible in all forms; fruit is a subclass of food, and apples are a subclass of fruit, hence an
apple is edible.

Defines a taxonomy

FOL and categories


● An object is a member of a category
○ MemberOf(BB12,Basketballs)
● A category is a subclass of another category
○ SubsetOf(Basketballs,Balls)
● All members of a category have some properties
○ ∀x (MemberOf(x,Basketballs) ⇒Round(x))
● All members of a category can be recognized by some properties
○ ∀x (Orange(x) ∧Round(x) ∧Diameter(x) = 9.5in
∧MemberOf(x,Balls)⇒MemberOf(x,BasketBalls))
● A category as a whole has some properties
○ MemberOf(Dogs,DomesticatedSpecies)

Relations between categories


● If two or more categories have no members in common, they are disjoint:
○ Disjoint(s)⇔(∀c1,c2 c1 ∈s ∧c2 ∈s ∧c1 ≠ c2 ⇒Intersection(c1,c2) ={})
● Example: Disjoint({animals, vegetables})
● If all members of the set are covered by categories in s, a set of categories s represents an
exhaustive decomposition of a category c:
○ E.D.(s,c) ⇔(∀i i∈c ⇒∃c2 c2∈s ∧i ∈c2)
● Example: ExhaustiveDecomposition( {Americans, Canadian, Mexicans},
NorthAmericans).
● A partition is an exhaustive disjoint decomposition:
○ Partition(s,c) ⇔Disjoint(s) ∧E.D.(s,c)
● Example: Partition({Males,Females},Persons).
● Is ({Americans,Canadian, Mexicans},NorthAmericans) a partition?
● No! There might be dual citizenships.
● By defining membership criteria that are both necessary and sufficient, categories can be created.

Substances and Objects


The real universe is made up of primitive items (such as atomic particles) and composite objects
made up of them.
We can avoid the complexity of dealing with large numbers of primitive things separately by
reasoning at the level of large objects like apples and cars.
However, there is a large part of reality that appears to defy any clear individuation—division into
different objects.
b∈Butter ∧PartOf(p, b) ⇒p ∈Butter .
We may now say that butter melts at a temperature of roughly 30 degrees Celsius:
b∈Butter ⇒MeltingPoint(b,Centigrade(30))
What's going on is that some properties are intrinsic, meaning they pertain to the thing's very
substance rather than the object as a whole.
When you cut a piece of stuffin in half, the fundamental properties—such as density, boiling
temperature, flavor, color, ownership, and so on—remain intact.
Extrinsic qualities like as weight, length, and shape, on the other hand, are lost during subdivision.
Stuff is the most broad substance type, with no inherent qualities specified.
Thing is the most broad discrete object category, with no extrinsic attributes specified.

Q15) What are events?


A15) The usefulness of situation calculus is limited: it was created to represent a world in which
activities are discrete, instantaneous, and occur one at a time.
Consider filling a bathtub, which is a continual action. Situation calculus can claim that the tub is
empty before the action and filled after the action, but it can't describe what happens in the middle
of the activity. It also can't depict two simultaneous actions, as cleaning one's teeth while waiting
for the tub to fill. We present an alternative formalism known as event calculus to address such
circumstances, which is based on points of time rather than situations.
Instances of event categories are used to describe events.4 Shankar's flight from San Francisco to
Washington, D.C. Is described as follows:
E1 ∈ Flyings ∧ Flyer (E1, Shankar ) ∧ Origin(E1, SF) ∧ Destination(E1,DC) .
Then we use Happens(E1, I to indicate that the event E1 occurred at the time interval i. A (start,
finish) pair of times is used to express time intervals.
For one form of the event calculus, the entire collection of predicates 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
T is defined as a fluent that holds at a given point in time if it was started by an event in the past
and was not made false (clipped) by an intervening event.
If an event terminates a fluent and it is not made true (restored) by another event, the fluent is no
longer valid. The axioms are as follows:
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 terms used to describe as:
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)
T can be extended to function over intervals as well as time points; for example, a fluent holds
across an interval if it holds at every point within the interval:
T(f, (t1, t2)) ⇔[∀ t (t1 ≤ t < t2) ⇒ T(f, t)]

Q16) Describe mental object and modal logic?


A16) So far, the agents we've created have beliefs and can infer new ones. Despite this, none of
them has any understanding of beliefs or deduction. Controlling inference requires understanding
of one's own knowledge and reasoning processes.
Propositional attitudes - the way a person feels about mental objects (e.g. Believes, Knows,
Wants, Intends, and Informs). These propositional attitudes do not behave in the same way that
ordinary predicates do.
To say, for example, that Lois is aware of Superman's ability to fly:
Knows(Lois, CanFly(Superman))
The inferential rules conclude that "Lois knows Clark can fly" if "Superman is Clark Kent" is true
(this is an example of referential transparency). Lois, on the other hand, has no idea that Clark can
fly.
Superman = Clark
(Superman = Clark) and (Knows(Lois, CanFly(Superman)) ⊨ Knows(Lois, CanFly(Clark))

Referential transparency
● In whatever situation, an expression always yields the same outcome.
● For example, if an agent understands that 2+2=4 and 4<5, it should also know that 2+25.
● integrated into inferential rules in most formal logic languages.

Referential opacity
● transparent but not referential
● For propositional attitudes, we want referential opacity because terms matter, and not all agents
are aware of which terms are co-referential.
● In most formal logic languages, this is not directly achievable (except Modal Logic).

Modal Logic
Created to allow for referential opacity in the knowledge base
Regular logic is concerned with a single modality (the truth modality), allowing us to say "P is
true."
Modal logic comprises modal operators that use sentences as arguments rather than terms (e.g. "A
knows P" is represented with notation KAP where K is the modal operator for knowledge, A is the
agent, and P is a sentence).
Modal logic has the same syntax as first-order logic, with the exception that modal operators can
also be used to build sentences.
Modal logic's semantics are more sophisticated. A model in first-order logic has a set of objects as
well as an interpretation that translates each name to the correct item, relation, or function. We
want to be able to consider both the possibility that Superman's secret identity is Clark and the
chance that it isn't in modal logic. As a result, a model in modal logic is a collection of possible
universes (instead of 1 true world). Accessibility relations connect the worlds in a graph (one
relation for each modal operator). If everything in w1 is consistent with what A knows in w0, we
say that world w1 is accessible from world w0 with respect to the modal operator KA, and we
express this as Acc (KA, w0, w1).
As an arrow between possible universes, the figure depicts accessibility.
Fig: Possible worlds with accessibility relations K Superman and KLois .
An atom of knowledge If and only if P is true in every world accessible from w, KAP is true in
world w. Recursive application of this rule with the standard laws of first-order logic yields the
truth of more complex sentences. That is, modal logic can be used to reason about nested
knowledge sentences, or what one agent knows about the knowledge of another agent.
We can claim, for example, that while Lois does not know if Superman's secret identity is Clark
Kent, she does know that Clark does:

K Lois [KClark Identity(Superman, Clark) ∨ KClark ¬Identity(Superman, Clark)]


The situation depicted in the TOP-LEFT of the picture is one in which Superman knows his own
identity and neither he nor Lois has received the weather report. So, in w0, Superman has access to
the worlds w0 and w2; rain may or may not be forecast.
For Lois, all four universes are accessible from one another; she has no idea what the report is
about or whether Clark is Superman. But she is aware that Superman is aware of whether he is
Clark or not, because in every reality accessible to Lois, either Superman is aware of I or he is
aware of ¬I. Lois isn't sure which is the case, but she knows Superman is aware of it.
The situation depicted in the top-right corner of the picture is one in which it is widely assumed
that Lois has seen the weather report. So she knows it's going to rain in w4 and it's not going to rain
in w6. Superman is unaware of the report, but he is aware that Lois is aware of it, because in every
reality to which he has access, she either knows R or knows¬ R.
The situation depicted in the BOTTOM of the figure is one in which Superman's identity is widely
known, and Lois may or may not have seen the weather report. We show this by combining the two
top situations and adding arrows to show that Superman has no idea which one is correct. We don't
need to draw any arrows for Lois because she already knows. In w0, Superman still recognises I
but not R, and he has no idea whether Lois recognises R. According to what Superman knows, he
might be in w0 or w2, in which case Lois is unsure whether R is true, w4, in which case she is
aware of R, or w6, in which case she is aware of ¬R.

Modal Logic's Tricky Interplay of Quantifiers and Knowledge


The English line "Bond knows that someone is a spy," for example, is ambiguous.
"There is a certain someone that Bond knows is a spy," says the first reading:

∃x K BondSpy(x)
In modal logic, this indicates that there is an x that Bonds knows to be a spy in all accessible
worlds.
The second interpretation is that "Bond just knows that at least one spy exists":

K Bond∃x Spy(x)
In modal logic, this indicates that there is an x who is a spy in each accessible world, but it does not
have to be the same x in each world.

Modal Logic - Writing Axioms With Modal Operators


State that agents can deduce; "if an agent knows P and recognises that P implies Q, then the agent
knows Q."

a a
(K P ∧ K (P ⇒ Q)) ⇒ K Q a
Declare that every agent is aware of the truth or falsity of every proposition P:

a
K (P v ¬P)
True belief is justified knowledge:

a
K P⇒P
If an agent is aware of something, they are aware that they are aware of it:

a a a
K P ⇒ K (K P)
Similar axioms can be defined for belief (commonly abbreviated as B) and other modal operators.
One issue with modal logic is that it presupposes agents have logical omniscience (that is, if an
agent knows a set of axioms, then it knows all consequences of those axioms).

Q17) Write about reasoning system for categories?


A17) The main building blocks of large-scale knowledge representation schemes are categories.
There are two families of systems that are closely related:
Description logics provide a formal language for constructing and combining category definitions,
as well as efficient algorithms for deciding subset and superset relationships between categories.
Semantic networks provide graphical aids for visualizing a knowledge base and efficient
algorithms for inferring properties of an object based on its category membership; and semantic
networks provide graphical aids for visualizing a knowledge base and efficient algorithms for
inferring properties of an object based on its category membership.
Semantic networks:
In 1909, Charles S. Peirce created existential graphs, a graphical notation of nodes and edges that
he dubbed "the logic of the future."
● Semantic networks come in a variety of shapes and sizes, but they may all represent individual
objects, categories of objects, and relationships between things.
● The names of objects or categories are displayed in ovals or boxes, and they are connected with
labeled connections in a standard graphical format.

For example, Figure below has a Member Of link between Mary and Female Persons,
corresponding to the logical assertion Mary ∈Female Persons; similarly, the Sister Of link
between Mary and John corresponds to the assertion Sister Of (Mary, John). We can connect
categories using Subset Of links, and so on.
It's easy to get carried away when painting bubbles and arrows.
Can we draw a Has Mother link from Persons to Female Persons, for example, because we know
that persons have female persons as mothers?
Has Mother is a relationship between a person and his or her mother, and categories do not have
mothers, hence the answer is no.
As a result, in Figure below, we've employed a specific notation—the double-boxed link.
According to this link,
∀x x∈ Persons ⇒ [∀ y HasMother (x, y) ⇒ y ∈ FemalePersons ] .
We might also say that people have two legs—that is, that they have two legs.
∀x x∈ Persons ⇒ Legs(x, 2) .
The single-boxed link in Figure below is used to assert properties for each category member.
One of the key attractions of semantic networks has been the simplicity and effectiveness of this
inference process when compared to logical theorem proving.

Fig: Semantic network with four objects and four categories. Relations are denoted by labeled links

Inverse linkages are another prominent method of inference. Has Sister, for example, is the inverse
of Sister Of, implying that
When compared to first-order logic, the reader may have recognised an evident disadvantage of
semantic network notation: the fact that linkages between bubbles only reflect binary relations.
In a semantic network, for example, the sentence Fly(Shankar, New York, New Delhi,Yesterday)
cannot be affirmed explicitly.

Fig: Fragment of a semantic network showing the representation of the logical assertion
Fly(Shankar, New York, New Delhi, Yesterday)

The capacity of semantic networks to represent default values for categories is one of its most
essential features.
If you look closely at Figure, you'll find that John only has one leg, despite the fact that he's a
person, and all people have two legs.
The default value is said to be overridden by the more particular value. We might alternatively
override the default number of legs by adding a One Legged Persons category, which is a subset of
Persons that includes John.
If we say that the Legs assertion for Persons includes an exception for John, we can keep the
network's semantics purely logical:
∀x x∈ Persons ∧ x _= John ⇒ Legs(x, 2) .
This is semantically appropriate for a fixed network.

Description logics
First-order logic's syntax is intended to make it simple to declare things about objects.
Description logics are notations that make describing the definitions and properties of categories
easier.
Subsumption (testing if one category is a subset of another by comparing their definitions) and
classification are the two main inference tasks for description logics (checking whether an object
belongs to a category)..
The consistency of a category definition—whether the membership criteria are logically satisfiable
—is also considered in some systems.
Fig: Syntax of description in sunset of CLASSIC language

A typical description logic is the CLASSIC language (Borgida et al., 1989). Figure depicts the
syntax of CLASSIC descriptions.
To say that bachelors are unmarried adult males, for example, we would write
Bachelor = And(Unmarried, Adult ,Male) .
In first-order logic, the equivalent would be
Bachelor (x) ⇔ Unmarried(x) ∧ Adult(x) ∧ Male(x).
Any CLASSIC description can be translated into a first-order equivalent statement, however some
CLASSIC descriptions are more clear.
For example, to characterise a group of males who have at least three unemployed sons who are all
married to doctors, and at most two daughters who are all professors in physics or math
departments, we would use
And(Man, AtLeast(3, Son), AtMost(2, Daughter ),
All(Son, And(Unemployed,Married, All(Spouse, Doctor ))),
All(Daughter , And(Professor , Fills(Department , Physics,Math)))) .
Translating this into first-order logic is left as an exercise.
Negation and disjunction, for example, are generally absent from description logics.
In the Fills and OneOf constructions, CLASSIC only provides for a restricted type of disjunction.

Q18) Write about reasoning with default information?


A18) Circumscription and default logic
When one sees a car parked on the street, for example, one is usually inclined to think it has four
wheels despite the fact that only three are visible.
While probability theory can surely lead to the conclusion that the fourth wheel exists with a high
probability, most people do not consider the idea that the car does not have four wheels unless new
data is presented.
In the absence of any reason to doubt it, it appears that the four-wheel conclusion is reached by
default. The conclusion can be retracted if fresh evidence is discovered—for example, if the owner
is seen carrying a wheel and the car is jacked up.
Because the collection of beliefs does not develop monotonically over time when new evidence
emerges, this type of reasoning is known as non monotonicity.
In order to capture such behaviour, non monotonic logics have been constructed with changed
ideas of truth and entailment.
Circumscription and default logic are two such logics that have been extensively investigated.
The closed world assumption can be considered as a more powerful and exact variant of
circumscription.
The goal is to define specific predicates that are supposed to be "as false as feasible," that is, false
for all objects except those for which they are known to be true.
Let's say we wish to establish the default rule that birds fly.
We'd create a predicate, say Abnormal 1(x), and write it down.
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).
Default logic is a formalism that allows for the creation of contingent, non-monotonic conclusions
using default principles. The following is an example of a default rule:
Bird(x) : Flies(x)/Flies(x)
If Bird(x) is true and Flies(x) is compatible with the knowledge base, Flies(x) can be concluded by
default. In most cases, a default rule looks like this:
P : J1, . . . , Jn/C
P stands for the precondition, C for the conclusion, and Ji for the justifications; if any of them is
demonstrated to be untrue, the conclusion cannot be formed.
Unit - 6
Planning
Q1) What do you mean by automated planning?
A1) The field of Artificial Intelligence known as Automated Planning investigates this discussion
process computationally. Its goal is to aid planning by reasoning on conceptual models, which are
abstract and formal representations of the domain, the effects and combinations of activities, and
the requirements to be met and objectives to be met. The planning domain is the conceptual model
of the domain in which activities are carried out, plans are combinations of actions, and goals are
the needs to be met. Intuitively, a planning problem entails determining a plan that satisfies the goal
in a specific domain, given a planning domain and a goal. For Automated Planning, we give a
broad formal framework.
Domains, plans, and goals are the three fundamental components of the planning problem that the
framework is built upon.
Domain - We allow for nondeterministic domains, which are domains in which actions may have
varied effects and it is impossible to predict which of the various possible outcomes will actually
occur at the time of planning. We also take partial observability into account. It represents the
reality that the state of the domain cannot always be observed completely, and so cannot be
determined uniquely in some instances. The special circumstances of full observability, where the
state may be totally observed and hence uniquely determined, and null observability, where no
observation is ever feasible at run time, are both included in a model with partial observability.

Plans - We define plans in which the action to be performed in a particular state may be influenced
by information about prior execution phases. Sequential plans, i.e., plans that are just sequences of
activities, conditional plans, i.e., plans that can pick a different action depending on the current
circumstance at execution time, and iterative plans that can run actions until a situation happens are
all covered by the definition. There are plans that rely on a finite number of execution steps (finite-
memory plans) and plans that do not rely on prior execution steps (non-memory plans) (memory-
less plans). Plan executions, in general, result in trees (called execution trees) whose nodes
correspond to domain states.

Goals - Goals are defined as sets of acceptable trees that correspond to intended planning domain
evolutions. They can be used to represent traditional reachability goals, which are requirements
expressed on the leaves of execution trees that specify the end states to be achieved once a plan is
performed. They can also represent more complicated types of "extended objectives," such as
temporally extended goals, that convey conditions across the entire execution tree.
Our framework is broad enough to encompass a wide range of relevant and important planning
issues. Deterministic domains, plans that are sequences of actions, and reachability goals can all be
used to mimic traditional planning. Furthermore, our framework is ideally adapted for modeling
specific types of planning under uncertainty and imperfect knowledge, which has recently been
addressed in the scientific literature and is relevant to a number of real-world applications.
Nondeterministic domains do, in fact, model uncertainty in action effects, whereas partial
observability does so for observations.
Nondeterministic domains, null observability, sequential plans, and reachability goals, for example,
can be used to model conformant planning. Nondeterministic domains, conditional plans, and
reachability goals can all be used to model contingent planning.
Nondeterministic domains, history-dependent plans, and objectives that describe desirable domain
evolutions can all be used to simulate planning for temporally extended goals.
For practical reasons, the framework cannot be too broad to encompass all of the various planning
issues that have been discussed in the literature thus far. For example, we do not represent
probabilities of action outcomes in action domains, and goals are represented as utility functions,
which is a difference from planning based on Markov Decision Processes (MDP).

Q2) Define classical planning?


A2) Classical planning is the process of constructing complicated plans of action using the issue
structure as a guide.
Invariants are used in optimum planning (graph theory, complexity theory).
Domain-specific solvers are integrated to improve the efficiency of classical planning on certain
domains (puzzles, logistics, video games).
Machine learning approaches are being used in the planning and extraction of structural data
(machine learning, deep learning, neural networks).
Optimize your strategy.
In traditional planning, the agent performs three tasks:
● planning: After determining the problem, the agent makes a plan.
● Acting: It chooses the course of action to adopt.
● Learning: The agent's actions cause him to learn new things.

Fig 1: Agent task

PDDL (Planning Domain Definition Language) is a language that is used to represent all actions in
a single action schema.
The four basic things required in a search problem are described by PDLL:
● Initial state - Each state is represented as the union of the ground and functionless atoms in its
initial state.
● Action - It is defined by a series of action schemas that define the ACTION() and RESULT()
functions implicitly.
● Result - The collection of activities taken by the agent yielded this result.
● Goal - The goal is the same as a precondition, which is a literal conjunction (whose value is
either positive or negative).

There are various examples which will make PDLL understandable:


● Air cargo transport
● The spare tire problem
● The blocks world and many more.

Q3) Write the advantages and complexity of classical planning?


A3) Advantages of Classical Planning
Classical planning has the following benefits:
● It has enabled the development of precise domain-independent heuristics.
● The systems are simple to use and operate efficiently.

Complexity of the classical planning


There are two decision difficulties that arise in traditional planning:
● PlanSAT: is a query that asks if any plan exists that solves a planning difficulty.
● Bounded PlanSAT: It's a question that asks if there's a solution with a length of k or less.

Q4) What do you mean by heuristics for planning?


A4) Without a good heuristic function, neither forward nor backward search is efficient. Remember
that a heuristic function h(s) measures the distance between a state s and the goal, and that we may
utilize A search to identify optimal solutions if we can construct an admissible heuristic for this
distance—one that does not overestimate. By establishing a relaxed issue that is easier to solve, an
admissible heuristic can be generated. The heuristic for the original problem is then the exact cost
of a solution to this easier problem.
Because there is no mechanism to analyze an atomic state by definition, it takes some ingenuity on
the part of a human analyst to come up with suitable domain-specific heuristics for atomic state
search problems. For states and action schemas, planning employs a factored representation. This
allows for the definition of good domain-independent heuristics and the automatic use of a good
domain - independent heuristic for a given problem by programmes.
Consider a search issue as a network with nodes representing states and edges representing
operations. The goal is to find a path from the original state to the desired state. We may make this
problem easier in two ways: by adding more edges to the graph, making it stricter to identify a
path, or by grouping several nodes together, generating an abstraction of the state space with fewer
states, making it easier to search.
First, we'll look at heuristics for adding edges to the graph. The disregard preconditions heuristic,
for example, removes all preconditions from actions. Every action becomes relevant in every stage,
and any single goal can be accomplished in a single step (assuming an applicable action exists—if
not, the problem is impossible to solve). This almost indicates that the number of steps required to
solve the relaxed problem is equal to the number of unmet goals—almost, but not quite, because
some acts may accomplish several goals and others may negate the results of others. Consider and
ignore is a good way to get an accurate heuristic for many problems.
First, we loosen up the actions by removing all preconditions and consequences that aren't literals
in the goal. Then we count the least number of activities required to achieve the goal when the
impacts of those actions are added together. This is a case of the set-cover problem in action. One
small annoyance is that the set-cover problem is NP-hard. Thankfully, a basic greedy algorithm
will always provide a set covering that is within a factor of log n of the true lowest covering, where
n is the number of literals in the target. Unfortunately, the greedy algorithm loses its admissibility
guarantee.
It's also feasible to ignore only some action preconditions. Consider the puzzle of sliding blocks (8-
puzzle or 15-puzzle). This might be expressed as a tile-based planning problem with a single
schema. Slide:
Action(Slide(t,s1,s2),
PRECOND:On(t,s1) ∧ Tile(t) ∧ Blank (s2) ∧ Adjacent(s1,s2)
EFFECT:On(t,s2) ∧ Blank(s1) ∧ ¬On(t,s1) ∧ ¬Blank(s2))
When the preconditions Blank (s2) ^ Adjacent(s1,s2) are removed, every tile can move to any
space in one action, yielding the number-of-misplaced-tiles heuristic. The Manhattan-distance
heuristic is obtained by removing Blank(s2). These heuristics might easily be deduced
automatically from the action schema description.
The factored form of planning issues has a significant advantage over the atomic representation of
search problems in terms of ease of manipulation of the schemas.
The ignore remove listings heuristic is another option. Assume that all objectives and preconditions
include only positive literals3 for a moment. We want to make a more relaxed version of the
original issue that is easier to solve and uses the length of the solution as a heuristic. This can be
accomplished by deleting delete lists from all actions (i.e., removing all negative literals from
effects). This allows for consistent progress toward the goal, as no action will ever negate progress
achieved by another. The optimal solution to this relaxed problem is still NP - hard to discover, but
an approximate solution can be achieved in polynomial time through hill-climbing.
Decomposition is an essential concept in defining heuristics: breaking a problem into parts, solving
each portion separately, and then merging the parts. The cost of achieving a conjunction of
subgoals is approximated by the total of the costs of solving each subgoal independently, according
to the subgoal independence assumption. The assumption of subgoal independence might be either
optimistic or pessimistic. When there are negative interactions between the sub plans for each
subgoal, such as when an action in one sub plan deletes a goal reached by another sub plan, it is
optimistic. When sub plans contain redundant actions—for example, two actions that might be
replaced by a single action in the merged plan—it is gloomy, and thus inadmissible.

Q5) Write about hierarchical planning?


A5) When planning, it's common to have hierarchical information on the actions, or a description
of how complex actions are broken down. For instance, a complicated activity such as "serving
coffee" can be broken down into two complex actions: "making coffee" and "bringing coffee." As a
result, there exist planners, such as ABSTRIPS, that take as input the hierarchical description of the
activities in addition to the description of the actions. For example, one can start planning at a
general level and then drill down into the details if necessary (as does ABSTRIPS for example). A
hierarchical task network is then used to express the goal (HTN).
● Hierarchical planning, often known as HTN planning, is a planning system based on the
Hierarchical Task Network (HTN).
● It combines Partial Order Planning and HTN Planning concepts.
● HTN planning is frequently organized around a single "top-level" action termed Act, with the
purpose of finding an Act execution that meets the goal.
● The first plan is considered as a high-level statement of what needs to be done in HTN planning.
● Decomposition actions are used to refine this strategy.
● Each action decomposition breaks down a higher-level activity into a jumble of lower-level
actions.
● This deconstruction continues until the plan is reduced to its most basic actions.
● Consider a hierarchical travel plan from a specific source to a specific destination.

● Assume we're traveling from source "Mumbai" to destination "Goa" in the above hierarchical
planner diagram.
● Then you can decide how you want to travel: by plane, bus, or car. Assume you decide to travel
by "Bus."
● The "Take-Bus" strategy can then be broken down into a series of tasks, such as going to
Mumbai – Bus stop, purchasing a bus ticket, boarding the bus, and departing for Goa.
● The four acts in the previous point can now be split down into their component parts. Take, for
example, "By-Ticket for Bus."
● It may be broken down into three steps: go to the bus stop counter, request a ticket, and pay for
the ticket.
● As a result, each of these actions can be further deconstructed until we reach the level of actions
that can be performed without thought in order to generate the needed motor control sequences.

Q6) Write the advantages and disadvantages of hierarchical planning?


A6) Advantages of Hierarchical Planning:
● The main advantage of a hierarchical structure is that it reduces the plan at each level of the
hierarchy to a small number of activities at the next lower level, lowering the computing cost of
determining the best method to organise those activities for the current challenge.
● Many real-world applications demand very big plans, which HTN algorithms may generate.
● In the event that something goes wrong, the hierarchical structure makes it simple to rectify the
problem.
● Hierarchical planning is far more efficient than single-level planning for complex issues.

Disadvantages of Hierarchical Planning:


● A Deterministic environment is required by many HTN planners.
● Many HTN planners are unable to deal with unpredictable results of actions.

Q7) Explain non deterministic domain, time, schedule and resources?


A7) Domain
We allow for nondeterministic domains, which are domains in which actions may have varied
effects and it is impossible to predict which of the various possible outcomes will actually occur at
the time of planning. We also take partial observability into account. It represents the reality that
the state of the domain cannot always be observed completely, and so cannot be determined
uniquely in some instances. The special circumstances of full observability, where the state may be
totally observed and hence uniquely determined, and null observability, where no observation is
ever feasible at run time, are both included in a model with partial observability.

Time, Schedule and Resources


The standard planning representation can communicate about what to do and in what order, but it
can't talk about how to execute it.
● Temporal ordering constraint - When an activity should occur (before and/or after a particular
time and/or specific action(s)), there are temporal ordering constraints.
● Resource constraints - outlines the resources required to carry out a task.

Representing Temporal Constraints, Resource Constraints, and the Available Resources


Each action is represented by:
● A period of time
● A collection of temporal ordering constraints (actions that must be performed before this action
may be carried out)
● A set of limits on resources

Each resource is represented by 3 things:


● The resource's kind (e.g. Bolts, wrenches, or pilots).
● The quantity of that resource at the start.
● Whether or not that resource:
○ Consumable - e.g. The bolts are no longer available for use
○ Reusable - e.g. a pilot is occupied during a flight but is available again when the flight is over
○ Sharable

Actions have the ability to generate resources.


A solution must meet all of the activities' and resources' temporal ordering constraints.
Example of a Scheduling Issue (Assembly of 2 Cars).
The problem of assembling two cars consists of the following steps:
● Resources: There are four different sorts of resources, with a certain number of each type
available at the start:

● Ordering & resource constraints: 2 jobs, each of form [AddEngine, AddWheels, Inspect] and
their individual action durations and its resource constraints

Q8) Analyze planning approaches?


A8) Planning brings together the two key AI disciplines we've discussed so far: search and logic. A
planner can be thought of as either a programme that looks for a solution or one that
(constructively) argues that one exists. The cross-fertilization of ideas from the two fields has
resulted in performance gains of several orders of magnitude over the last decade, as well as a rise
in the usage of planners in industrial applications. Regrettably, we do not yet have a firm grasp of
which strategies are most effective in particular situations. It's possible that new procedures will
arise that will supplant old ones.
Controlling combinatorial explosion is at the heart of planning. There are 2n states in a domain if
there are n propositions. As we've seen, planning is difficult. Identifying independent subproblems
can be a powerful tool against such pessimism. We gain an exponential speedup in the best case—
full decomposability of the problem. Negative interactions between acts, on the other hand, destroy
decomposability. GRAPHPLAN keeps track of mutexes to help you figure out where the tricky
interactions occur.
SATPLAN represents mutex relations in a similar way, but instead of employing a specialized data
structure, it uses the universal CNF form. Forward search tries to uncover patterns (subsets of
propositions) that cover all of the independent subproblems heuristically. Because this is a heuristic
approach, it can be used even if the subproblems are not totally independent.
It is sometimes possible to efficiently address an issue by understanding that unfavorable
interactions can be ruled out. If there is a SERIALIZABLE SUBGOAL an order of subgoals such
that the planner can achieve them in that order without having to reverse any of the previously
achieved subgoals, we say the problem has serializable subgoals. If the goal is to build a tower
(e.g., A on B, which is on C, which is on Table), then the subgoals are serializable bottom to top: if
we first achieve C on Table, we will never have to undo it while achieving the other subgoals. A
planner who employs the bottom-to-top strategy can solve any problem in the world of blocks
without having to go backwards (although it might not always find the shortest plan).
For a more complex example, it was determined that the propositions involved in commanding
NASA's Deep Space One spacecraft are serializable for the Remote Agent planner that commanded
NASA's Deep Space One spacecraft. This is perhaps unsurprising, given that engineers construct
spaceships to be as simple to manage as possible (subject to other constraints). The Remote Agent
planner was able to eliminate the majority of the search by taking use of the serialized ordering of
goals. This meant it could control the spacecraft in real time, which had previously been thought
impossible.
GRAPHPLAN, SATPLAN, and FF are examples of planners who have advanced the science of
planning by improving the performance of planning systems, explaining the representational and
combinatorial challenges involved, and developing useful heuristics. However, it is unclear how far
these procedures can be scaled. Further progress on larger issues is likely to require some type of
synthesis of first-order and hierarchical representations with the efficient techniques already in use,
rather than relying solely on factored and propositional representations.

Q9) What are the limits of AI?


A9) The availability of data is one of the most significant obstacles to AI implementation. Data is
frequently fragmented, inconsistent, and of low quality, posing hurdles for firms attempting to
leverage AI at scale. To avoid this, you should have a defined approach for obtaining the data that
your AI will require from the start.
Another major impediment to AI adoption is a skills scarcity and a lack of technical professionals
with the appropriate knowledge and training to deploy and run AI technologies. According to
research, experienced data scientists, as well as other specialized data professionals competent in
machine learning, training effective models, and so on, are in short supply.
Another important factor to consider when purchasing AI technology is the price. Businesses that
lack in-house capabilities or are unfamiliar with AI are frequently forced to outsource, posing cost
and maintenance issues. Smart technologies can be costly due to their complexity, and you may pay
additional fees for repair and continuous maintenance. Computational costs for training data
models, for example, can be an added cost.
Software programmes must be updated on a regular basis to keep up with the changing business
environment, and if they fail, there is a risk of losing code or essential data. It can take a long time
and be expensive to restore this. This danger, however, is no higher with AI than with any other
software development. These dangers can be reduced if the system is well-designed and people
purchasing AI are aware of their needs and options.
Cost and maintenance - Purchase costs can be high, and there may be a need for ongoing
maintenance and repair, as with any new technology. In order to react to the ever-changing business
environment, your AI software will need to be updated on a regular basis. Before you go forward
and adopt any AI system, your organization should thoroughly analyze the return on investment.
Lack of creativity - A good marketing effort requires a high level of creativity. Machines just do not
possess the ability to think creatively. Humans, unlike robots, have the ability to think and feel,
which influences their decision-making when it comes to creativity. Yes, AI can help estimate what
type of picture, for example, a consumer is likely to click on - everything from color preferences to
style and price. A machine, on the other hand, cannot compete with the human brain when it comes
to originality and creative thinking. Both humans and machines are still required.

Other AI limitations include:


● Implementation times, which can vary based on what you're trying to accomplish.
● Integration issues and a lack of knowledge about cutting-edge technology.
● Interoperability with various systems and platforms, as well as usability.

Q10) Write the ethics of AI?


A10) Artificial Intelligence ethics, often known as AI ethics, is a set of beliefs, ideas, and
methodologies that use commonly accepted criteria of right and wrong to govern moral behavior in
the development and deployment of AI systems.
In recent years, the ethics of AI and robotics have gotten a lot of press attention, which helps
support related research but also risks undermining it: the press frequently talks as if the issues
under discussion are just predictions of what future technology will bring, and as if we already
know what would be most ethical and how to get there.
The ethics of AI and robotics are frequently centered on various "concerns," which is a common
reaction to new technologies. Many of these concerns turn out to be rather quaint (trains are too
fast for souls); some are predictably wrong when they claim that technology will fundamentally
change humans (telephones will destroy personal communication, writing will destroy memory,
video cassettes will render going out obsolete); some are broadly correct but moderately relevant
(digital technology will destroy industries that make photographic film, cassette tapes, or vinyl
records); and some are egregiously wrong when they claim that technology will fundamentally
change humans (telephones will destroy personal (cars will kill children and fundamentally change
the landscape). The purpose of a piece like this is to dissect the concerns and deflate the non-issues.
Some technologies, such as nuclear power, automobiles, and plastics, have sparked ethical and
political debate as well as considerable regulatory initiatives to limit their trajectory, usually after
some damage has been done. New technologies, in addition to "ethical issues," challenge present
norms and conceptual frameworks, which is of particular interest to philosophy. Finally, once we've
grasped the context of a technology, we must shape our societal reaction, which includes regulation
and law. All of these characteristics are present in modern AI and robotics technologies, as well as
the more fundamental worry that they will usher in the end of the period of human control on
Earth.
Though there is a promising outline (European Group on Ethics in Science and New Technologies
2018) and there are beginnings on societal impact (Floridi et al. 2018; Taddeo and Floridi 2018; S.
Taylor et al. 2018; Walsh 2018; Bryson 2019; Gibert 2019; Whittlestone et al. 2019), and policy
recommendations, the ethics of AI and robotics is a very young field within applied ethics, with
significant dynamics but few well-established issues (AI HLEG 2019 [OIR]; IEEE 2019). As a
result, this page must not only repeat what the community has already accomplished, but also offer
an order where none exists.
A variety of ethical challenges have arisen as a result of AI's rapid growth. These are some of them:
● The potential for employment loss as a result of automation technologies
● Employees must be redeployed or retrained in order to keep their positions.
● Machine-created wealth should be distributed fairly.
● The impact of human-machine interaction on human attention and behavior
● The necessity to address algorithmic bias in data resulting from human bias
● The safety of AI systems that have the capacity to cause harm (e.g. Autonomous weapons).
● Because smart machines are considered to learn and develop independently, there is a need to
guard against unforeseen outcomes.

Q11) What is the future of AI?


A11) Artificial Intelligence (AI) is a breakthrough discipline of computer science that is poised to
become a key component of several future technologies such as big data, robotics, and the Internet
of Things (IoT). In the coming years, it will continue to be a technical trailblazer. AI has gone from
science fiction to reality in a few of years. Machines that assist people with intelligence can be
found in the real world as well as in science fiction films. We now live in a world of Artificial
Intelligence, which was only a story a few years ago.
We use AI technology in our daily lives, whether consciously or unconsciously, and it has become
a part of our lives. Everyone uses AI in their day-to-day lives, from Alexa/Siri to Chatbots. The
advancement and evolution of this technology is occurring at a breakneck speed. It was not,
however, as smooth and simple as it appeared to us. It has taken several years, as well as a lot of
hard effort and contributions from a variety of people, to get AI to this point.
Because AI is such a revolutionary technology, there are numerous questions concerning its future
and impact on humans. It's risky, but it's also a fantastic opportunity. Artificial intelligence will be
used to improve both defensive and offensive cyber operations. In addition, new cyber-attack
methods will be developed to exploit AI technology's specific vulnerabilities.
Future impact of AI in different sectors

Fig 2: Future of AI

Healthcare: In the healthcare industry, AI will be critical in promptly and effectively diagnosing
ailments. With the help of AI, new drug discovery will be speedier and more cost-effective. It will
also improve patient engagement in their care by making appointment booking and bill payment
easier and with fewer errors. Apart from these helpful applications, one of AI's greatest challenges
in healthcare is ensuring its acceptance in daily clinical operations.

Cyber security: Without a question, ensuring data security is a top responsibility for every
company. The following are some predictions about how cyber security will alter as a result of AI:
● Security incidents will be tracked using AI techniques.
● NLP is used to identify the source of cyber-attacks.
● RPA bots are used to automate rule-based operations and procedures.
As a brilliant technology, however, it can also be used by attackers as a threat. They can employ AI
in an unethical manner by automating attacks that are difficult to defend.

Transportation: In the transportation industry, a fully autonomous vehicle has not yet been
produced, but researchers are working on it. In the cockpit, artificial intelligence and machine
learning are being used to help minimise workload, manage pilot stress and fatigue, and increase
on-time performance. There are a number of barriers to AI adoption in transportation, particularly
in public transit. There is a significant risk of becoming overly reliant on automated and
autonomous technologies.

E-commerce: In the near future, Artificial Intelligence will play a critical role in the e-commerce
industry. It will have a favorable impact on every part of the e-commerce industry, from user
experience to product marketing and delivery. In the future, we can expect e-commerce to include
automated warehouse and inventory management, shopper personalisation, and the employment of
chatbots.

Employment: Because of the usage of Artificial Intelligence, finding work has become easier for
both job seekers and companies. In the job market, AI is already being employed with stringent
regulations and algorithms that automatically reject an employee's résumé if it does not meet the
company's requirements. Most AI-enabled applications, spanning from marking written interviews
to telephonic rounds, are expected to drive the job process in the future.
Various AI programmes, such as Rezi, Jobseeker, and others, are assisting job searchers in creating
great resumes and finding the perfect position for their skills.
Apart from the aforementioned industries, AI has a bright future in manufacturing, finance and
banking, entertainment, and other fields.

Q12) Explain AI components?


A12) Learning, thinking, problem solving, perception, and language use are all aspects of
intelligence.

Fig 3: Components of AI

Learning
Computer programmes, like humans, learn in a variety of ways. When it comes to AI, this
platform's learning is divided into a variety of categories. Learning for AI comprises the trial-and-
error approach, which is one of the most important aspects of AI. The solution continues to solve
problems until it obtains the desired results. As a consequence, the programme keeps track of all
the movements that resulted in positive outcomes and stores them in its database for use the next
time the computer is presented with the same problem.
Individual things, such as multiple solutions to problems, vocabulary, foreign languages, and so on,
are memorized as part of AI's learning component, often known as rote learning. The generalization
method is then used to put this learning process into practice.
When it comes to artificial intelligence, there are several different types of learning. The most basic
method is to learn through trial and error. A rudimentary computer programme for solving mate-in-
one chess situations, for example, might try moves at random until it finds mate. The programme
could then save the solution along with the position so that it could be recalled the next time the
computer came across the same situation. On a computer, rote learning—the simple memorizing of
individual items and procedures—is relatively straightforward to accomplish. The difficulty of
implementing what is known as generalization is more difficult. Generalization is the process of
adapting previous experience to similar new situations.

Reasoning
Until about five decades ago, the art of reasoning was solely available to humans. Reasoning is one
of the most important components of artificial intelligence because of its ability to differentiate. To
reason is to allow the platform to make inferences that are appropriate for the situation at hand. In
addition, these inferences are classified as inductive or deductive. The difference is that in an
inferential scenario, a problem's solution assures a conclusion. In the inductive example, however,
the mishap is always caused by instrument failure.
Programming computers have had a lot of success with deductive interferences. Reasoning, on the
other hand, always entails drawing meaningful inferences from the circumstance at hand.
To reason is to make inferences that are appropriate for the circumstances. Deductive and inductive
inferences are the two types of inferences. "Fred must be in either the museum or the café," for
example, is an example of the former. "Previous accidents of this nature were caused by instrument
failure; thus, this accident was caused by instrument failure," and "Previous accidents of this nature
were caused by instrument failure; therefore, this accident was caused by instrument failure." The
most important distinction between these two types of reasoning is that in deductive reasoning, the
validity of the premises assures the truth of the conclusion, whereas inductive reasoning offers
support to the conclusion without providing total assurance.

Problem-solving
In its most basic form, AI's problem-solving ability consists of data, with the answer requiring the
discovery of x. The AI platform sees a wide range of problems being handled. The various
'Problem-solving' approaches are artificial intelligence components that split questions into special
and general categories.
A solution to a given problem is tailor-made in the case of a special-purpose method, which often
takes advantage of some of the unique features supplied in the instance where a suggested problem
is incorporated. A general-purpose approach, on the other hand, entails a wide range of interesting
challenges. In addition, AI's problem-solving component allows programmes to include a step-by-
step reduction of the distance between any target state and the current state.
Problem solving, especially in artificial intelligence, can be defined as a methodical search through
a set of options in order to arrive at a predetermined goal or solution. There are two types of
problem-solving methods: special purpose and general purpose. A special-purpose approach is
designed specifically for a problem and typically takes advantage of extremely specific aspects of
the scenario in which the problem exists. A general-purpose method, on the other hand, can be used
to solve a wide range of issues.

Perception
When the 'perception' component of Artificial Intelligence is used, it scans any given environment
utilizing various artificial or actual sense organs. Furthermore, the processes are maintained
internally, allowing the perceiver to examine different scenes in suggested objects and comprehend
their relationships and characteristics. This analysis is frequently problematic as a result of the fact
that similar products might have a wide range of looks depending on the viewpoint of the indicated
angle.
Perception is one of the components of artificial intelligence that, in its current condition, can
propel self-driving cars at low speeds. FREDDY was one of the first robots that use perception to
detect distinct things and put together various artifacts.
Perception involves scanning the surroundings with numerous sense organs, both real and artificial,
and decomposing the view into discrete objects in various spatial relationships. The fact that an
object can seem differently depending on the angle from which it is viewed, the direction and
intensity of illumination in the scene, and how much the object contrasts with the surrounding
field, makes analysis more difficult.
Artificial perception has progressed to the point that optical sensors can identify humans,
autonomous vehicles can drive at highway speeds, and robots can roam through buildings
collecting empty drink cans.

Language - understanding
Language can be defined as a collection of diverse system indications that use convention to justify
their means. Language understanding, which is one of the most extensively used artificial
intelligence components, employs distinct types of language across various forms of natural
meaning, as shown by overstatements.
Human English is one of the most important qualities of languages since it allows us to distinguish
between distinct items. Similarly, AI is designed in such a way that it can grasp English, the most
widely spoken human language. In this way, the platform enables computers to quickly
comprehend the many computer programmes that are run on them.
A language is a set of signs with predetermined meaning. Language does not have to be limited to
the spoken word in this sense. For example, traffic signs form a mini language, with "danger
ahead" being a matter of convention in some nations. The fact that linguistic units have meaning by
convention distinguishes languages from other languages, and linguistic meaning differs
significantly from natural meaning, as seen by expressions like "Those clouds signify rain" and
"The drop in pressure shows the valve is malfunctioning."

Q13) Write the Ai architecture?


A13) Today's architecture is a multi-skilled profession that draws on a variety of disciplines,
including structural and environmental engineering, as well as social and material sciences. We
have a long history of studying, adapting, and leveraging available technology to broaden and
strengthen our design capabilities at Foster + Partners. The Applied Research and Development
(ARD) team is at the forefront of this, having recently investigated the possibilities of employing
artificial intelligence (AI) in the creative process.
AI was created as an area of academic research in the 1950s, and it can be roughly characterized as
the development of machines that exhibit human intelligence and behaviors. It has been a hot issue
of discussion since its inception, frequently making headlines – both good and negative – and being
ingrained in popular culture and science fiction. Thankfully, AI has progressed with primarily
benevolent innovations: it can assist us in understanding and responding to human speech,
screening for breast cancer, developing robots and self-driving cars, or simply recommending films
to watch.
Many systems and processes must be perfected in order to accurately mimic human intelligence;
one example is the AI subset known as machine learning, which is defined as "the study of
computer algorithms that allow computer programmes to automatically improve through
experience" by computer scientist Tom Mitchell.

English mathematician and pioneer of computer science, Alan Turing, standing at the Ferranti
Mark 1 computer at the University of Manchester in 1951. The earliest successful AI program was
written by Christopher Strachey to play checkers, or draughts, and ran on the Ferranti Mark I
Machine learning has the ability to analyze our designs more rapidly and at a lower cost in the
context of architecture and design. The ARD team has been experimenting with two methods for
incorporating it into the design process, as well as some potentially innovative applications.
The first is surrogate modeling, which is a direct alternative for time-consuming analytical
engineering simulations (such as structural deformation, solar radiation, and pedestrian movement)
that might take hours or even days to complete.
Many architectural projects today are of immense scale and complexity, characterized by a diverse
array of overlapping talent and technologies. Machine learning may be able to assist us in this
diverse subject by allowing us to solve problems and find patterns that were previously dependant
on complex analytical simulations and programmes. Due to the time and effort required, design
optimization based on their findings has been almost difficult, weakening the value of these tools.
We need to give designers with results in near real-time to tackle this problem. As a result, the
ARD team looked into surrogate models, in which a computationally 'cheaper' predictive model is
built based on a set of carefully selected simulation results. The surrogate model's approximation of
a simulation in real-time can then provide the designer with results that are good enough for them
to make a swift decision.
We call the second – and more cutting-edge – field of ARD's machine learning research 'design aid'
modeling, and these systems have the ability to function alongside designers' intuition in the
creative process.
This is referred to as design-assistance modeling because it aids architectural processes for which
we do not always have an analytical solution – one that can be determined from simulations. This
could include optimizing the spatial layout of furniture within a space or providing designers with
real-time document control support while they work.

You might also like