MeTTa language transpiler: PeTTa

Hi!

I’d like to introduce PeTTa ( GitHub - trueagi-io/PeTTa: Efficient MeTTa language implementation in Prolog. ), a MeTTa-to-Prolog transpiler I originally designed last year, and which reached maturity this January in collaboration with Peter Isaev and the talented team at SingularityNET.

PeTTa directly translates MeTTa ( https://metta-lang.dev/ ) functions into Prolog clauses and enables efficient execution of MeTTa code, preserving the strong performance characteristics of SWI-Prolog in the translation, and allowing overhead-free bi-directional interop with Prolog code.

This demonstrates that a logic programming language can easily host a fully featured, and even extended, functional language while preserving logic programming capabilities and high performance. By contrast, embedding logic programming into a functional language has historically produced slow, toy-like systems (such as Kanren variants), often with weak integration into the host language. Crucially, functional runtimes lack the deep execution, indexing, and search optimizations needed for efficient logic programming, and reproducing them would be an immense undertaking. (Thank you @jan and others for your decades of work on SWI-Prolog, it is king!)

Also, PeTTa is now actively used by Peter and me at Life-like AI (https://life-like.ai) for real-time neuro-symbolic integration and empirical reasoning, including mobile robotics applications that leverage our NARS-based reasoning technology. Working with deep neural networks and symbolic mechanisms using the same language, and elegantly, has never been easier, integrating PyTorch, OpenAI LLM/VLM API, vector databases (FAISS), and scalable symbolic atom spaces (MORK) in addition to the great predicate store of Swipl itself. Have fun with PeTTa, and please check out the examples: PeTTa/examples at main · trueagi-io/PeTTa · GitHub

Best regards,
Patrick Hammer

4 Likes

Very nice! I’ll have to port the Metta-WAM LSP to run on PeTTa :slight_smile: ; it will presumably be a bit easier for other MeTTa devs to make use of if it can be run a bit more independently!

1 Like

Do you have some data on the efficiency compared to the native version?

Not sure it is feasible, but would it be possible to create a SWI-Prolog pack? That provides permanent visibility as well as very simple installation. Let me know if you need help.

We carried out a detailed performance analysis a few weeks ago, and will soon link replicable benchmarks in the repository Wiki. On average, PeTTa is at least ~500× faster than the Hyperon-Experimental Rust interpreter, which is a classical AST-walking interpreter and lacks most optimizations.

Best regards,

Patrick

1 Like