GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
1[1X7 [33X[0;0YSome Permutation Essentials[133X[101X23[33X[0;0YIn this chapter we mention a couple functions that are fairly basic but4useful tools to work with.[133X567[1X7.1 [33X[0;0YComplement[133X[101X89[1X7.1-1 PermComplement[101X1011[29X[2XPermComplement[102X( [3Xperm[103X ) [32X function12[6XReturns:[106X [33X[0;10YThe permutation that is the complement of [10Xperm[110X.[133X1314[33X[0;0YThe complement of a permutation [22Xτ=τ_1...τ_n[122X is the permutation[133X151617[24X[33X[0;6Yτ^C=(n+1)-τ_1 (n+1)-τ_2... (n+1)-τ_n[133X[124X1819[33X[0;0Y.[133X2021[4X[32X Example [32X[104X22[4X[25Xgap>[125X [27XPermComplement([3,2,8,6,7,1,5,4]);[127X[104X23[4X[28X[ 6, 7, 1, 3, 2, 8, 4, 5 ][128X[104X24[4X[25Xgap>[125X [27X[127X[104X25[4X[32X[104X262728[1X7.2 [33X[0;0YRank Encoding[133X[101X2930[1X7.2-1 IsRankEncoding[101X3132[29X[2XIsRankEncoding[102X( [3Xperm[103X ) [32X function33[6XReturns:[106X [33X[0;10Y[10Xtrue[110X if [10Xperm[110X is a valid rank encoding of a permutation.[133X3435[33X[0;0Y[10XIsRankEncoding[110X checkes whether the input list [10Xperm[110X is a valid rank encoding36by checking whether it is accepted by the bounded class automaton, with the37highest rank being set by the highest element in [10Xperm[110X.[133X3839[4X[32X Example [32X[104X40[4X[25Xgap>[125X [27XIsRankEncoding([3,2,6,4,4,1,2,1]);[127X[104X41[4X[28Xtrue[128X[104X42[4X[25Xgap>[125X [27XIsRankEncoding([3,2,6,4,5,1,2,1]);[127X[104X43[4X[28Xfalse[128X[104X44[4X[25Xgap>[125X [27X[127X[104X45[4X[32X[104X46474849