Development Guide (flowlog.c)

This guide focuses on developing Flowlog in flowlog.c.

Build and run

make
./flowlog

Direct compilation is also supported:

cc -O2 -Wall -Wextra -pthread flowlog.c -lm -o flowlog

Test workflow

Run the regression suite and INRIA ISO suite from this directory:

make test
make inria

Run the Quad conformance tests (QUAD - Query Using Answer Description):

make quad
make quad-wam
make quad-wamvm
make quad-tpl
make quad-scryer

# Run a single quad file
make quad tests/predicates/assertz_quad.pl

To ensure the bytecode VM (flowlog_engine=wamvm) runs the ISO suite without falling back to wam, run:

make inria-wamvm-vmonly

Directory layout

In the full repository checkout, benchmark scripts live under ../bench/.

flowlog.c Layout Map

Flowlog uses SECTION NN and SUBSECTION NN.N headings inside flowlog.c. Documentation references these headings so you can jump directly to the implementation.

Sections (in file order):

Adding or adjusting built-ins

Most ISO predicates are implemented as built-ins in the solver’s goal dispatcher.

Suggested workflow:

  1. Add the predicate implementation in flowlog.c (SECTIONS 22/23/24)
  2. Add a regression test under tests/
  3. If applicable, add a reference comparison case (Trealla/Scryer) or extend the INRIA harness inputs
  4. Run:

Coding style and PR hygiene (single file)

Even though flowlog.c is a single file, it helps to keep structure consistent:

Debugging

OR-par debug logs

Enable OR-par logging:

FLOWLOG_DEBUG_ORPAR=all FLOWLOG_DEBUG_ORPAR_LOG=orpar.log \
  ./flowlog program.pl -g "goal."

Profiling

For CPU-bound problems, perf (Linux) or pmcstat (FreeBSD) can help identify hot paths in:

REPL terminal state

The REPL uses termios raw mode when running on a TTY. If a crash leaves your terminal in a bad state, run:

reset