Skip to content

nowarp/souffle.js

Repository files navigation

Souffle.js

Souffle.js offers bindings to Soufflé, an open-source, parallel logic programming language.

Installation

Install the library with Yarn:

yarn add @nowarp/souffle

Getting Started

Here is an example implementing the Simple Typed VarPointsTo example:

const ctx = new SouffleContext("VarPointsTo");

// Declare relations
ctx.add(
  relation("assign", [
    ["a", Type.symbol()],
    ["b", Type.symbol()],
  ]),
);

// Add facts
ctx.addFact("assign", ["v1", "v2"]);

// Define and output rules
ctx.add(
  relation(
    "alias",
    [
      ["a", Type.symbol()],
      ["b", Type.symbol()],
    ],
    "output",
  ),
);
ctx.add(rule([atom("alias", ["X", "X"])], [body(atom("assign", ["X", "_"]))]));

// Execute the Soufflé program
const executor = new SouffleSyncExecutor();
const out = executor.execute(ctx);
console.log("Raw Soufflé output:\n", out.results);

For the full example, see the source here.

Projects Using Souffle.js