|
PPL Prolog Language Interface 2.0
|
The Ciao Prolog interface to the PPL is an importable Prolog module backed by shared libraries. Configure with --enable-interfaces=ciao_prolog and leave shared libraries enabled. See interfaces/Prolog/Ciao/README.ciao.md for build and usage instructions.
The command make install installs the module and its native foreign interface in prefix/lib/ppl (or the corresponding directory if a custom --libdir was selected). Import it in your Ciao program with:
Compile your program with ciaoc -o myprog myprog.pl. Call ppl_initialize/0 before other PPL predicates and ppl_finalize/0 when finished.
The GNU Prolog interface to the PPL is available both as a PPL-enhanced interpreter and as a library that can be linked to GNU Prolog programs. GNU Prolog 1.3.2(20100322) or later is supported. Put the installed gprolog and gplc programs on PATH. See interfaces/Prolog/GNU/README.gprolog.md for configuration and installed-client checks.
Configuration obtains the include path and fixed-register options from gplc and checks that the selected C++ compiler accepts the runtime's register ABI. A GNU Prolog runtime built with --disable-regs requires no fixed-register options. Otherwise, use a compatible C++ compiler. An explicit request for an incompatible interface fails; automatic selection warns and omits it.
ppl_gprolog ExecutableThe command make install installs ppl_gprolog in bindir. It is a GNU Prolog interpreter with PPL linked in. Call ppl_initialize/0 before other PPL predicates and ppl_finalize/0 when finished.
The foreign declarations ppl_gprolog.pl are installed in pkgdatadir. The adapter libraries libppl_gprolog.* are in pkglibdir, and the core library is in libdir. These directories are defined in Compilation and Installation.
Save the following domain-independent example as example.pl. It solves a MIP problem with a constant objective, checks that the optimal value is 7, and releases the problem explicitly:
main :-
ppl_initialize,
ppl_new_MIP_Problem(1, [], 7, max, Problem),
ppl_MIP_Problem_solve(Problem, optimized),
ppl_MIP_Problem_optimal_value(Problem, 7, 1),
ppl_delete_MIP_Problem(Problem),
ppl_version(Version),
format('PPL ~w~nOptimal value: 7~n', [Version]),
ppl_finalize.
:- initialization(main).
Choose the C++ compiler and options used for PPL and GMP. Let that driver select its C++ runtime instead of hardcoding -lstdc++. Set the following variables to the installation's actual directories, then compile and run the example:
This example requires the static GNU Prolog adapter archive. Keep static libraries enabled (--enable-static) when configuring PPL for this form of linking. A loadable module is not a portable substitute for the archive; on macOS it is a bundle and cannot be linked into an executable. The operating-system loader must find any shared PPL/GMP libraries. A static-only PPL installation needs the full dependency closure in the link flags. Omit --no-top-level when an interactive Prolog shell is wanted. The same example can be consulted by the installed ppl_gprolog interpreter without linking another client.
GNU Prolog has separately sized execution stacks. If an application needs larger stacks, set the relevant environment variables when running it; for example, GLOBALSZ=32768 ./example increases the global stack. Consult the GNU Prolog manual supplied with the runtime for its stack settings.
The SICStus Prolog interface to the PPL is available both as a statically linked module or as a dynamically linked one. SICStus Prolog 4.10.1 or later is required.
ppl_sicstus ExecutableIf an appropriate version of SICStus Prolog is installed on the machine on which you compiled the library, the command make install will install the executable ppl_sicstus in the directory prefix/bin. The ppl_sicstus executable is simply the SICStus Prolog system with the Parma Polyhedra Library statically linked. The only thing you should do to use the library is to load prefix/lib/ppl/ppl_sicstus.pl.
In order to dynamically load the library from SICStus Prolog you should simply load prefix/lib/ppl/ppl_sicstus.pl. Notice that, for dynamic linking to work, you should have configured the library with the --enable-shared option.
The SWI-Prolog interface to the PPL is available as a dynamically loaded module or, when shared libraries are disabled, in a prelinked interpreter. SWI-Prolog 5.6.0 or later is supported. Configuration needs the selected interpreter, its foreign-interface headers and its matching swipl-ld or plld build tool. Running the tests also requires library(plunit).
ppl_pl ExecutableWhen shared libraries are disabled, make install installs ppl_pl in bindir. This is an SWI-Prolog shell with PPL linked in; its PPL predicates are available without a separate loader. Shared builds install the native module instead. In those builds, ppl_pl remains a build-tree regression-test executable.
With shared libraries enabled, consult the installed loader in pkgdatadir, normally prefix/share/ppl:
:- consult('<pkgdatadir>/ppl_swiprolog.pl').
The native module is in pkglibdir, normally libdir/ppl. The generated loader resolves its actual platform filename relative to the script's location, including custom --libdir and --datadir layouts. It does not rely on the application's working directory or on adding pkglibdir to SWI-Prolog's foreign-library search path. See Compilation and Installation for relocation, staging and runtime-library requirements.
Loading the native module invokes ppl_initialize/0 automatically. Unloading it with unload_foreign_library/1 invokes ppl_finalize/0. For direct module loading, use its actual installed filename, including the platform suffix; for example:
:- load_foreign_library('<pkglibdir>/libppl_swiprolog.so').
:- unload_foreign_library('<pkglibdir>/libppl_swiprolog.so').
See interfaces/Prolog/SWI/README.swiprolog.md for build, loading and installed-client checks.
The XSB Prolog interface to the PPL is available as a dynamically linked module. XSB 5.0.0 or later is required.
Load the installed ppl_xsb module from pkgdatadir, normally prefix/share/ppl, and import the predicates you need. Keep ppl_xsb.xwam and its companion native module together in that directory. Use the actual configured datadir; no copy into the application's working directory is needed. See interfaces/Prolog/XSB/README.xsb.md for configuration and runtime requirements.
The YAP Prolog interface to the PPL is a dynamically loaded module. Compatibility depends on the runtime build. The PPL was validated with YAP 8.0.2 using the source changes described in interfaces/Prolog/YAP/README.yap.md. Configuration needs the yap executable, the Yap/c_interface.h development header and the YAP library. Use compiler and linker search options when these are outside the toolchain's ordinary search paths.
With shared libraries enabled, consult the installed loader in pkgdatadir, normally prefix/share/ppl:
:- consult('<pkgdatadir>/ppl_yap.pl').
The native module is in pkglibdir, normally libdir/ppl. The generated script resolves its actual platform filename relative to the loader's location, including custom --libdir and --datadir layouts. Keep that relative layout when relocating the installation; DESTDIR is not embedded in the loader. The operating-system loader must also find PPL and GMP.
Loading the module invokes ppl_initialize/0 automatically. Call ppl_finalize/0 when the application no longer needs PPL. See interfaces/Prolog/YAP/README.yap.md and run make installcheck with the selected YAP runtime to check the installed loader and predicates. If installation used DESTDIR, use the same staging directory for this check.