Demo: John, Mary and R2D2

From: Neo <neo55592_at_hotmail.com>
Date: 9 Nov 2004 19:10:18 -0800
Message-ID: <4b45d3ad.0411091910.5151947_at_posting.google.com>



The following example (www.xdb2.com/Example/Ex113.asp) represents/queries the following things:

john is a person whose profession is gardener. mary is a horse whose breed is mustang.
r2d2 is a robot whose cpu is 8051.
mary bite r2d2 before breakfast.
r2d2 hit mary during lunch.
(r2d2 hit mary during lunch) because (mary bite r2d2 before breakfast).
john reboot r2d2 after dinner.
(john reboot r2d2 after dinner) because (r2d2 hit mary during lunch).

The above things are created by the script below:

// Create profession class

CREATE2 *profession.cls = thing;

// Create breed class

CREATE2 *breed.cls = thing;

// Create cpu class

CREATE2 *cpu.cls = thing;

// Create person named john who is a gardener
CREATE2 *person.cls = thing;
CREATE2 *john.cls = person;
CREATE2 john.profession = +gardener;

// Create horse named mary who is a mustang
CREATE2 *horse.cls = thing;
CREATE2 *mary.cls = horse;
CREATE2 mary.breed = +mustang;

// Create robot named r2d2 powered by a 8051 cpu
CREATE2 *robot.cls = thing;
CREATE2 *r2d2.cls = robot;
CREATE2 r2d2.cpu = +8051;

// Create verbs

CREATE2 *like.cls = verb;
CREATE2 *bite.cls = verb;
CREATE2 *hit.cls = verb;
CREATE2 *reboot.cls = verb;
CREATE2 *because.cls = verb;

// Create prepositions

CREATE2 *before.cls = preposition;
CREATE2 *during.cls = preposition;
CREATE2 *after.cls = preposition;

// Create meals

CREATE2 *meal.cls = thing;
CREATE2 *breakfast.cls = meal;
CREATE2 *lunch.cls = meal;
CREATE2 *dinner.cls = meal;

// Create a story

CREATE2 john.like = mary;
CREATE2 mary.like = john;
CREATE2 (john.like=mary).because = (mary.like=john);
CREATE2 mary.bite = r2d2 _at_before = breakfast;
CREATE2 r2d2.hit = mary _at_during = lunch; CREATE2 (r2d2.hit=mary _at_during=lunch).because = (mary.bite=r2d2 _at_before=breakfast);
CREATE2 john.reboot = r2d2 _at_after = dinner; CREATE2 (john.reboot=r2d2 _at_after=dinner).because = (r2d2.hit=mary _at_during=lunch);

// Queries

// Who did mary bite?
// Finds r2d2.

SELECT2 mary.bite = %;

// Who hit mary?
// Finds r2d2.

SELECT2 %.hit = mary;

// What did r2d2 do to mary?
// Finds hit

SELECT2 r2d2.% = mary;

// What kind of thing likes john?
// Finds horse (not mary).

SELECT2 %.cls=thing & %.inst=(%.like=john);

// Why did r2d2 hit mary?
// Finds mary.bite=r2d2 before breakfast.
SELECT2 (r2d2.hit=mary).because = %;

// What did john do to r2d2 after dinner?
// Finds reboot.

SELECT2 john.%=r2d2 _at_after=dinner; Received on Wed Nov 10 2004 - 04:10:18 CET

Original text of this message