![]() ![]() ![]() ![]() ![]() | Object-Oriented Language: Prolog | ![]() |
Prolog is a goal-oriented, implicative language based on predicate logic. Goal-oriented means that a program proceeds by attempting to achieve a goal which is itself defined by other goals. Prolog operates in an inferential or implicative way: What you write are implications, and operation flows from one impliction to the next implied goal. A line of Prolog code is generally either a rule or a fact - code and data being largely interchangable. Prolog code often has a declarative interpretation, meaning that it specifies "what" exists but not "how." This is different from imperative in which a program defines a series of steps to carry out (C or Basic for example).
PROLOG means PROgramming in LOGic. Implications are specified in the form of logical predicates called Horn clauses. A horn clause consists of a sought implication (a goal clause), and a set of clauses that must be be proven separated by :-. which simply means "if." A typical Prolog statement has the form:
goalclause(Vg) :- clause1(V1),..,clausem(Vm)
which means goalclause is true for variable set Vg if the series of clauses clause1,..,clausem are true. In other words:
goalclause(Vg) is true if clause1(V1) and ... and clausem(Vm) are true.
To represent just a fact instead of a rule, you specify just the head part of the horn clause (An implication with no conditions required to make it true is essentially a fact). Here is a sample with one rule and two facts:
grandmother(G,S) :- parent(P,S), mother(G,P).
mother(sarah,issac).
parent(issac, jacob).The first statement means G is the grandmother of S if there is a parent P of S and G is the mother of P. The next two statements are facts indicating that issac is a parent of jacob and that sarah is the mother of issac.
Prolog finds solutions by unification: binding a variable to a value. For an implication to succeed, all goal variables Vg on the left side of :- must find a solution by binding variables from the clauses which are activated on the right side. Standard Prolog evalutates clauses from left to right. When all clauses are examined and all variables in Vg are bound, the goal succeeds. But if a variable can not be bound for a given clause, that clause fails. When any clause fails, Prolog backtracks - it goes back to the left to a previous clauses to continue trying to unify with alternative bindings. Backtracking give Prolog the ability to find multiple solutions to for a given query or goal.
History: Prolog was created in the early 1970s by Alain Colmerauer, Robert Kowalski, Phillipe Roussel and collegues. Modern implementation began with a virtual machine called the "Warren Abstract Machine" implemented by David H. D. Warren at Edinburgh. The Prolog language is now defined by an ISO (1995) Standard. However, much current theoretical value comes from continuing develoment: extensions, modifications and experimental aspects.
Continuing Development: The developmental aspects of Prolog and logic programming include:
- Constraint logic programming (CLP)
- Parallelism and concurrency
- Linear logic (LLP)
- Inductive logic (ILP)
- Committed Choice Languages
- Higher-Order Logic (HOL)
- Object-oriented programming (OOLP).
- Java and XML Interoperability
Object-oriented Aspects: OOLP of course relates directly to object orientation. Many Prolog systems directly incorporate OO capabilities. LOGIN, was an early OO extension of Prolog created in the mid-1980s by Ait Kaci (also the creator of the LIFE language) and Nasr. However, today, nearly all Prolog systems can use OOLP through an OO add-on called LogTalk.
In addition most of the other developments above relate to OO and/or component capabilities in some way. And some go beyond traditional OO. For instance, some Constraint programming systems enhance Prolog so that it can bind variables "incrementally" so that variables are constrained (numerically, by enumarated type, or by class) before they are bound. Some standard Prolog systems include CLP extensions.
Some logic languages Mercury, KLIC, Mozart and Gödel incorporate concurrency and parallelism and eliminate or restrict backtracking and unification. These are known as committed choice languages. They not Prolog, at least not as defined above, but are they logic languages. Others, ECLiPSe and BAP, however, offer parallelism and are extentions of Prolog.
Linear logic models causality, state transitions, and accounting for resources used in logic. Linear logic programming originated from the work of Jean-Yves Girard. Linear logic systems such as Lolli and LLP are supersets (more or less) of Prolog that define additional operations for these purposes. Closely related to LLP is higher-order logic (HOL), as embodied in Lambda Prolog. HOL concerns topics such as provability and correctness and other functional programming concepts as opposed to OO, but is also used in solving problems concerning mobile agents (Pi Calculus) as defined by Robin Milner and others.
Progol is a superset of Prolog that provides rapid definition of classes and attributes. It includes extensions for inductive logic. Inductive logic often uses a schema of classes, instances and attribute values to define a rule base.
In fact, objects, attributes, and inheritance are a frequent focus in logic applications. The ISO Prolog standard does not define traditional OO features: classes, inheritance, methods, and events (although OO standards are under consideration). However, Prolog is highly extensible. OO capabilities can be and often are implemented in extensions. Implementing traditional multiple inheritance can be done with just a few Prolog statem-ents, albiet maybe simplistically. But, it is equally possible to equip Prolog with additional object and inheritance capabilities not available in traditional OO.
Doing so is sometimes necessary. Many practical and research logic problems push beyond the capabilities of traditional OO. In reasoning about beliefs, norms, learning, linguistics, agents, and incomplete knowledge, inheritance is extra-hierarchial and fluid. Knowledge changes over time and occurs as inheritance networks rather than as strict hierarchies - Additional inheritance and object relation styles need to be considered. It is valuable to view inheritance network tools as advanced OO with added capabilities for role definition, defeasibility, nonmonotonicity, abduction, and preferencial inheritance.
In addition to OO extensions, there are also interoperability tools, database tools, deductive database Prolog systems, open source C++ WAM implementations, and Java implementations of Prolog and Java-Prolog libraries. I would hazard a guess, there are now more combinations of Java-Prolog than of any other two computer langauges anywhere. Prolog-Java combinations often enable Prolog access to Java objects, properties, reflection capabilities, and wide array of interfaces.
This page includes:
- Liner Logic and Prolog systems with OO abilities and/or extensions.
- Generic OO extensions that can be used with standard Prolog.
- Prolog - Java implementations and C++ WAM implementations.
- Interoperability with the OO world: GUI, Web, and with Deductive, OO, and relational databases.
- Works that consider inheritance networks, and advanced inheritance.
OO provides an exciting and even broad, if incomplete spectrum in which to view logic programming, a field which is extensive and growing. This page thus explores many of the flavors of Prolog and LP.
![]()
Prolog (and LLP) with OOP built-in support or extensions::
OO extensions to use with Prolog systems
Committed Choice Languages
Nonmonotonic Prologs and Prolog Extensions
Linear Logic Languages
Java-Prolog Implementations and Interfaces