@@ -20,7 +20,149 @@ This directory contains **executable Python examples** that demonstrate TNFR gra
2020
2121## Available Examples
2222
23- ### 01-basic-bootstrap.py
23+ ### Constraint-Focused Examples (NEW)
24+
25+ #### u1-initiation-closure-examples.py
26+
27+ ** Level:** Beginner
28+ ** Constraint:** U1 (Structural Initiation & Closure)
29+ ** Focus:** U1a (Initiation), U1b (Closure)
30+
31+ ** Demonstrates:**
32+ - Valid generator patterns (AL, NAV, REMESH)
33+ - Valid closure patterns (SHA, NAV, REMESH, OZ)
34+ - When U1a applies (EPI=0 vs EPI>0)
35+ - Dual-role operators (NAV, REMESH)
36+ - Common anti-patterns and mistakes
37+
38+ ** Run:**
39+ ``` bash
40+ python docs/grammar/examples/u1-initiation-closure-examples.py
41+ ```
42+
43+ ** Sections:**
44+ - U1a valid examples (starting with generators)
45+ - U1a invalid examples (missing generators)
46+ - U1a context (when initiation applies)
47+ - U1b valid examples (ending with closures)
48+ - U1b invalid examples (missing closures)
49+ - Dual role operators
50+
51+ ** Key Learning:**
52+ - Cannot evolve from EPI=0 without generator
53+ - All sequences need closure operator
54+ - Some operators serve multiple roles
55+
56+ ---
57+
58+ #### u2-convergence-examples.py
59+
60+ ** Level:** Intermediate
61+ ** Constraint:** U2 (Convergence & Boundedness)
62+ ** Focus:** Stabilizer-destabilizer balance
63+
64+ ** Demonstrates:**
65+ - Valid balanced sequences
66+ - Invalid unbalanced sequences
67+ - When U2 applies (has destabilizers)
68+ - Operator classification
69+ - Ordering importance
70+ - Anti-patterns (masking, accumulation)
71+
72+ ** Run:**
73+ ``` bash
74+ python docs/grammar/examples/u2-convergence-examples.py
75+ ```
76+
77+ ** Sections:**
78+ - U2 valid examples (balanced)
79+ - U2 invalid examples (unbalanced)
80+ - U2 not applicable (no destabilizers)
81+ - Operator classification
82+ - Ordering matters (stabilizer placement)
83+ - Masking anti-pattern
84+ - Interleaving pattern (best practice)
85+
86+ ** Key Learning:**
87+ - Without stabilizers: ∫νf·ΔNFR dt → ∞
88+ - Stabilizer order matters
89+ - Interleave for better control
90+
91+ ---
92+
93+ #### u3-resonant-coupling-examples.py
94+
95+ ** Level:** Intermediate
96+ ** Constraint:** U3 (Resonant Coupling)
97+ ** Focus:** Phase verification requirement
98+
99+ ** Demonstrates:**
100+ - Phase compatibility checking
101+ - Coupling/resonance operators
102+ - Sequence-level validation
103+ - Wave interference physics
104+ - Anti-patterns (no check, phase drift)
105+
106+ ** Run:**
107+ ``` bash
108+ python docs/grammar/examples/u3-resonant-coupling-examples.py
109+ ```
110+
111+ ** Sections:**
112+ - Phase compatibility examples
113+ - Coupling/resonance operator requirements
114+ - Sequence-level validation (meta-rule)
115+ - Anti-pattern: No phase check
116+ - Anti-pattern: Phase drift
117+ - Threshold considerations
118+ - Wave interference physics
119+
120+ ** Key Learning:**
121+ - Phase check is MANDATORY (Invariant #5 )
122+ - |φᵢ - φⱼ| ≤ π/2 typically required
123+ - Antiphase = destructive interference
124+
125+ ---
126+
127+ #### u4-bifurcation-examples.py
128+
129+ ** Level:** Advanced
130+ ** Constraint:** U4 (Bifurcation Dynamics)
131+ ** Focus:** U4a (Triggers need handlers), U4b (Transformers need context)
132+
133+ ** Demonstrates:**
134+ - Valid bifurcation sequences
135+ - Invalid uncontrolled bifurcations
136+ - Transformer context requirements
137+ - ZHIR-specific requirements
138+ - Anti-patterns (cascades, wrong handlers, window violations)
139+
140+ ** Run:**
141+ ``` bash
142+ python docs/grammar/examples/u4-bifurcation-examples.py
143+ ```
144+
145+ ** Sections:**
146+ - U4a valid examples (triggers with handlers)
147+ - U4a invalid examples (uncontrolled)
148+ - U4b valid examples (transformers with context)
149+ - U4b invalid examples (missing context)
150+ - Operator classification
151+ - ZHIR-specific requirements
152+ - Anti-pattern: Bifurcation cascade
153+ - Anti-pattern: Context window violation
154+ - Handler selection best practices
155+
156+ ** Key Learning:**
157+ - Bifurcations need control (U4a)
158+ - Transformers need energy (U4b)
159+ - ZHIR needs stable base + recent destabilizer
160+
161+ ---
162+
163+ ### Pattern-Based Examples (EXISTING)
164+
165+ #### 01-basic-bootstrap.py
24166
25167** Level:** Beginner
26168** Pattern:** Bootstrap (minimal)
@@ -32,29 +174,14 @@ This directory contains **executable Python examples** that demonstrate TNFR gra
32174- Minimal valid sequence
33175- Basic telemetry export
34176
35- ** Concepts covered:**
36- - Creating nodes from vacuum (EPI=0)
37- - Applying operators
38- - Measuring coherence
39-
40177** Run:**
41178``` bash
42- python examples/01-basic-bootstrap.py
43- ```
44-
45- ** Expected output:**
46- ```
47- ✓ Bootstrap sequence valid
48- Initial: EPI=0.000, vf=1.000
49- After Emission: EPI=0.XXX, vf=1.XXX
50- After Coherence: EPI=0.XXX, vf=1.XXX, dnfr reduced
51- After Silence: EPI=0.XXX, vf~0.000 (frozen)
52- Coherence: C(t)=X.XXX
179+ python docs/grammar/examples/01-basic-bootstrap.py
53180```
54181
55182---
56183
57- ### 02-intermediate-exploration.py
184+ #### 02-intermediate-exploration.py
58185
59186** Level:** Intermediate
60187** Pattern:** Controlled exploration
@@ -65,29 +192,14 @@ Coherence: C(t)=X.XXX
65192- U4a: Bifurcation trigger (Dissonance) with handler (Coherence)
66193- Exploration with stability
67194
68- ** Concepts covered:**
69- - Destabilization-stabilization cycles
70- - |ΔNFR| dynamics
71- - Coherence preservation
72- - Controlled perturbation
73-
74195** Run:**
75196``` bash
76- python examples/02-intermediate-exploration.py
77- ```
78-
79- ** Expected output:**
80- ```
81- ✓ Exploration sequence valid
82- Phase 1 - Bootstrap: C(t)=X.XXX
83- Phase 2 - Dissonance: |ΔNFR| increased, C(t) may decrease
84- Phase 3 - Re-stabilize: C(t) recovered, |ΔNFR| reduced
85- Final coherence: C(t)=X.XXX (maintained)
197+ python docs/grammar/examples/02-intermediate-exploration.py
86198```
87199
88200---
89201
90- ### 03-advanced-bifurcation.py
202+ #### 03-advanced-bifurcation.py
91203
92204** Level:** Advanced
93205** Pattern:** Complete transformation
@@ -97,28 +209,10 @@ Final coherence: C(t)=X.XXX (maintained)
97209- U4b: Mutation with proper context (prior IL, recent destabilizer)
98210- U4a: Multiple handlers (SelfOrganization, Coherence)
99211- Phase transformation
100- - Multi-scale organization
101-
102- ** Concepts covered:**
103- - Bifurcation handling
104- - Phase transitions (θ changes)
105- - Hierarchical structure creation
106- - Complete transformation lifecycle
107212
108213** Run:**
109214``` bash
110- python examples/03-advanced-bifurcation.py
111- ```
112-
113- ** Expected output:**
114- ```
115- ✓ Bifurcation sequence valid
116- Phase 1 - Stable base: θ=X.XXX
117- Phase 2 - Destabilize: |ΔNFR| elevated
118- Phase 3 - Mutate: θ→θ' (phase changed)
119- Phase 4 - Self-organize: Hierarchical structure created
120- Phase 5 - Stabilize: C(t) recovered
121- Phase transformation complete: θ_initial → θ_final
215+ python docs/grammar/examples/03-advanced-bifurcation.py
122216```
123217
124218---
@@ -127,41 +221,44 @@ Phase transformation complete: θ_initial → θ_final
127221
128222### By Constraint
129223
130- ** U1a - Initiation:**
224+ ** U1 - Initiation & Closure:**
225+ - ` u1-initiation-closure-examples.py ` - Comprehensive U1 coverage
131226- ` 01-basic-bootstrap.py ` - Emission as generator
132227- All examples (always start with generator when EPI=0)
133228
134- ** U1b - Closure:**
135- - ` 01-basic-bootstrap.py ` - Silence as closure
136- - All examples (always end with closure)
137-
138- ** U2 - Convergence:**
229+ ** U2 - Convergence & Boundedness:**
230+ - ` u2-convergence-examples.py ` - Comprehensive U2 coverage
139231- ` 02-intermediate-exploration.py ` - Dissonance + Coherence
140232- ` 03-advanced-bifurcation.py ` - Multiple destabilizers balanced
141233
142- ** U3 - Coupling:**
234+ ** U3 - Resonant Coupling:**
235+ - ` u3-resonant-coupling-examples.py ` - Comprehensive U3 coverage
143236- (Planned: 04-network-propagation.py)
144237
145- ** U4a - Bifurcation Triggers:**
238+ ** U4 - Bifurcation Dynamics:**
239+ - ` u4-bifurcation-examples.py ` - Comprehensive U4a/U4b coverage
146240- ` 02-intermediate-exploration.py ` - Dissonance with handler
147241- ` 03-advanced-bifurcation.py ` - Mutation with handlers
148242
149- ** U4b - Transformer Context:**
150- - ` 03-advanced-bifurcation.py ` - Mutation with proper context
151-
152243### By Pattern
153244
154245** Bootstrap:**
155246- ` 01-basic-bootstrap.py `
247+ - ` u1-initiation-closure-examples.py ` (simple sequences)
156248
157249** Exploration:**
158250- ` 02-intermediate-exploration.py `
251+ - ` u2-convergence-examples.py ` (balanced sequences)
159252
160253** Transformation:**
161254- ` 03-advanced-bifurcation.py `
255+ - ` u4-bifurcation-examples.py ` (transformer sequences)
162256
163- ** Propagation:**
164- - (Planned: 04-network-propagation.py)
257+ ** Anti-Patterns:**
258+ - ` u1-initiation-closure-examples.py ` - U1 anti-patterns
259+ - ` u2-convergence-examples.py ` - U2 anti-patterns
260+ - ` u3-resonant-coupling-examples.py ` - U3 anti-patterns
261+ - ` u4-bifurcation-examples.py ` - U4 anti-patterns
165262
166263---
167264
@@ -171,25 +268,42 @@ Phase transformation complete: θ_initial → θ_final
171268
172269``` bash
173270# Run specific example
174- python docs/grammar/examples/01-basic-bootstrap .py
271+ python docs/grammar/examples/u1-initiation-closure-examples .py
175272```
176273
177- ### All Examples
274+ ### All Constraint Examples
178275
179276``` bash
180- # Run all examples
277+ # Run all U1-U4 examples
278+ for constraint in u1 u2 u3 u4; do
279+ echo " Running ${constraint} examples..."
280+ python docs/grammar/examples/${constraint} -* -examples.py
281+ echo " ---"
282+ done
283+ ```
284+
285+ ### All Pattern Examples
286+
287+ ``` bash
288+ # Run all pattern examples
181289for f in docs/grammar/examples/0* .py; do
182290 echo " Running $f ..."
183291 python " $f "
184292 echo " ---"
185293done
186294```
187295
188- ### With pytest
296+ ### All Examples
189297
190298``` bash
191- # If examples have test functions
192- pytest docs/grammar/examples/
299+ # Run everything
300+ python docs/grammar/examples/u1-initiation-closure-examples.py
301+ python docs/grammar/examples/u2-convergence-examples.py
302+ python docs/grammar/examples/u3-resonant-coupling-examples.py
303+ python docs/grammar/examples/u4-bifurcation-examples.py
304+ python docs/grammar/examples/01-basic-bootstrap.py
305+ python docs/grammar/examples/02-intermediate-exploration.py
306+ python docs/grammar/examples/03-advanced-bifurcation.py
193307```
194308
195309---
0 commit comments