"""Enumerate ideals in (Z/3^k)[eta]/(eta^2 - 3 eta). Run with Python 3. The direct check builds additive subgroups independently of the lattice formula. It is intended for the three smallest quotients. """ from collections import deque from itertools import product def quotient_ideals(k): modulus = 3**k elements = list(product(range(modulus), repeat=2)) zero = frozenset({(0, 0)}) pending = deque([zero]) seen = {zero} ideals = [] while pending: group = pending.popleft() # Multiplication by eta sends (x,y) to (0,x+3y). if all((0, (x + 3*y) % modulus) in group for x, y in group): ideals.append(group) # Every subgroup of a finite abelian 3-group has a chain from zero # with successive index three. Add each such extension exactly once. covered = set(group) for x, y in elements: if (x, y) in covered or ((3*x) % modulus, (3*y) % modulus) not in group: continue extension = frozenset( ((a + i*x) % modulus, (b + i*y) % modulus) for a, b in group for i in range(3) ) covered.update(extension) if extension not in seen: seen.add(extension) pending.append(extension) return ideals def lattice_count(k): # Columns (3^a,t) and (0,3^b) in the basis (1,eta). return sum( (3**a + 3*t) % (3**b) == 0 and (3**(k-a)*t) % (3**b) == 0 for a in range(k+1) for b in range(k+1) for t in range(3**b) ) if __name__ == "__main__": for k in range(1, 7): predicted = 2*k + 1 + 3*(k-1)**2 count = lattice_count(k) assert count == predicted direct = len(quotient_ideals(k)) if k <= 3 else None assert direct is None or direct == count print(f"k={k} lattice={count} direct={direct if direct is not None else 'skipped'}")