Write up on Tech Geek History: Prolog extensive Summary

Researched/Written by Shaun Scott:
Purpose is to Bring Artificial Intelligence awareness to the Community by Peer to Peer Review Journals
Literature Review

Logic Programming is the name of a programming paradigm which was developed in the 70s. Rather than viewing a computer program as a step-by-step description of an algorithm, the program is conceived as a logical theory, and a procedure call is viewed as a theorem of which the truth needs to be established. Thus, executing a program means searching for a proof. In traditional (imperative) programming languages, the program is a procedural specification of how a problem needs to be solved. In contrast, a logic program concentrates on a declarative specification of what the problem is. Readers familiar with imperative programming will find that Logic Programming requires quite a different way of thinking. Indeed, their knowledge of the imperative paradigm will be partly incompatible with the logic paradigm.
This is certainly true with regard to the concept of a program variable. In imperative languages, a variable is a name for a memory location which can store data of certain types. While the contents of the location may vary over time, the variable always points to the same location. In fact, the term ‘variable’ is a bit of a misnomer here, since it refers to a value that is well-defined at every moment. In contrast, a variable in a logic program is a variable in the mathematical sense, i.e. a placeholder that can take on any value. In this respect, Logic Programming is therefore much closer to mathematical intuition than imperative programming.
Imperative programming and Logic Programming also differ with respect to the machine model they assume. A machine model is an abstraction of the computer on which programs are executed. The imperative paradigm assumes a dynamic, state-based machine model, where the state of the computer is given by the contents of its memory. The effect of a program statement is a transition from one state to another. Logic Programming does not assume such a dynamic machine model. Computer plus program represent a certain amount of knowledge about the world, which is used to answer queries
https://book.simply-logical.space/src/simply-logical.html

The Prolog programmer straightforwardly describes the grandfather concept in explicit, natural terms: a grandfather is a father of a parent. Here is the Prolog notation: grandfather(X, Z) :- father( X, Y), parent( Y, Z)

Prolog is a programming language centered around a small set of basic mechanisms, including pattern matching, tree-based data structuring, and automatic backtracking. This small set constitutes a surprisingly powerful and flexible programming framework. Prolog is especially well suited for problems that involve objects – in particular, structured objects – and relations between them. For example, it is an easy exercise in Prolog to express the spatial relationships suggested in the cover illustration – such as, the top sphere is behind the left one. It is also easy to state a more general rule: if
X is closer to the observer than Y and Y is closer than Z,
then X must be closer than Z.
Prolog can now reason about the spatial relations and their consistency with respect to the general rule. Features like this make Prolog a powerful language for Artificial Intelligence and non-numerical programming in general. Prolog stands for programming in logic – an idea that emerged in the early 1970s to use logic as a programming language. The earty developers of this idea included Robert Kowalski at Edinburgh (on the theoretical side), Maarten van Emden at Edinburgh (experimental demonstration), and Alain Colmerauer at Marseilles (implementation). The present popularity of Prolog is largely due to David Warren’s efficient implementation at Edinburgh in the mid 1970s. Since Prolog has its roots in mathematical logic it is often introduced through logic. However, such a mathematically intensive introduction is not very useful if the aim is to teach Prolog as a practical programming tool. Whereas conventional languages are procedurally oriented, Prolog introduces the descriptive, or declarative, view. This greatly alters the way of thinking about problems and makes learning to program in Prolog an exciting intellectual challenge.
Fundamental AI techniques are introduced and developed in depth towards their implementation in Prolog, resulting in complete programs. These can be used as building blocks for sophisticated applications. Techniques to handle important data structures, such as trees and graphs? are also included PREFACE although they do not strictly belong to AI. These techniques are often used in AI programs and their implementation helps to learn the general skills of Prolog programming. Throughout, the emphasis is on the clarity of programs; efficiency tricks that rely on implementation-dependent features are avoided. Prolog and Artificial Intelligence. It can be used in a Prolog course or in an AI course in which the principles of AI are brought to life through Prolog.
https://silp.iiita.ac.in/wp-content/uploads/PROLOG.pdf
Characteristics of PROLOG There are a number of reasons why Prolog is so suitable for the development of advanced software systems:

  • Logic programming. Prolog is a logical language; the meaning of a significant frac tion of the Prolog language can be completely described and understood in terms of the Horn subset of first-order predicate logic (Horn-clause logic). So, this is the mathematical foundation of the language, explaining its expressiveness.
  • A single data structure as the foundation of the language. Prolog offers the term as the basic data structure to implement any other data structure (lists, arrays, trees, records, queues, etc.). The entire language is tailored to the manipulation of terms.
  • Simple syntax. The syntax of Prolog is much simpler than that of the imperative programming languages. A Prolog program is actually from a syntactical point of view simply a sequence of terms.
    For example, the following Prolog program p(X) :- q(X). corresponds to the term :-(p(X),q(X)). Whereas the definition of the formal syntax of a language such as Java or Pascal requires many pages, Prolog’s syntax can be described in a few lines. Finally, the syntax of data is exactly the same as the syntax of programs!
    Backtracking is a mechanism in Prolog that is offered to systematically search for solutions of a problem specified in terms of Prolog clauses. A particular Prolog specification may have more than one solution, and Prolog normally tries to find one of those. When it is not possible to prove a subgoal given an already partially determined solution to a problem, Prolog does undo all substitutions which were made to reach this subgoal, and alternative substitutions are tried. The search space that is examined by the Prolog system has the form of a tree. More insight into the structure of this space is obtained by a Prolog program that itself defines a tree data structure: /1/ branch(a,b). /2/ branch(a,c). /3/ branch(c,d). /4/ branch(c,e). /5/ path(X,X). /6/ path(X,Y) : branch(X,Z), path(Z,Y)
    Prolog was initially designed to process natural languages. Its application in various problem solving areas has brought out its qualities, but has also made clear its limits. Some of these limitations have been overcome as a result of more and more efficient implementations and ever richer environments. The fact remains, however, that the core of Prolog, namely, Alan Robinson’s unification algorithm [22], has not fundamentally changed since the time of the first Prolog implementations, and is becoming less and less significant compared to the ever-increasing number of external procedures as, for example, the procedures used for numerical processing. These external procedures are not easy to use. Their invocation requires that certain parameters are completely known, and this is not in line with the general Prolog philosophy that it should be possible anywhere and at any time to talk about an unknown object x. In order to improve this state of affairs, we have fundamentally reshaped Prolog by integrating at the unification level : (1) a refined manipulation of trees, including infinite trees, together with a specific treatment of lists, (2) a complete treatment of two-valued Boolean algebra, (3) a treatment of the operations of addition, subtraction, multiplication by a constant and of the relations , =, (4) the general processing of the relation ?. By doing so we replace the very concept of unification by the concept of constraint solving in a chosen mathematical structure. By mathematical structure we mean here a domain equipped with operations and relations, the operations being not necessarily defined everywhere. The result of incorporating the above features into Prolog is the new programming language Prolog III. In this paper1 we establish its foundations and illustrate its capabilities using representative examples. These foundations, which in fact apply to a whole family of “Prolog III like” programming languages, will be presented by means of simple mathematical concepts without explicit recourse to first-order logic
    https://cs.bme.hu/~szeredi/nlp/Colmerauer-Prolog-III.pdf

There are only three basic constructs in Prolog: facts, rules, and queries.
A collection of facts and rules is called a knowledge base (or a database) and Prolog programming is all about writing knowledge bases. That is, Prolog programs simply are knowledge bases, collections of facts and rules which describe some collection of relationships that we find interesting.
So how do we use a Prolog program? By posing queries. That is, by asking questions about the information stored in the knowledge base. The computer will automatically find the answer (either True or False) to our queries.
Prolog is a language built around the Logical Paradigm: a declarative approach to problem-solving.
There are only three basic constructs in Prolog: facts, rules, and queries.
A collection of facts and rules is called a knowledge base (or a database) and Prolog programming is all about writing knowledge bases. That is, Prolog programs simply are knowledge bases, collections of facts and rules which describe some collection of relationships that we find interesting.
So how do we use a Prolog program? By posing queries. That is, by asking questions about the information stored in the knowledge base. The computer will automatically find the answer (either True or False) to our queries.
https://www.101computing.net/prolog-family-tree/

Prolog under a database perspective. Prolog is interesting for students and researchers in the database area for a number of reasons:

  • Prolog itself may serve as a prototype database language as relational algebra can be expressed directly, including tabular relations, views and integrity constraints
    • Prolog is a programming language that is very easy to learn and in which it is fairly straight forward to implement and experiment with different database functionalities.
    • Prolog is based on first-order logic so that programs have a clear semantics that can refer to a large body of knowledge and tradition.
    • • It represents live logic in a way that is much more appealing than a myriad of Greek letters and strange symbols on paper. And a good supplement to or a starting point for the one who wants to dig into the database literature which is inherently loaded with logic.
    The real advantage of Prolog in this context is as an experimental tool, which can give a clearer understanding of underlying concepts and serve as workbench for developing new methods in the shape of running prototypes. It is much easier to play with different variations of some advanced database functionality in a Prolog program than doing so by modifying the source code of a big relational database system! In what follows, we introduce Prolog to a level which is intended to make it possible for the reader to write interesting and working Prolog programs, and to see the similarity with databases on the one side and logic on the other. Prolog as they are useful for the understanding o
  • f databases and their semantics in general

Prolog is a programming language based on a subset of first-order logic and the syntactic and
semantic notions of Prolog are more or less taken over from logic. There are, however, a few (and
occasionally quite unfortunate) clashes in usage between the two worlds that will be noticed in the
sequel, mostly as footnotes.
In the following we introduce the basic elements of the Prolog language, which coincide with
the subset called Datalog;

Datalog, like Prolog, is a logic programming language. However, the semantics of Datalog differ from the
semantics of Prolog. Syntactically, Datalog is a subset of Prolog.
In a Datalog program, the order of clauses are not important: a Datalog program can be thought of
as a set of clauses, rather than a list. Moreover, unlike Prolog queries, Datalog queries (on finite sets) are
guaranteed to terminate. Indeed, evaluation of Datalog programs is polynomial in the size of the program.
More specifically, it is possible to enumerate all the ground terms implied by a Datalog program (i.e., a set
of clauses) in time polynomial in the number of clauses in the program. (The degree of the polynomial is
essentially the maximum number of variables that appear in any rule.)
In order to achieve decidability, Datalog is less expressive than Prolog. In particular, Datalog makes the
following restrictions.

  • Datalog does not allow functions with arity greater than 0. That is, the syntax for terms permits only
    variables and constants.
    Terms s, t ::“ X | f
    So, for example, whereas appendpconspalice, []q, []q is a syntactically valid Prolog atom, it is not syntactically valid Datalog.
  • Datalog requires that any variable that appears in the head of a clause also appears in the body of the
    clause. For example, the clause foopX, Y q :– barpXq. is not allowed in Datalog, since the variable Y
    appears in the head of the clause, but not the body.
    (There are also some additional restrictions when we allow negation.
  • https://groups.seas.harvard.edu/courses/cs152/2015sp/lectures/lec23-prolog.pdf

Prolog under a database perspective. Prolog is interesting
for students and researchers in the database area for a number of reasons:

  • Prolog itself may serve as a prototype database language as relational algebra can be expressed
    directly, including tabular relations, views and integrity constraints.
  • Prolog is a programming language that is very easy to learn and in which it is fairly straightforward to implement and experiment with different database functionalities.
  • Prolog is based on first-order logic so that programs have a clear semantics that can refer to
    a large body of knowledge and tradition.
  • It represents live logic in a way that is much more appealing than a myriad of Greek letters
    and strange symbols on paper. And a good supplement to or a starting point for the one who
    wants to dig into the database literature which is inherently loaded with logic.
    We do not, in general, advocate to use Prolog for storing really large amounts of data, as traditional
    database systems are much better for this purpose. The real advantage of Prolog in this context is
    as an experimental tool, which can give a clearer understanding of underlying concepts and serve
    as workbench for developing new methods in the shape of running prototypes.
  • It is much easier to
    play with different variations of some advanced database functionality in a Prolog program than
    doing so by modifying the source code of a big relational database system

https://groups.seas.harvard.edu/courses/cs152/2015sp/lectures/lec23-prolog.pdf

Leave a Comment

Your email address will not be published. Required fields are marked *