eyedia

npm version DOI

EYE

Eyedia — reasoning you can see.

A standalone, dependency-free Prolog rule language with forward and backward reasoning and checkable proofs.

Eyedia turns explicit facts and rules into conclusions whose derivations can be inspected and checked. An answer can arrive together with a certificate, and that certificate can be verified against the program that produced it.

Facts and rules use Prolog syntax:

human(socrates).
mortal(X) :+ human(X).

Head :+ Body materializes conclusions until a fixpoint. Head :- Body defines a predicate evaluated when called. The two compose: a forward body may call backward definitions, and a backward goal may use facts that forward reasoning established.

The thread

Eyedia is built around one idea: reasoning you can see. You write facts and rules; Eyedia draws conclusions, forward until nothing new follows and backward on request, and every answer can come with a proof. A separate checker verifies that proof against the program, independently of the reasoner, and does more than a classic proof checker:

The report is itself Prolog, and every generated proof is checked before it is returned. Around that core, 59 examples grew, from Socrates and the zebra puzzle to a hospital research portal decided under today’s EU rules and under the Commission’s Digital Omnibus proposal, and package holiday cancellations under the 2015 and the revised Package Travel Directive. Each has a deck for a wide audience and can be run in the playground.

A proof guarantees that the conclusions follow from the rules, not that the rules say what the law or the policy says. So eyedia --unused shows which parts of a translation make no difference to the conclusions, and an expert knows where to look.

Run it

Node.js 18 or newer. No install, no build step:

node bin/eyedia.js examples/socrates.pl
node bin/eyedia.js --proof examples/socrates.pl
node bin/eyedia.js --proof examples/socrates.pl | node bin/eyedia.js --check-proof - examples/socrates.pl
npm test

The executable becomes eyedia when the package is installed. Run eyedia --help for the full command line.

Or in the browser: the playground edits, runs and checks any example. To run it from a checkout, serve it (python3 -m http.server) and open /playground/.

From JavaScript

import { run, checkProof } from './index.js';

const source = 'human(socrates). mortal(X) :+ human(X).';
const result = run(source, { goal: 'mortal(X)', proof: true });
console.log(result.answers);                            // ['mortal(socrates)']
console.log(checkProof(source, result.proof).valid);    // true

Read on

License

MIT