User:Rhmccullough/Sandbox/Examples

See External References for additional details commands [18] options [19] methods [20] tutorial [21] grammar [22] predefined knowledge units [23][24]

The brief examples given below illustrate the basic features of mKR.

* attributes John Doe has email = jdoe@PioneerCA.com, phone = 209-555-1212;

* relation

address book is relation with format = [person:1, email:2, phone:3], meaning = { $1 has email=$2, phone=$3; }; begin relation address book; John Doe, jdoe@PioneerCA.com, 209-555-1212; end relation address book;

* hierarchy

begin hierarchy tabula rasa; existent; /   group;  # abstract entity /   entity; # physical entity /   characteristic;  # property //      attribute; //      part; //      relation; //      action; //      interaction; /   proposition; end hierarchy tabula rasa;

* display hierarchy

existent isc* ?;

* display classes

John Doe isa* ?;

* action

at time = 10 am { John Doe do walk from his house to the store with purpose = buy food done; };

* definitions and context


 * mKE is ke;
 * at view = Aristotle { man is ANIMAL with rational; };
 * at view = OWL      { man isand ANIMAL, rational; };
 * at view = John Doe { man is person with gender=male; };

* questions

ke do ? done; # mKE commands ke has ?;     # mKE options and variables verb isc* ?;  # mKR verbs cat ? car;    # relation attrs := John Doe has ?; # list of attributes

* iteration

every p isu person { do print od $p done; };

* conditional

if e := John Doe has email = ?; then do print od $e done; fi;

* define enumeration, set, union, disjoint union, intersection, complement

color isany red, green, blue; digits isall 0, 1, 2, 3, 4, 5, 6, 7, 8, 9; domestic animals isor cats, dogs, parrots; integers isxor even numbers, odd numbers; busy man isand father and Chief Executive Officer; dead person isnon living person; # relative to genus person not person isnot person;         # relative to existent

* store attributes in database or table

John Doe[email] := jdoe@PioneerCA.com; John Doe[phone] := 209-555-1212;

* print attributes

every a of John Doe { do print od John Doe[$a] done; };

* define method

char is method with format = [ existent:1 ], meaning = { $1 is ?; $1 has ?; $1 do ? done; };

* execute method

do char od John Doe done;

* execute UNIX shell command

! cat *.txt | sort done;

* execute mKR script

ke -m -owl < peirce.out do read owl from peirce.owl done; do check od genus done; do check od unknown done; do simplify lattice od Thing done; Thing isc* ?; EOF grep -v '^#' peirce.out > peirce.ho