Home / Knowledge Representations / MORK / MORK Full
Responsible: Adam Vandervorst, Luke Peterson, Remy Clarke
Papers: Goertzel (2025), Hyperon Whitepaper §2.3, §3.6; Goertzel (2025), Articulating Conditions Where ZAM/MORK Yield Benefit: A Selectivity Theorem; Goertzel (2025), From Path Algebra in MORK to Tensor Logic on GPUs; Goertzel (2025), Slot-Centric Indexing vs. Permutation Explosion; Peyton Jones et al., Triemaps that Match (arXiv:2302.08775)
Status: Current. MORK is operational — the 8-crate Rust workspace compiles on nightly, with working triemap storage, Zipper Abstract Machine, bidirectional pattern matching, and MM2 execution. PeTTa/MORK integration handles 400M+ atoms in RAM (per AtomSpace cluster pilot 2026-04-29 reconciliation; earlier "500M" figure was wiki drift). MORK-native PLN, WILLIAM integration, and distributed multi-machine execution are under development. Note that PathMap is a sibling-repo dependency (separate codebase), not a MORK subcrate; the MORK server-branch is versioned independently of the main library.
This card provides technical depth beyond the concise MORK index card. MORK (MeTTa Optimal Reduction Kernel) is Hyperon's high-performance hypergraph engine — a specialized in-RAM processing kernel designed for large speedups over previous AtomSpace implementations. It provides the computational substrate on which PRIMUS's cognitive algorithms execute at scale.
Cluster-pilot context: The AtomSpace Backend Integration cluster pilot (closed 2026-04-29) locked in a four-layer taxonomy where MORK is Layer 4 — see the Architecture and Ecosystem and Status and Resources subcards below for the per-corner reconciled findings (8-crate workspace, server-branch separation, 400M atom RAM scaling, MorkDB link-delete blocker for primary-store promotion, weighted-atom-sweep reframed as adjacent experimental analogy not a strict-literal ECAN port).
Related cards: AtomSpace Full (abstract concept), DAS Full (distributed complement), PathMap (foundational trie substrate, sibling-repo dependency), PLN Full (chaining + factor graphs on MORK), ECAN Full (weighted atom sweeps), MORK Theory Publication Map
MORK's foundational data structure is a prefix-compressed triemap (radix tree) that stores S-expressions as paths. Where a traditional graph database scatters nodes and links across memory, MORK organizes them into a structured hierarchy where shared prefixes are stored once. This provides:
The execution model that exploits PathMap: given a query with one or more legs (rows of guarded reads), ZAM chooses selective path prefixes, fetches posting lists from the trie, computes intersections incrementally, and streams only the compatible frontier to the unifier. This pushes most pruning before unification. ZAM uses zippers (cursor-based navigation) for efficient, parallel logical inference with near-linear performance scaling across cores.
A low-level dataflow language for defining performance-critical components directly on MORK's data structures. MM2 uses a "Gather-Process-Scatter" paradigm with priority-based execution, sources (inputs), and sinks (outputs). The language is formally decomposed into four semantic segments: a monotonic base (metagraph rewrites where automatic pattern reordering is safe — enabling 1000× speedups without changing semantics), sinks (non-monotonic output operations), sources (input/data loading), and syncs (conjunctions of sources and sinks). Operations include fork/join patterns, set operations, and macro-based partial evaluation. MM2 is where PLN factor-graph message passing, ECAN attention sweeps, pattern mining iterations, and tensor operations run at database-engine speeds.
A declarative query language providing "bare metal" access to MORK's trie structures for structural manipulation using S-expression syntax. Think of it as SQL for MORK — whereas MM2 is for dynamic algorithms at scale.
The "MORK theory" paper provides a formal analysis of when ZAM/MORK yields substantial advantage. The selectivity exponent:
\[\gamma(p) = -\log_N\!\left(\frac{|P(p)|}{N}\right)\]For a \(k\)-leg join over prefixes \(p_1, \ldots, p_k\), under \(\varepsilon\)-independence assumptions:
Under a hierarchical generative model (tree-structured conditionals with exponential decay of prefix probabilities), even moderately deep bindings across a few legs push the selectivity sum past 1. Real-world AtomSpaces — logic proofs, program ASTs, semantic parses, knowledge graphs — are approximately hierarchical: symbols follow heavy-tailed distributions, structures are compositionally generated, and query legs bind weakly dependent positions.
Instead of \(k!\) permutations, MORK maintains at most \(k\) slot-centric prefix views — one per argument position — plus selectively promoted "hot" pair views. Key structure (binary relation):
R/_1/<EXPR_ID>/_2/<C_ID> → payloadR/_2/<C_ID>/_1/<EXPR_ID> → pointer to canonicalThe probabilistic break-even rule:
\[p_{s+1}(M - L) > \alpha\]Worked example: with \(p_1=0.4, p_2=0.6, L=1, M=50\), the flip view yields a 29.4× expected speedup for roughly 2× index entries. For hot multi-slot queries, the general problem is submodular coverage under a storage budget, solvable greedily. (Source: Goertzel 2025, MORK Slots)
MORK is an 8-member Rust workspace (verified at HEAD 4cef6f7 against MORK/Cargo.toml:3-12; nightly toolchain required for generators, coroutines, SIMD):
Foundational dependency: PathMap — sibling repo authored by Luke Peterson; declared at MORK/Cargo.toml:28-32 as ../PathMap/ with jemalloc, arena_compact, nightly features. PathMap is the low-level trie substrate (key-value store with prefix compression, structural sharing, algebraic operations); MORK's path-algebra and zipper machinery sit on top of it. See PathMap for substrate details.
Server branch: The mork-server deployment is maintained on a separate server branch, distinct from main. DAS pins MORK 578a759 (2025-07-21) via das/src/docker/mork/Dockerfile.server; local origin/server HEAD as of 2026-04-29 is 5b04a1d (2026-04-18), 49 commits ahead of the DAS pin with deadlock and UTF-8 fixes. See Status for drift detail.
mork_ffi/example_space.metta:13-17 documents successful 100M/200M/300M/400M loads; 500M ran out of memory at the same site). Earlier wiki text quoting "500M+ atoms in RAM" treated the OOM ceiling as demonstrated capacity — corrected.experiments/unification_test_laws/; (2) PeTTa runtime bridge via SWI-Prolog predicate mork/3 at mork_ffi/mork.c:33-36 + morkspaces.pl:7-32.MorkDB AtomDB backend (subclass of RedisMongoDB) that talks to a MORK HTTP server (server-branch deployment) and Mongo-side metadata. Link/S-expression delete is hard-failed at MorkDB.cc:268-270 ("MORKDB does not support deleting links") — DAS-as-MORK-backend is integration-ready for loads and queries, NOT a Decko-compatible mutable store. See DAS Full.MeTTaTron provides four special forms that bridge high-level MeTTa and low-level MORK execution. All use uniform conjunction semantics — the (,) wrapper makes result cardinality explicit and enables meta-programming:
exec (<priority> <antecedent> <consequent>) — Rule execution with conjunction antecedents. All antecedent goals must match (left-to-right, variable bindings threaded through). Consequents can be conjunction results or space-modifying Operations (O (+ fact) (- fact)). Priority determines execution order. Non-deterministic: multiple antecedent solutions produce multiple consequent evaluations.coalg (<pattern> <templates>) — Coalgebra patterns for tree transformations. Template conjunction cardinality determines result count: (,) = zero results (termination), (, t) = one result, (, t1 t2) = unfold to two. Enables hierarchical decomposition (e.g., tree → contexts → leaf values via lift/explode/drop stages).lookup (<pattern> <success-goals> <failure-goals>) — Conditional fact queries with branching. Variables bound during pattern match are available in the success branch. Nestable for priority chains.rulify ($name <pattern> <templates> <antecedent> <consequent>) — Meta-programming: generates exec rules from coalgebra definitions by pattern matching on template arity. Enables runtime rule generation from declarative specifications.The conjunction pattern provides ~36% parser code reduction, ~40% evaluator simplification, and ~80% fewer edge-case bugs, with negligible runtime overhead (~2 bytes per conjunction, ~10ns per goal evaluation).
(Provenance: repo-doc, MeTTa-Compiler MORK special forms documentation)
MORK/, PathMap/, mork_ffi/, mork-rust-sdk/, mork-ts-sdk/: 0 hits for FactorGraph/factor_graph/belief_propagation/pln/wmpln/lib_pln/AttentionBank/cog-av-sti).weighted-atom-sweep repo (HEAD 1471ff2c, 2026-03-03) is a separate adjacent experimental crate outside the canonical MORK 8-member workspace, depending on PathMap and MORK expr. Its AtomHeader is a generic trait — NOT an STI/LTI/TruthValue/AttentionValue — and its match counter is an integer, not an ECAN attention currency. The pattern (aggregate weight counters in trie nodes for importance-proportional sampling) is repurposable for recency/priority/card-version metadata if a Decko-specific AtomHeader and traversal policy are defined, but NOT a code-real ECAN bridge at this snapshot.4cef6f7; nightly toolchain required.../PathMap/ dep. See PathMap.mork-server at origin/server; DAS pin and image-tag reconciliation discussed at Status.CountSink in the kernel (MORK/kernel/src/sinks.rs:512-591) is an MM2 query/reduction primitive (per-execution accumulator), not a persistent revision log — do not target it as a Decko card-history counter.mork_ffi/example_space.metta:13-17: successful 100M/200M/300M/400M; 500M ran out of memory at the same site). Earlier "500M+ atoms in RAM" wiki text treated the OOM ceiling as demonstrated capacity — corrected.paths_export() / paths_import().!= or nested if/not/find instead.mork-server deployment line is maintained on a separate server branch. As of 2026-04-29, three references are not reconciled: das-toolbox CLI defaults to image tags trueagi/das:mork-server-1.0.5 + mork-loader-1.0.5; das/src/docker/mork/Dockerfile.server pins MORK commit 578a759 (2025-07-21); local origin/server HEAD is 5b04a1d (2026-04-18) — 49 commits ahead of the DAS pin with deadlock and UTF-8 fixes. Production deployment must reconcile all three references. Notable post-pin fixes in the gap: server shutdown deadlock (5b04a1d), user-status-map cleanup (08116b0), lock-held-too-long deadlock (205dd91), UTF-8 validation for symbol pathway (f284ff6), edge-case + malformed-symbol test coverage (7872975).das/src/atomdb/morkdb/MorkDB.cc:268-270 hard-fails. Node delete works (inherited from RedisMongoDB); link delete does not. flush_pattern + re_index_patterns provide batch-rebuild workarounds, NOT live mutable-store CRUD. See DAS Full.scripts/archive/atomspace_pilot/; Source 3 reconciliation is the canonical record for the corrections on this card.