Amzi!
Prolog +
|
|
Rule-Based Components
|
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).
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 |
Amzi! Tools
|
The Amzi! Eclipse IDE features:
Other standard features of the Eclipse IDE that may be useful to Amzi! users are:
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.
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.
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.
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 ServerThe 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 Servletsls.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.NETls.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 Delphils.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, |
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. |
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 |
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.
"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 |
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
|
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:
"You guys rock... thanks for putting out excellent well-documented
software!"
Oliver Jones, DotClick Corporation |
Amzi! is royalty free.
"Contact Amzi! Their Prolog products are `with-it'"
from the comp.lang.prolog newsgroup |
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.
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.