next up previous contents
Next: Facts and rules Up: Logic programming Previous: Logic programming   Contents

Introduction to logic programming

Logic programming is a probably more accurately called ``programming with relations'', in contrast to functional programming, which is ``programming with functions''.

The idea is that a function $f$ with $n$ arguments can always be written as a relation $R_f$ with $n{+1}$ arguments:


\begin{displaymath}
f(x_1,x_2,\ldots,x_n) = y \mbox{~iff~} (x_1,x_2,\ldots,x_n,y) \in
R_f
\end{displaymath}

Having gone from functions to relations, we can generalize our objectives and give rules to compute not only those special relations that correspond to functions (where the last component of each tuple is uniquely fixed by the others), but more general relations as well.

We will describe logic programming using a syntax that is based on Prolog, the most commonly used programming language in this paradigm.



Subsections

Madhavan Mukund 2004-04-29