Tau Tau Prolog

An open source Prolog interpreter in JavaScript

Get started
Version

Try it

Paste your program in the box in the left and type a Prolog goal below. When you press ENTER on the goal textbox, the interpreter will read the goal and try to find a computed answer, showing the result here. If you press ENTER again (to keep looking for answers), the interpreter will continue looking from the last choice point.

Look at built-in predicates and modules supported by Tau Prolog.

Features

ISO Prolog Standard compliance

Tau Prolog development has been directed by the ISO Prolog Standard, designed to promote the applicability and portability of Prolog text and data among several data processing systems.

More about ISO Prolog

Compatible with browsers and Node.js

Tau Prolog has been developed to be used with either Node.js or a browser seamlessly. Just use the <script> tag or the require function to add Tau Prolog to your project and start coding.

More about Node.js support

DOM manipulation and event handling

Taking the best from JavaScript and Prolog, Tau Prolog allows you to handle browser events and modify the DOM of a web using Prolog predicates, making Prolog even more powerful.

More about DOM and events

Asynchronous predicates

Tau Prolog has been developed following a non-blocking, callback-based approach, allowing you, for instance, to sleep the main thread or to do AJAX requests without blocking the browser.

More about asynchrony

A brief look

Load the library

<script src="tau-prolog.js"></script>

Create a session

var session = pl.create();

Consult a program

session.consult(` likes(sam, salad). likes(dean, pie). likes(sam, apples). likes(dean, whiskey). `, { success: function() { /* Program loaded correctly */ }, error: function(err) { /* Error parsing program */ } });

or

session.consult("path/to/src.pl" { success: function() { /* Program loaded correctly */ }, error: function(err) { /* Error parsing program */ } });

Query a goal

session.query("likes(sam, X).", { success: function(goal) { /* Goal loaded correctly */ }, error: function(err) { /* Error parsing goal */ } });

Look for answers

session.answer({ success: function(answer) { console.log(session.format_answer(answer)); // X = salad ; session.answer({ success: function(answer) { console.log(session.format_answer(answer)); // X = apples ; }, // ... }); }, fail: function() { /* No more answers */ }, error: function(err) { /* Uncaught exception */ }, limit: function() { /* Limit exceeded */ } });

Enjoy Prolog!

// is that possible? ...

Who uses Tau Prolog?

Yarn is a package manager for your code. It allows you to use and share code with other developers from around the world. Yarn does this quickly, securely, and reliably.

Logtalk is a declarative object-oriented logic programming language that extends and leverages the Prolog language with modern code encapsulation and code reuse mechanisms.

Klipse is a JavaScript plugin for embedding interactive code snippets in tech blogs. A simple client-side code evaluator pluggable on any web page.