# Clone the repository git clone https://github.com/OutfinityResearch/AGISystem2.git cd AGISystem2 # Install dependencies npm install # Verify installation npm run eval
Running 364 tests across 27 suites... Configuration: metric(32)+symb Pass Rate: 100% (364/364) Time: 318ms
Create a file called tutorial.mjs:
import { Session } from './src/session.mjs'; // Create a new reasoning session const session = new Session(); // Add some facts about animals session.learn('isA Tom Cat'); session.learn('isA Cat Mammal'); session.learn('isA Mammal Animal'); // Query: Is Tom an animal? const result = session.query('isA Tom Animal'); console.log('Is Tom an animal?', result.success); // Output: Is Tom an animal? true console.log('Proof:', result.proof); // Output: Proof steps showing the transitive chain
# Run it
node tutorial.mjs
import { Session } from './src/session.mjs'; const session = new Session(); // Define a rule: All mammals are warm-blooded session.learn('@ant isA ?x Mammal'); session.learn('@cons hasProperty ?x warm_blooded'); session.learn('Implies $ant $cons'); // Add facts session.learn('isA Dog Mammal'); session.learn('isA Fido Dog'); // Query: Is Fido warm-blooded? const result = session.query('hasProperty Fido warm_blooded'); console.log('Is Fido warm-blooded?', result.success); // Output: Is Fido warm-blooded? true
import { Session } from './src/session.mjs'; import { translateContextWithGrammar } from './src/nlp/nl2dsl/grammar.mjs'; // Natural language context const text = ` All cats are mammals. All mammals are animals. Tom is a cat. Jerry is a mouse. Mice are animals. `; // Translate to DSL const { dsl, errors } = translateContextWithGrammar(text, { autoDeclareUnknownOperators: true }); console.log('Generated DSL:'); console.log(dsl); // Load into session const session = new Session(); for (const line of dsl.split('\n')) { if (line.trim()) session.learn(line); } // Query console.log('Is Tom an animal?', session.query('isA Tom Animal').success); console.log('Is Jerry an animal?', session.query('isA Jerry Animal').success);
AGISystem2 supports five HDC strategies. Set via environment variables:
# Metric-Affine (fastest, recommended) SYS2_HDC_STRATEGY=metric-affine SYS2_GEOMETRY=32 node tutorial.mjs # Metric-Affine Elastic (large KBs) SYS2_HDC_STRATEGY=metric-affine-elastic SYS2_GEOMETRY=32 node tutorial.mjs # Dense-Binary (standard VSA) SYS2_HDC_STRATEGY=dense-binary SYS2_GEOMETRY=256 node tutorial.mjs # Sparse-Polynomial (memory efficient) SYS2_HDC_STRATEGY=sparse-polynomial SYS2_GEOMETRY=4 node tutorial.mjs # EXACT (lossless, session-local atom IDs) SYS2_HDC_STRATEGY=exact SYS2_GEOMETRY=256 node tutorial.mjs
| Strategy | Best For | Speed |
|---|---|---|
| metric-affine | Production, fastest performance | 318ms (2.6x faster) |
| metric-affine-elastic | Large KBs, stable bundling | Similar to metric-affine |
| dense-binary | Standard HDC, similarity search | 456ms |
| sparse-polynomial | Memory-constrained environments | 349ms (k=2) |
| exact | Lossless experiments, saturation studies | Varies (BigInt/KB dependent) |
# Run core theory tests (364 tests, 27 suites) npm run eval # Run with all 16 configurations (includes EMA) npm run eval -- --full # Run stress tests node evals/runStressCheck.js # Run external benchmarks node autoDiscovery/bugsAutoDiscovery.mjs --source=prontoqa --batch=20
| DSL Statement | Meaning |
|---|---|
| isA Tom Cat | Tom is a Cat |
| hasProperty Ball red | Ball has property red |
| loves John Mary | John loves Mary |
| @ref isA ?x Cat | Named reference with variable |
| Implies $ant $cons | If $ant then $cons |
| Not (isA Tom Dog) | Tom is not a Dog |
| And $a $b $c | Conjunction of conditions |