Flowlog User Guide (flowlog.c)

This guide focuses on using Flowlog (flowlog.c) as an ISO-style Prolog system, with multicore parallelism.

Running programs

Load a file and run a goal (one-shot)

./flowlog program.pl -g "goal."

Notes:

Interactive REPL (SECTION 26)

Start an empty REPL:

./flowlog

Start a REPL with a program preloaded:

./flowlog program.pl

Inside the REPL:

Scripted input (non-TTY) (SECTION 26)

When stdin/stdout are not TTYs, Flowlog suppresses prompts/banners and reads goals line-by-line:

printf "length([1,2,3], N).\n" | ./flowlog

Writing portable programs

Flowlog is happiest with “pure” ISO-style code:

Facts and rules

parent(alice, bob).
parent(bob, claire).

ancestor(X, Y) :- parent(X, Y).
ancestor(X, Y) :- parent(X, Z), ancestor(Z, Y).

Directives at load time

Flowlog supports a small set of common directives in source files (SECTION 25 and SECTION 10):

Flowlog also recognizes a portability pattern used by some code bases (SECTION 25):

:- catch(set_prolog_flag(flowlog_parallel_profile, fast), _, true).

If the inner flag is recognized, Flowlog applies it; otherwise the directive is ignored.

Dynamic database (interactive and runtime) (SECTION 13)

To add or remove clauses at runtime, use the ISO dynamic database predicates:

?- asserta(parent(alice, bob)),
   assertz(parent(bob, claire)),
   clause(parent(X, Y), true).

For rules, assert a clause term:

?- assertz((ancestor(A, B) :- parent(A, B))).

Streams and I/O (SECTION 08 and SUBSECTION 17.5)

Flowlog implements the ISO stream model (open/close, selecting current input/output, reading and writing terms).

Example:

?- open('data.pl', read, S),
   set_input(S),
   read_term(T, [syntax_errors(error)]),
   close(S).

For writing:

?- open('out.txt', write, S),
   write_term(S, hello(world), [quoted(true), fullstop(true), nl(true)]),
   close(S).

Prolog flags (SECTION 05.4 and SECTIONS 22/23/24)

Use current_prolog_flag/2 and set_prolog_flag/2 for ISO flags like:

Flowlog also exposes non-ISO flags for parallelism (see below).

Parallel execution (default)

Flowlog defaults to flowlog_parallel_profile=fast (unordered OR-par commits for throughput) (SECTION 25 and SECTION 21).

For “as compatible as possible” behavior, use the iso profile (SUBSECTION 26.1):

:- set_prolog_flag(flowlog_parallel_profile, iso).

For maximum throughput (solutions may arrive out-of-order), use the fast profile (SUBSECTION 26.1):

:- set_prolog_flag(flowlog_parallel_profile, fast).

To disable Flowlog parallel features (sequential) (SUBSECTION 26.1):

:- set_prolog_flag(flowlog_parallel_profile, off).

See PARALLELISM.md for semantics, tuning, and safety notes.

Differences from common REPLs (SECTION 26)

Flowlog’s REPL is intentionally minimal:

These are UI differences, not language semantics.