LinuxCommandLibrary

gprolog

TLDR

Start GNU Prolog interpreter

$ gprolog
copy
Load and run file
$ gprolog --consult-file [program.pl]
copy
Compile to executable
$ gplc [program.pl] -o [program]
copy
Run query from command line
$ gprolog --query-goal "[goal]"
copy

SYNOPSIS

gprolog [options]
gplc [options] files

DESCRIPTION

GNU Prolog is a Prolog compiler with constraint solving over finite domains. It compiles Prolog to native code and provides an interactive interpreter.
GNU Prolog supports ISO Prolog with extensions for constraint logic programming, making it suitable for combinatorial problems, scheduling, and AI applications.

PARAMETERS

--consult-file file

Load Prolog file at startup.
--query-goal goal
Execute goal after loading.
--init-goal goal
Execute initialization goal.
--entry-goal goal
Entry point goal.
--no-top-level
Exit after executing goals.

INTERPRETER COMMANDS

$ ?- consult('file.pl').    % Load file
?- listing.               % Show predicates
?- halt.                  % Exit
?- trace.                 % Enable tracing
copy

COMPILING

$ # Compile to executable
gplc program.pl -o program

# With optimization
gplc --fast-math program.pl -o program
copy

CAVEATS

Syntax differs slightly from SWI-Prolog. Native compilation adds startup complexity. Constraint solving requires finite domain declarations. Interactive debugging requires trace mode.

HISTORY

GNU Prolog was created by Daniel Diaz at INRIA, first released in 1996. It emphasizes native code compilation and constraint solving, distinguishing it from interpreted Prolog systems.

SEE ALSO

swipl(1), sicstus(1), prolog(1)

Copied to clipboard