Tuesday, 13 November 2012

An example of what can be done with Terms.

Terms is a production system. With it, you define words, and use the words to produce sentences and rules, that you add to the knowledge base. Terms extracts consecuences from those sentences and rules, and adds them to the knowledge base. Then you query the knowledge base. The knowledge base resides in a RDBMS.

I think the systax of Terms is intuitive enough that that I can give some code examples without going into much detail.

Almost everything in Terms are words. Words have types, and those types are themselves words. Facts are made out of words, and are themselves words. Only rules (and definitions of words) are not words. You can use Python in the rules, but I won’t touch on that here.

This means that we only need first order variables (ranging over words) to cover all Terms constructs with the exception of rules. I will give an example of this.

To start with, we define a word she of type thing:

she is a thing.

Then we define 2 verbs (2 words of type verb), wants and gets:

to want is to exist, what a word.
to get is to exist, what a word.

With these words, we can make facts shuch as (want she, what <some word>).

Let’s make some more words, so that she can want/get things:

a fruit is a thing.
this-banana is a fruit.
to eat is to exist, what a fruit.

Now we can make a fact such as (eat she, what this-banana).

Now we introduce a rule that expresses that she always gets what she wants:

(want she, what Word1)
(get she, what Word1).

Now, if we say that she wants this banana:

(want she, what this-banana).

We obtain that she gets it:

(get she, what this-banana)?

And also if she wants a verb, or a noun, or a number, or a fact...:

(want she, what fruit).
(get she, what fruit)?

(want she, what eat).
(get she, what eat)?

(want she, what number).
(get she, what number)?

(get she, what 42)?

(want she, what 42).
(get she, what 42)?

(want she, what (eat she, what this-banana)).
(get she, what (eat she, what this-banana))?

Then you can do something like:

(get she, what (Exist1))

To obtain that:

(eat she, what this-banana).

I don’t think that you can do that easily in other logic systems. Am I wrong?

No comments:

Post a Comment