@aleph-ai/tinyaleph 1.2.1 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +609 -13
  2. package/backends/bioinformatics/binding.js +503 -0
  3. package/backends/bioinformatics/dna-computing.js +664 -0
  4. package/backends/bioinformatics/encoding.js +339 -0
  5. package/backends/bioinformatics/folding.js +454 -0
  6. package/backends/bioinformatics/genetic-code.js +269 -0
  7. package/backends/bioinformatics/index.js +522 -0
  8. package/backends/bioinformatics/transcription.js +221 -0
  9. package/backends/bioinformatics/translation.js +264 -0
  10. package/backends/cryptographic/index.js +455 -2
  11. package/backends/index.js +25 -1
  12. package/core/beacon.js +735 -0
  13. package/core/compound.js +532 -0
  14. package/core/crt-homology.js +1004 -0
  15. package/core/enochian-vocabulary.js +910 -0
  16. package/core/enochian.js +744 -0
  17. package/core/errors.js +587 -0
  18. package/core/hilbert.js +1105 -2
  19. package/core/index.js +192 -13
  20. package/core/inference.js +605 -0
  21. package/core/lambda.js +284 -33
  22. package/core/logger.js +350 -0
  23. package/core/prime.js +136 -1
  24. package/core/quaternion-semantics.js +623 -0
  25. package/core/reduction.js +391 -1
  26. package/core/resonance.js +245 -616
  27. package/core/rformer-crt.js +892 -0
  28. package/core/symbols/archetypes.js +478 -0
  29. package/core/symbols/base.js +302 -0
  30. package/core/symbols/elements.js +487 -0
  31. package/core/symbols/hieroglyphs.js +303 -0
  32. package/core/symbols/iching.js +471 -0
  33. package/core/symbols/index.js +77 -0
  34. package/core/symbols/tarot.js +211 -0
  35. package/core/symbols.js +22 -0
  36. package/core/topology.js +655 -0
  37. package/docs/README.md +54 -0
  38. package/docs/design/BIOINFORMATICS_BACKEND_DESIGN.md +493 -0
  39. package/docs/guide/06-symbolic-ai.md +370 -0
  40. package/docs/guide/README.md +2 -1
  41. package/docs/reference/05-symbolic-ai.md +570 -0
  42. package/docs/reference/06-bioinformatics.md +546 -0
  43. package/docs/reference/07-topology.md +257 -0
  44. package/docs/reference/08-observer.md +421 -0
  45. package/docs/reference/09-crt-homology.md +369 -0
  46. package/docs/reference/README.md +32 -2
  47. package/docs/theory/11-prgraph-memory.md +559 -0
  48. package/docs/theory/12-resonant-attention.md +661 -0
  49. package/modular.js +264 -4
  50. package/package.json +1 -1
package/README.md CHANGED
@@ -16,13 +16,24 @@ A novel computational paradigm that encodes meaning as prime number signatures,
16
16
  - **Prime Entanglement**: Graph-based tracking of prime relationships and co-occurrences
17
17
  - **Event Streaming**: Real-time monitoring with EventEmitter pattern and async iteration
18
18
  - **Entropy Minimization**: Reasoning as reduction of semantic uncertainty
19
- - **Multiple Backends**: Semantic (NLP), Cryptographic (hashing), Scientific (quantum-inspired)
19
+ - **Multiple Backends**: Semantic (NLP), Cryptographic (hashing), Scientific (quantum-inspired), Bioinformatics (DNA/protein)
20
20
  - **Formal Type System**: Typed term calculus with N(p)/A(p)/S types and ordering constraints
21
21
  - **Reduction Semantics**: Strong normalization with prime-preserving operators
22
22
  - **Lambda Translation**: Model-theoretic semantics via λ-calculus embedding
23
23
  - **Enochian Vocabulary**: 21-letter angelic alphabet with prime basis and sedenion operations
24
24
  - **ResoFormer Architecture**: Complete prime-indexed transformer with multi-head attention
25
25
  - **Multi-Z Memory**: Hierarchical memory with fast/slow/permanent channels
26
+ - **Symbolic AI**: 184+ emoji symbols with cultural tags, resonance-enhanced inference
27
+ - **Golden Ratio Resonance**: Harmony measurement using φ ≈ 1.618 ratio detection
28
+ - **Topological Invariants**: 108 invariant (2²×3³), Trefoil complexity, physical constant derivation
29
+ - **Gauge Symmetry**: Standard Model SU(3)×SU(2)×U(1) from 108 factorization
30
+ - **Observer Hierarchy**: Multi-scale observers from quantum to cosmic
31
+ - **Free Energy Dynamics**: Cubic FEP model for consciousness and curiosity
32
+ - **Discrete Dynamics**: Integer sine tables, histogram coherence, tick-based gating
33
+ - **Codebook Tunneling**: 64-attractor SMF codebook for controlled state transitions
34
+ - **Canonical Fusion**: Deterministic FUSE(p,q,r) triad selection
35
+ - **CRT-Homology**: Chinese Remainder Theorem for semantic reconstruction with homology-based consistency detection
36
+ - **Birkhoff Attention**: Doubly-stochastic attention via Sinkhorn-Knopp projection
26
37
 
27
38
  ## Installation
28
39
 
@@ -156,6 +167,69 @@ const superposition = backend.superpose(state, 0.5, basis, 0.5);
156
167
  const result = backend.measure(superposition, [basis]);
157
168
  ```
158
169
 
170
+ ### Bioinformatics Backend
171
+
172
+ DNA computing, protein folding, and molecular biology:
173
+
174
+ ```javascript
175
+ const { BioinformaticsBackend, DNACircuit, ANDGate, ORGate } = require('@aleph-ai/tinyaleph');
176
+
177
+ const backend = new BioinformaticsBackend();
178
+
179
+ // Encode DNA sequence
180
+ const dnaPrimes = backend.encode('ATGCGATCG');
181
+
182
+ // Transcribe DNA to RNA
183
+ const transcribed = backend.transcribe(dnaPrimes, { force: true });
184
+ console.log('mRNA primes:', transcribed.rna);
185
+
186
+ // Translate RNA to Protein
187
+ const translated = backend.translate(transcribed.rna);
188
+ console.log('Protein:', backend.decode(translated.protein));
189
+
190
+ // Full gene expression (DNA → RNA → Protein)
191
+ const expressed = backend.express(dnaPrimes);
192
+ console.log('Protein sequence:', expressed.sequence);
193
+
194
+ // Protein folding via Kuramoto oscillators
195
+ const proteinPrimes = backend.encode('MWLKFVIER');
196
+ const foldResult = backend.foldProtein(proteinPrimes);
197
+ console.log('Folding order parameter:', foldResult.orderParameter);
198
+
199
+ // Molecular binding affinity
200
+ const affinity = backend.bindingAffinity(dnaPrimes, proteinPrimes);
201
+ console.log('Binding affinity:', affinity.affinity);
202
+ ```
203
+
204
+ ### DNA Computing
205
+
206
+ Build logic gates and circuits using DNA strands:
207
+
208
+ ```javascript
209
+ const { DNACircuit, ANDGate, ORGate, NOTGate } = require('@aleph-ai/tinyaleph');
210
+
211
+ // Create logic gates
212
+ const andGate = new ANDGate({ name: 'and1' });
213
+ const orGate = new ORGate({ name: 'or1' });
214
+ const notGate = new NOTGate({ name: 'not1' });
215
+
216
+ // Evaluate gates (concentration-based)
217
+ console.log(andGate.evaluate(1, 1)); // { output: true, ... }
218
+ console.log(orGate.evaluate(0, 1)); // { output: true, ... }
219
+ console.log(notGate.evaluate(0)); // { output: true, ... }
220
+
221
+ // Build a circuit
222
+ const circuit = new DNACircuit('logic-circuit');
223
+ circuit.addGate('and1', new ANDGate({ name: 'and1' }));
224
+ circuit.addGate('not1', new NOTGate({ name: 'not1' }));
225
+ circuit.addGate('or1', new ORGate({ name: 'or1' }));
226
+ circuit.connect('and1', 'or1', 1);
227
+ circuit.connect('not1', 'or1', 2);
228
+
229
+ // Evaluate circuit
230
+ const result = circuit.evaluate();
231
+ ```
232
+
159
233
  ## Physics Engine
160
234
 
161
235
  ### Oscillators
@@ -375,6 +449,195 @@ const Jt = createAdiabaticSchedule(0.1, 0.5, 100, 'sinusoidal');
375
449
  const ladder2 = new PrimeonZLadderMulti({ N: 16, Jt });
376
450
  ```
377
451
 
452
+ ### Topological Physics
453
+
454
+ The 108 Invariant from 108bio.pdf provides deep connections between number theory and physics:
455
+
456
+ ```javascript
457
+ const {
458
+ TWIST_108,
459
+ Knot,
460
+ TREFOIL,
461
+ PhysicalConstants,
462
+ GaugeSymmetry,
463
+ FreeEnergyDynamics,
464
+ OBSERVER_HIERARCHY
465
+ } = require('@aleph-ai/tinyaleph/core/topology');
466
+
467
+ // 108 Invariant: 2² × 3³ = 108
468
+ console.log(TWIST_108.value); // 108
469
+ console.log(TWIST_108.factorization); // { twos: 2, threes: 3 }
470
+
471
+ // Twist angle κ(p) = 360°/p
472
+ const twistAngle = TWIST_108.twistAngle(7); // 51.43°
473
+
474
+ // Find minimum primes for closed twist (sum to 360°)
475
+ const closingPrimes = TWIST_108.findClosingPrimes(3);
476
+
477
+ // Trefoil Knot with complexity T = s·c - b + u = 17
478
+ console.log(TREFOIL.strands); // 1
479
+ console.log(TREFOIL.crossings); // 3
480
+ console.log(TREFOIL.bridges); // 2
481
+ console.log(TREFOIL.unknotting); // 1
482
+ console.log(TREFOIL.complexity); // 17
483
+
484
+ // Physical constants from 108 + Trefoil
485
+ console.log(PhysicalConstants.PROTON_ELECTRON_RATIO); // 1836 (17 × 108)
486
+ console.log(PhysicalConstants.FINE_STRUCTURE_INV); // 137 (108 + 29)
487
+ console.log(PhysicalConstants.ALPHA); // 1/137
488
+
489
+ // Gauge symmetry from 108 factorization
490
+ const gauge = new GaugeSymmetry();
491
+ console.log(gauge.generators); // { SU3: 8, SU2: 3, U1: 1 }
492
+ console.log(gauge.totalDimension); // 12
493
+ console.log(gauge.isStandardModel); // true
494
+
495
+ // Free Energy Dynamics (cubic FEP)
496
+ // dψ/dt = αψ + βψ² + γψ³
497
+ const fep = new FreeEnergyDynamics({ alpha: 0.1, beta: -0.3, gamma: 0.2 });
498
+ const energy = fep.freeEnergy(0.5); // F(ψ)
499
+ const gradient = fep.gradient(0.5); // dF/dψ
500
+ const minima = fep.findMinima(); // Stable states
501
+
502
+ // Observer Hierarchy (quantum to cosmic scales)
503
+ OBSERVER_HIERARCHY.forEach(level => {
504
+ console.log(`${level.name}: scale=${level.scale}, capacity=${level.capacity}`);
505
+ });
506
+ // cellular: scale=1e-6, capacity=1e6
507
+ // neural: scale=1e-3, capacity=1e9
508
+ // cognitive: scale=1, capacity=1e12
509
+ // collective: scale=1e6, capacity=1e15
510
+ // cosmic: scale=1e26, capacity=1e21
511
+ ```
512
+
513
+ ### Discrete Dynamics
514
+
515
+ Integer-domain computation from discrete.pdf:
516
+
517
+ ```javascript
518
+ const { INT_SINE_TABLE, computeHistogramCoherence } = require('@aleph-ai/tinyaleph/apps/sentient/lib/prsc');
519
+ const { SMF_CODEBOOK, nearestCodebookAttractor, codebookTunnel } = require('@aleph-ai/tinyaleph/apps/sentient/lib/smf');
520
+ const { canonicalTriad, canonicalFusion, verifyCanonical } = require('@aleph-ai/tinyaleph/apps/sentient/lib/prime-calculus');
521
+ const { TickGate } = require('@aleph-ai/tinyaleph/apps/sentient/lib/hqe');
522
+
523
+ // Integer Sine Table (M=256 discretization)
524
+ console.log(INT_SINE_TABLE.M); // 256
525
+ const sinValue = INT_SINE_TABLE.sin(64); // Integer sine at phase 64
526
+ const cosValue = INT_SINE_TABLE.cos(128); // Integer cosine at phase 128
527
+
528
+ // Histogram Coherence C_bin(t) = max_k(b_k(t))/|P|
529
+ const phases = [10, 12, 11, 50, 52, 51, 100, 102, 101];
530
+ const coherence = computeHistogramCoherence(phases, { numBins: 16 });
531
+ // coherence ≈ 0.33 (three clusters of 3 phases each)
532
+
533
+ // 64-Attractor SMF Codebook
534
+ console.log(SMF_CODEBOOK.length); // 64
535
+ console.log(SMF_CODEBOOK[0]); // { index: 0, phase: 0, label: '0x00' }
536
+
537
+ // Find nearest codebook attractor
538
+ const nearest = nearestCodebookAttractor(130); // phase 130
539
+ console.log(nearest.index); // Nearest codebook index
540
+ console.log(nearest.distance); // Distance to attractor
541
+
542
+ // Controlled tunneling to codebook attractor
543
+ const tunneled = codebookTunnel(130, { force: 0.5 });
544
+ console.log(tunneled.original); // 130
545
+ console.log(tunneled.target); // Nearest attractor phase
546
+ console.log(tunneled.result); // Tunneled phase (interpolated)
547
+
548
+ // Canonical Fusion FUSE(p,q,r) selection
549
+ const triad = canonicalTriad(19); // Find canonical triad for sum 19
550
+ console.log(triad); // [3, 5, 11] (lexicographically first)
551
+
552
+ // Verify canonical property
553
+ console.log(verifyCanonical(3, 5, 11, 19)); // true
554
+
555
+ // Fuse with automatic triad selection
556
+ const fused = canonicalFusion(19);
557
+ console.log(fused.triad); // [3, 5, 11]
558
+ console.log(fused.sum); // 19
559
+
560
+ // Tick-Only HQE Gate
561
+ const tickGate = new TickGate({ threshold: 0.7 });
562
+ const gateResult = tickGate.evaluate({ coherence: 0.8, tickValid: true });
563
+ console.log(gateResult.passed); // true (coherence > threshold && tick valid)
564
+ console.log(gateResult.reason); // 'TICK_VALID'
565
+ ```
566
+
567
+ ### Observer Capacity
568
+
569
+ Calculate observer capacity from 108bio.pdf's C_obs = α·N_osc·K̄·τ⁻¹:
570
+
571
+ ```javascript
572
+ const { SymbolicObserver } = require('@aleph-ai/tinyaleph/apps/sentient/lib/symbolic-observer');
573
+
574
+ const observer = new SymbolicObserver();
575
+
576
+ // Add oscillator bank for N_osc
577
+ observer.addOscillatorBank(bank);
578
+
579
+ // Calculate observer capacity
580
+ const capacity = observer.calculateObserverCapacity({
581
+ alpha: 1/137, // Fine structure constant
582
+ meanCoupling: 0.5, // K̄ average coupling
583
+ coherenceTime: 0.1 // τ coherence time
584
+ });
585
+
586
+ console.log(capacity.value); // Capacity in bits/second
587
+ console.log(capacity.numOscillators);
588
+ console.log(capacity.formula); // 'α × N_osc × K̄ × τ⁻¹'
589
+ ```
590
+
591
+ ### Free Energy Curiosity
592
+
593
+ Cubic FEP-based curiosity for learning systems:
594
+
595
+ ```javascript
596
+ const { FreeEnergyCuriosity } = require('@aleph-ai/tinyaleph/apps/sentient/lib/learning/curiosity');
597
+
598
+ const curiosity = new FreeEnergyCuriosity({
599
+ alpha: 0.1, // Linear coefficient
600
+ beta: -0.3, // Quadratic coefficient
601
+ gamma: 0.2 // Cubic coefficient
602
+ });
603
+
604
+ // Evaluate free energy at belief state ψ
605
+ const energy = curiosity.freeEnergy(0.5);
606
+
607
+ // Get gradient for belief update
608
+ const grad = curiosity.gradient(0.5);
609
+
610
+ // Find stable belief states (local minima)
611
+ const stableStates = curiosity.findMinima();
612
+
613
+ // Check if current state is at equilibrium
614
+ const isStable = curiosity.isStable(0.5, { tolerance: 0.01 });
615
+ ```
616
+
617
+ ### Observer Scale Management
618
+
619
+ Multi-scale observer hierarchy from 108bio.pdf:
620
+
621
+ ```javascript
622
+ const { ObserverScaleManager } = require('@aleph-ai/tinyaleph/apps/sentient/lib/collective');
623
+
624
+ const manager = new ObserverScaleManager();
625
+
626
+ // Assign node to appropriate hierarchy level based on capacity
627
+ const level = manager.assignNode(nodeId, observerCapacity);
628
+ console.log(level.name); // 'neural', 'cognitive', etc.
629
+ console.log(level.scale); // Physical scale
630
+ console.log(level.capacity); // Information capacity
631
+
632
+ // Get all nodes at a level
633
+ const cognitiveNodes = manager.getNodesAtLevel('cognitive');
634
+
635
+ // Get hierarchy statistics
636
+ const stats = manager.getHierarchyStats();
637
+ console.log(stats.totalNodes);
638
+ console.log(stats.levelDistribution);
639
+ ```
640
+
378
641
  ### ResoFormer Architecture
379
642
 
380
643
  Complete prime-indexed transformer:
@@ -410,6 +673,188 @@ const model = new ResoFormer({
410
673
  const outputs = model.forward([state1, state2]);
411
674
  ```
412
675
 
676
+ ### CRT-Enhanced ResoFormer
677
+
678
+ Integrates Chinese Remainder Theorem reconstruction with homology-based regularization:
679
+
680
+ ```javascript
681
+ const {
682
+ CRTResonantAttention,
683
+ HomologyRegularizedBlock,
684
+ CRTResoFormer,
685
+ createCRTResoFormer
686
+ } = require('@aleph-ai/tinyaleph');
687
+
688
+ // Create CRT-enhanced model
689
+ const model = createCRTResoFormer({
690
+ numLayers: 3,
691
+ numHeads: 4, // Maps to coprime moduli [2, 3, 5, 7]
692
+ homologyWeight: 0.1
693
+ });
694
+
695
+ // Process sequence with homology detection
696
+ const sequence = [
697
+ SparsePrimeState.fromHash('the'),
698
+ SparsePrimeState.fromHash('quick'),
699
+ SparsePrimeState.fromHash('fox')
700
+ ];
701
+
702
+ const result = model.forward(sequence);
703
+
704
+ console.log('Total homology loss:', result.totalLoss);
705
+ console.log('Holes detected:', result.homologyReport.hasHoles);
706
+ console.log('Betti numbers:', result.homologyReport.maxBettiNumber);
707
+ ```
708
+
709
+ ### CRT Residue Encoding
710
+
711
+ Encode semantic states as residue distributions over coprime moduli:
712
+
713
+ ```javascript
714
+ const {
715
+ ResidueEncoder,
716
+ CRTReconstructor,
717
+ BirkhoffProjector,
718
+ HomologyLoss,
719
+ DEFAULT_PRIMES_SMALL
720
+ } = require('@aleph-ai/tinyaleph');
721
+
722
+ // Use first 4 primes: [2, 3, 5, 7], P = 210
723
+ const primes = DEFAULT_PRIMES_SMALL;
724
+ const encoder = new ResidueEncoder(primes, 16);
725
+ const crt = new CRTReconstructor(primes);
726
+
727
+ // Encode hidden vector to residue distributions
728
+ const h = new Float64Array(16).fill(0.5);
729
+ const residues = encoder.encode(h);
730
+ const expectedResidues = encoder.expectedResidues(residues);
731
+
732
+ // CRT reconstruction
733
+ const L = crt.reconstruct(expectedResidues);
734
+ console.log('Reconstructed:', L);
735
+
736
+ // Detect kernel (consistency failures)
737
+ const inKernel = crt.detectKernel(expectedResidues, 0.1);
738
+ console.log('In kernel:', inKernel);
739
+
740
+ // Birkhoff attention (doubly-stochastic)
741
+ const birkhoff = new BirkhoffProjector(20);
742
+ const attentionMatrix = [[0.8, 0.2], [0.3, 0.7]];
743
+ const projected = birkhoff.project(attentionMatrix);
744
+ // Row sums ≈ 1, column sums ≈ 1
745
+ ```
746
+
747
+ ### Homology Loss
748
+
749
+ Detect semantic inconsistencies as topological holes:
750
+
751
+ ```javascript
752
+ const { HomologyLoss, CRTReconstructor } = require('@aleph-ai/tinyaleph');
753
+
754
+ const crt = new CRTReconstructor([2, 3, 5, 7]);
755
+ const homology = new HomologyLoss({ tau: 0.1 });
756
+
757
+ // Batch of residue tuples
758
+ const residueBatch = [
759
+ [0.5, 1.2, 2.8, 4.1],
760
+ [0.99, 0.01, 2.5, 3.99],
761
+ [0.1, 0.2, 0.3, 0.4]
762
+ ];
763
+
764
+ // Compute homology loss
765
+ const result = homology.compute(residueBatch, crt);
766
+ console.log('Homology loss:', result.loss);
767
+ console.log('Cycles detected:', result.cycles);
768
+
769
+ // Betti numbers (topological invariants)
770
+ const betti = homology.computeBettiNumbers(residueBatch, crt);
771
+ console.log('β₀ (components):', betti.beta0);
772
+ console.log('β₁ (holes):', betti.beta1);
773
+ ```
774
+
775
+ ## Symbolic AI
776
+
777
+ ### Symbol Database
778
+
779
+ 184+ emoji symbols with prime assignments and cultural tags:
780
+
781
+ ```javascript
782
+ const { getSymbol, symbolDatabase } = require('@aleph-ai/tinyaleph');
783
+
784
+ // Get a symbol
785
+ const hero = getSymbol('hero');
786
+ console.log(hero);
787
+ // { id: 'hero', unicode: '🦸', prime: 1013, meaning: 'Hero archetype', culturalTags: ['universal'] }
788
+
789
+ // Find Greek mythology symbols
790
+ const greekSymbols = symbolDatabase.getSymbolsByTag('greek');
791
+
792
+ // Encode/decode concepts to prime signatures
793
+ const signature = symbolDatabase.encode(['hero', 'journey', 'mountain']);
794
+ const symbols = symbolDatabase.decode(signature);
795
+ ```
796
+
797
+ ### Semantic Inference
798
+
799
+ Pattern matching with resonance-enhanced disambiguation:
800
+
801
+ ```javascript
802
+ const { inferSymbol, inferWithResonance, inferMostResonant } = require('@aleph-ai/tinyaleph');
803
+
804
+ // Basic inference
805
+ const result = inferSymbol('brave knight');
806
+ // { symbol: ⚔️, method: 'regex', confidence: 0.85 }
807
+
808
+ // Resonance-enhanced inference - symbols ranked by harmony
809
+ const symbols = inferWithResonance('The hero fought the shadow in the temple');
810
+ // Symbols sorted by attention weight based on resonance scores
811
+
812
+ // Context-aware selection
813
+ const context = [getSymbol('warrior'), getSymbol('temple')];
814
+ const best = inferMostResonant('weapon', context);
815
+ // → 🗡️ sword (high resonance with warrior/temple context)
816
+ ```
817
+
818
+ ### Compound Symbols
819
+
820
+ Build multi-symbol concepts through prime multiplication:
821
+
822
+ ```javascript
823
+ const { createCompound, getCompound, compoundBuilder } = require('@aleph-ai/tinyaleph');
824
+
825
+ // Pre-built compound
826
+ const greekWarrior = getCompound('greek_warrior');
827
+ // { unicode: '⚔️⛩️🦉', meaning: 'Greek Warrior: Temple guardian blessed by Athena' }
828
+
829
+ // Create custom compound
830
+ const fireMage = createCompound('fire_mage',
831
+ ['magician', 'fire', 'staff'],
832
+ 'Fire Mage - Wielder of flame magic'
833
+ );
834
+
835
+ // Calculate internal harmony
836
+ const harmony = compoundBuilder.calculateCompoundResonance(fireMage);
837
+ ```
838
+
839
+ ### Golden Ratio Resonance
840
+
841
+ Primes whose ratio approaches φ ≈ 1.618 have natural harmony:
842
+
843
+ ```javascript
844
+ const { calculateResonance, findGoldenPairs, resonanceSignature } = require('@aleph-ai/tinyaleph');
845
+
846
+ // Check resonance between primes
847
+ calculateResonance(3, 5); // 0.9 (Fibonacci pair!)
848
+ calculateResonance(7, 11); // 0.936 (close to φ)
849
+
850
+ // Find golden pairs
851
+ const pairs = findGoldenPairs([2, 3, 5, 7, 11, 13]);
852
+
853
+ // Get signature for symbol set
854
+ const sig = resonanceSignature([2, 3, 5, 7]);
855
+ console.log(`Mean resonance: ${sig.mean}, Golden pairs: ${sig.goldenCount}`);
856
+ ```
857
+
413
858
  ## Formal Semantics
414
859
 
415
860
  ### Typed Term Calculus
@@ -541,6 +986,9 @@ console.log(CORE_VOCABULARY['ZORGE']); // "be friendly unto"
541
986
  | `SemanticBackend` | Natural language processing |
542
987
  | `CryptographicBackend` | Hashing and key derivation |
543
988
  | `ScientificBackend` | Quantum-inspired computation |
989
+ | `BioinformaticsBackend` | DNA/RNA/Protein computation |
990
+ | `DNACircuit` | DNA logic circuit builder |
991
+ | `ANDGate` / `ORGate` / `NOTGate` | DNA logic gates |
544
992
  | `Hypercomplex` | Sedenion algebra with exp/log/slerp |
545
993
  | `Oscillator` / `OscillatorBank` | Phase-amplitude oscillators |
546
994
  | `KuramotoModel` | Coupled oscillator synchronization |
@@ -559,9 +1007,92 @@ console.log(CORE_VOCABULARY['ZORGE']); // "be friendly unto"
559
1007
  | `PrimeonZLadderMulti` | Multi-channel Z memory |
560
1008
  | `ResoFormer` | Prime-indexed transformer |
561
1009
  | `SparsePrimeState` | Sparse prime activations |
1010
+ | `getSymbol(id)` | Get symbol by ID |
1011
+ | `symbolDatabase` | Symbol database singleton |
1012
+ | `inferSymbol(text)` | Infer symbol from text |
1013
+ | `inferWithResonance(text)` | Resonance-ranked inference |
1014
+ | `inferMostResonant(text, ctx)` | Context-aware selection |
1015
+ | `createCompound(...)` | Build compound symbol |
1016
+ | `compoundBuilder` | Compound builder instance |
1017
+ | `calculateResonance(p1, p2)` | Prime pair resonance |
1018
+ | `findGoldenPairs(primes)` | Find φ-ratio pairs |
1019
+ | `resonanceSignature(primes)` | Resonance statistics |
562
1020
  | `hash(input)` | Quick semantic hash |
563
1021
  | `deriveKey(pass, salt)` | Quick key derivation |
564
1022
 
1023
+ ### Observer Exports
1024
+
1025
+ The observer module provides components for building sentient observer systems:
1026
+
1027
+ ```javascript
1028
+ const observer = require('@aleph-ai/tinyaleph/observer');
1029
+ // Or destructure specific exports:
1030
+ const {
1031
+ SedenionMemoryField,
1032
+ PRSCLayer,
1033
+ TemporalLayer,
1034
+ SymbolicSMF,
1035
+ SymbolicTemporalLayer,
1036
+ AssaySuite
1037
+ } = require('@aleph-ai/tinyaleph/observer');
1038
+ ```
1039
+
1040
+ | Export | Description |
1041
+ |--------|-------------|
1042
+ | `PrimeOscillator` | Single prime-indexed oscillator |
1043
+ | `PRSCLayer` | Prime Resonance Semantic Coherence oscillator bank |
1044
+ | `coherenceKernel` | Phase coherence calculation |
1045
+ | `TickGate` | Tick-based activation gating |
1046
+ | `HQE` | Holographic Quaternion Engine |
1047
+ | `SedenionMemoryField` | 16D semantic orientation field |
1048
+ | `SMF_AXES` | Named axes for 16D space |
1049
+ | `Moment` | Discrete temporal moment |
1050
+ | `TemporalLayer` | Moment classification and time tracking |
1051
+ | `AttentionFocus` | Attention target with decay |
1052
+ | `Goal` | Goal representation with progress |
1053
+ | `AgencyLayer` | Goals, attention, and intention management |
1054
+ | `BoundaryLayer` | Self-other differentiation |
1055
+ | `EntanglementLayer` | Semantic phrase coherence |
1056
+ | `SafetyMonitor` | Constraint monitoring |
1057
+ | `SymbolicSMF` | Symbol-grounded Sedenion field |
1058
+ | `SMFSymbolMapper` | Maps SMF axes to symbols |
1059
+ | `AXIS_SYMBOL_MAPPING` | 16 axes → symbol mappings |
1060
+ | `SymbolicMoment` | Moment with I-Ching classification |
1061
+ | `SymbolicTemporalLayer` | 64-attractor hexagram classification |
1062
+ | `HEXAGRAM_ARCHETYPES` | 64 hexagram → archetype mappings |
1063
+ | `SymbolicPatternDetector` | Narrative pattern detection |
1064
+ | `TimeDilationAssay` | Assay A: Time dilation test |
1065
+ | `MemoryContinuityAssay` | Assay B: Memory continuity test |
1066
+ | `AgencyConstraintAssay` | Assay C: Agency under constraint test |
1067
+ | `NonCommutativeMeaningAssay` | Assay D: Non-commutative meaning test |
1068
+ | `AssaySuite` | Run all four validation assays |
1069
+
1070
+ ### Topology Exports
1071
+
1072
+ | Export | Description |
1073
+ |--------|-------------|
1074
+ | `TWIST_108` | 108 invariant with twist angle calculations |
1075
+ | `Knot` | General knot class with invariant computation |
1076
+ | `TREFOIL` | Pre-configured trefoil knot (T=17) |
1077
+ | `PhysicalConstants` | Derived constants (α, proton/electron ratio) |
1078
+ | `GaugeSymmetry` | Standard Model gauge group from 108 |
1079
+ | `FreeEnergyDynamics` | Cubic FEP model dψ/dt = αψ + βψ² + γψ³ |
1080
+ | `OBSERVER_HIERARCHY` | 5-level observer scale hierarchy |
1081
+
1082
+ ### Discrete Dynamics Exports
1083
+
1084
+ | Export | Description |
1085
+ |--------|-------------|
1086
+ | `INT_SINE_TABLE` | M=256 integer sine/cosine table |
1087
+ | `computeHistogramCoherence` | C_bin(t) = max_k(b_k)/\|P\| |
1088
+ | `SMF_CODEBOOK` | 64-attractor codebook array |
1089
+ | `nearestCodebookAttractor` | Find nearest attractor for phase |
1090
+ | `codebookTunnel` | Controlled tunneling to attractor |
1091
+ | `canonicalTriad` | Find lexicographically first triad for sum |
1092
+ | `canonicalFusion` | FUSE(p,q,r) with automatic triad |
1093
+ | `verifyCanonical` | Verify triad is canonical |
1094
+ | `TickGate` | Tick-only HQE gating class |
1095
+
565
1096
  ### Formal Semantics Exports
566
1097
 
567
1098
  | Export | Description |
@@ -622,6 +1153,14 @@ const engine = require('@aleph-ai/tinyaleph/engine');
622
1153
  | `PrimeLayerNorm` | Prime-preserving normalization |
623
1154
  | `PositionalPrimeEncoding` | Position as prime phases |
624
1155
  | `SparsePrimeState` | Sparse activation storage |
1156
+ | `CRTResonantAttention` | Multi-head CRT-fused attention |
1157
+ | `HomologyRegularizedBlock` | Block with homology loss |
1158
+ | `CRTResoFormer` | Complete CRT-enhanced model |
1159
+ | `ResidueEncoder` | Encode to residue distributions |
1160
+ | `CRTReconstructor` | Chinese Remainder Theorem |
1161
+ | `BirkhoffProjector` | Doubly-stochastic projection |
1162
+ | `HomologyLoss` | Cycle-based regularization |
1163
+ | `CoprimeSelector` | Optimal moduli selection |
625
1164
 
626
1165
  ## Documentation
627
1166
 
@@ -633,11 +1172,26 @@ Full documentation is available in the `docs/` directory:
633
1172
 
634
1173
  - **[Guide](./docs/guide/README.md)**: Practical tutorials
635
1174
  - Quick start, semantic computing, cryptographic applications
636
- - Scientific computing, LLM integration, advanced topics
1175
+ - Scientific computing, LLM integration, symbolic AI, advanced topics
637
1176
 
638
1177
  - **[Reference](./docs/reference/README.md)**: Complete API documentation
639
1178
  - Core module, physics module, backends, engine
1179
+ - [Topology module](./docs/reference/07-topology.md): 108 invariant, knots, gauge symmetry
640
1180
 
1181
+ - **[CRT-Homology Reference](./docs/reference/09-crt-homology.md)**: CRT reconstruction and homology
1182
+
1183
+ - **[Topology Examples](./examples/topology/README.md)**: 108 invariant and physical constants
1184
+ - 108 invariant and twist angles
1185
+ - Trefoil complexity and mass ratios
1186
+ - Gauge symmetry from factorization
1187
+ - Free energy dynamics
1188
+
1189
+ - **[Discrete Dynamics Examples](./examples/discrete/README.md)**: Integer-domain computation
1190
+ - Integer sine tables
1191
+ - Codebook tunneling
1192
+ - Canonical fusion selection
1193
+ - Tick-based gating
1194
+
641
1195
  - **[Formal Semantics Examples](./examples/formal-semantics/README.md)**: New formal system demos
642
1196
  - Typed terms and type checking
643
1197
  - Reduction and normalization
@@ -666,6 +1220,37 @@ node examples/formal-semantics/01-typed-terms.js
666
1220
  node examples/formal-semantics/02-reduction.js
667
1221
  node examples/formal-semantics/03-lambda-translation.js
668
1222
  node examples/formal-semantics/04-enochian-language.js
1223
+
1224
+ # Topology examples (108 invariant, physical constants)
1225
+ node examples/topology/01-108-invariant.js
1226
+ node examples/topology/02-trefoil-constants.js
1227
+ node examples/topology/03-gauge-symmetry.js
1228
+ node examples/topology/04-free-energy-dynamics.js
1229
+
1230
+ # Discrete dynamics examples (integer tables, codebooks)
1231
+ node examples/discrete/01-integer-sine-table.js
1232
+ node examples/discrete/02-codebook-tunneling.js
1233
+ node examples/discrete/03-canonical-fusion.js
1234
+ node examples/discrete/04-tick-gate.js
1235
+
1236
+ # CRT-Homology examples
1237
+ node examples/crt-homology/01-residue-encoding.js
1238
+ node examples/crt-homology/02-birkhoff-attention.js
1239
+ node examples/crt-homology/03-homology-loss.js
1240
+ node examples/crt-homology/04-crt-resoformer.js
1241
+
1242
+ # Bioinformatics examples
1243
+ node examples/bioinformatics/01-dna-encoding.js
1244
+ node examples/bioinformatics/02-central-dogma.js
1245
+ node examples/bioinformatics/03-protein-folding.js
1246
+ node examples/bioinformatics/04-dna-computing.js
1247
+ node examples/bioinformatics/05-molecular-binding.js
1248
+
1249
+ # Symbolic AI examples
1250
+ node examples/05-symbolic-resonance.js
1251
+ node examples/06-symbol-database.js
1252
+ node examples/07-semantic-inference.js
1253
+ node examples/08-compound-symbols.js
669
1254
  ```
670
1255
 
671
1256
  ## Architecture
@@ -673,10 +1258,10 @@ node examples/formal-semantics/04-enochian-language.js
673
1258
  ```
674
1259
  ┌─────────────────────────────────────────────────────────────────┐
675
1260
  │ AlephEngine │
676
- │ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────────┐
677
- │ │ Oscillators │◄─┤ Field │◄─┤ Transform │
678
- │ │ (Kuramoto) │ │ (Sedenion) │ │ Pipeline │
679
- │ └─────────────┘ └─────────────┘ └─────────────────────────┘
1261
+ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────────┐
1262
+ │ │ Oscillators │◄─┤ Field │◄─┤ Transform │
1263
+ │ │ (Kuramoto) │ │ (Sedenion) │ │ Pipeline │
1264
+ │ └─────────────┘ └─────────────┘ └─────────────────────────┘
680
1265
  └─────────────────────────────────────────────────────────────────┘
681
1266
 
682
1267
  ┌────────────────────┼────────────────────┐
@@ -690,7 +1275,7 @@ node examples/formal-semantics/04-enochian-language.js
690
1275
  └─────────────────┘ └─────────────────┘ └─────────────────┘
691
1276
 
692
1277
  ┌─────────────────────────────────────────────────────────────────┐
693
- │ Formal Semantics Layer
1278
+ │ Formal Semantics Layer
694
1279
  ├─────────────────┬─────────────────┬─────────────────────────────┤
695
1280
  │ Type System │ Reduction │ Lambda Translation │
696
1281
  │ │ │ │
@@ -701,14 +1286,25 @@ node examples/formal-semantics/04-enochian-language.js
701
1286
  └─────────────────┴─────────────────┴─────────────────────────────┘
702
1287
 
703
1288
  ┌─────────────────────────────────────────────────────────────────┐
704
- Enochian Language Module
1289
+ Symbolic AI Layer
1290
+ ├─────────────────┬─────────────────┬─────────────────────────────┤
1291
+ │ Symbol DB │ Inference │ Resonance │
1292
+ │ │ │ │
1293
+ │ • 184+ emojis │ • Pattern match │ • Golden ratio φ │
1294
+ │ • Cultural tags │ • Semantic sim │ • Prime pair harmony │
1295
+ │ • Prime index │ • ResoFormer │ • Cluster detection │
1296
+ │ • Categories │ • Context-aware │ • Compound scoring │
1297
+ └─────────────────┴─────────────────┴─────────────────────────────┘
1298
+
1299
+ ┌─────────────────────────────────────────────────────────────────┐
1300
+ │ Enochian Language Module │
705
1301
  ├─────────────────────────────────────────────────────────────────┤
706
- │ • 21-letter alphabet with prime mappings
1302
+ │ • 21-letter alphabet with prime mappings
707
1303
  │ • Prime basis PE = {7, 11, 13, 17, 19, 23, 29} │
708
- │ • Twist angles κ(p) = 360/p degrees
709
- │ • 16-dimensional sedenion operations
710
- │ • Core vocabulary (35+ words)
711
- │ • The Nineteen Calls (traditional invocations)
1304
+ │ • Twist angles κ(p) = 360/p degrees
1305
+ │ • 16-dimensional sedenion operations
1306
+ │ • Core vocabulary (35+ words)
1307
+ │ • The Nineteen Calls (traditional invocations)
712
1308
  └─────────────────────────────────────────────────────────────────┘
713
1309
  ```
714
1310