Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
## The vector space in which everything will happen:
V = QQ^8
## The simple roots (and smallest root alpha0) of E_8 under the usual “even”
## coordinate system:
alpha1 = V((1,-1,-1,-1,-1,-1,-1,1))/2
alpha2 = V((1,1,0,0,0,0,0,0))
alpha3 = V((-1,1,0,0,0,0,0,0))
alpha4 = V((0,-1,1,0,0,0,0,0))
alpha5 = V((0,0,-1,1,0,0,0,0))
alpha6 = V((0,0,0,-1,1,0,0,0))
alpha7 = V((0,0,0,0,-1,1,0,0))
alpha8 = V((0,0,0,0,0,-1,1,0))
alpha0 = -(2*alpha1 + 3*alpha2 + 4*alpha3 + 6*alpha4 + 5*alpha5 + 4*alpha6 + 3*alpha7 + 2*alpha8)
alphas = [alpha0,alpha1,alpha2,alpha3,alpha4,alpha5,alpha6,alpha7,alpha8]
## The corresponding reflection matrices (note matrices act on the RIGHT!):
refls = [-Matrix([x]).transpose() * Matrix([x]) + 1 for x in alphas]
## The associated fundamental weights:
weightmat = Matrix([alphas[i] for i in range(1,9)]).inverse().transpose()
weight1 = weightmat[0]
weight2 = weightmat[1]
weight3 = weightmat[2]
weight4 = weightmat[3]
weight5 = weightmat[4]
weight6 = weightmat[5]
weight7 = weightmat[6]
weight8 = weightmat[7]
## The Weyl vector ρ (sum of the fundamental weights):
rho = sum([weightmat[i] for i in range(8)])
## Normalize an octuple (element of V) under the action of W(D_8), i.e., return
## its representative in the Weyl chamber of D_8.
## In practice: return an element (y_0,y_1,y_2,y_3,y_4,y_5,y_6,y_7)
## with |y_0| ≤ y_1 ≤ y_2 ≤ y_3 ≤ y_4 ≤ y_5 ≤ y_6 ≤ y_7
## obtained by permuting the given coordinates and changing an even number of
## signs.
def d8_normalize(x):
xabs = [abs(x[i]) for i in range(8)]
signs = len([None for i in range(8) if x[i]<0])
xabs[0] *= (-1 if signs%2==1 else 1)
return V(xabs)
## Now compute the orbit of rho under W(E_8) modulo W(D_8): to do this, “mine”
## contains a set of pairs (w,v) where w is a matrix in W(E_8) and v=ρw; and we
## repeatedly try to add every w′=rw (where r ranges over the simple generators
## of W(E_8)) as long as the corresponding v′=ρw′=ρrw is in the Weyl chamber of
## D_8 (cf. d8_normalize() above) and is not already known to us.
wident = identity_matrix(QQ,8)
oldmine = set([])
mine = set([(wident,rho)])
while len(mine)>len(oldmine): # Main loop:
minecopy = set(mine)
for (w,v) in mine: # Iterate over vectors:
for k in range(1,9): # Iterate over generators of W(E_8):
w2 = refls[k]*w
v2 = rho*w2
if v2 == d8_normalize(v2):
## We have a new vector to add!
oldmine = mine
mine = minecopy
## List of vectors v obtained:
lister = [V(v[::-1]) for v in sorted([list(v)[::-1] for (w,v) in mine])[::-1]]
## (Note: v[::-1] is used to reverse coordinates, for sorting purposes.)
## I hate Python's distinction of statements and expressions:
junk = [v.set_immutable() for v in lister]
## Write the list to stdout:
sys.stdout.write("".join(["(%s, %s, %s, %s, %s, %s, %s, %s)\n"%(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7]) for v in lister]))
## Dictionary for v↦w conversion:
matrixer = dict([(v,w) for (w,v) in mine])
## Matrices w in the same order as the vectors v in “lister”:
matlister = [matrixer[lister[i]] for i in range(len(lister))]
## Dictionaries for recovering the index i in “lister” from a vector or matrix:
invlister = dict([lister[i],i] for i in range(len(lister)))
invmatlister = dict([matlister[i],i] for i in range(len(lister)))
## Save the resulting graph as /tmp/ (ready for dot consumption).
## Convert to PDF with “dot -Tpdf /tmp/ > /tmp/we8modd8.pdf”
odot = open("/tmp/","w")
odot.write("graph e8modd8 {\n")
for i in range(len(lister)):
v = lister[i]
if v[7] in ZZ:
ext = ""
v *= 2
ext = "/2"
lab = "(%s,%s,%s,%s,\\n%s,%s,%s,%s)%s"%(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],ext)
lab = lab.replace("-","&#8722;") # Use Unicode U+2212 MINUS SIGN for display
odot.write("\tq%d [shape=\"box\",label=\"%s\"];\n"%(i,lab))
colortab = [None, "red", "green", "blue", "magenta", "brown", "yellow", "cyan", "gray"]
for i in range(len(lister)):
for k in range(1,9):
w2 = refls[k]*matlister[i]
if invmatlister.has_key(w2):
i2 = invmatlister[w2]
if i2 > i:
odot.write("\tq%d -- q%d [color=\"%s\"];\n"%(i,i2,colortab[k]))
Copy link

Gro-Tsen commented Jun 17, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment