@@ -154,6 +154,44 @@ Apply framing or self-writhe (D1.18, context-dependent):
154154| `cup(e, f)` | Attach cup (∪-shaped connection)
155155|===
156156
157+ == Compositional PD Compiler API
158+
159+ The compiler library includes `Tangle.Compositional`, a focused API for:
160+
161+ * compositional AST nodes (generators, compose, tensor, close)
162+ * parser adapter from language expressions into the compositional subset
163+ * compilation to a PlanarDiagram-equivalent IR
164+ * pure Skein hook payload generation (`pdv1` + PD tuple entries)
165+
166+ This API intentionally excludes invariant computation and persistence.
167+
168+ [source,ocaml]
169+ ----
170+ open Tangle.Compositional
171+
172+ let trefoil_expr = close (braid [
173+ { index = 1; exponent = 1 };
174+ { index = 1; exponent = 1 };
175+ { index = 1; exponent = 1 };
176+ ])
177+
178+ let trefoil_compiled = compile trefoil_expr
179+ (* => ClosedDiagram pd, with 3 crossings *)
180+
181+ let figure_eight_compiled =
182+ compile_source_expr "close(braid[s1, s2^-1, s1, s2^-1])"
183+ (* => ClosedDiagram pd, with 4 crossings *)
184+ ----
185+
186+ [source,ocaml]
187+ ----
188+ let sink payload =
189+ Printf.printf "name=%s pd=%s\n" payload.name payload.pd_blob
190+
191+ let _ =
192+ compile_and_send_to_skein sink ~name:"trefoil" trefoil_expr
193+ ----
194+
157195== Example Programs
158196
159197=== Identity Twist (Trivial Knot)
0 commit comments