A modern Prolog implementation written mostly in Rust.
A modern Prolog implementation written mostly in Rust.
Scryer Prolog aims to become to ISO Prolog what GHC is to Haskell: an open source industrial strength production environment that is also a testbed for bleeding edge research in logic and constraint programming, which is itself written in a high-level language.
Scryer Prolog passes all tests of
syntactic conformity,
variable_names/1 and
dif/2.
The homepage of the project is: https://www.scryer.pl
Produce an implementation of the Warren Abstract Machine in Rust, done according to the progression of languages in Warren's Abstract Machine: A Tutorial Reconstruction.
Phase 1 has been completed in that Scryer Prolog implements in some form all of the WAM book, including lists, cuts, Debray allocation, first argument indexing, last call optimization and conjunctive queries.
Extend Scryer Prolog to include the following, among other features:
,, ;, ->, etc.).setup_call_cleanup/3, call_with_inference_limit/3,
etc.)term_expansion/2 and goal_expansion/2.dif/2, freeze/2, etc.
is straightforward with attributed variables.
verify_attributes/3attribute_goals/2 and project_attributes/2call_residue_vars/2if_/3 and related predicates, following the developments of the
paper "Indexing dif/2".findall/{3,4}, bagof/3, setof/3, forall/2).asserta/1, assertz/1,
retract/1, abolish/1) with logical update semantics.bb_get/2
bb_put/2 (non-backtrackable) and bb_b_put/2
(backtrackable).atom, var, etc) with if/else ladders. (in progress)Use the WAM code produced by the completed code generator to get JIT-compiled and -executed Prolog programs. The question of how to get assembly from WAM code is something I'm still considering.
It's my hope to use Scryer Prolog as the logic engine of a low level (and ideally, very fast) Shen implementation.
There are no current plans to implement any of these, but they might be nice to have in the future. They'd make a good project for anyone wanting to contribute code to Scryer Prolog.
Implement the global analysis techniques described in Peter van Roy's thesis, "Can Logic Programming Execute as Fast as Imperative Programming?"
Add unum representation and arithmetic, using either an existing unum implementation or an ad hoc one. Unums are described in Gustafson's book "The End of Error."
Add concurrent tables to manage shared references to atoms and strings.
Precompiled binaries for several platforms are available for download at:
https://github.com/mthom/scryer-prolog/releases/latest
First, install the latest stable version of Rust using your preferred method. Scryer tends to use features from newer Rust releases, whereas Rust packages in Linux distributions, Macports, etc. tend to lag behind. rustup will keep your Rust updated to the latest stable release; any existing Rust distribution should be uninstalled from your system before rustup is used.
[!NOTE] The minimum rust toolchain version required can be found in the Cargo.toml under the
package.rust-versionkey. The accuracy of this value is validated in CI
$> git clone https://github.com/mthom/scryer-prolog
$> cd scryer-prolog
$> cargo build --releaseThe --release flag performs various optimizations, producing a
faster executable.
After compilation, the executable scryer-prolog is available in the
directory target/release and can be invoked to run the system.
cargo installcargo install --locked --git https://github.com/mthom/scryer-prolog.gitAfterwards the scryer-prolog binary will be in the $HOME/.cargo/bin directory which is usually added to your PATH
during the installation of the rust toolchain.
[!NOTE] The latest crates.io release can be significantly behind the version available in the git repository The crates.io badge in this sections title is a link to the crates.io page. The msrv badge in the section title references the minimum rust toolchain version required to compile the latest crates.io release
scryer-prolog is also release on crates.io and can be installed with
cargo install --locked scryer-prologOn Windows, Scryer Prolog is easier to build inside a MSYS2 environment as some crates may require native C compilation. However, the resulting binary does not need MSYS2 to run. When executing Scryer in a shell, it is recommended to use a more advanced shell than mintty (the default MSYS2 shell). The Windows Terminal works correctly.
To build a Windows Installer, you'll need first Scryer Prolog compiled in release mode, then, with WiX Toolset installed, execute:
candle.exe scryer-prolog.wxs
light.exe scryer-prolog.wixobjIt will generate a very basic MSI file which installs the main executable and a shortcut in the Start Menu. It can be installed with a double-click. To uninstall, go to the Control Panel and uninstall as usual.
Scryer Prolog has basic WebAssembly support. You can follow wasm-pack's official instructions to install wasm-pack and build it in any way you like.
However, none of the default features are currently supported. The preferred way of disabling them is passing extra options to wasm-pack.
For example, if you want a minimal working package without using any bundler like webpack, you can do this:
wasm-pack build --target web -- --no-default-featuresThen a pkg directory will be created, containing everything you need for a webapp. You can test whether the package is successfully built by creating an html file, adapted from wasm-bindgen's official example like this:
…Then you can serve it with your favorite http server like python -m http.server or npx serve, and access the page with your browser.
Pre-built Docker images are available on Docker Hub.
The latest tag reflects the state on master, which might be unstable.
There are also tags for Scryer releases 0.9.2 and up.
Note though, that the base images are not kept up to date at the moment,
so be wary of security vulnerabilities (see #2646).
First, install Docker on Linux, Windows, or Mac.
Once Docker is installed, you can download and run Scryer Prolog with a single command:
$> docker run -it mjt128/scryer-prologTo consult your Prolog files, bind mount your programs folder as a Docker volume:
$> docker run -v /home/user/prolog:/mnt -it mjt128/scryer-prolog
?- consult('/mnt/program.pl').
true.This works on Windows too:
$> docker run -v C:\Users\\user\Documents\prolog:/mnt -it mjt128/scryer-prolog
?- consult('/mnt/program.pl').
true.Prolog files are loaded by specifying them as arguments on the command
line. For example, to load program.pl, use:
$> scryer-prolog program.plLoading a Prolog file is also called “consulting” it. The built-in
predicate consult/1 can be used to consult a file from within
Prolog:
?- consult('program.pl').As an abbreviation for consult/1, you can specify a list of
program files, given as atoms:
?- ['program.pl'].The special notation [user] is used to read Prolog text from
standard input. For example,
?- [user].
hello(declarative_world).
hello(pure_world).Pressing RETURN followed by Ctrl-d stops reading from
standard input and consults the entered Prolog text.
After a program is consulted, you can ask queries about the predicates it defines. For example, with the program shown above:
?- hello(What).
What = declarative_world
; What = pure_world.Press SPACE to show further answers, if any exist. Press RETURN
or . to abort the search and return to the
toplevel prompt. Press f to see up to the next multiple of
5 answers, and a to see all answers. Press h to show a help
message.
Use TAB to complete atoms and predicate names in queries. For
instance, after consulting the program above, typing decl followed
by TAB yields declarative_world. Press TAB repeatedly
to cycle through alternative com
No open issues yet, or sync has not completed.