Liking cljdoc? Tell your friends :D

MeTTaIL: Semantic Type Checking for MeTTa

This documentation provides a rigorous, pedagogical treatment of semantic type checking for MeTTa using MeTTaIL. It synthesizes insights from four foundational papers and two prototype implementations to answer the question:

Can MeTTaIL be used for semantic type checking?

Answer: Yes, with qualifications. MeTTaIL provides foundational capabilities for semantic type checking, but realizing the full vision requires implementing Native Type Theory (OSLF) as described in the Williams & Stay paper.


Executive Summary

MeTTa's operational semantics (Meta-MeTTa paper, 2023) explicitly recommends OSLF for deriving "a type system for MeTTa that includes spatial and behavioral types." This documentation series explains:

  1. What semantic type checking means for a rewriting language like MeTTa
  2. How OSLF (Native Type Theory) provides the mathematical foundation
  3. How Gph-enriched Lawvere theories offer a simpler alternative path
  4. How RHO calculus reflection enables nominal feature elimination
  5. What the current prototypes implement and what remains to be built

Three Levels of Semantic Type Checking

LevelApproachCapabilitiesStatus
BasicCurrent MeTTaILSort validation, constructor checkingDone
OperationalGph-enriched LawvereReduction semantics, evaluation control, resourcesMedium effort
FullOSLF/Native TypesBehavioral predicates, bisimulation, refined bindingHigh effort

Documentation Structure

Theoretical Foundations

These documents explain the mathematical foundations required to understand semantic type checking for MeTTa.

DocumentDescription
01-metta-operational-semantics.mdMeTTa as a state machine with rewrite rules
02-native-type-theory-oslf.mdThe 2-functor construction from λ-theories to type systems
03-gph-enriched-lawvere.mdSimpler semantics when binding is eliminated via reflection
04-rho-calculus.mdRholang's theoretical foundation and reflection mechanism
05-type-lifting.mdDeriving types from operational semantics via T(-) transformation
06-inference-rules.mdPractical guide to reading and implementing inference rules

Reading Order: Start with (01) for MeTTa background. For type derivation, read (05) and (06) next. Then either (02) for full OSLF theory or (03) for the simpler Gph-enriched approach. Document (04) explains how RHO calculus reflection bridges to Rholang.

Implementation

These documents describe the existing prototypes and the path forward.

DocumentDescription
01-mettail-scala-prototype.mdTheory definitions, hypercube transformation, BNFC generation
02-mettail-rust-prototype.mdCategory-based checking, rewrite engine, Ascent Datalog
03-rholang-integration.mdCurrent MeTTa-Rholang bridge via mettatron
04-implementation-roadmap.mdLayered approach to full semantic type checking

MeTTa Ecosystem

These documents describe the broader MeTTa ecosystem and implementation architectures.

DocumentDescription
01-opencog-hyperon.mdOpenCog Hyperon architecture, Atomspace, four meta-types
02-hyperon-experimental.mdOfficial MeTTa implementation details
03-mettatron.mdF1R3FLY.io's MeTTaTron compiler architecture
04-mork-pathmap-integration.mdMORK and PathMap storage layer integration

Correction WFST

These documents describe the unified three-tier correction WFST architecture that integrates liblevenshtein with MeTTaIL for semantic type-aware correction.

DocumentDescription
01-architecture-overview.mdThree-tier WFST architecture overview
02-tier1-lexical-correction.mdliblevenshtein edit distance and phonetic rules
03-tier2-syntactic-validation.mdCFG validation via MORK/PathMap
04-tier3-semantic-type-checking.mdMeTTaIL/MeTTaTron/Rholang semantic checking
05-data-flow.mdComplete data flow through the stack
06-integration-possibilities.mdCross-language, ASR, IDE integrations

Reference

Quick-reference materials and supporting documentation.

DocumentDescription
gap-analysis.mdWhat's missing for full OSLF implementation
use-cases.mdConcrete examples of semantic type checking
bibliography.mdComplete reference list with annotations

Key Insight: The Binding Decision

The choice between Gph-enriched Lawvere theories and full OSLF depends on one key question:

Can MeTTa's unification patterns be given a combinator representation?

  • If yes → Gph-theories suffice (simpler path)
  • If no → Full OSLF required (handles binding natively)

The RHO calculus paper demonstrates that reflection can eliminate nominal features, suggesting the simpler Gph-theory path is viable for MeTTa's reflective capabilities.


Recommended Reading Path

For Implementers

  1. 01-metta-operational-semantics - Understand the target
  2. 06-inference-rules - Learn to read type notation
  3. 05-type-lifting - Derive types from semantics
  4. 03-gph-enriched-lawvere - Simplest semantic model
  5. 04-implementation-roadmap - Concrete steps
  6. gap-analysis - What to build

For Theorists

  1. 02-native-type-theory-oslf - Full mathematical foundation
  2. 05-type-lifting - Type lifting transformation
  3. 04-rho-calculus - Reflection theory
  4. use-cases - Applications of behavioral types

For Project Managers

  1. This README - Overview
  2. 04-implementation-roadmap - Phases and dependencies
  3. gap-analysis - Scope of remaining work

For Correction/WFST Integration

  1. 01-architecture-overview - Three-tier architecture
  2. 02-tier1-lexical-correction - liblevenshtein integration
  3. 04-tier3-semantic-type-checking - MeTTaIL as semantic layer
  4. 05-data-flow - Complete pipeline

For MeTTa Ecosystem Understanding

  1. 01-opencog-hyperon - Theoretical foundations
  2. 02-hyperon-experimental - Reference implementation
  3. 03-mettatron - F1R3FLY.io compiler
  4. 04-mork-pathmap-integration - Storage layer

Source Materials

This documentation synthesizes:

Papers

  1. Meta-MeTTa: an operational semantics for MeTTa (Meredith et al., 2023)
  2. Native Type Theory (Williams & Stay, ACT 2021)
  3. Representing operational semantics with enriched Lawvere theories (Stay & Meredith, 2017)
  4. A Reflective Higher-order Calculus (Meredith & Radestock, ENTCS 2005)
  5. OpenCog Hyperon: A Framework for AGI (Goertzel et al., 2023)

Implementations

  • MeTTaIL Scala prototype (/home/dylon/Workspace/f1r3fly.io/MeTTaIL/)
  • mettail-rust prototype (/home/dylon/Workspace/f1r3fly.io/mettail-rust/)
  • Rholang f1r3node (/home/dylon/Workspace/f1r3fly.io/f1r3node/)
  • hyperon-experimental (/home/dylon/Workspace/f1r3fly.io/hyperon-experimental/)
  • MeTTaTron (/home/dylon/Workspace/f1r3fly.io/MeTTa-Compiler/)
  • MORK (/home/dylon/Workspace/f1r3fly.io/MORK/)
  • PathMap (/home/dylon/Workspace/f1r3fly.io/PathMap/)
  • liblevenshtein (/home/dylon/Workspace/f1r3fly.io/liblevenshtein-rust/)

Quick Reference: The OSLF 2-Functor

The core mathematical construction underlying full semantic type checking:

λ-theory  ──[P]──>  presheaf topos  ──[L]──>  type system
   T                    P(T)                   LP(T)

Where:

  • T = MeTTa formalized as a λ-theory with equality
  • P = Presheaf construction (preserves products, equality, function types)
  • L = Internal language functor (extracts the type theory)

This construction is native because types arise directly from the syntax, not imposed externally.


Notation Quick Reference

Common type-theoretic notation used throughout these documents:

SymbolNameMeaningExample
$\vdash$Turnstile"derives" or "proves"$\Gamma \vdash M : A$ means "$\Gamma$ proves M has type A"
$\Gamma$ContextType assumptions in scopex: Int, y: Bool
:Type ascription"has type"M : A means "M has type A"
Function typeFunctions from A to BA → B
×Product typePairs of A and BA × B
Possibility"possibly" (modal)◇A = "can become A"
T(-)Type liftingTransformation functionT(A → B) = T(A) × (T(A) → T(B))

For detailed explanations, see 06-inference-rules.md.

Can you improve this documentation?Edit on GitHub

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close