Skip to main content

Syntax

A FlowLog program is a plain-text .dl file containing declarations and rules. This page covers the building blocks you'll use everywhere.

Variables

Variables start with a lowercase letter and can contain letters, digits, and underscores. Each variable is local to the rule it appears in — the same name in two different rules is two independent bindings:

Path(x, y) :- Edge(x, y).
Path(x, z) :- Path(x, y), Edge(y, z).

When a variable shows up in multiple atoms of the same rule, it acts as a join keyFlowLog only keeps combinations where that variable has the same value everywhere. In the second rule above, y must match across Path and Edge.

Constants

You can use literal values directly in rules and facts:

KindExampleNotes
Integer42, -1, 0Decimal literals; see Types for the full set of numeric types
Float1.25, 0.0Decimal with a dot
String"hello"Double-quoted, UTF-8
BooleanTrue, FalseCapitalized — true won't work!

Constants work in both rule heads and bodies:

// Inline facts
Source(1).
Name(1, "alice").
Flag(1, True).

// Filtering in a rule body
BigNode(x) :- Node(x, size), size > 100.

Placeholders

Don't care about a column? Use the underscore _ wildcard — it matches anything without binding a name:

HasOutEdge(x) :- Edge(x, _).

Multiple underscores in the same rule are independent. Each _ is its own "I don't care."

Comments

Line comments start with // or #:

// This is a comment
# So is this
Reach(y) :- Source(y). // inline comment

There are no block comments — just keep commenting lines. It builds character.

Whitespace

Spaces, tabs, and newlines are only there to separate tokens. Feel free to break long rules across multiple lines:

Path(x, y) :-
Edge(x, z),
Path(z, y).

.include

Split your program across files with .include:

.include "lib/graph_utils.dl"
.include "lib/string_helpers.dl"

All declarations and rules from included files get merged into the main program. Includes can nest — an included file can .include other files too.