$ dprolog
?-
With an initialization file:
$ dprolog -f example/family.pro
?-
?- male(X).
X = bob;
X = tom;
X = jim.
?- halt.
or input ctrl+c
or ctrl+d
to stop D-Prolog.
-h
,--help
: Print a help message-v
,--version
: Print version of dprolog-f
,--file=VALUE
: ReadVALUE
as an initialization file--verbose
: Print diagnostic output
example/family.pro
example/list.pro
example/factorial.pro
example/if.pro
Input a query ?- [<file path>].
while running as follows:
?- [`file.pro`].
?- [`/path/to/file.pro`].
Input a query ?- [user].
, and you will be able to add rules from the console:
?- [user].
|: hoge(poyo).
|:
Input ctrl+c
or ctrl+d
to exit from the mode for adding rules.
?- hoge(X).
X = poyo.
The %-style line comments are supported.
?- X = 1. % This is a comment.
X = 1.
?- X = [a, b, c].
X = [a, b, c].
?- X = [a | [b, c]].
X = [a, b, c].
?- X = 10. % A decimal literal
X = 10.
?- X = 0b1010. % A binary literal
X = 10.
?- X = 0xff. % A hexadecimal literal
X = 255.
?- X is 1 + 2.
X = 3.
?- X = 10, Y is X * X - 1.
X = 10, Y = 99.
?- 10 < 100.
true.
$ dprolog -f list.pro
Conjunctions:
?- member(X, [1, 2, 3]), member(X, [3, 4]).
X = 3;
false.
Disjunctions:
?- member(X, [1, 2, 3]); member(X, [3, 4]).
X = 1;
X = 2;
X = 3;
X = 3;
X = 4;
false.
Conjuctions and disjunctions:
?- member(X, [1, 2, 3]); member(X, [3, 4]), X > 3.
X = 1;
X = 2;
X = 3;
X = 4.
?- (member(X, [1, 2, 3]); member(X, [3, 4])), X > 3.
X = 4.
?- X = 1; X = 2.
X = 1;
X = 2.
?- X = 1, !; X = 2.
X = 1.
Load example/if.pro
, then
?- if(true, X = 1, X = 2).
X = 1.
?- if(false, X = 1, X = 2).
X = 2.
If you want to know more about D-Prolog, see Specification.