-
Notifications
You must be signed in to change notification settings - Fork 34
Home
Yutaka Ichibangase edited this page Feb 11, 2023
·
1 revision
Welcome to the prolog wiki!
-
:- dynamic(PI)Specifies the predicates indicated byPIare dynamic. ISO -
:- multifile(PI)Specified the predicates indicated byPImay be in multiple files. ISO -
:- discontiguous(PI)Specifies the predicates indicated byPImay be defined by clauses which are not consecutive read-terms. ISO -
:- op(Priority, Specifier, Op)Alters the operator table. ISO -
:- char_conversion(In, Out)Alters the character conversion mapping. ISO -
:- initialization(T)Registers a goal for execution right before exitingExec()orExecContext(). ISO -
:- include(F)Loads the content of the fileFas if it were there instead of this directive. ISO -
:- ensure_loaded(P)Loads the content of the filePif not loaded. ISO -
:- set_prolog_flag(Flag, Value)Alters the value for the Prolog flag. ISO
-
trueAlways succeeds. ISO -
failAlways fails. ISO -
call(Goal)CallsGoal. ISO -
!Cut. ISO -
P, QConjunction. ISO -
P; QDisjunction. ISO -
If -> ThenIf-then. ISO -
If -> Then; ElseIf-then-else. ISO -
catch(Goal, Catcher, Recovery)CallsGoal. If an exception is raised and unifies withCatcher, callsRecovery. ISO -
throw(Ball)Raises an exceptionBall. ISO
-
X = YUnifiesXwithY. ISO -
unify_with_occurs_check(X, Y)UnifiesXwithYwith occurs check. ISO -
X \= YSucceeds iffXandYare not unifiable. ISO -
subsumes_term(General, Specific)Succeeds iff there's a substitutionθsuch thatGeneralθ = SpecificθandSpecificθ = Specific. ISO
-
var(X)Succeeds iffXis a variable. ISO -
atom(X)Succeeds iffXis an atom. ISO -
integer(X)Succeeds iffXis an integer. ISO -
float(X)Succeeds iffXis a float. ISO -
atomic(X)Succeeds iffXis neither a variable nor a compound. ISO -
compound(X)Succeeds iffXis a compound. ISO -
nonvar(X)Succeeds iffXis not a variable. ISO -
number(X)Succeeds iffXis either an integer or a float. ISO -
callable(X)Succeeds iffXis either an atom or a compound. ISO -
ground(X)Succeeds iffXis a ground term. ISO -
acyclic_term(X)Succeeds iffXis acyclic. ISO
-
X @=< YEitherX == YorX @< Y. ISO -
X == YEquivalent tocompare(=, X, Y). ISO -
X \== YEquivalent to\+compare(=, X, Y). ISO -
X @< YEquivalent tocompare(<, X, Y). ISO -
X @> YEquivalent tocompare(>, X, Y). ISO -
X @>= YEitherX == YorX @> Y. ISO -
compare(Order, X, Y)ComparesXandYand unifiesOrderwith either<,=, or>. ISO -
sort(List, Sorted)Succeeds iffSortedunifies with a sorted list ofList. ISO -
keysort(Pairs, Sorted)Succeeds iffPairsis a list ofKey-Valuepairs andSortedunifies with a permutation ofPairssorted byKey. ISO
-
functor(Term, Name, Arity)Succeeds iffTermia either a compound term ofNameandArityor an atom ofNameandArity = 0. ISO -
arg(N, Term, Arg)Succeeds iffArgis theN-th argument ofTerm. ISO -
Term =.. ListSucceeds iffListis a list of the functor and arguments ofTerm. ISO -
copy_term(Term1, Term2)Creates a copy ofTerm1and unifies it withTerm2. ISO -
term_variables(Term, Vars)Succeeds iffVarsis a list of variables appear inTerm. ISO
-
Result is ExpressionEvaluatesExpressionand unifies it withResult. ISO-
Expressionis either:-
integer,
-
float, or
-
evaluable functors
X + YX - YX * YX // YX / YX rem YX mod Y-Xabs(X)sign(X)float_integer_part(X)float_fractional_part(X)float(X)floor(X)truncate(X)round(X)ceiling(X)+(X)X div YX ** Ysin(X)cos(X)atan(X)exp(X)log(X)sqrt(X)max(X, Y)min(X, Y)X ^ Yasin(X)acos(X)atan2(X, Y)tan(X)piX >> YX << YX /\ YX \/ Y\Xxor(X, Y)
-
-
-
succ(X, S)Succeeds iffSis the successor of the non-negative integerX. prologue
-
E1 =:= E2Succeeds iffE1andE2are evaluated toEV1andEV2respectively andEV1equals toEV2. ISO -
E1 =\= E2Succeeds iffE1andE2are evaluated toEV1andEV2respectively andEV1does not equal toEV2. ISO -
E1 < E2Succeeds iffE1andE2are evaluated toEV1andEV2respectively andEV1is greater thanEV2. ISO -
E1 =< E2Succeeds iffE1andE2are evaluated toEV1andEV2respectively andEV1is greater than or equal toEV2. ISO -
E1 > E2Succeeds iffE1andE2are evaluated toEV1andEV2respectively andEV1is less thanEV2. ISO -
E1 >= E2Succeeds iffE1andE2are evaluated toEV1andEV2respectively andEV1is less than or equal toEV2. ISO
-
clause(Head, Body)Succeeds iffHead :- Bodyunifies with a clause in the DB. ISO -
current_predicate(PI)Succeeds iff the predicate indicated byPIis in the DB. ISO
-
asserta(Clause)PrependsClauseto the DB. ISO -
assertz(Clause)AppendsClauseto the DB. ISO -
retract(Clause)Removes a clause that unifies withClausefrom the DB. ISO -
abolish(PI)Removes the predicate indicated byPIfrom the DB. ISO -
retractall(Head)Removes all the clauses which head unifies withHeadfrom the DB. ISO
-
findall(Template, Goal, Instances)Succeeds iffInstancesunifies with a list ofTemplatefor each solution ofGoal. ISO -
bagof(Template, Goal, Instances)Succeeds iffInstancesunifies with a bag (multiset) ofTemplatefor each solution ofGoal. ISO -
setof(Template, Goal, Instances)Succeeds iffInstancesunifies with a set ofTemplatefor each solution ofGoal. ISO
-
current_input(Stream)Succeeds iffStreamunifies with the current input stream. ISO -
current_output(Stream)Succeeds iffStreamunifies with the current output stream. ISO -
set_input(S_or_a)Sets the current input stream to the stream indicated byS_or_awhich is either the stream itself or its alias. ISO -
set_output(S_or_a)Sets the current output stream to the stream indicated byS_or_awhich is either the stream itself or its alias. ISO -
open(File, Mode, Stream, Options)Opens the fileFileinModewithOptionsand unifies the stream withStream. ISO-
Modeis either:read,write, orappend. -
Optionsis a list of stream options listed below:-
type(T)Specifies the type of the stream.Tis eithertext(default) orbinary. -
reposition(Bool)Specifies if the stream can be repositions.Boolis eithertrueorfalse. -
alias(A)Specifies the alias for the stream.Ais an atom. -
eof_action(Action)Specifies the action that will be taken when the input stream reached to the end.Actionis either:-
errorwhich throws an exception, -
eof_codewhich returns a value indicating the end of stream (default), or -
resetwhich resets the stream.
-
-
-
-
open(File, Mode, Stream)Equivalent toopen(File, Mode, Stream, []). ISO -
close(S_or_a, Options)Closes the stream indicated byS_or_awhich is the stream itself or its alias. ISO-
Optionsis a list of:-
force(Bool)Specifies if an exception will be raised when it failed to close the stream.Boolis eitherfalse(default) ortrue.
-
-
-
close(S_or_a)Equivalent toclose(S_or_a, []). ISO -
flush_output(S_or_a)Sends any buffered output to the stream indicated byS_or_awhich is either the stream itself or its alias. ISO -
flush_outputEquivalent tocurrent_output(S), flush_output(S). ISO -
stream_property(Stream, Property)Succeeds iff the streamStreamhas the propertyProperty. ISO-
Propertyis either:file_name(F)mode(M)inputoutputalias(A)position(P)end_of_stream(E)eof_action(A)reposition(Bool)type(T)
-
-
at_end_of_streamEquivalent tocurrent_input(S), at_end_of_stream(S). ISO -
at_end_of_stream(S_or_a)Succeeds iff the stream indicated byS_or_awhich is either a stream or an alias has the property eitherend_of_stream(at)orend_of_stream(past). ISO -
set_stream_position(S_or_a, Position)Sets the position of the stream indicated byS_or_awhich is either a stream or an alias to the positionPosition. ISO
-
get_char(S_or_a, Char)Succeeds iffCharunifies with the next character from the stream indicated byS_or_awhich is either a stream or an alias. ISO -
get_char(Char)Equivalent tocurrent_input(S), get_char(S, Char). ISO -
get_code(S_or_a, Code)Succeeds iffCharunifies with the next code from the stream indicated byS_or_awhich is either a stream or an alias. ISO -
get_code(Code)Equivalent tocurrent_input(S), get_code(S, Code). ISO -
peek_char(S_or_a, Char)Similar toget_char(S_or_a, Char)but doesn't consume the character. ISO -
peek_char(Char)Equivalent tocurrent_input(S), peek_char(S, Char). ISO -
peek_code(S_or_a, Code)Similar toget_code(S_or_a, Code)but doesn't consume the code. ISO -
peek_code(Code)Equivalent tocurrent_input(S), peek_code(S, Code). ISO -
put_char(S_or_a, Char)Outputs the characterCharto the stream indicated byS_or_awhich is either a stream or an alias. ISO -
put_char(Char)Equivalent tocurrent_output(S), put_char(S, Char). ISO -
put_code(S_or_a, Code)Outputs the codeCodeto the stream indicated byS_or_awhich is either a stream or an alias. ISO -
put_code(Code)Equivalent tocurrent_output(S), put_code(S, Code). ISO -
nl(S_or_a)Outputs a newline to the stream indicated byS_or_awhich is either a stream or an alias. ISO -
nlEquivalent tocurrent_output(S), nl(S). ISO
-
get_byte(S_or_a, Byte)Succeeds iffByteunifies with the next byte from the stream indicated byS_or_awhich is a stream or an alias. ISO -
get_byte(Byte)Equivalent tocurrent_input(S), get_byte(S, Byte). ISO -
peek_byte(S_or_a, Byte)Similar toget_byte(S_or_a, Byte)but doesn't consume the byte. ISO -
peek_byte(Byte)Equivalent tocurrent_input(S), peek_byte(S, Byte). ISO -
put_byte(S_or_a, Byte)Outputs the byteByteto the stream indicated byS_or_awhich is either a stream or an alias. ISO -
put_byte(Byte)Equivalent tocurrent_output(S), put_byte(S, Byte). ISO
-
read_term(S_or_a, Term, Options)Succeeds iffTermunifies with the next term from the stream indicated byS_or_awhich is a stream or an alias. ISO-
Optionsis a list of read options listed below:-
variables(Vars)the list of variables appeared inTerm -
variable_names(VN_list)the list ofA = VwhereAis an atom which name is the string representation ofVandVis a variable appeared inTerm -
singletons(VN_list)similar tovariable_names(VN_list)but those of variables that appeared once.
-
-
-
read_term(Term, Options)Equivalent tocurrent_input(S), read_term(S, Term, Options). ISO -
read(S_or_a, Term)Equivalent toread_term(S_or_a, Term, []). ISO -
read(Term)Equivalent tocurrent_input(S), read(S, Term). ISO -
write_term(S_or_a, Term, Options)OutputsTermto the stream indicated byS_or_awhich is either a stream or an alias. ISO-
Optionsis a list of write options listed below:-
quoted(Bool)Boolis eithertrueorfalse. Iftrue, atoms and functors will be quoted as needed. -
ignore_ops(Bool)Boolis eithertrueorfalse. Iftrue, operators will be written in functional notation. -
variable_names(VN_list)VN_listis a proper list which element is a form ofA = VwhereAis an atom andVis a variable. Each occurrence ofVwill be replaced by the leftmost and unquotedA. -
numbervars(Bool)Boolis eithertrueorfalse. Iftrue, terms'$VAR'(0),'$VAR'(1), ... will be written asA,B, ...
-
-
-
write_term(Term, Options)Equivalent tocurrent_output(S), write_term(S, Term, Options). ISO -
write(S_or_a, Term)Equivalent towrite_term(S_or_a, Term, [numbervars(true)]). ISO -
write(Term)Equivalent tocurrent_output(S), write(S, Term). ISO -
writeq(S_or_a, Term)Equivalent towrite_temr(S_or_a, Term, [quoted(true), numbervars(true)]). ISO -
writeq(Term)Equivalent tocurrent_output(S), writeq(S, Term). ISO -
write_canonical(S_or_a, Term)Equivalent towrite_term(S_or_a, Term, [quoted(true), ignore_ops(true)]). ISO -
write_canonical(Term)Equivalent tocurrent_output(S), write_canonical(S, Term). ISO -
op(Priority, Specifier, Operator)Alters the operator table. ISO -
current_op(Priority, Specifier, Operator)Succeeds iff the operator indicated byPriority,Specifier,Operatoris in the operator table. ISO -
char_conversion(In, Out)Alters the character conversion mapping. ISO -
current_char_conversion(In, Out)Succeeds iff the character conversion fromIntoOutis in the conversion mapping. ISO
-
\+GoalSucceeds iffcall(Goal)fails. ISO -
once(Goal)CallsGoalbut never redoes. ISO -
repeatRepeats the following code until it succeeds. ISO -
call(Closure, Arg1, ..., ArgN)N = 1..7. Succeeds iffcall(Goal)whereGoalisClosurewith additional argumentsArg1, ..., ArgN. ISO -
falseEquivalent tofail. ISO -
between(Lower, Upper, X)Succeeds iffLower <= X <= Upper. prologue
-
atom_length(Atom, Length)Succeeds iffLengthis the number of runes inAtom. ISO -
atom_concat(Atom1, Atom2, Atom3)Succeeds iffAtom3is a concatenation ofAtom1andAtom2. ISO -
sub_atom(Atom, Before, Length, After, SubAtom)Succeeds iffSubAtomis a sub atom ofAtomwhereBeforeis the number of runes beforeSubAtom,Lengthis the length ofSubAtom, andAfteris the number of runes afterSubAtom. ISO -
atom_chars(Atom, List)Succeeds iffListis the list of single-rune atoms thatAtomconsists of. ISO -
atom_codes(Atom, List)Succeeds iffListis the list of runes thatAtomconsists of. ISO -
char_code(Char, Code)Succeeds iffCharis a single-rune atom which rune isCode. ISO -
number_chars(Number, List)Succeeds iffListis the list of single-rune atoms that representsNumber. ISO -
number_codes(Number, List)Succeeds iffListis the list of runes that representsNumber. ISO
-
set_prolog_flag(Flag, Value)Sets the Prolog flagFlagtoValue. ISO-
Flagis either:-
char_conversionValueis eitheronoroff(default). -
debugValueis eitheronoroff(default). -
unknownValueis eithererror(default),fail, orwarning. -
double_quotesValueis eitherchars(default),codes, oratom.
-
-
-
current_prolog_flag(Flag, Value)Succeeds iffValueis the current value for the Prolog flagFlag. ISO-
Flagis either:-
boundedValueis alwaystrue. -
max_integerValueis always9223372036854775807. -
min_integerValueis always-9223372036854775808. -
integer_rounding_functionValueis alwaystoward_zero. -
char_conversionValueis eitheronoroff(default). -
debugValueis eitheronoroff(default). -
max_arityValueis alwaysunbounded. -
unknownValueis eithererror(default),fail, orwarning. -
double_quotesValueis eitherchars(default),codes, oratom.
-
-
-
halt(X)Exits the host program with the status code ofX. ISO -
haltEquivalent tohalt(0). ISO
-
expand_term(In, Out)Succeeds iffOutis an expansion of the termIn. -
phrase(Phrase, List, Remainder)Succeeds iff the different listList-Remaindersatisfies the grammar rulePhrase. -
phrase(Phrase, List)Equivalent tophrase(Phrase, List, []).
-
member(X, L)Succeeds iffXis a member of the listL. prologue -
append(Xs, Ys, Zs)Succeeds iffZsis the concatenation ofXsandYs. prologue -
length(List, Length)Succeeds iffLengthis the length ofList. prologue -
select(X, Xs, Ys)Succeeds iffXis an element ofXsandYsisXswith one occurence ofXremoved. prologue -
maplist(Goal, List1, ..., Listn)n = 1..7. Succeeds iffList1, ..., Listnare the list of the same length andcall(Goal, List1_i, ..., Listn_i)succeeds for all thei-th elements ofList1, ..., Listn. prologue -
nth0(N, List, Elem)Succeeds iffElemis theN-th element ofListcounting from 0. -
nth1(N, List, Elem)Succeeds iffElemis theN-th element ofListcounting from 1.
-
consult(File)Loads Prolog program files indicated byFile.Fileis either an atom or a list of atoms. An atomabcindicates a Prolog program file./abcor./abc.pl. -
[File|Files]Equivalent toconsult([File|Files]).