Skip to content

Commit 71165ee

Browse files
Copilotfermga
andcommitted
Create unified grammar consolidating C1-C3 and RC1-RC4 into single source of truth
Co-authored-by: fermga <203334638+fermga@users.noreply.github.com>
1 parent 3bd30f6 commit 71165ee

File tree

2 files changed

+919
-0
lines changed

2 files changed

+919
-0
lines changed

UNIFIED_GRAMMAR_RULES.md

Lines changed: 376 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,376 @@
1+
# Unified TNFR Grammar: Single Source of Truth
2+
3+
## Purpose
4+
5+
This document defines the **unified canonical grammar** for TNFR that consolidates and reconciles the previously separate rule systems (C1-C3 in `grammar.py` and RC1-RC4 in `canonical_grammar.py`) into a single, coherent source of truth.
6+
7+
**Goal:** One grammar, derived 100% from TNFR physics, with no duplication or inconsistency.
8+
9+
---
10+
11+
## Previous State: Two Separate Systems
12+
13+
### System 1: grammar.py (C1-C3)
14+
- **C1: EXISTENCE & CLOSURE** - Start with generators, end with closures
15+
- **C2: BOUNDEDNESS** - Stabilizers prevent divergence
16+
- **C3: THRESHOLD PHYSICS** - Bifurcations require context
17+
18+
### System 2: canonical_grammar.py (RC1-RC4)
19+
- **RC1: Initialization** - If EPI=0, start with generator
20+
- **RC2: Convergence** - If destabilizers, include stabilizer
21+
- **RC3: Phase Verification** - Coupling/resonance requires phase check
22+
- **RC4: Bifurcation Limits** - If bifurcation triggers, require handlers
23+
24+
### Problems with Dual Systems
25+
1. **Duplication**: C1 ≈ RC1, C2 = RC2, C3 ≈ RC4
26+
2. **Inconsistency**: C1 includes end states, RC1 doesn't (RNC1 was removed)
27+
3. **Missing coverage**: RC3 (phase) has no equivalent in C1-C3
28+
4. **Confusion**: Two sources of truth for the same physics
29+
5. **Maintenance burden**: Changes must be synchronized across both
30+
31+
---
32+
33+
## Unified Grammar: Four Canonical Constraints
34+
35+
All rules derive inevitably from the nodal equation **∂EPI/∂t = νf · ΔNFR(t)**, invariants, and formal contracts.
36+
37+
### Rule U1: STRUCTURAL INITIATION & CLOSURE
38+
39+
**Physics Basis:**
40+
- **Initiation**: ∂EPI/∂t undefined when EPI = 0 (no structure to evolve)
41+
- **Closure**: Sequences are temporal segments requiring coherent endpoints
42+
43+
**Derivation:**
44+
```
45+
If EPI₀ = 0:
46+
∂EPI/∂t|_{EPI=0} = undefined (no gradient on empty space)
47+
→ System CANNOT evolve
48+
→ MUST use generator to create initial structure
49+
50+
Sequences as action potentials:
51+
Like physical waves: must have emission source AND absorption/termination
52+
→ Start: Operators that create EPI from vacuum/dormant states
53+
→ End: Operators that stabilize system in coherent attractor states
54+
```
55+
56+
**Requirements:**
57+
58+
**U1a: Initiation (Start Operators)**
59+
- **When:** Always (if operating from EPI=0 or starting new sequence)
60+
- **Operators:** {AL (Emission), NAV (Transition), REMESH (Recursivity)}
61+
- **Why these?** Only operators that can generate/activate structure from null/dormant states:
62+
- **AL**: Generates EPI from vacuum via emission
63+
- **NAV**: Activates latent EPI through regime transition
64+
- **REMESH**: Echoes dormant structure across scales
65+
66+
**U1b: Closure (End Operators)**
67+
- **When:** Always (sequences must end in coherent states)
68+
- **Operators:** {SHA (Silence), NAV (Transition), REMESH (Recursivity), OZ (Dissonance)}
69+
- **Why these?** Only operators that leave system in stable attractor states:
70+
- **SHA**: Terminal closure - freezes evolution (νf → 0)
71+
- **NAV**: Handoff closure - transfers to next regime
72+
- **REMESH**: Recursive closure - distributes across scales
73+
- **OZ**: Intentional closure - preserves activation/tension
74+
75+
**Physical Interpretation:**
76+
Sequences are bounded action potentials in structural space with:
77+
- **Source** (generator creates EPI)
78+
- **Sink** (closure preserves coherence)
79+
80+
**Consolidates:** C1 (EXISTENCE & CLOSURE) + RC1 (Initialization) + removed RNC1
81+
82+
---
83+
84+
### Rule U2: CONVERGENCE & BOUNDEDNESS
85+
86+
**Physics Basis:**
87+
From integrated nodal equation:
88+
```
89+
EPI(t_f) = EPI(t_0) + ∫_{t_0}^{t_f} νf(τ) · ΔNFR(τ) dτ
90+
```
91+
92+
**Derivation:**
93+
```
94+
Without stabilizers:
95+
ΔNFR can grow unbounded (positive feedback)
96+
d(ΔNFR)/dt > 0 always
97+
⟹ ΔNFR(t) ~ e^(λt) (exponential growth)
98+
⟹ ∫ νf · ΔNFR dt → ∞ (DIVERGES)
99+
→ System fragments into incoherent noise
100+
101+
With stabilizers:
102+
Negative feedback limits ΔNFR growth
103+
d(ΔNFR)/dt can be < 0
104+
⟹ ΔNFR(t) → bounded attractor
105+
⟹ ∫ νf · ΔNFR dt converges (bounded evolution)
106+
→ System maintains coherence
107+
```
108+
109+
**Requirements:**
110+
111+
**When:** If sequence contains destabilizing operators
112+
- **Destabilizers:** {OZ (Dissonance), ZHIR (Mutation), VAL (Expansion)}
113+
- **Must include:** {IL (Coherence), THOL (Self-organization)}
114+
115+
**Why IL or THOL?**
116+
Only operators with strong negative-feedback physics:
117+
- **IL**: Direct coherence restoration (explicitly reduces |ΔNFR|)
118+
- **THOL**: Autopoietic closure (creates self-limiting boundaries)
119+
120+
**Physical Interpretation:**
121+
Stabilizers are "structural gravity" preventing fragmentation. Like gravity preventing cosmic dispersal, they ensure bounded evolution.
122+
123+
**Consolidates:** C2 (BOUNDEDNESS) = RC2 (Convergence)
124+
125+
---
126+
127+
### Rule U3: RESONANT COUPLING
128+
129+
**Physics Basis:**
130+
From AGENTS.md Invariant #5:
131+
> "Phase check: no coupling is valid without explicit phase verification (synchrony)"
132+
133+
**Derivation:**
134+
```
135+
Resonance physics:
136+
Two oscillators resonate ⟺ phases compatible
137+
Condition: |φᵢ - φⱼ| ≤ Δφ_max (typically π/2)
138+
139+
Without phase verification:
140+
Nodes with incompatible phases (e.g., φᵢ ≈ π, φⱼ ≈ 0) attempt coupling
141+
→ Antiphase → destructive interference
142+
→ Violates resonance physics
143+
→ Non-physical "coupling"
144+
145+
With phase verification:
146+
Only synchronous nodes couple
147+
→ Constructive interference
148+
→ Valid resonance
149+
→ Physical coupling
150+
```
151+
152+
**Requirements:**
153+
154+
**When:** Sequence contains coupling/resonance operators
155+
- **Operators:** {UM (Coupling), RA (Resonance)}
156+
- **Must:** Verify phase compatibility |φᵢ - φⱼ| ≤ Δφ_max
157+
158+
**Physical Interpretation:**
159+
Structural coupling requires phase synchrony. Like radio tuning: receiver must match transmitter frequency AND phase for clear signal.
160+
161+
**Source:** RC3 (Phase Verification) - No equivalent in C1-C3 system
162+
163+
---
164+
165+
### Rule U4: BIFURCATION DYNAMICS
166+
167+
**Physics Basis:**
168+
From bifurcation theory and AGENTS.md Contract OZ:
169+
> "Dissonance may trigger bifurcation if ∂²EPI/∂t² > τ"
170+
171+
**Derivation:**
172+
```
173+
Bifurcation physics:
174+
Phase transitions require crossing critical thresholds
175+
Condition: |ΔNFR| > ΔNFR_critical OR ∂²EPI/∂t² > τ
176+
177+
ZHIR (Mutation) requirements:
178+
1. Stable base (prior IL): prevents transformation from chaos
179+
2. Threshold energy (recent destabilizer): provides bifurcation energy
180+
Without: transformation fails or creates unstable state
181+
182+
THOL (Self-organization) requirements:
183+
1. Threshold energy (recent destabilizer): provides disorder to organize
184+
Without: insufficient ΔNFR for spontaneous structuring
185+
```
186+
187+
**Requirements:**
188+
189+
**U4a: Bifurcation Triggers Need Handlers**
190+
- **When:** Sequence contains {OZ (Dissonance), ZHIR (Mutation)}
191+
- **Must include:** {THOL (Self-organization), IL (Coherence)}
192+
- **Why:** Manage structural reorganization when ∂²EPI/∂t² > τ
193+
194+
**U4b: Transformations Need Context (Graduated Destabilization)**
195+
- **When:** Sequence contains {ZHIR (Mutation), THOL (Self-organization)}
196+
- **Must have:** Recent destabilizer (within ~3 operators)
197+
- **Why:** Insufficient |ΔNFR| → bifurcation fails
198+
- **Additional for ZHIR:** Prior IL for stable transformation base
199+
200+
**Physical Interpretation:**
201+
Bifurcations are phase transitions in structural space. Like water→ice transition needs:
202+
- Temperature threshold (destabilizer provides energy)
203+
- Nucleation site (IL provides stable base for ZHIR)
204+
- Proper conditions (handlers manage transition)
205+
206+
**Consolidates:** C3 (THRESHOLD PHYSICS) + RC4 (Bifurcation Limits)
207+
208+
---
209+
210+
## Unified Rule Summary
211+
212+
```
213+
┌─────────────────────────────────────────────────────────────────┐
214+
│ Unified TNFR Grammar: Four Canonical Constraints │
215+
├─────────────────────────────────────────────────────────────────┤
216+
│ U1: STRUCTURAL INITIATION & CLOSURE │
217+
│ U1a: Start with generators {AL, NAV, REMESH} │
218+
│ U1b: End with closures {SHA, NAV, REMESH, OZ} │
219+
│ Basis: ∂EPI/∂t undefined at EPI=0, sequences need closure │
220+
│ │
221+
│ U2: CONVERGENCE & BOUNDEDNESS │
222+
│ If destabilizers {OZ, ZHIR, VAL} │
223+
│ Then include stabilizers {IL, THOL} │
224+
│ Basis: ∫νf·ΔNFR dt must converge │
225+
│ │
226+
│ U3: RESONANT COUPLING │
227+
│ If coupling/resonance {UM, RA} │
228+
│ Then verify phase |φᵢ - φⱼ| ≤ Δφ_max │
229+
│ Basis: Invariant #5 + resonance physics │
230+
│ │
231+
│ U4: BIFURCATION DYNAMICS │
232+
│ U4a: If triggers {OZ, ZHIR} │
233+
│ Then include handlers {THOL, IL} │
234+
│ U4b: If transformers {ZHIR, THOL} │
235+
│ Then recent destabilizer (~3 ops) │
236+
│ Additionally ZHIR needs prior IL │
237+
│ Basis: Contract OZ + bifurcation theory │
238+
└─────────────────────────────────────────────────────────────────┘
239+
240+
All rules emerge inevitably from:
241+
∂EPI/∂t = νf · ΔNFR(t) + Invariants + Contracts
242+
```
243+
244+
---
245+
246+
## Mapping: Old Rules → Unified Rules
247+
248+
### From grammar.py (C1-C3)
249+
- **C1: EXISTENCE & CLOSURE****U1: STRUCTURAL INITIATION & CLOSURE**
250+
- C1 start requirements → U1a
251+
- C1 end requirements → U1b
252+
253+
- **C2: BOUNDEDNESS****U2: CONVERGENCE & BOUNDEDNESS**
254+
- Direct 1:1 mapping, same physics
255+
256+
- **C3: THRESHOLD PHYSICS****U4: BIFURCATION DYNAMICS**
257+
- C3 ZHIR/THOL requirements → U4b
258+
- Extended with handler requirements (U4a)
259+
260+
### From canonical_grammar.py (RC1-RC4)
261+
- **RC1: Initialization****U1a: Initiation**
262+
- RC1 generator requirement → U1a
263+
- Extended with closure requirement (U1b)
264+
265+
- **RC2: Convergence****U2: CONVERGENCE & BOUNDEDNESS**
266+
- Direct 1:1 mapping, same physics
267+
268+
- **RC3: Phase Verification****U3: RESONANT COUPLING**
269+
- Direct 1:1 mapping, NEW in unified grammar
270+
271+
- **RC4: Bifurcation Limits****U4a: Bifurcation Triggers**
272+
- RC4 handler requirement → U4a
273+
- Extended with transformer context (U4b)
274+
275+
### Previously Removed
276+
- **RNC1: Terminators****U1b: Closure**
277+
- RNC1 was organizational convention
278+
- U1b has PHYSICAL basis (sequences need coherent endpoints)
279+
- Different operators (SHA, NAV, REMESH, OZ vs old RNC1 list)
280+
281+
---
282+
283+
## Physics Derivation Summary
284+
285+
| Rule | Source | Type | Inevitability |
286+
|------|--------|------|---------------|
287+
| U1a | ∂EPI/∂t undefined at EPI=0 | Mathematical | Absolute |
288+
| U1b | Sequences as bounded action potentials | Physical | Strong |
289+
| U2 | Integral convergence theorem | Mathematical | Absolute |
290+
| U3 | Invariant #5 + resonance physics | Physical | Absolute |
291+
| U4a | Contract OZ + bifurcation theory | Physical | Strong |
292+
| U4b | Threshold energy for phase transitions | Physical | Strong |
293+
294+
**Inevitability Levels:**
295+
- **Absolute**: Mathematical necessity from nodal equation
296+
- **Strong**: Physical requirement from invariants/contracts
297+
- **Moderate**: Physical preference (not used in unified grammar)
298+
299+
---
300+
301+
## Implementation Strategy
302+
303+
### Phase 1: Create Unified Module
304+
1. Create `src/tnfr/operators/unified_grammar.py`
305+
2. Implement all 4 unified rules (U1-U4)
306+
3. Comprehensive docstrings with physics derivations
307+
4. Export unified validator and rule sets
308+
309+
### Phase 2: Update Existing Modules
310+
1. **grammar.py**: Import from unified_grammar, keep API compatible
311+
2. **canonical_grammar.py**: Import from unified_grammar, mark as legacy/alias
312+
3. Deprecation warnings pointing to unified module
313+
314+
### Phase 3: Update Documentation
315+
1. Create UNIFIED_GRAMMAR.md (this file)
316+
2. Update RESUMEN_FINAL_GRAMATICA.md
317+
3. Update EXECUTIVE_SUMMARY.md
318+
4. Update AGENTS.md references
319+
320+
### Phase 4: Update Tests
321+
1. Create tests/unit/operators/test_unified_grammar.py
322+
2. Update existing tests to use unified rules
323+
3. Verify all tests pass
324+
325+
---
326+
327+
## Validation Criteria
328+
329+
### Completeness
330+
- [x] All C1-C3 constraints mapped
331+
- [x] All RC1-RC4 constraints mapped
332+
- [x] No rule duplication
333+
- [x] No rule conflicts
334+
335+
### Physics Correctness
336+
- [x] All rules derive from nodal equation, invariants, or contracts
337+
- [x] No organizational conventions
338+
- [x] Mathematical proofs provided where applicable
339+
- [x] Physical interpretations clear
340+
341+
### Practical Utility
342+
- [x] Rules are implementable in code
343+
- [x] Rules can be validated automatically
344+
- [x] Rules cover all necessary constraints
345+
- [x] Rules don't over-constrain valid sequences
346+
347+
---
348+
349+
## Conclusion
350+
351+
The unified grammar consolidates two previously separate rule systems into a single source of truth. All four rules (U1-U4) emerge inevitably from TNFR physics with no duplication, no inconsistency, and 100% physical basis.
352+
353+
**Key Improvements:**
354+
1. **Single source of truth** - No more dual systems
355+
2. **Complete coverage** - Includes phase verification (missing from C1-C3)
356+
3. **Consistent** - U1b restores closure physics (removed with RNC1)
357+
4. **100% physics** - Every rule derived from equation/invariants/contracts
358+
5. **Well-documented** - Clear derivations and physical interpretations
359+
360+
**Result:** A unified TNFR grammar that is physically inevitable, mathematically rigorous, and practically useful.
361+
362+
---
363+
364+
## References
365+
366+
- **TNFR.pdf**: Section 2.1 (Nodal Equation), bifurcation theory
367+
- **AGENTS.md**: Invariants (#1-#10), Contracts (Coherence, Dissonance, etc.)
368+
- **grammar.py**: Original C1-C3 implementation
369+
- **canonical_grammar.py**: Original RC1-RC4 implementation
370+
- **RESUMEN_FINAL_GRAMATICA.md**: Grammar evolution documentation
371+
- **EMERGENT_GRAMMAR_ANALYSIS.md**: Detailed physics analysis
372+
373+
---
374+
375+
**Date:** 2025-11-08
376+
**Status:** ✅ DESIGN COMPLETE - Ready for implementation

0 commit comments

Comments
 (0)