"""
GL_6/Sp_6 over F_q((t)): value of T_nu * phi_0 for nu = (0,0,0,0,0,-2) at the orbits
c1 = (2,2,0,0,0,0) and c2 = (1,1,1,1,0,0).
Lattices of type nu: M = O^6 + O t^{-2} v, v primitive, the line [v] in P^5(O/t^2).
x unimodular on M  <=>  x(v, e_j) in t^2 O for all j (x alternating; det condition holds).
Usage: python3 -I gl6_extra_translate.py q
"""
import itertools, sys
q = int(sys.argv[1]) if len(sys.argv) > 1 else 3
# elements of O/t^2 as pairs (c0, c1) = c0 + c1 t
def mul(a, b):
    return ((a[0]*b[0]) % q, (a[0]*b[1] + a[1]*b[0]) % q)
def is_zero(a):
    return a == (0, 0)
def count(a_list):
    # x(e_{2p-1}, e_{2p}) = t^{a_p}; need x(v, e_j) = 0 mod t^2 for all j
    tp = []
    for a in a_list:
        tp.append((1, 0) if a == 0 else ((0, 1) if a == 1 else (0, 0)))  # t^a mod t^2
    n = 0
    elems = [(c0, c1) for c0 in range(q) for c1 in range(q)]
    for v in itertools.product(elems, repeat=6):
        i0 = next((i for i in range(6) if v[i][0] != 0), None)
        if i0 is None or v[i0] != (1, 0):
            continue   # normalise first unit coordinate to 1: one rep per point of P^5(O/t^2)
        ok = True
        for p, tpa in enumerate(tp):
            # x(v, e_{2p}) = t^a v_{2p-1}, x(v, e_{2p-1}) = -t^a v_{2p}
            if not is_zero(mul(tpa, v[2*p])) or not is_zero(mul(tpa, v[2*p+1])):
                ok = False; break
        if ok:
            n += 1
    return n
v1 = count([2, 0, 0]); v2 = count([1, 1, 0])
print('q=%d  T_(0,0,0,0,0,-2)*phi0 at c1=%d (predicted q(q+1)=%d), at c2=%d (predicted 0)' % (q, v1, q*(q+1), v2))
