XLOG lets you write a few logic rules — like “if there is an edge from X to Y, then Y is reachable from X” — and get the answer computed for you. This page takes you from an empty file to a running query in a couple of minutes. By the end you will have written a program, run it from the command line, and confirmed the result by reading the table XLOG prints back.

Your first program

1

Write the program

Create a file named reachability.xlog. It declares two relations, lists three edges, and defines what “reachable” means — including the recursive case, where reaching Z means you can already reach some Y that has an edge to Z. The last line, starting with ?-, is the question you want answered.
This query asks: starting from node 1, which nodes N can I reach?
2

Run it

3

Confirm it worked

XLOG prints the answer as a table. Starting from node 1 you can reach 2, 3, and 4, so those are the rows you should see:
If you get these three rows, your program ran correctly.
The language reference covers the full surface, and the repository’s examples/ directory contains annotated programs for lists and meta-predicates, magic sets, probabilistic aggregates, approximate inference, epistemic reasoning (examples/epistemic/), and Python neural-symbolic training (examples/python/).

CLI at a glance

Once your first program runs, the same xlog command gives you other ways to execute and inspect a program. Each block below is a self-contained example; the comment says what it is for. Run a program and compute exact answers:
Feed in a table from an external file, using Arrow IPC (Apache Arrow’s columnar format for exchanging tables between tools):
Run a program whose facts have probabilities and get the probability of each answer. exact_ddnnf computes exact probabilities; mc estimates them by Monte Carlo sampling (repeated random trials — faster, approximate):
Measure where time and memory go:
Ask XLOG to explain how it planned and executed a program:
List every flag for a subcommand:
See the CLI reference for the complete flag reference.

Next steps

  • Installation — supported platform, source builds, PyPI, crates.io, and the CUDA kernel artifact model
  • Language reference — types, predicates, rules, modules, UDFs, aggregations, and pragmas