12 interactive demos • 624 lines of MeTTa • Built on hyperon-experimental v0.2.10 (Rust) + PyPI hyperon
Live MeTTa REPL session: atoms, pattern matching, type queries.
MeTTa (Meta Type Talk) is the successor to OpenCog Classic's Atomese — an "Atomese 2" for the OpenCog Hyperon AGI architecture. It is a symbolic expression language with:
- Pattern matching as the core computation primitive
- Dependent types for expressing logical constraints
- Spaces for knowledge isolation and modularity
- Mutable state via state monads
- Grounded functions for host-language interop (Python, Rust)
- Rewriting rules for graph transformation and inference
- Non-determinism — queries return all matching results
Implemented in Rust by TrueAGI (hyperon-experimental) and available on PyPI.
pip install hyperon
./run.sh # Run all 12 demos in sequence
python run_demo.py # Annotated output with pass/fail
metta-py demo/01_symbols.metta # Single demo
python scripts/load_kb.py demo/03_taxonomy.metta # Interactive| # | File | Topic | Concepts | Lines |
|---|---|---|---|---|
| 1 | demo/01_symbols.metta |
Symbols & Matching | Atoms, variables, match, expression patterns |
35 |
| 2 | demo/02_combinators.metta |
Combinatory Logic | SKI combinators, Peano arithmetic, lists, recursion | 87 |
| 3 | demo/03_taxonomy.metta |
Taxonomy KB | Inheritance chains, property queries, multi-condition joins | 70 |
| 4 | demo/04_types.metta |
Type System | Type hierarchy, function types, GADTs, parametric types, functors | 66 |
| 5 | demo/05_grounded.metta |
Grounded Functions | Arithmetic, comparisons, string ops, type errors | 45 |
| 6 | demo/06_nondeterminism.metta |
Non-Determinism | collapse, superpose, HVAC controller (PLN example) |
66 |
| 7 | demo/07_state.metta |
State (Simple) | new-state, change-state!, bind!, counter |
40 |
| 8 | demo/08_state_agent.metta |
State Agent | Compound state, agent position/health, typed transitions | 65 |
| 9 | demo/09_reasoning.metta |
Reasoning | Socrates syllogism, family tree, recursive ancestor | 43 |
| 10 | demo/10_backchaining.metta |
Backward Chaining | Deduction, proof trees, Implication, explain |
68 |
| 11 | demo/11_spaces.metta |
Spaces | Multi-space queries, cross-condition joins | 49 |
| 12 | demo/12_truth_values.metta |
Truth Values | PLN stv, conjunction/implication TV rules, Fritz story |
67 |
| MeTTa Feature | Demo(s) | Lines of code |
|---|---|---|
match pattern matching |
1, 3, 9, 11 | ~20 |
= function definition |
2, 5, 6, 7, 8, 9, 10, 12 | ~60 |
(: ...) type declarations |
2, 4, 9 | ~30 |
get-type type inference |
4 | ~10 |
new-state / change-state! |
7, 8 | ~25 |
bind! token binding |
7, 8 | ~5 |
| GADT & parametric types | 4 | ~15 |
collapse / superpose |
6 | ~8 |
| Grounded arithmetic | 2, 5 | ~15 |
if conditionals |
5, 6, 12 | ~8 |
let bindings |
6, 7, 8 | ~10 |
assertEqual / println! |
4, 7, 8 | ~10 |
| Recursive functions | 2, 9 | ~15 |
| Backward chaining | 10 | ~30 |
| PLN-style truth values | 12 | ~40 |
Hyperon system architecture: Rust core, C API, Python bindings, REPL.
Data flow through the MeTTa interpreter pipeline.
Pattern matching pipeline: atom indexing → unification → result streaming.
metta-py (CLI / REPL) ← pip install hyperon
hyperon (Python lib) ← Python API
libhyperonpy (pybind11) ← C++/Python bridge
libhyperonc (C API) ← C bindings
hyperon-common / -atom / -space ← Rust crates
libhyperon (Rust core) ← interpreter, matcher, type system
| Component | Time | Command |
|---|---|---|
| Rust core | ~3 min | cargo build --release |
| C/Python API | ~3 min | cmake --build . |
| Docker | ~8 min | docker build -t trueagi/hyperon . |
| PyPI install | 5 sec | pip install hyperon |
See hyperon-experimental/README.md for full build instructions.
metta-demo/
├── README.md ← you are here
├── LICENSE Apache 2.0
├── .gitignore
├── run.sh Run all 12 demos (shell)
├── run_demo.py Annotated Python runner
├── scripts/
│ └── load_kb.py Interactive REPL on a loaded KB
├── assets/
│ ├── repl-demo.gif Animated REPL (2.4 MB)
│ ├── architecture.svg Hyperon architecture
│ ├── data-flow.svg Interpreter pipeline
│ └── query-pipeline.svg Pattern matching pipeline
└── demo/
├── 01_symbols.metta Symbols & pattern matching
├── 02_combinators.metta SKI combinators & Peano arithmetic
├── 03_taxonomy.metta Taxonomy knowledge base
├── 04_types.metta Type system & functors
├── 05_grounded.metta Grounded functions
├── 06_nondeterminism.metta Non-determinism & PLN HVAC
├── 07_state.metta Simple mutable state
├── 08_state_agent.metta Compound agent state
├── 09_reasoning.metta Syllogisms & family trees
├── 10_backchaining.metta Deduction & proof trees
├── 11_spaces.metta Spaces & cross-condition queries
└── 12_truth_values.metta PLN truth value propagation
| OpenCog Classic (Atomese) | MeTTa equivalent |
|---|---|
InheritanceLink (C "cat") (C "mammal") |
(Isa cat mammal) |
EvaluationLink (Predicate "fly") (ListLink (C "eagle")) |
(can-fly eagle True) |
GetLink ... / BindLink ... |
(match &self pattern result) |
(cog-evaluate! (Plus (Number 1) (Number 2))) |
!(+ 1 2) |
StateLink |
(new-state ...) / (change-state! ...) |
cog-execute! |
! prefix |
| Typed variables | (: name type) declarations |
(cog-count-atoms) |
No direct equivalent (use match + collapse) |
| Resource | Link |
|---|---|
| MeTTa Language | https://metta-lang.dev |
| hyperon-experimental (Rust) | https://github.com/trueagi-io/hyperon-experimental |
| hyperon (PyPI) | https://pypi.org/project/hyperon/ |
| MeTTa-WAM (Prolog) | https://github.com/trueagi-io/metta-wam |
| MeTTa Spec | https://wiki.opencog.org/w/File:MeTTa_Specification.pdf |
| Hyperon Docs | https://trueagi-io.github.io/hyperon-experimental |
| OpenCog Hyperon | https://opencog.org |
| OpenCog Classic Demo | https://github.com/NullLabTests/opencog-codespace-demo |
| Hyperon arXiv paper | https://arxiv.org/abs/2310.18318 |
git clone https://github.com/NullLabTests/metta-demo
cd metta-demo
pip install hyperon
vim demo/04_types.metta
metta-py demo/04_types.metta
./run.shApache 2.0 — see LICENSE. MeTTa runtime (hyperon-experimental) is MIT-licensed by SingularityNET / TrueAGI.
MeTTa-lang.dev · Hyperon · OpenCog.org · Classic Demo · Built with OpenCode