Newsgroups: comp.ai.edu,comp.ai,sci.logic,sci.math
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!udel!gatech!howland.reston.ans.net!newsserver.jvnc.net!nntpserver.pppl.gov!princeton!tucson.princeton.edu!chesakov
From: chesakov@tucson.princeton.edu (George Chesakov)
Subject: Re: A proof of a solvability algorithm for a 15-puzzle, etc...
Message-ID: <1995Apr10.224929.12804@Princeton.EDU>
To: Igor Pechtchanski <ipechtch@its.brooklyn.cuny.edu>
Originator: news@hedgehog.Princeton.EDU
Sender: news@Princeton.EDU (USENET News System)
Nntp-Posting-Host: tucson.princeton.edu
Organization: Princeton University
References:  <Pine.SUN.3.91.950410115111.15718A-100000@atrium44>
Distribution: inet
Date: Mon, 10 Apr 1995 22:49:29 GMT
Lines: 98
Xref: glinda.oz.cs.cmu.edu comp.ai.edu:2449 comp.ai:29010 sci.logic:10295 sci.math:101283

In article <Pine.SUN.3.91.950410115111.15718A-100000@atrium44>, 
Igor Pechtchanski <ipechtch@its.brooklyn.cuny.edu> writes:
|> Hi, everybody!
|> 
|> Does anyone know a good (easy to understand) proof, or can anybody refer 
|> me to a source where I can find one, that there are two equivalence 
|> classes of permutations for the 15-puzzle in particular and n-puzzle in 
|> general - those reachable from a current position and those not reachable?


first part:

for a matrix A
define I(A), such that if I(A) <> I(A') then A' is not reachable
from A. 
vice versa might not be necessarily true, but in case of 15 puzzle, 
the following also holds:
 if I(A) = I(A'), then A' is reachable from A.


n = m*k - 1


    | a11             ...             a1k |
    |                 ...                 |
A = | ai1 ... ai(j-1)  x  ai(j+1) ... aik |
    |                 ...                 |
    | am1             ...             amk |

where S(A) = (a11 ... a1k ... ai1 ... ai(j-1)  ai(j+1) ... aik ... am1 ... amk)
is a permutation of (1 2 ... n)
(x means blank)

sig(S) = the sign of the permutation (1 if even, -1 if not)
even(A) = 1, if i is even, and -1 if i is odd, where i is the number of row 
            with blank


we can do  do the following: 

  1. switch blank and ai(j-1)
  2. switch blank and ai(j+1) 
       --- in both cases even(A) and sig(S(A)) remain the same 
           (latter is because S(A) remains the same)
           

  3. switch blank and a(i-1)j getting A' from A

        | a11                     ...                 a1k |
        |                         ...                     |
        | a(i-1)1 ... a(i-1)(j-1)  x  a(i-1)(j+1) ... aik |
   A' = | ai1     ... ai(j-1)   a(i-1)j  ai(j+1)  ... aik |
        |                         ...                     |
        | am1                     ...                 amk |

and S(A')= (a11 ... a(i-1)(j-1) ... ai(j-1) a(i-1)j ai(j+1) ... amk)

it is easy to see that S(A) is transformed to S(A') using k elementary
transpositions (of adjacent elements) (just moving a(i-1)j  
k positions to the right),
so sig(S(A')) = (-1)^k * sig(S(A))

even(A')= -1*even(A)

if k is even, then sig(S(A)) is invariant, else even(k)*sig(S(A)) is.


Define  I(A) = sig(S(A)), if k is even, ang I(A) = even(k)*sig(S(A)), if k is odd.

I(A) = -1, or 1
I(A) does not change during the game, depending only on initial permutation.


------------------------

Now, about equivalence classes:

let A be a permutation, [A] the set of permutations, reachable
from A.

obviously, reachability is an equivalence relation, [A] is the equivlence class
of A.

There can be more than 2 equivalence classes in general (consider 
the puzzle with m*1 matrix, there're (m-1)! equivalence classes).

But for the 15 puzzle we have only 2 equivalence classes:
even and odd permutations of (1..15).
To prove that all even permutations can be generated from (1 .. 15),
using only available transpositions (those swapping s(i) and s(i+4) ),
is an easy excersize.



-- 
naive

        Stupidity is a choice.
