This document provides a comprehensive overview of OpenCog Hyperon, the cognitive architecture that underlies MeTTa and serves as the foundation for MeTTaIL's semantic type checking capabilities.
Source: Goertzel et al. "OpenCog Hyperon: A Framework for AGI at the Human Level and Beyond" (2023)
OpenCog Hyperon is an open-source framework designed for Artificial General Intelligence (AGI). Unlike narrow AI systems optimized for specific tasks, Hyperon provides a flexible infrastructure where multiple AI paradigms can cooperate and share knowledge through a unified representation.
The Hyperon architecture consists of layered components:
┌─────────────────────────────────────────────────────────────────┐
│ AI Agents │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
│ │ GOFAI │ │ Neural │ │ Evol. │ │ Prob. │ │
│ │ Logic │ │ Nets │ │ Algo. │ │ Graphs │ │
│ └────┬────┘ └────┬────┘ └────┬────┘ └────┬────┘ │
│ │ │ │ │ │
│ └────────────┴────────────┴────────────┘ │
│ │ │
│ ┌──────────▼──────────┐ │
│ │ MeTTa │ ← Programming Language │
│ │ (Meta Type Talk) │ │
│ └──────────┬──────────┘ │
│ │ │
│ ┌──────────▼──────────┐ │
│ │ Atomspace │ ← Metagraph Knowledge │
│ │ (Atomese Core) │ Store │
│ └──────────┬──────────┘ │
│ │ │
│ ┌──────────▼──────────┐ │
│ │ Distributed AS │ ← Scalable Storage │
│ │ (DAS) │ │
│ └──────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
| Layer | Component | Purpose |
|---|---|---|
| Top | AI Agents | Domain-specific algorithms |
| Middle | MeTTa | Programming language interface |
| Core | Atomspace | Knowledge representation & manipulation |
| Base | DAS | Distributed storage & retrieval |
The Atomspace is a metagraph data structure that stores all knowledge in Hyperon. Unlike traditional graphs, metagraphs allow edges to connect to other edges, enabling higher-order relationships.
A metagraph M = (V, E) where:
E \subseteq P(V \cup E) \times P(V \cup E)$ is a set of hyperedges that can connect vertices or other edgesAtomspace:
(Inheritance "cat" "animal")
(Evaluation "has-property"
(List "cat" "furry"))
(TypedAtom
(: "add" (-> Number Number Number)))
MeTTa uses exactly four fundamental atom meta-types. Every atom in the system is classified as one of these:
A named constant representing an identifier or value.
; Symbols
foo ; Named identifier
+ ; Operator symbol
Type ; Type name
"string" ; String literal (also a symbol)
Properties:
A placeholder for pattern matching and unification.
; Variables (prefixed with $)
$x ; Simple variable
$pattern ; Named pattern variable
$_ ; Anonymous/wildcard variable
Properties:
An ordered list of atoms (can contain any meta-type).
; Expressions (parenthesized lists)
(+ 1 2) ; Function application
(: x Int) ; Type annotation
(= (f $x) (g $x $x)) ; Equality declaration
(if $cond $then $else) ; Control flow
Properties:
Foreign data or functions from the host language (Rust, Python, etc.).
; Grounded atoms (opaque to MeTTa)
<Rust::HashMap> ; External data structure
<Python::numpy.array> ; Foreign array
<fn:add-integers> ; External function
Properties:
Atom
│
┌─────────────┼─────────────┐
│ │ │
▼ ▼ ▼
┌───────┐ ┌───────────┐ ┌──────────┐
│Symbol │ │Expression │ │ Grounded │
└───────┘ └───────────┘ └──────────┘
│
▼
┌───────┐
│Variable│
└───────┘
Atomese 2 (MeTTa's underlying representation) employs a two-layer type architecture designed for maximum flexibility:
The generic core provides minimal type infrastructure:
; Type declaration syntax
(: expr TypeName)
; Examples
(: 42 Number)
(: "hello" String)
(: add (-> Number Number Number))
Core Features:
Domain-specific type systems built atop the core:
; Example: Linear type system for resource tracking
(: LinearType Type)
(: consume (-> (Linear $a) Unit))
; Example: Dependent types for refinement
(: Vector (-> Type Nat Type))
(: zeros (-> (n : Nat) (Vector Int n)))
Specialized Systems:
"We designed Atomese 2 with two separate layers: a generic core, plus one or more specific type systems that define their own notions of 'type' and their own checking/inference algorithms."
— OpenCog Hyperon Paper
This separation enables:
Pattern matching is the fundamental operation in MeTTa. All computation proceeds via matching patterns against the Atomspace.
; Knowledge base
(parent Alice Bob)
(parent Bob Carol)
; Query pattern (returns all matches)
!(match &self (parent $x $y) ($x $y))
; Result: ((Alice Bob) (Bob Carol))
Pattern matching implements unification with occurs check:
match(pattern, target) → BindingsSet
Where BindingsSet = { σ₁, σ₂, ... } and each σᵢ : Var → Atom
Algorithm Properties:
\sigma(\text{pattern})$ = target for all $\sigma$ in resultComputation proceeds via conditional rewriting:
; Define rewrite rule
(= (factorial 0) 1)
(= (factorial $n)
(* $n (factorial (- $n 1))))
; Evaluate (triggers rewrites)
!(factorial 5)
; Result: 120
From Meta-MeTTa, the core operations are:
| Operation | Purpose |
|---|---|
eval | Evaluate expression |
evalc | Conditional evaluation |
chain | Sequential composition |
function/return | Functional abstraction |
unify | Pattern unification |
cons-atom/decons-atom | List construction |
collapse-bind/superpose-bind | Nondeterminism |
MeTTa supports gradual typing, allowing typed and untyped code to coexist.
; Fully typed
(: add (-> Int Int Int))
(= (add $x $y) (+ $x $y))
; Untyped (dynamically checked)
(= (flexible-add $x $y) (+ $x $y))
; Mixed (type at boundary)
(= (safe-add $x $y)
(if (and (is-int $x) (is-int $y))
(add $x $y)
(Error "Type mismatch")))
Via the Curry-Howard correspondence, gradual types map to paraconsistent logic — a logic that tolerates contradictions without explosion:
Gradual Type System ↔ Paraconsistent Logic
│ │
Type errors Contradictions
are localized don't propagate
Implications:
The Distributed Atomspace (DAS) enables Hyperon to scale across machines.
┌─────────────────────────────────────────────────────────────────┐
│ Distributed Atomspace │
├─────────────────────────────────────────────────────────────────┤
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Node 1 │ │ Node 2 │ │ Node 3 │ │
│ │ ┌─────────┐ │ │ ┌─────────┐ │ │ ┌─────────┐ │ │
│ │ │Local AS │ │ │ │Local AS │ │ │ │Local AS │ │ │
│ │ └────┬────┘ │ │ └────┬────┘ │ │ └────┬────┘ │ │
│ │ │ │ │ │ │ │ │ │ │
│ │ ┌────▼────┐ │ │ ┌────▼────┐ │ │ ┌────▼────┐ │ │
│ │ │ Cache │ │ │ │ Cache │ │ │ │ Cache │ │ │
│ │ └────┬────┘ │ │ └────┬────┘ │ │ └────┬────┘ │ │
│ └──────┼──────┘ └──────┼──────┘ └──────┼──────┘ │
│ │ │ │ │
│ └────────────────┼────────────────┘ │
│ │ │
│ ┌────────▼────────┐ │
│ │ Query Router │ │
│ └────────┬────────┘ │
│ │ │
│ ┌────────▼────────┐ │
│ │ Index Layer │ │
│ │ (MongoDB/Redis) │ │
│ └─────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
Pattern queries are distributed using:
Hyperon's architecture enables cognitive synergy — multiple AI paradigms cooperating through shared knowledge.
| Paradigm | Atomspace Representation | Interaction Mode |
|---|---|---|
| Symbolic AI | Logic atoms, rules | Direct manipulation |
| Neural Networks | Weight atoms, activations | Grounded atoms |
| Evolutionary | Population atoms | Mutation operators |
| Probabilistic | Truth values, distributions | Inference atoms |
; Neural network suggests candidates
(neural-suggest "image-features" $candidates)
; Symbolic reasoning filters
(logical-filter $candidates
(satisfies safety-constraint))
; Evolutionary search optimizes
(evolve-solution $filtered
fitness-function
100) ; generations
The OpenCog Hyperon architecture directly informs MeTTaIL's design:
| Hyperon Concept | MeTTaIL Mapping |
|---|---|
| Two-layer types | Basic sorts + OSLF predicates |
| Gradual typing | Optional behavioral annotations |
| Metagraph | Theory categories |
| Pattern matching | Predicate evaluation |
The two-layer type system from Atomese 2 validates MeTTaIL's approach:
This alignment ensures MeTTaIL can serve as MeTTa's native type system while supporting advanced behavioral reasoning for Rholang integration.
OpenCog Hyperon provides:
These foundations directly support MeTTaIL's semantic type checking goals and provide the theoretical justification for the layered approach to behavioral types.
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |