/ specs / construct_language_cl_op_1_spec.tex
construct_language_cl_op_1_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-OP-1 --- Operator Binding Rules (Topology-Based Operand Selection)}
 11  \author{}
 12  \date{January 13, 2026}
 13  
 14  \begin{document}
 15  \maketitle
 16  
 17  \section{Purpose}
 18  
 19  CL-REL-1 type-checks graph edges. CL-OP-1 resolves a different ambiguity: \textbf{what subgraph an operator acts on}
 20  when the representation is non-linear and does not use explicit ``argument'' syntax.
 21  
 22  CL-OP-1 defines a deterministic binding rule that uses only:
 23  \begin{itemize}
 24    \item scope (frames),
 25    \item geometry (distance),
 26    \item glyph mask bounds (GML v0.2).
 27  \end{itemize}
 28  
 29  No natural-language grammar is introduced.
 30  
 31  \section{Scope Constraint}
 32  
 33  An operator instance \(O\) binds operands only within its \textbf{effective scope}:
 34  
 35  \[
 36  \operatorname{scope}(X) = \operatorname{scope}(O)
 37  \]
 38  
 39  Root scope is treated as \texttt{\_\_root\_\_}.
 40  
 41  \section{Candidate Set}
 42  
 43  Candidates \(C\) for an operator \(O\) are instances in the same scope excluding:
 44  
 45  \begin{itemize}
 46    \item frames (containers),
 47    \item stances (epistemic overlays),
 48    \item the closure instance (\texttt{G29}),
 49    \item the operator instance itself.
 50  \end{itemize}
 51  
 52  Objects, relations, and other operators may be candidates.
 53  
 54  \section{Binding Radius}
 55  
 56  Using GML v0.2, each glyph has a convex hull. Define a hull radius proxy:
 57  
 58  \[
 59  r_0(G) = \max_{p \in \text{Hull}(G)} \|p - (32,32)\|
 60  \]
 61  
 62  For an operator instance \(O\) with glyph \(G_O\) and scale \(s(O)\), define binding radius:
 63  
 64  \[
 65  R(O) = \max(24,\ r_0(G_O)\cdot s(O) + 8)
 66  \]
 67  
 68  The constant 24 aligns with CL-NORM-3 ring spacing; the additional 8 is a safety margin.
 69  
 70  \section{Deterministic Selection}
 71  
 72  Let \(d(X)\) be Euclidean distance between centers of \(O\) and \(X\).
 73  
 74  \subsection{Primary region}
 75  
 76  Define the in-range set:
 77  \[
 78  C_R = \{X \in C \mid d(X) \le R(O)\}
 79  \]
 80  
 81  \subsection{Ordering}
 82  
 83  Candidates are ordered deterministically by:
 84  \[
 85  (d(X)\uparrow,\ \text{glyphID}(X)\uparrow,\ \text{id}(X)\uparrow)
 86  \]
 87  
 88  \subsection{Operator arity}
 89  
 90  Each operator glyph has a required operand count range \([m, M]\). Examples:
 91  
 92  \begin{itemize}
 93    \item unary operators: Normalize (G79), Hash (G98), Commit (G100), Erase (G101) have \([1,1]\)
 94    \item binary combinators: Fuse (G92), Bind (G94) have \([2,2]\)
 95  \end{itemize}
 96  
 97  \subsection{Binding}
 98  
 99  \begin{enumerate}
100    \item Start with the ordered list \(C_R\).
101    \item If \(|C_R| < m\), extend by taking nearest candidates from \(C \setminus C_R\) until \(m\) is met.
102    \item If \(|C_R| > M\), truncate to the first \(M\) and emit an \textbf{ambiguity warning}.
103    \item If after extension, \(|C| < m\), emit an \textbf{arity error}.
104  \end{enumerate}
105  
106  \section{Validator Output}
107  
108  A validator produces:
109  \begin{itemize}
110    \item \textbf{errors}: operator missing required operands
111    \item \textbf{warnings}: operator has too many nearby operands and was truncated deterministically
112    \item \textbf{bindings}: a derived mapping from operator instance id to operand ids
113  \end{itemize}
114  
115  \section{Notes}
116  
117  CL-OP-1 is intentionally local (radius-based) and scope-limited. Future CL-OP-2 may add containment-based binding
118  (using operator hull overlap) for tighter semantics, but CL-OP-1 is sufficient for deterministic decoding.
119  
120  \end{document}