CoCalc Public Filesfinal.ipynb
Views : 312
Compute Environment: Ubuntu 18.04 (Deprecated)
In [31]:
import __future__
from Weight import Weight
from PartitionTree import PartitionTree
def Eval(string):
return eval(compile(str(string), '<string>', 'eval', __future__.division.compiler_flag))

def getBasisChange(name):
simples = RootSystem(name).ambient_space().simple_roots()
bChange = ([Eval((str(x).replace("(", "[").replace(")", "]"))) for x in simples])
for i in range(len(bChange), len(bChange[0])):
bChange.append([1 if j==i else 0 for j in range(0, len(bChange[0]))])
return matrix(bChange).transpose().inverse()

def geometricSumForPartition(positive_root, translations, q_analog):
x = 1
for i in range(0, len(positive_root)):
for j in range(0, positive_root[i]):
x = x * translations["A" + str(i+1)]
return 1/(1 - x) if not q_analog else 1/(1 -q*x)

def calculatePartition(name, weight, positive_roots = [], translations = {}, q_analog = False):
if positive_roots == []:
bChange = getBasisChange(name)
positive_roots = [vector(list(Eval(x))) for x in RootSystem(name).ambient_space().positive_roots()]
positive_roots = [bChange * x for x in positive_roots]

if translations == {}:
s = ''
if q_analog:
s = 'q, '
s += 'A1'
for i in range(1, len(weight)):
s += ', A' + str(i + 1)
variables = var(s)
for i in range(0, len(weight)):
translations["A" + str(i+1)] = eval("A" + str(i+1))

termsForSum = [geometricSumForPartition(list(x), translations, q_analog) for x in positive_roots]
for x in termsForSum:

for i in range(0, len(weight)):

def findAltSet(name, lamb = None, mu = None):
# initialize constants and vector space for the lie algebra
lie_algebra = RootSystem(name).ambient_space()
weyl_group = WeylGroup(name, prefix = "s")
simples = weyl_group.gens()

#print(weyl_group.one())
altset = [weyl_group.one()]

# used to change the basis from the standard basis of R^n to simple roots
changeBasis = getBasisChange(name)

# if lambda is not specified, the highest root is used
if lamb == None:
lamb = lie_algebra.highest_root()

# if mu is not specified, 0 vector is used
if mu == None:
mu = weyl_group.domain()([0 for i in range(0, len(lie_algebra.simple_roots()))])

#code moved to the bottom - LS 6/23/21
#check to see if the alt set is the empty set
#init = (lamb - mu) #was lamb+mu but needs to be subtraction - LS 6/16/21
#init = changeBasis * vector(list(Eval(init)))
#init = Weight(init)

#if init.isNegative():
#    return []
#end of LS

rho = lie_algebra.rho()
length = len(altset)
i=0
while i < length:
for simple in simples:
if ((altset[i] == simple)or (altset[i] == altset[i] * simple)):
continue
res = (altset[i]*simple).action(lamb + rho) - (rho + mu)
res = changeBasis * vector(list(Eval(res)))
res = Weight(res)

if not (res.isNegative() or res.hasFraction()):
if not (altset[i]*simple in altset):
altset.append(altset[i]*simple)
length += 1
i+=1

#Check to see if identity is in alternation set - LS 6/23/21
init = (lamb - mu)
init = changeBasis * vector(list(Eval(init)))
init = Weight(init)

if init.isNegative():
altset.remove(weyl_group.one())#end of LS

return altset

def calculateMultiplicity(name, lamb = None, mu = None, q_analog = False):
mult = 0
lie_algebra = RootSystem(name).ambient_space()
weyl_group = WeylGroup(name, prefix = "s")

# used to change the basis from the standard basis of R^n to simple roots
changeBasis = getBasisChange(name)

positive_roots = [vector(list(Eval(x))) for x in RootSystem(name).ambient_space().positive_roots()]
positive_roots = [getBasisChange(name) * x for x in positive_roots]

# if lambda is not specified, the highest root is used
if lamb == None:
lamb = lie_algebra.highest_root()
else:
while not len(lamb) == changeBasis.ncols():
lamb.append(0)
lamb = changeBasis.inverse() * vector(lamb)
lamb = weyl_group.domain()(list(eval(str(lamb))))

# if mu is not specified, 0 vector is used
if mu == None:
mu = weyl_group.domain()([0 for i in range(0, len(lie_algebra.simple_roots()))])
else:
while not len(mu) == changeBasis.ncols():
mu.append(0)
mu = changeBasis.inverse() * vector(mu)
mu = weyl_group.domain()(list(eval(str(mu))))

rho = lie_algebra.rho()
altset = findAltSet(name, lamb, mu)
#print(changeBasis * vector(list(Eval(lamb))))
for elm in altset:
# expression in partition function
res = elm.action(lamb + rho) - (mu + rho)

#change basis from standard basis to simple roots
res = vector(list(Eval(res)))
res = changeBasis * res

term = calculatePartition(name, list(res), positive_roots, q_analog=q_analog)

term *= (-1)**elm.length()
mult += term

#return mult
#To get both the multiplicity and the alternation set to print, comment the previous return line and uncomment the line below
return [mult, altset]

def printPartitions(name, weight, tex):
lie_algebra = RootSystem(name).ambient_space()

# used to change the basis from the standard basis of R^n to simple roots
changeBasis = getBasisChange(name)

positive_roots = [vector(list(Eval(x))) for x in RootSystem(name).ambient_space().positive_roots()]
positive_roots = [getBasisChange(name) * x for x in positive_roots]
latex_roots = ["".join([str(root[j] if root[j] != 1 else "") + "\\alpha_" + str(j+1)+"+" if root[j] != 0 else "" for j in range(0, len(root))]) for root in positive_roots]
latex_roots = [root[0:len(root)-1] for root in latex_roots]
weight_positive_roots = [Weight(list(root)) for root in positive_roots]
weight = Weight(weight)
tree = PartitionTree(weight, weight_positive_roots, 0, 0)

partitions = []
tree.getPartitions(partitions)

output = open(tex, "w")
output.write("\\documentclass{article}\n\\begin{document}\n")
for partition in partitions:
string = ""
for i in range(len(partition)):
coeff = partition[i]
if coeff > 1:
string += str(coeff) + "(" + latex_roots[i] + ") +"
elif coeff > 0:
string += "(" + latex_roots[i] + ")+"
string = "$"+ string[0:len(string)-1] string += "$\\\\\\\\\n\n"
output.write(string)
output.write("\\end{document}")
output.close()
print "Done"

#first argument is the name of the lie algebra
#second argument is lambda, an array that has the coefficients of the simple roots in order of subscript
#third argument is mu, given in the same way as lambda
#fourth argument is a boolean flag, so True/False, that determines whether to do the q-analog or not
#you can ommit any of the last three arguments and a default will be used
#default for lambda is the highest positive root
#default for mu is the 0 weight
#default for the q analog is false
#if you want to use a subset of the last three, you can set them by name.
#set lambda with lamb = ..., mu with mu = ..., and q-analog with q_analog = True/False
#Below are examples
#calculateMultiplicity("A3", [3,3,3], [2,2,2], True)
#calculateMultiplicity("A3", [3,3,3], q_analog=True)
#calculateMultiplicity("B3",lamb=[1,2,2], mu=[0,0], q_analog=False)
#printPartitions("A6", [1,2,1,1,1], "output.tex")
#findAltSet("A2")
#calculateMultiplicity("B3",[8,8,8],[5,7,7],True)

In [32]:
calculateMultiplicity("A2", [5, 5],[2,1], q_analog=True)

[q^7 + q^6 + q^5 + q^4, [1]]
In [33]:
calculateMultiplicity("A2", [5,5],[-1,1], q_analog=True)

[q^10 + q^9 + q^8 + q^7 + q^6 - q^4, [1, s1]]
In [34]:
calculateMultiplicity("A2", [5,5],[2,1], q_analog=True)

[q^7 + q^6 + q^5 + q^4, [1]]
In [35]:
calculateMultiplicity("A2", [5,5],[-1,1], q_analog=True)

[q^10 + q^9 + q^8 + q^7 + q^6 - q^4, [1, s1]]


In [36]:
calculateMultiplicity("A2", [5,5],[-1,-2], q_analog=True)

[q^13 + q^12 + q^11 + q^10 + q^9 + q^8 - q^7 - q^6, [1, s1, s2]]
In [37]:
calculateMultiplicity("A2", [5,5],[-1,-2], q_analog=True)

[q^13 + q^12 + q^11 + q^10 + q^9 + q^8 - q^7 - q^6, [1, s1, s2]]
In [ ]:


In [38]:
calculateMultiplicity("A2", [4,4],[-1,-1],q_analog=True)

[q^10 + q^9 + q^8 + q^7 + q^6 - q^5, [1, s1, s2]]
In [39]:
calculateMultiplicity("A2", [4,2],[1,0],q_analog=True)

[q^5, [1, s2]]
In [40]:
calculateMultiplicity("A2", [2,4],[1,0],q_analog=True)

[q^5, [1, s1]]
In [ ]:


In [41]:
calculateMultiplicity("A2", [2,0],[-1,-1], q_analog=True)

[-q^5, [1, s2]]
In [42]:
calculateMultiplicity("A2", [9,3],[1,0],q_analog=True)

[-q^13 - q^12, [1, s2]]
In [43]:
calculateMultiplicity("A2", [3,9],[1,0],q_analog=True)

[-q^13 - q^12, [1, s1]]
In [44]:
calculateMultiplicity("A2", [-1,-1],[0,0],q_analog=True)

[0, []]
In [45]:
calculateMultiplicity("A2", [0,2],[-1,0],q_analog=True)


[-q^4, [1, s1]]
In [ ]: