! abolish / 2. abolish(Name, Arity) -------------------- Removes all dynamic clauses defining predicate Name/Arity. ! abort / 1. abort(Severity) --------------- Severity should be bound to an integer: 0, 1 or 2. Severity = 0 --> Close and flush all opened files, reset the environment return the the Prolog top level listener. Severity = 1 --> Close and flush all opened files, and return to MSDOS returning a 'normal termination' code. Severity = 2 --> As severity = 1 except returns an abnormal termination condition to MSDOS. ! arg / 3. arg(Index, Term, Arg) --------------------- Arg must be instantiated to a positive integer less than or equal to the number of arguments in structure Term. Then succeeds if Arg can be unified with the Arg'th argument of Term. Otherwise the call fails. ! aritherrors / 0. aritherrors, noaritherrors, aritherrors(X) ------------------------------------------ Aritherrors is a Cogent Prolog mode switch. If on (?- aritherrors. ) then any runtime errors resulting from a bad arithmetic expression being evaluated raise an error. If noaritherrors is in force then the result of the evaluation is the special atom '!IS'. aritherrors(X) succeeds binding X to 0 if noaritherrors is in force else binds X to 1. ! assert / 1. assert(Term) ------------ Adds Term to the End of the database. Term must be a valid clause: - a structure - an atom - a clause of the form (Head :- Body) Note that in the latter case the Term must be surrounded in ( ) to prevent a reader error: assert((foo :- bar)) and not assert(foo :- bar) ! asserta / 1. asserta(Term) ------------- Adds Term to the Begining of the database. Term must be a valid clause: - a structure - an atom - a clause of the form (Head :- Body) Note that in the latter case the Term must be surrounded in ( ) to prevent a reader error: asserta((foo :- bar)) and not asserta(foo :- bar) ! assertz / 1. assertz(Term) ------------- Adds Term to the End of the database. Term must be a valid clause: - a structure - an atom - a clause of the form (Head :- Body) Note that in the latter case the Term must be surrounded in ( ) to prevent a reader error: assertz((foo :- bar)) and not assertz(foo :- bar) ! atom/1. atom(Term) ---------- Succeeds if and only if Term is bound to an atom. ! atomic/1. atomic(Term) ------------ Succeeds if and only if Term is bound to either an atom or a number. ! findall / 3. findall(X, Y, L) ---------------- Succeeds if it can unify L with the list of all those Xs such that Y is provable. For example ?- findall(X, for(X, 1, 100, 1), L). succeeds instantiating L to the list [1,2,...,100]. If Y is not proveable for any values of X then instantiate L to []. ! bios / 9. bios(Int,AX,BX,CX,DX,NAX,NBX,NCX,NDX) ------------------------------------- In, AX, BX, CX and DX should be bound to arithmetic expressions. Succeeds by causing bios interrrupt number Int to be raised with the AX,BX,CX,DX registers set to the given values. When the interrupt returns the new valus of the AX - DX registers are unified with the arguments NAX - NDX. ! bios / 11. bios(Int,AX,BX,CX,DX,NAX,NBX,NCX,NDX,DS,ES) ------------------------------------------- In, AX, BX, CX, DX, DS and ES should be bound to arithmetic expressions. Succeeds by causing bios interrrupt number Int to be raised with the AX,BX,CX,DX,DS,ES registers set to the given values. When the interrupt returns the new values of the AX - DX registers are unified with the arguments NAX - NDX. ! call / 1. call(X) ------- Treats term X as a predicate to be proved - so X must be bound to an atom or a structure. Succeeds if the proof of X succeeds, otherwise call(X) fails. ! chdir/2. chdir(Dir, Err) --------------- Dir should be bound to an atom which is the name of a directory. Changes current directory to be Dir. Err is unified with the DOS error code returned by the chdir call - 0 if the directory was changed successfully. ! delfile/2. delfile(File, Err) ----------------- File should be bound to an atom which is the (path) name of a file. An attempt is made to delete the file. Err is unified with the DOS error code returned by the delfile call - 0 if the directory was changed successfully. ! clause / 2. clause(Head, Body) ------------------ Head should be bound to an atom or a structure. The first dynamic clause whose head unifies with Head and whose Body unifies with Body causes clause/2 to succeed. On backtracking then looks for the next dynamic clause whose Head and Body match. Again succeeds. Fails if no more clauses can be found. ! cntr_get / 2. cntr_get(CntrNum, Value) ------------------------ Cogent Prolog maintains five Counters (labelled 0 through 4). A counter is a global register containing and integer which can be read and written by any Prolog program. cntr_get/2 succeeds if it can unify the value of counter CntrNum with Value. ! cntr_set / 2. cntr_set(CntrNum, Value) ------------------------ Cogent Prolog maintains five Counters (labelled 0 through 4). A counter is a global register containing and integer which can be read and written by any Prolog program. cntr_set/2 succeeds by setting the value of counter CntrNum to Value. ! comm / 1. comm(Command) ------------- Command should be bound to an atom or a list of characters which represents an MSDOS command. A new copy of the MSDOS command processor is invoked to process Command (which may be either an internal MSDOS command or a .com or a .exe file). Cogent Prolog remains resident while Command is processed and then Prolog is reentered. Notice that since MSDOS knows nothing of windows, the integrity of the Prolog windows screen may be damaged. See also command / 1. ! command / 1. command(Command) ---------------- Command should be bound to an atom or a list of characters which represents an MSDOS command. A new copy of the MSDOS command processor is invoked to process Command (which may be either an internal MSDOS command or a .com or a .exe file). Cogent Prolog remains resident while Command is processed and then Prolog is reentered. The MSDOS command is run in a borderless, white-on-black full screen window which is removed once the command has run. Consequently, invoking a command using command/1 rather than comm / 1 will not destroy the integrity of the Prolog windows system. ! command_line / 1. command_line(CL) ---------------- Succeeds if it can unify CL with a list whose elements are list of ASCII characters. Each sub-list is a token from the command line used to invoke the current copy of Prolog. A token is a portion of the command line delimited by spaces. The first token is always the path name of the prorun file. For example, had prolog been invoked by the commadn line A> prorun -f foo.bin -x the command_line(CL) would cause CL to be unified with the list ["prorun", "-f", "foo.bin", "-x"] ! compare/3. compare(E, T1, T2) ------------------ Succeeds by unifying E with the atom ==, < or > as T1 == T2, T1 @< T2 or T1 @> T2. Where @> is the standard ordering. The standard ordering orders terms as follows (in order): Unbound Variables (Oldest first) Database references (approximately age of clause they reference) Numbers Atoms (lexicographic - telephone book - ordering) Strings ( "" "" "" ) Structures (Ordered by Name / Arity and then arguments) See the manual for greater detail about standard ordering ! consult/1. consult(FileName) ----------------- If FileName is an atom corresponding to the name of a Prolog source file or a compiled Prolog file or application then load the code in that file and succeed. If FileName is a list of atoms of names of such files then load each file in sequence. ! current_atom / 1. current_atom(A) --------------- If A is bound to an atom then current_atom(A) succeeds. If A is an unbound variable then current_atom(A) succeeds by binding A to an atom known to the system. On backtracking, A gets bound to another atom. The order in which the Atoms are bound to A is system dependent. ! cut_tag / 1. cut_tag(Term) ------------- Looks back along the execution stack trying to find a choice point (a stage in the proof that Prolog could backtrack to) which has been marked, using tag/1, with a term which unifies with Term. All the more recent choice points are removed. Consequently, if failure occurs after cut_tag succeeds then the program will backtrack to the choicepoint marked with Term. See also tag/1. ! db_ref/3. db_ref(Head, Body, Ref) ----------------------- If Ref is bound to a databse reference then succeed if you can unify Head and Body with the clause referenced by Ref. If Head and Body are well instantiated to identify an existing dynamic clause (i.e. Head is an atom or a structure) then unify Head with the Head of the clause, Body with the body of the clause and Ref with the database reference of the clause. ! debug / 0. debug ----- Requires debugger.sys be loaded. Turns on the debugger: . Splits the screen . Passes all calls to Prolog interpreter to the debugger. The first spy pointed clause to be entered causes the debugger to trigger and the user is deposited at the port. See also notrace/0 and spy/1. ! erase/1. erase(DBref) ------------ DBref must be bound to a valid database reference. The corresponding database entry is deleted. ! err_msg/2. err_msg(ErrNum, Msg) -------------------- ErrNum must be bound to an integer. If ErrNum is a valid error number then Msg is unified with the list of characters of the corresponding error message. If ErrNum is not a valid error number then Msg gets bound to the list "Unknown Error". ! err_raise/1. err_raise(Number) ----------------- Raises soft error number Number (which should be a negative number). Note that this need not be a predefined error number - a user may define and raise his own errors. However, we reserve error numbers -1 to -256 for our own use. ! err_read/2. err_read(List, Index) --------------------- If an error occured during the last read() then List will be unified with the List of characters read in, and Index will be unified with the index in the list of the point at which the reader decided an error had occurred. ! expand_term/2. expand_term(In, Out) -------------------- The Prolog listener, consult() and reconsult() all process the term just read in through expand_term/2. They pass the term in through the first argument, and actually interpret (or assert, depending on the calling predicate) the term passed out the Out. The default definition is expand_term(X, X) but user programs are at liberty to define expand_term as they wish. For instance, the Definite Clause Grammar compiler (in dcgcomp.sys and the Prolog compiler) have the definition expand_term((A --> B), (HeadA :- BodyB)) :- dcgcompile((A,B), (HeadA,BodyB)). so terms of the form A --> B are 'compiled' to their raw Prolog form before being asserted into the database. ! fail / 0. fail ---- Always fails. ! fatalerrors/0. fatalerrors, nofatalerrors, fatalerrors(X) ------------------------------------------ Fatalerrors is a Cogent Prolog mode switch. If on (?- fatalerrors. ) then any HARD errors (see Error section in manual for hard errors) will cause the Prolog session to be terminated after the error message is printed. If nofatalerrors is in force then the hard error will cause suspension of the current execution and print out an error message in a pop up window. When the user hits the Esc key the Prolog environment will be reset and the user returned to the top level Prolog listener. fatalerrors(X) succeeds binding X to 0 if nofatalerrors is in force else binds X to 1. ! fclose_ / 1. fclose_(H) ---------- fclose_/1 is a routine used internally by Cogent Prolog. It is used to actually close the file or window specified by fclose/1 or wn_close/1. If fclose_/1 raises an error it will be because fclose/1 or wn_close/1 was called with a bad argument. The argument must be a valid file handle H which instantiated by either wn_open(H, w(..)) or fopen(H, FileSpec, Mode) or H can be the special handle -1 or -2. ! fclose/1. fclose(H) --------- H must be a handle returned by fopen() or wn_open(). Flushes and closes the associated file, or closes and removes the associated window. ! fflush/1. fflush(H) --------- H must be a handle returned by fopen() for a file opened in write or append mode. Any data in memory which is waiting to be written out to the file is force written. ! file_exists/1. file_exists(File) ----------------- File is an atom representing the path name of a file. file_exists(File) succeeds if File exists. ! file_exists/2. file_exists(File, Type) ----------------------- File is an atom representing the path name of a file. Succeeds if it can unify Type with 1 if file is a Prolog object file 0 if file is (probably) an ascii file ! fileerrors/0. fileerrors, nofileerrors, fileerrors(X) -------------------------------------- If fileerrors mode is active then any errors which occur while processing a file (e.g. file does not exist, disk is full etc) will raise an error. If fileerrors mode is inactive then any such error will simply cause the appropriate predicate to fail. fileerrors sets fileerror mode. nofileerrors make file errors inactive. And fileerrors(X) unifies X with 1 or 0 as file errors are active or not. ! float / 1. float(F) -------- Succeeds if and only if F is bound to a floating point number. ! fopen_/3. fopen_(Handle, Name, Key) ------------------------- fopen_ is a predicate used internally by the Prolog library. An error here is most probably due to a bad parameter passed into fopen/3. ! fopen/3. fopen(Handle, Name, Mode) ------------------------- Opens file whose name is the atom Name in mode Mode where Mode is one of: r -- read (ascii) rb -- read (binary) w -- write(ascii) wb -- write (binary) a -- append (ascii) ab -- append (binary) In ascii mode, the ascii character sequence gets mapped to if the file is opened for reading. Conversely, on writing, the character is mapped to . If the file is opened in w or wb mode the file is erased first if it exists. If the file is opened in append mode then writing occurs at the end of the file if it exists, otherwise it is created. ! for / 4. for(Index, Lower, Upper, Increment) ----------------------------------- The first time it is proved, for() unifies Index with Lower. If Index is <= Upper then it succeeds. On backtracking, Increment is added to Index and the range check performed again. Finally it fails. ! fread/3. fread(H, Val, Type) ------------------- H should be the handle of a file opened in read binary or append binary mode. Type is an integer 0 - read one byte 1 - read one 16 bit word 2 - read one 32 bit floating point number The read takes place at the current file position and the appropriate value unified with Val. ! fseek/4. fseek(H, Offset, Method, NewLoc) -------------------------------- H should be the handle of file opened in binary mode. The file pointer is repositioned to be Offset (an integer or a float) bytes from the starting point. The newlocation position is unified with NewLoc. The starting point is defined by integer Method: 0 - the beginning of the file 1 - the current position 2 - the end of the file ! functor/3. functor(Term, Name, Arity) -------------------------- 1. If Term is instantiated to an atom then functor/3 succeeds if Name can be unified with the atom and Arity can be unified with 0. 2. If Term is instantiated to a structure then functor/3 suceeds if Name can be unified with the name of the structure and Arity with its Arity. 3. If Name is bound to an atom and Arity to an integer > 0 then succeeds if Term can be unified with the structure whose name is Name, whose arity is arity, and whose arguments are distinct variables. If Arity is bound to 0 then succeeds if Term can be unified with the atom Name. If none of the above hold then fail. ! fwrite/3. fwrite(Handle, Value, Type) --------------------------- Writes Value to the file specified by Handle. Type is one of 0 -- the value is an integer 0 <= Value <= 255. Write one byte to file 1 -- the value is a 16 bit integer. Write out the integer as two bytes. 2 -- the value is a float. Write out the float as four bytes. ! gc / 0. gc -- gc invokes garbage collection of discarded clause space and discarded string space. As much of this unused memory as possible is returned to Prolog for later use. ! gc/1. gc(Type) ________ gc(Type) garbage collects according to Type: 1 - collect strings only 2 - collect clauses only 3 - collect both clauses and strings If verbose mode is on then each time gc occurs a message will be flashed in an overlayed window at the bottom of the screen. See also verbose/0. ! get / 1. get(X) ------ get(X) succeeds if X can be unified with the ASCII value of the next non whitespace character read in from current input. Whitespace is any character whose ASCII code is less than or equal 32. X is unified with the atom '!EOF' if an end of file condition is raised during the read. ! get / 2. get(H, X) --------- get(H, X) succeeds if X can be unified with the ASCII value of the next non whitespace character read in from current file whose handle is H. Whitespace is any character whose ASCII code is less than or equal 32. X is unified with the atom '!EOF' if an end of file condition is raised during the read. ! get0 / 1. get0(X) ------- get0(X) succeeds if X can be unified with the ASCII value of the next character read in from current input. X is unified with the atom '!EOF' if an end of file condition is raised during the read. ! get0 / 2. get0(H, X) ---------- get0(H, X) succeeds if X can be unified with the ASCII value of the next character read in from current file whose handle is H. X is unified with the atom '!EOF' if an end of file condition is raised during the read. ! get0_noecho/1. get0_noecho(X) -------------- Succeeds if X can be unified with the ASCII value of the next character in the user's keyboard. If there is a character waiting in the keyboard then return immediately, otherwise wait for the character to be typed. Typed characters are not echoed to the screen. ! halt / 0. halt ---- Any open files are flushed and closed. Prolog is quit and the user returned to MSDOS. ! help/0. help ---- [Only valid when the help system is loaded]. Presents the user with a menu of choices for this help file. Allows a user to select a topic (using cursor keys and ENTER) and then displays one page of help text on the predicate. ! help/1. help(Name/Arity) ---------------- [Only valid when the help system is loaded]. Gives a page of help on predicate Name/Arity. Name must be bound to an atom, Arity must be an integer or a variable. In the latter case, the system will instantiate Arity to a valid number for which it has help and display the help. ! instance / 2. instance(DBref, Term) --------------------- DBref should be bound to a valid database reference. Succeeds if Term can be unified with the clause at DBref. ! integer / 1. integer(X) ---------- Succeeds if and only if X is bound to an integer. ! is/2. X is Y ------ Succeeds if X is unifiable with Y evaluated as an arithmetic expression. Thus Y must be either a number or a structure composed of numbers and the operators: + /\ / \/ // \ * << - >> and the special structures sin(X) cos(X) tan(X) asin(X) acos(X) atan(X) e pi integer(X) float(X) ln(X) exp(X) ! leash / 1. leash(Ports) ------------ Only defined when the debugger is loaded. Decides at which ports (call, exit, fail, redo) the debugger will stop and prompt for input. Ports can either be one of the standard ports or a list of ports. leash([]) turns off all leashing. ! lint / 0. lint, nolinst, lint(X) ---------------------- lint is a Cogent Prolog mode. When active, lint causes a read error to be raised if a term read in contains named variables which occur only once in the clause. Thus it restricts anonymous variables to being named '_' only. This is very useful for catching typographical errors. lint turns on lint mode. nolint turns it off. lint(X) unifies X with 0 if lint mode is off, otherwise unifies it with 1. ! list/1. list(Term) ---------- Succeeds if and only if Term is bound to a non empty list. ! listing/1. listing(Name/Arity) ------------------- If the predicate whose name is Name and arity is Arity is defined by clauses in the dynamic database then list the clauses for the predicate at the current output stream. ! listing/0. listing ------- List all predicates defined by dynamic clauses at the current output stream. ! mem_word/3. mem_word(Seg, Off, X) --------------------- Seg and Off should be bound to integers corresponding to a valid Segment:Offset address in the PC's memory. If X is unbound then it is unified with the 16 bit integer at the address. Otherwise X should be bound to an integer which is written to memory at the given address. USE WITH GREAT CARE =================== ! mem_byte/3. mem_byte(Seg, Off, X) --------------------- Seg and Off should be bound to integers corresponding to a valid Segment:Offset address in the PC's memory. If X is unbound then it is unified with the 8 bit integer at the address. Otherwise X should be bound to an small integer which is written to the byte at the given address. USE WITH GREAT CARE =================== ! mkdir/2. mkdir(Dir, Err) --------------- Dir should be bound to an atom which is the name of a directory. Creates a directory whose path is Dir. Err is unified with the DOS error code returned by the mkdir call - 0 if the directory was created successfully. ! name/2. name(Atom, List) ---------------- If Atom is bound to an atom then succeed if List can be unified with the list whose elements are ASCII values of the character in the name of atom. Otherwise if List is a list of ASCII values (integers between 0 and 255) then succeed if Atom can be unified with the atom whose name is given by the characters whose ascii values are in List. If neither case holds then fail. Note that List may contain any valid ascii character values - thus Atom may well have symbols that would require that Atom would have to be 'quoted' if it were read through the standard Prolog reader. ! nl / 0. nl -- Writes carriage return - line feed at the current output stream. ! nl / 1. nl(H) ----- Write carriage return - line feed at the specified file whose handle is H. ! nonvar/1. nonvar(X) --------- Succeeds if and only if X is not an unbound variable ! nospy / 1. nospy(Name/Arity) ----------------- Only defined when debugger.sys is loaded. Removes spy point from predicate Name/Arity. ! nospyall/0. nospyall -------- Only defined when debugger.sys is loaded. Removes all current spy points. ! not/1. not(X) ------ Attempts to prove X, which must be a structure or an atom. not(X) succeeds if and only if the proof of X fails. ! notrace / 0. notrace ------- Only defined when debugger.sys is loaded. Turns off debugging. Closes the debugger window. Does not remove any spy points (use nospy/1 or nospyall / 0). ! number/1. number(X) --------- Succeeds if and only if X is bound to a number (integer or float). ! numbervars/3. numbervars(Term, LowerIndex, UpperIndex) ---------------------------------------- Unifies the variables in Term with structures of the form var$$(N) for some integers N. N begins at value LowerIndex (which must be bound to an integer). Upper index is unified with LowerIndex + # of different variables in Term. ! op / 3. op(Prec, Assoc, Op) ------------------- Atom (or list of Atoms) Op is defined to be an operator whose precedence is integer Prec and whose associativity is defined by atom Assoc: fx xfx fy xfy xf yfx yf yfy See section on operators in the Manual for detailed explanantion of how operators work. ! port/2. port(PortId, Value) ------------------- PortId must be bound to a small integer (0 <= 255). This specifies one of the PC's ports. If Value is unbound then it is unified with the small integer corresponding to the 8 bit value read from the port at the given ID. Otherwise, Value must be bound to a small integer. This value is written to the port at the given address. ! pp / 1. pp(X) ----- A rudimentary pretty printer. pp(X) first trys to call user_pp(X) to display X. If user_pp / 1 has not been defined then the default behaviour of pp is to print X at the current output in a prettified form. Clauses a spread across a number of lines, one goal per line, and indented. ! put/1. put(X) ------ The character whose ASCII value is X is printed at the current output stream. ! put/2. put(H, X) --------- The character whose ASCII value is X is printed at the current output at the file, opened in write mode, whose handle is H. ! read/1. read(X) ------- Reads the next term from current input unifies the term with X. Unifies X with '!EOF' if an end-of-file is met. ! read/2. read(H, X) ---------- Reads the next term from file/window whose handle is H and unifies the term with X. Unifies X with '!EOF' if an end-of-file is met. ! read_string/1. read_string(S) -------------- Reads a string of characters from current input and unifies it with S. A string is a sequence of ASCII characters terminated with a new line character (\n). The string can have a maximum length of 255 characters. Unifies S with '!EOF' of an end-of-file is met. ! read_string/2. read_string(H, S) ----------------- Reads a string of characters from the file/window whose handle is H and unifies it with S. A string is a sequence of ASCII characters terminated with a new line character (\n). The string can have a maximum length of 255 characters. Unifies S with '!EOF' of an end-of-file is met. ! reconsult/1. reconsult(F) ------------ F must be an atom representing the pathname of a file containing Prolog source code. The clauses in F are added to the database. If a group of clauses define a predicate, say P, and clauses for this predicate already exist in the database, then the original clauses are removed before the new ones are loaded. Thus reconsult() replaces clauses with new ones. ! record/3. record(Key, Term, DBref) ------------------------ Key should be bound to an atom. Term is added to the dynamic database as the first term recorded under Key. DBref is unified with the database reference of the recorded Term. ! recorda/3. recorda(Key, Term, DBref) ------------------------ Key should be bound to an atom. Term is added to the dynamic database as the first term recorded under Key. DBref is unified with the database reference of the recorded Term. ! recordz/3. recordz(Key, Term, DBref) ------------------------ Key should be bound to an atom. Term is added to the dynamic database as the last term recorded under Key. DBref is unified with the database reference of the recorded Term. recorded/3. recorded(Key, Term, DBref) -------------------------- Key shpuld be bound to an atom. Succeeds if it can unify Term with the first term recorded under Key and DBref with its reference. On successive backtrackings unify Term and DBref with successive terms recorded under Key. ! repeat/0. repeat ------ Repeat can be reproved and arbitrary number of times. It behaves exactly as if defined by repeat. repeat :- repeat. ! retract/1. retract(X) ---------- Removes a clause which can be unified with X. Thus X should be of the form Atom, Atom :- Term, Structure, or Structure :- Term. On backtracking removes the next clause which can be unified with X. ! retractall/1. retractall(X) ------------- Removes all clauses which can be unified with X. Thus X should be of the form Atom, Atom :- Term, Structure, or Structure :- Term. ! rmdir/2. rmdir(Dir, Err) --------------- Dir should be bound to an atom which is the name of a directory. Removes the directory Dir. Err is unified with the DOS error code returned by the rmdir call - 0 if the directory was removed successfully. ! see / 1. see(File) --------- File should be an atom representing the pathname of a file. The file is opened in read mode and becomes the current input stream. So, calls to such predicates as read/1, get/1 etc. will take their input from File. ! segs_list/3. segs_list(Seg, Off, List) ------------------------- If List is unbound then Seg and Off should be bound to integers. Treats Seg:Off as an address in memory which contains a null terminated string. Creates a Prolog list consisting of the ASCII representation of the characters (less the terminating null) and unifies it with List. Is List is bound to a list of ASCII characters then creates a null terminated string in memroy consisting of the same characters, and unifies Seg and Off with the Segment and Offset portions of the address of this string, respectively. segs_list/3 is often used with bios/10 when it is required to pass a null terminated string to a BIOS or DOS call (in DS:DX). ! seen / 0. seen ---- Flush and lose the current input stream. The stream that was the current input before the last stream was opened is reestablished as the current input. ! skip/1. skip(M) ------- Keep reading characters from current input until a character is found which unifies with M. If end-of-file is reached then fail. ! skip/2. skip(H, M) ---------- Keep reading characters from the file whose handle is H until a character is found which unifies with M. If end-of-file is reached then fail. ! spy/1. spy(Predicate) --------------- Only defined when debugger.sys is loaded. Predicate should be of the form Name/Arity. spy/1 sets a spy point on the specified predicate. When the debugger is activated and execution comes to an occurence of Predicate, the debugger will stop and give a prompt to the user. Used to selectively debug code. ! string / 1. string(S) --------- Succeeds if and only if S is bound to a string. ! string_list/2. string_list(S, L) ----------------- If S is bound to a string then succeeds if L can be unified with the list of ASCII charcters in S. If L is bound to a list of ASCII characters then succeeds if S can be unified with the string whose characters are given by L. ! structure/1. structure(Term) --------------- Succeeds if and only if Term is bound to a structure. ! tab/1. tab(N) ------ N should be bound to an integer. Prints out N spaces at the current output. ! tab/2. tab(H, N) --------- N should be bound to an integer. Prints out N spaces at the file/window whose handle is H. ! tag/1. tag(Term) --------- Attaches Term to the last choice point thereby 'tagging' the choicepoint. This has no impact on the execution of the Prolog program unless cut_tag/1 is used, in which case the cut operation extends back to the tagged choice point. Term should not be an integer. See also cut_tag/1. ! tell/1. tell(File) ---------- File should be an atom representing the pathname of a file. The file is opened in write mode and becomes the current output stream. So, calls to such predicates as write/1, put/1 etc. will send their output to File. ! tget/2. tget(Row, Col) -------------- Unifies the current row and column postions of the cursor on the screen with Row and Col. ! timer/1. timer(X) -------- Unifies X with the number of 1/10 second ticks since a system dependent time. The value returned is currently an integer. This means that the value 'wraps around' after approximately two hours. Also X may be a negative number half of the time. ! time / 4. time(Hr, Min, Sec, Hun) ----------------------- time/4 examines the system clock and unifies Hr, Min, Sec and Huns with the current (24 hour) time - Hours, Minutes, Seconds and Hundreths of a second. ! tmove/2. tmove(Row, Col) --------------- Row and Col should be bound to integers. Moves the cursor to location (Row, Col) on the screen. The upper left hand corner of the screen is (0,0), the lower right hand corner is (24, 79). Notice that this absolute cursor positioning does not respect any window boundaries on the screen. ! told / 0. told ---- Closes and flushes the current output stream. The previous output stream is reestablished as the current output stream. ! trace / 0. trace, notrace, trace(X) ------------------------ Requires debugger.sys to be loaded. Trace turns on trace mode. The screen is split into a listener and debugger window. The debugger is turned on. Creep mode is turned on - so the next goal will cause the debugger to trigger whether or not the predicate has a spy point set on it. Notrace turns off trace mode, removes the debugger window and restores the screen to the state it was in before the debugger was called. trace/1 unifies X with 1 if trace mode is on else unifies X with 0. ! true / 0. true ---- true is always provable once. It cannot be backtracked into. ! ttyflush/0. ttyflush -------- Removes any keystrokes pending in the keyboard buffer. ! ttyrdy/0. ttyrdy ------ Succeeds if there is at least one keystroke waiting in the keyboard buffer, else fails. ! var/1. var(Term) --------- Succeeds if and only if Term is bound to an unbound variable. ! varsof/2. varsof(Term, Vars) ------------------ Unifies Vars with a list of all those variables occuring in Term. Variables appear only once in the list. ! verbose/0. verbose, noverbose, verbose(X) ------------------------------ Verbose turns on verbose mode (which may also be turned on by using the command line flag '-v'). In verbose mode, any garbage collections will cuase a window to pop up at the bottom of the screen indicating garbage collection is in process. The window will also inform you what type of garbage collection is in progress. Noverbose truns off verbose mode. Garbage collection occurs silently. verbose/1 unifies X with 1 if verbose mode is on else X is unified with 0. ! wa/2. wa(N, A) -------- N should be bound to an integer, A to an integer 0 <= A <= 255. The next N screen locations beginning at the current cursor location have their attribute byte set to A. wa/2 does not respect windows on the screen. ! wc/2. wc(N, C) -------- N should be bound to an integer, C to an integer 0 <= C <= 255. The next N screen locations beginning at the current cursor location are filled with the character whose ASCII code is C. wc/2 does not respect windows on the screen. ! wca/3. wca(N, C, A) ------------ N should be bound to an integer, A and C to integers between 0 and 255. The next N screen locations beginning at the current cursor location are filled with the character whose ASCII code is C and whose attribute byte is A. wca/3 does not respect windows on the screen. ! wn_attrib/3. wn_attrib(Handle, Sa, Ba) ------------------------- Handle must be the handle of an opened window. Sa and Ba should be bound to integers between 0 and 255. Sets the attribute byte of all characters appearing in the writeable portion of the window to Sa, and the attribute byte of the border characters to Ba. ! wn_close / 1. wn_close(H) ----------- Close the window specified by handle H. H must have been specified by wn_open(H, w(...)) or H must be the current output handle ( i.e. H is -1) ! wn_locate/3. wn_locate(Handle, Row, Col) --------------------------- Handle must be the handle of an opened window. If Row and Col are bound to integers then postion the cursor in the window to (Row, Col) where the row and column coordinates are relative to the upper left hand corner of the window (whose cordinates are (0,0). Otherwise unify the current relative cursor coordinates with Row and Col. ! wn_move/3. wn_move(H, Row, Col) -------------------- The window specified by handle H is moved so that its upper left hand corner is at row Row and column Col. ! wn_open / 2. wn_open(Handle, WindowSpec) --------------------------- Opens a new window identified with Handle. The size, position and attributes of the window are given by WindowSpec which must be a structure as follows: w(Row,Col,Width,Height,ScrnAttrib,BorderAttrib,BorderWrap) Row - integer between 0 and 23 - row of winodw's upper left corner Col - integer between 0 and 78 - column of window's upper left corner Width - integer specifiying inside width of window Height - integer specifying inside height of the window ScrnAttrib - integer between 0 and 255 specifying colour of text BorderAttrib - integer between 0 and 255 specifying colour of border BorderWrap - integer between 0 and 3 0 - No border, no wrap text 1 - Border, no wrap text 2 - NoBorder, wrap text 3 - Border, wrap text ! write/1. write(X) -------- Term X is written out in standard format to the current output device. ! write/2. write(H, X) ----------- Term X is written out in standard format to the file/window whose handle is H. ! writeq/1. writeq(X) --------- Term X is written to the current output device. Atoms which would be required to be quoted had they been input are quoted if written by writeq(). ! writeq/2. writeq(H, X) ------------ Term X is written to the file/window whose handle is H. Atoms which would be required to be quoted had they been input are quoted if written by writeq(). ! =.. / 2. Structure =.. List ------------------ 1. If Structure is a structure then succeed if List can be unified with a list whose first element is the name of the structure and whose next N elements are the N arguments of structure. 2. If Structure is an atom then succeed if List is unifiable with the one element list whose sole element is the atom Structure. 3. If L is a list whose first element is an atom then succeed if Structure can be unified with the structure whose name is the name of the atom and whose N arguments are the remaining N elements in the list. If the list has only one element, which is an atom, then succeed if Structure can be unified with the atom. If none of the above hold then fail. ! = / 2. X = Y ----- Succeeds if and only if X and Y are unifiable. In this case X is unified with Y. ! \= / 2. X \= Y ------ Succeeds if and only if X is not unifiable with Y. ! == / 2. X == Y ------ Succeeds if and only if X is identical with Y i.e. X and Y can be unified without performing any variable bindings. ! \== / 2. X \== Y ------- Succeeds if and only if either X is not unifiable with Y, or the unification between X and Y is such that variable bindings must be performed. ! latent_exp / 0. latent_exp ---------- Any compiled clause for latent_exp/0 is EXECUTED at load time rather than being added to the compiled database. Thus there is no requirement that all clauses for latent_exp/0 be contiguous (or even in the same file) for compilation. ! \+ / 1. \+ X ---- \+ is a prefix operator. It is an alternative form of not/1. i.e. \+ X succeeds if and only if the proof of X fails. ! -> / 2. X -> Y ; Z ---------- The proof of (X -> Y ; Z) proceeds as follows. If the proof of X succeeds then the truth of the whole expression depends on whether Y is proveable or not, otherwise if X fails then a proof of Z is attempted. Thus the form could be read "if X then Y else Z". ! load_code/1. load_code(F) ------------ F should be an atom or list of atoms corresponding to the names of compiled Prolog files. The files are loaded in the order specified. ! =:= / 2. E1 =:= E2 --------- E1 and E2 must be terms corresponding to valid arithmetic expressions. The expressions are evaluated and the predicate succeeds if the two expressions are ARITHMETICALLY equal. Thus 3.0 =:= 3 succeeds but 3.0 = 3 does not. ! =\= /2. E1 =\= E2. ---------- E1 and E2 must be terms corresponding to valid arithmetic expressions. The expressions are evaluated and the predicate succeeds if the two expressions are ARITHMETICALLY not equal. ! =< /2. E1 =< E2. ---------- E1 and E2 must be terms corresponding to valid arithmetic expressions. The expressions are evaluated and the predicate succeeds if the value of E1 is ARITHMETICALLY less than or equal that of E2. ! >= /2. E1 >= E2. ---------- E1 and E2 must be terms corresponding to valid arithmetic expressions. The expressions are evaluated and the predicate succeeds if the value of E1 is ARITHMETICALLY greater than or equal that of E2. ! < /2. E1 < E2. ---------- E1 and E2 must be terms corresponding to valid arithmetic expressions. The expressions are evaluated and the predicate succeeds if the value of E1 is ARITHMETICALLY less than that of E2. ! > /2. E1 > E2. ---------- E1 and E2 must be terms corresponding to valid arithmetic expressions. The expressions are evaluated and the predicate succeeds if the value of E1 is ARITHMETICALLY greater than that of E2. ! bagof/3. bagof(X, P, L) -------------- L is the list of all those terms X for which P is proveable. The terms X and P should have some variables in common. The behaviour of bagof/3 depends on which variables in P are FREE. A variable is free if It occurs in P but not in X It is not bound when bagof is called It is not locally bound Then for each instantiation of the free variables in P, bagof instantiates L to a list of all those terms X satisfying P. L may have duplicates and is not sorted. A variable is LOCALLY BOUND by specifying it with ^ as follows: bagof(X, Y1 ^ Y2 ^ goal(Y1, Y2, Y3, X), L). here only Y3 is free so bagof may be backtracked into N times where N is the number of distinct values of Y3 in proving goal(Y1, Y2, Y3, X). For each such Y3 we may get a different list L. ! setof/3. setof(X, P, L) -------------- L is the list of all those terms X for which P is proveable. The terms X and P should have some variables in common. The behaviour of bagof/3 depends on which variables in P are FREE. A variable is free if It occurs in P but not in X It is not bound when bagof is called It is not locally bound Then for each instantiation of the free variables in P, bagof instantiates L to a list of all those terms X satisfying P. L is sorted and will have no duplicates. A variable is LOCALLY BOUND by specifying it with ^ as follows: setof(X, Y1 ^ Y2 ^ goal(Y1, Y2, Y3, X), L). here only Y3 is free so bagof may be backtracked into N times where N is the number of distinct values of Y3 in proving goal(Y1, Y2, Y3, X). For each such Y3 we may get a different list L. ! sort / 2. sort(L, S). ----------- L should be a list. Succeeds if S can bound to the list which has the same elements as L but which elements are sorted according to the standard ordering given by @<. ! @< / 2. A @< B ------ Succeeds if and only if A is less than B in the standard ordering. (see compare/3 for a description of the standard ordering). ! @> / 2. A @> B ------ Succeeds if and only if A is greater than B in the standard ordering. (see compare/3 for a description of the standard ordering). ! @=< / 2. A @=< B ------- Succeeds if and only if A is less than or equal B in the standard ordering. (see compare/3 for a description of the standard ordering). ! @>= / 2. A @>= B ------- Succeeds if and only if A is greater than or equal B in the standard ordering. (see compare/3 for a description of the standard ordering). ! recorded/3. recorded(Key, Term, DBref) -------------------------- Key must be bound to an atom. Unifies Term with the first term which was recorded under Key. Unifies DBref with the database refernce of these term. On backtracking unifies with all such terms in order of their recording and then fail.