@aleph-ai/tinyaleph 1.0.2 → 1.1.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.
package/README.md CHANGED
@@ -14,6 +14,10 @@ A novel computational paradigm that encodes meaning as prime number signatures,
14
14
  - **Oscillator Dynamics**: Kuramoto-model synchronization for coherent reasoning
15
15
  - **Entropy Minimization**: Reasoning as reduction of semantic uncertainty
16
16
  - **Multiple Backends**: Semantic (NLP), Cryptographic (hashing), Scientific (quantum-inspired)
17
+ - **Formal Type System**: Typed term calculus with N(p)/A(p)/S types and ordering constraints
18
+ - **Reduction Semantics**: Strong normalization with prime-preserving operators
19
+ - **Lambda Translation**: Model-theoretic semantics via λ-calculus embedding
20
+ - **Enochian Vocabulary**: 21-letter angelic alphabet with prime basis and sedenion operations
17
21
 
18
22
  ## Installation
19
23
 
@@ -167,6 +171,40 @@ kuramoto.step(0.01);
167
171
  console.log('Order parameter:', kuramoto.orderParameter());
168
172
  ```
169
173
 
174
+ ### Extended Synchronization Models
175
+
176
+ Five advanced Kuramoto-family models for complex synchronization dynamics:
177
+
178
+ ```javascript
179
+ const {
180
+ NetworkKuramoto, // Topology-aware coupling
181
+ AdaptiveKuramoto, // Hebbian plasticity
182
+ SakaguchiKuramoto, // Phase frustration (chimera states)
183
+ SmallWorldKuramoto, // Watts-Strogatz topology
184
+ MultiSystemCoupling // Cross-system synchronization
185
+ } = require('@aleph-ai/tinyaleph');
186
+
187
+ // Network Kuramoto with custom topology
188
+ const network = new NetworkKuramoto(frequencies, adjacencyMatrix, 0.5);
189
+ network.setFromEntanglementGraph(entanglementGraph, primeList);
190
+
191
+ // Adaptive Kuramoto with Hebbian learning
192
+ const adaptive = new AdaptiveKuramoto(frequencies, 0.3, 0.02);
193
+ // Coupling evolves: "concepts that sync together link together"
194
+
195
+ // Sakaguchi-Kuramoto with phase frustration
196
+ const sakaguchi = new SakaguchiKuramoto(frequencies, 0.5, Math.PI/4);
197
+ console.log('State:', sakaguchi.classifyState()); // synchronized/chimera/incoherent
198
+
199
+ // Small-world topology
200
+ const smallWorld = new SmallWorldKuramoto(frequencies, 4, 0.1, 0.5);
201
+ console.log('Small-world coefficient:', smallWorld.smallWorldCoefficient());
202
+
203
+ // Multi-system coupling (hierarchical or peer-to-peer)
204
+ const multi = new MultiSystemCoupling([system1, system2, system3]);
205
+ console.log('Inter-system coherence:', multi.interSystemCoherence());
206
+ ```
207
+
170
208
  ### Entropy and Stability
171
209
 
172
210
  ```javascript
@@ -180,6 +218,126 @@ const lambda = estimateLyapunov(entropyTimeSeries);
180
218
  console.log('Stable:', lambda < 0);
181
219
  ```
182
220
 
221
+ ## Formal Semantics
222
+
223
+ ### Typed Term Calculus
224
+
225
+ The library implements a formal type system for prime-based compositional semantics:
226
+
227
+ ```javascript
228
+ const { N, A, FUSE, CHAIN, SENTENCE, TypeChecker } = require('@aleph-ai/tinyaleph');
229
+
230
+ // Create typed terms
231
+ const noun7 = N(7); // N(7) - noun indexed by prime 7
232
+ const adj3 = A(3); // A(3) - adjective indexed by prime 3
233
+
234
+ // Adjective application with ordering constraint (p < q)
235
+ const chain = adj3.apply(noun7); // A(3)N(7) is valid since 3 < 7
236
+
237
+ // Triadic fusion where p+q+r is prime
238
+ const fused = FUSE(3, 5, 11); // 3+5+11 = 19 (prime) ✓
239
+
240
+ // Sentence composition
241
+ const s1 = SENTENCE(7);
242
+ const s2 = SENTENCE(11);
243
+ const compound = SEQ(s1, s2); // s₁ ◦ s₂
244
+
245
+ // Type checking
246
+ const checker = new TypeChecker();
247
+ console.log(checker.inferType(noun7)); // 'N'
248
+ console.log(checker.checkApplication(adj3, noun7)); // { valid: true }
249
+ ```
250
+
251
+ ### Reduction Semantics
252
+
253
+ Strong normalization with prime-preserving operators:
254
+
255
+ ```javascript
256
+ const {
257
+ ReductionSystem,
258
+ ResonanceOperator,
259
+ NextPrimeOperator,
260
+ demonstrateStrongNormalization
261
+ } = require('@aleph-ai/tinyaleph');
262
+
263
+ // Create reduction system
264
+ const reduction = new ReductionSystem();
265
+
266
+ // Add prime-preserving operators
267
+ reduction.addOperator(new ResonanceOperator(2)); // Resonance at p=2
268
+ reduction.addOperator(new NextPrimeOperator()); // Map to next prime
269
+
270
+ // Normalize a term sequence
271
+ const result = reduction.normalize([7, 11, 13]);
272
+ console.log(result.normalForm); // Canonical form
273
+ console.log(result.steps); // Reduction trace
274
+
275
+ // Demonstrate strong normalization
276
+ const proof = demonstrateStrongNormalization([3, 5, 7], reduction);
277
+ console.log(proof.terminates); // true (guaranteed!)
278
+ ```
279
+
280
+ ### Lambda Calculus Translation
281
+
282
+ Model-theoretic semantics via τ translation:
283
+
284
+ ```javascript
285
+ const {
286
+ Translator,
287
+ LambdaEvaluator,
288
+ Semantics
289
+ } = require('@aleph-ai/tinyaleph');
290
+
291
+ // Translate prime terms to λ-expressions
292
+ const translator = new Translator();
293
+ const lambda = translator.translateNoun(N(7)); // Constant 7
294
+ const appLambda = translator.translateChain(chain);
295
+
296
+ // Evaluate λ-expressions
297
+ const evaluator = new LambdaEvaluator();
298
+ const normal = evaluator.normalize(appLambda);
299
+
300
+ // Model-theoretic interpretation
301
+ const semantics = new Semantics();
302
+ semantics.domain = [2, 3, 5, 7, 11, 13]; // Prime domain
303
+ const value = semantics.interpret(N(7)); // 7
304
+ ```
305
+
306
+ ### Enochian Vocabulary
307
+
308
+ The 21-letter angelic alphabet with prime basis and sedenion operations:
309
+
310
+ ```javascript
311
+ const {
312
+ EnochianEngine,
313
+ ENOCHIAN_ALPHABET,
314
+ PRIME_BASIS,
315
+ CORE_VOCABULARY,
316
+ SedenionElement
317
+ } = require('@aleph-ai/tinyaleph/apps/sentient/lib/enochian-vocabulary');
318
+
319
+ // 21-letter alphabet with prime mappings
320
+ console.log(ENOCHIAN_ALPHABET['A']); // { prime: 3, value: 1, angle: 51.43 }
321
+ console.log(PRIME_BASIS); // [7, 11, 13, 17, 19, 23, 29]
322
+
323
+ // Enochian engine for word processing
324
+ const engine = new EnochianEngine();
325
+
326
+ // Parse and compute word prime value
327
+ const parsed = engine.parseWord('MADRIAX'); // "O ye heavens"
328
+ console.log(parsed.primeValue);
329
+ console.log(parsed.letters);
330
+
331
+ // Sedenion operations (16-dimensional)
332
+ const s1 = new SedenionElement([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
333
+ const s2 = new SedenionElement([0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
334
+ const product = s1.multiply(s2); // Non-commutative!
335
+
336
+ // Access core vocabulary (35+ Enochian words)
337
+ console.log(CORE_VOCABULARY['OL']); // "I" (first person)
338
+ console.log(CORE_VOCABULARY['ZORGE']); // "be friendly unto"
339
+ ```
340
+
183
341
  ## API Overview
184
342
 
185
343
  ### Main Exports
@@ -194,9 +352,36 @@ console.log('Stable:', lambda < 0);
194
352
  | `Hypercomplex` | Sedenion algebra |
195
353
  | `Oscillator` / `OscillatorBank` | Phase-amplitude oscillators |
196
354
  | `KuramotoModel` | Coupled oscillator synchronization |
355
+ | `NetworkKuramoto` | Topology-aware coupling |
356
+ | `AdaptiveKuramoto` | Hebbian plasticity |
357
+ | `SakaguchiKuramoto` | Phase frustration / chimera states |
358
+ | `SmallWorldKuramoto` | Watts-Strogatz topology |
359
+ | `MultiSystemCoupling` | Cross-system synchronization |
197
360
  | `hash(input)` | Quick semantic hash |
198
361
  | `deriveKey(pass, salt)` | Quick key derivation |
199
362
 
363
+ ### Formal Semantics Exports
364
+
365
+ | Export | Description |
366
+ |--------|-------------|
367
+ | `N(prime)` | Create noun term N(p) |
368
+ | `A(prime)` | Create adjective term A(p) |
369
+ | `FUSE(p, q, r)` | Create triadic fusion |
370
+ | `CHAIN(ops, noun)` | Create operator chain |
371
+ | `SENTENCE(expr)` | Create sentence from noun |
372
+ | `SEQ(s1, s2)` | Sequential composition |
373
+ | `IMPL(s1, s2)` | Implication |
374
+ | `TypeChecker` | Type inference and checking |
375
+ | `ReductionSystem` | Reduction semantics engine |
376
+ | `ResonanceOperator` | Prime resonance operator |
377
+ | `NextPrimeOperator` | Next prime mapping |
378
+ | `ModularOperator` | Modular arithmetic |
379
+ | `Translator` | λ-calculus translation |
380
+ | `LambdaEvaluator` | β-reduction evaluator |
381
+ | `Semantics` | Model-theoretic interpretation |
382
+ | `EnochianEngine` | Enochian language processing |
383
+ | `SedenionElement` | 16D hypercomplex operations |
384
+
200
385
  ### Sub-modules
201
386
 
202
387
  ```javascript
@@ -224,6 +409,12 @@ Full documentation is available in the `docs/` directory:
224
409
 
225
410
  - **[Reference](./docs/reference/README.md)**: Complete API documentation
226
411
  - Core module, physics module, backends, engine
412
+
413
+ - **[Formal Semantics Examples](./examples/formal-semantics/README.md)**: New formal system demos
414
+ - Typed terms and type checking
415
+ - Reduction and normalization
416
+ - Lambda translation
417
+ - Enochian language
227
418
 
228
419
  ## Examples
229
420
 
@@ -241,6 +432,12 @@ npm run benchmark
241
432
 
242
433
  # Interactive chat
243
434
  npm run chat
435
+
436
+ # Formal semantics examples
437
+ node examples/formal-semantics/01-typed-terms.js
438
+ node examples/formal-semantics/02-reduction.js
439
+ node examples/formal-semantics/03-lambda-translation.js
440
+ node examples/formal-semantics/04-enochian-language.js
244
441
  ```
245
442
 
246
443
  ## Architecture
@@ -263,6 +460,28 @@ npm run chat
263
460
  │ • Prime encode │ │ • Key derive │ │ • Wave collapse │
264
461
  │ • Transforms │ │ • Verify │ │ • Measurement │
265
462
  └─────────────────┘ └─────────────────┘ └─────────────────┘
463
+
464
+ ┌─────────────────────────────────────────────────────────────────┐
465
+ │ Formal Semantics Layer │
466
+ ├─────────────────┬─────────────────┬─────────────────────────────┤
467
+ │ Type System │ Reduction │ Lambda Translation │
468
+ │ │ │ │
469
+ │ • N(p), A(p), S │ • Small-step → │ • τ: Terms → λ-expressions │
470
+ │ • FUSE(p,q,r) │ • ⊕ operators │ • β-reduction │
471
+ │ • ◦ composition │ • Normal forms │ • Model interpretation │
472
+ │ • ⇒ implication │ • Confluence │ • Semantic domains │
473
+ └─────────────────┴─────────────────┴─────────────────────────────┘
474
+
475
+ ┌─────────────────────────────────────────────────────────────────┐
476
+ │ Enochian Language Module │
477
+ ├─────────────────────────────────────────────────────────────────┤
478
+ │ • 21-letter alphabet with prime mappings │
479
+ │ • Prime basis PE = {7, 11, 13, 17, 19, 23, 29} │
480
+ │ • Twist angles κ(p) = 360/p degrees │
481
+ │ • 16-dimensional sedenion operations │
482
+ │ • Core vocabulary (35+ words) │
483
+ │ • The Nineteen Calls (traditional invocations) │
484
+ └─────────────────────────────────────────────────────────────────┘
266
485
  ```
267
486
 
268
487
  ## Requirements
package/core/index.js CHANGED
@@ -3,6 +3,33 @@
3
3
  */
4
4
 
5
5
  const { Hypercomplex } = require('./hypercomplex');
6
+
7
+ // Formal Type System (mtspbc.pdf implementation)
8
+ const {
9
+ NounType, AdjType, SentenceType,
10
+ NounTerm, AdjTerm, ChainTerm, FusionTerm,
11
+ NounSentence, SeqSentence, ImplSentence,
12
+ TypingContext, TypingJudgment, TypeChecker,
13
+ N, A, FUSE, CHAIN, SENTENCE, SEQ, IMPL
14
+ } = require('./types');
15
+
16
+ // Reduction Semantics (ncpsc.pdf implementation)
17
+ const {
18
+ PrimeOperator, NextPrimeOperator, ModularPrimeOperator,
19
+ ResonancePrimeOperator, IdentityPrimeOperator, DEFAULT_OPERATOR,
20
+ ReductionStep, ReductionTrace, ReductionSystem,
21
+ isNormalForm, isReducible, termSize,
22
+ FusionCanonicalizer, NormalFormVerifier,
23
+ demonstrateStrongNormalization, testLocalConfluence
24
+ } = require('./reduction');
25
+
26
+ // Lambda Calculus Translation (Section 4 from mtspbc.pdf)
27
+ const {
28
+ LambdaExpr, VarExpr, ConstExpr, LamExpr, AppExpr,
29
+ PairExpr, ImplExpr, PrimOpExpr,
30
+ Translator, TypeDirectedTranslator,
31
+ LambdaEvaluator, Semantics, ConceptInterpreter
32
+ } = require('./lambda');
6
33
  const {
7
34
  FANO_LINES,
8
35
  octonionMultiplyIndex,
@@ -129,5 +156,60 @@ module.exports = {
129
156
  applyResonanceOperator,
130
157
 
131
158
  // TensorFlow.js ResoFormer layers (if available)
132
- ...(rformerTF || {})
159
+ ...(rformerTF || {}),
160
+
161
+ // Formal Type System (mtspbc.pdf)
162
+ NounType,
163
+ AdjType,
164
+ SentenceType,
165
+ NounTerm,
166
+ AdjTerm,
167
+ ChainTerm,
168
+ FusionTerm,
169
+ NounSentence,
170
+ SeqSentence,
171
+ ImplSentence,
172
+ TypingContext,
173
+ TypingJudgment,
174
+ TypeChecker,
175
+ N,
176
+ A,
177
+ FUSE,
178
+ CHAIN,
179
+ SENTENCE,
180
+ SEQ,
181
+ IMPL,
182
+
183
+ // Reduction Semantics (ncpsc.pdf)
184
+ PrimeOperator,
185
+ NextPrimeOperator,
186
+ ModularPrimeOperator,
187
+ ResonancePrimeOperator,
188
+ IdentityPrimeOperator,
189
+ DEFAULT_OPERATOR,
190
+ ReductionStep,
191
+ ReductionTrace,
192
+ ReductionSystem,
193
+ isNormalForm,
194
+ isReducible,
195
+ termSize,
196
+ FusionCanonicalizer,
197
+ NormalFormVerifier,
198
+ demonstrateStrongNormalization,
199
+ testLocalConfluence,
200
+
201
+ // Lambda Calculus Translation
202
+ LambdaExpr,
203
+ VarExpr,
204
+ ConstExpr,
205
+ LamExpr,
206
+ AppExpr,
207
+ PairExpr,
208
+ ImplExpr,
209
+ PrimOpExpr,
210
+ Translator,
211
+ TypeDirectedTranslator,
212
+ LambdaEvaluator,
213
+ Semantics,
214
+ ConceptInterpreter
133
215
  };