# Check: the functional ev(a,b,a) - ev(b,a,b) on characters of SL2^3 kills Res V_lam (SO5 x SO5 irreps)
# and is nonzero on V_(0,2,0). Uses SO5 Weyl character formula numerically (exact rationals).
from fractions import Fraction as Fr
from itertools import product
def so5_char(a, b, x, y):
    # weights of SO5 irrep (a,b) via Freudenthal is heavy; use branching SO5->SO4 (interlacing) and SO4 chars
    tot = Fr(0)
    for p1 in range(b, a+1):
        for p2 in range(-b, b+1):
            m, n = p1+p2, p1-p2   # SL2 x SL2 highest weights
            tot += sl2(m, (x*y)) * sl2(n, (x/y)) if False else 0
    return tot
def sl2(m, z):  # character of V_m at diag(z,1/z)
    return sum(z**(m-2*j) for j in range(m+1))
def res_char(lam, a, b, c):
    # Res of V_lam1 x V_lam2 to SL2^3 via SO4 x SO4: V_{(p1,p2)} -> V_{p1+p2} (x) V_{p1-p2}
    (a1,b1),(a2,b2) = lam
    s1 = sum(sl2(p1+p2, a)*sl2(p1-p2, b) for p1 in range(b1, a1+1) for p2 in range(-b1, b1+1))
    s2 = sum(sl2(p1+p2, b)*sl2(p1-p2, c) for p1 in range(b2, a2+1) for p2 in range(-b2, b2+1))
    return s1*s2
A, B = Fr(2), Fr(3)
ok = True
for a1 in range(4):
  for b1 in range(a1+1):
    for a2 in range(4):
      for b2 in range(a2+1):
        lam=((a1,b1),(a2,b2))
        if res_char(lam, A, B, A) != res_char(lam, B, A, B): ok=False; print("fails", lam)
print("restricted characters agree at fused points:", ok)
v020 = lambda a,b,c: sl2(0,a)*sl2(2,b)*sl2(0,c)
print("V_(0,2,0) at (a,b,a):", v020(A,B,A), " at (b,a,b):", v020(B,A,B))
