AI-UNIT-2 PPT
AI-UNIT-2 PPT
• Use a SEARCH STRATEGIES to determine the way of traveling down the hierarchy of the
search tree. HEURISTICS can be used to give weights or "costs" to the different paths
between nodes and help in the strategy decisions of which path to ultimately choose
Stochastic Search
• Adversarial search, or game-tree search, is a technique for analyzing
an adversarial game in order to try to determine who can win the
game and what moves the players should make in order to win.
Adversarial search is one of the oldest topics in Artificial Intelligence.
The original ideas for adversarial search were developed by Shannon
in 1950 and independently by Turing in 1951, in the context of the
game of chess—and their ideas still form the basis for the techniques
used today
Game playing:
• Good example for Stochastic search is Game playing.
• It is an interesting topic because:
one require intelligence
Logical thinking
Rational mind
Searching algorithms
• At the same time, we don’t know what the opponent choice and ideas
• It is a multi agent environment
• Game playing works on consistent values (utility factor)
• It is a space search so we use BFS and DFS
• In this depth is called ply
• How much the big is game tree the same amount of search is done
2-Person Games:
• Players: We call them Max and Min.
• Initial State: Includes board position and whose turn it is.
• Operators: These correspond to legal moves.
• Terminal Test: A test applied to a board position which
determines whether the game is over. In chess, for example, this
would be a checkmate or stalemate situation.
• Utility Function: A function which assigns a numeric value to a
terminal state. For example, in chess the outcome is win (+1),
lose (-1) or draw (0). Note that by convention, we always
measure utility relative to Max.
• Example: Tic-Tac-Toe
max
min
AO* Algorithm
• Best-first search is what the AO* algorithm does. The AO*
method divides any given difficult problem into a smaller group of
problems that are then resolved using the AND-OR graph concept.
AND OR graphs are specialized graphs that are used in problems that
can be divided into smaller problems. The AND side of the graph
represents a set of tasks that must be completed to achieve the main
goal, while the OR side of the graph represents different methods for
accomplishing the same main goal.
Working of AO* algorithm:
• The evaluation function in AO* looks like this:
f(n) = g(n) + h(n)
f(n) = Actual cost + Estimated cost
here,
f(n) = The actual cost of traversal.
g(n) = the cost from the initial node to the current node.
h(n) = estimated cost from the current node to the goal state.
• Game playing majorly works on 2 algorithms:
1 Minimax search
2 alpha Beta pruning
Minimax search
mainly works with the help of backtracking algorithm
Best move strategy is used
Max will try to maximize (best move)
Min will try to minimize (Worst move)
Minimax Search
1. Generate the whole game tree.
2. Apply the utility function to leaf nodes to get their values.
3. Use the utility of nodes at level n to derive the utility of nodes at
level n-1.
4. Continue backing up values towards the root (one layer at a
time).
5. Eventually the backed up values reach the top of the tree, at
which point Max chooses the move that yields the highest value.
This is called the minimax decision because it maximises the
utility for Max on the assumption that Min will play perfectly to
minimise it.
Basic Example 1
Example 2:
• Let us assume Max=- inf and Min=inf
Max move
(inf,3) --- 3
(3,2) ---- 2
(2,-1) ----- -1
(inf,1) --- 1
(1,0)---- 0
(0,2) ----- 0
(inf,5) ----- 5
(5,4) ----- 4
(4,1) ----- 1
(inf,7) ----min 7
(7,5) ----- min 5
Min move
(-inf,-1) --- -1
(-1,0) ---- 0
(-inf,1) ---- 1
(1,5)----- 5
Max Move
(Inf,0) ----- 0
(0,5) ------ 0
Example:3
• We have utility values -1,5,-2,-4,1,-1,2,4
• Now it is our turn to move
we choose best value or max value
• The next turn is opponent will
always choose which is worst for
Us (i.,e 1 st player)
Example :Tic-Tac-Toe (minimax)
• Properties of minimax:
Inference mechanism reads the environment and interprets the knowledge that
is represented in suitable language and act accordingly.
Not A
And
^ A^B
OR AVB
Implies A B
If and only if A B
P Q P Q
P P
T T T
T F F T F
F T F F T
F F T
If the roads are wet than it rains ????? -------- meaning less
Convert all the above statements into predicate logic (or) FOL?
Inference in FOL:
• This is used to deduce new facts or sentences from existing sentences
• By understanding FOL inference rules let us understand some basic
terminology used:
Substitution:
It is a fundamental operation performed on terms and formulae's
Equality:
It not only uses predicate ,terms for creating or making atomic
sentences but also uses equality
Example:
Brother(john)=smith
~(x=y) equivalent to x!=y
Inference rules for quantifiers
• Universal Generalization
• Universal Instantiation
• Existential Instantiation
• Existential Introduction
• Universal Generalization:
It is a valid inference rule which states that if premises p(c) is true for
any arbitrary element ‘C’ in the universe of discourse, then (x) p(x)
can be represented as,
P(c)
(x) p(x)
• Universal Instantiation:
It is also called as universal elimination, can be applied multiple times
to add new sentence.
(x) p(x)
P(c)
• Existential Instantiation:
It is also called as existential elimination which can be applied only once
to replace the existential sentence.
x p(x)
p(c)
• Existential Introduction:
It states that if there is some element ‘c’ in the universe of discourse,
which has a property ‘p’
P(c)
x p(x)
• Example1: 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.
• Example:2.IF "Every person like ice-cream"=> ∀x P(x) so we can infer
that "John likes ice-cream" => P(c)
• Example 3: 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.
• Example 4: Let's say that,
"Priyanka got good marks in English."
"Therefore, someone got good marks in English."
Resolution in FOL:
• It is defined as a theorem proven technique which proves by contradiction.
• It is used when there are various statements, then read to prove conclusion
of those statements.
• Unification is the key concept which proves the conclusion of those
statements.
• Resolution is a single inference rule which can be efficiently operated on
Horn clause and definite clause (conjunction normal form and clausal
form )
Clause: Disjunction of literals
Conjunctive Normal Form: A sentence represented as a conjunction of
clauses said to be CNF
Steps for resolution:
• Conversion of Sentence into FOL
• Convert FOL statement into CNF
• Negate the statement which needs to prove (by contradiction)
• Draw resolution graph (unification).
Example:
John likes all kind of food
Apple and vegetables are food
Anything anyone eats and not killed his food
Anil eats peanut and still alive
Harry eats everything that anil eats
Prove by resolution that --- John like peanuts
Step 1: Convert the given into FOL
• Step 2: Conversion of FOL into CNF
(i) Eliminate all implications and rewrite
(ii) Move negation inside and rewrite
• (iii) Rename or standardize variable
• (iv) Eliminate any Existential instantiation quantifiers in the
statements:
No problem because in any of statement there is no existential
quantifier
• (v) Drop universal quantifiers
Step3: Negate the statement to be proved
In this we consider or apply negation to the conclusion statement i.e.,
it is represented as
~ likes(john, peanuts)
Problem :Prove IF A and B are true then D is true (IF A and B then D)