Last Updated on October 28, 2024
Prolog is a general purpose, declarative, logic programming language, often associated with artificial intelligence, computational linguistics, intelligent database retrieval, and problem solving. It’s widely used in research and education for natural language processing.
Automatic backtracking is one of the most characteristic features of Prolog. It’s a form of searching, fundamental to all artificial intelligence techniques. Prolog also supports multi-directional reasoning; arguments to a procedure can freely be designated inputs and outputs in different ways in different procedure calls. This is a powerful theorem-proving technique. Another key feature of Prolog is that its syntax and semantics are closer to formal logic than say Lisp.
Prolog is generally regarded as a difficult language to get to grips with. But learning the fundamentals of Prolog is definitely worthwhile.
1. Simply Logical by Peter Flach
Simply Logical – Intelligent Reasoning by Example aims to introduce the reader to a number of topics — logic, Artificial Intelligence and computer programming.
This is a book about intelligent reasoning. Reasoning is the process of drawing conclusions; intelligent reasoning is the kind of reasoning performed by humans.
The latter parts of the book present a number of recent extensions of Logic Programming, most of which have been accessible previously only in conference proceedings and journal articles.
Chapters cover:
- Logic and Logic Programming – introduces the main concepts in logic programming such as program clauses, query answering, proof trees, and recursive data structures.
- Clausal logic and resolution: theoretical backgrounds – deals with concepts such as Herbrand models and resolution refutations, as well as meta-theoretical notions like soundness and completeness. The presentation starts with propositional clausal logic, and proceeds via relational clausal logic (without functors) to full clausal logic, and finally arrives at definite clause logic.
- Logic Programming and Prolog – discusses the practical aspects of Prolog programming examining concepts such as SLD-tree forms, the treatment of arithmetic expressions in Prolog, second-order predicates like setof, and various programming techniques like accumulators and difference lists.
- Representing structured knowledge – discusses various ways to represent structured knowledge in Prolog.
- Searching graphs – discusses and implements some basic techniques for finding solutions in search spaces. Their common denominator is that they are exhaustive: that is, in the worst case they will eventually visit every node in the search space along every possible path, before finding a solution.
- Informed search – best-first search, a complete variant of best-first search called the A algorithm, and non-exhaustive informed search strategies, that can be derived from best-first search by limiting the size of the agenda.
- Reasoning with natural language.
- Reasoning with incomplete information.
- Inductive reasoning.
2. Logic, Programming and Prolog (2ed) by Ulf Nilsson and Jan Maluszynski
The main objective of Logic, Programming and Prolog is to provide a uniform account of both the foundations of logic programming and simple programming techniques in the programming language Prolog.
Chapters include:
- Preliminaries – contains a recapitulation of notions basic to logic in general. The chapter discusses concepts related both to model- and proof-theory of predicate logic including notions like language, interpretation, model, logical consequence, logical inference, soundness and completeness. The final section introduces the concept of substitution.
- Definite Logic Programs – introduces the restricted language of definite programs and discusses the model-theoretic consequences of restricting the language.
- SLD-Resolution – describes the operational semantics of definite programs.
- Negation in Logic Programming – discusses the use of negation in logic programming. It introduces the negation-as-definite-failure rule used to implement negation in most Prolog systems and also provides a logical justification of the rule by extending the user’s program with additional axioms.
- Towards Prolog: Cut and Arithmetic – Cut is introduced as a mechanism for reducing the overhead of Prolog computations. The chapter also discusses the use of predefined arithmetic predicates in Prolog and provides a logical explanation for them.
- Logic and Databases – describes logic programming from a database point of view.
- Programming with Recursive Data Structures – demonstrates techniques for defining relations on recursive data-structures, in particular on lists.
- Amalgamating Object- and Meta-language – introduces the notion of meta- and object-language and illustrates how to use logic programs for describing SLD-resolution. The chapter also introduces some (controversial) built-in predicates available in most Prolog implementations.
- Logic and Expert Systems – demonstrates how to extend an interpreter from the previous chapter into a simple expert-system shell.
- Logic and Grammars – shows how to describe grammars in Prolog, starting from context-free grammars. Larger classes of languages are considered. The chapter moves on to introduce the notion of Definite Clause Grammars (DCGs) commonly used for describing both natural and artificial languages in Prolog
- Searching in a State-space – demonstrates simple techniques for solving search-problems in state-transition graphs and raises some of the difficulties which are inherently associated with such problems.
- Logic Programming and Concurrency – describes a class of languages commonly called concurrent logic programming languages.
- Logic Programs with Equality – discusses an approach to integration of logic programming with functional programming based on the use of equations.
- Constraint Logic Programming – concerns the use of constraints in logic programming.
- Query-answering in Deductive Databases – concerns the use of constraints in logic programming. A rigorous semantical framework is briefly described.
The book may also be copied and distributed in paper-form for non-profit use only.
3. Prolog and Natural-Language Analysis by Fernando C.N. Pereira, Stuart Shieber
Prolog and Natural Language Analysis provides a concise and practical introduction to logic programming and the logic-programming language Prolog both as vehicles for understanding elementary computational linguistics and as tools for implementing the basic components of natural-language-processing systems.
The main objective of Prolog and Natural-Language Analysis is to provide a working understanding of basic computational linguistic and logic programming concepts.
Throughout this book, the specific concepts and techniques are given rigorous theoretical justification and are demonstrated with working programs that show how Prolog can be used to solve actual problems in syntax, parsing, and semantic interpretation. These examples culminate in a simple working natural-language question-answering system written in Prolog. Extensive bibliographic notes point the reader to related research and further reading.
Chapters cover:
- Introduction.
- Database Prolog.
- Pure Prolog.
- Further Topics in Natural-Language Analysis.
- Full Prolog.
- Interpreters.
The digital edition of the work can be reproduced and distributed subject to specified conditions.
4. GNU Prolog by Daniel Diaz
GNU Prolog is a free, open source Prolog compiler with constraint solving over finite domains developed by Daniel Diaz. It is based on the Warren Abstract Machine. The compiler also offers various extensions very useful in practice (global variables, OS interface, sockets, …).
Chapters cover:
- Introduction.
- Using GNU Prolog.
- Debugging.
- Format of definitions.
- Prolog directives and control constructs.
- Prolog built-in predicates.
- Finite domain solver and built-in predicates.
- Interfacing Prolog and C.
The author gives permission to make and distribute verbatim copies of his manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of an identical permission notice.
Next page: Page 2 – Adventure in Prolog and more books
Pages in this article:
Page 1 – Simply Logical and more books
Page 2 – Adventure in Prolog and more books
Page 3 – Warren’s Abstract Machine: A Tutorial Reconstruction and more books
Page 4 – Prolog Techniques and more books
All books in this series:
Free Programming Books | |
---|---|
Ada | ALGOL-like programming language, extended from Pascal and other languages |
Agda | Dependently typed functional language based on intuitionistic Type Theory |
Arduino | Inexpensive, flexible, open source microcontroller platform |
Assembly | As close to writing machine code without writing in pure hexadecimal |
Awk | Versatile language designed for pattern scanning and processing language |
Bash | Shell and command language; popular both as a shell and a scripting language |
BASIC | Beginner’s All-purpose Symbolic Instruction Code |
C | General-purpose, procedural, portable, high-level language |
C++ | General-purpose, portable, free-form, multi-paradigm language |
C# | Combines the power and flexibility of C++ with the simplicity of Visual Basic |
Clojure | Dialect of the Lisp programming language |
ClojureScript | Compiler for Clojure that targets JavaScript |
COBOL | Common Business-Oriented Language |
CoffeeScript | Transcompiles into JavaScript inspired by Ruby, Python and Haskell |
Coq | Dependently typed language similar to Agda, Idris, F* and others |
Crystal | General-purpose, concurrent, multi-paradigm, object-oriented language |
CSS | CSS (Cascading Style Sheets) specifies a web page’s appearance |
D | General-purpose systems programming language with a C-like syntax |
Dart | Client-optimized language for fast apps on multiple platforms |
Dylan | Multi-paradigm language supporting functional and object-oriented coding |
ECMAScript | Best known as the language embedded in web browsers |
Eiffel | Object-oriented language designed by Bertrand Meyer |
Elixir | Relatively new functional language running on the Erlang virtual machine |
Erlang | General-purpose, concurrent, declarative, functional language |
F# | Uses functional, imperative, and object-oriented programming methods |
Factor | Dynamic stack-based programming language |
Forth | Imperative stack-based programming language |
Fortran | The first high-level language, using the first compiler |
Go | Compiled, statically typed programming language |
Groovy | Powerful, optionally typed and dynamic language |
Haskell | Standardized, general-purpose, polymorphically, statically typed language |
HTML | HyperText Markup Language |
Icon | Wide variety of features for processing and presenting symbolic data |
J | Array programming language based primarily on APL |
Java | General-purpose, concurrent, class-based, object-oriented, high-level language |
JavaScript | Interpreted, prototype-based, scripting language |
Julia | High-level, high-performance language for technical computing |
Kotlin | More modern version of Java |
LabVIEW | Designed to enable domain experts to build power systems quickly |
LaTeX | Professional document preparation system and document markup language |
Lisp | Unique features - excellent to study programming constructs |
Logo | Dialect of Lisp that features interactivity, modularity, extensibility |
Lua | Designed as an embeddable scripting language |
Markdown | Plain text formatting syntax designed to be easy-to-read and easy-to-write |
Objective-C | Object-oriented language that adds Smalltalk-style messaging to C |
OCaml | The main implementation of the Caml language |
Pascal | Imperative and procedural language designed in the late 1960s |
Perl | High-level, general-purpose, interpreted, scripting, dynamic language |
PHP | PHP has been at the helm of the web for many years |
PostScript | Interpreted, stack-based and Turing complete language |
Prolog | A general purpose, declarative, logic programming language |
PureScript | Small strongly, statically typed language compiling to JavaScript |
Python | General-purpose, structured, powerful language |
QML | Hierarchical declarative language for user interface layout - JSON-like syntax |
R | De facto standard among statisticians and data analysts |
Racket | General-purpose, object-oriented, multi-paradigm, functional language |
Raku | Member of the Perl family of programming languages |
Ruby | General purpose, scripting, structured, flexible, fully object-oriented language |
Rust | Ideal for systems, embedded, and other performance critical code |
Scala | Modern, object-functional, multi-paradigm, Java-based language |
Scheme | A general-purpose, functional language descended from Lisp and Algol |
Scratch | Visual programming language designed for 8-16 year-old children |
SQL | Access and manipulate data held in a relational database management system |
Standard ML | General-purpose functional language characterized as "Lisp with types" |
Swift | Powerful and intuitive general-purpose programming language |
Tcl | Dynamic language based on concepts of Lisp, C, and Unix shells |
TeX | Markup and programming language - create professional quality typeset text |
TypeScript | Strict syntactical superset of JavaScript adding optional static typing |
Vala | Object-oriented language, syntactically similar to C# |
VHDL | Hardware description language used in electronic design automation |
VimL | Powerful scripting language of the Vim editor |
XML | Rules for defining semantic tags describing structure ad meaning |