Ai - ML Module1 Final
Ai - ML Module1 Final
To impart high quality education in Engineering, Technology and Management with a difference, enabling
students to excel in their career by
1. Attracting quality Students and preparing them with a strong foundation in fundamentals so as to
achievedistinctions in various walks of life leading to outstanding contributions.
2. Imparting value based, need based, and choice based and skill based professional education to the
aspiringyouth and carving them into disciplined, World class Professionals with social responsibility.
3. Promoting excellence in Teaching, Research and Consultancy that galvanizes academic consciousness
among Faculty and Students.
4. Exposing Students to emerging frontiers of knowledge in various domains and make them suitable
forIndustry, Entrepreneurship, Higher studies, and Research & Development.
5. Providing freedom of action and choice for all the Stake holders with better visibility.
Imparting high quality education in the area of Information Science so as to graduate the students
with good fundamentals, "Information System Integration", "Software Creation" capability & suitably train
them to thrive in Industries, higher schools of learning and R & D centers with a comprehensive
perspective.
• PSO1 – Problem Solving Abilities: Ability to demonstrate the fundamental and theoretical concepts,
analyze the real time problems and develop customized software solutions by applying the
knowledge of mathematics and algorithmic techniques.
• PSO2 – Applied Engineering Skills: Enable creative thinking, Ability to apply standard practices and
strategies, technical skills in software design, development, integration of systems and management
forimproving the security, reliability and survivability of the infrastructure.
• PSO3 – General Expertise and Higher Learning: Ability to exchange knowledge effectively
demonstrate the ability of team work, documentation skills, professional ethics, entrepreneurial skills
and continuing higher education in the field of Information technology.
✓ Mundane Tasks
– Perception
• Vision
• Speech
– Natural Languages
• Understanding
• Generation
• Translation
– Common sense reasoning
– Robot Control
✓ Formal Tasks
– Games Playing
• Chess
• Backgammon
• Checkers - Go
– Mathematics
• Geometry
• Logic
• Integral calculus
• Theorem Proving
• General Problem Solving
✓ Expert Tasks (require specialized skills and training)
SDV, SGN,PR, Dept. of ISE, RNSIT 2022-2023 Page 5
ARTIFICIAL INTELLIGENCE & MACHINE LEARNING (18CS71)
– Engineering
• Design
• Fault finding
• Manufacturing planning
– Scientific Analysis
– Medical Diagnosis
– Financial Analysis
Note: AI is concerned with automating both Mundane and Expert tasks
The heart of research in artificial intelligence lies what Newell and Simon [1976] call the physical
symbol system hypothesis. They define a Physical symbol system as follows:
✓ A physical symbol system consist of a set of entities called symbols, which are physical
patterns that can occur as components of another type of entity called an expression or symbol
structure. Thus, a symbol structure is composed of a number of instances or tokens of symbols
related in some physical way. At any instant of time the system will contain a collection of these
symbol structures.
✓ In addition to these structures, the system also contains a collection of processes that operate on
expressions to produce other expressions: processes of creation, modification, reproduction
and destruction. A physical symbol system is a machine that produces through time, an
evolving collection of symbol structures.
✓ The physical Symbol System Hypothesis can be stated as – A physical symbol system has the
necessary and sufficient means for general intelligent action.
✓ The truth of this hypothesis can be determined only by experimentation. Computers provide
the perfect medium for this experimentation since they can be programmed to simulate any
physical symbol system. This ability of computers to serve as arbitrary symbol manipulators was
noticed very early in the history of computing by Lady Lovelace about Babbage’s proposed
Analytical Engine in 1842.
✓ The operating mechanism can even be thrown into action independently of any object to operate
upon. As it has become increasingly easy to build computing machines, so it has become
increasingly possible to conduct empirical investigations of the physical symbol system
hypothesis. In each such investigation, a particular task that might be regarded as requiring
intelligence is selected. A program to perform the task is proposed and then tested. We have not
been completely successful at creating programs that perform all the selected tasks.
✓ Evidence in support of the physical symbol system hypothesis has come not only from areas such
as game playing, but also from areas such as visual perception, where it is more tempting to
suspect the influence of sub-symbolic processes. However, sub-symbolic models such as neural
networks are beginning to challenge symbolic ones at such low-level tasks.
Artificial intelligence problems span a very broad spectrum. There are techniques that are appropriate for
the solution of a variety of these problems.
One of the few hard and fast results to come out of the first three decades of AI research is that
intelligence requires knowledge. The knowledge possesses some properties as follows:
✓ It is voluminous
✓ It is hard to characterize accurately
✓ It is constantly changing
✓ It differs from data being organized in a way that corresponds to the ways it will be used
Here, it is concluded that an AI technique is a method that exploits knowledge that should be
represented in such a way that:
✓ The knowledge captures generalizations means that, it is not necessary to represent separately
each individual situation. Instead, situations that share important properties are grouped together.
If knowledge does not have this property, excessive amounts of memory and updating will be
require, then called as data rather than knowledge.
✓ It can be understood by people who must provide it. Although for many programs, the bulk of the
data can be acquired automatically, for example by taking readings from a variety of instruments.
✓ It can easily be modified to correct errors and to reflect changes in the world and in our world
view.
✓ It can be used in many situations even if it is not totally accurate or complete.
✓ It can be used to help overcome its own complete volume by helping to narrow the range of
possibilities.
Although AI techniques must be designed in keeping with these constraints imposed by Al problems, there
is some degree of independence between problems and problem-solving techniques. It is possible to solve Al
problems without using AI techniques and it is possible to apply AI techniques to the solution of non-Al
problems.
Here, presented a series of three programs to play tic-tac-toe. The programs in this series increase in:
Data Structures:
Board A nine-element vector representing the board, where the elements of the vector correspond
to the board positions as follows:
1 2 3
4 5 6
7 8 9
An element contains the value 0 if the corresponding square is blank. 1 if it is filled with
an X, or 2 if it is filled with an O.
Movetable A large vector of 19,683 elements (39 ), each element of which is a nine-element vector.
The contents of this-vector are chosen specifically to allow the algorithm to work.
1. View the vector Board as a ternary (base three) number. Convert it to a decimal number.
2. Use the number computed in step 1 as an index into Movetable and access the vector stored
there.
3. The vector selected in step 2 represents the way the board will look after the move that should be
made. So set Board equal to that vector.
Comments:
This program is very efficient in terms of time. And, in theory, it could play an optimal game of tic-tac-
toe. But it has several disadvantages:
Program 2
Data Structures:
Board A nine-element vector representing the board, as described for Program 1. But instead of
using the numbers 0, 1 or 2 in each element, we store 2 is blank, 3 for X and 5 for O.
Turn An integer indicating which move of the game is about to be played; 1 indicates the first
move, 9 the last.
Make 2 Returns 5 if the center square of the board is blank, that is, if Board [5] = 2. Otherwise,
this function returns any blank Noncorner Square – 2, 4, 6, or 8.
Posswin (p) Returns 0 if player p cannot win on his next move; otherwise, it returns the number of the
square that constitutes a winning move. This function will enable the program both to win
and to block the opponent's win. Posswin operates by checking, one at a time, each of the
rows, columns, and diagonals. Because of the way values are numbered it can test an entire
row/column/diagonal to see if it is a possible win by multiplying the values of its squares
together. If the product is 18 (3 x 3 x 2), then X can win (means one of the squares is
empty). If the product is 50 (5 x 5 x 2), then O can win (means one of the squares is
empty). If we find a winning row, we determine which element is blank, and return the
number of that square.
Go (n) Makes a move in square n. This procedure sets Board[n] to 3 if Turn is odd, or 5 if Turn
is even. It also increments Turn by one.
The algorithm has a built-in strategy for each move. It makes the odd-numbered moves if it is playing X, the
even-numbered moves if it is playing O. The strategy for each turn is as follows:
This program is identical to program 2 except for the one change in the representation of the board and is
as follows:
8 3 4
1 5 9
6 7 2
Data Structures
BoardPosition: A structure containing a nine-element vector representing the board, a list of board
positions that could result from the next move, and a number representing an estimate of how likely the
board position is to lead to an ultimate win for the player to move.
Algorithm:
To decide on the next move, look ahead at the board positions that result from each possible move. Decide
which position is best (as described below), make the move that leads to that position, and assign the rating of
that best move to the current position.
To decide which of a set of board positions is best, do the following for each of them:
1. See if it is a win. If so, call it the best by giving it the highest possible rating.
2. Otherwise, consider all the moves the opponent could make next. See which of them is worst for us
(by recursively calling this procedure). Assume the opponent will make that move. Whatever
rating that moves has, assign it to the node we are considering.
3. The best node is then the one with the highest rating.
This algorithm will look ahead at various sequences of moves in order to find a sequence that leads to a
win. It attempts to maximize the likelihood of winning, while assuming that the opponent will try to
minimize that likelihood. This algorithm is called the minimax procedure.
Here, programs that read in English text and then answer questions also stated in English, about that
text. This is more difficult to state formally and precisely what our problem is and what constitutes
correct solutions to it. For example, suppose that the input text were just the single sentence
Example 1:
Russia massed troops on the Czech border.
Then either of the following question-answering dialogues might occur with the POLITICS program:
Dialogue 2
Q: Why did Russia do this?
A: Because Russia wanted to increase its political influence over Czechoslovakia.
Q: What should the United States do?
A: The United States should denounce (condemn) the Russian action in the United Nations.
✓ In the POLITICS program, answers were constructed by considering both the input text and a separate
model of the beliefs and actions of various political entities, including Russia. When the model is changed,
the system’s answers also change.
✓ The general point here is that defining what it means to produce a correct answer to a question may be very
hard.
Example 2:
Mary went shopping for a new coat. She found a red one she really liked. When she got it home, she
discovered that it went perfectly with her favorite dress.
This program is to attempt to answer questions using the literal text. It simply matches text fragments in
the questions against the input text.
Data structures
Question patterns: A set of templates that match common question forms and produce patterns to be
used to match against inputs. Templates and patterns are paired so that if a template matches successfully
against an input question then its associated text patterns are used to try finding appropriate answers in
the text. For example, if the template “who did x y” matches an input question, then the text patterns “x,
y, z” is matched against the text and the value of z is given as the answer to the question.
Algorithm
To answer a question, do the following:
Answers:
Q1: The template “what did x y” matches this question and generates the text pattern “Mary go
shopping for z.” After the pattern-substitution step, this pattern is expanded to a set of patterns including
“Mary goes shopping for z,” and “Mary went shopping for z.” the latter pattern matches the input
text; the program, using a convention that variables match the longest possible string up to a sentence
delimiter (such as a period), assigns z the value, “a new coat,” which is given as the answer.
Q2: Unless the template set is very large, allowing for the insertion of the object of “find” between it and
the modifying phrase “that she liked,” the insertion of the word “really” in the text, and the substitution
of “she” for “Mary,” this question is hot answerable. If all of these variations are accounted for and the
question can be answered, then the response is “a red one”.
Q3: Since no answer to this question is contained in the text, no answer will be found.
Program 2
This program first converts the input text into a structured internal from that attempt to capture the
meaning of the sentences. It also converts questions into that form. It finds answers by matching
structured forms against each other.
Data structures
EnglishKnow: A description of the words, grammar, and appropriate semantic interpretations of a large
enough subset of English to account for the input texts that the system will see. This knowledge of
English is used both to map input sentences into an internal, meaning-oriented form and to map from
such internal forms back into English. The former process is used when English text is being read; the
latter is used to generate English answers from the meaning-oriented from that constitutes the program’s
knowledge base.
Structured Text A Structured representation of the content of the input text. This Structure attempts
to capture the essential Knowledge contained in the text, independently of the exact way that the
Knowledge was stated in English.
Event 2
StructQuestions A structured representation of the content of the user’s question. The structure
is the same as the one used to represent the content of the input text.
Algorithm:
Convert the input text into structured form using the Knowledge contained in English Know. This may
require considering several different potential structures, for a variety of reasons, including the fact that
English words can be ambiguous, English grammatical structures can be ambiguous, and pronouns may
have several possible antecedents. Then, to answer a question, do the following:
1. Convert the question to structured form, again using the Knowledge contained in English Know. Use
some special marker in the structure to indicate the part of the structure that should be returned as the
answer. This marker will often correspond to the occurrence of a question word (like “who” or
“what”) in the sentence. The exact way in which this marking gets done depends on the form chosen
for representing structured Text.
2. Match this structured form against Structured Text.
3. Return as the answer those parts of the text that match the requested segment of the question.
Answers:
Q1: This question is answered straightforwardly with, “a new coat”
Q2: This one also is answered successfully with, “a red coat”.
Q3: This one, though, cannot be answered, since there is no direct response to it in the text.
Program 3
This program converts the input text into a structured form that contains the meanings of the
sentences in the text, and then it combines that form with other structured forms that describe prior
knowledge about the objects and situations involved in the text. It answers questions using this
augmented knowledge structure.
World Model: A Structured representation of background world Knowledge. This structure contains
Knowledge about objects, actions and situations that are described in the input text. This Structure is
used to construct Integrated Text from the input text. For example, Figure below shows an example
of a Structure that represents the systems Knowledge about shopping. In the case of this text, for
example, M is a coat and M’ is a red coat. Branches in the figure describe alternative paths through
the script.
The Algorithm:
Convert the input Text into structured form using both the Knowledge contained in English Know
and that contained in world model. The number possible structures will usually be greater now than it
was in program 2 because so much more Knowledge is being used. Sometimes, though, it may be
possible to consider fewer possibilities by using the additional knowledge to filter the alternatives.
Shopping script:
Roles: C (customer), S (salesperson)
Props: M (merchandise), D (dollars)
Location: L (a store)
To answer a question, do the following:
1. Convert the question to structured form as in program 2 but use WorldModel necessary to resolve
any ambiguities that may arise.
2. Match this structured form against Integrated Text.
3. Return as the answer those parts of the text that match the requested segment of the question.
✓ Programs in the first class attempt to solve problems that do not really fit definition of an AI task.
They are problems that a computer cloud easily solves.
✓ Example is Elementary Perceiver and Memorizer (EPAM) [Feigenbaum, 1963], which
memorized associated pairs of nonsense syllables. Memorizing pairs of nonsense syllables is easy
for a computer. But this task is hard for people.
✓ The programs in the second class attempt to model human performance and are within AI
definitions. Reasons for this are:
• The following are the disciplines that contributed ideas, new points, and techniques to AI:
✓ Philosophy: (428BC- Present)
1. Can formal rules be used to draw valid conclusions?
2. How does the mental mind arise from a physical brain?
3. Where does knowledge come from?
4. How does knowledge lead to action?
✓ Mathematics
1. What are the formal rules to draw valid conclusions?
2. What can be computed?
3. How do we reason with uncertain information?
✓ Economics
1. How should we make decisions so as to maximize pay off?
2. How should we do this when others may not go along?
3. How should we do this when the pay off may be far in the feature?
✓ Neuroscience
How do brains process information?
✓ Psychology
How do humans and animals think & act?
✓ Computer Engineer
How can we an efficient as computer?
✓ Computer Theory and Cybernetics
How can computer operate under their own control?
✓ Linguistic
How does language relate to thought?
Note: The questions under each of the above foundations, shows that, what exactly their contributions
✓ The first work in AI was done by McCalloch and Pitts (1943), who proposed artificial neurons.
They worked on three sources:
1. Knowledge of the basic Physiology.
2. Functions of neurons in the brain.
3. A formal analysis of propositional logic and turing’s theory of computations.
✓ Later in 1949, Donald Hebb demonstrated a simple updating rule for modifying the
connection strengths between neurons, called Hebbbian Learning.
✓ First, will have some survey books: The broadest are the multi-volume handbook of artificial
intelligence [Barr et al.. 1981] and Encyclopedia of artificial intelligence [Shapiro and Eckroth,
1987], both of which contain articles on each of the major topics in the field.
✓ Four other books that provide good overviews of the field are artificial intelligence [Winston,
1984], introduction to artificial intelligence [Charniak and McDermott, 1985], Logical
Foundations of artificial intelligence [Genesereth and Nilsson, 1987], and The Elements of
artificial intelligence [Tanimoto, 1987] of more restricted scope is principles of artificial
intelligence [Nilsson, 1980], which contains a formal treatment of some general- purpose AI
techniques.
✓ Most the work conducted in AI has been originally reported in journal articles, conference
proceedings or technical reports. But some of the most interesting of these papers have later
appeared in special collections published as books. Computer and Thought [Feigenbaum and
Feldman, 1963] is a very early collection of this sort. Later ones include Simon and
Siklossy[1972], Schank and Colby [1973], Bobrow and Collins [1975], waterman and Hayes-
Roth[1978], Findler [1979],Webber and Nilsson [1981], Halpern[1986], Shrobe [1988], and
1. Define the problem precisely: This definition must include precise specifications of what the
initial situation (s) will be as well as what final situations constitute acceptable solutions to the
problem.
2. Analyze the problem: A few very important features can have an immense impact on the
appropriateness of various possible techniques for solving the problem.
3. Isolate and represent the task knowledge that is necessary to solve the problem.
4. Choose the best problem-solving technique(s) and apply it (them) to the particular problem.
Also think of: what knowledge is given (restrictions / constraints), knowledge to be assumed,
additional assumptions to be made and order of applying rules (control strategy).
Example Problems:
1. Playing Chess
✓ Each position can be described by an 8x8 array.
✓ Initial Position is the game opening position.
✓ Goal Position is any position in which the opponent does not have a legal move and his/her
king is under attack, (check made).
✓ Legal Moves can be described by a set of rules.
✓ Left side of the rule matched against the current state.
✓ Right side of the rule describes the new resulting state.
✓ State space is the set of legal positions.
✓ Starting at the initial state, using the set of rules to move from one state to another and
attempting to end up in a goal state is the procedure for solving problem.
Solution: objects water jugs (2) pump let ‘x’ represents amount of water in 4-litre jug ‘y’ 3 litre
jug.
➔ State represents pair (x,y) where x = 0, 1, 2, 3, or 4
y = 0, 1, 2, or 3
Note: Starting from (0, 0), search and loop until it reaches the goal state (2, 0). Apply a rule whose left
side matches the current state and set the new current state to be the resulting state.
Similarly, try for 6-litre and 8-litre jugs; indicate how 8-litre jug can be filled with 4 litre of water.
→ (0,0)
→ (6,0) separate all the rules & state space tree (Second Possible solution)
→ (0,6)
→ (6,6)
→ (4,8)
→ (4,0)
→ (0,4)
Additional Programs
3. Man –Tiger –Cow - Grass Problem [MTCG]
A man has a pet Tiger, a cow, and a bundle of grass with him. He wants the cross from one Bank (A) to
another Bank (B) of a river using a small boat that can hold him and any one of the remaining three. If
the man is not there, Tiger would eat cow, and similarly, the cow would eat the grass. Man does not want
to lose any of his possessions. Indicate how he can cross the river (BANK A to BANK B).
T/C/G/none
Meaning: Man transports the object in the boat from source to destination.
✓ One Possible Solution for MTCG problem using state space approach
Three married couples come to the river bank A. there is a boat on bank A that can carry at most two
persons. All the six persons want to cross the river and reach bank B using the boat, but there are certain
condition / restrictions to be observed and met.
Solution:
✓ Objects
1. 1 to 3 - married couples C1, C2, C3
✓ Knowledge Base
1. Boat can carry at most 2 persons
2. All the conditions / restrictions mentioned above.
Three Missionaries and three cannibals want to cross a river. There is a boat on their side of the river that
can be used by either one or two persons. How they cross the river?
Note: at any point of time, on either side of the river, number of cannibals should never be more than
missionaries. How can they all cross over without anyone being eaten?
Solution:
Bank-A Bank-B
✓ Knowledge given
1. Boat can carry at most two persons.
2. Any Person can row the boat
3. Number of cannibals should never be more than number of missionaries at any point of time on
either side of the river.
A hungry monkey finds himself in a room in which a bunch of bananas is hanging from the ceiling. The
monkey, unfortunately cannot reach the bananas. However, in the room there are also a chair and a stick.
The ceiling is just the right height so that a monkey standing on a chair could knock the bananas down
Solution:
Actions in sequence are:
1. The monkey reaches to the box.
2. Pushes the box under hanging bananas
3. Climbs on the box.
The state of the problem consists of representing the states by four elements (X, W, Y, and K)
Where X= horizontal position of monkey
W= Monkey’s position on the box, if yes w=1, not w=0
Y= horizontal position of box
K= grasp of bananas by monkey, if yes k=1, not k=0
Four operators govern the four possible actions
Go to (P): Monkey goes to horizontal position P
Push box (Q): Monkey pushes the box to horizontal position Q
Climb box ( ): Monkey climbs top of the box
Graph ( ): Monkey holds the bananas
P and Q are the variables to represent any position in the room for the monkey and box respectively.
State Action Result
The 8-puzzle problem consists of a 3x3 grid, which holds 8 movable tiles numbered as 1 to 8. One
square is empty, allowing the adjacent tiles to be shifted. The objective of the puzzle is to find a sequence
To be transformed
1 2 3 1 2 3
8 5 6
⟹ 4 5 6
4 7 7 8
Initial state / configuration (start) Goal state/configuration (Final)
Note: i) States of 8-puzzle are the different permutations of the tiles within the frame.
ii) An optimal solution is the one that maps an initial arrangement of tiles to the goal state
with the smallest number of moves.
iii) Root node can be any random starting state.
Solution:
States: Specifies the locations of each of the tiles and the blank in one of the nine squares.
Search Space: A tree that shows possible moves from an initial state.
A salesman has a list of cities, each of which he has to visit exactly once. There are roads between each
pair of cities on the list. i.e., n-cities with paths connecting the cities.
Find the route (tour) the salesman should follow for the shortest possible round trip that starts and ends at
any one of the cities.
Diagrammatically,
5
A B
2
2 3 1 4 E
3
C D
6
A B
2
2 1 3
E
C 3
Total Cost=2+1+2+3+3=11
Note:
The time to examine single path is proportional to N. So, the total time required to perform this search
is proportional to N!
For ex: N=10, means 10! i.e., 3,628,800 time units (large number)
✓ Since search forms the core of many intelligent process, it is useful to structure AI programs in a
way that facilities describing the search process. So, production systems provide the structure for
AI programs that makes searching process easy. i.e., production systems help in describing and
performing the search operation in AI programs.
✓ Advantages
• It models strong data-driven nature of intelligent action
• New rules can easily be added to take care of new situations without disturbing the rest of the
system
• Handling of changes in knowledge base is dynamic
• Helps in making inference mechanism easy.
Monotonic Non-Monotonic
Partially Ex: theorem Ex: Blocks world, 8-
commutative proving puzzle
Non-
Ex: chemical Ex: Bridge/cards
partially
Synthesis problem
commutative
✓ A Monotonic Production System: is one in which the application of a rule never prevents
the later application of another rule that could also have been applied at the time the first
rule was selected.
✓ A Non-Monotonic Production System: is a production system is one in which the above
statement is not true.
✓ A partially commutative production system: is a production system with the property
that if the application of a particulars sequence of rules transforms state ‘X’ into state ‘Y’
then any permutation of those rules that is allowable also transforms state ‘X’ into state
‘Y’. Partially commutative monotonic production systems are useful for solving
➔ Control Strategies
✓ Specifies what rule to be applied next and in what order / sequence during the search
process. There are many control Strategies exist uniformed search strategies like DFS,
BFS and informed / heuristic Strategies like Hill climbing, Backtracking, Branch and
Bound, Best first search etc.,.
✓ Two requirements for good control strategies are:
• They should cause motion, so that it lead to a solution
• They should be systematic, so that it lead to a solution
Ex: BFS and DFS strategies
✓ Depth-first Search requires less memory since only the nodes on the current path are stored.
This contract with breadth-first search, where all of the tree that has so far generated must be
stored- more Memory.
✓ Depth-first search may find a solution without examining much of the search space at all.
This contracts with breadth-first search in which all parts of the tree must be examined to
level n before any nodes on level n+1 can be examined.
✓ Breadth-first search will not get trapped exploring a blind alley (path). This contrast with
depth-first searching, which may follow a single unfruitful path for a very long time, before
the path actually terminates in a state that has no successors. This is a particular problem in
depth-first search if there are loops (i.e., a state has a successor that is also one of its
ancestors) unless special care is expended to test such a situation.
✓ If there is a solution, then breadth-first search is guaranteed to find it. Furthermore, if there
are multiple solutions, then a minimal solution i.e., one that requires the minimum number
of steps will be found. This is guaranteed by the fact that longer paths are never explored until
all shorter ones have already been examined. These contrasts with depth-first search, which
may find a long path to a solution in one part of the tree, when a shorter path exists in some
other, unexplored part of the tree.
A Salesman has a list of cities, each of which he must visit exactly once. There are direct
roads between each pair of cities on the list. Find the route the Salesman should follow for the
shortest possible round trip that both starts and finishes at any one of the cities.
A simple, motion-causing and systematic control structure could, in principle, solve this
problem. It would simply explore all possible paths in the tree and return the one with the
shortest length. This approach will work in practice for very short lists of cities. But it breaks
down quickly as the number of cities grows. If there are N cities, then the number of
different paths among them is 1.2… (N-1), or (N-1)! . The time to examine a single path is
proportional to N. So the total time required to perform this search is proportional to N! .
Assuming there are only 10 cities, 10! is 3,628,800, which is a very large number. The
➔ Heuristic Search
✓ A Heuristic function is a function that maps from problem state description to measures of
desirability, usually represented as numbers.
✓ Improves the efficiency of a search process and always finds a very goal solution for hard
problems.
✓ In general, it points in interesting directions.
✓ Like tour guides, helps to guide a search process. Ex: nearest Neighbor Heuristic
✓ Well designed Heuristic functions can play an important part in efficiently guiding a search
process toward a solution.
✓ Sometimes very simple Heuristic functions can provide a fairly good estimate of whether a
path is good or not. In other situations, more complex Heuristic functions should be
employed.
Note:
In order to choose the most appropriate method for a particular problem, it is necessary to analyze the
problem along several key dimensions / Characteristics:
1. Is the problem Decomposable into a set of independent smaller and/or easier sub problem? (D)
2. Can solution steps be Ignored or at least undone if they prove unwise? (I)
3. Is the problem’s universe Predictable? [predictability (P)]
4. Is a good solution to the problem obvious without comparison to all other possible solutions?
[Comparability ( C )]
5. Is the desired solution a state of the world OR a path to a state? (R)
6. Is a large amount of knowledge absolutely required to solve the problem, OR is knowledge
important only to constrain the search? [knowledge based consistency (C )]
7. Can a computer that is simply given the problem return the solution, or will the solution of the
problem require interaction between the computer and a person? [ Interactions (I) ]
Now consider a Simple Blocks World Problem illustrated below. This problem is drawn from the
domain often referred to in AI literature as the blocks world. Assume that the following operators
are available:
1. CLEAR (x) [block x has nothing on it] → ON (x Table) [pick up x and put it on the
table]
2. CLEAR (x) and CLEAR (y) → ON (x, y) [put x on y]
Start: Goal:
A
B
C
C
A B
Applying the technique of problem decomposition to this simple blocks world example, would
lead to a solution tree as shown in Figure below. In the figure, goals are underlined. States that
have been achieved are not underlined. The idea of this solution is to reduce the problem of
getting B on C and A on B to two separate problems. The first of these new problems, getting B on
C, is simple, given the start state. Simply put B on C. The second sub goal is not quite so simple.
ON (B, C) ON (A, B)
Example:
• Ignorable (e.g.., theorem proving), in which solution steps can be ignored
• Recoverable (e.g.., 8-puzzle), in which solution steps can be undone
• Irrecoverable (e.g.., chess), in which solution steps cannot be undone
These three definitions make reference to the steps of the solution to a problem and thus may
appear to characterize particular production system for solving a problem. This is true for each of
the problem used as examples above. When this is the case, it makes sense to view the
recoverability of a problem as equivalent to recoverability of a natural formulation of it.
The planning process can only be done effectively for certain-outcome. A few examples of such
problems are:
✓ Playing bridge: we can do fairly well since we have available accurate estimates of the
probabilities of each of the possible outcomes.
✓ Controlling a robot arm: The outcome is uncertain for a variety of reasons. Someone
might move something into the path of the arm. The gears of the arm might stick. A slight
error could cause the arm to knock over a whole stack of things.
✓ Helping a lawyer decide how to defend his client against a murder charge: Here we
probably cannot even list all the possible outcomes, much less assess their probabilities.
Examples:
In 8-puzzle problem → certain outcome
In bridge problem → uncertain outcome (cards)
In controlling a Robot arm → uncertain outcome
Since we are interested in the answer to the question, it does not matter which path we follow. If
we do follow one path successfully to the answer, there is no reason to go back and see if some
other path might also lead to a solution. These types of problems are called as “Any path
Problems”. Now consider the Travelling Salesman Problem. Our goal is to find the shortest path
route that visits each city exactly once
Suppose we find a path it may not be a solution to the problem. We also try all other paths. The
shortest path (best path) is called as a solution to the problem. These types of problems are known
as “Best path” problems. But path problems are computationally harder than any path problems.
For Example:
• Solitary problem, in which there is no intermediate communication and no demand for an
explanation of the reasoning process.
• Conversational problem, in which intermediate communication is to provide either additional
assistance to the computer or additional information to the user.
8. Problem Classification
There are several broad classes into which the problems may fall.
Example: In Diagnostic tasks, i.e. both in medical and fault diagnosis, we need to examine the
input and decide which of a set of known classes, the input is an instance of?
Every search process can be viewed as a traversal of a tree structure in which each node represent a
problem state and each arc represents a relationship between the states represented by the nodes it
connects. For example, Figure below shows part of a search tree for a water jug problem. The search
process must find a path or paths through the tree that connect an initial state with one or more
final states. The tree that must be searched could in principle, be constructed in it’s entirely from the
rules that define allowable moves in the problem space.
✓ The direction in which to conduct the search (forward versus backward reasoning).
✓ How to select applicable rules (matching). Production systems typically spend most of their
time looking for rules to apply, so it is critical to have efficient procedures for matching rules
against states.
✓ How to represent each node of the search process. For problems like chess, a node can be
fully represented by a simple array. In more complex problem solving, however, it is
inefficient and/or impossible to represent all of the facts in the world and to determine all of the
side effects an action may have.
1.12 GENERATE-AND-TEST-ALGORITHM
✓ It is a simple and exhaustive search method
Steps:
1. Generate a possible solution and solution is either to find a point or path in solution
space.
2. Test whether it is correct solution or not. If yes, return success and quit.
3. Otherwise, return to step 1
Disadvantages:
For example, consider the puzzle that consists of four six-sided cubes, with each side of each cube
painted one of four colors. A solution to the puzzle consists of an arrangement of the cubes in a row such
that on all four sides of the row one block face of each color is showing. This problem can be solved by a
person in several minutes by systematically and exhaustively trying all possibilities. It can be solved even
more quickly using a heuristic generate-and-test procedure.
Algorithm Steps:
1. Generate the first proposed solution (initial state). Evaluate the initial state. If it is a solution state
then return it and quit. Else continue with initiate state as the current state.
2. Loop until a solution state is found or until there are no new operators left to be applied in the
current state.
a) Select an operator that has not yet been applied to the current state and apply it to
produce a new state.
b) Evaluate the new state.
i. If it is a goal / solution state, then return it and quit.
ii. If it is not a goal state but it is better than the current state, then make it the current
state
iii. If it is not better than the current state, then continue in the loop.
For example, suppose you are in an unfamiliar city without a map and you want to get downtown. You
simply aim for the tall buildings. The heuristic function is just distance between the current location and
the location of the tall buildings and the desirable states are those in which this distance is minimized.
✓ A variation of simple hill climbing that considers all the moves from the current state and selects
the best one as the next state. This is also called as Gradient search. This contrasts with simple
method in which the first state that is better than current state is taken.
Algorithm Steps:
1. Generate and evaluate the initial state. If it is also a goal state, then return it and quit.
Otherwise, continue with the initial state as the current state.
2. Loop until a solution is found or until a complete iteration produces no change to
current state.
a) Let SUCC be a state such that any possible successor of the current state will be better
than SUCC.
b) for each operator that applies to the current state do:
i) Apply the operator and generate a new state.
ii) Evaluate the new state. If it is a goal state, then return it and quit. If not compare
it to SUCC. If it is better, then set SUCC to this state. If it is not better, leave
SUCC alone.
c) If the SUCC is better than current state, then set current state to SUCC.
Both basic and steepest-Ascent hill climbing may fail to find a solution. They may be terminated by
getting to a state from which no better states can be generated. This can happen, if the program has
reached a local maximum, a plateau, or a ridge.
Local: Add one point for every block that is resting on the thing it is supposed to be resting on.
Subtract one point for every block that is sitting on the wrong thing.
Global: For each block that has the correct support structure (i.e., the complete structure underneath
it is exactly as it should be), add one point for every block in the support structure. For each block that
has an incorrect support structure, subtract one point for every block in the existing support
structure.
Using this function, the goal state has the score 28 (1 for B, 2 for C, …. 7 for H) because all blocks have
correct support structure. The initial state has the score -28 (-1 for C, -2 for D, …. -7 for A, because no
blocks have correct support structure excluding B). Moving A to the table yields a state with a score of
-21 since A no longer have seven wrong blocks under it (-28-(-7)). The three states that can be
produced next now have the following scores: (a) -28, (b) -16 (-15+ (-1) for H), and (c) -15 (H is on
table now). This time, steepest-ascent hill climbing will choose move (c), which is the correct one. This
new heuristic function captures the two key aspects of this problem: incorrect structures are bad and
should be taken apart; and correct structures are good should be build up. As a result, the same hill
climbing procedure that failed with the earlier heuristic function now works perfectly.
• Simulated Annealing
✓ A variation of hill climbing in which, at the beginning of the process, some downhill moves may
be made. Here, an idea is to do enough exploration of the whole space early on, so that, the final
solution is relatively insensitive to the starting state. This may lower the chances of getting caught
at a local maximum, a plateau, or a ridge.
✓ Uses objective function in place of the term heuristic function. Here, attempt is made to
minimize rather than maximize the value of objective function. So it is valley descendent rather
than hill climbing.
✓ Maintains annealing schedule. The rate at which the system is cooled is called the annealing
schedule.
✓ Moves to worse states may be accepted.
✓ Maintains best state so far, so that, if the final state is worse than previous, then earlier state is
still available.
✓ Uses probability formula P = 𝒆−∆𝑬/𝑻 , Where ∆E = change in the value of objective function.
Simulated annealing as a computational processes patterned after the physical process of annealing, in
which physical substances such as metals are melted (i.e., raised to high energy levels) and then gradually
cooled until some solid state is reached. The goal of this process is to produce a minimal – energy final
state. Thus this process is one of valley descending in which the objective function is the energy level.
Physical substances usually move from higher energy configurations to lower ones, so the valley
descending occurs naturally, but there is some probability that a transition to a higher energy state will
occur. This probability is given by the function P1 = 𝒆−∆𝑬/𝑲𝑻
Where ∆E is the positive change in the energy level, T is the temperature, and K is Boltzmann’s
constant. Thus, in the physical valley descending that occurs during annealing, the probability of a large
uphill move is lower than the probability of a small one. Also, the probability that an uphill move will be
made decreases, as the temperature decreases. One way to characterize this process is that downhill
moves are allowed anytime. Large upward moves may occur early on, but as the process progress, only
relatively small upward moves are allowed until finally the process converges to a local minimum
configuration.
In the physical process, temperature is a well-defined notion, measured in standard units. The variable K
describes the correspondence between the units of temperature and the units of energy. Since, in the
analogous process, the units for both E and T are artificial, it makes sense to incorporate K into T,
selecting values for T that produce desirable behavior on the part of the algorithm. Thus we use the
revised probability formula P = 𝒆−∆𝑬/𝑻 . But we still need to choose a schedule of values for T - a
temperature.
Algorithm Steps:
1. Evaluate the initial state, if it is goal, return it and quit. Else, continue with current state.
2. Initialize BEST-SO-FAR to current state.
3. Initialize T according to annealing schedule.
4. Loop until solution is found, or there are no operators left to be applied in the current state.
a) Choose an operator which is not yet applied, apply it and produce a new state.
b) Evaluate new state, compute
∆E = (value of current) – (value of new state)
i) If new state is goal, return it and quit
ii) If it is not a goal state, but is better than current state, then make new state as current
state
iii) If it is not a better state, make it the current with probability P as defined above.
c) Revise T as necessary according to the annealing schedule.
5. Return BEST-SO-FAR, as the answer.
• OR- Graphs
✓ At each step of the best-first search process, we select the most promising of the nodes we have
generated so far. This is done by applying an appropriate heuristic function to each of them.
We then expand the chosen node by using the rules to generate its successors. If one of them is
a solution, we can quit. If not, all those new nodes are added to the set of nodes generated so
far. Again the most promising node is selected and the process continues.
✓ Figure below shows the beginning of a best-first search procedure. Initially, there is only one
node, so it will be expanded. Doing so generates three new nodes. The heuristic function,
which, in this example, is an estimate of the cost of getting to a solution from a given node, is
applied to each of these new nodes, since node D is the most promising, it is expanded next,
producing two successor nodes, E and F. But then the heuristic function is applied to them.
Now another path, that going through node B, looks more promising, so it is pursued,
generating nodes G and H. But again when these new nodes are evaluated they look less
promising than another path, so attention is returned to the path through D to E. E is then
expanded, yielding nodes I and J. At the next step, J will be expanded, since it is the most
promising. This process can continue until a solution is found.
• Introduction of A* Algorithm
✓ Proposed by Hart in 1972, is a combination of best-first and Branch-and-Bound methods along
with Dynamic Programming principle.
✓ Uses a heuristic or evaluation function f(x) to determine the order in which the search visits
nodes in the tree. For any node N, f(N) is defined as f(N)=g(N) + h(N), where ‘g’ is a measure of
the cost from starting node to N, i.e., sum of costs of the rules that were applied along the best
path to the current node. ‘h’ is an estimate of additional cost of getting from the current node N
to the goal node.
✓ Also called as OR graph / Tree search algorithm.
✓ A* Algorithm incrementally searches all the nodes staring from the start node until it finds the
shortest path to a goal node. Starting with a given node, the algorithm expands the node with the
lowest f(x) value.
A* Algorithm Steps
Now consider the situation shown in Figure (b) below. Again we expand B on the first step. On the
second step we again expand E. At the next step we expand F, and finally we generate G, for a solution
path of length 4. But suppose there is a direct path from D to a solution, giving a path of length 2. We
will never find it. By overestimating h(D), we make D look so bad that we may find some other, worse
solution without ever expanding D.
So, we cannot be guaranteed of finding the cheapest path solution unless we expand the entire graph
until all paths are longer than the best solution.
(a) (b)
• AGENDAS
An agenda is a list of tasks a system could perform. Associated with each task there are usually two
things: a list of reasons why the task is being proposed (often called justifications) and a rating
representing the overall weight of evidence suggesting that the task would be useful.
One important question that arises in agenda-driven systems is how to find the most promising
task on each cycle. One way to do this is- Maintain the agenda sorted by rating. When a new
task is created, insert it into the agenda in its proper place. When a task has its justifications
changed, re-compute its rating and move it to the correct place in the list.
An agenda-driven control structure is also useful if some tasks (or nodes) provide negative
evidence about the merits of other tasks (or nodes). This can be represented by justifications with
negative weightings. If these negative weightings are used, it may be important to check not only
for the possibility of moving a task to the head of the agenda but also of moving a top task to the
bottom if new, negative justifications appear.
Despite of difficulties, Agenda-driven control structures are very useful. They provide an
excellent way of integrating information from a variety of sources into one program since each
source simply adds tasks and justifications to the agenda. As AI programs become more complex
and their knowledge bases grow, this becomes a particularly significant advantage.
✓ Problem can be decomposed into smaller problems, all of which must then be solved.
✓ AND-OR graph (tree) is useful for representing the solution of problems that are decomposed.
✓ The decomposition generates arcs that we call AND arcs. One AND arc may point to many
number of successor nodes, all of which must be solved in order for the arc point to a solution.
✓ Best – First Search algorithm is not adequate for searching AND-OR graphs.
✓ This uses a value called FUTILITY (threshold cost).
Example:
✓ This process is illustrated in Figure below. Assume that the cost of all arcs is 1. At step 1, A is the
only node, so it is at the end of the current best path. It is expanded, yielding nodes B, C and D.
The arc to D is labeled as the most promising one emerging from A, since it costs 6 compared to
B and C, which costs 9. (Marked arcs are indicated in the Figure by arrows). In step 2, node
D is chosen for expansion. This process produces one new arc, the AND arc to E and F, with a
combined cost estimate of 10. So we update the f value of D to 10. Going back one level, we see
that this makes AND arc B-C better than the arc to D, so it is labeled as the current best path.
At step 3, we traverse that arc from A and discover the unexpanded nodes B and C. If we are
going to find a solution along this path, we will have to expand both B and C, and then choose to
explore B first. This generates two new arcs, the ones to G and to H. propagating their f values
backward, we update f of B to 6 (since that is the best we think we can do, which we can achieve
by going through G). This requires updating the cost of the AND arc B-C to 12 (6 + 4 + 2). After
doing that, the arc to D is again the better path from A, so we record that as the current best path
and either node E or node F will be chosen for expansion at step 4. This process continues until
either a solution is found or all paths have led to dead ends, indicating that there is no solution.
✓ Uses a graph, representing the part of the search graph that has been explicitly generated so far.
Each node in the graph will have pointers to immediate successors and procedures.
Algorithm Steps
1. Let graph G consists of only initial node, call it INIT node, and compute h (INIT).
2. Until INIT is labeled SOLVED or until INIT’s ‘h’ value becomes greater than FUTILITY,
repeat the following procedure.
a) Trace marked arcs from INIT & select for expansion, call this as NODE.
b) Generate SUCCESSORS of NODE, if none then assign FUTILITY as ‘h’ value of
NODE and this is not solvable. If SUCCESSORS, then call SUCCESSOR & do the
following.
i. Add SUCCESSOR to G.
ii. If SUCCESSOR is terminated, label as SOLVED and assign ‘h’ to zero.
iii. If SUCCESSOR is not a terminal node, compute ‘h’ value for it.
c) Propagate the newly discovered information up the graph G by doing the following:
Let ‘S’ be the set of of nodes marked SOLVED or whose ‘h’ values have been changed.
Initialize ‘S’ to NODE until S is empty. Repeat the following.
i. Select from ‘S’ a node whose descendent in G occurs in ‘S’. Call this as current
and remove it from ‘S’.
ii. Compute the cost from current, assign as current’s new ‘h’ value minimum.
iii. Mark best path of current by marking arc that had minimum cost.
iv. Mark current SOLVED, if all of nodes connected to it through the new labeled arc
have been labeled SOLVED.
v. If current marked SOLVED, or if cost of current changed, then its new status
propagated. So add all of the ancestors of current to S.
GRAPH
NT Q
WA
NSW
SA
✓ The goal is to assign colors to each region so that no neighboring regions have the same color.
✓ To formulate this as CSP, we need to define the variables representing the regions
▪ X= {WA, NT, Q, NSW, V, SA, T}
▪ The domain if the each variable is D𝑖 = {Red, Blue, Green}
• Cryptarithmetic Puzzles
✓ Each letter stands for a distinct digit: 0 to 9 only.
✓ The aim is to find a substitution of digits for letters such that the resulting sum is arithmetically
correct, with the added restriction that no leading zeroes are allowed.
Ex1: T W O
+T W O
FO U R
0+0=R+10.C1
C1+W+W1=U+10.C2
C2+T+T=0+10.C3
C3=F
F=1, → T ≠ 0, and T ≥ 5
T=5 → O=0 O≠0
T=6 → O=2, R=4, W=?
T=7 → O=4, R=8, W=3, U=6 one solution
S E N D
+ M O R E
M O N E Y
✓ Constraints
1. Values for letters: 0 to 9 only
2. No two letters should have the same value
3. Sum of the digits much be as shown in the problem.
✓ Initial state
✓ Carry: C4 C3 C2 C1
Solution
1. M=1, since two single digit numbers plus a carry cannot total more than 19.
2. S=8 or 9, since S+M+C3>9 and M=1, S+1+C3>9, so S+C3>8 and c3 is at most1.
3. O= ∅ , since S+M (1) +C3 (≤1) must be at least 10 to generate a carry and it can be at most 11.
But M is already 1, so O must be 0(zero).
4. N=E or E+1, depending on the C2 value. But N cannot have the same value as E, so, N=E+1 and
C2=1.
5. In order for C2 to be 1, the sum of N+R+C1 must be greater than 9. So, N+R must be greater than
8.
6. N+R cannot be greater than 18; even with a carry in, so, E cannot be 9.
At this point, let us assume that no more constraints can be generated. Then to make progress
from here, we must guess. Suppose E=2, (this occurs three times) N=3 (E+1) and R= 8 or 9 since
R +N(3)+C1 (1 or 0)= 2 or 12. But N is already 3, thus R+3+ (0 or 1) =12 and R=8 or 9.
→ 2+D=y or 2+D=10+y, from the sum in the right most column. Again assuming no further
constraints can be generated a guess is required for C1. Suppose that C1=1, then R=9 and 2+D=Y
Thus 8 or 9 is assigned to R or D or S
E=4 E=5
E=3 945 ? 9567
9347 1084 1 085
1083 1054 10652
1043
3. BASE 4. R O A D S 5. D O N A L D
+BALL + CROSS +GERALD
GAMES DANGER ROBERT
Constraints satisfaction is a search procedure that operates in a space of Constraint sets. The initial state
contains the constraints that are originally given in the problem description. A Goal State is any state
that has been constrained “enough”, where “enough” must be defined for each problem. For example,
for crypt arithmetic, enough means that each letter has been assigned a unique numeric value.
Constraint satisfaction is a two-step process. First, Constraints are discovered and propagated as far as
possible throughout the system. Then, if there is still not a solution, search begins. A guess about
something is made and added as a new Constraint. Propagation can then occur with this new Constraint,
and so forth.
1. Propagate available constraints. To do this, first set OPEN to the set of all objects that must have
values assigned to them in a complete solution. Then do until an inconsistency is detected or until
OPEN is empty:
a) Select an object OB from OPEN. Strengthen as much as possible the set of constraints that
apply to OB.
b) If this set is different from the set that was assigned the last time OB was examined or if this
is the first time OB has been examined, then add to OPEN all objects that share any
constraint with OB.
c) Remove OB from OPEN.
2. If the union of the constraints discovered above defines a solution, then quit and report the
solution.
3. If the union of the constraints discovered above defines contradiction, then return failure.
4. If neither of the above occurs, then it is necessary to make a guess at something in order to
proceed. To do this, loop until a solution is found or all possible solutions have been eliminated:
a) Select an object whose value is not yet determined and select a way of strengthening the
constraints on that object.
b) Recursively invoke constraint satisfaction with the current set of constraints augmented by the
strengthening constraint just selected.
1.17 MEANS-ENDS-ANALYSIS
✓ This process centers on the detection of differences between the current state and the goal
state. Once the difference is isolated, an operator that can reduce the difference can be found.
✓ The problem space of means-ends-Analysis has an initial state (object) and one or more goal
states (objects), a set of operators Ok with given pre-conditions for their applications and a
difference function that computes the difference between two states Si and Sj
Algorithm steps
✓ Compare the current state ‘Si’ and goal state ‘Sj’ compute the difference Dij.
1. Select an operator ok to reduce the difference Dij.
2. Apply the ok if possible. Otherwise, save the current state, create the subgoal and apply
means-ends-Analysis recursively to reduce the subgoal.
3. If the subgoal is solved, the saved state is restored and work is resumed on the original
problem.
Example 1: Consider a simple household robot domain. The available operators are shown in Figure
(a) below, along with their preconditions and results. Figure (b) shows the difference table that describes
when each of the operators is appropriate. Notice that sometimes there may be more than one operator
that can reduce a given difference and that a given operator may be able to reduce more than one
difference.
Suppose that the robot in this domain were given the problem of moving a desk with two things on it
from one room to another. The objects on top must also be moved. The main difference between the start
state and the goal state would be the location of the desk. To reduce this difference, either PUSH or
CARRY could be chosen. If CARRY is chosen first, its preconditions must be met. These results in two
more differences that must be reduced: the location of the robot and the size of the desk. The location
of the robot can be handled by applying WALK, but there are no operators that can change the size of an
object. So this path leads to a dead-end. Following the other branch, we attempt to apply PUSH. Figure
(c) shows the problem solver’s progress at this point. It has found a way of doing something useful. But it
is not yet in a position to do that thing. And the thing does not get it quite to the goal state. So now the
differences between A and B and between C and D must be reduced.
PUSH has four preconditions, two of which produce differences between the start and the goal states: the
robot must be at the desk, and the desk must be clear. Since the desk is already large, and the robot’s arm
is empty, those two preconditions can be ignored. The robot can be brought to the correct location by
using WALK. And the surface of the desk can be cleared by two uses of PICKUP. But after one
PICKUP, an attempt to do the second results in another difference – the arm must be empty.
PUTDOWN can be used to reduce that difference.
Example:
Initial state: R^ (~ p→ 𝑞)
Final state: (q ⋁ p) ^ R
Operators: 1. A ⋁ B ⟺ B ⋁ 𝐴
2. A→ 𝐵 ⟺ ~ A⋁B
3. A ⋀ B ⟺ 𝐵⋀𝐴
4. (A→ 𝐵) ⟺ ~ B → ~ A
Difference:
R ⋀ (~ p→ 𝑞)
(q ⋁ p) ^ R
Initial state: R^ (~ p→ 𝑞)
Apply A ⋀ B ⟺ 𝐵⋀ 𝐴
⟹ (~ p→ 𝑞) ^ R
Apply A→ 𝐵 ⟺ ~ A⋁B
⟹ (p⋁q) ^ R
Apply A⋁B ⟺ B ⋁ 𝐴
⟹ (q ⋁ p) ^ R goal state.
******************************************************