110 lines
2.1 KiB
Groff
110 lines
2.1 KiB
Groff
.TH tabletofact "" "" "/rdb Command"
|
|
.PC "Converts a table to PROLOG fact-file format"
|
|
\fBtabletofact \fItable ... \fB> \fIprologfactfile\fR
|
|
.PP
|
|
.II "table^convert to PROLOG facts"
|
|
.II "convert table to PROLOG facts"
|
|
.II "PROLOG^convert table to facts"
|
|
The command
|
|
.B tabletofact
|
|
converts each
|
|
.I table
|
|
into a file of facts in predicate calculus functor form,
|
|
which can be input to a PROLOG interpreter.
|
|
.SH Facts
|
|
PROLOG
|
|
facts are in the form
|
|
.IR relationship(subject,object) .
|
|
For example, the fact
|
|
.DM
|
|
parent(sally,fred)
|
|
.DE
|
|
.PP
|
|
means that ``sally is the parent of fred''.
|
|
.PP
|
|
PROLOG is a programming language whose name is a contraction of the phrase
|
|
.IR "programming in logic" .
|
|
Its input consists of
|
|
.IR facts ,
|
|
.IR rules ,
|
|
and
|
|
.IR questions .
|
|
If you build a data base of facts and rules,
|
|
you can ask questions and get answers.
|
|
If a question you ask does not have a
|
|
corresponding fact in the data base,
|
|
PROLOG looks through its rule file to see if other facts might
|
|
logically deduce the fact requested.
|
|
.SH Example
|
|
Suppose we have these simple table
|
|
.B parent
|
|
.DM
|
|
Parent Child
|
|
------- -------
|
|
Sally Fred
|
|
Mike Fred
|
|
Fred Jane
|
|
.DE
|
|
.PP
|
|
the simple table
|
|
.B female
|
|
.DM
|
|
Name
|
|
----
|
|
Jane
|
|
Sally
|
|
.DE
|
|
.PP
|
|
and the simple table
|
|
.BR male :
|
|
.DM
|
|
Name
|
|
----
|
|
Fred
|
|
Mike
|
|
.DE
|
|
.PP
|
|
The command
|
|
.DM
|
|
tabletofact parent female male > fact
|
|
.DE
|
|
.PP
|
|
produces the following facts:
|
|
.DM
|
|
parent(Sally,Fred).
|
|
parent(Mike,Fred).
|
|
parent(Fred,Jane).
|
|
female(Jane).
|
|
female(Sally).
|
|
male(Fred).
|
|
male(Mike).
|
|
.DE
|
|
.PP
|
|
As you can see,
|
|
the relationship is set by the name of the table, and the subject and
|
|
object (if any) are set by the data in each row.
|
|
.PP
|
|
PROLOG
|
|
can now use its command
|
|
.B consult
|
|
to read this file.
|
|
If PROLOG
|
|
had rules about father, mother, grandparent, and so on,
|
|
then it could answer questions like:
|
|
.B mother(sally,fred)?
|
|
That fact is not in the data base, but can be deduced from rules like:
|
|
.DM
|
|
mother(X,Y) if parent(X,Y) and female(X)
|
|
.DE
|
|
.PP
|
|
.SH "See Also"
|
|
.B
|
|
tabletorule
|
|
.R
|
|
.SH Notes
|
|
.II COHware
|
|
If you wish to experiment with PROLOG,
|
|
volume 2 of
|
|
.B COHware
|
|
includes the source code for a PROLOG interpreter.
|