MeTTa

1 program Added 2026-02-28T14:07:55Z Agent: claude-codeModel: claude-sonnet-4-6WebSearch: disabled Evidence Report issue View issues
Aliases: Meta Type Talk, Atomese 2
Provenance: commit 6855239d63 · authored 2026-02-28T15:08:25+01:00 · agent claude-code · model claude-sonnet-4-6

Sources mentioning this language

2 sources · pl_id: pl/metta
LLM (this repo) · 1Linguist

Extensions claimed by this language

1 claim. Each row is one upstream assertion with its strength. SWH column shows file occurrences with that extension across the entire archive.
ExtensionSourceStrengthSWH
.mettalinguistprimary5.5K files

Related languages

MetaTalk (0.18)Metalua (0.18)META II (0.14)META-II (0.14)ATS2 (0.13)

Real programs from Software Heritage

No SWH evidence indexed yet for this language. (Either the SWH mining hasn't reached this language's extensions, or no matching files exist in the archive.)

Programs collected by LLM agents experimental · unverified

Gathered by LLM agents during the experiment that started this catalogue. They are not verified: the agent names an origin, but a program can be altered or invented — an audit found one attributed to a file that does not exist, in a syntax the language does not have. Prefer the programs archived by Software Heritage above. The catalogue's goal is the languages themselves, grounded in sources (PLDB, Wikipedia, Rosetta Code, …), with real archived programs; these examples may be dropped.

Pattern Matching with Symbols

Provenance: commit 6855239d63 · authored 2026-02-28T15:08:25+01:00 · agent claude-code · model claude-sonnet-4-6 · WebSearch disabled
code.metta · license: MIT · added: 2026-02-28T14:07:55Z
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; `match` searches for all expressions corresponding to
; the given pattern and produces the output pattern.
; It doesn't search in subexpressions.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Some expressions to be matched
((leaf1 leaf2) leaf3)
(((leaf0 leaf1) leaf2) leaf3)
; This one contains `((leaf1 leaf2) leaf3)` as a subexpression
; and thus will not be matched
(top ((leaf1 leaf2) leaf3))
; `assertEqualToResult` checks all the results of the first
; expression; it doesn't evaluate the second expression,
; which is treated as a set of expected results.
!(assertEqualToResult
  (match &self (($x leaf2) leaf3) $x)
  (leaf1
   (leaf0 leaf1)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Symbols can be arranged in arbitrary expressions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(Sam is a frog)
(Tom is a cat)
(Sophia is a robot)
; `match` can bind more that one variable
!(assertEqualToResult
  (match &self ($who is a $what) ($who the $what))
  ((Sam the frog)
   (Tom the cat)
   (Sophia the robot)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; More examples of pattern matching
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; `:=` is a custom symbol. These are still purely symbolic expressions
(:= (Green Sam) T)
(:= (White Tom) T)
(:= (Green Tom) F)
!(assertEqualToResult
  (match &self (:= (Green $who) T) ($who is really green))
  ((Sam is really green)))
!(assertEqualToResult
  (match &self (:= ($color $who) T) ($who is really $color))
  ((Sam is really Green)
   (Tom is really White)))
!(assertEqualToResult
  (match &self (:= ($color $who) $tv) (It's $tv that $who is $color))
  ((It's T that Sam is Green)
   (It's T that Tom is White)
   (It's F that Tom is Green)))
; This type of query works as a sort of evaluation/reduction
!(assertEqualToResult
  (match &self (:= (Green Tom) $tv) $tv)
  (F))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; One more example
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(isa red color)
(isa green color)
(isa blue color)
!(assertEqualToResult
  (match &self (isa $color color) $color)
  (red green blue))

Contribute — propose a file extension

Tell us where to find evidence about MeTTa (mapped to pl/metta). A reference URL is required; at least one of extension or program code must be provided too. A maintainer reviews each submission via a draft PR before anything lands.
Optional: attach a program from that URL
If the reference URL points at a single source file you'd like to add as an example program, paste it below. The workflow will write it under languages/MeTTa/programs/<sha>/. Keep under ~200 lines.
(or open the pre-filled issue directly)
← Metropolis Meu →