@aleph-ai/tinyaleph 1.5.7 → 1.6.1
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/core/alexander-module.js +1469 -0
- package/core/arithmetic-link-kernel.js +1338 -0
- package/core/emotion.js +565 -0
- package/core/gravity.js +714 -0
- package/core/hilbert.js +506 -3
- package/core/index.js +132 -4
- package/core/nonlocal.js +744 -0
- package/core/oracle.js +662 -0
- package/examples/01-hello-world.js +69 -0
- package/examples/02-basic-hash.js +90 -0
- package/examples/02-observer-stack.js +385 -0
- package/examples/03-quantum-coin.js +136 -0
- package/examples/05-symbolic-resonance.js +146 -0
- package/examples/06-symbol-database.js +150 -0
- package/examples/07-semantic-inference.js +223 -0
- package/examples/08-compound-symbols.js +219 -0
- package/examples/README.md +170 -0
- package/examples/ai/01-embeddings.js +155 -0
- package/examples/ai/02-semantic-memory.js +243 -0
- package/examples/ai/03-reasoning.js +243 -0
- package/examples/ai/04-knowledge-graph.js +279 -0
- package/examples/ai/05-llm-integration.js +333 -0
- package/examples/ai/06-agent.js +294 -0
- package/examples/ai/07-hybrid-ai.js +223 -0
- package/examples/ai/08-entropy-reasoning.js +259 -0
- package/examples/ai/09-concept-learning.js +271 -0
- package/examples/ai/10-prompt-primes.js +312 -0
- package/examples/ai/11-rag.js +332 -0
- package/examples/ai/12-neuro-symbolic.js +321 -0
- package/examples/ai/README.md +80 -0
- package/examples/arithmetic-topology/01-legendre-symbol.js +78 -0
- package/examples/arithmetic-topology/02-redei-symbol.js +126 -0
- package/examples/arithmetic-topology/03-alk-kuramoto.js +138 -0
- package/examples/arithmetic-topology/04-alexander-module.js +117 -0
- package/examples/arithmetic-topology/05-signature-memory.js +118 -0
- package/examples/arithmetic-topology/README.md +291 -0
- package/examples/bioinformatics/01-dna-encoding.js +108 -0
- package/examples/bioinformatics/02-central-dogma.js +162 -0
- package/examples/bioinformatics/03-protein-folding.js +206 -0
- package/examples/bioinformatics/04-dna-computing.js +192 -0
- package/examples/bioinformatics/05-molecular-binding.js +209 -0
- package/examples/book-operators-demo.js +155 -0
- package/examples/chat.js +105 -0
- package/examples/crt-homology/01-residue-encoding.js +87 -0
- package/examples/crt-homology/02-birkhoff-attention.js +100 -0
- package/examples/crt-homology/03-homology-loss.js +132 -0
- package/examples/crt-homology/04-crt-resoformer.js +132 -0
- package/examples/crt-homology/README.md +67 -0
- package/examples/crypto/01-password-hash.js +210 -0
- package/examples/crypto/02-key-derivation.js +210 -0
- package/examples/crypto/03-hmac.js +229 -0
- package/examples/crypto/04-file-integrity.js +263 -0
- package/examples/crypto/05-content-hash.js +263 -0
- package/examples/crypto/README.md +99 -0
- package/examples/demo-modular.js +223 -0
- package/examples/demo-two-layer.js +196 -0
- package/examples/discrete/01-integer-sine-table.js +120 -0
- package/examples/discrete/02-codebook-tunneling.js +118 -0
- package/examples/discrete/03-canonical-fusion.js +135 -0
- package/examples/discrete/04-tick-gate.js +139 -0
- package/examples/discrete/README.md +142 -0
- package/examples/emotion-demo.js +200 -0
- package/examples/formal-semantics/01-typed-terms.js +156 -0
- package/examples/formal-semantics/02-reduction.js +202 -0
- package/examples/formal-semantics/03-lambda-translation.js +206 -0
- package/examples/formal-semantics/04-enochian-language.js +257 -0
- package/examples/formal-semantics/README.md +98 -0
- package/examples/gravity-demo.js +190 -0
- package/examples/math/01-quaternions.js +237 -0
- package/examples/math/02-octonions.js +192 -0
- package/examples/math/03-prime-factorization.js +215 -0
- package/examples/math/04-vector-spaces.js +210 -0
- package/examples/math/05-gaussian-primes.js +234 -0
- package/examples/math/README.md +93 -0
- package/examples/nonlocal-demo.js +237 -0
- package/examples/oracle-demo.js +204 -0
- package/examples/physics/01-oscillator.js +177 -0
- package/examples/physics/02-lyapunov.js +201 -0
- package/examples/physics/03-collapse.js +183 -0
- package/examples/physics/04-kuramoto.js +212 -0
- package/examples/physics/05-entropy.js +226 -0
- package/examples/physics/05-sync-models.js +298 -0
- package/examples/physics/06-primeon-ladder.js +233 -0
- package/examples/physics/07-kuramoto-coupled-ladder.js +298 -0
- package/examples/physics/README.md +126 -0
- package/examples/quantum/01-prime-hunter.js +79 -0
- package/examples/quantum/02-entanglement-demo.js +79 -0
- package/examples/quantum/03-wave-analysis.js +63 -0
- package/examples/resonance/01-prime-hilbert-space.js +140 -0
- package/examples/resonance/02-prime-resonance-network.js +221 -0
- package/examples/resonance/03-resoformer.js +349 -0
- package/examples/resonance/04-resoformer-training.js +329 -0
- package/examples/resonance/05-language-model.js +484 -0
- package/examples/resonance/README.md +238 -0
- package/examples/run-examples.js +427 -0
- package/examples/scientific/01-single-qubit.js +185 -0
- package/examples/scientific/02-two-qubit.js +209 -0
- package/examples/scientific/03-quantum-circuits.js +270 -0
- package/examples/scientific/04-measurement.js +229 -0
- package/examples/scientific/05-algorithms.js +245 -0
- package/examples/scientific/06-random.js +225 -0
- package/examples/scientific/07-wavefunction.js +192 -0
- package/examples/scientific/README.md +118 -0
- package/examples/semantic/01-vocabulary.js +186 -0
- package/examples/semantic/02-similarity.js +263 -0
- package/examples/semantic/03-word-algebra.js +295 -0
- package/examples/semantic/04-clustering.js +348 -0
- package/examples/semantic/05-classification.js +386 -0
- package/examples/semantic/06-dna-encoding.js +228 -0
- package/examples/semantic/07-search.js +304 -0
- package/examples/semantic/08-qa-system.js +278 -0
- package/examples/semantic/README.md +116 -0
- package/examples/topology/01-108-invariant.js +81 -0
- package/examples/topology/02-trefoil-constants.js +112 -0
- package/examples/topology/03-gauge-symmetry.js +112 -0
- package/examples/topology/04-free-energy-dynamics.js +124 -0
- package/examples/topology/README.md +129 -0
- package/index.js +32 -0
- package/modular.js +63 -2
- package/package.json +8 -3
- package/physics/alk-kuramoto.js +817 -0
- package/physics/index.js +23 -2
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example: Prime Hilbert Space (HP)
|
|
3
|
+
*
|
|
4
|
+
* Demonstrates the formal quantum-like structure from the paper:
|
|
5
|
+
* "Programming Reality: Prime Resonance Systems for Memory, Computation, and Probability Control"
|
|
6
|
+
*
|
|
7
|
+
* Key concepts:
|
|
8
|
+
* - Prime basis states |p⟩
|
|
9
|
+
* - Complex amplitudes αp ∈ ℂ
|
|
10
|
+
* - Superposition and measurement
|
|
11
|
+
* - Resonance operators (P̂, F̂, R̂, Ĉ)
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const {
|
|
15
|
+
Complex,
|
|
16
|
+
PrimeState,
|
|
17
|
+
ResonanceOperators,
|
|
18
|
+
EntropyDrivenEvolution
|
|
19
|
+
} = require('../../modular');
|
|
20
|
+
|
|
21
|
+
console.log('═══════════════════════════════════════════════════════════════');
|
|
22
|
+
console.log(' PRIME HILBERT SPACE DEMONSTRATION');
|
|
23
|
+
console.log('═══════════════════════════════════════════════════════════════\n');
|
|
24
|
+
|
|
25
|
+
// 1. Prime Basis States
|
|
26
|
+
console.log('1. PRIME BASIS STATES |p⟩');
|
|
27
|
+
console.log('─────────────────────────────────────────────────────────────────');
|
|
28
|
+
|
|
29
|
+
const basis7 = PrimeState.basis(7);
|
|
30
|
+
const basis11 = PrimeState.basis(11);
|
|
31
|
+
|
|
32
|
+
console.log('|7⟩ amplitude:', basis7.get(7).toString());
|
|
33
|
+
console.log('|11⟩ amplitude:', basis11.get(11).toString());
|
|
34
|
+
console.log('Inner product ⟨7|7⟩:', basis7.inner(basis7).toString());
|
|
35
|
+
console.log('Inner product ⟨7|11⟩:', basis7.inner(basis11).toString(), '(orthogonal)');
|
|
36
|
+
|
|
37
|
+
// 2. Uniform Superposition
|
|
38
|
+
console.log('\n2. UNIFORM SUPERPOSITION');
|
|
39
|
+
console.log('─────────────────────────────────────────────────────────────────');
|
|
40
|
+
|
|
41
|
+
const uniform = PrimeState.uniform();
|
|
42
|
+
console.log('Uniform superposition entropy:', uniform.entropy().toFixed(4));
|
|
43
|
+
console.log('Number of primes:', uniform.primes.length);
|
|
44
|
+
console.log('First 5 amplitudes:');
|
|
45
|
+
for (let i = 0; i < 5; i++) {
|
|
46
|
+
const p = uniform.primes[i];
|
|
47
|
+
console.log(` |${p}⟩: ${uniform.get(p).toString()}`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// 3. Composite States
|
|
51
|
+
console.log('\n3. COMPOSITE STATES |n⟩ = |p₁⟩|p₂⟩...');
|
|
52
|
+
console.log('─────────────────────────────────────────────────────────────────');
|
|
53
|
+
|
|
54
|
+
const composite30 = PrimeState.composite(30); // 30 = 2 × 3 × 5
|
|
55
|
+
console.log('|30⟩ = |2⟩|3⟩|5⟩ (as weighted superposition)');
|
|
56
|
+
console.log('Dominant primes:');
|
|
57
|
+
for (const { p, amp } of composite30.dominant(3)) {
|
|
58
|
+
console.log(` |${p}⟩: amplitude ${amp.toFixed(4)}`);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// 4. Resonance Operators
|
|
62
|
+
console.log('\n4. RESONANCE OPERATORS');
|
|
63
|
+
console.log('─────────────────────────────────────────────────────────────────');
|
|
64
|
+
|
|
65
|
+
// P̂: Prime eigenvalue operator
|
|
66
|
+
console.log('\nP̂ (Prime Eigenvalue): P̂|p⟩ = p|p⟩');
|
|
67
|
+
const Pstate = ResonanceOperators.P(basis7);
|
|
68
|
+
console.log('P̂|7⟩ amplitude:', Pstate.get(7).toString(), '(= 7 × |7⟩)');
|
|
69
|
+
|
|
70
|
+
// R̂: Phase rotation operator
|
|
71
|
+
console.log('\nR̂(n) (Resonance): e^(2πi log_p(n)) rotation');
|
|
72
|
+
const R5 = ResonanceOperators.R(5);
|
|
73
|
+
const rotated = R5(basis7);
|
|
74
|
+
console.log('R̂(5)|7⟩ amplitude:', rotated.get(7).toString());
|
|
75
|
+
console.log('Original norm:', basis7.norm().toFixed(4));
|
|
76
|
+
console.log('After R̂(5) norm:', rotated.norm().toFixed(4), '(preserved)');
|
|
77
|
+
|
|
78
|
+
// Ĉ: Coupling operator
|
|
79
|
+
console.log('\nĈ(n) (Coupling): Phase coupling between primes');
|
|
80
|
+
const C7 = ResonanceOperators.C(7);
|
|
81
|
+
const coupled = C7(uniform);
|
|
82
|
+
console.log('Ĉ(7) on uniform state - creates interference');
|
|
83
|
+
console.log('Dominant after coupling:', coupled.dominant(3).map(d => d.p).join(', '));
|
|
84
|
+
|
|
85
|
+
// Ĥ: Hadamard-like
|
|
86
|
+
console.log('\nĤ (Hadamard-like): Creates superposition');
|
|
87
|
+
const hadamard = ResonanceOperators.H(basis7);
|
|
88
|
+
console.log('Ĥ|7⟩ entropy:', hadamard.entropy().toFixed(4), '(increased)');
|
|
89
|
+
|
|
90
|
+
// 5. Measurement (Born Rule)
|
|
91
|
+
console.log('\n5. QUANTUM MEASUREMENT (Born Rule)');
|
|
92
|
+
console.log('─────────────────────────────────────────────────────────────────');
|
|
93
|
+
|
|
94
|
+
const superposition = PrimeState.uniform();
|
|
95
|
+
console.log('Measuring uniform superposition 10 times:');
|
|
96
|
+
const measurements = [];
|
|
97
|
+
for (let i = 0; i < 10; i++) {
|
|
98
|
+
const result = superposition.measure();
|
|
99
|
+
measurements.push(result.prime);
|
|
100
|
+
}
|
|
101
|
+
console.log('Results:', measurements.join(', '));
|
|
102
|
+
|
|
103
|
+
// 6. Entropy-Driven Evolution
|
|
104
|
+
console.log('\n6. ENTROPY-DRIVEN EVOLUTION');
|
|
105
|
+
console.log('─────────────────────────────────────────────────────────────────');
|
|
106
|
+
console.log('Equation: d|Ψ(t)⟩/dt = iĤ|Ψ(t)⟩ - λ(R̂ - r_stable)|Ψ(t)⟩');
|
|
107
|
+
|
|
108
|
+
const evolution = new EntropyDrivenEvolution(PrimeState.uniform(), {
|
|
109
|
+
lambda: 0.1,
|
|
110
|
+
rStable: 0.5,
|
|
111
|
+
dt: 0.01
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
console.log('\nInitial entropy:', evolution.state.entropy().toFixed(4));
|
|
115
|
+
|
|
116
|
+
for (let i = 0; i < 100; i++) {
|
|
117
|
+
evolution.step();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
console.log('After 100 steps:');
|
|
121
|
+
console.log(' Entropy:', evolution.state.entropy().toFixed(4));
|
|
122
|
+
console.log(' Time:', evolution.time.toFixed(2));
|
|
123
|
+
console.log(' Entropy integral:', evolution.entropyIntegral.toFixed(4));
|
|
124
|
+
|
|
125
|
+
// 7. Collapse Until Threshold
|
|
126
|
+
console.log('\n7. EVOLUTION UNTIL COLLAPSE');
|
|
127
|
+
console.log('─────────────────────────────────────────────────────────────────');
|
|
128
|
+
console.log('P_collapse = 1 - e^(-∫S(t)dt)');
|
|
129
|
+
|
|
130
|
+
const evo2 = new EntropyDrivenEvolution(PrimeState.uniform(), { lambda: 0.3 });
|
|
131
|
+
const result = evo2.evolveUntilCollapse(500);
|
|
132
|
+
|
|
133
|
+
console.log('Collapsed:', result.collapsed);
|
|
134
|
+
console.log('Steps taken:', result.steps);
|
|
135
|
+
console.log('Collapse probability:', result.probability.toFixed(4));
|
|
136
|
+
console.log('Final state (dominant prime):', result.finalState.prime || result.finalState.p);
|
|
137
|
+
|
|
138
|
+
console.log('\n═══════════════════════════════════════════════════════════════');
|
|
139
|
+
console.log(' DEMONSTRATION COMPLETE');
|
|
140
|
+
console.log('═══════════════════════════════════════════════════════════════\n');
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example: Prime Resonance Network (PRN)
|
|
3
|
+
*
|
|
4
|
+
* Demonstrates the network components from the PRNS specification:
|
|
5
|
+
* - Prime Resonance Identity (PRI) = (P_G, P_E, P_Q)
|
|
6
|
+
* - Phase-Locked Prime Rings
|
|
7
|
+
* - Holographic Memory Fields
|
|
8
|
+
* - Entangled Nodes
|
|
9
|
+
* - Resonant Fragments
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const {
|
|
13
|
+
PrimeResonanceIdentity,
|
|
14
|
+
PhaseLockedRing,
|
|
15
|
+
HolographicField,
|
|
16
|
+
EntangledNode,
|
|
17
|
+
ResonantFragment,
|
|
18
|
+
PrimeState,
|
|
19
|
+
PHI,
|
|
20
|
+
DELTA_S
|
|
21
|
+
} = require('../../modular');
|
|
22
|
+
|
|
23
|
+
console.log('═══════════════════════════════════════════════════════════════');
|
|
24
|
+
console.log(' PRIME RESONANCE NETWORK DEMONSTRATION');
|
|
25
|
+
console.log('═══════════════════════════════════════════════════════════════\n');
|
|
26
|
+
|
|
27
|
+
// 1. Prime Resonance Identity (PRI)
|
|
28
|
+
console.log('1. PRIME RESONANCE IDENTITY (PRI)');
|
|
29
|
+
console.log('─────────────────────────────────────────────────────────────────');
|
|
30
|
+
console.log('PRI = (P_G, P_E, P_Q) - Gaussian, Eisenstein, Quaternionic primes');
|
|
31
|
+
|
|
32
|
+
const priAlpha = PrimeResonanceIdentity.fromSeed(42);
|
|
33
|
+
const priBeta = PrimeResonanceIdentity.random();
|
|
34
|
+
|
|
35
|
+
console.log('\nNode Alpha PRI:');
|
|
36
|
+
console.log(' Gaussian:', priAlpha.gaussian.toString());
|
|
37
|
+
console.log(' Eisenstein:', priAlpha.eisenstein.toString());
|
|
38
|
+
console.log(' Quaternion:', priAlpha.quaternion.toString());
|
|
39
|
+
console.log(' Signature:', priAlpha.signature);
|
|
40
|
+
|
|
41
|
+
console.log('\nNode Beta PRI:');
|
|
42
|
+
console.log(' Signature:', priBeta.signature);
|
|
43
|
+
|
|
44
|
+
const strength = priAlpha.entanglementStrength(priBeta);
|
|
45
|
+
console.log('\nEntanglement strength α↔β:', strength.toFixed(4));
|
|
46
|
+
|
|
47
|
+
// 2. Phase-Locked Prime Rings
|
|
48
|
+
console.log('\n2. PHASE-LOCKED PRIME RINGS');
|
|
49
|
+
console.log('─────────────────────────────────────────────────────────────────');
|
|
50
|
+
console.log('Using irrational phase locks: 2π/φ, 2π/√2');
|
|
51
|
+
console.log('φ (golden ratio):', PHI.toFixed(6));
|
|
52
|
+
console.log('δS (√2):', DELTA_S.toFixed(6));
|
|
53
|
+
|
|
54
|
+
const primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29];
|
|
55
|
+
const ring = new PhaseLockedRing(primes, 'phi');
|
|
56
|
+
|
|
57
|
+
console.log('\nInitial phases (scaled by 1/π):');
|
|
58
|
+
for (let i = 0; i < 5; i++) {
|
|
59
|
+
console.log(` Phase[${primes[i]}]: ${(ring.phases[i] / Math.PI).toFixed(4)}π`);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
console.log('\nInitial order parameter:', ring.orderParameter().toFixed(4));
|
|
63
|
+
|
|
64
|
+
// Evolve the ring
|
|
65
|
+
for (let i = 0; i < 200; i++) {
|
|
66
|
+
ring.tick(0.05);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
console.log('After 200 ticks:');
|
|
70
|
+
console.log(' Order parameter:', ring.orderParameter().toFixed(4));
|
|
71
|
+
console.log(' Mean phase:', (ring.meanPhase() / Math.PI).toFixed(4) + 'π');
|
|
72
|
+
console.log(' Synchronization:', ring.synchronization().toFixed(4));
|
|
73
|
+
|
|
74
|
+
// 3. Holographic Memory Field
|
|
75
|
+
console.log('\n3. HOLOGRAPHIC MEMORY FIELD');
|
|
76
|
+
console.log('─────────────────────────────────────────────────────────────────');
|
|
77
|
+
console.log('I(x,y) = Σ A_p e^(-S(x,y)) e^(ipθ)');
|
|
78
|
+
|
|
79
|
+
const field = new HolographicField(64, 64);
|
|
80
|
+
|
|
81
|
+
// Encode multiple memory fragments at different locations
|
|
82
|
+
const memories = [
|
|
83
|
+
{ state: PrimeState.basis(7), x: 20, y: 20 },
|
|
84
|
+
{ state: PrimeState.basis(11), x: 44, y: 20 },
|
|
85
|
+
{ state: PrimeState.basis(13), x: 32, y: 44 }
|
|
86
|
+
];
|
|
87
|
+
|
|
88
|
+
for (const mem of memories) {
|
|
89
|
+
field.encodeState(mem.state, mem.x, mem.y);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
console.log('\nEncoded 3 memory fragments:');
|
|
93
|
+
console.log(' |7⟩ at (20, 20)');
|
|
94
|
+
console.log(' |11⟩ at (44, 20)');
|
|
95
|
+
console.log(' |13⟩ at (32, 44)');
|
|
96
|
+
|
|
97
|
+
console.log('\nField statistics:');
|
|
98
|
+
console.log(' Max intensity:', field.maxIntensity().toFixed(4));
|
|
99
|
+
|
|
100
|
+
const peaks = field.findPeaks(0.5);
|
|
101
|
+
console.log(' Peaks found:', peaks.length);
|
|
102
|
+
|
|
103
|
+
for (const peak of peaks.slice(0, 3)) {
|
|
104
|
+
console.log(` Peak at (${peak.x}, ${peak.y}): intensity=${peak.intensity.toFixed(4)}`);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Decode from a location
|
|
108
|
+
const decoded = field.decodeAt(20, 20, 5);
|
|
109
|
+
console.log('\nDecoded from (20, 20):');
|
|
110
|
+
for (const { p, amp } of decoded.dominant(3)) {
|
|
111
|
+
console.log(` |${p}⟩: ${amp.toFixed(4)}`);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// 4. Entangled Nodes
|
|
115
|
+
console.log('\n4. ENTANGLED NODES');
|
|
116
|
+
console.log('─────────────────────────────────────────────────────────────────');
|
|
117
|
+
|
|
118
|
+
const nodeA = new EntangledNode('observer-1');
|
|
119
|
+
const nodeB = new EntangledNode('observer-2');
|
|
120
|
+
const nodeC = new EntangledNode('observer-3');
|
|
121
|
+
|
|
122
|
+
console.log('Created nodes: observer-1, observer-2, observer-3');
|
|
123
|
+
|
|
124
|
+
// Establish entanglements
|
|
125
|
+
const strengthAB = nodeA.entangleWith(nodeB);
|
|
126
|
+
const strengthBC = nodeB.entangleWith(nodeC);
|
|
127
|
+
const strengthAC = nodeA.entangleWith(nodeC);
|
|
128
|
+
|
|
129
|
+
console.log('\nEntanglement network:');
|
|
130
|
+
console.log(' observer-1 ↔ observer-2:', strengthAB.toFixed(4));
|
|
131
|
+
console.log(' observer-2 ↔ observer-3:', strengthBC.toFixed(4));
|
|
132
|
+
console.log(' observer-1 ↔ observer-3:', strengthAC.toFixed(4));
|
|
133
|
+
|
|
134
|
+
// Store memory in node A
|
|
135
|
+
const thoughtState = PrimeState.uniform().scale({ re: 0.5, im: 0.5 });
|
|
136
|
+
nodeA.storeMemory(thoughtState, 16, 16);
|
|
137
|
+
|
|
138
|
+
console.log('\nStored memory in observer-1');
|
|
139
|
+
console.log(' Holographic field intensity:', nodeA.holographicMemory.maxIntensity().toFixed(4));
|
|
140
|
+
|
|
141
|
+
// Evolve nodes
|
|
142
|
+
for (let i = 0; i < 50; i++) {
|
|
143
|
+
nodeA.tick(0.1);
|
|
144
|
+
nodeB.tick(0.1);
|
|
145
|
+
nodeC.tick(0.1);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
console.log('\nAfter 50 ticks:');
|
|
149
|
+
console.log(' observer-1 coherence:', nodeA.coherence.toFixed(4));
|
|
150
|
+
console.log(' observer-2 coherence:', nodeB.coherence.toFixed(4));
|
|
151
|
+
console.log(' observer-3 coherence:', nodeC.coherence.toFixed(4));
|
|
152
|
+
|
|
153
|
+
console.log('\nNode stability:');
|
|
154
|
+
console.log(' observer-1 stable:', nodeA.isStable() ? 'YES' : 'NO');
|
|
155
|
+
console.log(' observer-2 stable:', nodeB.isStable() ? 'YES' : 'NO');
|
|
156
|
+
|
|
157
|
+
// 5. Resonant Fragments
|
|
158
|
+
console.log('\n5. RESONANT FRAGMENTS');
|
|
159
|
+
console.log('─────────────────────────────────────────────────────────────────');
|
|
160
|
+
|
|
161
|
+
const fragmentA = ResonantFragment.fromText('truth and wisdom');
|
|
162
|
+
const fragmentB = ResonantFragment.fromText('love and beauty');
|
|
163
|
+
|
|
164
|
+
console.log('Fragment A: "truth and wisdom"');
|
|
165
|
+
console.log(' Entropy:', fragmentA.entropy.toFixed(4));
|
|
166
|
+
console.log(' Dominant primes:', fragmentA.dominant(3).map(d => d.p).join(', '));
|
|
167
|
+
|
|
168
|
+
console.log('\nFragment B: "love and beauty"');
|
|
169
|
+
console.log(' Entropy:', fragmentB.entropy.toFixed(4));
|
|
170
|
+
console.log(' Dominant primes:', fragmentB.dominant(3).map(d => d.p).join(', '));
|
|
171
|
+
|
|
172
|
+
// Tensor product
|
|
173
|
+
const combined = fragmentA.tensorWith(fragmentB);
|
|
174
|
+
console.log('\nTensor product A ⊗ B:');
|
|
175
|
+
console.log(' Combined dominant primes:', combined.dominant(3).map(d => d.p).join(', '));
|
|
176
|
+
|
|
177
|
+
// Coherence
|
|
178
|
+
const coherence = fragmentA.coherenceWith(fragmentB);
|
|
179
|
+
console.log('\nCoherence(A, B):', coherence.toFixed(4));
|
|
180
|
+
|
|
181
|
+
// Phase rotation
|
|
182
|
+
const rotated = fragmentA.rotatePhase(Math.PI / 4);
|
|
183
|
+
console.log('\nAfter π/4 phase rotation:');
|
|
184
|
+
console.log(' Coherence with original:', fragmentA.coherenceWith(rotated).toFixed(4));
|
|
185
|
+
|
|
186
|
+
// 6. Memory Teleportation Scenario
|
|
187
|
+
console.log('\n6. MEMORY TELEPORTATION SCENARIO');
|
|
188
|
+
console.log('─────────────────────────────────────────────────────────────────');
|
|
189
|
+
|
|
190
|
+
const sender = new EntangledNode('sender');
|
|
191
|
+
const receiver = new EntangledNode('receiver');
|
|
192
|
+
|
|
193
|
+
// Establish entanglement
|
|
194
|
+
const entStrength = sender.entangleWith(receiver);
|
|
195
|
+
console.log('Entanglement established:', entStrength.toFixed(4));
|
|
196
|
+
|
|
197
|
+
// Create memory to teleport
|
|
198
|
+
const memoryFragment = ResonantFragment.fromText('the secret of existence');
|
|
199
|
+
console.log('Memory to teleport: "the secret of existence"');
|
|
200
|
+
console.log(' Dominant primes:', memoryFragment.dominant(3).map(d => d.p).join(', '));
|
|
201
|
+
|
|
202
|
+
// Store in sender's holographic field
|
|
203
|
+
sender.storeMemory(memoryFragment.state, 16, 16);
|
|
204
|
+
|
|
205
|
+
// Simulate teleportation (in a real implementation, this would involve
|
|
206
|
+
// the Memory Teleportation Protocol from PRNS)
|
|
207
|
+
console.log('\nSimulating teleportation...');
|
|
208
|
+
|
|
209
|
+
// Transfer the memory pattern to receiver (conceptually)
|
|
210
|
+
receiver.holographicMemory.encodeState(memoryFragment.state, 16, 16);
|
|
211
|
+
|
|
212
|
+
// Verify transfer
|
|
213
|
+
const retrieved = receiver.holographicMemory.decodeAt(16, 16, 5);
|
|
214
|
+
console.log('\nRetrieved from receiver:');
|
|
215
|
+
for (const { p, amp } of retrieved.dominant(3)) {
|
|
216
|
+
console.log(` |${p}⟩: ${amp.toFixed(4)}`);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
console.log('\n═══════════════════════════════════════════════════════════════');
|
|
220
|
+
console.log(' DEMONSTRATION COMPLETE');
|
|
221
|
+
console.log('═══════════════════════════════════════════════════════════════\n');
|