Sie sind auf Seite 1von 36

Artificial Intelligence

Chapters Reviews
Readings:

Chapters 3-8 of Russell &


Norvig.

Topics covered in the midterm


Solving problems by searching (Chap. 3)
How to formulate a search problem?
How to measure a search strategy?
What are popular uninformed search strategies?
Informed search and exploration (Chap. 4)
What are the greedy best-first search and A*?
How to design and use a heuristic function?
What is local search? Hill-climbing? Simulated
annealing?
What are Genetic Algorithms?

Topics covered in the midterm


Adversarial Search
Whats the minimax algorithm?
Whats Alpha-Beta pruning?
Propositional Logic (Chap. 7.1-7.5)
What are its syntax and semantics?
Validity vs. satisfiability?
How to obtain CNF?
Whats the truth-table inference system?
Whats the inference rule system?
Whats resolution and its property?

Topics covered in the midterm


Propositional Satisfiability (SAT) (Chap. 7.6)
How to formulate an instance of SAT?
Whats a backtracking search?
Whats DIMACS CNF format?
How to use local search for SAT?
First-order Logic (Chap. 8)
What are its syntax and semantics?
What are quantifiers and their meaning?
Whats a model of a FOL sentence?
How to use FOL to describe assertions and queries?

Topics covered in the midterm


Inference in First Order Logic (Chap. 9)
What is unification and how to do it?
Whats resolution?
How to use resolution to prove a theorem?
What is Prolog?
What is the syntax for a Prolog program?
What kind of resolution strategies in Prolog?

A Technicality
The resolution rule alone is not complete.

z
}|
{ z
}|
{
For example, the set {P (x) P (y), P (x) P (y)} is
unsatisfiable.

But all we can do is start with


P (x) P (y)
P (x) P (y)
P (y) P (y)
{z
}
|

But then, resolving with , or with leads nowhere.


(try it!)

Factors
Let be a CNF sentence of the form below where
1 2 are both positive (or negative) literals
1 2

If 1 , 2 unify with mgu then


(1 )

is a factor of .
Example: P (x) is a factor of P (x) P (y) because
P (x), P (y) unify with mgu = {y/x}

Too Many Choices!


A resolution-based inference system has just one rule
to apply to build a proof.
However, at any step there may be several possible
ways to apply the resolution rule.
~P \/ Q

~P \/ R

~Q \/ R

False

~R
~Q

~P

Several resolution strategies have been developed in


order to reduce the search space.

~P

Some Resolution Strategies


Unit resolution:

Unit resolution only.

Input resolution:

One of the two clauses must be an input

clause.
Set of support:

One of the two clauses must be from a


designed set called set of support. New resolvent are
added into the set of support.
The latest resolvent must be used in the
current resolution.
Linear resolution

The first 3 strategies above are incomplete.


The Unit resolution strategy is equivalent to the Input
resolution strategy: a proof in one strategy can be
converted into a proof in the other strategy.

Note:

Search Trees in Prolog


A search tree is representation of all possible computation paths. All
possible proofs of a query are represented in one search tree.
Consider, for example, the following program.
member(X,[X|Ys]).
member(X,[Y|Ys]) :- member(X,Ys).

The following is a search tree for the goal member(a,[a,b,a]).


member(a,[a,b,a])
/
\
succ
member(a,[b,a])
/
\
fail
member(a, [a])
/
\
succ
member(a, [])
/ \
fail
fail

Traversing Search Tree


Prolog traverses a search tree in a depth-first manner.
We may not find a proof even if one exists, because depth-first
search is an incomplete search procedure.
The order of clauses and the order of literals in a clause decide the
structure of the search tree.
Different goal orders result in search trees with different structures.
Consider the following example
q(a).
p(s(Y)) :- p(Y).

The results for query p(X), q(X) and query q(X), p(X) are quite
different.
Changes in rule order permutes the branches of the search tree.
When writing Prolog program, make sure a successful path in the
search tree appears before any infinite search tree path.

Unification in Prolog
A query ?- test. will succeed for the following
program:
less(X,succ(X)).
test :- less(Y,Y).

Why? This because Prolog uses an unsound unification


algorithm: The occur check is omitted for the purpose of
efficiency.
occur check:

If v =? t and v occurs in t, then failure.

Another Example: An infinite loop for the query test.


test :- leq(Y,Y).
leq(X,s(X)) :- leq(X,X).

Resolution Strategies in Prolog


Set of support: The query (negative clauses) is the only
clause in the set of support.
Input strategy: One of the two clauses must be an input
clause.
Linear strategy: Only one resolvent is saved at any time.
The literals in the resolvent is organized as a stack:
First In, Last Out.
The clauses are treated in the order they are listed.
The literals in one clause are treated in the order from
left to right.
Note: The first three strategies are equivalent for Horn
clauses.

Exercise Problems
Chap. 3: 1, 3, 6, 7, 9, 11, 13, 17.
Chap. 4: 2, 3, 4, 9, 11, 12, 15.
Chap. 6: 2, 3, 15.
Chap. 7: 3, 4, 5, 6, 8, 12.
Chap. 8: 2, 3, 4, 6, 7, 8, 10, 11, 15

Exercise 3.1
Define in your own words the following items: state, state
space, search tree, search node, action, successor
function, and branching factor.

Exercise 3.1
State: A condition of (a problem or an agent) being in a
stage or form
State space: A collection of all states
Action: An act which causes a state to change to
another state, called successor.
Successor function: returns all the successors of a state
Branching factor: The maximum number of successors
of any state
Search tree: A graphical representation of the order of
successors explored from the initial state.
Search node: A node in the search tree which contains
the information of a state and its location in the tree.

Exercise 3.3
Suppose that L EGAL -ACTION(s) denotes the set of actions
that are legal in state s, and R ESULT(a, s) denotes the state
that results from performing a legal action a in state s.
Define S UCCESSOR -F N in terms of L EGAL -ACTIONS and R ESULT,
and vice versa.

Exercise 3.3
Suppose that L EGAL -ACTION(s) denotes the set of actions
that are legal in state s, and R ESULT(a, s) denotes the state
that results from performing a legal action a in state s.
Define S UCCESSOR -F N in terms of L EGAL -ACTIONS and R ESULT,
and vice versa.
S UCCESSOR -F N(s)

= { R ESULT(a, s) | a L EGAL -ACTIONS(s) }

L EGAL -ACTIONS(s) = {a | R ESULT(a, s) S UCCESSOR -F N(s)

Exercise 3.6
Does a finite state space always lead to a finite search
tree? How about a finite state space that is a tree? Can you
be more precise about what types of state spaces always
lead to finite search trees?

Exercise 3.6
Does a finite state space always lead to a finite search
tree? No. Without checking duplicates in a path, a loop
may occur.
How about a finite state space that is a tree? Yes.
Can you be more precise about what types of state
spaces always lead to finite search trees? Acyclic
graphs of successor relations will always lead to finite
search trees. Finite state space with duplicate checking
in a path will always lead to finite search trees.

Exercise 3.7b
A 3-foot-tall monkey is in a room where some bananas are
suspended from the 8-foot ceiling. Hw would like to get the
bananas. The room contains two stackable, movable,
climbing 3-foot-high crates.
initial state
goal test
successor function
cost function

Exercise 3.7b
Initially, four objects, m (monkey), b (bananas), c1 (crate1),
c2 (crate2), are at four different locations l1 , l2 , l3 , and l4 , respectively.
We use (l1 , l2 , l3 , l4 ) as the initial state.
initial state:

To get bananas, crate2 must be at location l2 ; crate1 must


be on top of crate2 (c2 ); monkey must be on top of crate1 (c1 ). That
is, the goal state is (c1 , l2 , c2 , l2 ). Switching crate1 and crate2, we
have another goal state: (c2 , l2 , l2 , c1 ).
goal test:

successor function:

There are many.

1. s((l1 , l2 , l3 , l4 )) = {(l2 , l2 , l3 , l4 ), (l3 , l2 , l3 , l4 ), (l4 , l2 , l3 , l4 )}


2. s((l3 , l2 , l3 , l4 )) = {(l2 , l2 , l2 , l4 ), ...}
3. s((l2 , l2 , l2 , l4 )) = {(l4 , l2 , l2 , l4 ), ...}
4. s((l4 , l2 , l2 , l4 )) = {(l2 , l2 , l2 , l2 ), ...}
5. s((l2 , l2 , l2 , l2 )) = {(l2 , l2 , c2 , l2 ), ...}
6. ...
cost function:

1 for each action.

Exercise 3.9
The missionaries and cannibals problem is usually stated as
follows. Three missionaries and three cannibals are on one
side of a river, along with a boat that can hold one or two
people. Find a way to get everyone to the other side,
without ever leaving a group of missionaries in one
placeoutnumered by the cannibals in that place.
a. Formulate the problem precisely, making only those
distinctions necessary to ensure a valid solution.
...

Exercise 3.9a
states: {hb, m, ci | b {0, 1}, 0 m 3, 0 c

3,

(m = c m {0, 1})}

initial state: h1, 3, 3i


goal test: h0, 0, 0i
successor function:

There are not many.

a solution: h1, 3, 3i h0, 3, 1i h1, 3, 2i h0, 3, 0i

h1, 3, 1i h0, 1, 1i h1, 2, 2i h0, 0, 2i h1, 0, 3i


h0, 0, 1i h1, 0, 2i h0, 0, 0i

Exercise 3.11
iterative lengthening search
a

Show that this algorithm is optimal for general path


costs.

How many iterations for solution depth d and unit step


costs?

If the minumum possible cost is , how many iterations


are required in the worst case?

...

Exercise 3.13
Describe a state space in which iterative deepening search
performs much worse than depth-first search (for example,
O(n2 ) vs. O(n)).

Exercise 3.17
Let us consider that actions can have negative costs.
a

If the negative costs are arbitrarily large, explain why


this will force any optiomal algorithms to explore the
entire state space.

Does it help if we know the negative costs are not


smaller than a negative constant c?

...

...

...

Exercise 4.2
The heuristic path algorithm is a best-first search in which the
objectiv e function is f (n) = (2 w)g(n) + wh(n). for what
values of w is this algorithm guaranteed to be optimal?
What kind of search does this perform when w = 0? When
w = 1? When w = 2?

Exercise 4.3
Prove each of the following statements:
a

Breadth-first search is a special case of uniform-cost


search.

Breadth-first search, depth-first search, and


uniform-cost search are special cases of best-first
search.

Uniform-cost search is a special case of A search.

Exercise 4.4
Devise a state space in which A using G RAPTH -S EARCH
returns a suboptiomal solution with an h(n) function that is
admissible but inconsistent.

Exercise 4.9
One of the relaxatio of the 8-puzzle in which a tile can move
from square A to square B if B is blank. Explain why this
heuristic is at least as accurate as h1 (misplaced tiles), and
show cases where it is more accurate than both h1 and h2
(Manhattan distance).

Exercise 4.11
Give the name of the algorithm that results from each of the
following special cases:
a

Local beam search with k = 1.

Local beam search with k = .

Simulated annealing with T = 0 (supposing no


termination) at all times.

Genetic algorithm with population size N = 1.

Exercise 4.12
Sometimes there is no good evalution function for a
problem, but there is a good comparison method: a way to
tell whether one node is better than another, without
assigning numerical values to either. Show that this is
enough to do a best-first search. Is there an analog of A ?

Exercise 4.15a
Devise a hill-climbing approach to solve TSP.

Exercise 6.3
Draw the complete game tree:
Write each state as (sA , sB ) where sA and sB denote the
token locations.
Put each terminal state in square boxes and write its
game value in a circle.
Put loop states (states that already appear on the path
to the root) in double square boxes.

Exercise 6.15
Describe how the minimax and alpha-beta algorithms
change for two-player, non-zero-sum games in which each
player has his or her own utility function. You may assume
that each player knows the others utility function. Is it
possible for any node to be pruned by alpha-beta?

Das könnte Ihnen auch gefallen