Amzi! Prolog +
Logic Server

Products and ServicesNews and Mailing ListsCustomer StoriesArticles and  LinksSupport and ForumsSearch and Site MapDownload and BuyContact and About


Amzi! Prolog + Logic Server

Learning Prolog

Consulting & Development Services


Create Logicbases for the Web, Java,
C++, .NET, Delphi and more

with State-of-the-Art Development Tools


Amzi!® Prolog + Logic ServerT makes it easy to integrate rule-based components with Windows, Linux, Sun Solaris, HP/UX and other applications (see list below).
 

Rule-Based Components 

  • Configuration and pricing rules for products and services,
  • Government regulations for industry, 
  • Legal and tax rules for forms filing,
  • Workflow rules for optimal customer service,
  • Diagnostic rules for problem solving 
  • Integrity-checking rules with databases,  
  • Parsing rules for documents, 
  • Tuning rules with performance-sensitive applications, 
  • Advisory rules with help systems, 
  • Business rules with any commercial application.


Amzi! offers plug-in, rule-based services for C, C++, Java, Web Servers (via ASP.NET, JSP, Java Servlets, CGI), Delphi, VB.NET, C#.NET, PowerBuilder, Access, Excel and many other tools.

The integration is achieved through the Logic Server API which lets you access a logic-base of rules as easily as you access a database today. The result is a manageable and well-behaved interface that makes it possible to utilize rule-based programming everywhere it is needed (see diagram).

Amzi! Architecture


In addition to enabling embedded Prolog applications, the Logic Server API (LSAPI) also lets you extend Amzi! Prolog so Prolog predicates can access your data, call your code and link to your other libraries and interfaces.

    "I've been looking for a Prolog with this kind of API for years ... it is designed to work equally well both ways (embed-dable AND extendable), ... it is small yet seems very complete." 

    Jonas Beckman, MU Data 

State-of-the-Art Interactive Development Environment

Amzi! provides the classic Prolog command-line tools, and a full Interactive Developer's Environment (IDE), based on the open-source Eclipse project, that integrates a code editor, listener, debugger, compiler, linker and runtime engine in one intuitive GUI environment (see screen shots).
 

Amzi! Tools

  • Amzi! Eclipse IDE. 
  • Full on-line documentation and tutorials.
  • Source Code Debugger.
  • Standard ?- Listener runs both compiled and interpreted code. 
  • Box-Model Debugger (as defined by Clocksin & Mellish). 
  • Compiler.
  • Linker. 
  • Definite Clause Grammar (DCG) support for natural language work). 
  • Dynamic (DLL, SO format) Logic Server API Libraries

 

The Amzi! Eclipse IDE features:

  • Syntax coloring in the editor to highlight built-in predicates, strings, comments, etc.
  • Source file outliner and project cross referencer.
  • Source code bookmarks to indicate the locations of errors, to-do items, search text and more.
  • Full source code debugging showing variable bindings at each level in the call stack.
  • Full source code debugging of compiled Prolog components embedded in other languages and tools, and running on remote machines (e.g. Web servers).
  • Portable projects that can optionally include other projects.
  • Automatic loading of libraries and lsx's in the Prolog listener, plus input line recall and editing.

Other standard features of the Eclipse IDE that may be useful to Amzi! users are:

  • Separately downloadable plugins for developing Java, C++, COBOL, C#, PHP and other programs.
  • Automatic file backup.
  • Tools for modelling, graphical editing and testing.
  • Seamless connection to source control systems like CVS, Perforce, PVCS, MKS, ClearCase and more.
  • Tight integration with the Apache's Ant build tool.

World Class Source Code Debugger

The real jewel of the Amzi! Eclipse IDE is the source code debugger. It combines conventional debugging tools like breakpoints, pause, step-into and step-over options, with extremely clear presentation of Prolog concepts like backtracking, unification and cut.

Clarity for Learning

As a program executes, the line of source code is highlighted in different colors depending on the state at that line, making it very clear how Prolog backtracking works its way through Prolog source. A separate window has the full call stack, and, at each level the variable bindings for the clause being executed.

For the beginning Prolog programmer this means that a difficult predicate, like append/3, becomes transparent, de-mystifying the seeming magic of the rippling effects of recursion and unification.

Embedded/Remote Debugging for Production Applications

For the professional, the debugger works equally well with compiled production code, and it can be used to debug embedded Prolog components, either on the developer's workstation or running remotely on a separate machine.

This means it is no longer necessary to test and debug Prolog code separate from an integrated application. A developer can have full source code debugging at a workstation for a Prolog component running as part of a remote server environment.

Embedding Logic Services

The Logic Server is implemented as a class, and the LSAPI is a collection of member functions for the class LogicServer. The LSAPI is also provided as a pure functional API. You access the Logic Server similar to a database. The LSAPI gives you the ability to load, query and update a Prolog logic-base of rules and data from any language on any supported platform, and, under Windows, from any tool that can call a DLL.

The code boxes (below) illustrate a simple rule-based system that asks the user for a sound, from which it identifies a pet. This same idea can be used to identify problems based on symptoms, tuning parameters based on system configuration, help based on user needs, etc.

Calling the Logic Server 

The program examples below implement 
these steps:
   Initialize Logic Server
   Load Pets program
   Get sound from user
   Assert sound to logic-base
   Query pet(X) in logic-base
   Get the value of X 
   Display results
   Close Logic Server

. . . from Java and Servlets

ls.Init("");
ls.Load("pets.xpl");
Sound.append("sound('");
System.out.println("What sound?");
while ((c=System.in.read())!=-1) 
    Sound.append((char) c);
Sound.append("')");
System.out.println(Sound.toString());
ls.AssertaStr(Sound.toString());
Term = ls.ExecStr("pet(X)");
Pet = ls.GetStrArg(Term, 1);
System.out.println("Pet is a ");
System.out.println(Pet);
ls.Close();

. . . from VB.NET and ASP.NET 

ls.Init("")
ls.Load("pets")
Sound = InputBox$("What sound?")
ls.AssertaStr("sound(" + Sound + ")")
Term = ls.CallStr("pet(X)")
Pet = ls.GetStrArg(Term, 1)
MsgBox "The pet is a " + Pet
Call ls.Close()

. . . from C++

Init("");
Load("pets");
puts("What sound?");
gets(Sound);
AssertaStr("sound(%s)",Sound);
CallStr(&term, "pet(X)");
GetArg(term, 1, cSTR. &Pet);
printf("The pet is a %s\n", Pet);
Close();

. . . from Delphi 

ls.InitLS(''); 
ls.LoadXPL('pets');
Sound:=InputBox('','What sound?','');
ls.AssertaPStr('sound('+ Sound +')');
ls.CallPStr(t, 'pet(X)');
Pet := ls.GetPStrArg(t, 1);
ShowMessage('Pet is a ' + Pet);
ls.Close;

PETS.PRO 

% 3 Prolog rules for 
% identifying pets based 
% on their sound

pet(dog) :- sound(woof).
pet(pig) :- sound(oink).
pet(duck) :- sound(quack).

PETS in the Listener 

?- consult(pets).
yes
?- assert(sound(woof)).
yes
?- pet(X).
X = dog

The API has 50+ methods/functions that provide both high-level and detailed access to Prolog rules, terms and data. The high-level functions use intuitive string-mapping functions that simulate a Prolog listener (see code boxes below).

The detailed functions let you construct and/or decompose arbitrarily complex Prolog terms and lists. For example, this C code pops all of the elements off a Prolog list and prints them:

    while (PopList(&Lst,cSTR,S)==OK)
       printf("Popped %s\n", S);
     
    "I was convinced that Amzi!'s approach to interfacing Prolog with procedural languages was the right one ... a Prolog program is fundamentally closer to a database than it is to a sequential program. As such, the API presents an interface that is similar to database interfaces ... In my mind this is as intuitive as one can get in an interface to Prolog ...

    Amzi! moves you toward a unique view of its positioning in the Prolog market. It aims to be a component of an application written in other languages.

    ...Solid, commercial grade..ideal for embedding" 

    PC AI Review, 
    Sep/Oct 95 

Extending Prolog

The Logic Server API also makes it easy to implement custom extended predicates for Prolog. These are predicates of your own design that are implemented in a host language. Extended predicates look and behave exactly like the built-in predicates, such as read/1 and write/1, that are part of the core Prolog system.

For example, a tuning application might have its user interface implemented using C++ GUI, which loads and calls tuning rules written in Prolog. Those rules make their decisions based on the state of the machine which is determined by C functions that are called directly by the Prolog program.

Or, you might want your Prolog code to access a network server. You can use the Logic Server API to let Prolog directly access the network's API.

Extended predicates can be implemented in any language that supports the notion of call-back functions. Currently this means C/C++, Java, Delphi, C# and Visual Basic can be used for implementing extended predicates.

    "I've been using Amzi! Prolog with an extensive C/C++ interface and provisions for adding Prolog predicates using C(++) code. It's wonderful."

    Gregg Weismann, Manager of System Software Development, Xircom, Inc.

Internet Support

For building Internet applications, Amzi! includes these features:
  • The Java class (described above) for use with JSP and Servlets (including samples).
  • A .NET Class for interfacing with Microsoft's ASP.NET.
  • An XML library for use with a variety of internet technologies including SOAP.
  • The ability to load Prolog components from memory (thereby supporting binary archives like JAR files).
  • A Logic Server Extension for communicating with clients and servers (e.g. mail, ftp, http) via Sockets.
  • A CGI interface that lets you write Prolog scripts that run on web servers.

Multiple Session Support

For building for the Internet, telephony, database and other server applications, you can invoke multiple, simultaneous instances of the Amzi! Logic Server (Prolog runtime). These instance can optionally run each in their own thread. This allows you to create an instance for each user or process accessing a server.

Database Support

Amzi! Prolog logic-bases can reason over records from any ODBC database (under Windows). This is a two-level interface, with one part implemented as an LSX (Logic Server eXtension) that implements extended predicates that directly access ODBC services, and the other part implemented as a Prolog wrapper around the ODBC predicates that allows natural Prolog pattern-matching and backtracking to be used with an ODBC database. Since full source code is provided, the ODBC interface can be readily adapted to other relational databases.

Tcl/Tk Graphical Interface

Tcl/Tk, a powerful, open-source, scripting and graphics toolkit, is supported as an Amzi! LSX (Logic Server eXtension). It allows for Tcl/Tk commands to be embedded in Prolog, and allows Tcl/Tk to query Prolog. The result is a powerful combination for building intelligent graphical applications.

Unicode Support

Internally, the Amzi! Logic Server is a pure UnicodeT Standard implementation. Externally, it supports Unicode, ANSI and multi-byte applications. This means you can write Prolog source code using the Unicode character set, and call the Logic Server using Unicode strings. Hence, Amzi! Prolog can communicate in any human language.

Object Oriented Programming

The C++, Java, Delphi, C# and VB versions of the Logic Server API are delivered as class with the LSAPI functions implemented as member functions. This means you can use these classes to derive subclasses for your applications. Those subclasses would then encapsulate the services your application expects from the Prolog portion of the application, hiding the details of the Logic Server inside the class.

For example, the pet identification code example could be encapsulated in a C++ object as illustrated in the box below.
 

Accessing a Prolog Logic- Base as a C++ Object 

// derive class from Prolog engine
class CPets: public CLogicServer {
public:
     Cpets();
     ~Cpets();
     void id(char *, char *); 
};

// constructor initializes engine and loads rules
CPets::CPets { Init(""); Load("pets");}

// destructor frees Prolog resources
CPets::~CPets { Close(); }

// identify the pet
void CPets::id(char* Sound,char* Pet) 
{
     char  buf[40];
     TERM  term;

     sprintf(buf, "sound(%s)", Sound);
     AssertaStr(buf);
     CallStr(&term, "pet(X)");
     GetArg(term, 1, cSTR, Pet); 
}


     // sample code to use CPets object
     ... 
     CPets    aPet;
     cout<<"what sound?";
     cin >> Sound;
     aPet.id(Sound, Pet);
     cout<<"The pet is a "<<Pet; 
     ...

    "Combining Visual Basic and the Logic Server lets you create programs that harness the power of Prolog while Visual Basic does all the work of maintaining the interface ... creating and debugging your Prolog programs is a piece of cake ... Since Amzi!'s version is a standard implementation of Prolog, it works right out of the box with most Prolog code." 

    VB Tech Journal Review

Performance

Performance is key in any application. Amzi! Prolog is a compiled Prolog, so the logic-base you access will usually be compiled. But, Amzi! is flexible as well, so you can intermix dynamically asserted (interpreted) code with the compiled code. In the PETS example (above) the rules are compiled and the sounds are asserted dynamically.

Open Architecture

All Amzi!-written extensions to Prolog are implemented using the Logic Server API and come with full source. You can use the LSAPI to design and write your own extensions just as easily. You can add your own Prolog-database, Prolog-GUI, Prolog-communications, etc.

Your extensions can be packaged in a special type of dynamic library (DLL/SO) called an LSX (Logic Server eXtension), or they can be part of your program. LSX's are provided as part of the product for ODBC, Tcl/Tk and Sockets.

Memory Utilization

To work as a component, Prolog is both compact and well-behaved. This makes Amzi! ideal for 24/7 online operations.
 
"Amzi! offers so much flexibility and, to all intents and purposes, allows mixing of numeric and symbolic computation in a way undreamt of a few short years ago. Well done!" 

Jim Morrison, Business Reasearch Associate, ZENECA Specialties 


Error Handling

Professional applications require robust error recovery. Amzi! is designed to recognize and come down gracefully in the case of errors. The host program can check for errors at API calls retrieving the error code, message, call stack, read buffer and other information. Programs can use catch/throw and exception handlers to capture and report all errors and respond accordingly. Hence errors can be thrown in your Prolog logic-base and caught and handled in your Java, C++, VB, C# or Delphi program.

Portability

Prolog source and object code developed on one platform will run on any other runtime or API platform (without recompiling or relinking). This is because the Amzi! Logic Server is implemented with a virtual machine architecture similar to Java and .NET called a WAM. The Amzi! compiler and linker create binary byte-code files that can be executed by any implemention of the Logic Server.

Prolog Technical Specs 

  • ISO-standard `Module' capability for reusable code and `hidden' predicates to prevent name collisions across files. 
  • String, floating point, stream i/o and random access binary file support.
  • Full control over the sizes of all heaps, stacks and various other dynamically allocated items. 
  • User-extensible error handling with catchable exceptions. 
  • Sorted and indexed dynamic database options for quicker access to terms. 
  • Last call optimization (a more general form of `tail recursion' elimination).
  • First argument indexing for more efficient predicate access. 
  • Automatic garbage collection of heaps, stacks and string space for more efficient use of memory. 

Ease of Development

Amzi! lets you build your applications a module at a time because compiled and interpreted code can be intermixed in the same program. In fact, compiled and interpreted modules are 100% source compatible and require no changes to move from one to the other. This makes it easy to work on large multi-module applications, with working code compiled and code still under development interpreted.

To get you started quickly, the package includes the Adventure in Prolog tutorial, the Building Expert Systems in Prolog advanced tutorial and lots of samples including:

  • Hello programs for C, C++, Java, Delphi, Visual Basic, .NET, etc.
  • A multi-threaded Rubik's Cube Solver.
  • Clocksin & Mellish's Predicate Calculus to Prolog translator (using actual symbols for 'exists', etc.)
  • A simple Japanese to English translator.
  • A genealogical database implemented with ODBC.
  • A general-purpose, forward-chaining expert system with a bird identification logic-base.
  • An information request form for a web server.
    "You guys rock... thanks for putting out excellent well-documented software!" 

    Oliver Jones, DotClick Corporation 

Distribution

Amzi! is royalty free.

"Contact Amzi! Their Prolog products are `with-it'" 

from the comp.lang.prolog newsgroup

Environments & Packaging

Amzi! Prolog + Logic Server runs under Windows, Linux, Solaris and HP/UX. (Contact us for other platforms). The product includes full HTML documentation, lots of samples, plus the tutorial texts, Adventure in Prolog and Building Expert Systems in Prolog.

Jolt Productivity Award for Components and Libraries 

"Decision-making software is found in domains from securities trading to air traffic control, where choices are made based on complicated conditions, often in real time. Rule-based systems are a common solution to these types of problems. One of the best languages for creating rule-based applications has always been Prolog. However, in the past it's been difficult to create full-blown applications using it. Amzi! inc. has a solution in the Amzi! Logic Server, an embeddable Prolog rule-base and inference engine that is accessible from C++, Java, Visual Basic, Smalltalk, and other tools. With its Edinburgh-standard implementation of Prolog and cross-platform, royalty-free runtimes, the Amzi! Logic Server should make rule-based programing accessible to anyone who feels the need to make smarter software."

Software Development

 

The Eclipse IDE, included in Amzi!, won the 2004 Jolt Award for Language and Development Environments from Software Development magazine.



Copyright ©1995-2006 Amzi! inc. All Rights Reserved. Privacy Policy.
Amzi!, KnowledgeWright and WebLS are registered trademarks and Adventure in Prolog, Logic Server, Logic Explorer, Adventure in Prolog and Subscription Plus are trademarks of Amzi! inc.