Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A modern Prolog implementation written mostly in Rust.

License

NotificationsYou must be signed in to change notification settings

mthom/scryer-prolog

Repository files navigation

Scryer Prolog aims to become to ISO Prolog what GHC is to Haskell: an opensource industrial strength production environment that is also atestbed for bleeding edge research in logic and constraintprogramming, which is itself written in a high-level language.

Scryer Prolog passes all tests ofsyntactic conformity,variable_names/1 anddif/2.

The homepage of the project is:https://www.scryer.pl

Scryer Logo: Cryer

Phase 1

Produce an implementation of the Warren Abstract Machine in Rust, doneaccording to the progression of languages inWarren's AbstractMachine: A Tutorial Reconstruction.

Phase 1 has been completed in that Scryer Prolog implements in some formall of the WAM book, including lists, cuts, Debray allocation, firstargument indexing, last call optimization and conjunctive queries.

Phase 2

Extend Scryer Prolog to include the following, among other features:

  • call/N as a built-in meta-predicate.
  • ISO Prolog compliant throw/catch.
  • Built-in and user-defined operators of all fixities, with customassociativity and precedence.
  • Bignum, rational number and floating point arithmetic.
  • Built-in control operators (,,;,->, etc.).
  • A revised, not-terrible module system.
  • Built-in predicates for list processing and top-level declarativecontrol (setup_call_cleanup/3,call_with_inference_limit/3,etc.)
  • Default representation of strings as lists of characters, using a packedinternal representation.
  • term_expansion/2 andgoal_expansion/2.
  • Definite Clause Grammars.
  • Attributed variables using the SICStus Prolog interface andsemantics. Adding coroutines likedif/2,freeze/2, etc.is straightforward with attributed variables.
    • Support forverify_attributes/3
    • Support forattribute_goals/2 andproject_attributes/2
    • call_residue_vars/2
  • if_/3 and related predicates, following the developments of thepaper "Indexingdif/2".
  • All-solutions predicates (findall/{3,4},bagof/3,setof/3,forall/2).
  • Clause creation and destruction (asserta/1,assertz/1,retract/1,abolish/1) with logical update semantics.
  • Backtrackable and non-backtrackable global variables viabb_get/2bb_put/2 (non-backtrackable) andbb_b_put/2(backtrackable).
  • Delimited continuations based on reset/3, shift/1 (documented in"Delimited Continuations for Prolog").
  • Tabling library based on delimited continuations(documented in "Tabling as a Library with Delimited Control").
  • Aredone representation of strings as difference lists ofcharacters, using a packed internal representation.
  • clp(B) and clp(ℤ) as builtin libraries.
  • Streams and predicates for stream control.
    • A simple sockets library representing TCP connections as streams.
  • Incremental compilation and loading process, newly written,primarily in Prolog.
  • Improvements to the WAM compiler and heap representation:
    • Replacing choice points pivoting on inlined semi-deterministic predicates(atom,var, etc) with if/else ladders. (in progress)
    • Inlining all built-ins and system call instructions.
    • Greatly reducing the number of instructions used to compile disjunctives.
    • Storing short atoms to heap cells without writing them to the atom table.
  • A compacting garbage collector satisfying the five properties of"Precise Garbage Collection in Prolog." (in progress)
  • Mode declarations.

Phase 3

Use the WAM code produced by the completed code generator to getJIT-compiled and -executed Prolog programs. The question of how to getassembly 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 (andideally, very fast)Shen implementation.

Nice to have features

There are no current plans to implement any of these, but they might benice to have in the future. They'd make a good project for anyone wantingto contribute code to Scryer Prolog.

  1. Implement the global analysis techniques described in Peter vanRoy's thesis, "Can Logic Programming Execute as Fast as ImperativeProgramming?"

  2. Add unum representation and arithmetic, using either an existingunum implementation or an ad hoc one. Unums are described inGustafson's book "The End of Error."

  3. Add concurrent tables to manage shared references to atoms andstrings.

  4. Add some form of JIT predicate indexing.

Installing Scryer Prolog

Binaries

Precompiled binaries for several platforms are available for downloadat:

https://github.com/mthom/scryer-prolog/releases/latest

Native Compilation

First, install the latest stable version ofRust using yourpreferred method. Scryer tends to use features from newer Rustreleases, whereas Rust packages in Linux distributions, Macports,etc. tend to lag behind.rustup will keep yourRust updated to the latest stable release; any existing Rustdistribution should be uninstalled from your system before rustup isused.

Note

The minimum rust toolchain version required can be found in theCargo.tomlunder thepackage.rust-version key.The accuracy of this value is validated in CI

From a local git checkout

$> git clone https://github.com/mthom/scryer-prolog$> cd scryer-prolog$> cargo build --release

The--release flag performs various optimizations, producing afaster executable.

After compilation, the executablescryer-prolog is available in thedirectory target/release and can be invoked to run the system.

Viacargo install

From git

cargo install --locked --git https://github.com/mthom/scryer-prolog.git

Afterwards thescryer-prolog binary will be in the$HOME/.cargo/bin directory which is usually added to your PATHduring the installation of the rust toolchain.

From Crates.ioCrates.io VersionCrates.io MSRV

Note

The lates crates.io release can be significantly behind the version available in the git repositoryThe crates.io badge in this sections title is a link to the crates.io page.The msrv badge in the section title referece to 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-prolog

Caveats for Windows

On Windows, Scryer Prolog is easier to build inside aMSYS2environment 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). TheWindows 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.wxslight.exe scryer-prolog.wixobj

It 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.

Building WebAssembly

Scryer Prolog has basic WebAssembly support. You can followwasm-pack'sofficial instructions to installwasm-pack and build it in any way you like.

However, none of thedefault features are currently supported. The preferred way of disabling them is passingextra options towasm-pack.

For example, if you want a minimal working package without using any bundler likewebpack, you can do this:

wasm-pack build --target web -- --no-default-features

Then apkg 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 fromwasm-bindgen'sofficial example like this:

<!DOCTYPE html><html><head><metacharset="UTF-8"/><title>Scryer Prolog - Sudoku Solver Example</title><scripttype="module">importinitScryer,{MachineBuilder}from"./pkg/scryer_prolog.js";// Initialize Scryer Prolog with WASMconstwasm=awaitfetch("./pkg/scryer_prolog_bg.wasm");constmodule=awaitWebAssembly.compile(awaitwasm.arrayBuffer());awaitinitScryer(module);// Set up the Prolog machineconstmachine=newMachineBuilder().build();// Knowledge base: Sudoku rules and problem definitionconstkb=`        :- use_module(library(format)).        :- use_module(library(clpz)).        :- use_module(library(lists)).        sudoku(Rows) :-          length(Rows, 9), maplist(same_length(Rows), Rows),          append(Rows, Vs), Vs ins 1..9,          maplist(all_distinct, Rows),          transpose(Rows, Columns),          maplist(all_distinct, Columns),          Rows = [A,B,C,D,E,F,G,H,I],          blocks(A, B, C),          blocks(D, E, F),          blocks(G, H, I).        blocks([], [], []).        blocks([A,B,C|T1], [D,E,F|T2], [G,H,I|T3]) :-          all_distinct([A,B,C,D,E,F,G,H,I]),          blocks(T1, T2, T3).        problem(1, [[_,_,_,_,_,_,_,_,_],                    [_,_,_,_,_,3,_,8,5],                    [_,_,1,_,2,_,_,_,_],                    [_,_,_,5,_,7,_,_,_],                    [_,_,4,_,_,_,1,_,_],                    [_,9,_,_,_,_,_,_,_],                    [5,_,_,_,_,_,_,7,3],                    [_,_,2,_,1,_,_,_,_],                    [_,_,_,_,4,_,_,_,9]]).      `;machine.consultModuleString("user",kb);// Run the queryconstquery="problem(1, Rows), sudoku(Rows), maplist(portray_clause, Rows).";constanswers=machine.runQuery(query);constformattedSolutions=[];// Format the answersfor(constsolutionofanswers){constrows=solution.bindings["Rows"].list;constgrid=rows.map(row=>row.list.map(cell=>cell.integer));constformatted=grid.map(row=>`[${row.join(", ")}]`).join("\n");formattedSolutions.push(formatted);}// Output resultsconstsolutionDiv=document.querySelector("#soduku-solution");for(constsolutionofformattedSolutions){constnewPre=document.createElement("pre");newPre.textContent=solution;solutionDiv.appendChild(newPre);}</script></head><body><p>Sudoku solver returns:</p><divid="soduku-solution"></div></body></html>

Then you can serve it with your favorite http server likepython -m http.server ornpx serve, and access the page with your browser.

Docker Install

Pre-builtDocker images are available on Docker Hub.Thelatest tag reflects the state onmaster, 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, installDocker on Linux,Windows, or Mac.

Once Docker is installed, you can download and run Scryer Prolog with a singlecommand:

$> docker run -it mjt128/scryer-prolog

To consult your Prolog files, bind mount your programs folder as aDocker 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.

Tutorial

Prolog files are loaded by specifying them as arguments on the commandline. For example, to loadprogram.pl, use:

$> scryer-prolog program.pl

Loading a Prolog file is also called “consulting” it. The built-inpredicateconsult/1 can be used to consult a file from withinProlog:

?- consult('program.pl').

As an abbreviation forconsult/1, you can specify alist ofprogram files, given asatoms:

?- ['program.pl'].

The special notation[user] is used to read Prolog text fromstandard input. For example,

?- [user].hello(declarative_world).hello(pure_world).

PressingRETURN followed byCtrl-d stops reading fromstandard input and consults the entered Prolog text.

After a program is consulted, you can askqueries about thepredicates it defines. For example, with the program shown above:

?- hello(What).   What = declarative_world;  What = pure_world.

PressSPACE to show further answers, if any exist. PressRETURNor . to abort the search and return to thetoplevel prompt. Press f to see up to the next multiple of5 answers, anda to see all answers. Press h to show a helpmessage.

UseTAB to complete atoms and predicate names in queries. Forinstance, after consulting the program above, typingdecl followedby TAB yieldsdeclarative_world. Press TAB repeatedlyto cycle through alternative completions.

To quit Scryer Prolog, use the standard predicatehalt/0:

?- halt.

Starting Scryer Prolog

Scryer Prolog can be started from the command line by specifyingoptions, files and additional arguments. All components are optional:

scryer-prolog [OPTIONS] [FILES] [-- ARGUMENTS]

The supported options are:

   -h, --help             Display help message   -v, --version          Print version information and exit   -g, --goal GOAL        Run the query GOAL after consulting files   -f                     Fast startup. Do not load initialization file (~/.scryerrc)   --no-add-history       Prevent adding input to history file (~/.scryer_history)

All specified Prolog files are consulted.

After Prolog files, application-specific arguments can be specified onthe command line. These arguments can be accessed from within Prologapplications with the predicate argv/1, which yields the listof arguments represented as strings.

Prolog files can also be turned intoshell scripts as explained in#2170 (comment).

Dynamic operators

Scryer supports dynamic operators. Using the built-inarithmetic operators with the usual precedences,

?- write_canonical(-5 + 3 - (2 * 4) // 8), nl.-(+(-5,3),//(*(2,4),8))   true.

New operators can be defined using theop declaration.

First instantiated argument indexing

Scryer Prolog indexes on the leftmost argument that is not a variablein all clauses of a predicate's definition. We call this strategyfirstinstantiated argument indexing.

A key motivation for first instantiated argument indexing is to enableindexing for meta-predicates such asmaplist/N andfoldl/N, whosefirst argument is a partial goal that is a variable in the definitionof these predicates and therefore cannot be used for indexing.

For example, a natural definition ofmaplist/2 reads:

maplist(_, []).maplist(Goal_1, [L|Ls]) :-        call(Goal_1, L),        maplist(Goal_1, Ls).

In this case, first instantiated argument indexing automatically usesthesecond argument for indexing, and thus prevents choicepoints forcalls with lists of fixed lengths (and deterministic goals).Conveniently, no auxiliary predicates with reordered arguments areneeded to benefit from indexing in such cases.

Conventional first argument indexing naturally arises as aspecial case of this strategy, if the first argument is instantiatedin any clause of a predicate's definition.

Strings and partial strings

A very compact internal representation ofstrings is one of the keyinnovations of Scryer Prolog. This means that terms which appear aslists of characters to Prolog programs are stored in packedUTF-8 encoding by the engine.

Without this innovation, storing a list of characters in memory woulduse one WAM memory cell per character, one cell per listconstructor, and one cell for each tail that occurs in the list. Sinceone cell takes 8 bytes in the WAM as implemented byScryer Prolog, the packed representation yields an up to24-fold reduction of memory usage, and correspondingreduction of memory accesses when creating and processingstrings.

Scryer Prolog's compact internal string representation makes itideally suited for the use case Prolog was originally developed for:efficient and convenient text processing, especially with definiteclause grammars (DCGs) as provided bylibrary(dcgs) andlibrary(pio) to transparently apply DCGs to files.

In Scryer Prolog, the default value of the Prolog flagdouble_quotesischars, which is also the recommended setting. This means thatlists of characters can be written as double-quoted strings, in thetradition of Marseille Prolog.

For example, the following query succeeds:

?- "abc" = [a,b,c].   true.

This shows that the string"abc", which is represented as a sequenceof 3 bytes internally, appears to Prolog programs as a list ofcharacters.

Scryer Prolog uses the same efficient encoding forpartial strings,which appear to Prolog code as partial lists of characters. Thepredicatepartial_string/3 fromlibrary(iso_ext) lets youconstruct partial strings explicitly. For example:

?- partial_string("abc", Ls0, Ls).   Ls0 = [a,b,c|Ls].

In this case, and as the answer illustrates,Ls0 isindistinguishable from a partial list with tail Ls, whilethe efficient packed representation is used internally.

An important design goal of Scryer Prolog is toautomatically usethe efficient string representation whenever possible. Therefore, itis only very rarely necessary to usepartial_string/3 explicitly. Inthe above example, postingLs0 = [a,b,c|Ls] yieldsthe exact same internal representation, and has the advantage thatonly the standard predicate (=)/2 is used.

The efficient internal representation of strings and partial stringswas first proposed and explained by Ulrich Neumerkel inissues #24and #95, andScryer Prolog is the first Prolog system that implements it.

Occurs check and cyclic terms

Theoccurs check is an element of algorithms that performsyntactic unification, causing the unification to fail if a variableis unified with a term that contains that variable as a propersubterm. For efficiency, theoccurs check is omitted by defaultin Scryer Prolog and many other Prolog systems.

In Scryer Prolog, unifications which succeed only if theoccurs check is omitted yieldcyclic terms, also calledrational trees. For example:

?- X = f(X), Y = g(X,Y).   X = f(X), Y = g(f(X),Y).

The creation of cyclic terms often indicates a programming mistake inthe formulation of Prolog predicates, and to obtain logically soundresults it is desirable to either perform all unifications withoccurs check enabled, or let Prolog throw an error if enablingtheoccurs check is necessary to prevent a unification.

Scryer Prolog supports this via the Prolog flagoccurs_check. It canbe set to one of the following values to obtain the desired behaviour:

  • falseDo not perform theoccurs check. This is the default.
  • truePerform all unifications with theoccurs check enabled.
  • errorYield an error if a unification is performed that theoccurs check would have prevented.

Especially when starting with Prolog, we recommend to add thefollowing directive to the~/.scryerrc configuration file so thatprogramming mistakes in predicates that lead to the creation of cyclicterms are indicated by errors:

:- set_prolog_flag(occurs_check, error).

Scryer Prolog implements specialized reasoning to make unificationsfast in many frequently occurring situations also if theoccurs check is enabled.

Tabling (SLG resolution)

One of the foremost attractions of Prolog is that logical consequencesof pure programs can be derived by various execution strategiesthat differ regarding essential properties such as termination,completeness and efficiency.

The default execution strategy of Prolog is depth-first search withchronological backtracking. This strategy is very efficient. Its maindrawback is that it isincomplete: It may fail to find any solutioneven if one exists.

Scryer Prolog supports an alternative execution strategy which iscalledtabling and also known as tabled execution andSLG resolution. To enable tabled execution for a predicate, uselibrary(tabling) and add a(table)/1directive for the desired predicate indicator. For example, if wewrite:

:- use_module(library(tabling)).:- table a/0.a :- a.

Then the query?- a.terminates (and fails), whereas itdoes not terminate with the default execution strategy.

Scryer Prolog implements tabling viadelimited continuations asdescribed inTabling as a Library with DelimitedControlby Desouter et. al.

Constraint Logic Programming (CLP)

Scryer Prolog provides excellent support for Constraint LogicProgramming (CLP), which is the amalgamation ofLogic Programming (LP) and Constraints.

In addition to built-in support fordif/2,freeze/2,CLP(B) andCLP(ℤ),Scryer provides a convenient way to implement new user-definedconstraints:Attributed variables are available vialibrary(atts) as in SICStus Prolog,which is one of the most sophisticated and fastest constraint systemsin existence. Inlibrary(iso_ext),Scryer provides predicates for backtrackable (bb_b_put/2) andnon-backtrackable (bb_put/2) global variables, which are needed toimplement certain types of constraint solvers.

These features make Scryer Prolog an ideal platform for teaching,learning and developing portable CLP applications.

Modules

Scryer has a simple predicate-based module system. It provides away to separate units of code into distinct namespaces, for bothpredicates and operators. See the filessrc/lib/*.pl forexamples.

At the time of this writing, many predicates reside in their ownmodules that need to be imported before they can be used.The modules that ship with Scryer Prolog are also calledlibrary modules orlibraries, and include:

  • listsprovidinglength/2,member/2,select/3,append/[2,3],foldl/[4,5],maplist/[2-9],same_length/2,transpose/2 etc.
  • dcgsDefinite Clause Grammars (DCGs), a built-in grammar mechanismthat uses the operator(-->)/2 to define grammar rules,and the predicatesphrase/[2,3] to invoke them.
  • difThe predicatedif/2 provides declarative disequality:It is true if and only if its arguments are different, anddelays the test until a sound decision can be made.
  • reifprovidingif_/3,tfilter/3 and related predicatesas described inIndexing dif/2.
  • clpzCLP(ℤ): Constraint Logic Programming over Integers,providing declarative integer arithmetic via(#=)/2,(#\=)/2,(#>=)/2 etc., and various global constraints andenumeration predicates for solving combinatorial tasks.
  • pairsBy convention,pairs are Prolog terms withprincipal functor(-)/2, written asKey-Value.This library providespairs_keys_values/3,pairs_keys/2, and other predicates to reason about pairs.
  • siThe predicatesatom_si/1,integer_si/1,atomic_si/1andlist_si/1 implement sound type checks. They raiseinstantiation errors if no decision can be made.They are declarative replacements for logically flawedlower-level type tests. For instance, instead ofinteger(X),writeinteger_si(X) to ensure soundness of your programs."si" stands forsufficiently instantiated, and also forsound inference.
  • debugVarious predicates that allow for declarative debugging.
  • piophrase_from_file/2 applies a DCG nonterminal to the contents of afile, reading lazily only as much as is needed. Due to the compactinternal string representation, also extremely large files can beefficiently processed with Scryer Prolog in this way.phrase_to_file/2 andphrase_to_stream/2 write lists ofcharacters described by DCGs to files and streams, respectively.
  • lambdaLambda expressions to simplify higher order programming.
  • charsio Various predicates that are usefulfor parsing and reasoning about characters, notablychar_type/2 toclassify characters according to their type, and conversionpredicates for different encodings of strings.
  • errormust_be/2 andcan_be/2 complement the type checks provided bylibrary(si), and are especially useful forProlog library authors.
  • tablingThe operator(table)/1 is used in directives that preparepredicates for tabled execution (SLG resolution).
  • formatThe nonterminalformat_//2 is used to describe formatted output,arranging arguments according to a given format string.The predicatesformat/[2,3],portray_clause/[1,2] andlisting/1provide formattedimpure output.
  • assocprovidingempty_assoc/1,get_assoc/3,put_assoc/4 etc.to manage elements in AVL trees which ensureO(log(N)) access.
  • ordsetsrepresents ordered sets as lists.
  • clpbCLP(B): Constraint Logic Programming over Boolean variables,a BDD-based SAT solver provided via the predicatessat/1,taut/2,labeling/1 etc.
  • arithmeticArithmetic predicates such aslsb/2,msb/2 andnumber_to_rational/2.
  • time Predicates for reasoning abouttime, includingtime/1 to measure the CPU time of a goal,current_time/1 to obtain the current system time, the nonterminalformat_time//2 to describe strings with dates and times, andsleep/1 to slow down a computation.
  • filesPredicates for reasoning about files and directories, such asdirectory_files/2,file_exists/1 andfile_size/2.
  • contProvidesdelimited continuations viareset/3 andshift/1.
  • randomProbabilistic predicates and random number generators.
  • http/http_open Open a stream toread answers from web servers. HTTPS is also supported.
  • http/http_server Runs a HTTP/1.1 and HTTP/2.0 web server. UsesWarp as a backend. Supports some query and form handling.
  • sgmlload_html/3 andload_xml/3 represent HTML and XML documentsas Prolog terms for convenient and efficient reasoning. Uselibrary(xpath) to extract information fromparsed documents.
  • csvparse_csv//1 andparse_csv//2 can be used withphrase_from_file/2orphrase/2 to parse csv
  • serialization/abnfDCGs describing theABNF grammar core (RFC 5234),which is used to describe manyIETFsyntaxes, such asHTTP v1.1,SMTP,iCalendar, and more.
  • serialization/jsonjson_chars//1 can be used withphrase_from_file/2orphrase/2 to parse and generateJSON.
  • xpathThe predicatexpath/3 is used for convenient reasoning about HTMLand XML documents, inspired by the XPath language. This libraryis often used together withlibrary(sgml).
  • socketsPredicates for opening and accepting TCP connections as streams.
  • osPredicates for reasoning about environment variables.
  • iso_extConforming extensions to and candidates for inclusion in the PrologISO standard, such assetup_call_cleanup/3,call_nth/2 andcall_with_inference_limit/3.
  • cryptoCryptographically secure random numbers and hashes, HMAC-based keyderivation (HKDF), password-based key derivation (PBKDF2),public key signatures and signature verification with Ed25519,ECDH key exchange over Curve25519 (X25519), authenticated symmetricencryption with ChaCha20-Poly1305, and reasoning about elliptic curves.
  • uuid UUIDv4 generation and hex representation
  • tlsPredicates for negotiating TLS connections explicitly.
  • ugraphs Graph manipulation library
  • simplex Providingassignment/2,transportation/4 and other predicates for solving linearprogramming problems.

To use predicates provided by thelists library, write:

?- use_module(library(lists)).

To load modules contained in files, thelibrary functor can beomitted, prompting Scryer to search for the file (specified as anatom) from its working directory:

?- use_module('file.pl').

use_module directives can be qualified by adding a list of imports:

?- use_module(library(lists), [member/2]).

A qualifieduse_module can be used to remove imports from thetoplevel by calling it with an empty import list.

The(:)/2 operator resolves calls to predicates that might not beimported to the current working namespace:

?- lists:member(X, Xs).

The [user] prompt can also be used to define modules inline at theREPL:

?- [user].:- module(test, [local_member/2]).:- use_module(library(lists)).local_member(X, Xs) :- member(X, Xs).

The user listing can also be terminated by placingend_of_file. atthe end of the stream.

Configuration file

At startup, Scryer Prolog consults the file~/.scryerrc, if the fileexists. This file is useful to automatically load libraries and definepredicates that you need often.

For example, a sensible starting point for~/.scryerrc is:

:- use_module(library(lists)).:- use_module(library(dcgs)).:- use_module(library(reif)).

Development environment

To write and edit Prolog programs, we recommendGNU Emacs with theProlog modemaintained by Stefan Bruda.

Useediprolog to consultProlog code and evaluate Prolog queries in arbitraryEmacs buffers.

Emacs definitions that show Prolog terms as trees are availablein tools.

Todebug Prolog code, we recommend the predicates fromlibrary(debug), most notably:

  • (*)/1 to"generalize away" a Prolog goal. Use it to debugunexpected failures by generalizing your definitions until theysucceed. Simply place * in front of a goal to generalize it away.
  • ($)/1 to emit atrace of the execution, showing when a goalis invoked, and when it has succeeded. Place $ in front of a goalto emit this information for that goal.

This way of debugging Prolog code has several major benefits, such as:It stays close to the actual Prolog code under consideration, it doesnot need additional tools and formalisms for its application, andfurther, it encourages declarative reasoning that can in principlealso be performed automatically.

Applications

Scryer Prolog's strong commitment to the Prolog ISO standard makes itideally suited for use in corporations and government agenciesthat are subject to strict regulations pertaining to interoperability,standards compliance and warranty.

Successful existing applications of Scryer Prolog include:

Scryer Prolog is also very well suited for teaching and learningProlog, and for testing syntactic conformance and hence portability ofexisting Prolog programs.

Scryer Prolog Meetups

Scryer Prolog Meetups are an excellent opportunity to present and getto know the latest developments in Scryer Prolog and itsapplications, to exchange ideas about current plans andfuture directions, and to discuss projects and visionsin person.

Support and discussions

If Scryer Prolog crashes or yields unexpected errors, consider filingan issue.

To get in touch with the Scryer Prolog community, participate indiscussionsor visit our #scryer IRC channel onLibera!

About

A modern Prolog implementation written mostly in Rust.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors44

Languages


[8]ページ先頭

©2009-2025 Movatter.jp