@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.
Files changed (58) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +278 -0
  3. package/backends/cryptographic/index.js +196 -0
  4. package/backends/index.js +15 -0
  5. package/backends/interface.js +89 -0
  6. package/backends/scientific/index.js +272 -0
  7. package/backends/semantic/index.js +527 -0
  8. package/backends/semantic/surface.js +393 -0
  9. package/backends/semantic/two-layer.js +375 -0
  10. package/core/fano.js +127 -0
  11. package/core/hilbert.js +564 -0
  12. package/core/hypercomplex.js +141 -0
  13. package/core/index.js +133 -0
  14. package/core/llm.js +132 -0
  15. package/core/prime.js +184 -0
  16. package/core/resonance.js +695 -0
  17. package/core/rformer-tf.js +1086 -0
  18. package/core/rformer.js +806 -0
  19. package/core/sieve.js +350 -0
  20. package/data.json +8163 -0
  21. package/docs/EXAMPLES_PLAN.md +293 -0
  22. package/docs/README.md +159 -0
  23. package/docs/design/ALEPH_CHAT_ARCHITECTURE.md +499 -0
  24. package/docs/guide/01-quickstart.md +298 -0
  25. package/docs/guide/02-semantic-computing.md +409 -0
  26. package/docs/guide/03-cryptographic.md +420 -0
  27. package/docs/guide/04-scientific.md +494 -0
  28. package/docs/guide/05-llm-integration.md +568 -0
  29. package/docs/guide/06-advanced.md +996 -0
  30. package/docs/guide/README.md +188 -0
  31. package/docs/reference/01-core.md +695 -0
  32. package/docs/reference/02-physics.md +601 -0
  33. package/docs/reference/03-backends.md +892 -0
  34. package/docs/reference/04-engine.md +632 -0
  35. package/docs/reference/README.md +252 -0
  36. package/docs/theory/01-prime-semantics.md +327 -0
  37. package/docs/theory/02-hypercomplex-algebra.md +421 -0
  38. package/docs/theory/03-phase-synchronization.md +364 -0
  39. package/docs/theory/04-entropy-reasoning.md +348 -0
  40. package/docs/theory/05-non-commutativity.md +402 -0
  41. package/docs/theory/06-two-layer-meaning.md +414 -0
  42. package/docs/theory/07-resonant-field-interface.md +419 -0
  43. package/docs/theory/08-semantic-sieve.md +520 -0
  44. package/docs/theory/09-temporal-emergence.md +298 -0
  45. package/docs/theory/10-quaternionic-memory.md +415 -0
  46. package/docs/theory/README.md +162 -0
  47. package/engine/aleph.js +418 -0
  48. package/engine/index.js +7 -0
  49. package/index.js +23 -0
  50. package/modular.js +254 -0
  51. package/package.json +99 -0
  52. package/physics/collapse.js +95 -0
  53. package/physics/entropy.js +88 -0
  54. package/physics/index.js +65 -0
  55. package/physics/kuramoto.js +91 -0
  56. package/physics/lyapunov.js +80 -0
  57. package/physics/oscillator.js +95 -0
  58. package/types/index.d.ts +575 -0
@@ -0,0 +1,293 @@
1
+ # TinyAleph Examples Plan
2
+
3
+ ## Overview
4
+
5
+ This document outlines a comprehensive set of examples demonstrating all major features of the TinyAleph library. Examples are organized by complexity (beginner → advanced) and by domain.
6
+
7
+ ---
8
+
9
+ ## Example Categories
10
+
11
+ ### 1. Quickstart Examples
12
+ Simple, copy-paste examples to get users started immediately.
13
+
14
+ | Example | File | Description |
15
+ |---------|------|-------------|
16
+ | Hello World | `01-hello-world.js` | Minimal example: encode text, get semantic state |
17
+ | Basic Hashing | `02-basic-hash.js` | Hash a password/message in 3 lines |
18
+ | Quantum Coin Flip | `03-quantum-coin.js` | Create superposition, measure, see randomness |
19
+
20
+ ### 2. Semantic Computing Examples
21
+ Natural language processing and concept mapping.
22
+
23
+ | Example | File | Description |
24
+ |---------|------|-------------|
25
+ | Vocabulary Building | `semantic/01-vocabulary.js` | Define words with prime signatures, build ontology |
26
+ | Sentence Comparison | `semantic/02-similarity.js` | Compare two sentences for semantic similarity |
27
+ | Non-Commutativity | `semantic/03-word-order.js` | Show "dog bites man" ≠ "man bites dog" |
28
+ | DNA Encoding | `semantic/04-dna-processing.js` | Use bidirectional, codons, 6-frame analysis |
29
+ | Register Translation | `semantic/05-registers.js` | Same meaning in formal/casual/poetic styles |
30
+ | Concept Clustering | `semantic/06-clustering.js` | Group related concepts by prime signature |
31
+ | Text Classification | `semantic/07-classifier.js` | Simple sentiment/topic classifier |
32
+ | Question Answering | `semantic/08-qa-system.js` | Build a simple QA system with transforms |
33
+
34
+ ### 3. Cryptographic Examples
35
+ Security-focused applications.
36
+
37
+ | Example | File | Description |
38
+ |---------|------|-------------|
39
+ | Secure Password Hashing | `crypto/01-password-hash.js` | Hash and verify passwords safely |
40
+ | Key Derivation | `crypto/02-key-derivation.js` | PBKDF-like key stretching |
41
+ | Message Authentication | `crypto/03-hmac.js` | Sign and verify messages with HMAC |
42
+ | Commitment Scheme | `crypto/04-commitment.js` | Commit-reveal protocol |
43
+ | Content Addressing | `crypto/05-content-hash.js` | Content-addressable storage like IPFS |
44
+
45
+ ### 4. Scientific Computing Examples
46
+ Physics simulations and quantum computing.
47
+
48
+ | Example | File | Description |
49
+ |---------|------|-------------|
50
+ | Single Qubit Gates | `scientific/01-single-qubit.js` | X, Y, Z, H gates on |0⟩ and |1⟩ |
51
+ | Two Qubit Gates | `scientific/02-two-qubit.js` | CNOT, SWAP, entanglement |
52
+ | Bell States | `scientific/03-bell-states.js` | Create and measure all 4 Bell states |
53
+ | Quantum Random Number | `scientific/04-quantum-rng.js` | True random via quantum measurement |
54
+ | Grover's Search | `scientific/05-grover-search.js` | Simplified Grover's algorithm |
55
+ | Particle Physics | `scientific/06-particles.js` | Model particle interactions |
56
+ | Wave Function Collapse | `scientific/07-wavefunction.js` | Visualize collapse dynamics |
57
+
58
+ ### 5. Hypercomplex Math Examples
59
+ Low-level mathematical operations.
60
+
61
+ | Example | File | Description |
62
+ |---------|------|-------------|
63
+ | Quaternion Rotations | `math/01-quaternions.js` | 3D rotations with quaternions |
64
+ | Octonion Multiplication | `math/02-octonions.js` | Explore non-associativity |
65
+ | Zero Divisors | `math/03-zero-divisors.js` | Find and visualize sedenion zero divisors |
66
+ | Prime Geometry | `math/04-prime-geometry.js` | Map primes to geometric structures |
67
+ | Gaussian Primes | `math/05-gaussian-primes.js` | Visualize Gaussian integer primes |
68
+
69
+ ### 6. Physics Engine Examples
70
+ Oscillator dynamics and stability analysis.
71
+
72
+ | Example | File | Description |
73
+ |---------|------|-------------|
74
+ | Simple Oscillator | `physics/01-oscillator.js` | Single oscillator dynamics |
75
+ | Coupled Oscillators | `physics/02-kuramoto.js` | Kuramoto synchronization |
76
+ | Phase Transitions | `physics/03-phase-transition.js` | Order parameter emergence |
77
+ | Lyapunov Analysis | `physics/04-lyapunov.js` | Stability classification |
78
+ | Entropy Evolution | `physics/05-entropy.js` | Track entropy over time |
79
+
80
+ ### 7. Application Examples
81
+ Complete mini-applications.
82
+
83
+ | Example | File | Description |
84
+ |---------|------|-------------|
85
+ | Semantic Search Engine | `apps/01-search-engine.js` | Search documents by meaning |
86
+ | Chatbot | `apps/02-chatbot.js` | Simple conversational agent |
87
+ | Content Deduplication | `apps/03-deduplication.js` | Find similar/duplicate content |
88
+ | Password Manager Core | `apps/04-password-manager.js` | Key derivation for password vault |
89
+ | Ontology Explorer | `apps/05-ontology-explorer.js` | Interactive ontology browser |
90
+ | Quantum Simulator CLI | `apps/06-quantum-cli.js` | Command-line quantum circuit tool |
91
+
92
+ ### 8. AI & Machine Learning Examples
93
+ Using TinyAleph for AI applications.
94
+
95
+ | Example | File | Description |
96
+ |---------|------|-------------|
97
+ | Prime Embeddings | `ai/01-embeddings.js` | Generate embeddings for text/concepts |
98
+ | Semantic Memory | `ai/02-semantic-memory.js` | Long-term memory for AI agents |
99
+ | Reasoning Chain | `ai/03-reasoning.js` | Multi-step inference with transforms |
100
+ | Knowledge Graph | `ai/04-knowledge-graph.js` | Build and query prime-based KG |
101
+ | LLM Integration | `ai/05-llm-integration.js` | Combine TinyAleph with LLM APIs |
102
+ | Agent Architecture | `ai/06-agent.js` | Simple reasoning agent |
103
+ | Symbolic + Neural | `ai/07-hybrid-ai.js` | Combine symbolic primes with embeddings |
104
+ | Entropy-Based Reasoning | `ai/08-entropy-reasoning.js` | Use entropy minimization for inference |
105
+ | Concept Learning | `ai/09-concept-learning.js` | Learn new concepts from examples |
106
+ | Prompt Engineering | `ai/10-prompt-primes.js` | Prime-based prompt construction |
107
+ | RAG with Primes | `ai/11-rag.js` | Retrieval augmented generation |
108
+ | Neural-Symbolic Bridge | `ai/12-neuro-symbolic.js` | Map neural embeddings to primes |
109
+
110
+ ### 9. Advanced Examples
111
+ Deep dives into specific features.
112
+
113
+ | Example | File | Description |
114
+ |---------|------|-------------|
115
+ | Custom Backend | `advanced/01-custom-backend.js` | Implement your own backend |
116
+ | Transform Engine | `advanced/02-transforms.js` | Build reasoning with transforms |
117
+ | Field-Based Computing | `advanced/03-field-computing.js` | Oscillator-based answer emergence |
118
+ | Hybrid Pipelines | `advanced/04-hybrid-pipeline.js` | Combine multiple backends |
119
+ | Training Loop | `advanced/05-training.js` | Learn new vocabulary from data |
120
+
121
+ ---
122
+
123
+ ## Implementation Plan
124
+
125
+ ### Phase 1: Quickstart (3 files)
126
+ Essential examples for immediate productivity.
127
+
128
+ ### Phase 2: Core Domains (24 files)
129
+ - Semantic: 8 examples
130
+ - Crypto: 5 examples
131
+ - Scientific: 7 examples
132
+ - Math: 5 examples
133
+
134
+ ### Phase 3: AI/ML (12 files)
135
+ - AI & ML applications that showcase TinyAleph's unique strengths
136
+
137
+ ### Phase 4: Physics & Apps (11 files)
138
+ - Physics: 5 examples
139
+ - Applications: 6 examples
140
+
141
+ ### Phase 5: Advanced (5 files)
142
+ Deep customization and extension patterns.
143
+
144
+ ---
145
+
146
+ ## Example Template
147
+
148
+ Each example should follow this structure:
149
+
150
+ ```javascript
151
+ /**
152
+ * @example Example Name
153
+ * @description What this example demonstrates
154
+ * @requires Specific requirements if any
155
+ */
156
+
157
+ const { /* imports */ } = require('@aleph-ai/tinyaleph');
158
+
159
+ // ===========================================
160
+ // SETUP
161
+ // ===========================================
162
+ // Configuration and initialization
163
+
164
+ // ===========================================
165
+ // EXAMPLE CODE
166
+ // ===========================================
167
+ // Main demonstration
168
+
169
+ // ===========================================
170
+ // OUTPUT
171
+ // ===========================================
172
+ // Show results
173
+
174
+ // ===========================================
175
+ // KEY TAKEAWAYS
176
+ // ===========================================
177
+ // Summarize what was learned
178
+ ```
179
+
180
+ ---
181
+
182
+ ## Directory Structure
183
+
184
+ ```
185
+ examples/
186
+ ├── README.md # Overview and index
187
+ ├── 01-hello-world.js # Quickstart
188
+ ├── 02-basic-hash.js
189
+ ├── 03-quantum-coin.js
190
+
191
+ ├── semantic/
192
+ │ ├── README.md
193
+ │ ├── 01-vocabulary.js
194
+ │ ├── 02-similarity.js
195
+ │ ├── 03-word-order.js
196
+ │ ├── 04-dna-processing.js
197
+ │ ├── 05-registers.js
198
+ │ ├── 06-clustering.js
199
+ │ ├── 07-classifier.js
200
+ │ └── 08-qa-system.js
201
+
202
+ ├── crypto/
203
+ │ ├── README.md
204
+ │ ├── 01-password-hash.js
205
+ │ ├── 02-key-derivation.js
206
+ │ ├── 03-hmac.js
207
+ │ ├── 04-commitment.js
208
+ │ └── 05-content-hash.js
209
+
210
+ ├── scientific/
211
+ │ ├── README.md
212
+ │ ├── 01-single-qubit.js
213
+ │ ├── 02-two-qubit.js
214
+ │ ├── 03-bell-states.js
215
+ │ ├── 04-quantum-rng.js
216
+ │ ├── 05-grover-search.js
217
+ │ ├── 06-particles.js
218
+ │ └── 07-wavefunction.js
219
+
220
+ ├── math/
221
+ │ ├── README.md
222
+ │ ├── 01-quaternions.js
223
+ │ ├── 02-octonions.js
224
+ │ ├── 03-zero-divisors.js
225
+ │ ├── 04-prime-geometry.js
226
+ │ └── 05-gaussian-primes.js
227
+
228
+ ├── physics/
229
+ │ ├── README.md
230
+ │ ├── 01-oscillator.js
231
+ │ ├── 02-kuramoto.js
232
+ │ ├── 03-phase-transition.js
233
+ │ ├── 04-lyapunov.js
234
+ │ └── 05-entropy.js
235
+
236
+ ├── apps/
237
+ │ ├── README.md
238
+ │ ├── 01-search-engine.js
239
+ │ ├── 02-chatbot.js
240
+ │ ├── 03-deduplication.js
241
+ │ ├── 04-password-manager.js
242
+ │ ├── 05-ontology-explorer.js
243
+ │ └── 06-quantum-cli.js
244
+
245
+ ├── ai/
246
+ │ ├── README.md
247
+ │ ├── 01-embeddings.js
248
+ │ ├── 02-semantic-memory.js
249
+ │ ├── 03-reasoning.js
250
+ │ ├── 04-knowledge-graph.js
251
+ │ ├── 05-llm-integration.js
252
+ │ ├── 06-agent.js
253
+ │ ├── 07-hybrid-ai.js
254
+ │ ├── 08-entropy-reasoning.js
255
+ │ ├── 09-concept-learning.js
256
+ │ ├── 10-prompt-primes.js
257
+ │ ├── 11-rag.js
258
+ │ └── 12-neuro-symbolic.js
259
+
260
+ └── advanced/
261
+ ├── README.md
262
+ ├── 01-custom-backend.js
263
+ ├── 02-transforms.js
264
+ ├── 03-field-computing.js
265
+ ├── 04-hybrid-pipeline.js
266
+ └── 05-training.js
267
+ ```
268
+
269
+ ---
270
+
271
+ ## Success Criteria
272
+
273
+ Each example must:
274
+ 1. Run without errors (`node examples/path/to/example.js`)
275
+ 2. Produce visible, understandable output
276
+ 3. Include comments explaining the "why"
277
+ 4. Be self-contained (no external dependencies beyond TinyAleph)
278
+ 5. Be under 150 lines of code
279
+ 6. Include a "Key Takeaways" section
280
+
281
+ ---
282
+
283
+ ## Priority Order for Implementation
284
+
285
+ 1. **Quickstart examples** (highest impact for new users)
286
+ 2. **AI examples** (high demand - embeddings, memory, reasoning)
287
+ 3. **Semantic examples** (core use case)
288
+ 4. **Crypto examples** (practical utility)
289
+ 5. **Scientific examples** (unique differentiator)
290
+ 6. **Math examples** (educational value)
291
+ 7. **Physics examples** (advanced understanding)
292
+ 8. **Application examples** (real-world patterns)
293
+ 9. **Advanced examples** (power users)
package/docs/README.md ADDED
@@ -0,0 +1,159 @@
1
+ # Aleph Documentation
2
+
3
+ **Aleph** (TinyAleph) is a semantic computing framework that uses prime numbers and hypercomplex algebra to represent and manipulate meaning. Unlike traditional computers that operate on bits, Aleph operates on *concepts* - using the mathematical structure of prime numbers to encode semantic content and physical dynamics to perform reasoning.
4
+
5
+ ## Documentation Structure
6
+
7
+ This documentation is organized into three parts:
8
+
9
+ ### [Part I: Theory](./theory/README.md)
10
+ Deep exploration of the theoretical foundations:
11
+ - **Prime Semantics** - How prime numbers encode meaning
12
+ - **Hypercomplex Algebra** - The Cayley-Dickson construction and sedenions
13
+ - **Phase Synchronization** - Kuramoto oscillator dynamics
14
+ - **Entropy Minimization** - Reasoning as entropy reduction
15
+ - **Non-Commutativity** - Why word order matters
16
+ - **Two-Layer Meaning** - Prime substrate vs. surface vocabulary
17
+
18
+ ### [Part II: Guide](./guide/README.md)
19
+ Practical application of Aleph:
20
+ - **Quick Start** - Get running in 5 minutes
21
+ - **Semantic Computing** - Natural language understanding
22
+ - **Cryptographic Applications** - Hashing and key derivation
23
+ - **Scientific Computing** - Quantum simulation
24
+ - **LLM Integration** - Coupling with language models
25
+ - **Advanced Techniques** - Power user guide
26
+
27
+ ### [Part III: Reference](./reference/README.md)
28
+ Complete API documentation:
29
+ - **Core Module** - Hypercomplex algebra and prime utilities
30
+ - **Physics Module** - Oscillators, entropy, stability
31
+ - **Backends** - Semantic, Cryptographic, Scientific
32
+ - **Engine** - The unified AlephEngine
33
+
34
+ ---
35
+
36
+ ## Quick Overview
37
+
38
+ ### What is Semantic Computing?
39
+
40
+ Traditional computing manipulates symbols according to formal rules. Semantic computing manipulates *meaning* according to mathematical structure.
41
+
42
+ ```javascript
43
+ const { createEngine } = require('./modular');
44
+
45
+ // Create a semantic engine
46
+ const engine = createEngine('semantic', require('./data.json'));
47
+
48
+ // Process natural language
49
+ const result = engine.run('What is the nature of truth?');
50
+ console.log(result.output); // Semantic response
51
+ console.log(result.entropy); // Information-theoretic measure
52
+ console.log(result.coherence); // Phase synchronization measure
53
+ ```
54
+
55
+ ### The Core Insight
56
+
57
+ **Meaning has mathematical structure.** Just as:
58
+ - Numbers can be uniquely factored into primes
59
+ - Rotations can be composed in higher dimensions
60
+ - Oscillators can synchronize through coupling
61
+
62
+ So too can concepts be:
63
+ - Decomposed into semantic primes
64
+ - Composed in hypercomplex space
65
+ - Synchronized through semantic resonance
66
+
67
+ ### Key Features
68
+
69
+ | Feature | Description |
70
+ |---------|-------------|
71
+ | **Prime Encoding** | Concepts as unique prime signatures |
72
+ | **Hypercomplex States** | 16D sedenion algebra for meaning vectors |
73
+ | **Kuramoto Dynamics** | Phase synchronization for coherence |
74
+ | **Entropy Minimization** | Reasoning as entropy reduction |
75
+ | **Multiple Backends** | Semantic, Cryptographic, Scientific |
76
+ | **LLM Integration** | Couple with language models |
77
+
78
+ ---
79
+
80
+ ## Installation
81
+
82
+ ```bash
83
+ # Clone the repository
84
+ git clone https://github.com/your-repo/tinyaleph.git
85
+ cd tinyaleph
86
+
87
+ # Install dependencies
88
+ npm install
89
+ ```
90
+
91
+ ## Basic Usage
92
+
93
+ ```javascript
94
+ const { createEngine, SemanticBackend } = require('./modular');
95
+
96
+ // Load configuration
97
+ const config = require('./data.json');
98
+
99
+ // Create engine with semantic backend
100
+ const engine = createEngine('semantic', config);
101
+
102
+ // Run a query
103
+ const result = engine.run('love and wisdom');
104
+
105
+ console.log({
106
+ input: result.input,
107
+ output: result.output,
108
+ entropy: result.entropy.toFixed(3),
109
+ coherence: result.coherence.toFixed(3),
110
+ stability: result.stability
111
+ });
112
+ ```
113
+
114
+ ## Architecture
115
+
116
+ ```
117
+ ┌─────────────────────────────────────────────────────────────┐
118
+ │ INPUT │
119
+ │ (text, data, qubits) │
120
+ └─────────────────────────────────────────────────────────────┘
121
+
122
+
123
+ ┌─────────────────────────────────────────────────────────────┐
124
+ │ BACKEND │
125
+ │ (Semantic / Cryptographic / Scientific) │
126
+ │ │
127
+ │ encode(input) → primes decode(primes) → output │
128
+ │ primesToState(primes) → hypercomplex │
129
+ │ applyTransform(primes, transform) → primes │
130
+ └─────────────────────────────────────────────────────────────┘
131
+
132
+
133
+ ┌─────────────────────────────────────────────────────────────┐
134
+ │ ALEPH ENGINE │
135
+ │ │
136
+ │ Kuramoto Oscillators ←→ Hypercomplex State │
137
+ │ │ │ │
138
+ │ ▼ ▼ │
139
+ │ Phase Dynamics Entropy Tracking │
140
+ │ Lyapunov Stability Coherence Measurement │
141
+ │ Adaptive Coupling Collapse Detection │
142
+ └─────────────────────────────────────────────────────────────┘
143
+
144
+
145
+ ┌─────────────────────────────────────────────────────────────┐
146
+ │ OUTPUT │
147
+ │ { result, primes, entropy, coherence, collapsed } │
148
+ └─────────────────────────────────────────────────────────────┘
149
+ ```
150
+
151
+ ---
152
+
153
+ ## License
154
+
155
+ MIT License
156
+
157
+ ## Contributing
158
+
159
+ Contributions are welcome! Please read the documentation thoroughly to understand the theoretical foundations before proposing changes.