Subject: Prolog for Lojbanists (was: lojban application in wearable computing)

From: John Cowan <[email-masked]>
Date: Thu, 14 Mar 2002 11:07:36 -0500 (EST)

Rob Speer scripsit:

> I wish I knew something about what Prolog was.

Short summary of Prolog for Lojbanists:

A Prolog program consists of a database of rules and facts. A rule
is a bridi with the following restricted grammar:

<rule> = <simple-bridi> .ijanai <simple-bridi> |
<simple-bridi> .ijanai tu'e <conjunct> tu'u

<conjunct> = <simple-bridi> | <simple-bridi> .ije <conjunct>

<simple-bridi> = <simple-sumti>* <brivla> <simple-sumti>*

<simple-sumti> = la <name> | <quantified-variable> | li <number>
lo <brivla> <be-beho>?

<be-beho> = be <simple-sumti> (bei <simple-sumti)* be'o

All variables are always quantified universally with a scope
extending over the whole rule. Facts are degenerate rules with
just a "<simple-bridi>", and are treated as unconditional rules.
A fact or rule is said to be "ground" if there are no variables in it.

Prolog interpreters accept queries, which are simple-bridi, and return
all values of all variables in the simple-bridi which, when substituted
for those variables, produce either facts in the database or facts
deducible from the facts and rules in the database.

Here is a trivial Prolog program in Lojban syntax:

la djan. patfu la djordj.
.i la djordj. patfu la fred.
.i roda rode rodi zo'u
da patpatfu de .ijanai tu'e
da patfu di .ije di patfu de tu'u

.i ma patpatfu la fred.

To which the Prolog system will reply "la fred." The system sees that
"ma patpatfu la fred." matches the rule head "da patpatfu de" and then
attempts to match the members of the conjunct against existing facts
or rule heads.

There are built-in brivla for which the system knows how to compute the
answer rather than consulting its database: e.g. "li mu du lo sumji
be li re bei li ci be'o" is always true. Typically the sumti of such
predicates must be ground.

-- 
John Cowan <[email-masked]> http://www.reutershealth.com
I amar prestar aen, han mathon ne nen, http://www.ccil.org/~cowan
han mathon ne chae, a han noston ne 'wilith. --Galadriel, _LOTR:FOTR_