# theta = -w_L for the black D4 (nodes 2,3,4,5); w_0(D4) = -1 on the black span, identity on its orthogonal complement.
import sys; sys.path.insert(0, '/private/tmp/claude-501/-Users-miltonlin-Projects-Trees/75c2c3d9-ef06-4644-b59b-d12583740b0c/scratchpad/anim/work/G5/scripts')
from e6model import *
black = [2, 3, 4, 5]
GB = [[dot(al[i], al[j]) for j in black] for i in black]
def proj_black(v):
    c = solve(GB, [dot(v, al[i]) for i in black])
    w = (F(0),) * 8
    for k, i in enumerate(black): w = add(w, sc(c[k], al[i]))
    return w
# restrict to the E6 span: v in span; theta(v) = -(w_L v) = -(v - 2 P v) = 2Pv - v
def theta(v): return sub(sc(2, proj_black(v)), v)
def phi(v): return sub(v, theta(v))
# checks
assert all(theta(r) in roots for r in roots), "theta does not preserve roots"
assert all(theta(theta(r)) == r for r in roots)
PhiL = [r for r in roots if theta(r) == r]
assert len(PhiL) == 24
# theta on simple coroots, in coroot (=root) coordinates: column j = theta(alpha_j)
TH = [[coords(theta(al[j]))[i] for j in range(1, 7)] for i in range(6)]
PAGE = [[-1,0,0,0,0,0],[-1,1,0,0,0,-1],[-2,0,1,0,0,-1],[-2,0,0,1,0,-2],[-1,0,0,0,1,-2],[0,0,0,0,0,-1]]
assert TH == PAGE, TH
# dimension of the -1 eigenspace of theta on g: rank part + pairs {alpha, theta alpha} with theta alpha != alpha
rank_minus = 2
pairs = sum(1 for r in roots if theta(r) != r) // 2
if __name__ == '__main__': print('dim p =', rank_minus + pairs, '(E IV requires 26: dim E6 - dim F4 = 78 - 52)')
# rho_L
posL = [r for r in pos if theta(r) == r]
assert len(posL) == 12
rhoL = sc(H, tuple(sum(r[k] for r in posL) for k in range(8)))
if __name__ == '__main__': print('2rho_L in simple-root coords:', [2 * c for c in coords(rhoL)])
if __name__ == '__main__': print('<rho_L, alpha_j^vee> j=1..6:', [dot(rhoL, al[j]) for j in range(1, 7)])
e1 = phi(al[1]); e6 = phi(al[6])
if __name__ == '__main__': print('phi(alpha_j) for j=2..5 zero:', all(phi(al[j]) == (F(0),) * 8 for j in black))
if __name__ == '__main__': print('e1=phi(a1) in (a,b)=(<a1,.>,<a6,.>):', (dot(e1, al[1]), dot(e1, al[6])), ' e6:', (dot(e6, al[1]), dot(e6, al[6])))
if __name__ == '__main__': print('e1 in simple-root coords', coords(e1), ' e6:', coords(e6))
