# Rank-two gluing data along the Brion path for w_gamma1 (E6/F4), left-action conventions.
import sys
sys.argv = ['x']
exec(open('/private/tmp/claude-501/-Users-miltonlin-Projects-Trees/75c2c3d9-ef06-4644-b59b-d12583740b0c/scratchpad/solve-vi/A3/e6_charp_checks.py').read().split('# ---- matrices for Weyl group elements')[0].replace('print(', 'pass; (lambda *a, **k: None)('))
def word_op(word):
    def f(v):
        for i in reversed(word): v = refl(i, v)
        return v
    return f
def neg(v): return tuple(-x for x in v)
def add(u,v): return tuple(a+b for a,b in zip(u,v))
def analyse(vword, d, e):
    vinv = word_op(list(reversed(vword)))
    Pv = set(vinv(r) for r in pos)
    dp, ep = vinv(simple[d]), vinv(simple[e])
    lev = [r for r in allroots if r in (dp, ep, neg(dp), neg(ep), add(dp,ep), neg(add(dp,ep)))]
    lev = sorted(set(lev))
    parab = Pv | set(lev)
    Gamma = [g for g in lev if theta(g) in parab and g in parab]
    thetalev = [g for g in lev if theta(g) in lev]
    # rank of image of T^theta in the adjoint torus of the Levi: characters d', e' restricted to T^theta
    # T^theta has cocharacters = black coroots; restriction of a root r to T^theta = (<r, a_j^vee>)_{j black}
    rest = [[pair(r, simple[j]) for j in black] for r in (dp, ep)]
    # rank of 2x4 integer matrix
    import itertools
    rk = 0
    if any(any(x for x in row) for row in rest): rk = 1
    for c in itertools.combinations(range(4),2):
        if rest[0][c[0]]*rest[1][c[1]] - rest[0][c[1]]*rest[1][c[0]] != 0: rk = 2
    return dict(delta_=dp, eps_=ep, levi_roots=len(lev), Gamma=[g for g in Gamma], theta_maps_levi_roots_into_levi=thetalev,
                rank_Ttheta_image=rk, theta_dp=theta(dp), theta_ep=theta(ep))
cases = [([0],0,2), ([2,0],2,3), ([3,2,0],3,1), ([3,2,0],3,4), ([3,2,0],1,4), ([1,3,2,0],1,4)]
for vw,d,e in cases:
    r = analyse(vw,d,e)
    print("vertex s_",[i+1 for i in vw], "edges alpha%d,alpha%d:"%(d+1,e+1), r)
