Channels ▼
RSS

Parallel

The Practical Application of Prolog


The Practical Application of Prolog

Source: AI Expert, April 1993

Prolog is no longer confined to research laboratories, but is now considered to be a powerful tool for the development of commercial applications

Prolog is no longer the best-kept secret in the programming industry. The Prolog programming language is not solely an AI language confined to research laboratories, but is increasingly seen as a powerful tool for the development of practical applications. The technology is now in widespread use in a wide range of domains, including finance, defense, telecommunications, law, medicine, agriculture, engineering, manufacturing, and education. Prolog has some clear advantages over other programming languages and can to significant returns on investments and completive advantages. Through the recently formed Prolog Vendors Group together with events such as the Prolog 1000 catalog, we now have solid information that many hundreds of fielded applications, demonstrating that Prolog is fast becoming the language of choice for many software developers.

HISTORY
The Prolog programming language originated from work done in the early 1970s by Robert A. Kowalski at Edinburgh University (and ever since at Imperial College, London) and Alain Colmerauer at the University of Aix-Marseille (France). Kowalski's research on the field of automated deduction led in 1972 to the development with Colmerauer of the use of formal logic as a programming language. Kowalski's research provided the theoretical framework, while Colmerauer's gave rise to the programming language Prolog. Colmerauer and Phillipe Roussel built the first Prolog intrepreter, and David Warren at the University of Edinburgh built the first Prolog compiler (for the DEC-10 machine). Most commercial implementations of Prolog now use this same Edinburgh Prolog syntax.

Since then, Prolog has grown in popularity throughout Europe, the United States, and in Japan. In Europe, Prolog is widely used. In the United States, Prolog is thriving, and suppliers of Prolog-based constraint technology report that it is a prime market. In Japan, Prolog was the fundamental technology underlying the ICOT Fifth Generation Computer System Imitative, which started in 1982. The Japanese interest in Prolog has gone some way in accounting for the growth of the language elsewhere; although interestingly, ICOT has been widely regarded as a major success.

PIGS
When you ask what Prolog is good for, it is tempting to point to its clear success for a particular set of application areas, including natural language and databases. While it is true that Prolog has qualities that are especially well-suited to these domains, Prolog is used for a surprisingly broad range of application areas.


One of the more interesting applications is PigE/Auspig—and expert system for raising pigs, which won the award for the best presentation at The First International Conference on the Practical Applications of Prolog. PigE is an intelligent backend to a mathematical modeling package called Auspig. The Auspig model simulates the growth and reproduction of pigs, identifies factors that limit optimal performance of the pig, and suggest management strategies that maximize profits. PigE presents an abstracted description of the output of the model in a form a nonmathematician can understand and suggests dietary, housing, genotyping, or resource input changes, which the developers say can dramatically improve the profitability of the herd.

Despite the rather wacky nature of this application, the PigE/Auspig have led to some startling returns on investment. PigE discovered that increasing the air flow over a hot pig shed by 0.2-0.6 meter per second (an increase not really discernable by humans), doubled the animals' growth rate. In one spectacularly successful study of a pig farm, Auspig was used to develop a growing regime that led to 496% increase in profits (from $40,992 to $202,231).

According to the developers of the system, verification studies have demonstrated that the expert system can significantly outperform human experts interpreting the output of the model (performance measured in dollars per square meter per day). In an unusual case, the improvement is in the order of 10%. If spread over the 300 kiloton $500 million (per annum) Australian pig herds, the developers believe that this improvement would be in the order of $50 million. PigE is now in routine use in the United States, the Netherlands, Belgium, France, Spain, and Australia.

ENVIROMENT
Another area where Prolog is successful is as environmental systems that predict the weather, analyze water supplies, and so on. The MM4 Weather Modeling System, developed at Penn State University and the National Center for Atmospheric Research in (Boulder Colo.), gives relatively detailed, short term forecast of meteorological conditions if the continental United States. It is used particularly to model pollutant dispersion (for instance, acid rain deposition). The original program, which contained 16,000 lines of FORTRAN code, was harnessed with Strand88, and 10-fold speedups have been obtained with 15 parallel processors.

The Air Pollution Control System, developed using the Hungarian product MPROLOG, handles data about the concentration of industrial pollutants in Budapest and other countries of Hungary. Designed for such users as managers and research workers, the system checks whether the air pollution of working or planned plants is below the permitted level. If permitted levels are exceeded, the system recommends appropriate filtering equipment.

RoadWeather is a 24-hour weather prediction system for snow and ice control on highways. Developed using PDC Prolog version 3.30 for Windows 3.1, RoadWeather Pro consists of three components. The first component is a numerical weather prediction system that forecasts from specified initial (radio sound and surface observations) and boundary conditions (detailed terrain effects) using a system of hydrodynamic and thermodynamic differential equations. This part of the system is written in FORTAN. The second component is a graphical user interface (GUI) written in Prolog under Windows 3.1, which the developers say is fully interactive and displays predicted weather phenomena as symbolic objects. The final component is an Expert Weather Advisor, written in Prolog and Windows 3.1, which permits mouse point and click manipulation of weather "objects" thereby allowing forecast upgrades based of recent observational data received from sensors or human observers. The RoadWeather Pro system is in use at the WELS Research Corp. (Boulder Colo.).

WATER
A series of Prolog expert systems has been developed at the U.K.'s University of Surrey, and several are targeted for the water industry. One of these systems WIESSE, which was built as part of the WIESC Alvey Project, provides an expert system development environment. WIESSE has been used to develop two expert systems: WADNES and SERPES. WADNES provides support for emergences that can occur in a water distribution system by using a model of the distribution network to suggest methods of re-supplying water—informing appropriate bodies and managing remedial resources. WADNES creates input data files for large commercial FORTRAN simulation program, runs the simulation, and interprets the output through intelligent processing. While these applications were developed as demonstrator systems, they are generating considerable interest throughout the U.K.'s private water companies.

Paul Holmes-Higgins, senior researcher fellow and prime mover behind the development of these systems, believes that Prolog is an ideal language for rapid prototyping, since it contains characteristics and constructs that would otherwise have to be implemented in C. "Characteristics such as unification and arbitrary data structures (Prolog terms) allow me to 'sketch' a program out and yet be able to execute it; there are no type declarations required, no memory allocation, just solving the problem," he said. Holmes-Higgins says this lets him involve the end user at a much earlier stage in the development process.

Holmes-Higgins notes that Prolog is a higher level language than C, so there is much less source code to maintain. "A well written Prolog program is more readable than a well written C++ program by respective experienced programmers" he said.

Historically, Prolog has sometimes been criticized for poor performance, but many argue that this is no longer a problem. Indeed, Holmes-Higgins believes that current Prolog technology provides run-time performance that is not noticeably slower than C programs. Often, says Holmes-Higgins, Prolog applications have a smaller memory "footprint. "I think commercial Prolog systems have a smaller 'footprint' in terms of memory and disk requirements than Lisp systems. You can write some very useful programs in DOS-based Prolog using the 640K limit—I'm not aware of a 640K DOS Lisp system"

AIR
Boeing Corp., the aircraft giant, is a major user of Prolog technology. Connector Assembly Specifications Expert (CASEy) is an expert system that guides shop floor personnel in the correct usage of electrical process specifications. CASEy provides detailed assembly instructions for terminating wire into electrical interconnects such as connectors, terminal lugs, splices, and so on. It provides a prioritized list of authorized tools, settings, materials, and procedures (with graphics), needed to perform the task. In practice, the system reduces the time for an operator to assemble a set to instructions from 42 to five minutes.

A Generalized Query System, developed by Boeing Computer Services, uses a client/server architecture and provides a high-level abstraction mechanism for access to diverse sources of data and knowledge. The system offers an access mechanism for either a Prolog or C program that provides a data abstraction service layer. External data access and interpretation are encapsulated in the conceptual views and meta data of the Generalized Query Server. The "core" Generalized Query System software provides a query language and network access layers so that application developers can access any of the encapsulated data sources. Data from flat files, databases, object-orientated databases, or even expert systems can be encapsulated, and the developers say that the query language makes the physical data access mechanisms and network layers transparent.

The system follows work on "mediators" (by Wiederhold at Stanford University), or intelligent agents. Bill McClay, senior principal scientist and AI specialist at Boeing, explains that the idea is to have intelligent agents between databases and applications in a distributed client-server network. These give a much higher level of abstraction in manipulating the data inside such crude things as databases. McClay says "Basically the idea is that you turn that data into information by having a layer of intelligence in each of the nodes where the data exists."

The developers say the generalized query language is much like Prolog, but has several additional features such as a second order logic, abstract data types, and object oriented syntax. The systems were developed using Quintaus Prolog version 3.1 running on Sun 4, VAX, and RS6000 workstations.

Bill McClay says it would have been much harder to develop these applications in any other language. "Prolog was a particularly good match for building the query engine because the language was so close the semantics of the language we wanted to build in terms of backtracking and unification." Comparing Prolog with Lisp and other languages, he added, "The work necessary to write a query engine in prolog was minimal compared to Lisp. Doing it in a conventional language would have been unthinkable, because it would have meant re-inventing Prolog."

BALL GAMES
Prolog is being used for fielded heavyweight applications, and benefits can result from using the language. But Prolog is a far more interesting language than, say, C++—and it is starting to finds its way into our homes.

The Fantasy Basketball system has been used for two years to produce the weekly standings for the Bay Area Fantasy Basketball League of Palo Alto, Calif. Fantasy (or Rotisserie) Basketball leagues are a growing hobby among avid basketball fans, consisting of fictitious teams who are in the NBA and featuring competitions between teams based on the game statistics of their NBA players.

John Dowding maintains Rotisserie/Fantasy Basketball leagues, keeps weekly NBA statistics in a Prolog database, and ranks NBA players and teams. The Prolog program downloads the weekly NBA stats, converts them into a Prolog clause database, and computes the weekly standings for teams in the league. The resulting NBA statistics database is also used to rank NBA players and predict future performance. Dowding says Prolog has been an excellent vehicle for this task because of its built-in support for databases, sorting, and parsing. The system was developed using Quintus Prolog versions 2.5-3.1.

Toernooi Assistant, developed by J.G. de Lint of the Netherlands, aims to automate everything about tennis tournaments. Developed using PDC Prolog v. 3.3, Toernooi Assistant provides optimal planning and scheduling of matches, fast replanning in case of rain, player administration, seeding and drawing of lots for the arrangement of the players, processing of the match results, generation of press releases, and financial support.

Nor is Prolog limited to basketball and tennis. Perfect Pitch is a sports advisor expert system built to advise the safest and most economical sports surface to use for a given sport. The developers say that the system will also advise formal specifications to aid in the tender process. Developed using PDC Prolog v. 3.21, the system is being used in Australia and is aimed particularly at local government, engineers, and architects.

THE GOLD RUSH
Finally, the U.S. gold rush could have been a lot more effective using Prolog. Goldfinder is a knowledge-based system that advises an exploration geologist on where to find gold. Developed by D.D. Hawkes using MacProlog from the London-based Logic Programming Associates, the Goldfinder system assesses the potential of a gold prospect and gives advice on the best location to site a drill hole. The geologist's map of the prospect is the primary source of input data. Knowledge is stored partly as semantic networks but mainly in a production rule formalism. Through interaction with the user, the system establishes a sophisticated dynamic database containing information about the main lithologies, the nature of any mineralization or alteration, and the structural features of eh prospect. Using a method of intersecting loci, the system locates a drill site with a precision governed only by the scale of the map. Race you to the hills folks..... but don't bring your C++ compilers.

PROLOG IS EVERYWHERE
Prolog's fast incremental development cycle and rapid prototyping capabilities have encouraged the use of the language as a tool for solving AI problems. However, other features of Prolog make it a particularly powerful tool for building robust commercial applications. These features include interfaces to other languages and database products, stand-alone application generators, and more recently, support for techniques such as object-orientated and constraint based programming

Object-oriented extensions to Prolog have increased the attractiveness and expressive power of the language and provide Prolog users with a powerful and flexible object-orientated development language. Constraints replace Prolog's usual pattern-matching mechanism with a more general operation called "constraint satisfaction." Constraints are a powerful way to reduce the size of the search space and thus increase the efficiency of the scheduler.

Prolog has grown from a simple stand-alone interpreter into a full compiler-based technology with links to external databases, GUIs, and other languages such as C, and in so doing has effectively made the transition from academic-theorem prover to a complete general-purpose programming language. Prolog technology will continue to mature and build on its foundation. The language will be increasingly deployed in systems, data processing systems, and specialized markets such as scheduling, help-desks, configuration and planning.

Enhancing the declarative nature of logic programming with additional features such as object-oriented extensions and constraint-based techniques results in very efficient and powerful Prolog systems. These facilities, together with increased integration to fourth-generation languages, are helping to position Prolog as an effective information-management tool. By adding value to mainstream data processing environments, Prolog will provide the key to handling the complex information repositories of the future.

Al Roth is a freelance writer and group secretary of the Prolog Vendors Group.


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.
 

Video