Skip to content

Commit 7b38b60

Browse files
authored
Merge pull request #2900 from fermga/copilot/implement-remesh-canonical-operator
Implement canonical REMESH operator: Structural memory, coherence preservation, physical dynamics documentation, and grammar limitations
2 parents af460b0 + 2d37ed9 commit 7b38b60

File tree

4 files changed

+1923
-2
lines changed

4 files changed

+1923
-2
lines changed

src/tnfr/operators/grammar.py

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,96 @@ def validate_transformer_context(sequence: List[Operator]) -> tuple[bool, str]:
804804

805805
return (True, f"U4b satisfied: transformers have proper context")
806806

807+
@staticmethod
808+
def validate_remesh_amplification(sequence: List[Operator]) -> tuple[bool, str]:
809+
"""Validate U2-REMESH: Recursive amplification control.
810+
811+
Physical basis: REMESH implements temporal coupling EPI(t) ↔ EPI(t-τ)
812+
which creates feedback that amplifies structural changes. When combined
813+
with destabilizers, this can cause unbounded growth.
814+
815+
From integrated nodal equation:
816+
EPI(t_f) = EPI(t_0) + ∫_{t_0}^{t_f} νf·ΔNFR dτ
817+
818+
REMESH temporal mixing:
819+
EPI_mixed = (1-α)·EPI_now + α·EPI_past
820+
821+
Without stabilizers:
822+
REMESH + destabilizers → recursive amplification
823+
→ ∫ νf·ΔNFR dt → ∞ (feedback loop)
824+
→ System fragments
825+
826+
With stabilizers:
827+
IL or THOL provides negative feedback
828+
→ Bounded recursive evolution
829+
→ ∫ νf·ΔNFR dt < ∞
830+
831+
Specific combinations requiring stabilizers:
832+
- REMESH + VAL: Recursive expansion needs coherence stabilization
833+
- REMESH + OZ: Recursive bifurcation needs self-organization handlers
834+
- REMESH + ZHIR: Replicative mutation needs coherence consolidation
835+
836+
Parameters
837+
----------
838+
sequence : List[Operator]
839+
Sequence of operators to validate
840+
841+
Returns
842+
-------
843+
tuple[bool, str]
844+
(is_valid, message)
845+
846+
Notes
847+
-----
848+
This rule is DISTINCT from general U2 (convergence). While U2 checks
849+
for destabilizers needing stabilizers, U2-REMESH specifically addresses
850+
REMESH's amplification property: it multiplies the effect of destabilizers
851+
through recursive feedback across temporal/spatial scales.
852+
853+
Physical derivation: See src/tnfr/operators/remesh.py module docstring,
854+
section "Grammar Implications from Physical Analysis" → U2: CONVERGENCE.
855+
"""
856+
# Check if sequence contains REMESH
857+
has_remesh = any(
858+
getattr(op, "canonical_name", op.name.lower()) == "recursivity"
859+
for op in sequence
860+
)
861+
862+
if not has_remesh:
863+
return True, "U2-REMESH: not applicable (no recursivity present)"
864+
865+
# Check for destabilizers
866+
destabilizers_present = [
867+
getattr(op, "canonical_name", op.name.lower())
868+
for op in sequence
869+
if getattr(op, "canonical_name", op.name.lower()) in DESTABILIZERS
870+
]
871+
872+
if not destabilizers_present:
873+
return True, "U2-REMESH: satisfied (no destabilizers to amplify)"
874+
875+
# Check for stabilizers
876+
stabilizers_present = [
877+
getattr(op, "canonical_name", op.name.lower())
878+
for op in sequence
879+
if getattr(op, "canonical_name", op.name.lower()) in STABILIZERS
880+
]
881+
882+
if not stabilizers_present:
883+
return (
884+
False,
885+
f"U2-REMESH violated: recursivity amplifies destabilizers "
886+
f"{destabilizers_present} via recursive feedback. "
887+
f"Integral ∫νf·ΔNFR dt may diverge (unbounded growth). "
888+
f"Required: {sorted(STABILIZERS)} to bound recursive amplification",
889+
)
890+
891+
return (
892+
True,
893+
f"U2-REMESH satisfied: stabilizers {stabilizers_present} "
894+
f"bound recursive amplification of {destabilizers_present}",
895+
)
896+
807897
@classmethod
808898
def validate(
809899
cls,
@@ -865,6 +955,11 @@ def validate(
865955
messages.append(f"U4b: {msg_context}")
866956
all_valid = all_valid and valid_context
867957

958+
# U2-REMESH: Recursive amplification control
959+
valid_remesh, msg_remesh = cls.validate_remesh_amplification(sequence)
960+
messages.append(f"U2-REMESH: {msg_remesh}")
961+
all_valid = all_valid and valid_remesh
962+
868963
return all_valid, messages
869964

870965

0 commit comments

Comments
 (0)