A new perspective of paramodulation complexity by solving massive 8 puzzles
aa r X i v : . [ c s . CC ] D ec A new perspective of paramodulation complexity bysolving massive 8 puzzles
Ruo Ando
National Institute of Informatics2-1-2 Hitotsubashi, Chiyoda-ku, Tokyo101-8430 Japan
Yoshiyasu Takefuji
Keio University5322 Endo Fujisawa, Kanagawa252-0882 Japan
Abstract —A sliding puzzle is a combination puzzle where aplayer slide pieces along certain routes on a board to reacha certain end-configuration. In this paper, we propose a novelmeasurement of complexity of massive sliding puzzles withparamodulation which is an inference method of automatedreasoning. It turned out that by counting the number of clausesyielded with paramodulation, we can evaluate the difficulty ofeach puzzle. In experiment, we have generated 100 * 8 puzzleswhich passed the solvability checking by countering inversions.By doing this, we can distinguish the complexity of 8 puzzles withthe number of generated with paramodulation. For example,board [2,3,6,1,7,8,5,4, hole] is the easiest with score 3008 andboard [6,5,8,7,4,3,2,1, hole] is the most difficult with score 48653.Besides, we have succeeded to obverse several layers of complexity(the number of clauses generated) in 100 puzzles. We canconclude that proposal method can provide a new perspectiveof paramodulation complexity concerning sliding block puzzles.
I. I
NTRODUCTION
A sliding puzzle (also called as sliding block puzzle) is acombination puzzle where a player slide pieces along certainroutes on a board to reach a certain end-configuration (state).The pieces are usually numbered, and sometimes may beimprinted with colors, patterns and sections of a large picture.In nature, sliding puzzles are two-dimensional even if thesliding is facilitated by encaged marbles or three-dimensionaltokens.
Fig. 1. Initial state and goal state of 8 puzzle.
In sliding puzzles, a player is prohibited to lift any piece offthe board. This constraint separates sliding puzzles from rear-rangement puzzles. Consequently, discovering routes openedup by each move with the two-dimensional confines of theboard is interesting point of solving sliding block puzzles. Figure 1 shows the example of sliding puzzle. The puzzlehas 9 square slots on a square board. The first 8 slots havesquare pieces. The 9th slot is empty.Historically, Noyes Chapman invented the oldest type ofsliding puzzle which is the fifteen puzzle in 1880. Folkloretells us that in 1886, puzzle master Sam Loyd offered a one-thousand dollar prize if anyone could swap tile 14 and 15 andreturn the other tiles to their original slots.Sliding block can be represented as the permutation. Apermutation of a set S is a bijection from S onto itself. Ifthe set we permuting is A = 1 , , ..., n , it is often convenientto represent a permutation σ as follows: σ = (cid:26) , , , ...σ (1) , σ (2) , σ (3) , ..., σ ( n ) (cid:27) (1)For instance, consider the set A = 1,2,3,4,5,6. Then thepermutation π , π = (cid:26) , , , , , , , , , , (cid:27) (2)sends 1 to 4, 2 to 1, 3 to 5 and fixes, or leaves unchanged,the element 6. II. OTTER A. OTTER and its clause sets
The theorem prover OTTER (Organized Techniques forTheorem-proving and Effective Research) has been developedby W. McCune as a product of Argonne National Laboratory.OTTER is based on earlier work by E. Lusk, R. Overbeekand others [12]. By the research efforts of [8] [9] [11] forcertain classes of problem, OTTER is widely regarded as themost powerful automated deduction system. OTTER adoptsthe given-clause algorithm and implements the set of supportstrategy [13].In given-clause algorithm, all retained clauses are dividedinto two sets. The first sets are called as the set of support(SoS). OTTER starts with the retention of a set of supportincluding all of the choses input clauses. During the run, theinitial set of support and the clauses which are generated areretained. The second set is the usable list. At beginning phaseof reasoning, the usable list is not included into the initial setf support. The usable list are the clauses which were once inthe set of support but have been already picked up as the focusof attention for deducing additional clauses. More technically,in detail, OTTER maintains four lists of clauses in reasoningprocess.1) Usable. This list works as a rule by keeping clauseswhich are available to make inferences.2) SoS. Clauses is regarded as facts. Set of support are notused to make inferences. They are kept to participate inthe search.3) Passive. They are specified to be used only for forwardsubsumption and unit conflict. The passive list does notparticipate in the search. The passive list does not changefrom the start of reasoning process as fixed input.4) Demodulators. Demodulators are used to rewrite newlyinferred clauses with equalities.In this paper, particularly, we focus on the size of setof support list. Set of support is important indicator forintrospecting the reasoning process.
B. Given Clause algorithm
OTTER adopts given-clause algorithm in which the programattempts to use any and all combinations from axioms ingiven clause. In other words, the combinations of clause aregenerated from given clauses which has been focused on.
Algorithm 1
Given clause algorithm
Input:
SOS, Usable List
Output:
Proof while until SoS is empty do choose a given clause G from SoS; move the clause g to Usable List; while c 1, ..., c n in Usable List do while R ( c , ..c i , G, c i +1 , ..c n ) exists do A ⇐ R ( c , ..c i , G, c i +1 , ..c n ); if A is the goal then report the proof; stop else { A is new odd } add A to SoS X end if end while end while end while At line 2, given clause G is extracted from SoS (Setof Support). Line 4 and 5 is a loop to use any and allcombinations of given clause and Usable List. In detail, [7][ ? ] discuss the basic framework of given clause algorithm. Toput it simply, given clause algorithm consists of the followingsteps.1) Pick up a clause (called the given clause) from the setof support.2) Add the given clause to the usable list. 3) Applying the inference rule or rules in the effect, inferall clauses which are generated from the given clause(one parent) and the usable list (other parents).4) Process newly inferred clause.5) Append each inferred new clause to the SoS. Theseclause is not discarded as a result of processing. Exactly,this is done in the course of processing the newlygenerated clause.In a nutshell, the reasoning program chooses a clause fromthe clauses which is focused on in the set of support. Theselected clause is called as focal clause or given clause. Definition 1.
Definition of given clause. The reasoning pro-gram chooses a clause on which to focus from among thosein the set of support, where the choice is based on variouscriteria such as the weight of the clause. The chosen clause isbased on various criteria from among those in the clause. Thechosen clause is called the “focal clause” (formerly the “givenclause”). The algorithm under discussion permits the focalclause to be considered by whatever inference rules are beingused, where the remaining clauses required by the inferencerule is selected from the usable list, but not from the set ofsupport. An equality literal is a literal whose predicate is to beinterpreted as meaning “equal”. The inference rule yields theclause C from the clauses A and B that are assumed to haveno variables in common when A contains a positive equalityliteral and B contains a term which unifies with one of thearguments of that equality literal.III. P
ARAMODULATION
Paramodulation is powerful method of equational reason-ing. It is the method based on resolution refutations whichincludes the equality. In the view of equational reasoning,paramodulation is a generalization of equality substitution. Forexample, if the equality of s = t and s occurs in the sentenceS, paramodulation can replace s in any of the occurrences.Also, on the rule of s = t , if t occurs in S, then reasoningprogram can replace s with t . C ∨ AD ∨ ¬ B ( C ∨ A ) σ if σ = mgu ( A, B ) (3)here, mgu (A, B) denotes a most general unifier of A andB, and factoring: C ∨ A ∨ B ( C ∨ A ) σ if σ = mgu ( A, B ) (4) Definition 2.
Definition of paramodulation. An equalitymeans if a literal whose predicate is to be represented asequal. The inference rule of paramodulation yields the clauseC between the clause A and B which are assumed to have novariables in common. Also, if A contains a positive equalityliteral and B contains a term which unifies with one of thearguments, C is yielded by paramodulation.In the equations above (3)(4), Clause A is called the fromclause, clause B is called the into clause, and clause C aaramodulant. Corresponding to the syntax of OTTER, forexample, given the following two clauses, from the first intothe second
EQUAL(a,b).Q(a). the clause
Q(b). is yielded by adopting paramodulation. For a second exam-ple, given the following two clauses, from the first into thesecond
EQUAL(sum(x,0), x).P(sum(sum(a,0), b),c).
Paramodulation yields
P(sum(a,b),c). as a paramodulant, from
Q(g(f(g(x)))).EQUAL(g(a),b). the clause
Q(g(f(b))). is deducible.In general, paramodulation is intended to be utilized, alongwith resolution, for theorem proving in first-order theories withequality.Concerning the implementation of OTTER, in paramodula-tion, two parents and a child are processed The parent clausescontain the equality applied for the replacement. The parentclauses are divided into two: from parent and from clause.If the equality comes from the literal, the side of the equalityunifies with the term which is replaced with the from term. Thereplaced term is called as the into term. The literal containingthe replaced term is also called as the into literal. Also theparent containing the replaced term is called as the into parentor into clause. IV. M
ETHODOLOGY
A. Setting OTTER’s rule set
As we discussed before, the basic inference mechanism ofOTTER is based on the given-clause algorithm. Given-clausealgorithm can be viewed as a simple implementation of theset of support strategy. OTTER maintains four lists of clauses:usable, SoS, demodulator and passive. In our case, we copewith two kinds of clauses: usable and SoS.Horizontal sliding from row[i] to row[i+1] is represented asfollows. list(usable).EQUAL(l(hole,l(n(x),y)),l(n(x),l(hole,y))).end_of_list. σ = (cid:26) hole hole (cid:27) (5)Vertical sliding from row[i] to row[i+4] is represented asfollows. list(usable).EQUAL(l(hole,l(x,l(y,l(z,l(u,l(n(w),v)))))),l(n(w),l(x,l(y,l(z,l(u,l(hole,v))))))).end_of_list. σ = (cid:26) hole hole (cid:27) (6) B. Checking the solvability of N puzzles
In general, to check the solvability of N puzzles, the numberof inversions of each number of N slots is calculated.For example, if we have the board configuration board[2,3,6,1,7,8,5,4, hole](5,2,8,4,1,7, hole, 3,6), the number of inversions are asfollows:1) 2 precedes 1 - 1 inversions2) 3 precedes 1 - 1 inversion3) 6 precedes 1, 5, 4 - 3 inversions4) 1 precedes none - 0 inversions5) 7 precedes 5, 4 - 2 inversions6) 8 precedes 5, 4 - 2 inversions7) 5 precedes 4 - 1 inversions8) 4 precedes none - 0 inversionsTotal inversions 1+1+3+0+2+2+1+0 = 10 (Even Number)So this puzzle configuration is solvable. On the other hand, itis not possible to solve an instance of 8 puzzle if number ofinversions is odd in the input state.Algorithm 2 shows the procedure for checking the solvabil-ity of N puzzles. At line 2 to 9, the number of inversions ofeach slots is counted. These figures are counted up at line 11to 14. Finally, the sum is checked if it is even or odd numberat line 15 to 19.
C. Incrementing the number of generated clauses
The main loop for inferring and processing clauses andsearching for a refutation operates mainly on the lists usableand SoS.1) Choose appropriate given clause in SoS;2) Move given clause from list ( SoS ) to list ( usable )
3) Infer and process new clauses using the inference rulesset.4) Newly generated clause must have the given clause .5) Do the retention test on new clauses and append thoseto list ( SoS ) .Main loop is depicted in Algorithm 3.At line 9, the number of generated clauses is incremented.After line 8 of picking up the clause from set of support, wecan record the current size of set of support. By doing this, wecan obtain the plot with lgorithm 2 Checking the solvability of N puzzles
Input:
Board[ x , x , ..., x n , hole ] Output:
SOLVABLE or UNSOLVABLE Board [ X | XS ] = Board [ x , x , ..., x n , hole ] while XS in Board [ XlXS ] is empty do for i in XS do statements.. if ( X = XS [ i ] ) then counter [ i ] + + end if end for end while line = check ( Board [ ... ] ⊆ hole ) sum = 0 for i to n do sum + = counter [ i ] end for if ( line + sum %2 == 0 ) then f lag = SOLVABLE else f lag = UNSOLVABLE end ifAlgorithm 3
Incrementing the number of generated clauses while given clause is NOT NULL do index lits clash ( giv cl ); append cl ( U sable, giv cl ); if splitting () then possible given split ( giv cl ); end if infer and process(giv cl); giv cl = extract given clause(); track(the number of generated clauses); end while V. E
XPERIMENTAL RESULTS
In experiment, we have generated 100 sliding puzzles withsize 8 * 8. All generated configurations of 8 puzzle aresolvable. For each puzzle, we have measured the number ofgenerated clauses with the procedures shown in Algorithm 2.For simplicity, we have generated the configuration of first 8slots with random integers ranging from 1 to 8 and fixed 9thslot to hole, as shown in the left side of Table I.The number of generated clauses with paramodula-tion ranges from 3008 (2,3,6,1,7,8,5,4, hole) to 468453(6,5,8,7,4,3,2,1, hole). In the view of complexity of reasoningprocess, the configuration [ (6,5,8,7,4,3,2,1, hole)] is 155.73times harder to solve than the configuration [(2,3,6,1,7,8,5,4,hole)].Figure 2 and 3 show the number of clauses generated withparamodulation which could be described as paramodulationcomplexity. In both graphs, X-axis is the number 8 puzzles.Y-axis is the number of generated clauses. For yielding Figure2 and 3, we have generated 100 * 8 puzzles which are solvable
TABLE II
NITIAL BOARD STATES AND THE COMPLEXITIES OF PARAMODULATION
Initial state clauses generated2,3,6,1,7,8,5,4,hole 3008 (easiest)2,4,3,8,7,6,5,1,hole 313442,5,3,8,6,1,7,4,hole 2724136,5,8,7,4,3,2,1,hole 468453 (the most difficult) as discussed in section IV-B. We have observed large variancein Figure 2. Besides, Figure 3 depicts the plot sorted by thenumber of clauses where the puzzle numbers are shuffled.
Fig. 2. Clauses generated by paramodulation. X-axis is the number 8 puzzles.Y-axis is the number of generated clauses.Fig. 3. Clauses generated by paramodulation. X-axis is the number 8 puzzles.Y-axis is the number of generated clauses.
Curiously, in sorted graph in Figure 3, the number of clausesis not increasing linearly. Instead, the number of clausesgenerated with paramodulation is increased drastically aroundX-axis 22, 38, 62, 79 and 97. Consequently, we can concludethat there are several layers of complexity in Figure 3. Also,in each layer, the number of clauses generated is increasinglinearly. VI. R
ELATED WORK
Archer [1] firstly discusses an algorithmic analysis of 15puzzle. In [1], a summary of all possible permutations ofslots attained by moving the black block from cell i to cellj effecting the permutation of σ i , j . Howe [2] proposes twoapproaches in the two kinds of viewpoints: the propertiesof permutations and graph theory. Ariyanto [3] proposes theew sliding puzzle made with several additional rules fromM13 puzzle. Calabro [4] proposes O ( n ) time algorithm fordeciding the time when tie initial configuration of the n *n puzzle game is solvable. Conrad [5] discusses 15 puzzleand rubik cube as permutation puzzle. Bischoff [6] adoptsreinforcement learning to solve 15-puzzle. Ando [14] applieshot list strategy [15] for faster paramodulation-based viral codedetection. Takefuji proposes the application of paramodulationto translator of Common Lisp [17]. Ando and Takefuji applieshot list strategy based on paramodulation for faster graphcoloring [16].Paramodulation originated as a development of resolution[18], one of the main computational methods in first-orderlogic, see [19]. For improving resolution-based methods, thestudy of the equality predicate has been particularly important,since reasoning with equality is well-known to be of greatimportant of mathematics, logic and computer science.Dan Carson and Larry Wos developed a resolution basedtheorem prover they called P1 which stands for “Program 1”.P1 is the founder of OTTER and includes basic strategy ofOTTER including the set-of-support strategy [13], unit prefer-ence [20] and paramodulation. P1 is the first implementation oftheorem prover where Wos’s invention of the paramodulationinference rule [21] is experimented. RW1 which stands for“Robinson-Wos 1” which is the product from the collaborationof Wos and George Robinson. RW1 adopts the paramodulationinference rule as well as demodulation [21]. Also, RW1 isbased on the concept by Knuth and Bendix, who independentlyformulated paramodulation and demodulation in the view ofa complete set of reductions in their 1970 paper [22].VII. C ONCLUSION