  
  [1X8 [33X[0;0YProperties of Permutations[133X[101X
  
  [33X[0;0YIt  has  been  of interest to the authors to compute different properties of
  permutations. Inspections include plus- and minus-decomposable permutations,
  block-decompositions  of  permutations,  as  well  as the computation of the
  direct  and skew sum of permutations. First a couple of definitions on which
  some of the properties are based on:[133X
  
  [33X[0;0YAn interval of a permutation [22Xσ[122X is a set of contiguous values which in [22Xσ[122X have
  consecutive indices.[133X
  
  [33X[0;0YA permutation of length [22Xn[122X is called simple if it only contains the intervals
  of length 0, 1 and [22Xn[122X.[133X
  
  
  [1X8.1 [33X[0;0YIntervals in Permutations[133X[101X
  
  [33X[0;0YAs  mentioned  above,  an interval of a permutation [22Xσ[122X is a set of contiguous
  numbers  which in [22Xσ[122X have consecutive indices. For example in [22Xσ = 4 6 8 7 1 5
  2 3[122X the following is an interval [22Xσ(2)σ(3)σ(4)=6 8 7[122X whereas [22Xσ(4)σ(5)σ(6)=7 1
  5[122X is not.[133X
  
  [1X8.1-1 IsInterval[101X
  
  [33X[1;0Y[29X[2XIsInterval[102X( [3Xlist[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10Y[10Xtrue[110X, if [10Xlist[110X is an interval.[133X
  
  [33X[0;0YIsInterval  takes  in  any  list  with unique elements, which can be ordered
  lexicographically and checkes whether it is an interval.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XIsInterval([3,6,9,2]);[127X[104X
    [4X[28Xfalse[128X[104X
    [4X[25Xgap>[125X [27XIsInterval([2,6,5,3,4]);[127X[104X
    [4X[28Xtrue[128X[104X
    [4X[25Xgap>[125X [27X [127X[104X
  [4X[32X[104X
  
  
  [1X8.2 [33X[0;0YSimplicity[133X[101X
  
  [33X[0;0YAs  mentioned  above  a permutation is said to be simple if it only contains
  intervals of length 0, 1 or the length of the permutation.[133X
  
  [1X8.2-1 IsSimplePerm[101X
  
  [33X[1;0Y[29X[2XIsSimplePerm[102X( [3Xperm[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10Y[10Xtrue[110X if [10Xperm[110X is simple.[133X
  
  [33X[0;0YTo  check  whether  [10Xperm[110X  (length  of  [10Xperm[110X  =  [22Xn[122X)  is  a simple permutation
  [10XIsSimplePerm[110X  uses the basic algorithm proposed by Uno and Yagiura in [8] to
  compare the [10Xperm[110X against the identity permutation of the same length.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XIsSimplePerm([2,3,4,5,1,1,1,1]);[127X[104X
    [4X[28Xtrue[128X[104X
    [4X[25Xgap>[125X [27XIsSimplePerm([2,4,6,8,1,3,5,7]);[127X[104X
    [4X[28Xtrue[128X[104X
    [4X[25Xgap>[125X [27XIsSimplePerm([3,2,8,6,7,1,5,4]);[127X[104X
    [4X[28Xfalse[128X[104X
    [4X[25Xgap>[125X [27X[127X[104X
  [4X[32X[104X
  
  
  [1X8.3 [33X[0;0YPoint Deletion in Simple Permutations[133X[101X
  
  [33X[0;0YIn [7] it is shown how one can get chains of permutations by starting with a
  simple permutation and then removing either a single point or two points and
  the resulting permutation would still be simple. We have applied this theory
  to  create  functions  such  that  the set of simple permutations of shorter
  length, by one deletion, can be found.[133X
  
  [1X8.3-1 OnePointDelete[101X
  
  [33X[1;0Y[29X[2XOnePointDelete[102X( [3Xperm[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YA list of simple permutations with one point less than [10Xperm[110X.[133X
  
  [33X[0;0Y[10XOnePointDelete[110X removes single points in the simple permutation and returns a
  list of the resulting simple permutations, in their rank encoding.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XOnePointDelete([5,2,3,1,2,1]);[127X[104X
    [4X[28X[ [ 2, 3, 1, 2, 1 ], [ 4, 1, 2, 2, 1 ] ][128X[104X
    [4X[25Xgap>[125X [27XOnePointDelete([5,2,4,1,6,3]);[127X[104X
    [4X[28X[ [ 2, 3, 1, 2, 1 ], [ 4, 1, 2, 2, 1 ] ][128X[104X
    [4X[25Xgap>[125X [27X[127X[104X
  [4X[32X[104X
  
  [1X8.3-2 TwoPointDelete[101X
  
  [33X[1;0Y[29X[2XTwoPointDelete[102X( [3Xperm[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YThe exceptional permutation with two point less than [10Xperm[110X.[133X
  
  [33X[0;0Y[10XTwoPointDelete[110X  removes  two points of the input exceptional permutation and
  returns the list of the unique resulting permutation, in its rank encoding.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XTwoPointDelete([2,4,6,8,1,3,5,7]);[127X[104X
    [4X[28X[ [ 2, 3, 4, 1, 1, 1 ] ][128X[104X
    [4X[25Xgap>[125X [27XTwoPointDelete([2,3,4,5,1,1,1,1]);[127X[104X
    [4X[28X[ [ 2, 3, 4, 1, 1, 1 ] ][128X[104X
    [4X[25Xgap>[125X [27X[127X[104X
  [4X[32X[104X
  
  [1X8.3-3 PointDeletion[101X
  
  [33X[1;0Y[29X[2XPointDeletion[102X( [3Xperm[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YA list of simple permutations with of shorter length than [10Xperm[110X.[133X
  
  [33X[0;0Y[10XPointDeletion[110X   takes   any  simple  permutation  does  not  matter  whether
  exceptional or not and removes the right number of points.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XPointDeletion([5,2,3,1,2,1]);[127X[104X
    [4X[28X[ [ 2, 3, 1, 2, 1 ], [ 4, 1, 2, 2, 1 ] ][128X[104X
    [4X[25Xgap>[125X [27XPointDeletion([5,2,4,1,6,3]);[127X[104X
    [4X[28X[ [ 2, 3, 1, 2, 1 ], [ 4, 1, 2, 2, 1 ] ][128X[104X
    [4X[25Xgap>[125X [27XPointDeletion([2,4,6,8,1,3,5,7]);[127X[104X
    [4X[28X[ [ 2, 3, 4, 1, 1, 1 ] ][128X[104X
    [4X[25Xgap>[125X [27XPointDeletion([2,3,4,5,1,1,1,1]);[127X[104X
    [4X[28X[ [ 2, 3, 4, 1, 1, 1 ] ][128X[104X
    [4X[25Xgap>[125X [27X[127X[104X
  [4X[32X[104X
  
  
  [1X8.4 [33X[0;0YBlock-Decomposition[133X[101X
  
  [33X[0;0YGiven  a permutation [22Xπ[122X of length [22Xm[122X and nonempty permutations [22Xα_1,...,α_m[122X the
  inflation of [22Xπ[122X by [22Xα_1,...,α_m[122X, written as [22Xπ[α_1,...,α_m][122X, is the permutation
  obtained  by  replacing  each  entry  [22Xπ(i)[122X  by  an  interval  that  is order
  isomorphic  to  [22Xα_i[122X  [4].  Conversely  a  block-decomposition  of  [22Xσ[122X  is any
  expression of [22Xσ[122X as an inflation [22Xσ=π[α_1,...,α_m][122X. The block decomposition of
  a  permutation  is unique if and only if [22Xσ,π,α_1,...,α_n[122X all are in the same
  pattern class and [22Xπ[122X is simple and [22Xπ≠ 1 2, 2 1[122X [1].[133X
  
  [33X[0;0YFor example the inflation of [22X25413[21,1,1,1,2413]=3 2 8 9 1 5 7 4 6[122X, written
  in [5XGAP[105X this is [10X[[2,5,4,1,3],[2,1],[1],[1],[1],[2,4,1,3]][110X. This decomposition
  of  [22X3  2  8  9  1  5 7 4 6[122X is not unique. The unique block-decomposition, as
  described above, for [22X3 2 8 9 1 5 7 4 6=2413[21,12,1,2413][122X or in [5XGAP[105X notation
  [10X[3,2,8,9,1,5,7,4,6]=[[2,4,1,3],[2,1],[1,2],[1],[2,4,1,3]][110X.[133X
  
  [1X8.4-1 Inflation[101X
  
  [33X[1;0Y[29X[2XInflation[102X( [3Xlist_of_perms[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YA  permutation  that  represents  the  inflation  of  the  list of
            permutations,  taking  the first permutation to be [22Xπ[122X, as described
            in the definition of inflation.[133X
  
  [33X[0;0YInflation  takes the list of permutations that stand for a box decomposition
  of  a permutation, and calculates that permutation by replacing each entry [22Xi[122X
  in  the first permutation by an interval order isomorphic to the permutation
  in index [22Xi+1[122X.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XInflation([[3,2,1],[1],[1,2],[1,2,3]]);[127X[104X
    [4X[28X[ 6, 4, 5, 1, 2, 3 ][128X[104X
    [4X[25Xgap>[125X [27XInflation([[1,2],[1],[4,2,1,3]]);[127X[104X
    [4X[28X[ 1, 5, 3, 2, 4 ][128X[104X
    [4X[25Xgap>[125X [27XInflation([[2,4,1,3],[2,1],[3,1,2],[1],[2,4,1,3]]);[127X[104X
    [4X[28X[ 3, 2, 10, 8, 9, 1, 5, 7, 4, 6 ][128X[104X
    [4X[25Xgap>[125X [27X[127X[104X
  [4X[32X[104X
  
  [1X8.4-2 BlockDecomposition[101X
  
  [33X[1;0Y[29X[2XBlockDecomposition[102X( [3Xperm[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YA  list  of  permutations, representing the block-decomposition of
            [10Xperm[110X.  In the list the first permutation is [22Xπ[122X, as described in the
            definiton of block-decomposition above.[133X
  
  [33X[0;0Y[10XBlockDecomposition[110X  takes  a  plus- and minus-indecomposable permutation and
  decomposes  it into its maximal maximal intervals, which are preceded by the
  simple  permutation  that  represents  the  positions of the intervals. If a
  plus-  or  minus-decomposable  permutation  is input, then the decomposition
  will  not  be the unique decomposition, by the definition of plus- or minus-
  decomposable permutations, see below.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XBlockDecomposition([3,2,10,8,9,1,5,7,4,6]);[127X[104X
    [4X[28X[ [ 2, 4, 1, 3 ], [ 2, 1 ], [ 3, 1, 2 ], [ 1 ], [ 2, 4, 1, 3 ] ][128X[104X
    [4X[25Xgap>[125X [27XBlockDecomposition([1,2,3,4,5]);                      [127X[104X
    [4X[28X[ [ 1, 2 ], [ 1, 2, 3, 4 ], [ 1 ] ][128X[104X
    [4X[25Xgap>[125X [27XBlockDecomposition([5,4,3,2,1]);[127X[104X
    [4X[28X[ [ 2, 1 ], [ 4, 3, 2, 1 ], [ 1 ] ][128X[104X
    [4X[25Xgap>[125X [27X [127X[104X
  [4X[32X[104X
  
  
  [1X8.5 [33X[0;0YPlus-Decomposability[133X[101X
  
  [33X[0;0YA  permutation  [22Xσ[122X  is  said  to  be  plus-decomposable  if it can be written
  uniquely in the following form,[133X
  
  
  [24X[33X[0;6Yσ = 12 [α_1,α_2][133X[124X
  
  [33X[0;0Ywhere [22Xα_1[122X is not plus-decomposable.[133X
  
  [33X[0;0YThe  subset  of  a  rational  class,  containing  all  permutations that are
  plus-decomposable and in the class, has been found to be also rational under
  the rank encoding.[133X
  
  [1X8.5-1 IsPlusDecomposable[101X
  
  [33X[1;0Y[29X[2XIsPlusDecomposable[102X( [3Xperm[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10Y[10Xtrue[110X if [10Xperm[110X is plus-decomposable.[133X
  
  [33X[0;0YTo  check whether [10Xperm[110X is a plus-decomposable permutation [10XIsPlusDecomposable[110X
  uses  the  fact that there has to be an interval [22X1..x[122X where [22Xx <n[122X ([22Xn[122X = length
  of the [10Xperm[110X) in the rank encoded permutation that is a valid rank encoding.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XIsPlusDecomposable([3,3,2,3,2,2,1,1]);[127X[104X
    [4X[28Xtrue[128X[104X
    [4X[25Xgap>[125X [27XIsPlusDecomposable([3,4,2,6,5,7,1,8]);[127X[104X
    [4X[28Xtrue[128X[104X
    [4X[25Xgap>[125X [27XIsPlusDecomposable([3,2,8,6,7,1,5,4]);[127X[104X
    [4X[28Xfalse[128X[104X
    [4X[25Xgap>[125X [27X[127X[104X
  [4X[32X[104X
  
  
  [1X8.6 [33X[0;0YMinus-Decomposability[133X[101X
  
  [33X[0;0YMinus-decomposability  is  essentially the same as plus-decomposability, the
  difference  is  that  if  a  permutation  [22Xσ[122X is minus-decomposable, it can be
  written uniquely in the following form,[133X
  
  
  [24X[33X[0;6Yσ = 21 [α_1,α_2][133X[124X
  
  [33X[0;0Ywhere [22Xα_1[122X is not minus-decomposable.[133X
  
  [33X[0;0YHere  also, the subset of a rational class, containing all permutations that
  are minus-decomposable and in the class, has been found to be rational under
  the rank encoding.[133X
  
  [1X8.6-1 IsMinusDecomposable[101X
  
  [33X[1;0Y[29X[2XIsMinusDecomposable[102X( [3Xperm[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10Y[10Xtrue[110X if [10Xperm[110X is minus-decomposable.[133X
  
  [33X[0;0YTo  check  whether  [10Xperm[110X  (length  of  [10Xperm[110X  =  [22Xn[122X)  is  a minus-decomposable
  permutation [10XIsMinusDecomposable[110X uses the fact that the first [22Xn-x[122X, where [22Xx<n[122X,
  letters in the rank encoding of [10Xperm[110X have to be [22X>x[122X and that the letters from
  position [22Xx+1[122X until the last one have to be [22X≤ x[122X.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XIsMinusDecomposable([3,3,3,3,3,3,2,1]);[127X[104X
    [4X[28Xtrue[128X[104X
    [4X[25Xgap>[125X [27XIsMinusDecomposable([3,4,5,6,7,8,2,1]);[127X[104X
    [4X[28Xtrue[128X[104X
    [4X[25Xgap>[125X [27XIsMinusDecomposable([3,2,8,6,7,1,5,4]);[127X[104X
    [4X[28Xfalse[128X[104X
    [4X[25Xgap>[125X [27X[127X[104X
  [4X[32X[104X
  
  
  [1X8.7 [33X[0;0YSums of Permutations[133X[101X
  
  [33X[0;0YThe  direct sum of two permutations [22Xσ=σ_1 ... σ_k[122X and [22Xτ=τ_1...τ_l[122X is defined
  as,[133X
  
  
  [24X[33X[0;6Yσ ⊕ τ = σ_1 σ_2...σ_k τ_1+k τ_2+k...τ_l+k .[133X[124X
  
  [33X[0;0YIn a similar fashion the skew sum of [22Xσ, τ[122X is[133X
  
  
  [24X[33X[0;6Yσ ⊖ τ = σ_1+l σ_2+l...σ_k+l τ_1 τ_2...τ_l .[133X[124X
  
  [33X[0;0YThe  calculation  of the direct and skew sums of permutations using the rank
  encoding  is  also  straight  forward and is used in the functions described
  below.  The  direct  sum  of  two permutations [22Xσ,τ[122X represented as their rank
  encoded sequences is the permutation which has the rank encoding that is the
  concatention  of  the  rank  encoding  of  [22Xσ[122X  and  [22Xτ[122X.  The  skew  sum of two
  permutations  [22Xσ,τ[122X  encoded  by the rank encoding is the concatenation of the
  rank encodings of [22Xσ[122X and [22Xτ[122X where in the sequence corresponding to [22Xσ[122X under the
  rank  encoding each element has been increased by [22Xl[122X, with [22Xl[122X being the length
  of [22Xτ[122X.[133X
  
  [1X8.7-1 PermDirectSum[101X
  
  [33X[1;0Y[29X[2XPermDirectSum[102X( [3Xperm1[103X, [3Xperm2[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YA permutation resulting from [10Xperm1[110X [22X⊕[122X [10Xperm2[110X.[133X
  
  [33X[0;0Y[10XPermDirectSum[110X  returns  the  permutation  corresponding  to [10Xperm1[110X [22X⊕[122X [10Xperm2[110X if
  [10Xperm1[110X  and [10Xperm2[110X are both not rank encoded. If both [10Xperm1[110X and [10Xperm2[110X are rank
  encoded, then [10XPermDirectSum[110X returns a rank encoded sequence.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XPermDirectSum([2,4,1,3],[2,5,4,1,3]);[127X[104X
    [4X[28X[ 2, 4, 1, 3, 6, 9, 8, 5, 7 ][128X[104X
    [4X[25Xgap>[125X [27XPermDirectSum([2,3,1,1],[2,4,3,1,1]);[127X[104X
    [4X[28X[ 2, 3, 1, 1, 2, 4, 3, 1, 1 ][128X[104X
    [4X[25Xgap>[125X [27X[127X[104X
  [4X[32X[104X
  
  [1X8.7-2 PermSkewSum[101X
  
  [33X[1;0Y[29X[2XPermSkewSum[102X( [3Xperm1[103X, [3Xperm2[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YA permutation resulting from [10Xperm1[110X [22X⊖[122X [10Xperm2[110X.[133X
  
  [33X[0;0Y[10XPermSkewSum[110X  returns the permutation corresponding to [10Xperm1[110X [22X⊖[122X [10Xperm2[110X if [10Xperm1[110X
  and  [10Xperm2[110X  are  both  not  rank  encoded.  If both [10Xperm1[110X and [10Xperm2[110X are rank
  encoded, then [10XPermSkewSum[110X returns a rank encoded sequence.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XPermSkewSum([2,4,1,3],[2,5,4,1,3]);[127X[104X
    [4X[28X[ 7, 9, 6, 8, 2, 5, 4, 1, 3 ][128X[104X
    [4X[25Xgap>[125X [27XPermSkewSum([2,3,1,1],[2,4,3,1,1]);[127X[104X
    [4X[28X[ 7, 8, 6, 6, 2, 4, 3, 1, 1 ][128X[104X
    [4X[25Xgap>[125X [27X[127X[104X
  [4X[32X[104X
  
