Skip to content

Releases: andrewgoodchild/tiny-datalog

tiny-datalog 0.6.0

Choose a tag to compare

@andrewgoodchild andrewgoodchild released this 15 Oct 10:38

Comparisons, integrity constraints, warnings, time, and agent memory.

  • Comparisons < <= > >= = !=. They check values but never compute them: both sides must be bound, and there is still no +. Numbers compare as numbers and strings as text, so ISO dates compare as dates. Every engine supports them, as do incremental maintenance, semirings and --models. prolog.py and the chase refuse them, and containment skips rules that use them.
  • Integrity constraints :- body.: after evaluation, every match is printed as a counterexample and the exit status is 3. In Python, engine.violations() returns the matches, and IncrementalEngine checks its updated state the same way.
  • Warnings on stderr for legal programs that are probably wrong:
    • a predicate nothing defines, with the nearest name ("did you mean suspended?");
    • a predicate with no base case;
    • comparisons that can never all hold.
  • --assume: a what-if run with facts added, or removed with fact~..
  • Value safety: strings containing line breaks, control characters, invisible or direction-changing characters, or both kinds of quote, are refused, in program text and in facts= from Python.
  • Two new lessons:
    • 23, Time: dated statements and supersession, intervals and overlap, and when a fact held versus when it was recorded.
    • 24, Agent memory: a language model writes only the statements it was told, tagged with their source. Rules derive the beliefs, contradictions become questions to the user, and --explain traces each belief back to its source.
  • Lesson 17 gains sections on integrity constraints and on mistakes that are still legal Datalog. An Agent Skill (skills/tiny-datalog/SKILL.md) is included, and the other lessons were updated to match.

Behaviour changes:

  • :- q(X). used to be a parse error and is now a constraint.
  • String values refuse tabs, newlines and other invisible characters.
  • violations() doesn't report _ variables, matching query().

362 tests.

tiny-datalog 0.5.0

Choose a tag to compare

@andrewgoodchild andrewgoodchild released this 11 Oct 08:58
a5533f1

Authorization, program analysis, knowledge graphs, and the chase.

  • Three new lessons (numbered 20–22, so existing lesson links are unchanged):
    • 20, Authorization: Zanzibar-style relationship-based access, --explain as an audit trail, why listing everyone with access costs more than checking one user, a revocation list that fails open when empty, and Biscuit-style tokens.
    • 21, Program analysis: points-to and the call graph in one fixpoint, and a taint analysis whose false positive --explain traces.
    • 22, Knowledge graphs: RDFS, OWL 2 RL, existential rules and the chase, and owl:sameAs as the bridge to union-find and egglog.
  • Lesson 0 gains "One language, many dialects": one program in Soufflé, Datomic, Mangle, Logica and SQL, with a comparison table.
  • tiny_datalog.chase and a new tiny-datalog-chase command: rules whose head mentions a value the body doesn't name invent unknown values (labelled nulls). It offers the restricted and oblivious chase, checks before running whether the rules are guaranteed to stop and names the cycle if not, has a --max-nulls budget, and marks answers that aren't certain.
  • Eight new example programs, plus exercises with answers for the three lessons.

Fix: when a fact could be derived several ways, --explain printed a tree that could change from run to run. It now always picks the same one.

326 tests.

tiny-datalog 0.4.0

Choose a tag to compare

@andrewgoodchild andrewgoodchild released this 05 Oct 10:22

A common core, pluggable engines, and extensions.

  • tiny_datalog.core: the language every module shares — parser, validation, stratification, matching, formatting. Former private helpers are now public (match, aggregate_of, sort_key, Engine.substitutions, …); old names remain as aliases, and every previous import still works.
  • tiny_datalog.engines: semi-naive, naive, magic sets and tabling behind one interface and a registry. tiny-datalog --engine {seminaive,naive,magic,tabling} -q '...'.
  • Extensions (stable models, semirings, incremental, defeasible logic, Prolog, subsumption, containment) build on the core.

Also: duplication removed across modules (one shared CLI error handler; grounding through the engine — up to 6× faster on supply-chain), four pieces of dead code removed, and package line coverage up from 95% to 99% (303 tests).

Behaviour change: --magic -e used to ignore -e silently; --explain now requires a bottom-up engine and says so.

tiny-datalog 0.3.0

Choose a tag to compare

@andrewgoodchild andrewgoodchild released this 05 Oct 00:43

Tabling with stratified negation. tiny-datalog-tabling now runs programs with not when they stratify: a negated subgoal's tables are completed one stratum down before they are read. Negation through recursion is still refused, with a pointer to --models for the well-founded semantics.

A friendlier library.

engine = run_program(rules, facts={"depends": [("app", "lib")], "service": ["app"]})
engine.query("exposed(S, C)")   # [{'S': ..., 'C': ...}, ...]

Course. Lesson 15 adds a section on what full SLG resolution adds, and eight queens as a worked example: tabling solves it in 0.4s, while plain bottom-up must build 2.5 million intermediate facts. benchmarks/generate.py queens N generates any board size.

tiny-datalog 0.2.0

Choose a tag to compare

@andrewgoodchild andrewgoodchild released this 03 Oct 09:24

New: defeasible logic. tiny_datalog.defeasible and the tiny-datalog-defeasible command: rules with exceptions and priorities — strict ->, defeasible =>, defeaters ~>, superiority r1 > r2, strong negation ~ — with ambiguity blocking (default) or --propagating. The proof conditions follow Antoniou, Billington, Governatori & Maher (TOCL 2001) and Maher (TPLP 2012).

pip install --upgrade tiny-datalog
tiny-datalog-defeasible -q 'flies(X)' birds.dfl

The course gains lesson 18, Rules with exceptions; the neighbours move to lesson 19. The external datalog-conformance corpus now runs its defeasible theories too: 195 cases pass.

tiny-datalog 0.1.2

Choose a tag to compare

@andrewgoodchild andrewgoodchild released this 03 Oct 04:13

Packaging-metadata release: PyPI classifiers (Python 3.9–3.13, Database / Education / Interpreters), keywords, and Source / Issues / Changelog / Lessons links. CI now tests every claimed Python version and runs the external datalog-conformance corpus. No engine changes since 0.1.1.

tiny-datalog 0.1.1

Choose a tag to compare

@andrewgoodchild andrewgoodchild released this 03 Oct 03:08

Documentation-only release: the README's lesson links are now absolute, so they resolve on the PyPI project page. No code changes since 0.1.0.

tiny-datalog 0.1.0

Choose a tag to compare

@andrewgoodchild andrewgoodchild released this 03 Oct 03:01

First release on PyPI.

pip install tiny-datalog

A Datalog engine small enough to read in an afternoon — semi-naive evaluation with stratified negation and aggregation, plus satellites for magic sets, stable and well-founded models, semiring provenance, incremental maintenance, tabling, KL-ONE subsumption, query containment and a Prolog reader. Installs the tiny-datalog command and its six tiny-datalog-* siblings.