From: jldh@sei.cmu.edu (Jorge Luis Diaz-Herrera)
Subject: Re: AI and Ada (Was: Multiple Inheritance -- the last post?)
Organization: The Software Engineering Institute
Date: Thu, 10 Sep 1992 16:10:51 GMT


In article <14425@goanna.cs.rmit.oz.au>, ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) writes:
|> ..., so I missed the bit where they were going to add support
|> for logic programming.  It really does come as a surprise that Ada9X will
|> "STRONGLY SUPPORT" logic programming.  I would definitely like to hear more
|> about this, and I'm sure many other comp.lang.ada readers would too.
|> ...

Probably one of the most widely used AI techniques are "production systems". 
A production system consists of a collection of condition-action pairs called
production rules stored in a rule-base, together with a database of known
facts of the problem domain, state information of the current solution, and a
procedure for "firing" the production rules called the inference mechanism.
In this framework, a program is not a procedural sequence of instructions, but
a set of declarative (i.e., non-procedural) statements providing information
about the problem. (To some, these are not considered programs, but data!).

These tools are based on the idea of "programming in logic".  Logic or
Predicate Programming is based on primitives for defining facts and rules
(declarative programs, similar to pattern-matching computing).  This form of 
logic programming is commonly done by using predicate calculus expressions
called "Horn Clauses" in which at most one the literals of the expressions is
unnegated.  Basically, a production rule consists of an IF part (or left-hand
side, antecedent, or conditional part) that when evaluated to TRUE produces
the THEN part (or right-hand side, consequent, or action).  Algorithms are not
completely under the control of the programmer, but of the underlying control
mechanism (or inference engine).  Programmers must master this underlying
process in order to specify a correct set of assertions (facts and goals to
prove).         

Although rules are representable using a frame structure (quite nicely
implemented in Ada), special languages and environments have been developed,
notably PROLOG.  Interpreters for these languages are purely procedural
programs and thus better written entirely in modern software engineering
languages like Ada.  Several Ada implementations of PROLOG (inference engines)
have been developed.  Two approaches have been observed as follows:
INTERNAL APPROACH: create Ada packages implementing inference systems.
	Sequential as well as concurrent implementations have been done. E.g.,
	each rule in this inference engine is implemented as a separate task,
	which serves to demonstrate parallelism at the rule level.  

EXTERNAL APPROACH: provide an interface between Ada and inference-oriented
	language or system. 

"Languages" and systems supporting logic programming have been designed based
on Ada.  Notably ALLAN and PROVER.  ALLAN is a language that, although based
on PROLOG, uses an Ada-like syntax, adding explanation capabilities and
confidence factors typically found in expert systems shells. In PROVER, users
supply facts and rules to prove a goal or possibly multiple goals; the system
uses a generalized first-order logic resolution algorithm to repeatedly deduce
new facts or to generate new subgoals until all alternatives are exhausted or
a special valid state has been reached.  PROVER takes advantage of Ada strong
typing and represents all assertions (well-formed formulas) as an abstract
tree whose leaves are linked lists.

There have been several Ada-based expert systems tools implemented some of
which are commercially available such as ART-Ada, CHRONOS, and CLIPS/Ada. The
RTEX system is an industry oriented system for developing embedded 
real-time expert systems.  The system integrates advance software engineering
and real-time concepts through the use of Ada, with (concurrent)
object-oriented programming, real-time inferencing, symbolic matching and
signal understanding.  Data in RTEX is kept in messages, initialized by a
burst of messages and which can come from external sources.  RTEX provides a
concurrent object-oriented language in which objects do not react on every
incoming message, but they know how to react on specific combinations of
messages. Message protocol corresponds to the left-hand side of the production
rules, whose associated "action parts" of the production rule correspond to
the methods.  In this sense, RTEX is also a data driven language in which 
execution control is triggered by the arrival of input data.  This accounts
for the high degree of parallelism in the system. 

The Helsinki Prolog System-HPS provides advanced programming tools integrated
into a programming environment to support modular Prolog systems development.
HPS was totally implemented in Ada, with some parts using Prolog primitives
(the system implements a superset of the Edinburgh Prolog Language).  The user
interface is provided out of a library of routines by using Ada PRAGMAs at the
implementation environment.  HPS consists of several integrated components,
including an interpreter-virtual machine to execute Prolog programs, a
compiler to produce a more efficient execution of predicates by the virtual
machine, an editor which ties together a syntax checker, a translator, and a
library manager in order to allow the incremental execution of intermediate
programs during the editing of source code.  HSP's shell uses tasks to allow
for concurrent queries to be handled graciously by the Ada run-time kernel.
It also permits the association of timing constraints, and thus to control the
use of resources spent in solving the queries in Prolog.
 
------..-----
If need further information, please do not hesitate to contact us.

J.L. Diaz-Herrera, chair AIWG, SIGada.