Skip to content

Repository files navigation

Eyepl

Eyepl logo

npm version DOI

Eyepl combines ISO Prolog and W3C RDF 1.2 to turn portable rules and linked data into answers and inspectable proofs.

Playground · The Art of Eyepl

Quick start

Install the published CLI globally:

npm install --global eyepl
eyepl --version
printf 'query(works(stdin, true)).\nworks(stdin, true) :- ok = ok.\n' | eyepl -

Eyepl has no build step. From a source checkout, install its RDF parser dependencies and run the CLI directly with Node.js 18 or newer:

npm install
node bin/eyepl.js --library examples/ancestor.pl
node bin/eyepl.js --library --proof examples/socrates.pl
node bin/eyepl.js --library --warnings test/conformance/warnings/negation/unstratified_mutual.pl
printf 'query(works(stdin, true)).\nworks(stdin, true) :- ok = ok.\n' | node bin/eyepl.js -

For one-off local CLI use from the checkout, npm can run the package bin without a manual symlink:

npm exec --yes --package=. -- eyepl --version
npm exec --yes --package=. -- eyepl --library examples/ancestor.pl

To install the checkout's eyepl command on your PATH, use npm's package link:

npm link
eyepl --version

For local browser use, run python3 -m http.server from the checkout and open http://localhost:8000/playground.html.

JavaScript API

import { run, Program, Solver } from 'eyepl';

const result = run(`
query(answer(X0)).
answer(ok) :- ok = ok.
`);
console.log(result.stdout);

The default registry contains Eyepl's ISO/IEC 13211-1:1995 core profile: unification and term inspection, control and exceptions, arithmetic, grouped solutions, the dynamic database, operators and directives, flags, atomic-term processing, streams, character/byte and term I/O, and processor termination. The profile has 114 registered predicate indicators across 93 names.

This is broad standards coverage, not a formal certification claim. Eyepl retains documented host conventions—most visibly query/1, automatic tabling, inference fuses, and a distinct double-quoted string scalar—and exhaustive standard error/option combinations remain part of the conformance work. Programs that use Eyepl's non-core string, list, aggregation, context, date, or convenience predicates must opt in explicitly:

import { getLibraryRegistry, run } from 'eyepl';

run(source, { registry: getLibraryRegistry() });

The equivalent CLI switch is -l or --library.

ISO streams are solver-owned and shared by nested goals. JavaScript callers can provide standard input and capture standard output:

const result = run(source, {
  ioOptions: {
    input: "term(from_input).\n",
    write: (text) => process.stdout.write(text),
  },
});

Rules headed by false are inference fuses. A matching fuse aborts before queries run; the CLI exits with code 65, while the JavaScript API throws an InferenceFuseError carrying the same code and a matched-rule diagnostic.

STEM showcase: evidence-backed diagnosis

The spacecraft battery example combines sensor telemetry, the physical relation P = I²R, engineering limits, redundant measurements, and causal rules to derive a diagnosis and safety action:

node bin/eyepl.js --library examples/spacecraft-battery-diagnosis.pl
node bin/eyepl.js --library -p examples/spacecraft-battery-diagnosis.pl

The normal output reports computed metrics, a thermal-runaway precursor, and an isolate_and_cool action. With -p, every conclusion carries machine-readable evidence back to telemetry facts, arithmetic operations, threshold comparisons, and the independent temperature channel.

How it works

The name Eyepl combines EYE with pl, reflecting EYE-style reasoning expressed with Prolog-like syntax.

Its default execution is automatically hybrid: ordinary goals use indexed depth-first resolution, while recursive helper predicate groups are detected and tabled automatically.

Clause selection combines compact any-argument scalar indexes with demand-driven multi-argument indexes. SWI-Prolog-inspired quality checks avoid building indexes for small, weakly selective, or variable-heavy clause groups.

The builtin boundary is intentionally visible in the source tree: src/iso.js contains the ISO processor predicates and default registry, while src/library.js contains the explicitly enabled extension predicates, portable Prolog clauses, and their small profile-guided accelerator set. Both layers use the same parser, terms, solver, streams, and proof machinery.

RDF 1.2 files

The tools convert standard RDF files to ordinary Eyepl rdf/4 facts, run Eyepl rules, and serialize query answers as RDF 1.2 N-Quads:

node tools/rdf-to-eyepl.mjs --rules rules.pl data.ttl -o program.pl
node bin/eyepl.js program.pl > derived.pl
node tools/eyepl-to-rdf.mjs derived.pl -o derived.nq

The input format is detected from the filename. Supported inputs include RDF 1.2 Turtle, TriG, N-Triples, N-Quads and RDF/XML, as well as JSON-LD, RDFa, Microdata, Notation3 and SHACL Compact Syntax. For stdin, provide the format; use --base when relative IRIs need an explicit base:

node tools/rdf-to-eyepl.mjs --format turtle --base https://example/ -

RDF IRIs, scoped blank nodes, literals, directional language strings, nested triple terms, named graphs and the default graph all have lossless Eyepl term encodings. The RDF 1.2 chapter in The Art of Eyepl covers the mapping and --include-source behavior.

Tests

The v0.1.15 release baseline passes 1,030 tests. Its 555-file conformance corpus includes 137 focused ISO cases covering the success, failure, mode, and error behavior derived from ISO/IEC 13211-1 clauses 7 and 8.

npm test
npm run test:conformance
node test/run-conformance-report.mjs
# release preparation writes conformance-report.md via the preversion script
npm run test:examples
npm run test:regression

About

Eyepl combines ISO Prolog and W3C RDF 1.2 to turn portable rules and linked data into answers and inspectable proofs.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages