@aleph-ai/tinyaleph 1.5.7 → 1.6.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 (109) hide show
  1. package/core/alexander-module.js +1469 -0
  2. package/core/arithmetic-link-kernel.js +1338 -0
  3. package/core/index.js +95 -2
  4. package/examples/01-hello-world.js +69 -0
  5. package/examples/02-basic-hash.js +90 -0
  6. package/examples/02-observer-stack.js +385 -0
  7. package/examples/03-quantum-coin.js +136 -0
  8. package/examples/05-symbolic-resonance.js +146 -0
  9. package/examples/06-symbol-database.js +150 -0
  10. package/examples/07-semantic-inference.js +223 -0
  11. package/examples/08-compound-symbols.js +219 -0
  12. package/examples/README.md +170 -0
  13. package/examples/ai/01-embeddings.js +155 -0
  14. package/examples/ai/02-semantic-memory.js +243 -0
  15. package/examples/ai/03-reasoning.js +243 -0
  16. package/examples/ai/04-knowledge-graph.js +279 -0
  17. package/examples/ai/05-llm-integration.js +333 -0
  18. package/examples/ai/06-agent.js +294 -0
  19. package/examples/ai/07-hybrid-ai.js +223 -0
  20. package/examples/ai/08-entropy-reasoning.js +259 -0
  21. package/examples/ai/09-concept-learning.js +271 -0
  22. package/examples/ai/10-prompt-primes.js +312 -0
  23. package/examples/ai/11-rag.js +332 -0
  24. package/examples/ai/12-neuro-symbolic.js +321 -0
  25. package/examples/ai/README.md +80 -0
  26. package/examples/arithmetic-topology/01-legendre-symbol.js +78 -0
  27. package/examples/arithmetic-topology/02-redei-symbol.js +126 -0
  28. package/examples/arithmetic-topology/03-alk-kuramoto.js +138 -0
  29. package/examples/arithmetic-topology/04-alexander-module.js +117 -0
  30. package/examples/arithmetic-topology/05-signature-memory.js +118 -0
  31. package/examples/arithmetic-topology/README.md +291 -0
  32. package/examples/bioinformatics/01-dna-encoding.js +108 -0
  33. package/examples/bioinformatics/02-central-dogma.js +162 -0
  34. package/examples/bioinformatics/03-protein-folding.js +206 -0
  35. package/examples/bioinformatics/04-dna-computing.js +192 -0
  36. package/examples/bioinformatics/05-molecular-binding.js +209 -0
  37. package/examples/chat.js +105 -0
  38. package/examples/crt-homology/01-residue-encoding.js +87 -0
  39. package/examples/crt-homology/02-birkhoff-attention.js +100 -0
  40. package/examples/crt-homology/03-homology-loss.js +132 -0
  41. package/examples/crt-homology/04-crt-resoformer.js +132 -0
  42. package/examples/crt-homology/README.md +67 -0
  43. package/examples/crypto/01-password-hash.js +210 -0
  44. package/examples/crypto/02-key-derivation.js +210 -0
  45. package/examples/crypto/03-hmac.js +229 -0
  46. package/examples/crypto/04-file-integrity.js +263 -0
  47. package/examples/crypto/05-content-hash.js +263 -0
  48. package/examples/crypto/README.md +99 -0
  49. package/examples/demo-modular.js +223 -0
  50. package/examples/demo-two-layer.js +196 -0
  51. package/examples/discrete/01-integer-sine-table.js +120 -0
  52. package/examples/discrete/02-codebook-tunneling.js +118 -0
  53. package/examples/discrete/03-canonical-fusion.js +135 -0
  54. package/examples/discrete/04-tick-gate.js +139 -0
  55. package/examples/discrete/README.md +142 -0
  56. package/examples/formal-semantics/01-typed-terms.js +156 -0
  57. package/examples/formal-semantics/02-reduction.js +202 -0
  58. package/examples/formal-semantics/03-lambda-translation.js +206 -0
  59. package/examples/formal-semantics/04-enochian-language.js +257 -0
  60. package/examples/formal-semantics/README.md +98 -0
  61. package/examples/math/01-quaternions.js +237 -0
  62. package/examples/math/02-octonions.js +192 -0
  63. package/examples/math/03-prime-factorization.js +215 -0
  64. package/examples/math/04-vector-spaces.js +210 -0
  65. package/examples/math/05-gaussian-primes.js +234 -0
  66. package/examples/math/README.md +93 -0
  67. package/examples/physics/01-oscillator.js +177 -0
  68. package/examples/physics/02-lyapunov.js +201 -0
  69. package/examples/physics/03-collapse.js +183 -0
  70. package/examples/physics/04-kuramoto.js +212 -0
  71. package/examples/physics/05-entropy.js +226 -0
  72. package/examples/physics/05-sync-models.js +298 -0
  73. package/examples/physics/06-primeon-ladder.js +233 -0
  74. package/examples/physics/07-kuramoto-coupled-ladder.js +298 -0
  75. package/examples/physics/README.md +126 -0
  76. package/examples/resonance/01-prime-hilbert-space.js +140 -0
  77. package/examples/resonance/02-prime-resonance-network.js +221 -0
  78. package/examples/resonance/03-resoformer.js +349 -0
  79. package/examples/resonance/04-resoformer-training.js +329 -0
  80. package/examples/resonance/05-language-model.js +484 -0
  81. package/examples/resonance/README.md +238 -0
  82. package/examples/run-examples.js +417 -0
  83. package/examples/scientific/01-single-qubit.js +185 -0
  84. package/examples/scientific/02-two-qubit.js +209 -0
  85. package/examples/scientific/03-quantum-circuits.js +270 -0
  86. package/examples/scientific/04-measurement.js +229 -0
  87. package/examples/scientific/05-algorithms.js +245 -0
  88. package/examples/scientific/06-random.js +225 -0
  89. package/examples/scientific/07-wavefunction.js +192 -0
  90. package/examples/scientific/README.md +118 -0
  91. package/examples/semantic/01-vocabulary.js +186 -0
  92. package/examples/semantic/02-similarity.js +263 -0
  93. package/examples/semantic/03-word-algebra.js +295 -0
  94. package/examples/semantic/04-clustering.js +348 -0
  95. package/examples/semantic/05-classification.js +386 -0
  96. package/examples/semantic/06-dna-encoding.js +228 -0
  97. package/examples/semantic/07-search.js +304 -0
  98. package/examples/semantic/08-qa-system.js +278 -0
  99. package/examples/semantic/README.md +116 -0
  100. package/examples/topology/01-108-invariant.js +81 -0
  101. package/examples/topology/02-trefoil-constants.js +112 -0
  102. package/examples/topology/03-gauge-symmetry.js +112 -0
  103. package/examples/topology/04-free-energy-dynamics.js +124 -0
  104. package/examples/topology/README.md +129 -0
  105. package/index.js +32 -0
  106. package/modular.js +63 -2
  107. package/package.json +8 -3
  108. package/physics/alk-kuramoto.js +817 -0
  109. package/physics/index.js +23 -2
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Example 01: The 108 Invariant
3
+ *
4
+ * Demonstrates the fundamental 108 = 2² × 3³ invariant from 108bio.pdf
5
+ * that generates gauge symmetries and physical constants.
6
+ */
7
+
8
+ const {
9
+ TWIST_108,
10
+ twistAngle,
11
+ totalTwist,
12
+ isTwistClosed,
13
+ findClosingPrimes
14
+ } = require('../../core/prime');
15
+
16
+ console.log('═══════════════════════════════════════════════════════════════');
17
+ console.log(' The 108 Invariant: Minimal Closed-Form Twist Configuration');
18
+ console.log('═══════════════════════════════════════════════════════════════\n');
19
+
20
+ // Basic properties
21
+ console.log('1. Basic Properties of 108\n');
22
+ console.log(` Value: ${TWIST_108.value}`);
23
+ console.log(` Factorization: ${TWIST_108.binary} × ${TWIST_108.ternary} = 2² × 3³`);
24
+ console.log(` Mod-30 boundary: ${TWIST_108.mod30Boundary} (prime sieve limit)\n`);
25
+
26
+ // Twist angles
27
+ console.log('2. Twist Angles (κ = 360°/p)\n');
28
+ const fundamentalPrimes = [2, 3, 5, 7, 11, 13];
29
+ for (const p of fundamentalPrimes) {
30
+ const angle = twistAngle(p);
31
+ console.log(` κ(${p}) = ${angle.toFixed(2)}°`);
32
+ }
33
+
34
+ // Closure demonstration
35
+ console.log('\n3. Twist Closure (sum must be multiple of 360°)\n');
36
+
37
+ const testSets = [
38
+ [2, 2], // 180 + 180 = 360
39
+ [2, 3, 3], // 180 + 120 + 120 = 420 (not closed)
40
+ [3, 3, 3], // 120 + 120 + 120 = 360
41
+ [2, 3, 3, 3], // 180 + 120 + 120 + 120 = 540 (not closed)
42
+ [2, 2, 3, 3, 3], // 180 + 180 + 120 + 120 + 120 = 720 (2 × 360)
43
+ ];
44
+
45
+ for (const primes of testSets) {
46
+ const total = totalTwist(primes);
47
+ const closed = isTwistClosed(primes);
48
+ console.log(` [${primes.join(', ')}] → ${total.toFixed(0)}° ${closed ? '✓ CLOSED' : '✗ open'}`);
49
+ }
50
+
51
+ // Resonance detection
52
+ console.log('\n4. 108-Resonance Detection\n');
53
+ const testNumbers = [54, 108, 216, 324, 100, 137];
54
+ for (const n of testNumbers) {
55
+ const resonates = TWIST_108.resonates(n);
56
+ console.log(` ${n} ${resonates ? '✓ resonates (n/108 = ' + n/108 + ')' : '✗ does not resonate'}`);
57
+ }
58
+
59
+ // Find primes that form closing sets
60
+ console.log('\n5. Finding Closing Prime Sets\n');
61
+ console.log(' Searching for primes that would close an open sequence...\n');
62
+
63
+ // Start with a single prime [5] and find what would close it
64
+ const currentSequence = [5];
65
+ const candidates = findClosingPrimes(currentSequence);
66
+ console.log(` Current sequence: [${currentSequence.join(', ')}] = ${totalTwist(currentSequence).toFixed(1)}°`);
67
+ console.log(' Top candidates to close:\n');
68
+ for (const candidate of candidates.slice(0, 5)) {
69
+ console.log(` + ${candidate.prime} → error ${candidate.error.toFixed(2)}° ${candidate.closesAt ? '✓ CLOSES' : ''}`);
70
+ }
71
+
72
+ // Physical significance
73
+ console.log('\n6. Physical Significance\n');
74
+ console.log(' The 108 invariant appears throughout physics:\n');
75
+ console.log(` • 108 = 2² × 3³ generates SU(3) × SU(2) × U(1) gauge group`);
76
+ console.log(` • Fine structure: α⁻¹ = 108 + 29 = 137`);
77
+ console.log(` • Mass ratio: 17 × 108 = 1836 (proton/electron)`);
78
+ console.log(` • Hindu/Buddhist: 108 beads, 108 sacred names`);
79
+ console.log(` • Geometry: interior angles of pentagon = 108°`);
80
+
81
+ console.log('\n═══════════════════════════════════════════════════════════════\n');
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Example 02: Trefoil Knot and Physical Constants
3
+ *
4
+ * Demonstrates how the Trefoil knot's topological invariants
5
+ * combine with the 108 invariant to derive physical constants.
6
+ */
7
+
8
+ const {
9
+ Knot,
10
+ TREFOIL,
11
+ FIGURE_EIGHT,
12
+ CINQUEFOIL,
13
+ STANDARD_KNOTS,
14
+ PhysicalConstants
15
+ } = require('../../core/topology');
16
+
17
+ console.log('═══════════════════════════════════════════════════════════════');
18
+ console.log(' Trefoil Knot and Physical Constant Derivation');
19
+ console.log('═══════════════════════════════════════════════════════════════\n');
20
+
21
+ // Trefoil invariants
22
+ console.log('1. The Trefoil Knot (3₁) - Minimal Stable Structure\n');
23
+
24
+ console.log(' Topological Invariants:');
25
+ console.log(` • Crossing number (c): ${TREFOIL.crossings}`);
26
+ console.log(` • Stick number (s): ${TREFOIL.sticks}`);
27
+ console.log(` • Bridge number (b): ${TREFOIL.bridge}`);
28
+ console.log(` • Unknotting (u): ${TREFOIL.unknotting}`);
29
+
30
+ console.log('\n Complexity Calculation:');
31
+ console.log(` T = s·c - b + u`);
32
+ console.log(` T = ${TREFOIL.sticks}×${TREFOIL.crossings} - ${TREFOIL.bridge} + ${TREFOIL.unknotting}`);
33
+ console.log(` T = ${TREFOIL.sticks * TREFOIL.crossings} - ${TREFOIL.bridge} + ${TREFOIL.unknotting}`);
34
+ console.log(` T = ${TREFOIL.complexity()}`);
35
+
36
+ // Mass ratio derivation
37
+ console.log('\n2. Proton-Electron Mass Ratio\n');
38
+
39
+ const massRatio = PhysicalConstants.protonElectronRatio();
40
+ console.log(` Formula: ${massRatio.formula}`);
41
+ console.log(` Derived value: ${massRatio.derived}`);
42
+ console.log(` Experimental value: ${massRatio.experimental}`);
43
+ console.log(` Relative error: ${(massRatio.relativeError * 100).toFixed(4)}%`);
44
+ console.log(` Interpretation: ${massRatio.interpretation}`);
45
+
46
+ // Fine structure constant
47
+ console.log('\n3. Fine Structure Constant Inverse\n');
48
+
49
+ const alpha = PhysicalConstants.fineStructureInverse();
50
+ console.log(` Formula: ${alpha.formula}`);
51
+ console.log(` Derived value: ${alpha.derived}`);
52
+ console.log(` Experimental value: ${alpha.experimental}`);
53
+ console.log(` Relative error: ${(alpha.relativeError * 100).toFixed(4)}%`);
54
+ console.log(` Interpretation: ${alpha.interpretation}`);
55
+
56
+ // Higgs mass
57
+ console.log('\n4. Higgs Boson Mass\n');
58
+
59
+ const higgs = PhysicalConstants.higgsMass();
60
+ console.log(` Formula: ${higgs.formula}`);
61
+ console.log(` Derived value: ${higgs.derived} ${higgs.unit}`);
62
+ console.log(` Experimental value: ${higgs.experimental} ${higgs.unit}`);
63
+ console.log(` Relative error: ${(higgs.relativeError * 100).toFixed(4)}%`);
64
+ console.log(` Interpretation: ${higgs.interpretation}`);
65
+
66
+ // Compare other knots
67
+ console.log('\n5. Comparing Different Knots\n');
68
+
69
+ const knots = [TREFOIL, FIGURE_EIGHT, CINQUEFOIL];
70
+
71
+ console.log(' ┌──────────────┬────────┬────────┬────────┬─────────────┐');
72
+ console.log(' │ Knot │ T │ Genus │ Prime? │ Mass Ratio │');
73
+ console.log(' ├──────────────┼────────┼────────┼────────┼─────────────┤');
74
+
75
+ for (const knot of knots) {
76
+ const T = knot.complexity();
77
+ const genus = knot.genusLowerBound();
78
+ const prime = knot.isPrimeKnot() ? 'Yes' : 'No';
79
+ const ratio = knot.deriveMassRatio();
80
+ console.log(` │ ${knot.name.padEnd(12)} │ ${T.toString().padEnd(6)} │ ${genus.toString().padEnd(6)} │ ${prime.padEnd(6)} │ ${ratio.toString().padEnd(11)} │`);
81
+ }
82
+
83
+ console.log(' └──────────────┴────────┴────────┴────────┴─────────────┘');
84
+
85
+ // Framework validation
86
+ console.log('\n6. Framework Validation\n');
87
+
88
+ const validation = PhysicalConstants.validate();
89
+ console.log(' Validation Results:');
90
+ console.log(` • Proton/electron ratio: ${validation.protonElectron.matches ? '✓ PASS' : '✗ FAIL'} (${(validation.protonElectron.accuracy * 100).toFixed(2)}% accurate)`);
91
+ console.log(` • Fine structure: ${validation.fineStructure.matches ? '✓ PASS' : '✗ FAIL'} (${(validation.fineStructure.accuracy * 100).toFixed(2)}% accurate)`);
92
+ console.log(` • Higgs mass: ${validation.higgs.matches ? '✓ PASS' : '✗ FAIL'} (${(validation.higgs.accuracy * 100).toFixed(2)}% accurate)`);
93
+ console.log(`\n Overall: ${validation.overallValid ? '✓ Framework validated!' : '✗ Some predictions failed'}`);
94
+
95
+ // Custom knot creation
96
+ console.log('\n7. Custom Knot Analysis\n');
97
+
98
+ const customKnot = new Knot({
99
+ name: 'Torus(3,7)',
100
+ notation: 'T(3,7)',
101
+ crossings: 12, // (p-1)(q-1) for torus knot
102
+ sticks: 14,
103
+ bridge: 3,
104
+ unknotting: 4
105
+ });
106
+
107
+ console.log(` ${customKnot.name}:`);
108
+ console.log(` Complexity: ${customKnot.complexity()}`);
109
+ console.log(` Mass ratio: ${customKnot.deriveMassRatio()}`);
110
+ console.log(` Is prime: ${customKnot.isPrimeKnot()}`);
111
+
112
+ console.log('\n═══════════════════════════════════════════════════════════════\n');
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Example 03: Gauge Symmetry from 108
3
+ *
4
+ * Demonstrates how 108 = 2² × 3³ generates the Standard Model
5
+ * gauge group SU(3) × SU(2) × U(1).
6
+ */
7
+
8
+ const { GaugeSymmetry } = require('../../core/topology');
9
+ const { TWIST_108, factorize } = require('../../core/prime');
10
+
11
+ console.log('═══════════════════════════════════════════════════════════════');
12
+ console.log(' Gauge Symmetry from the 108 Invariant');
13
+ console.log('═══════════════════════════════════════════════════════════════\n');
14
+
15
+ // The factorization
16
+ console.log('1. The Factorization 108 = 2² × 3³\n');
17
+ console.log(` 108 = ${TWIST_108.binary} × ${TWIST_108.ternary}`);
18
+ console.log(' = 2² × 3³');
19
+ console.log(' = 4 × 27\n');
20
+ console.log(' This generates the complete Standard Model gauge structure.');
21
+
22
+ // SU(3) - Color
23
+ console.log('\n2. SU(3) Color Symmetry (Strong Force)\n');
24
+
25
+ const su3 = GaugeSymmetry.su3();
26
+ console.log(` Name: ${su3.name}`);
27
+ console.log(` Generator: 3³ = ${su3.generator}`);
28
+ console.log(` Twist angle: ${su3.twistAngle}° (ternary rotation)`);
29
+ console.log(` Symmetry type: ${su3.symmetryType}`);
30
+ console.log(` Description: ${su3.description}`);
31
+ console.log('\n Physical interpretation:');
32
+ console.log(' • Three color charges: red, green, blue');
33
+ console.log(' • 120° rotation between color states');
34
+ console.log(' • Quarks carry color, gluons carry color pairs');
35
+
36
+ // SU(2) - Weak
37
+ console.log('\n3. SU(2) Weak Isospin (Weak Force)\n');
38
+
39
+ const su2 = GaugeSymmetry.su2();
40
+ console.log(` Name: ${su2.name}`);
41
+ console.log(` Generator: 2² = ${su2.generator}`);
42
+ console.log(` Twist angle: ${su2.twistAngle}° (binary rotation)`);
43
+ console.log(` Symmetry type: ${su2.symmetryType}`);
44
+ console.log(` Description: ${su2.description}`);
45
+ console.log('\n Physical interpretation:');
46
+ console.log(' • Two isospin states: up/down');
47
+ console.log(' • 180° rotation between weak eigenstates');
48
+ console.log(' • W±, Z⁰ bosons mediate weak interactions');
49
+
50
+ // U(1) - Electromagnetic
51
+ console.log('\n4. U(1) Electromagnetic (EM Force)\n');
52
+
53
+ const u1 = GaugeSymmetry.u1();
54
+ console.log(` Name: ${u1.name}`);
55
+ console.log(` Generator: ${u1.generator} (full 108)`);
56
+ console.log(` Twist angle: ${u1.twistAngle}° (complete rotation)`);
57
+ console.log(` Symmetry type: ${u1.symmetryType}`);
58
+ console.log(` Description: ${u1.description}`);
59
+ console.log('\n Physical interpretation:');
60
+ console.log(' • Phase symmetry of charged particles');
61
+ console.log(' • 360° rotation returns to same state');
62
+ console.log(' • Photon is the gauge boson');
63
+
64
+ // Full Standard Model
65
+ console.log('\n5. Complete Standard Model Gauge Group\n');
66
+
67
+ const sm = GaugeSymmetry.standardModel();
68
+ console.log(` Name: ${sm.name}`);
69
+ console.log(` Generator: ${sm.generator}`);
70
+ console.log(` Factorization: ${sm.factorization}`);
71
+ console.log(` Description: ${sm.description}`);
72
+
73
+ console.log('\n Component Summary:');
74
+ console.log(' ┌─────────┬───────────────┬───────────┬──────────────┐');
75
+ console.log(' │ Group │ Force │ Generator │ Twist Angle │');
76
+ console.log(' ├─────────┼───────────────┼───────────┼──────────────┤');
77
+ for (const comp of sm.components) {
78
+ console.log(` │ ${comp.name.padEnd(7)} │ ${comp.type.padEnd(13)} │ ${comp.generator.toString().padEnd(9)} │ ${comp.twistAngle.toString().padEnd(4)}° │`);
79
+ }
80
+ console.log(' └─────────┴───────────────┴───────────┴──────────────┘');
81
+
82
+ // Decomposing other numbers
83
+ console.log('\n6. Gauge Decomposition of Numbers\n');
84
+
85
+ const testNumbers = [108, 216, 324, 54, 72, 36, 12, 1836, 137];
86
+
87
+ console.log(' Analyzing gauge structure of various numbers:\n');
88
+ console.log(' ┌────────┬────────┬────────┬────────┬──────────────┐');
89
+ console.log(' │ Number │ SU(3) │ SU(2) │ U(1) │ 108-Resonant │');
90
+ console.log(' ├────────┼────────┼────────┼────────┼──────────────┤');
91
+
92
+ for (const n of testNumbers) {
93
+ const decomp = GaugeSymmetry.decompose(n);
94
+ const resonant = decomp.is108Resonant ? '✓' : '✗';
95
+ console.log(` │ ${n.toString().padEnd(6)} │ ${decomp.su3Strength.toString().padEnd(6)} │ ${decomp.su2Strength.toString().padEnd(6)} │ ${decomp.u1Strength.toString().padEnd(6)} │ ${resonant.padEnd(12)} │`);
96
+ }
97
+
98
+ console.log(' └────────┴────────┴────────┴────────┴──────────────┘');
99
+
100
+ // Physical implications
101
+ console.log('\n7. Physical Implications\n');
102
+
103
+ console.log(' The 108 factorization explains why:');
104
+ console.log(' • The strong force has 3 color charges (from 3³)');
105
+ console.log(' • The weak force has 2 isospin states (from 2²)');
106
+ console.log(' • EM has 1 charge type (from full 108)');
107
+ console.log(' • These forces unify at high energies (GUT scale)');
108
+ console.log('\n The 2² × 3³ structure is the minimal configuration');
109
+ console.log(' that closes under twist operations while preserving');
110
+ console.log(' both binary (weak) and ternary (strong) symmetries.');
111
+
112
+ console.log('\n═══════════════════════════════════════════════════════════════\n');
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Example 04: Free Energy Dynamics
3
+ *
4
+ * Demonstrates the cubic FEP dynamics from 108bio.pdf Section 4.2:
5
+ * dψ/dt = αψ + βψ² + γψ³
6
+ *
7
+ * This models consciousness as minimization of epistemic surprise.
8
+ */
9
+
10
+ const { FreeEnergyDynamics, OBSERVER_HIERARCHY, observerCapacity } = require('../../core/topology');
11
+
12
+ console.log('═══════════════════════════════════════════════════════════════');
13
+ console.log(' Free Energy Dynamics: Cubic FEP Model');
14
+ console.log('═══════════════════════════════════════════════════════════════\n');
15
+
16
+ // Create FEP dynamics
17
+ console.log('1. The Cubic Free Energy Model\n');
18
+ console.log(' dψ/dt = αψ + βψ² + γψ³\n');
19
+ console.log(' Where:');
20
+ console.log(' • ψ represents the "understanding" state');
21
+ console.log(' • α controls linear drift');
22
+ console.log(' • β controls bifurcation (quadratic)');
23
+ console.log(' • γ provides stabilization (cubic)\n');
24
+
25
+ const fep = new FreeEnergyDynamics(0.1, -0.5, -0.1);
26
+ console.log(` Parameters: α=${fep.alpha}, β=${fep.beta}, γ=${fep.gamma}`);
27
+
28
+ // Find fixed points
29
+ console.log('\n2. Fixed Points (Attractors)\n');
30
+
31
+ const fixedPoints = fep.fixedPoints();
32
+ console.log(' Fixed points of the dynamics (where dψ/dt = 0):\n');
33
+ for (const fp of fixedPoints) {
34
+ const potential = fep.potential(fp.value);
35
+ console.log(` ψ = ${fp.value.toFixed(4)} → ${fp.stability} (V = ${potential.toFixed(4)})`);
36
+ }
37
+
38
+ // Trajectory simulation
39
+ console.log('\n3. Trajectory Simulation\n');
40
+
41
+ const trajectory = fep.simulate(0.2, 5, 0.05);
42
+ console.log(' Starting from ψ₀ = 0.2, simulating for t = 5:\n');
43
+ console.log(' ┌────────┬──────────┬────────────┐');
44
+ console.log(' │ Time │ ψ │ V(ψ) │');
45
+ console.log(' ├────────┼──────────┼────────────┤');
46
+
47
+ // Sample every 20 steps
48
+ for (let i = 0; i < trajectory.length; i += 20) {
49
+ const pt = trajectory[i];
50
+ console.log(` │ ${pt.t.toFixed(2).padStart(6)} │ ${pt.psi.toFixed(6).padStart(8)} │ ${pt.potential.toFixed(6).padStart(10)} │`);
51
+ }
52
+ console.log(' └────────┴──────────┴────────────┘');
53
+
54
+ // Compare different parameter regimes
55
+ console.log('\n4. Parameter Regime Exploration\n');
56
+
57
+ const regimes = [
58
+ { name: 'Stable focus', alpha: 0.05, beta: -0.3, gamma: -0.05 },
59
+ { name: 'Saddle', alpha: 0.2, beta: -0.1, gamma: -0.1 },
60
+ { name: 'Bistable', alpha: 0.1, beta: 0.3, gamma: -0.2 },
61
+ { name: 'Monostable', alpha: -0.1, beta: -0.2, gamma: -0.05 },
62
+ ];
63
+
64
+ for (const regime of regimes) {
65
+ const dynamics = new FreeEnergyDynamics(regime.alpha, regime.beta, regime.gamma);
66
+ const fps = dynamics.fixedPoints();
67
+ const stableCount = fps.filter(fp => fp.stability === 'stable').length;
68
+
69
+ console.log(` ${regime.name}:`);
70
+ console.log(` Parameters: α=${regime.alpha}, β=${regime.beta}, γ=${regime.gamma}`);
71
+ console.log(` Fixed points: ${fps.length}, Stable: ${stableCount}\n`);
72
+ }
73
+
74
+ // Observer hierarchy
75
+ console.log('5. Observer Hierarchy (from Table 1)\n');
76
+
77
+ console.log(' Different scales of observers from 108bio.pdf:\n');
78
+ console.log(' ┌────────────┬─────────────────────┬──────────────────────────┐');
79
+ console.log(' │ Scale │ Oscillators │ Observable Behavior │');
80
+ console.log(' ├────────────┼─────────────────────┼──────────────────────────┤');
81
+
82
+ for (const level of OBSERVER_HIERARCHY) {
83
+ const scale = level.scale.padEnd(10);
84
+ const oscillators = (level.constituentOscillators || 'N/A').padEnd(19);
85
+ const behavior = (level.observableBehavior || 'N/A').slice(0, 24).padEnd(24);
86
+ console.log(` │ ${scale} │ ${oscillators} │ ${behavior} │`);
87
+ }
88
+ console.log(' └────────────┴─────────────────────┴──────────────────────────┘');
89
+
90
+ // Observer capacity
91
+ console.log('\n6. Observer Capacity Calculation\n');
92
+ console.log(' C_obs = α·N_osc·K̄·τ⁻¹\n');
93
+ console.log(' Where:');
94
+ console.log(' • N_osc = number of oscillators');
95
+ console.log(' • K̄ = mean coupling strength');
96
+ console.log(' • τ = characteristic coherence time');
97
+ console.log(' • α = scaling constant\n');
98
+
99
+ const examples = [
100
+ { name: 'Neural ensemble', N: 1000, K: 0.3, tau: 0.05, alpha: 1.0 },
101
+ { name: 'Cognitive network', N: 10000, K: 0.5, tau: 0.2, alpha: 1.0 },
102
+ { name: 'Social group', N: 100, K: 0.1, tau: 10.0, alpha: 1.0 },
103
+ ];
104
+
105
+ for (const ex of examples) {
106
+ const capacity = observerCapacity(ex.N, ex.K, ex.tau, ex.alpha);
107
+ console.log(` ${ex.name}:`);
108
+ console.log(` N=${ex.N}, K̄=${ex.K}, τ=${ex.tau}`);
109
+ console.log(` C_obs = ${capacity.toFixed(2)}\n`);
110
+ }
111
+
112
+ // Interpretation
113
+ console.log('7. Interpretation: Consciousness as Entropy Minimization\n');
114
+
115
+ console.log(' The cubic FEP dynamics models consciousness as:');
116
+ console.log(' 1. Modal superposition → ψ represents superposed possibilities');
117
+ console.log(' 2. Entropy gradient → dψ/dt driven by surprise minimization');
118
+ console.log(' 3. Collapse to "now" → stable attractor = present moment');
119
+ console.log(' 4. Multi-scale nesting → observers at each scale');
120
+ console.log('\n High ψ = exploring/uncertain state');
121
+ console.log(' Low ψ = exploiting/certain state');
122
+ console.log(' Attractors = stable conscious states');
123
+
124
+ console.log('\n═══════════════════════════════════════════════════════════════\n');
@@ -0,0 +1,129 @@
1
+ # Topology Examples
2
+
3
+ These examples demonstrate the topological invariants and physical constant derivations from the 108bio.pdf paper "Twist Eigenstates and Topological Morphogenesis".
4
+
5
+ ## Examples
6
+
7
+ ### [01-108-invariant.js](./01-108-invariant.js)
8
+
9
+ The fundamental 108 = 2² × 3³ invariant:
10
+
11
+ - Basic properties and factorization
12
+ - Twist angles κ(p) = 360°/p
13
+ - Twist closure detection
14
+ - 108-resonance checking
15
+ - Finding closing prime sets
16
+
17
+ ```bash
18
+ node examples/topology/01-108-invariant.js
19
+ ```
20
+
21
+ ### [02-trefoil-constants.js](./02-trefoil-constants.js)
22
+
23
+ Trefoil knot and physical constant derivation:
24
+
25
+ - Knot topological invariants (crossings, sticks, bridge, unknotting)
26
+ - Complexity calculation: T = s·c - b + u = 17
27
+ - Proton-electron mass ratio: 17 × 108 = 1836
28
+ - Fine structure constant: α⁻¹ = 108 + 29 = 137
29
+ - Higgs mass: 5³ = 125 GeV
30
+ - Framework validation
31
+
32
+ ```bash
33
+ node examples/topology/02-trefoil-constants.js
34
+ ```
35
+
36
+ ### [03-gauge-symmetry.js](./03-gauge-symmetry.js)
37
+
38
+ Standard Model gauge group from 108:
39
+
40
+ - SU(3) color symmetry from 3³
41
+ - SU(2) weak isospin from 2²
42
+ - U(1) electromagnetic from full 108
43
+ - Complete Standard Model structure
44
+ - Gauge decomposition of numbers
45
+
46
+ ```bash
47
+ node examples/topology/03-gauge-symmetry.js
48
+ ```
49
+
50
+ ### [04-free-energy-dynamics.js](./04-free-energy-dynamics.js)
51
+
52
+ Free Energy Principle (FEP) dynamics:
53
+
54
+ - Cubic dynamics: dψ/dt = αψ + βψ² + γψ³
55
+ - Fixed point analysis
56
+ - Trajectory simulation
57
+ - Parameter regime exploration
58
+ - Observer hierarchy
59
+ - Observer capacity calculation
60
+
61
+ ```bash
62
+ node examples/topology/04-free-energy-dynamics.js
63
+ ```
64
+
65
+ ## Key Concepts
66
+
67
+ ### The 108 Invariant
68
+
69
+ The number 108 = 2² × 3³ is the minimal closed-form twist configuration:
70
+
71
+ ```javascript
72
+ const { TWIST_108 } = require('@aleph-ai/tinyaleph/core/prime');
73
+
74
+ // Check twist closure
75
+ console.log(TWIST_108.isTwistClosed([3, 3, 3])); // true (360°)
76
+ console.log(TWIST_108.resonates(216)); // true (2 × 108)
77
+ ```
78
+
79
+ ### Trefoil Complexity
80
+
81
+ The Trefoil knot (3₁) is the minimal stable structure:
82
+
83
+ ```javascript
84
+ const { TREFOIL, PhysicalConstants } = require('@aleph-ai/tinyaleph/core/topology');
85
+
86
+ console.log(TREFOIL.complexity()); // 17
87
+ console.log(TREFOIL.deriveMassRatio()); // 1836
88
+
89
+ const ratio = PhysicalConstants.protonElectronRatio();
90
+ console.log(ratio.relativeError); // < 0.001
91
+ ```
92
+
93
+ ### Gauge Symmetry
94
+
95
+ 108 generates the Standard Model gauge group:
96
+
97
+ ```javascript
98
+ const { GaugeSymmetry } = require('@aleph-ai/tinyaleph/core/topology');
99
+
100
+ const sm = GaugeSymmetry.standardModel();
101
+ console.log(sm.name); // 'SU(3) × SU(2) × U(1)'
102
+ ```
103
+
104
+ ### Free Energy Dynamics
105
+
106
+ Consciousness modeled as entropy minimization:
107
+
108
+ ```javascript
109
+ const { FreeEnergyDynamics } = require('@aleph-ai/tinyaleph/core/topology');
110
+
111
+ const fep = new FreeEnergyDynamics(0.1, -0.5, -0.1);
112
+ const trajectory = fep.simulate(0.2, 10, 0.01);
113
+ const attractors = fep.fixedPoints();
114
+ ```
115
+
116
+ ## Running All Examples
117
+
118
+ ```bash
119
+ # Run all topology examples
120
+ for f in examples/topology/*.js; do node "$f"; done
121
+ ```
122
+
123
+ ## References
124
+
125
+ - 108bio.pdf: "Twist Eigenstates and Topological Morphogenesis"
126
+ - Section 2: The 108 Invariant
127
+ - Section 3: Knot Invariants and Mass Ratios
128
+ - Section 4: Free Energy Dynamics
129
+ - Table 1: Observer Hierarchy
package/index.js CHANGED
@@ -128,6 +128,13 @@ export const {
128
128
  partialCollapse,
129
129
  applyDecoherence,
130
130
 
131
+ // ALK-Kuramoto models
132
+ ALKKuramotoModel,
133
+ ALKNetworkKuramoto,
134
+ createALKKuramoto,
135
+ createALKNetworkKuramoto,
136
+ runBorromeanExperiment,
137
+
131
138
  // Convenience functions
132
139
  hash,
133
140
  deriveKey,
@@ -169,6 +176,31 @@ export const {
169
176
  PRGraphMemory,
170
177
  applyResonanceOperator,
171
178
 
179
+ // Arithmetic Link Kernel (ArithmeticLinkKernels.pdf)
180
+ LegendreSymbol,
181
+ PowerResidueSymbol,
182
+ RedeiSymbol,
183
+ ArithmeticMilnorInvariant,
184
+ MultipleResidueSymbol,
185
+ ArithmeticLinkKernel,
186
+ ALKOperators,
187
+ findBorromeanPrimes,
188
+ computeLegendreMatrix,
189
+ quickBorromeanCheck,
190
+
191
+ // Alexander Modules (CompleteAlexanderModules.pdf)
192
+ LaurentPolynomial,
193
+ FittingIdeal,
194
+ CrowellSequence,
195
+ AlexanderModule,
196
+ ModuleSignature,
197
+ SignatureMemory,
198
+ SignatureExtractor,
199
+ createAlexanderModule,
200
+ extractSignature,
201
+ createSignatureMemory,
202
+ createSignatureExtractor,
203
+
172
204
  // Sub-modules
173
205
  core,
174
206
  physics,