# GL4/Sp4 at varpi J: all varpi J-unimodular lattices M subset t^{-L}O^4, by type,
# compared with the GSp4 Macdonald prediction:
#   type (a,b,-1-b,-1-a): q^{6a}(q+1)(q^2+1) if a=b, q^{4a+2b-1}(q+1)^2(q^2+1) if a>b; 0 otherwise.
import sys, time
exec(open('/private/tmp/claude-501/-Users-miltonlin-Projects-Trees/f0f18b89-aa0d-4ce6-93d2-78c269eb7d7d/scratchpad/salvage/S1/engine.py').read())
p = int(sys.argv[1]); L = int(sys.argv[2])
t0 = time.time()
cnt = count_types((1, 1), p, lo=[-L]*4, hi=[L+1]*4, total_d=-2, shift=L, prec=4*L+6)
print('q=%d box t^{-%d}: %.1fs' % (p, L, time.time()-t0))
ok = True
for ty, c in sorted(cnt.items()):
    a, b, c3, c4 = ty
    pred = None
    if c3 == -1 - b and c4 == -1 - a and a >= b >= 0:
        pred = p**(6*a)*(p+1)*(p*p+1) if a == b else p**(4*a+2*b-1)*(p+1)**2*(p*p+1)
    print('  type', ty, 'lambda', tuple(-v for v in reversed(ty)), 'count', c, 'predicted', pred)
    ok &= (pred == c)
# predicted types inside the box that did not occur
for a in range(0, L):
    for b in range(0, a+1):
        if -1-a >= -L and (a, b, -1-b, -1-a) not in cnt:
            print('  MISSING predicted type', (a, b, -1-b, -1-a)); ok = False
print('all agree:', ok)
