@aleph-ai/tinyaleph 1.5.6 → 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 (121) 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/observer/agency.js +885 -0
  108. package/observer/assays.js +973 -0
  109. package/observer/boundary.js +1155 -0
  110. package/observer/entanglement.js +673 -0
  111. package/observer/hqe.js +1465 -0
  112. package/observer/index.js +158 -0
  113. package/observer/prsc.js +1289 -0
  114. package/observer/safety.js +815 -0
  115. package/observer/smf.js +1015 -0
  116. package/observer/symbolic-smf.js +726 -0
  117. package/observer/symbolic-temporal.js +790 -0
  118. package/observer/temporal.js +669 -0
  119. package/package.json +9 -3
  120. package/physics/alk-kuramoto.js +817 -0
  121. package/physics/index.js +23 -2
@@ -0,0 +1,206 @@
1
+ /**
2
+ * Example: Lambda Calculus Translation
3
+ *
4
+ * Demonstrates the τ translation:
5
+ * - τ: Term → λ-expression
6
+ * - Compositional semantics via function application
7
+ * - Type preservation during translation
8
+ * - Operational/denotational agreement
9
+ */
10
+
11
+ const {
12
+ N, A, FUSE, CHAIN, SENTENCE, SEQ, IMPL,
13
+ Translator, LambdaEvaluator, Semantics, ConceptInterpreter,
14
+ ConstExpr, LamExpr, VarExpr, AppExpr
15
+ } = require('../../core');
16
+
17
+ console.log('=== Lambda Calculus Translation ===\n');
18
+
19
+ // ============================================================================
20
+ // 1. Basic Translations
21
+ // ============================================================================
22
+
23
+ console.log('1. BASIC TRANSLATIONS (τ function)\n');
24
+
25
+ const translator = new Translator();
26
+
27
+ // τ(N(p)) = p (constant)
28
+ const noun = N(7);
29
+ const lambdaNoun = translator.translate(noun);
30
+ console.log(`τ(N(7)) = ${lambdaNoun.toString()}`);
31
+ console.log(` Type: ${JSON.stringify(lambdaNoun.getType())}`);
32
+ console.log(` Is value: ${lambdaNoun.isValue()}`);
33
+
34
+ // τ(A(p)) = λx.⊕(p, x)
35
+ const adj = A(3);
36
+ const lambdaAdj = translator.translate(adj);
37
+ console.log(`\nτ(A(3)) = ${lambdaAdj.toString()}`);
38
+ console.log(` Type: ${JSON.stringify(lambdaAdj.getType())}`);
39
+
40
+ // τ(FUSE(p,q,r)) = p+q+r
41
+ const fusion = FUSE(3, 5, 11);
42
+ const lambdaFusion = translator.translate(fusion);
43
+ console.log(`\nτ(FUSE(3,5,11)) = ${lambdaFusion.toString()}`);
44
+ console.log(` Value: ${lambdaFusion.value} (= 3 + 5 + 11)`);
45
+
46
+ // ============================================================================
47
+ // 2. Chain Translation
48
+ // ============================================================================
49
+
50
+ console.log('\n2. CHAIN TRANSLATION\n');
51
+
52
+ // τ(A(p₁)...A(pₖ)N(q)) = ((τ(A(p₁)) ... (τ(A(pₖ)) τ(N(q))))
53
+ const chain = CHAIN([2, 3], N(7));
54
+ const lambdaChain = translator.translate(chain);
55
+ console.log(`τ(${chain.signature()}):`);
56
+ console.log(` = ${lambdaChain.toString()}`);
57
+
58
+ // Show the structure
59
+ console.log('\nStructure breakdown:');
60
+ console.log(` τ(N(7)) = 7`);
61
+ console.log(` τ(A(3)) = λx₀.(x₀ ⊕ 3)`);
62
+ console.log(` τ(A(2)) = λx₁.(x₁ ⊕ 2)`);
63
+ console.log(` Combined: ((λx₁.(x₁ ⊕ 2)) ((λx₀.(x₀ ⊕ 3)) 7))`);
64
+
65
+ // ============================================================================
66
+ // 3. Lambda Evaluation (β-reduction)
67
+ // ============================================================================
68
+
69
+ console.log('\n3. LAMBDA EVALUATION (β-reduction)\n');
70
+
71
+ const evaluator = new LambdaEvaluator();
72
+
73
+ // Simple examples
74
+ console.log('Evaluating λ-expressions:');
75
+
76
+ // (λx.x) 5 → 5
77
+ const identity = new LamExpr('x', new VarExpr('x'));
78
+ const app1 = new AppExpr(identity, new ConstExpr(5));
79
+ const result1 = evaluator.evaluate(app1);
80
+ console.log(` (λx.x) 5 → ${result1.result.toString()} (${result1.steps} steps)`);
81
+
82
+ // (λx.x) (λy.y) → λy.y
83
+ const app2 = new AppExpr(identity, new LamExpr('y', new VarExpr('y')));
84
+ const result2 = evaluator.evaluate(app2);
85
+ console.log(` (λx.x)(λy.y) → ${result2.result.toString()}`);
86
+
87
+ // Evaluating translated terms
88
+ console.log('\nEvaluating translated terms:');
89
+ const chainResult = evaluator.evaluate(lambdaChain);
90
+ console.log(` τ(A(2)A(3)N(7)) → ${chainResult.result.toString()}`);
91
+ console.log(` Steps: ${chainResult.steps}`);
92
+
93
+ // ============================================================================
94
+ // 4. Denotational Semantics
95
+ // ============================================================================
96
+
97
+ console.log('\n4. DENOTATIONAL SEMANTICS\n');
98
+
99
+ const semantics = new Semantics();
100
+
101
+ console.log('Computing denotations [[e]]:');
102
+
103
+ // [[FUSE(3,5,11)]] = 19
104
+ const d1 = semantics.denote(FUSE(3, 5, 11));
105
+ console.log(` [[FUSE(3,5,11)]] = ${d1.value}`);
106
+
107
+ // [[N(7)]] = 7
108
+ const d2 = semantics.denote(N(7));
109
+ console.log(` [[N(7)]] = ${d2.value}`);
110
+
111
+ // [[A(2)A(3)N(7)]]
112
+ const d3 = semantics.denote(CHAIN([2, 3], N(7)));
113
+ console.log(` [[A(2)A(3)N(7)]] = ${d3.value || d3.toString()}`);
114
+
115
+ // ============================================================================
116
+ // 5. Semantic Equivalence
117
+ // ============================================================================
118
+
119
+ console.log('\n5. SEMANTIC EQUIVALENCE\n');
120
+
121
+ // Same terms should be equivalent
122
+ const f1 = FUSE(3, 5, 11);
123
+ const f2 = FUSE(3, 5, 11);
124
+ console.log(`[[FUSE(3,5,11)]] = [[FUSE(3,5,11)]]: ${semantics.equivalent(f1, f2)}`);
125
+
126
+ // Different fusions with same sum should be equivalent
127
+ const f3 = FUSE(5, 7, 7); // Would be ill-formed (repeated prime)
128
+ console.log(`Different fusions summing to 19 are semantically equivalent if well-formed`);
129
+
130
+ // ============================================================================
131
+ // 6. Operational/Denotational Agreement
132
+ // ============================================================================
133
+
134
+ console.log('\n6. OPERATIONAL/DENOTATIONAL AGREEMENT\n');
135
+
136
+ console.log('Theorem: If e →* v (operational), then [[e]] = v (denotational)\n');
137
+
138
+ const terms = [
139
+ FUSE(3, 5, 11),
140
+ CHAIN([2], N(7)),
141
+ CHAIN([2, 3, 5], N(11))
142
+ ];
143
+
144
+ for (const term of terms) {
145
+ const verification = semantics.verifySemanticEquivalence(term);
146
+ console.log(`${term.signature()}:`);
147
+ console.log(` Operational: ${verification.operational}`);
148
+ console.log(` Denotational: ${verification.denotational}`);
149
+ console.log(` Agreement: ${verification.equivalent}`);
150
+ }
151
+
152
+ // ============================================================================
153
+ // 7. Concept Interpretation
154
+ // ============================================================================
155
+
156
+ console.log('\n7. CONCEPT INTERPRETATION\n');
157
+
158
+ const interpreter = new ConceptInterpreter();
159
+
160
+ console.log('Prime → Concept mappings:');
161
+ const conceptPrimes = [2, 3, 5, 7, 11, 13, 17, 19, 23];
162
+ for (const p of conceptPrimes) {
163
+ const noun = N(p);
164
+ const concept = interpreter.interpretNoun(noun);
165
+ console.log(` N(${p}) → "${concept}"`);
166
+ }
167
+
168
+ console.log('\nChain interpretation:');
169
+ const chain1 = CHAIN([2, 3], N(7));
170
+ const phrase1 = interpreter.interpretChain(chain1);
171
+ console.log(` ${chain1.signature()} → "${phrase1}"`);
172
+
173
+ const chain2 = CHAIN([5, 7], N(11));
174
+ const phrase2 = interpreter.interpretChain(chain2);
175
+ console.log(` ${chain2.signature()} → "${phrase2}"`);
176
+
177
+ // Custom concept mappings
178
+ console.log('\nCustom concept mappings:');
179
+ interpreter.addNounConcept(97, 'transcendence');
180
+ interpreter.addNounConcept(101, 'infinity');
181
+ console.log(` N(97) → "${interpreter.interpretNoun(N(97))}"`);
182
+ console.log(` N(101) → "${interpreter.interpretNoun(N(101))}"`);
183
+
184
+ // ============================================================================
185
+ // 8. Sentence Translation
186
+ // ============================================================================
187
+
188
+ console.log('\n8. SENTENCE TRANSLATION\n');
189
+
190
+ // Noun sentence
191
+ const s1 = SENTENCE(N(7));
192
+ const lambdaS1 = translator.translate(s1);
193
+ console.log(`τ(SENTENCE(N(7))) = ${lambdaS1.toString()}`);
194
+
195
+ // Sequential composition
196
+ const s2 = SENTENCE(N(11));
197
+ const seq = SEQ(s1, s2);
198
+ const lambdaSeq = translator.translate(seq);
199
+ console.log(`τ(S₁ ◦ S₂) = ${lambdaSeq.toString()}`);
200
+
201
+ // Implication
202
+ const impl = IMPL(s1, s2);
203
+ const lambdaImpl = translator.translate(impl);
204
+ console.log(`τ(S₁ ⇒ S₂) = ${lambdaImpl.toString()}`);
205
+
206
+ console.log('\n=== Done ===');
@@ -0,0 +1,257 @@
1
+ /**
2
+ * Example: Enochian Formal Language System
3
+ *
4
+ * Demonstrates the Enochian language system:
5
+ * - 21-letter alphabet with prime mappings
6
+ * - Prime basis PE = {7, 11, 13, 17, 19, 23, 29}
7
+ * - Twist operations κ(p) = 360/p
8
+ * - Core vocabulary and The 19 Calls
9
+ * - Sedenion (16D) integration
10
+ */
11
+
12
+ const {
13
+ ENOCHIAN_ALPHABET,
14
+ letterToPrime,
15
+ primeToLetter,
16
+ PRIME_BASIS,
17
+ BASIS_MEANINGS,
18
+ TWIST_MODES,
19
+ twistAngle,
20
+ twistRadians,
21
+ TwistOperator,
22
+ validateTwistClosure,
23
+ EnochianWord,
24
+ CORE_VOCABULARY,
25
+ wordLookup,
26
+ EnochianCall,
27
+ THE_NINETEEN_CALLS,
28
+ SedenionElement,
29
+ EnochianEngine
30
+ } = require('../../apps/sentient/lib/enochian-vocabulary');
31
+
32
+ console.log('=== Enochian Formal Language System ===\n');
33
+
34
+ // ============================================================================
35
+ // 1. The Enochian Alphabet
36
+ // ============================================================================
37
+
38
+ console.log('1. THE ENOCHIAN ALPHABET (21 Letters)\n');
39
+
40
+ console.log('Letter | Name | Prime | Meaning');
41
+ console.log('-------|---------|-------|-------------');
42
+ for (const entry of ENOCHIAN_ALPHABET.slice(0, 10)) {
43
+ console.log(` ${entry.letter} | ${entry.name.padEnd(7)} | ${String(entry.prime).padStart(5)} | ${entry.meaning}`);
44
+ }
45
+ console.log(' ... (11 more letters)\n');
46
+
47
+ console.log('Letter → Prime mappings:');
48
+ console.log(` A → ${letterToPrime.get('A')} (beginning)`);
49
+ console.log(` D → ${letterToPrime.get('D')} (foundation)`);
50
+ console.log(` E → ${letterToPrime.get('E')} (light)`);
51
+ console.log(` Z → ${letterToPrime.get('Z')} (completion)`);
52
+
53
+ // ============================================================================
54
+ // 2. Prime Basis PE
55
+ // ============================================================================
56
+
57
+ console.log('\n2. PRIME BASIS PE = {7, 11, 13, 17, 19, 23, 29}\n');
58
+
59
+ console.log('The seven foundational primes and their meanings:');
60
+ for (const p of PRIME_BASIS) {
61
+ console.log(` ${p}: ${BASIS_MEANINGS.get(p)}`);
62
+ }
63
+
64
+ // ============================================================================
65
+ // 3. Twist Operations
66
+ // ============================================================================
67
+
68
+ console.log('\n3. TWIST OPERATIONS\n');
69
+
70
+ console.log('Twist angle κ(p) = 360°/p:\n');
71
+
72
+ const twistPrimes = [7, 11, 13, 17, 19, 23, 29];
73
+ for (const p of twistPrimes) {
74
+ const angle = twistAngle(p);
75
+ const radians = twistRadians(p);
76
+ console.log(` κ(${p.toString().padStart(2)}) = ${angle.toFixed(2)}° = ${radians.toFixed(4)} rad`);
77
+ }
78
+
79
+ // Twist operators
80
+ console.log('\nTwist operators:');
81
+ const twist7 = new TwistOperator(7);
82
+ const twist11 = new TwistOperator(11, TWIST_MODES.MU);
83
+
84
+ console.log(` ${twist7.toString()}`);
85
+ console.log(` ${twist11.toString()}`);
86
+
87
+ // 2D rotation
88
+ const rotated = twist7.apply2D(1, 0);
89
+ console.log(`\n Applying twist(7) to (1, 0):`);
90
+ console.log(` Result: (${rotated.x.toFixed(4)}, ${rotated.y.toFixed(4)})`);
91
+
92
+ // Twist closure validation
93
+ console.log('\nTwist closure validation:');
94
+ const closure1 = validateTwistClosure([7, 11, 13, 17, 19, 23, 29]);
95
+ console.log(` PE basis total angle: ${closure1.totalAngle.toFixed(2)}°`);
96
+ console.log(` Revolutions: ${closure1.revolutions}`);
97
+ console.log(` Is closed: ${closure1.valid}`);
98
+
99
+ // ============================================================================
100
+ // 4. Enochian Words
101
+ // ============================================================================
102
+
103
+ console.log('\n4. ENOCHIAN WORDS\n');
104
+
105
+ // Create some words
106
+ const zacar = new EnochianWord('ZACAR', 'Move', { category: 'command' });
107
+ const zorge = new EnochianWord('ZORGE', 'Be friendly unto me', { category: 'invocation' });
108
+
109
+ console.log('Word: ZACAR (Move)');
110
+ console.log(` Primes: [${zacar.primes.join(', ')}]`);
111
+ console.log(` Product: ${zacar.primeProduct}`);
112
+ console.log(` Twist sum: ${zacar.twistSum.toFixed(2)}°`);
113
+ console.log(` Closure: ${JSON.stringify(zacar.getTwistClosure())}`);
114
+
115
+ console.log('\nWord: ZORGE (Be friendly unto me)');
116
+ console.log(` Primes: [${zorge.primes.join(', ')}]`);
117
+ console.log(` Product: ${zorge.primeProduct}`);
118
+ console.log(` Twist sum: ${zorge.twistSum.toFixed(2)}°`);
119
+
120
+ // Resonance between words
121
+ const resonance = zacar.resonanceWith(zorge);
122
+ console.log('\nResonance between ZACAR and ZORGE:');
123
+ console.log(` Shared primes: [${resonance.sharedPrimes.join(', ')}]`);
124
+ console.log(` Resonance score: ${resonance.resonanceScore.toFixed(4)}`);
125
+ console.log(` Harmonic ratio: ${resonance.harmonicRatio.toFixed(4)}`);
126
+
127
+ // ============================================================================
128
+ // 5. Core Vocabulary
129
+ // ============================================================================
130
+
131
+ console.log('\n5. CORE VOCABULARY\n');
132
+
133
+ console.log(`Total words in vocabulary: ${CORE_VOCABULARY.length}\n`);
134
+
135
+ console.log('Sample words by category:');
136
+ const categories = ['command', 'invocation', 'noun', 'verb', 'element'];
137
+ for (const cat of categories) {
138
+ const words = CORE_VOCABULARY.filter(w => w.category === cat).slice(0, 2);
139
+ if (words.length > 0) {
140
+ console.log(` ${cat}:`);
141
+ for (const w of words) {
142
+ console.log(` ${w.word} - "${w.meaning}"`);
143
+ }
144
+ }
145
+ }
146
+
147
+ // ============================================================================
148
+ // 6. The 19 Calls
149
+ // ============================================================================
150
+
151
+ console.log('\n6. THE 19 CALLS (Keys)\n');
152
+
153
+ console.log(`Total calls: ${THE_NINETEEN_CALLS.length}\n`);
154
+
155
+ console.log('The 19 Calls:');
156
+ for (const call of THE_NINETEEN_CALLS.slice(0, 5)) {
157
+ console.log(` ${call.number}. ${call.name}`);
158
+ console.log(` Purpose: ${call.purpose}`);
159
+ }
160
+ console.log(' ... (14 more calls)\n');
161
+
162
+ // Call analysis
163
+ const call1 = THE_NINETEEN_CALLS[0];
164
+ console.log(`Analysis of Call 1 (${call1.name}):`);
165
+ console.log(` Words: [${call1.words.join(', ')}]`);
166
+ console.log(` Total primes: ${call1.getAllPrimes().length}`);
167
+ const callTwist = call1.getTotalTwist();
168
+ console.log(` Total twist: ${callTwist.totalAngle.toFixed(2)}°`);
169
+ console.log(` Signature: ${call1.getPrimeSignature()}`);
170
+
171
+ // ============================================================================
172
+ // 7. Sedenion Integration (16D)
173
+ // ============================================================================
174
+
175
+ console.log('\n7. SEDENION INTEGRATION (16D)\n');
176
+
177
+ // Create sedenion from word
178
+ const wordSed = SedenionElement.fromWord(zacar);
179
+ console.log('Sedenion from "ZACAR":');
180
+ console.log(` Norm: ${wordSed.norm().toFixed(4)}`);
181
+ console.log(` Components: [${wordSed.components.slice(0, 4).map(c => c.toFixed(4)).join(', ')}, ...]`);
182
+
183
+ // Sedenion operations
184
+ const sed1 = new SedenionElement([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
185
+ const sed2 = new SedenionElement([0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
186
+
187
+ console.log('\nSedenion operations:');
188
+ console.log(` s1 = 1 (real unit)`);
189
+ console.log(` s2 = e₁ (first imaginary unit)`);
190
+
191
+ const sum = sed1.add(sed2);
192
+ console.log(` s1 + s2 = ${sum.toString()}`);
193
+
194
+ const conj = sed2.conjugate();
195
+ console.log(` conj(s2) = ${conj.toString()}`);
196
+
197
+ // Twist in 16D
198
+ const twisted = wordSed.twist(7);
199
+ console.log('\nTwisting sedenion by prime 7:');
200
+ console.log(` Original norm: ${wordSed.norm().toFixed(4)}`);
201
+ console.log(` Twisted norm: ${twisted.norm().toFixed(4)}`);
202
+ console.log(` Norm preserved: ${Math.abs(wordSed.norm() - twisted.norm()) < 0.0001}`);
203
+
204
+ // ============================================================================
205
+ // 8. Enochian Engine
206
+ // ============================================================================
207
+
208
+ console.log('\n8. ENOCHIAN ENGINE\n');
209
+
210
+ const engine = new EnochianEngine();
211
+
212
+ // Parse text
213
+ console.log('Parsing Enochian text:');
214
+ const parsed = engine.parse('OL SONF VORS GOHE');
215
+ console.log(` Input: "OL SONF VORS GOHE"`);
216
+ console.log(` Parsed words: ${parsed.length}`);
217
+ for (const word of parsed) {
218
+ console.log(` ${word.word} - "${word.meaning}"`);
219
+ }
220
+
221
+ // Prime signature
222
+ console.log('\nPrime signature:');
223
+ const sig = engine.primeSignature('ZACAR ZAMRAN');
224
+ console.log(` "ZACAR ZAMRAN" → [${sig.join(', ')}]`);
225
+
226
+ // Convert to sedenion
227
+ console.log('\nSedenion representation:');
228
+ const sed = engine.toSedenion('ZACAR');
229
+ console.log(` "ZACAR" → sedenion with norm ${sed.norm().toFixed(4)}`);
230
+
231
+ // Resonance between texts
232
+ console.log('\nResonance computation:');
233
+ const res = engine.resonance('ZACAR', 'ZORGE');
234
+ console.log(` resonance("ZACAR", "ZORGE") = ${res.toFixed(4)}`);
235
+
236
+ // Execute a call
237
+ console.log('\nExecuting Call 1:');
238
+ const callResult = engine.executeCall(1);
239
+ console.log(` Sedenion norm: ${callResult.norm.toFixed(4)}`);
240
+ console.log(` Twist closure valid: ${callResult.twistClosure.valid}`);
241
+
242
+ // Basis decomposition
243
+ console.log('\nBasis decomposition:');
244
+ const decomp = engine.basisDecomposition('ZACAR ZORGE');
245
+ console.log(` Basis counts: ${JSON.stringify(decomp.basisCounts)}`);
246
+ console.log(` Basis ratio: ${(decomp.basisRatio * 100).toFixed(1)}%`);
247
+ console.log(` Non-basis primes: [${decomp.nonBasisPrimes.join(', ')}]`);
248
+
249
+ // Find resonant words
250
+ console.log('\nFinding words resonant with prime 7:');
251
+ const resonant = engine.findResonantWords(7);
252
+ console.log(` Found ${resonant.length} words containing prime 7`);
253
+ if (resonant.length > 0) {
254
+ console.log(` Examples: ${resonant.slice(0, 3).map(w => w.word).join(', ')}`);
255
+ }
256
+
257
+ console.log('\n=== Done ===');
@@ -0,0 +1,98 @@
1
+ # Formal Semantics Examples
2
+
3
+ These examples demonstrate the formal semantic systems for prime-indexed computation.
4
+
5
+ ## Examples
6
+
7
+ ### 1. Typed Terms (`01-typed-terms.js`)
8
+
9
+ Demonstrates the type system:
10
+ - N(p): Noun terms indexed by prime
11
+ - A(p): Adjective/operator terms with p < q constraint
12
+ - ChainTerm: Operator chains A(p₁)...A(pₖ)N(q)
13
+ - FusionTerm: Triadic fusion FUSE(p,q,r)
14
+ - Sentence composition (◦) and implication (⇒)
15
+
16
+ ```bash
17
+ node examples/formal-semantics/01-typed-terms.js
18
+ ```
19
+
20
+ ### 2. Reduction Semantics (`02-reduction.js`)
21
+
22
+ Demonstrates the operational semantics:
23
+ - Small-step reduction (→)
24
+ - Prime-preserving operators (⊕)
25
+ - Strong normalization proof
26
+ - Confluence via Newman's Lemma
27
+ - Fusion canonicalization
28
+
29
+ ```bash
30
+ node examples/formal-semantics/02-reduction.js
31
+ ```
32
+
33
+ ### 3. Lambda Translation (`03-lambda-translation.js`)
34
+
35
+ Demonstrates the τ translation:
36
+ - τ: Term → λ-expression
37
+ - Compositional semantics
38
+ - Type preservation
39
+ - Operational/denotational agreement
40
+ - Concept interpretation
41
+
42
+ ```bash
43
+ node examples/formal-semantics/03-lambda-translation.js
44
+ ```
45
+
46
+ ### 4. Enochian Language (`04-enochian-language.js`)
47
+
48
+ Demonstrates the Enochian formal system:
49
+ - 21-letter alphabet with prime mappings
50
+ - Prime basis PE = {7, 11, 13, 17, 19, 23, 29}
51
+ - Twist operations κ(p) = 360/p
52
+ - The 19 Calls
53
+ - Sedenion (16D) integration
54
+
55
+ ```bash
56
+ node examples/formal-semantics/04-enochian-language.js
57
+ ```
58
+
59
+ ## Running All Examples
60
+
61
+ ```bash
62
+ cd examples/formal-semantics
63
+ for f in *.js; do echo "=== $f ==="; node "$f"; echo; done
64
+ ```
65
+
66
+ ## Key Concepts
67
+
68
+ ### Type System
69
+
70
+ | Type | Description | Example |
71
+ |------|-------------|---------|
72
+ | N(p) | Noun indexed by prime p | N(7) = "truth" |
73
+ | A(p) | Adjective with constraint p < q | A(3) = "triple" modifier |
74
+ | S | Sentence-level proposition | [N(7)] = statement |
75
+
76
+ ### Reduction Rules
77
+
78
+ | Rule | Reduction | Description |
79
+ |------|-----------|-------------|
80
+ | FUSE | FUSE(p,q,r) → N(p+q+r) | Triadic fusion |
81
+ | APPLY | A(p)N(q) → N(q⊕p) | Operator application |
82
+
83
+ ### Enochian Primes
84
+
85
+ | Letter | Prime | Meaning |
86
+ |--------|-------|---------|
87
+ | A | 2 | Beginning |
88
+ | D | 7 | Foundation |
89
+ | E | 11 | Light |
90
+ | G | 17 | Spirit |
91
+ | Z | 73 | Completion |
92
+
93
+ ## Related Files
94
+
95
+ - `core/types.js` - Type system implementation
96
+ - `core/reduction.js` - Reduction semantics
97
+ - `core/lambda.js` - Lambda calculus translation
98
+ - `apps/sentient/lib/enochian-vocabulary.js` - Enochian language