@aleph-ai/tinyaleph 1.0.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/LICENSE +21 -0
- package/README.md +278 -0
- package/backends/cryptographic/index.js +196 -0
- package/backends/index.js +15 -0
- package/backends/interface.js +89 -0
- package/backends/scientific/index.js +272 -0
- package/backends/semantic/index.js +527 -0
- package/backends/semantic/surface.js +393 -0
- package/backends/semantic/two-layer.js +375 -0
- package/core/fano.js +127 -0
- package/core/hilbert.js +564 -0
- package/core/hypercomplex.js +141 -0
- package/core/index.js +133 -0
- package/core/llm.js +132 -0
- package/core/prime.js +184 -0
- package/core/resonance.js +695 -0
- package/core/rformer-tf.js +1086 -0
- package/core/rformer.js +806 -0
- package/core/sieve.js +350 -0
- package/data.json +8163 -0
- package/docs/EXAMPLES_PLAN.md +293 -0
- package/docs/README.md +159 -0
- package/docs/design/ALEPH_CHAT_ARCHITECTURE.md +499 -0
- package/docs/guide/01-quickstart.md +298 -0
- package/docs/guide/02-semantic-computing.md +409 -0
- package/docs/guide/03-cryptographic.md +420 -0
- package/docs/guide/04-scientific.md +494 -0
- package/docs/guide/05-llm-integration.md +568 -0
- package/docs/guide/06-advanced.md +996 -0
- package/docs/guide/README.md +188 -0
- package/docs/reference/01-core.md +695 -0
- package/docs/reference/02-physics.md +601 -0
- package/docs/reference/03-backends.md +892 -0
- package/docs/reference/04-engine.md +632 -0
- package/docs/reference/README.md +252 -0
- package/docs/theory/01-prime-semantics.md +327 -0
- package/docs/theory/02-hypercomplex-algebra.md +421 -0
- package/docs/theory/03-phase-synchronization.md +364 -0
- package/docs/theory/04-entropy-reasoning.md +348 -0
- package/docs/theory/05-non-commutativity.md +402 -0
- package/docs/theory/06-two-layer-meaning.md +414 -0
- package/docs/theory/07-resonant-field-interface.md +419 -0
- package/docs/theory/08-semantic-sieve.md +520 -0
- package/docs/theory/09-temporal-emergence.md +298 -0
- package/docs/theory/10-quaternionic-memory.md +415 -0
- package/docs/theory/README.md +162 -0
- package/engine/aleph.js +418 -0
- package/engine/index.js +7 -0
- package/index.js +23 -0
- package/modular.js +254 -0
- package/package.json +99 -0
- package/physics/collapse.js +95 -0
- package/physics/entropy.js +88 -0
- package/physics/index.js +65 -0
- package/physics/kuramoto.js +91 -0
- package/physics/lyapunov.js +80 -0
- package/physics/oscillator.js +95 -0
- package/types/index.d.ts +575 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lyapunov exponent estimation from phase histories
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
function estimateLyapunov(oscillators, windowSize = 20) {
|
|
6
|
+
if (oscillators[0].phaseHistory.length < windowSize) return 0;
|
|
7
|
+
|
|
8
|
+
let sumLog = 0, count = 0;
|
|
9
|
+
for (let i = 0; i < oscillators.length - 1; i++) {
|
|
10
|
+
const h1 = oscillators[i].phaseHistory;
|
|
11
|
+
const h2 = oscillators[i + 1].phaseHistory;
|
|
12
|
+
const d0 = Math.abs(h1[0] - h2[0]);
|
|
13
|
+
const dN = Math.abs(h1[h1.length - 1] - h2[h2.length - 1]);
|
|
14
|
+
if (d0 > 1e-10 && dN > 1e-10) {
|
|
15
|
+
sumLog += Math.log(dN / d0) / windowSize;
|
|
16
|
+
count++;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return count > 0 ? sumLog / count : 0;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function classifyStability(lyapunovExponent) {
|
|
23
|
+
if (lyapunovExponent < -0.1) return 'STABLE';
|
|
24
|
+
if (lyapunovExponent > 0.1) return 'CHAOTIC';
|
|
25
|
+
return 'MARGINAL';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function adaptiveCoupling(baseCoupling, lyapunovExponent, gain = 0.5) {
|
|
29
|
+
if (lyapunovExponent < -0.1) return baseCoupling * (1 + gain);
|
|
30
|
+
if (lyapunovExponent > 0.1) return baseCoupling * (1 - gain);
|
|
31
|
+
return baseCoupling;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Compute local Lyapunov exponent for a specific oscillator
|
|
36
|
+
*/
|
|
37
|
+
function localLyapunov(oscillator, windowSize = 20) {
|
|
38
|
+
const history = oscillator.phaseHistory;
|
|
39
|
+
if (history.length < windowSize + 1) return 0;
|
|
40
|
+
|
|
41
|
+
let sumLog = 0;
|
|
42
|
+
for (let i = 1; i < windowSize; i++) {
|
|
43
|
+
const d0 = Math.abs(history[i] - history[i - 1]);
|
|
44
|
+
if (d0 > 1e-10) {
|
|
45
|
+
sumLog += Math.log(d0);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return sumLog / windowSize;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Phase space reconstruction using delay embedding
|
|
53
|
+
*/
|
|
54
|
+
function delayEmbedding(history, embeddingDim = 3, delay = 1) {
|
|
55
|
+
const embedded = [];
|
|
56
|
+
for (let i = 0; i < history.length - (embeddingDim - 1) * delay; i++) {
|
|
57
|
+
const point = [];
|
|
58
|
+
for (let d = 0; d < embeddingDim; d++) {
|
|
59
|
+
point.push(history[i + d * delay]);
|
|
60
|
+
}
|
|
61
|
+
embedded.push(point);
|
|
62
|
+
}
|
|
63
|
+
return embedded;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Stability margin: how far from instability threshold
|
|
68
|
+
*/
|
|
69
|
+
function stabilityMargin(lyapunovExponent, threshold = 0.1) {
|
|
70
|
+
return threshold - lyapunovExponent;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
module.exports = {
|
|
74
|
+
estimateLyapunov,
|
|
75
|
+
classifyStability,
|
|
76
|
+
adaptiveCoupling,
|
|
77
|
+
localLyapunov,
|
|
78
|
+
delayEmbedding,
|
|
79
|
+
stabilityMargin
|
|
80
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base class for phase-amplitude oscillator
|
|
3
|
+
*
|
|
4
|
+
* Oscillators start QUIESCENT (amplitude = 0) and must be EXCITED
|
|
5
|
+
* by input to become active. This ensures the field response
|
|
6
|
+
* reflects the input, not a default full-amplitude state.
|
|
7
|
+
*/
|
|
8
|
+
class Oscillator {
|
|
9
|
+
constructor(frequency, phase = 0, amplitude = 0) { // Start quiescent!
|
|
10
|
+
this.freq = frequency;
|
|
11
|
+
this.phase = phase;
|
|
12
|
+
this.amplitude = amplitude;
|
|
13
|
+
this.baseAmplitude = amplitude; // Remember initial state
|
|
14
|
+
this.phaseHistory = [];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
tick(dt, coupling = 0) {
|
|
18
|
+
this.phase = (this.phase + 2 * Math.PI * this.freq * dt + coupling) % (2 * Math.PI);
|
|
19
|
+
this.phaseHistory.push(this.phase);
|
|
20
|
+
if (this.phaseHistory.length > 100) this.phaseHistory.shift();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
excite(amount = 0.5) {
|
|
24
|
+
this.amplitude = Math.min(1, this.amplitude + amount);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
decay(rate = 0.02, dt = 1) {
|
|
28
|
+
this.amplitude *= (1 - rate * dt);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
getState() {
|
|
32
|
+
return {
|
|
33
|
+
freq: this.freq,
|
|
34
|
+
phase: this.phase,
|
|
35
|
+
amplitude: this.amplitude
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
reset() {
|
|
40
|
+
this.phase = 0;
|
|
41
|
+
this.amplitude = 0; // Reset to quiescent, not full amplitude!
|
|
42
|
+
this.baseAmplitude = 0;
|
|
43
|
+
this.phaseHistory = [];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Collection of coupled oscillators
|
|
49
|
+
*/
|
|
50
|
+
class OscillatorBank {
|
|
51
|
+
constructor(frequencies) {
|
|
52
|
+
this.oscillators = frequencies.map(f => new Oscillator(f));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
tick(dt, couplingFn) {
|
|
56
|
+
for (const osc of this.oscillators) {
|
|
57
|
+
const coupling = couplingFn ? couplingFn(osc, this.oscillators) : 0;
|
|
58
|
+
osc.tick(dt, coupling);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
exciteByIndices(indices, amount = 0.5) {
|
|
63
|
+
for (const idx of indices) {
|
|
64
|
+
if (idx >= 0 && idx < this.oscillators.length) {
|
|
65
|
+
this.oscillators[idx].excite(amount);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
decayAll(rate = 0.02, dt = 1) {
|
|
71
|
+
for (const osc of this.oscillators) {
|
|
72
|
+
osc.decay(rate, dt);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
getState() {
|
|
77
|
+
return this.oscillators.map(o => o.getState());
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
getAmplitudes() {
|
|
81
|
+
return this.oscillators.map(o => o.amplitude);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
getPhases() {
|
|
85
|
+
return this.oscillators.map(o => o.phase);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
reset() {
|
|
89
|
+
for (const osc of this.oscillators) {
|
|
90
|
+
osc.reset();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
module.exports = { Oscillator, OscillatorBank };
|