1 // Package axiom defines the seed crystal: the axiom pair from which all
2 // lattice dynamics derive.
3 //
4 // Coherence is determinism. Incoherence is nondeterminism.
5 //
6 // These two interfaces are the only hand-written structure. Everything
7 // else is grown.
8 package axiom
9 10 // Constraint defines the shape of what fits at a lattice site.
11 // A constraint is negative space — it specifies what an occupant must
12 // satisfy without specifying the occupant itself.
13 type Constraint interface {
14 // Tag identifies the type layer this constraint belongs to.
15 // Constraints from different type layers cannot cross-bond.
16 Tag() string
17 18 // Admits reports whether an element satisfies this constraint.
19 Admits(Element) bool
20 }
21 22 // Element is the minimal unit that can exist in either the coherent
23 // (lattice-bound) or incoherent (dissolved) state.
24 type Element interface {
25 // Type returns the element's type tag. An element can only bond
26 // at sites whose constraints share its type layer.
27 Type() string
28 29 // Value returns the element's content — opaque to the lattice,
30 // meaningful only to the constraint that admits it.
31 Value() any
32 }
33 34 // Coherent describes something that has constraints and can be checked
35 // against them. The lattice. The crystalline state. The axiom side.
36 type Coherent interface {
37 // Constraints returns the constraint envelope at this position —
38 // the negative space that defines what can bond here.
39 Constraints() []Constraint
40 41 // Satisfies reports whether this structure satisfies a given
42 // constraint. Used when two lattice regions meet (anastomosis)
43 // to check alignment compatibility.
44 Satisfies(Constraint) bool
45 }
46 47 // Incoherent describes something that can dissolve into elements and
48 // report availability. The solution. The dissolved state. The inverse.
49 type Incoherent interface {
50 // Dissolve breaks this structure into its constituent elements,
51 // returning them to the free-floating pool.
52 Dissolve() []Element
53 54 // Available reports whether this substrate has elements that
55 // could potentially bond into a lattice.
56 Available() bool
57 }
58 59 // Layer identifies a type layer in the coherence field. Constraints and
60 // elements belong to layers. Cross-layer bonding is structurally prevented
61 // — a procedural element cannot nucleate in a lexical region.
62 type Layer struct {
63 Name string // e.g. "lexical", "syntactic", "semantic"
64 Depth int // 0 = coarsest, higher = finer grain
65 }
66 67 // StickyElement extends Element with dissolution resistance.
68 // Elements implementing this interface with IsSticky() == true
69 // survive dissolution regardless of lock-in depth.
70 type StickyElement interface {
71 Element
72 IsSticky() bool
73 }
74 75 // LayeredElement extends Element with layer information.
76 type LayeredElement interface {
77 Element
78 Layer() Layer
79 }
80 81 // LayeredConstraint extends Constraint with layer information and
82 // hierarchical alignment checking.
83 type LayeredConstraint interface {
84 Constraint
85 86 // Layer returns the type layer this constraint operates in.
87 Layer() Layer
88 89 // Aligns reports whether an element's layer is compatible with
90 // this constraint's layer. The coherence field: preventing
91 // cross-layer bonding without directing individual elements.
92 Aligns(LayeredElement) bool
93 }
94 95 // PermutedElement extends Element with an S_3 projection angle.
96 // Elements implementing this interface carry a permutation index (0-5)
97 // that determines which variant transition table governs the lattice
98 // node they bond to. The permutation reorders the 3 trigram axes
99 // (Bonding, Constraint, Energy), giving each element its own "shadow"
100 // of the hexagram dynamics.
101 type PermutedElement interface {
102 Element
103 Permutation() uint8 // 0-5, index into S_3
104 }
105 106 // ProjectedElement extends Element with the full cubic projection encoding.
107 // Elements implementing this interface carry a 6-bit projection identity
108 // (3-bit vertex + 3-bit key) plus a path index encoding the rendering
109 // sequence — the temporal order of growth.
110 type ProjectedElement interface {
111 Element
112 ProjectionVertex() uint8 // 0-7: which cube vertex
113 ProjectionKey() uint8 // 0-7: which projection direction
114 ProjectionPath() uint16 // path index: rendering sequence
115 }
116 117 // HexagramElement extends Element with hexagram-encoded value.
118 // Elements implementing this interface carry their value as a sequence
119 // of 6-bit hexagram tokens (0-63) alongside the raw value. The encoding
120 // is deterministic and reversible: 3 bytes → 4 tokens (24 bits = 4 × 6 bits).
121 type HexagramElement interface {
122 Element
123 HexTokens() []uint8 // 6-bit hexagram tokens (each in 0-63)
124 OrigLen() int // original byte length before encoding
125 }
126 127 // ContextualConstraint extends Constraint with neighborhood awareness.
128 // During bonding, the lattice checks whether the element's causal
129 // prerequisites are satisfied by examining occupied neighbors.
130 // This allows the lattice to learn causal correctness structurally.
131 type ContextualConstraint interface {
132 Constraint
133 134 // AdmitsInContext checks whether the element can bond at this
135 // position given the neighborhood. The neighbors slice contains
136 // the occupants of all neighboring nodes (nil entries for vacant).
137 AdmitsInContext(elem Element, neighbors []Element) bool
138 }
139