/ specs / construct_language_cl_norm_3_spec.tex
construct_language_cl_norm_3_spec.tex
  1  \documentclass[11pt]{article}
  2  
  3  \usepackage[margin=1in]{geometry}
  4  \usepackage{microtype}
  5  \usepackage{booktabs}
  6  \usepackage{longtable}
  7  \usepackage[hidelinks]{hyperref}
  8  \usepackage{amsmath}
  9  
 10  \title{CL-NORM-3 --- Canonical Layout Constraints}
 11  \author{}
 12  \date{January 13, 2026}
 13  
 14  \begin{document}
 15  \maketitle
 16  
 17  \section{Purpose}
 18  
 19  CL-NORM-1 makes serialization stable (ordering).
 20  CL-NORM-2 makes scope stable (frame containment inference).
 21  CL-NORM-3 makes \textbf{layout} stable: two authors should converge toward the same geometry for the same construct,
 22  reducing drift in exchange and reducing accidental ambiguity.
 23  
 24  This is not ``word order'' or grammar. It is a \textbf{canonicalization of geometry}.
 25  
 26  \section{Inputs and Outputs}
 27  
 28  \textbf{Input:} instances with quantized transforms (coords/rot/ref/scale), and a scope tree (explicit or inferred).
 29  
 30  \textbf{Output:} instances with canonicalized \texttt{x,y} positions and canonical link geometry hints. Semantics are preserved:
 31  \begin{itemize}
 32    \item glyph IDs unchanged,
 33    \item links unchanged (only their \emph{rendering hints} may be canonicalized),
 34    \item scope is revalidated after layout.
 35  \end{itemize}
 36  
 37  \section{Core Idea: Polar Slots Around an Origin}
 38  
 39  Each scope has an \textbf{origin}:
 40  \begin{itemize}
 41    \item root scope: \((W/2, H/2)\) on the canvas lattice,
 42    \item non-root scope: the center \((x,y)\) of its frame instance.
 43  \end{itemize}
 44  
 45  Within each scope, child instances are placed into a canonical \textbf{polar slot grid}:
 46  
 47  \begin{itemize}
 48    \item \textbf{Angle quantization:} 16 sectors (every \(22.5^\circ\)).
 49    \item \textbf{Ring quantization:} step size \(S_r = 24\) lattice units.
 50    \item \textbf{Rings:} \(r \in \{0, 24, 48, 72, \dots\}\).
 51  \end{itemize}
 52  
 53  \section{Algorithm}
 54  
 55  For each scope \(S\):
 56  
 57  \subsection{Step 1: Choose a Canonical Anchor}
 58  
 59  Select an anchor instance \(A\) (child of \(S\)) by deterministic salience:
 60  
 61  \[
 62  \text{salience}(i) = \big(s(i)\downarrow,\ \text{typePriority}(i)\uparrow,\ \text{glyphID}(i)\uparrow,\ x(i)\uparrow,\ y(i)\uparrow\big)
 63  \]
 64  
 65  Where \(\downarrow\) indicates descending order and typePriority is:
 66  
 67  \[
 68  \text{object} < \text{operator} < \text{relation} < \text{stance} < \text{frame}
 69  \]
 70  
 71  The anchor is placed at the origin (ring \(r=0\)).
 72  
 73  \subsection{Step 2: Quantize Remaining Instances}
 74  
 75  For each non-anchor instance \(X\), compute polar coordinates relative to origin:
 76  
 77  \[
 78  (dx,dy)=(x-x_0, y-y_0), \quad r=\sqrt{dx^2+dy^2}, \quad \theta=\operatorname{atan2}(dy,dx)
 79  \]
 80  
 81  Quantize:
 82  \[
 83  \theta' = \operatorname{round}\Big(\frac{\theta}{2\pi/16}\Big)\cdot\frac{2\pi}{16}, \quad
 84  r' = \operatorname{round}\Big(\frac{r}{S_r}\Big)\cdot S_r
 85  \]
 86  
 87  Then set:
 88  \[
 89  x' = x_0 + r'\cos(\theta'), \quad y' = y_0 + r'\sin(\theta')
 90  \]
 91  
 92  \subsection{Step 3: Collision Resolution}
 93  
 94  If two instances land in the same slot \((r',\theta')\), resolve deterministically:
 95  
 96  \begin{itemize}
 97    \item process instances in canonical order,
 98    \item if occupied, increment ring: \(r' \leftarrow r' + S_r\) until a free slot exists.
 99  \end{itemize}
100  
101  \subsection{Step 4: Clamp to Canvas}
102  
103  After relocation, clamp all coordinates to canvas bounds.
104  
105  \subsection{Step 5: Canonicalize Link Geometry Hints}
106  
107  To avoid author-specific pathing drift, CL-NORM-3 canonicalizes link rendering hints:
108  
109  \begin{itemize}
110    \item set \texttt{geom.kind = "straight"} for all links,
111    \item set \texttt{geom.via = []} (empty) for all links.
112  \end{itemize}
113  
114  Links remain semantically identical; only visual hints are normalized.
115  
116  \subsection{Step 6: Re-run Scope Inference}
117  
118  Because layout changed, re-run CL-NORM-2 containment inference:
119  \begin{itemize}
120    \item in non-strict mode, inferred \texttt{scope} overwrites existing fields,
121    \item in strict mode, mismatches error.
122  \end{itemize}
123  
124  \section{Notes}
125  
126  CL-NORM-3 is intentionally coarse. It provides a stable lattice arrangement without requiring glyph geometry.
127  A future CL-NORM-4 may use actual glyph bounds or signed-distance fields to replace circular radii.
128  
129  \end{document}