Chapter 6

Foundations of Logic Programming

6.1. Specifications and programming

The most important task of a programmer (at least till now) can be characterized as filling the gap g below:

Specification of a problem (Cannot be run) ← g → Program (Can be run)

Logic programming (LP) tends to reduce this gap (and possibly obtain g = 0) when the specification is given in a logical language (or a language close to a logical one).

It envisions calculus as a controlled deduction. This is related to the paradigm:

equ213_01.gif

In LP, the emphasis is put on what the program computes and paying as little attention as possible to how it computes. It is a declarative form of programming (as opposed to imperative programming).

We give a first glimpse of such a type of programming.

EXAMPLE 6.1.– Imagine that in the following graph, we want to know whether there are paths from A to I, and if so, which ones.

equ214_01.gif

a) We describe the graph using a unary predicate (which corresponds to a property).

Att(x): x is attainable

Premises

Att(A); % Must not be forgotten!

equ214_02.gif

The conclusion:

equ214_03.gif

Two essential questions:

i) which inference ...

Get Logic for Computer Science and Artificial Intelligence now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.