Files
rdb/man/tabletorule.man

107 lines
1.9 KiB
Groff

.TH tabletorule "" "" "/rdb Command"
.PC "Convert a table to PROLOG rule-file format"
\fBtabletorule \fItable ... \fB> \fIprologrulefile\fR
.PP
.II "table^convert to PROLOG rules"
.II "PROLOG^convert table to rules"
The command
.B tabletorule
converts each
.I table
into a file of rules in predicate-calculus implication form
that can be input to a PROLOG interpreter.
.PP
PROLOG rules are in the form:
.DS
.I
relationship(X,Y) :- class(X), relationship(X,Y).
.DE
.PP
For example
.DM
mother(X,Y) :- female(X), parent(X,Y).
.DE
.PP
means that ``X is the mother of Y, if X is female and X is the parent of Y.''
.PP
PROLOG is a programming language used for artificial-intelligence applications.
Its name is a contraction of the phrase
.I "programming in logic."
Input to PROLOG 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 will look through its rule file to see if other facts might
logically deduce the fact requested.
.SH Example
Suppose we have the 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
the simple table
.B male
.DM
Name
----
Fred
Mike
.DE
.PP
and the simple table
.BR ruletable :
.DM
True If
----------- -------------------------
mother(X,Y) female(X), parent(X,Y)
.DE
.PP
The command
.DM
tabletorule ruletable > rule
.DE
.PP
writes the following into file
.BR rule :
.DM
mother(X,Y) :- female(X), parent(X,Y).
.DE
.PP
Now PROLOG can use its
.B consult
command to read
.BR rule .
It could then answer questions like:
.DM
mother(sally,fred)?
.DE
.SH "See Also"
.B
tabletofact
.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.