LPA Intelligence Server
The Intelligence Server allows you to embed your LPA-based intelligent components in other applications written using almost any Windows programming language or visual development system. For example, games developers can add smart characters to traditional games written in C or C++, and manufacturers of scientific instrumentation can incorporate powerful algorithms into their analytical engines.
The Intelligence Server not only lets developers use the inferencing power of Prolog and Flex invisibly in the background, but also provides 'callback' facilities so that the inferencing engine can, when required, request additional input needed to complete its computations. This 'query-the-user' mechanism frequently occurs in the realm of expert systems and knowledge-based systems.
The Intelligence Server provides a safe and unintrusive way of using AI technology to add value to conventional processes and applications. The Intelligence Server has been used in numerous commercial and research projects and with a variety of different front-end langauges.
The Features of the Intelligence Server
The Intelligence Server interface provides a number of features that directly benefit the development of distributed intelligent applications, these can be summarised as follows:
- Text-based interface - this provides a clean and safe interface between languages with radically different data types.
- Server independence - back-end programs can be written without having to worry about which front-end language is used.
- Extendibility - any Windows language that supports 32-bit DLL calls can potentially be used as the front-end.
- Prolog backtracking - each solution to a multiple solution Prolog goal is returned individually.
- Clean and safe development - because the Prolog code for the server utilises pure text input and output, it can easily be developed in isolation. This means that code can be fully tested and debugged using the extensive features of the WIN-PROLOG development environment.
- Callbacks - these allow the currently running back-end goal to request additional information from the front-end.
- Shared data - efficient sharing of large data structures between processes is possible using using memory mapped files.
- Multiple instances - each application can call multiple instances of Prolog only limited by memory.
- Unicode - There is full support for Unicode text where required.
A Safe and Simple Text Interface
A general problem associated with mixed language programming is that the languages tend to come from completely different worlds and use very different internal data structures. In the Prolog world not only are the data structures complex, they are also dynamic. This means that Prolog requires the use of garbage collection, to tidy up once such a structure is no longer in use. Any system that allowed arbitrary Prolog terms to be built piecemeal would also have to take garbage collection into account.
Rather than provide direct mappings between the complex structures of Prolog and a multiplicity of other languages, LPA has provided a uniform and safe way of communicating via a simple text interface. In this model, the client application simply sends the text of queries to Prolog, and receives back any output performed by the user's Prolog code.
To facilitate the text interface, WIN-PROLOG has a string data type, which is highly efficient for inputting and outputting significant amounts of data. The string data type is also backed up by a number of versatile text formatting predicates. In each function call the Intelligence Server can send as much data as required, this corresponds to quite a significant Prolog goal.
Suppose an application wanted to call WIN-PROLOG's member/2 predicate to return the individual elements of a given list. If knowledge of Prolog's internal mechanism for constructing lists was required, constructing the call to member/2 would be a complex process.
In the Intelligence Server model, you can construct a text string that represents the Prolog term and then pass this to Prolog to let it do the hard work of constructing Prolog data structures, something that it is specifically optimised to do. This is also a much safer approach. If you made any mistake in the building of the text of the term, all that would happen is that a syntax error would be returned, rather than a GPF!
Independence from the Front-end Language
Because the Intelligence Server uses text as the medium for the interface, standard Prolog code can be developed and then integrated into any front-end language required. This means that you could for example develop your application's front-end in Visual Basic and then replace it with C++ or Java as and when the need requires without having to alter your Prolog or flex code in any way!
The Intelligence Server makes the facilities in WIN-PROLOG available via six 32-bit function calls provided in the SERVER.DLL. This means that any Windows language supporting 32-bit DLL function calls can potentially be used as a front-end language. LPA currently provides three versions of the server DLL: one for C, C++ and Delphi, another for Visual Basic, and a third for Java; finally an interface to the Flex expert system toolkit is provided. All of these can use Unicode text.
The support for backtracking in the Intelligence Server interface means that natural Prolog programs can be developed. When a Prolog predicate is called and returns a result, it maintains its current backtracking position, so that each successive call returns the next available solution.
Clean and Safe Development
In any multi-language application, the safe testing and debugging of the individual components becomes an important issue. In a system where direct callbacks are involved, where one language can directly call functions in the other, this testing becomes extremely complex, as the development environments for all the languages involved need to be running at the same time. Because the Prolog code in an Intelligence Server application uses pure text as its input and output, this means that it can be easily tested and debugged in isolation from the front-end code. The WIN-PROLOG development environment provides a number of support features including a sophisticated source-level debugger.
An essential feature for a client-server interface is to allow the server to request additional information from the client during the process of an evaluation. In the Intelligence Server a special predicate, input/2, is provided to do this. When input/2 is called as part of the Prolog server code, the predicate making the call is suspended until some information on a specific subject is returned by the front-end, at which point the predicate can continue its evaluation with the new information in place. This is a typical requirement for expert system-type applications where the inference engine requires additional answers to find a solution.
Where large amounts of data are involved, rather than pass them backwards and forwards, they can be shared by using Memory Mapped Files; so rather than pass across the whole board state in a board game, it can be referred to by both the rendering front-end and the intelligent back-end.
The Structure of an Intelligence Server Application
To show more clearly how the Intelligence Server works, let's examine the components that go to make up the interface. An Intelligence Server application can be divided into three main parts:
- The front-end. This comprises the components that make up the front-end executable or equivalents. This front-end may be written in any language that supports 32-bit DLL function calls, such as C/C++, VB, Java, Delphi, C#, etc.
- The Intelligence Server interface. This forms the bridge between the front-end and the WIN-PROLOG-based application.
- The WIN-PROLOG-based application. This contains the user-defined Prolog/Flex/Flint application code.
The Intelligence Server interface itself comes in two parts:
- INT386W.DLL - A DLL, compatible with the front-end implementation, which contains the 6 functions that constitute the Intelligence Server protocol. You load this DLL from your front-end program, making its functions available to the programming language you are using.
- INT386W.OVL - The Intelligence Server Prolog object code that implements the WIN-PROLOG side of the interface. This file handles the connection between the DLL and the user-defined Prolog application code.
Copyright © 2017 LPA Ltd
All rights reserved