I'm a computer vision student, and I'm looking for some symmetric group literature guidance. I'm going to provide some context, and finally ask two questions.


The Cayley distance and other distances on permutations ($S\_n$) are quite useful in applied machine learning; see the beginning of [this paper](http://www.maths.qmul.ac.uk/~pjc/preprints/sd.pdf) for some examples of distances on $S\_n$. Typically, such distances are used when the absolute intensities of measurements are meaningless, but the relative intensities are meaningful. For example, if I wanted to compare the colors of pixels in a natural scene from an RGB image, I would not directly consider the absolute values of the R, G, and B components, as such values are sensitive to lighting. Instead, I would consider the differences in the ratios of R to G, R to B, etc. In the extreme case, I might only care about the ranking of the intensities of the color channels. The ranking is a permutation, so I could compare colors using a permutation distance.


This approach falls down when there is ambiguity in the ranking, as the ambiguity is a source of noise. For example, for a purely green pixel (R = 0, G = 255, B = 0), the rankings R <= B <= G and B <= R <= G are equally valid. So if I don't choose the rankings consistently, identical pixels may have nonzero distance (breaking a metric axiom). 


Even if I choose rankings consistently (say I choose the unique stable sort), weird behavior can arise; consider the pixels {0, 0, 255} and {255, 0, 0}. In the "spirit" of the Cayley distance, these pixels should have a distance of one: swap the R and B channels. This corresponds to the sorts G <= R <= B and G <= B <= R, which differ by one swap. However, the stable sorts are R <= G <= B and G <= B <= R, which has a Cayley distance of two.


Finally, my questions: 1) **What generalization of $S\_n$ are there that explicitly account for repeated elements?** To give a flavor of what I'm asking for, one possible generalization could replace the single-row representation of a permutation, e.g. [1, 3, 4, 2], with a single row of rows representation, e.g. [`[1]`, [3, 4], [2]]. This latter representation would represent the sorts for [100, 255, 127, 127]. Of course, people smarter than myself will have thought about this and come up with a better solution. 2) **For a given generalization, what are some common distances on it?**



Distances on generalizations of the symmetric group
I think the generalization you want is a total preorder, or equivalently a [strict weak ordering](http://en.wikipedia.org/wiki/Strict_weak_ordering). On finite sets, these correspond to the orderings of values of a function from the set to $\mathbb{R}$. In a total preorder, if $f(x) = f(y)$ then you say $x \le y$ and $y \le x$. In a strict weak order, if $f(x) = f(y)$ then you say neither $x \lt y$ nor $y \lt x$.


Strict weak orders are in bijection with the faces of a [permutohedron](http://en.wikipedia.org/wiki/Permutohedron) whose $1$-skeleton is identified with the Cayley graph of adjacent transpositions (by inverting the permutations). The dimension of a face is the number of equalities. The distance you want might be the distance in a graph $G$ whose vertices are the faces of the permutohedron where each face is adjacent to the faces of one lower dimension it contains and the faces of one higher dimension which contain it. 


This distance on $G$, restricted to the $0$-dimensional faces, is at most twice the Cayley distance, since you can achieve a transposition in two steps, moving from $a \lt b \lt c$ to $a \lt b = c$ to $a \lt c \lt b$. However, the macroscopic properties of this distance are quite different from those of the Cayley graph because you can take big shortcuts through high dimensional faces. To reverse $a \lt b \lt c$ takes $3$ transpositions but only $4$ steps in $G$: $a \lt b \lt c$, $a \lt b = c$, $a=b=c$, $b=c\lt a$, $c \lt b \lt a$. Every face is of distance at most $2(n-1)$ from every other face since every face is of distance at most $n-1$ from the $n-1$-dimensional face in which all coordinates are equal. 


So, another possible distance on $G$ is to declare that the length of an edge is the number of pairwise inequalities added or subtracted. Adjacent faces are related by merging two equivalence classes or dividing one into two. If an edge merges two equivalence classes of sizes $m\_1$ and $m\_2$, then let the length of that edge be $m\_1\times m\_2$. So, the distance between $a\lt b=c$ and $a=b=c$ is $2$, and the path of $4$ edges from $a\lt b\lt c$ to $c \lt b \lt a$ has length $6$. If you restrict this distance to the vertices of the permutohedron, you get twice the Cayley distance. 


