tell [Macro]

tellm [Macro]


Purpose

The tell macro is used to assert propositions to the Loom database. A proposition states that an instance belongs to a given concept or has a particular feature, or that a relationship holds between two or more instances, or that two instances are equivalent.

The tellm macro asserts one or more propositions, and then calls the Loom matcher to recompute the types of the affected instances.

Syntax

tell &body propositions
tellm &body propositions

Arguments

The propositions argument consists of zero or more propositions (see Remarks below) which are to be asserted.

Value

The tell macro normally returns the symbol ok. However, if propositions contains one or more :about clauses, the subject of the last such clause is returned. The tellm macro returns the number of the newly-advanced knowledge base state.

Remarks

Each proposition in the propositions argument above has the following syntax:
 proposition ::= ( concept instance ) |
                 ( relation instance+ value ) |
                 ( :CREATE ?Var concept [:CLOS] ) |
                 ( :SAME-AS instance instance ) |
                 ( :ABOUT instance about-clause* )
Each about-clause in a proposition has the form:
 about-clause ::= concept |
                  ( concept ) |
                  ( relation value ) |
                  ( :FILLED-BY relation value+ ) |
                  ( :FILLED-BY-LIST relation List ) |
                  ( {:AT-LEAST | :AT-MOST | :EXACTLY} Integer relation ) |
                  ( {:ALL | :SOME | :THE} relation concept )

A concept, relation, or instance may be either a symbol that names a Loom object, or a variable beginning with the character ?. An instance may also be a constant or a formula, where a formula is a list of the form (relation instance).

The scope of the ?-variable in a :create proposition extends to all of the propositions following that :create. In general, any ?-variable not bound in a preceding :create proposition is assumed to be bound externally. The value of an external ?-variable should be a Loom object, i.e., a concept, relation, or instance, rather than the name of such an object.

A :create proposition may optionally contain the :clos keyword. If this keyword is supplied, or if the global feature :prefer-clos-instances is set, a CLOS instance (see make-object) is created instead of a Loom instance. If there is no existing CLOS class corresponding to concept, Loom attempts to create the needed class. If this attempt fails, a standard Loom instance is created and a warning is issued.

Concepts and relations referenced by name in an assertion must be defined at the time the assertion is compiled. References to an instance, say A, bind to a previously declared concept or relation with name A, if such exists. Otherwise, they bind to an existing instance with identifier A. If no such instance can be found, then a new instance with identifier A is created. Subsequent references to A bind to the same object as the first one.

A :same-as proposition asserts that two instances are equivalent. It causes them to be merged into a single instance that combines the assertions made about each of them individually.

If two or more values are asserted to be fillers of a single-valued role, Loom automatically clips, i.e., retracts, all but the last assertion (providing that the :auto-clip feature is set). Similarly, a :filled-by-list assertion has the effect of retracting all previously-asserted fillers of a role.

Examples

(tell (Person Joe)) ==> OK 
(tell (age Joe 30) (wife Joe Sue) (Teacher Sue)) ==> OK  
(tell (age (wife Joe) (+ (age Joe) 1))) ==> OK 
(tellm (Person Honey) (:same-as (wife Joe) Honey)) ==> 3 

(setq ?C (fc Person) ?R (fr age) ?I (fi Joe) ?V 30) 
(tellm (?C ?I) (?R ?I ?V)) ==> 4 
(tellm (:create ?X Dog) (pet Joe ?X)) ==> 5 
(tell (:about Joe Person (wife Sue))) ==> |I|JOE 
(tellm (:about Joe (child Fred) (child Mary))) ==> 6  
(tellm (:about Joe (:filled-by child Fred Mary Don))) ==> 7 

(setq ?L (list (fi Fred) (fi Mary) (fi Don))) 
(tellm (:about Joe (:filled-by-list child ?L))) ==> 8 
(tellm (:about Joe (:at-least 3 child) (:at-most 1 daughter) 
                   (:exactly 2 son))) ==> 9 
(tellm (:about Joe (:all child Adult) (:some son Bachelor))) ==> 10 

(setq ?I (fi Joe) ?R (fr child) ?C (fc Adult)) 
(tellm (:about ?I (:all ?R ?C))) ==> 11

See Also

Last modified: Sep 20 1995