Computing Bruhat Order Covering Relations To put this in context:  I am in the process of developing a package for Macaulay 2 (a commutative algebra software,) called "Permutations", which will add permutations as a type of combinatorial object that M2 will handle, hopefully integrating nicely with the (still in development) Posets package, the (still in development) Graphs package, and various current M2 functions.
One of the first things that I'd wanted to put in was functions which compute the poset of the Bruhat order on $S_n$ and compute when one permutation covers another in the Bruhat order.  This was all coded and "working" - but has been producing a poset which is decidedly NOT the desired poset (among other things, the graph of the Hasse diagram isn't regular.)  I'd like to ask whether the (probably somewhat naive) algorithm I was using to check covering relations seems reasonable (so the problem is just in the coding of it, not in the theory behind it) or not.
To see if $P\leq R$ in the Bruhat order:
Given a pair of permutations P and R, compute their lengths (the number of simple transpositions in their decomposition, or [as implemented right now] the sum of entries in their inversion vectors.)  If length(P)=length(R)+1, then we compute
$(P^{-1})*R$.
If R covers P in the Bruhat order, then length$((P^{-1})*R)=1.$
Am I missing some subtlety of the Bruhat order?  I thought one permutation covered enough exactly when they differed by a single, simple transposition.  This seemed to capture that - but is giving me an incorrect poset.
Coding error or theory error?  I'd love to hear it.
 A: My M2 permutation code is here:
http://www.math.cornell.edu/~allenk/permutation.m2
It's got a bunch of specialized stuff about Rothe diagrams and Fulton's essential set, but at the end it's got a BruhatLeq, for strong Bruhat order (so, not what you're computing).
If you want covering relations in strong Bruhat or right weak Bruhat, find the first place F and the last place L that your permutations differ. Weak Bruhat Covering: L=F+1. Strong Bruhat covering: each value w(F+1)...w(L-1) is not in the interval (w(F),w(L)).
If you want all relations in weak Bruhat order, w >= v if l(w) = l(v) + l(v^-1 w). 
For all relations in strong Bruhat order, best to compute the corresponding rank matrices, and compare those entrywise. (That's what I do in the above code.)
A: $P^{-1}R$ is not in general of length 1. For example
(12)(23)(34)(45)(56) covers (12)(23)(45)(56) but (12)(23)(45)(56) (56)(45)(34)(23)(12)=
(12)(23)(34)(23)(12)
Your algorithm should work if you instead test if $P^{-1}R$ is a transposition (not just a simple transposition).
A: For  Stephen Griffeth and others:
download: http://math.univ-lyon1.fr/~ducloux/coxeter/coxeter3/english/coxeter3_e.html
To tell the software what group you want to work with, get yourself to the "type" prompt, either by pressing Enter at the main prompt, or by entering "type" as a command. The names of the groups are:


*

*A-I, corresponding to the finite Coxeter groups

*a-g, corresponding to the affine Coxeter groups

*X or x, for input from a file

*Y or y, for interactive input


For (1) (2) and (4) you will next be presented with the "rank" prompt, which refers to the size of the generating set of the Coxeter group, so for example the affine Weyl group of SL(3) should be "a" followed by "3". For (4) you will also be asked for the entries of the Coxeter matrix. For (3) you will be asked for a file.
When you need to enter a group element, you merely type a sequence of integers 1 through rank separated by periods, e.g. 1.2.1. If the rank is at most 9 then you can (must?) omit the periods, e.g. 121. If you need to input the identity element, you simply type nothing and press Enter. 
I don't remember how the simple reflections are numbered, but I seem to remember that the affine generator is always the last one. There is a prefix and postfix command to change these naming conventions (so you could call the 1st reflection "s(1)" if you wanted), which is useful when you are doing input from the output of some other program or script.
You can see a list of commands by typing "help", and they should be mostly self-explanatory knowing the above.
