Next: Bibliography Up: A Selective Macro-learning Algorithm Previous: Appendix A. Applying PARAMETRIC

# Appendix B. The Efficiency of Solving NxN Puzzles by MICRO-HILLARY

This section contains a proof that a specific set of macros learned by MICRO-HILLARY is complete with respect to the heuristic function h defined in Table 19, and that a problem solver that uses these macros can solve any solvable NxN puzzle problem in O(N3) with a reasonable constant. The proof can be easily generalized to specify sufficient conditions for a set of macros to be complete.

Lemma 1   Let h be the heuristic function and B the set of basic operators defined in Table 19. Let sg be a goal state of NxN puzzle. Let be a puzzle state different from sg such that solvable(s,sg).
If , then there exists a basic operator such that h(o(s),sg) < h(s,sg).

Proof:
Let , and . The following basic operators will decrease the value of h:

 (4)

Table 20: The macro used for each of the conditions on the tile indices. The right column shows an example for a state before and after the macro application.
 jp=j0 d jp>jt lur jp

Lemma 2   Let h, B, sg and s be defined as in Lemma 1. Let M be the following set of macros:

Then the set M is a complete set of macros, i.e., there is always an operator such that h(o(s),sg) < h(s,sg).

Proof:
By Lemma 1, we need to prove only for the cases where . There are four possible cases. Tables 20 and 21 show which operator can be applied in each of the cases to decrease the value of h. To make the proof simpler, the tables assume N > 4.

Table 21: (Cont.) The macro used for each of the conditions on the tile indices. The right column shows an example for a state before and after the macro application.
 ip=i0 jp>jt r jp 1 lurrdluld j0 = 1 urdrulldrur ip=i0 jp>jt dllur uld llurdrrullldrrurd uldllurdrulldrrurd Unsolvable puzzle jp < jt l jp = jt uld

Theorem 1   Let h and M be defined as in Lemma 2. MICRO-HILLARY, using M, can solve any solvable NxN puzzle problem performing no more than 288N3-301N2 basic operator applications. The length of the solution is bounded by 50N3-66N2.

Proof:
By Lemma 2, we can move from each state to a state with a lower heuristic value. Therefore, after a finite number of states, we will reach the state s with h(s,sg)=0, which is the goal state. N2 tiles are moved into their goal location. The maximum distance of each tile from its goal location is 2(N-1). Each movement of a tile towards its goal location involves moving the blank tile to be adjacent to the next tile, and then using either a basic operator or a macro operator to advance the next tile. At the beginning of this operation the blank tile can be anywhere, so we need to advance it at most (N-1)+(N-2) times to bring it to distance 1 from the next tile. After that, for the remaining 2(N-1)-1 times, a macro operator can move the blank away from the next tile, but the distance will be at most 4 (this is a property of the specific M), so we will need to advance it at most 3 times to bring it next to the next tile. By Lemma 1, the blank tile can be brought to distance 1 using only basic operators. After bringing the empty tile next to the next tile, in the worst case, the algorithm may try all the 4 basic operators and all the macros (with a total length of 124) before finding the one that reduces the heuristic value. All this leads to the following bound on the total number of basic operators applied while solving a problem p using B and M:

N2[4((N-1)+(N-2)+3(2(N-1)-1))+2(N-1)(124+4)]=288N3-301N2

The maximal length of a macro is 18. Therefore, the length of a solution found by
MICRO-HILLARY is bounded by

We can use the same lemmas to prove that MICRO-HILLARY can solve any solvable problem in O(N3) even without learning simply by performing BFS search in each place where a macro is used in the original proof. However, instead of using 128 in the above formula, we will use 418 (18, the length of the longest macro, can be used as an upper bound on the depth of the search). This gives a bound of 137,438,953,504N3 - 137,438,953,520N2, which is about 477,218,588 times larger than the constant for MICRO-HILLARY after learning. While in the pure sense of computational complexity both bounds belong to the same complexity class, the huge constant makes this fact meaningless for any practical purpose.

Next: Bibliography Up: A Selective Macro-learning Algorithm Previous: Appendix A. Applying PARAMETRIC
Shaul Markovitch
1998-07-21