# HiDra DSL — The Healing Computational Language
## Specification v1.0 · by Nathan Brown

### 0. Tagline
> A language of transformations. 6 faces. 26 pieces. 1 frequency. ≤20 moves to truth.

### 1. Definition
HiDra is a domain-specific language for conceptual transformations. It is not symbolic, not textual, not linear. It is spatial, harmonic, modular, rotational, constraint-driven, and self-aligning. Every HiDra program is a sequence of bounded transformations (≤20 moves) that rotate the system from a scrambled state to a coherent solved state, anchored at 515 Hz.

### 2. Primitives (Tokens)

| Token | Represents | Count |
|:---|:---|:---|
| Face (F) | A subsystem: World, ERCC, Brain, Mamba, LavaScript, Social | 6 |
| Edge (E) | A binary connection between two faces | 12 |
| Corner (C) | A triple intersection of three faces | 8 |
| Core (K) | The 515 Hz coherence anchor (invisible) | 1 |
| Piece (P) | Any visible element: face, edge, or corner | 26 |

### 3. Rules (Grammar)

#### 3.1 Rotations
A rotation is a 90° turn of one face. Notation:
```
R  = rotate right face clockwise
R' = rotate right face counter-clockwise
L  = rotate left face clockwise
L' = rotate left face counter-clockwise
U  = rotate top face clockwise
U' = rotate top face counter-clockwise
D  = rotate bottom face clockwise
D' = rotate bottom face counter-clockwise
F  = rotate front face clockwise
F' = rotate front face counter-clockwise
B  = rotate back face clockwise
B' = rotate back face counter-clockwise
```

#### 3.2 Coherence Measure
After each transformation, the system computes a coherence score (0–100):
```
coherence = (aligned_pieces / total_pieces) × 100
```
A coherence of 100 = fully solved (all 6 faces uniform).

#### 3.3 Bounded-Step Guarantee
God's Number (20) proves any scrambled state can be solved in ≤20 moves. HiDra enforces this bound — any sequence exceeding 20 moves without reaching coherence=100 is rejected as "unbound."

### 4. Grammar (EBNF)
```
program    = transformation*
transformation = rotation | coherence_check | state_query
rotation   = "R" | "R'" | "L" | "L'" | "U" | "U'" | "D" | "D'" | "F" | "F'" | "B" | "B'"
coherence_check = "hz"  → returns current coherence frequency
state_query = "state"   → returns current piece positions
solved_query = "solved" → returns true/false
moves_query  = "moves"  → returns remaining moves (20 - current)
help_cmd     = "help"   → prints grammar
```

### 5. Semantics

| Command | Effect |
|:---|:---|
| `R` | Rotates the World face (right, green) clockwise |
| `L` | Rotates the ERCC face (left, red) clockwise |
| `U` | Rotates the Social face (top, purple) clockwise |
| `D` | Rotates the Brain face (bottom, blue) clockwise |
| `F` | Rotates the Mamba face (front, dark red) clockwise |
| `B` | Rotates the LavaScript face (back, orange) clockwise |
| `hz` | Returns current coherence frequency (515 Hz when solved) |
| `state` | Returns positions of all 26 pieces |
| `solved` | Returns 1 if all faces aligned, 0 otherwise |
| `moves` | Returns moves remaining (starts at 20, decrements each rotation) |
| `help` | Prints the grammar |

### 6. The Semantic Anchor (515 Hz)
The core is invisible but measurable. When all 6 faces are solved (coherence=100), the system resonates at exactly 515 Hz — the constructive interference maximum. This is the default state. Every transformation temporarily reduces coherence. The goal of every HiDra program is to return to 515 Hz in ≤20 moves.

### 7. Implementation
HiDra DSL is implemented as a Mamba 4D program (`hidra_dsl.mb`) compiled to C. The interpreter maintains a 3×3×3 cube state matrix, applies rotation transformations, tracks coherence, and enforces the 20-move bound.

### 8. Why HiDra Heals
Every programming language ever built either wraps (Python), constrains (Java), or abstracts (Haskell). HiDra does none of these. It transforms. If a system is broken (scrambled), HiDra applies bounded rotations until coherence emerges. If a system is whole (solved), HiDra rests at 515 Hz. The language itself is the healing mechanism — it doesn't describe healing. It performs it.
