"""Exact A2 subword enumeration and editable TikZ tiling, standard library only. Run from any directory. The TikZ output goes to the project figures directory, and the JSON record goes next to this script. Group elements use permutations and integral translations in the zero-sum subspace of R^3; all geometry below uses exact integers. """ from pathlib import Path import json HERE = Path(__file__).resolve().parent FIGURES = HERE.parents[2] / 'figures' ID = (1, 2, 3, 0, 0, 0) W0 = (3, 2, 1, 0, 0, 0) GEN = ((3, 2, 1, -1, 0, 1), (2, 1, 3, 0, 0, 0), (1, 3, 2, 0, 0, 0)) ROOT = ((1, -1, 0), (0, 1, -1), (1, 0, -1)) def mul(g, h): return tuple(h[g[i]-1] for i in range(3)) + tuple(h[g[i]+2]+g[i+3] for i in range(3)) def act3(g, v): return tuple(v[g[i]-1]+3*g[i+3] for i in range(3)) def center3(g): return act3(g, (-1, 0, 1)) def length(g): c = center3(g) return sum(abs(sum(x*y for x,y in zip(c,r))//3+1) for r in ROOT) def word(g): result=[] while length(g): for i,s in enumerate(GEN): h=mul(s,g) if length(h)==length(g)-1: result.append(i);g=h;break else: raise AssertionError('No left descent') assert g==ID return result def interval(g): result={ID} for i in word(g): result.update(mul(x,GEN[i]) for x in tuple(result)) return result def dominant(g): c=center3(g) return c[0]>c[1]>c[2] def le(u,v): d=(2*(v[0]-u[0])+v[1]-u[1],v[0]-u[0]+2*(v[1]-u[1])) return all(x>=0 and x%3==0 for x in d) def vertices(g): result=[] for v in ((0,0,0),(-2,1,1),(-1,-1,2)): x=act3(g,v) assert (x[0]-x[1])%3==0 and (x[1]-x[2])%3==0 result.append(((x[0]-x[1])//3,(x[1]-x[2])//3)) return tuple(result) PALETTE={(0,0):'PBgray',(1,0):'PBblue',(2,0):'PBteal', (0,1):'PBviolet',(1,1):'PBorange',(2,1):'PBred', (0,2):'PBteal!65!PBblue',(1,2):'PBviolet!60!PBred',(2,2):'PBblue!55!PBteal'} lam=(4,4) params=sorted(((i,j) for i in range(9) for j in range(9) if le((i,j),lam)), key=lambda p:(sum(p),p)) intervals={} for m in params: t=((2*m[0]+m[1])//3,(-m[0]+m[1])//3,(-m[0]-2*m[1])//3) intervals[m]=interval(mul((1,2,3)+t,W0)) boats={m:intervals[m]-set().union(*(intervals[k] for k in params if k!=m and le(k,m))) for m in params} assert len(intervals[lam])==366 assert sum(map(len,boats.values()))==len(set().union(*boats.values()))==366 assert sum(dominant(g) for g in intervals[lam])==61 rows=[] tex=[r'\begin{tikzpicture}[every node/.style={font=\small}]', r'\begin{scope}[shift={(3cm,.45cm)},PB weight basis,scale=.78]'] for index,m in enumerate(params,1): tris=[vertices(g) for g in sorted(boats[m]) if dominant(g)] color=PALETTE[tuple(min(x,2) for x in m)] counts={} for tri in tris: for a,b in zip(tri,tri[1:]+tri[:1]): key=tuple(sorted((a,b)));counts[key]=counts.get(key,0)+1 path='--'.join(f'({x},{y})' for x,y in tri) tex.append(r'\path[fill='+color+r'!24,draw=white,line width=.3pt] '+path+r'--cycle;') for (a,b),count in counts.items(): if count==1: tex.append(r'\draw[draw='+color+r',line width=.85pt] '+str(a)+r'--'+str(b)+';') # Boat number is placed at the mean of its dominant alcove centroids. u=sum(x for t in tris for x,y in t)/(3*len(tris)) v=sum(y for t in tris for x,y in t)/(3*len(tris)) tex.append(fr'\node[font=\scriptsize,fill=white,inner sep=1pt,text=black!85] at({u:.6f},{v:.6f}) {{$ {index} $}};') rows.append({'index':index,'parameter':m,'zone':tuple(min(x,2) for x in m),'whole_boat':len(boats[m]),'dominant_alcoves':len(tris),'triangles':tris}) tex += [r'\draw[PB wall,->] (0,0)--(7.35,0) node[right] {$m_1$};', r'\draw[PB wall,->] (0,0)--(0,7.35) node[left] {$m_2$};', r'\node[below] at(0,0) {$0$};', r'\end{scope}', r'\begin{scope}[shift={(10.1cm,.45cm)},PB weight basis,scale=.78]', r'\path[fill=PBblue!4,draw=PBblue!60,line width=.8pt] (0,0)--(6,0)--(4,4)--(0,6)--cycle;', r'\draw[PB wall,->] (0,0)--(7.35,0) node[right] {$m_1$};', r'\draw[PB wall,->] (0,0)--(0,7.35) node[left] {$m_2$};'] for i in range(8): for j in range(8): if 2*i+j<=12 and i+2*j<=12: tex.append(fr'\fill[PBgray!45] ({i},{j}) circle (.85pt);') for row in rows: i,j=row['parameter']; color=PALETTE[tuple(row['zone'])] tex.append(fr'\fill[{color}] ({i},{j}) circle(2pt);') tex.append(fr'\node[font=\scriptsize,above=2pt,text=black!85,inner sep=0pt] at({i},{j}) {{$ {row["index"]} $}};') tex += [r'\node[PB label,above] at(4.6,4.6) {$\lambda=(4,4)$};', r'\node[below] at(0,0) {$0$};', r'\node[below right] at(6,0) {$(6,0)$};', r'\node[below left] at(0,6) {$(0,6)$};', r'\end{scope}', r'\node at(3,-.05) {$(a)\quad J_{e,e}(\lambda)\cap W_{\mathrm{aff}}^+$};', r'\node at(10.1,-.05) {$(b)\quad\Pi_\lambda\cap C^+\cap Q^\vee$};', r'\end{tikzpicture}'] (FIGURES/'dominant_tiling.tex').write_text('\n'.join(tex)+'\n',encoding='utf-8') (HERE/'dominant_tiling_audit.json').write_text(json.dumps({'type':'A2','factors':['e','e'],'parameter':lam,'interval':366,'dominant_interval':61,'boats':13,'disjoint_partition_verified':True,'rows':rows},indent=2),encoding='utf-8') print('Verified 366 alcoves, 61 dominant alcoves, 13 disjoint paper boats.')