Skip to content

Commit 2c747ba

Browse files
authored
Merge pull request #2811 from fermga/copilot/fix-frequency-classification-issue
Fix RECEPTION dual-role: distinguish base frequency from destabilization capacity
2 parents ea989bf + 4581908 commit 2c747ba

File tree

4 files changed

+652
-6
lines changed

4 files changed

+652
-6
lines changed

docs/RECEPTION_DUAL_ROLE.md

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
# RECEPTION Dual-Role Frequency Classification
2+
3+
## Issue Resolution
4+
5+
**Issue**: [GRAMÁTICA CANÓNICA] Inconsistencia entre clasificación de frecuencias y reglas de bifurcación (P1)
6+
7+
**Problem**: Structural inconsistency between RECEPTION operator frequency classification and its role in graduated bifurcation rules (R4).
8+
9+
- RECEPTION classified as **medium** frequency in `STRUCTURAL_FREQUENCIES`
10+
- RECEPTION acts as **weak destabilizer** in graduated bifurcation windows
11+
- **Contradiction**: Medium νf cannot generate sufficient ΔNFR for ZHIR alone
12+
13+
## Theoretical Foundation
14+
15+
### Nodal Equation
16+
```
17+
∂EPI/∂t = νf · ΔNFR
18+
```
19+
20+
Where:
21+
- **νf**: Structural frequency (reorganization rate)
22+
- **ΔNFR**: Internal reorganization gradient (structural pressure)
23+
24+
### RECEPTION Dual Role
25+
26+
**Base Frequency (νf)**:
27+
- Classification: `medium`
28+
- Represents: Structural capture rate
29+
- Effect: Moderate reorganization capacity
30+
31+
**Destabilization Capacity (ΔNFR Generation)**:
32+
- Classification: `weak`
33+
- Condition: Requires prior coherent base
34+
- Effect: Can generate reorganization pressure when capturing external coherence into prepared node
35+
36+
## Solution: Hybrid Category (Option C)
37+
38+
### DUAL_FREQUENCY_OPERATORS Configuration
39+
40+
```python
41+
DUAL_FREQUENCY_OPERATORS: dict[str, dict[str, str]] = {
42+
RECEPTION: {
43+
"base_freq": "medium",
44+
"destabilization_capacity": "weak",
45+
"conditions": "requires_prior_coherence",
46+
"rationale": (
47+
"Captures external coherence which can generate ΔNFR when "
48+
"integrated into structurally prepared node"
49+
),
50+
}
51+
}
52+
```
53+
54+
### Context Validation
55+
56+
RECEPTION as weak destabilizer requires:
57+
58+
1. **Prior Stabilizer**: IL or THOL within 3 operators before EN
59+
2. **No Interruption**: No SILENCE between stabilizer and EN (would remove base)
60+
3. **Structural Preparation**: Node must have coherent base for EN to generate ΔNFR
61+
62+
### Valid Patterns
63+
64+
**AL → EN → IL → EN → ZHIR**
65+
- First EN captures
66+
- IL stabilizes (creates coherent base)
67+
- Second EN destabilizes with context
68+
- ZHIR enabled by EN-generated ΔNFR
69+
70+
**EN → IL → EN → ZHIR**
71+
- First EN captures
72+
- IL stabilizes
73+
- Second EN has context
74+
- ZHIR enabled
75+
76+
**OZ → IL → EN → ZHIR**
77+
- OZ provides strong destabilization
78+
- IL resolves
79+
- EN has context from resolution
80+
- ZHIR enabled by OZ (EN's context not needed when stronger destabilizer present)
81+
82+
### Invalid Patterns
83+
84+
**EN → ZHIR** (without context)
85+
- EN has no prior stabilizer
86+
- Medium νf alone insufficient for ZHIR
87+
- Violates structural coherence
88+
89+
**AL → EN → ZHIR** (no stabilization)
90+
- EN not stabilized by IL/THOL
91+
- No coherent base for destabilization
92+
- Cannot generate required ΔNFR
93+
94+
**AL → EN → IL → SHA → EN → ZHIR** (SILENCE interruption)
95+
- IL provides base
96+
- SHA removes base (νf → 0)
97+
- Second EN has no context
98+
- Cannot destabilize
99+
100+
## Implementation
101+
102+
### Files Modified
103+
104+
1. **src/tnfr/operators/grammar.py**
105+
- Added `DUAL_FREQUENCY_OPERATORS` constant
106+
- Implemented `_validate_reception_context()` method
107+
- Enhanced `_has_graduated_destabilizer()` with context validation
108+
- Added extensive documentation
109+
110+
2. **tests/unit/operators/test_reception_dual_role.py** (NEW)
111+
- 21 comprehensive tests
112+
- Coverage: valid contexts, invalid contexts, distance limits, SILENCE interruption
113+
- Backward compatibility validation
114+
115+
3. **tests/unit/operators/test_graduated_destabilizer_windows.py**
116+
- Updated 1 test for more precise error reporting
117+
118+
### Test Results
119+
120+
- ✅ 21/21 dual-role tests passing
121+
- ✅ 26/26 graduated destabilizer tests passing
122+
- ✅ 27/27 grammar module tests passing
123+
- ✅ 17/17 bifurcation tests passing
124+
-**Total: 91/91 related tests passing**
125+
126+
## Theoretical Implications
127+
128+
### Why Context Matters
129+
130+
From ∂EPI/∂t = νf · ΔNFR:
131+
132+
1. **Base Operation**: EN with medium νf provides moderate reorganization rate
133+
2. **Context Multiplication**: When EN captures external coherence into prepared node:
134+
- Integration creates structural tension
135+
- Tension manifests as ΔNFR
136+
- Product νf · ΔNFR sufficient for structural transformation
137+
3. **Without Context**: EN alone has medium νf but generates minimal ΔNFR
138+
- Insufficient product for ZHIR (requires high transformation energy)
139+
- Violates structural coherence principles
140+
141+
### Frequency vs. Destabilization
142+
143+
**Key Distinction**:
144+
- **Frequency (νf)**: Intrinsic reorganization capacity
145+
- **Destabilization (ΔNFR)**: Context-dependent gradient generation
146+
147+
**RECEPTION uniqueness**:
148+
- Medium base frequency (inherent property)
149+
- Weak destabilization capacity (contextual property)
150+
- First operator with explicit dual classification
151+
152+
## Future Considerations
153+
154+
### Potential Dual-Role Operators
155+
156+
Consider evaluating:
157+
- **COUPLING (UM)**: Medium frequency, could generate ΔNFR through synchronization
158+
- **TRANSITION (NAV)**: Medium frequency, already moderate destabilizer, possible context-dependent intensification
159+
- **RESONANCE (RA)**: High frequency, could have context-dependent amplification
160+
161+
### Telemetry Enhancement
162+
163+
Add tracking for:
164+
- Context validation decisions
165+
- RECEPTION destabilization success/failure rates
166+
- Distance between stabilizer and EN
167+
- SILENCE interruption frequency
168+
169+
### Documentation Updates
170+
171+
- [ ] Add to Mathematical Foundations document
172+
- [ ] Update operator reference with dual-role concept
173+
- [ ] Create visual diagrams for EN context patterns
174+
- [ ] Add examples to tutorials
175+
176+
## References
177+
178+
- **Issue**: GitHub Issue #[number]
179+
- **TNFR.pdf**: Section 2.1 - Ecuación Nodal
180+
- **Code**: `src/tnfr/operators/grammar.py:DUAL_FREQUENCY_OPERATORS`
181+
- **Tests**: `tests/unit/operators/test_reception_dual_role.py`
182+
- **Theory**: Resonant Fractal Nature Theory - Bifurcation and Emergence
183+
184+
---
185+
186+
**Implementation Date**: 2025-11-08
187+
**Status**: ✅ Complete and Tested
188+
**Backward Compatibility**: ✅ Preserved

src/tnfr/operators/grammar.py

Lines changed: 101 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
"FUNCTION_TO_GLYPH",
8888
"GLYPH_TO_FUNCTION",
8989
"STRUCTURAL_FREQUENCIES",
90+
"DUAL_FREQUENCY_OPERATORS",
9091
"FREQUENCY_TRANSITIONS",
9192
"glyph_function_name",
9293
"function_name_to_glyph",
@@ -661,6 +662,62 @@ def _has_recent_destabilizer(self, current_index: int) -> bool:
661662
for _, dest_index in self._bifurcation_context
662663
)
663664

665+
def _validate_reception_context(self, reception_index: int) -> bool:
666+
"""Validate that RECEPTION has sufficient prior coherence for destabilization.
667+
668+
RECEPTION (EN) as a weak destabilizer requires context: it must operate on
669+
a node with existing structural base to generate sufficient ΔNFR for transformers.
670+
671+
Parameters
672+
----------
673+
reception_index : int
674+
Index of the RECEPTION operator in the sequence
675+
676+
Returns
677+
-------
678+
bool
679+
True if RECEPTION has adequate prior structural coherence
680+
681+
Notes
682+
-----
683+
Valid patterns include:
684+
- AL → EN → IL → EN (emission provides base, first EN consolidated, second can destabilize)
685+
- EN → IL → EN (first EN consolidated, second can destabilize)
686+
- OZ → IL → EN (dissonance resolved provides base)
687+
688+
Invalid patterns include:
689+
- EN as first operator (no prior base)
690+
- EN immediately after SHA (silence removes base)
691+
692+
Theoretical justification:
693+
From nodal equation ∂EPI/∂t = νf · ΔNFR, RECEPTION has medium νf.
694+
For EN → ZHIR to be valid, EN must generate high ΔNFR. This is only possible
695+
when EN captures external coherence into a structurally prepared node,
696+
creating reorganization pressure from the integration.
697+
"""
698+
# RECEPTION at position 0 cannot have prior coherence
699+
if reception_index == 0:
700+
return False
701+
702+
# Look for stabilizer (IL or THOL) before RECEPTION
703+
# This indicates the node has structural base for destabilization
704+
for i in range(reception_index):
705+
op = self._canonical[i]
706+
if op in {COHERENCE, SELF_ORGANIZATION}:
707+
# Found stabilizer - check it's not too far back
708+
# For context, we require stabilizer within 3 operators before EN
709+
if reception_index - i <= 3:
710+
# Additionally, ensure no SILENCE between stabilizer and EN
711+
# (SILENCE would remove the coherent base)
712+
has_silence = any(
713+
self._canonical[j] == SILENCE
714+
for j in range(i + 1, reception_index)
715+
)
716+
if not has_silence:
717+
return True
718+
719+
return False
720+
664721
def _has_graduated_destabilizer(self, current_index: int) -> bool:
665722
"""Check if any level of destabilizer satisfies its window requirement.
666723
@@ -680,9 +737,16 @@ def _has_graduated_destabilizer(self, current_index: int) -> bool:
680737
- Strong destabilizers (OZ): window of 4 operators
681738
- Moderate destabilizers (NAV, VAL): window of 2 operators
682739
- Weak destabilizers (EN): must be immediate predecessor (window of 1)
740+
AND have sufficient prior coherence context
683741
684742
The method checks each level in order of window size (largest first)
685743
to provide the most permissive validation.
744+
745+
RECEPTION (EN) Context Validation:
746+
EN as weak destabilizer requires validation of structural context.
747+
According to DUAL_FREQUENCY_OPERATORS, EN has medium base frequency
748+
but can generate ΔNFR when capturing external coherence into a prepared
749+
node. This validation ensures EN → ZHIR transitions are structurally sound.
686750
"""
687751
# Check strong destabilizers (longest window = 4)
688752
if self._destabilizer_context["strong"]:
@@ -697,10 +761,14 @@ def _has_graduated_destabilizer(self, current_index: int) -> bool:
697761
return True
698762

699763
# Check weak destabilizers (window = 1, must be immediate)
764+
# RECEPTION requires additional context validation for dual-role coherence
700765
if self._destabilizer_context["weak"]:
701766
last_weak = self._destabilizer_context["weak"][-1]
702767
if current_index - last_weak == 1:
703-
return True
768+
# Validate that RECEPTION has sufficient context for destabilization
769+
# This implements the "requires_prior_coherence" condition from
770+
# DUAL_FREQUENCY_OPERATORS
771+
return self._validate_reception_context(last_weak)
704772

705773
return False
706774

@@ -983,7 +1051,7 @@ class StructuralPattern(Enum):
9831051
# - zero: Operators that suspend reorganization while preserving form
9841052
STRUCTURAL_FREQUENCIES: dict[str, str] = {
9851053
EMISSION: "high", # AL: initiation/reorganization
986-
RECEPTION: "medium", # EN: structural capture
1054+
RECEPTION: "medium", # EN: structural capture (base frequency)
9871055
COHERENCE: "medium", # IL: stabilization
9881056
DISSONANCE: "high", # OZ: tension
9891057
COUPLING: "medium", # UM: coupling
@@ -997,6 +1065,37 @@ class StructuralPattern(Enum):
9971065
RECURSIVITY: "medium", # REMESH: fractal echo
9981066
}
9991067

1068+
# Dual-role operators: operators with context-dependent destabilization capacity
1069+
# Resolves the structural inconsistency between base frequency (νf) and ΔNFR generation.
1070+
#
1071+
# RECEPTION (EN) is the canonical dual-role operator:
1072+
# - Base frequency: "medium" (νf for structural capture)
1073+
# - Destabilization capacity: "weak" (can generate ΔNFR when integrating external coherence)
1074+
# - Condition: Requires prior coherence base for effective destabilization
1075+
#
1076+
# Theoretical foundation (nodal equation):
1077+
# ∂EPI/∂t = νf · ΔNFR
1078+
#
1079+
# RECEPTION has medium νf (moderate reorganization rate) but can act as weak
1080+
# destabilizer in graduated bifurcation (R4) when capturing external coherence
1081+
# into a node with existing structural base. The external input can generate
1082+
# sufficient ΔNFR to enable transformers (ZHIR/THOL) despite medium base frequency.
1083+
#
1084+
# Context requirement: EN → ZHIR valid only when EN operates on coherent base
1085+
# (e.g., AL → EN → IL → EN → ZHIR). Direct EN → ZHIR without context violates
1086+
# structural coherence as medium νf alone cannot sustain high ΔNFR for mutation.
1087+
DUAL_FREQUENCY_OPERATORS: dict[str, dict[str, str]] = {
1088+
RECEPTION: {
1089+
"base_freq": "medium",
1090+
"destabilization_capacity": "weak",
1091+
"conditions": "requires_prior_coherence",
1092+
"rationale": (
1093+
"Captures external coherence which can generate ΔNFR when "
1094+
"integrated into structurally prepared node"
1095+
),
1096+
}
1097+
}
1098+
10001099
# Frequency compatibility: operators with harmonic frequencies can transition
10011100
# Valid transitions preserve structural coherence:
10021101
# - high ↔ medium: High energy can stabilize or stabilized can amplify

tests/unit/operators/test_graduated_destabilizer_windows.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,16 +166,26 @@ def test_en_with_stronger_destabilizer(self):
166166
assert result.passed
167167

168168
def test_en_immediate_thol_also_requires_coherence(self):
169-
"""EN → THOL also needs EN → IL → THOL per R2."""
170-
# R2 requires RECEPTION → COHERENCE segment
169+
"""EN → THOL fails because EN lacks coherent context for destabilization.
170+
171+
Updated with dual-role context validation: EN as weak destabilizer now
172+
requires prior coherence base. AL → EN → THOL fails because EN at position 1
173+
has no prior stabilizer (IL or THOL) to provide context for destabilization.
174+
175+
This is more precise than the generic "missing reception→coherence segment"
176+
error, as it specifically identifies that EN cannot destabilize THOL without
177+
structural preparation.
178+
"""
171179
with pytest.raises(SequenceSyntaxError) as excinfo:
172180
parse_sequence(
173181
[EMISSION, RECEPTION, SELF_ORGANIZATION, SILENCE]
174182
)
175183

176184
error = excinfo.value
177-
# Should fail on missing coherence segment, not destabilizer
178-
assert "reception" in error.message.lower() and "coherence" in error.message.lower()
185+
# With dual-role validation, fails on destabilizer requirement
186+
# (more specific than generic EN→IL segment requirement)
187+
assert "self_organization" in error.message.lower()
188+
assert "destabilizer" in error.message.lower()
179189

180190
def test_en_with_intermediate_thol_fails(self):
181191
"""EN → IL → THOL (fails - EN requires immediate)."""

0 commit comments

Comments
 (0)