Amzi! Prolog User's Guide & Reference

Index

Amzi! Prolog User's Guide and Reference
 Contents
 Purpose

Quick Overview
 Quick Overview
  Listener
   Debugger
   Intermixing Interpreted and Compiled Code
  Compiler
  Linker
  IDE
  Amzi! Runtime
  Dynamic / Shared Libraries
  Where to Go Next?

Quick Tutorial
 Quick Tutorial
  Duck World
  Starting the Listener
  Creating a Source File
  Consulting a Source File
  Using the Listener
  Debugging
  Modules
  Running a Modular Application
   Using alis and BAT Files
   Using Projects
  Compiling
  Running
  Linking and Running
  Distributing an Application
  Interfacing with Other Tools

IDE
 IDE
  Interface
  Unicode and ASCII
  File Menu
  Edit Menu
  View Menu
  Listener Menu
  Build Menu
  Window Menu
  Help

Projects
 Projects
  Creating a Project
  Dialog Box
  Consulting / Loading
  Building

Listener
 Listener
  Running in the IDE
  Running from the Command-Line
   Consulting Files
   Executing main / 0
  Loading Prolog Code
  Adding and Removing Clauses
   assert
   Typing in a Rule
   Consulting user
   add
   Removing Clauses
  Listing Clauses
  Proving Goals
  Syntax Errors
  Other Command-Line Services
  Exiting

Debugger
 Debugger
  Box Model
  Starting and Exiting
  Display
   portray(GOAL)
  Debug Port Options
  Spypoints
  Leashing Debug Ports
  Logging
  Example

Debugging Your Programs
 Debugging Your Programs
  Initial Development for Embedded Modules
  Tracking Prolog Errors
   Logging
   Debugger-Like Output
   catch and throw
   Prolog Error File
  Tracking LSAPI Errors
   Tracing LSAPI Calls
   Checking LSAPI Error Codes
   Examining Prolog Terms

Managing Memory
 Managing Memory
   Stacks and Database Space
  Garbage Collection
   Dynamic Database
   Heap Stack
  Reducing Memory Demands
   Iteration vs. Recursion
   Backtrack Points

Compiler
 Compiler
  Advantages
  Disadvantages
  Requirements
  Directives
  Running from the IDE
  Running from the Command-Line
  Messages
  Errors
   Complex Clauses
   Complex Predicates
  Dynamic Clauses in Compiled Code
  Multifile Directive
  Discontiguous Directive
  Latent Expressions
  Main Predicate
  Using Modules
   Importing Predicates
   Exporting Predicates
   Hidden Predicates
   Modules Example
   Loadtime Errors

Linker
 Linker
  Running from the IDE
  Running from the Command-Line
  Libraries

Amzi! Runtime
 Amzi! Runtime
  Running arun from the Command-Line
  Configuration Files
   Configuration Parameters
   Default .cfg Values
  Modes
   fatal_errors
   file_errors
   protect_db
   string_esc
   verbose

Distributing Your Programs
 Distributing Your Programs
  Redistributable Files

Prolog Terms
 Prolog Terms
  Numbers
   Integers
   Floating Point Numbers
  Atoms
   Built-in Atoms
  Escape Characters
   Enabling and Disabling Escape Processing
   Escape Codes
   Using Escape Codes
   Examples
  Strings
  Variables
  Structures
  Lists
  Character Lists
   Character Constants
  Database References
  Comments
  Operators
   Precedence
   Associativity
   op(Precedence, Type, Oper)
   Term1 : Term2
   Predefined Prolog Operators

Prolog Execution
 Prolog Execution
  Clauses
  Unification
  Backtracking Search
  Complex Goals
   X , Y
   X; Y
   Goal1 - Goal2; Goal3
   call(Goal)
   not(Goal)
   \+ Goal
   findall(Instance, Goal, List)
   bagof(Instance, Goal, List)
   get_preds(PredList)
   once(Goal)
   setof(Instance, Goal, List)
  Flow-of-Control
   ! Cut
   repeat
   fail
   true
   for(Index, Start, End, Increment)
   catch(Goal, Catcher, Recover) and throw(Term)
   tag(Term) and cut_tag(Term)
   halt
  Counters
   cntr_get(Counter, Value)
   cntr_dec(Counter, Value)
   cntr_inc(Counter, Value)
   cntr_set(Counter, Value)

Manipulating Terms
 Manipulating Terms
  Term Classification
   atom(X)
   atomic(X)
   defined(ExtendedPredicate)
   float(X)
   integer(X)
   list(X)
   islist(X)
   long(X)
   nonvar(X)
   number(X)
   short(X)
   string(X)
   structure(X)
   var(X)
  Comparison of Terms
   X @< Y
   X @> Y
   X @ = < Y
   X @> = Y
   compare(Result, Term1, Term2)
  Equality of Terms
   X = Y
   X \ = Y
   X = = Y
   X \ = = Y
  Dissecting Terms
   arg(N, Term, Argument)
   functor(Term, Functor, N)
   gensym(Root, Sym)
   numbervars(Term, Start, End)
   Term = .. List (univ)
   varlist(List)
   varsof(Term, List)

Atoms, Lists and Strings
 Atoms, Lists and Strings
  Atom Processing
   atom_codes(Atom, CharList)
   atomlist_concat(AtomList, Atom)
   atom_concat(Atom1, Atom2, AtomVar3)
   atom_length(Atom, Length)
   atom_uplow(AtomUpper, AtomLower)
   current_atom(Atom)
   name(Atom, CharList)
   sub_atom(Atom, Index, Length, SubAtom)
  List Processing
   compare_lists(List1, List2, DiffList)
   is_member(Term, List) is_member is a restricted version of the classic member / 2 predicate (in the LIST.PLM library) than can be used for fast testing if Term is a member of List. It uses a strong unify ( = = ) for testing the element. The definition is equivalent to: is_member(X, [Y|_]) :- X = = Y,! . is_member(X,[_|Z]) :- is_member(X,Z). Note, is_member cannot be backtracked into. remove_dups(List, NoDupsList)
   sort(List, SortedList)
  String Processing
   nonblank_string(String)
   strcat(StringA, StringB, StringAB)
   stringlist_concat(StringList, String), stringlist_concat(StringList, Separator, String)
   string_atom(String, Atom)
   string_icomp(String1, String2)
   string_integer(String, Integer)
   string_length(String, Length)
   string_list(String, List)
   string_split(String, DelimitersS, List)
   string_term(String, Term)
   string_termq(StringQ, Term)
   string_tokens(String, TokenList), string_tokens(String, TokenList, DelimitersS)
   string_trim(String, TrimmedString)
   sub_string(String, Index, Length, SubString)

Arithmetic
 Arithmetic
   X is Y
  Arithmetic Comparisons
   X > = Y
   X = < Y
   X > Y
   X < Y
   X = : = Y
   X = \ = Y
  Arithmetic Operators
   X + Y
   X - Y
   X * Y
   X / Y
   X / / Y
   X divs Y
   X divu Y
   X mod Y
   X mods Y
   X modu Y
   X / \ Y
   X \ / Y
   X < < Y
   X > > Y
   X ** Y
   \ X
   - X
  Arithmetic Functions
   acos(X)
   asin(X)
   atan(X)
   cos(X)
   exp(X)
   float(X)
   integer(X)
   ln(X)
   seed_random(I)
   sin(X)
   sqrt(X)
   tan(X)
  Built-in Atoms

Prolog Database
 Prolog Database
  Populating
   consult(FileA), consult([F1, F2, ...]), [F1, F2, ...]
   reconsult(FileA), reconsult([F1, F2, ...])
   load(FileA), load([F1, F2, ...])
   unload(FileA), unload([F1, F2, ...])
   add , [user]
   replace
   listing, listing(Name), listing(Name / Arity)
   :- dynamic Name / Arity.
  Modifying
   abolish(Name / Arity), abolish(Name, Arity)
   asserta(Term)
   assertz(Term)
   assert(Term)
   clause(Head, Body)
   retract(Term)
   retractall(Term)
  Keys
   db_ref(Head, Body, Dbref)
   erase(DBref)
   eraseall(Key)
   instance(DBref, Term)
   recorda(Key, Term, Dbref)
   recordz(Key, Term, Dbref)
   record(Key, Term, Dbref)
   recorded(Key, Term, Dbref)

Input and Output
 Input and Output
  I / O by Ids
  I / O by Streams
   Current Streams
   User Streams
   Stream Management
  I / O by IDs and Streams
   ! EOF End of File
   current_streams(Input_ID, Output_ID, Error_ID)
   current_user(UserIn_ID, UserOut_ID, UserErr_ID)
   display(Term)
   flush_in and flush_out
   get(Char), get(ID, Char)
   get0(Char), get0(ID, Char)
   handle_name(Handle, DeviceName)
   nl, nl(ID)
   put(Char), put(ID, Char)
   read(Term), read(ID, Term)
   read_string(String), read_string(ID, String)
   see(StreamA)
   seen
   seeing(SName)
   seetell(StreamA)
   seentold
   set_errors(StreamA)
   skip(Char), skip(ID, Char)
   stream_type(ID, Type)
   tab(N), tab(ID, N)
   tell(StreamA)
   told
   telling(SName)
   write(Term), write(ID, Term)
   writeq(Term), writeq(ID, Term)
  File-Only I / O
   fopen(ID, File, Mode)
   fclose(ID)
   fflush(ID)
   fread(ID, Value, Type)
   fseek(ID, Offset, Method, NewOff)
   fwrite(ID, Value, Type)
   file_exists(File), file_exists(File, Type)
  Keyboard Input
   get1(Key)
   keyb(Ascii)
   respkey(Char)
  Logging
   openlog(Fname)
   closelog
   writelog(X)
   nllog

Definite Clause Grammars (DCGs)
 Definite Clause Grammars (DCGs)
   expand_term(DCGclause, PROLOGclause)
   dcg_terminal(LIST, DIFFLIST1, DIFFLIST2)

Runtime and Environment
 Runtime & Environment
  Setting Runtime Modes
   get_mode(Mode, Value)
   set_mode(Mode, Value)
  Miscellaneous Predicates
   abort(Severity)
   current_prolog_flag(FlagAV, ValueNV)
   date(MonthNV, DayNV, YearNV)
   highwater(Heap, Local, Control, Trail)
   pro_heap(Top, Pos)
   pro_control(Top, Pos)
   pro_local(Top, Pos)
   pro_trail(Top, Pos)
   pro_db(Allocated, Used)
   stack_sizes(Heap, Control, Local, Trail)
   system(CmdA)
   time(Hour, Min, Sec)
   timer(Ticks)
   version(String)
  Special Listener Predicates
   add
   consult_project(ProjectFile)
   debug
   pp(Term), user_pp(Term)
   quit
   reconsult_project(ProjectFile)
   replace

Extended Predicates
 Extended Predicates
  Files and Directories
   chdir(DirL)
   chdir(DirL, Err)
   curdir(DirS)
   delfile(PathL, Err)
   findfiles(Mask, Attr, FileInfo)
   getdrive(Drive)
   mkdir(DirL, Err)
   rename(OldName, NewName, Err)
   rmdir(DirL, Err)
   setdrive(Drive)
  Windows-Only
   w_msgbox(Term)
   w_tfmsgbox(Term)
   w_getfile(FileStr)
  Miscellaneous Command-Line Predicates
   command_line(ArgsL)

Predicate Summary
 Predicate Summary
  Predicates
  Extended Predicates
  Arithmetic Operators
  Arithmetic Comparisons
  Term Comparisons

Copyright ©1987-1998 Amzi! inc