Table of Contents

Function Define-Relation

(define-relation <relation-name> (<var>+)
    [<docstring>]
    [:when <sent-with-arg-vars>]
    {:def | :iff-def} <sent-with-arg-vars>
    [:constraints <sent-with-arg-vars>]
    [:equivalent (<sent-with-arg-vars>*)]
    [:sufficient <sent-with-arg-vars>]
    [:default-constraints (<sent-with-arg-vars>*)]
    [:axiom-def <sent-without-arg-vars>]
    [:axiom-constraints <sent-without-arg-vars>]
    [:axiom-defaults (<sent-without-arg-vars>*)]
    [:theory <theory-name>]
    [:implementation <target-system-name>]
    [:class-slots (<slot-spec>*)]
    [:instance-slots (<extended-slot-spec>*)]
    [:default-slot-values (<slot-spec>*)]
    [:documentation <docstring>]
    [:issues <issue-tree>])

Macro for defining relations. No arguments are evaluated. See also CREATE-RELATION, which is the functional form.

<relation-name> should be a symbol which names the relation being defined. Ontolingua will convert this symbol into a format which is appropriate for the selected target representation system during translation (e.g., if one were translating into CycL, the symbol would be converted into a string which would obey the CycL conventions for case and word delimiters.)

<var> is a symbol begining with a ? that names arguments to the relation or function being defined. For example, in

    (define-relation father-of (?father ?child) ...)

the symbols ?father and ?child are the <var> arguments.

Within the sentences in the body of the define-relation form, such symbols are treated as variables bound to the objects related by the relation. The current KIF convention is to use symbols which begin with a "?", but since Ontolingua converts all variables to this format internally it is not strictly necessary to adhere to this convention.

Note: sequence-variables (indicated by a '@' prefix in KIF and Epikit) are not guaranteed to be supported in all target representation systems. This means that "portable" Ontolingua relations always have a fixed arity.

<docstring> when provided, should be a string which describes the function being defined. It will be stored as the Lisp documentation (of type OL:ONTO-RELATION) for the symbol which names the relation. If a docstring is provided, it must immediately follow the argument list.

The remaining keyword arguments may occur in any order, and are described below:

:AXIOM-CONSTRAINTS - The associated value should be a KIF sentence which is a standalone sentence not related to the variables in the argument list. It is the same as the :AXIOM-DEF sentence except it is not definitional -- relevant to the form being defined, but not part of its definition.

Logically, this sentence neither implies nor is implied by the relation holding for a given binding of the variable(s) <var> ; it is a standalone sentence. It should mention the relation being defined, however.

A list of sentences may be supplied instead of a single sentence; Ontolingua will automatically construct a conjunction of all the supplied :AXIOM-CONSTRAINTS sentences in this case.

:AXIOM-DEF - The associated value should be a KIF sentence; it will be asserted along with the definition. Logically, this sentence neither implies nor is implied by the relation holding for a given binding of the variables in the <var> argument list; it is a standalone sentence. It should mention the relation being defined, however. If this axiom happens to mention the variables in the <var> list, then these variables are considered as any other unquantified KIF variables: they are assumed to be universally quantified. Thus, it's confusing to use the <var> argument list variables in the :AXIOM-DEF sentences.- The value should be a KIF sentence with no free variables. In particular, the sentence does not implicitly constrain the variables in the argument list (that is what :def and :iff-def are for). The :AXIOM-DEF sentence is considered to be definitional. That is, it is part of the definition as are :DEF and :IFF-DEF sentences. Non-definition axioms should be specified with the :AXIOM-CONSTRAINTS keyword.

A list of sentences may be supplied instead of a single sentence; Ontolingua will automatically construct a conjunction of all the supplied :AXIOM-DEF sentences in this case.

:AXIOM-DEFAULTS - the value of this keyword should be a list of KIF sentences which are not related to the <var> arguments They should mention the relation being defined, however. Each of these sentences is taken to hold until and unless a contradictory sentence is asserted.

:CONSTRAINTS - The associated value should be a KIF sentence that specifies necessary constraints on the relation that are not meant as part of the definition of the relation. The :CONSTRAINTS sentence is taken to be true for any bindings of the <var> arguments for which the relation holds; it "follows" from the definition. One can also think of constraints as (monotonically) inherited facts about sets of instances for which the relation holds.

:CONSTRAINTS sentences are logically equivalent to :DEF sentences, and take the same form (i.e., sentences with terms that include free variables from the <var> arguments list.) The purpose of the distinction between definitional and nondefinitional constraints is to support terminological reasoning apart from other kinds of deductive inference. The :CONSTRAINTS sentence is an assertion used in nonterminological inference, such as inheritence of sentences used to ensure consistency.

A list of sentences may be supplied instead of a single sentence; Ontolingua will automatically construct a conjunction of all the supplied :CONSTRAINTS sentences in this case.

:DEF - The value of this keyword argument should be a KIF sentence that "defines" the relation; that is, a KIF sentence using the <var> arguments as free variables that holds when the relation is asserted on specific instances. The purpose of the :DEF sentence is to specify constraints on consistent use of the relation; it should reflect the textual definition given in the docstring. Some implementations make special use of sentences labeled as definitions.

Logically, the :DEF sentence is implied by the relation. For example:

    (define-relation has-parent (?child ?parent)
      "the relation from children to parents."
       :def (and (person ?child) (person ?parent)))

is logically equivalent to

    (=> (has-parent ?parent ?child) 
        (and (person ?parent) (person ?child)))

:DEFAULT-CONSTRAINTS - The value of this keyword argument should be a list of KIF sentences that specify what "follows by default" from the relation. The precise operational semantics of nonmonotonic inference will depend on the target representation system. The intended use of :default-constraints is to specify

"default rules" whose anticendents are the relation with the <var>
arguments as free variables and whose consequents are each of the :default-constraints sentences. The :default-constraints sentences have the the same form as the :DEF and :CONSTRAINTS sentences.

WARNING: :DEFAULT-CONSTRAINTS DOESN'T TRANSLATE PORTABLY. AVOID DEFAULTS IN PORTABLE ONTOLOGIES.

When a ground assertion using the relation is asserted, then each of the :default-constraints sentences will hold ("by default") for those bindings of the <var> arguments until and unless a sentence that contradicts that default-constraints sentence is asserted for those bindings. For example:

    (define-relation country-of-citizenship (?person ?country)
      :default-constraints 
      (exists ?language 
	(and (languages-spoken ?person ?language)
	     (official-language ?country ?language))))

means that if the country-of-citizenship of a person is known, then at least one of the languages that the person speaks is an official-language of the person's country-of-citizenship, unless this is explicitly asserted not to be the case.

:DOCUMENTATION - when provided, should be a string which describes the function being defined. It will be stored as the Lisp documentation (of type OL:ONTO-RELATION) for the symbol which names the relation. If a docstring is provided, it must immediately follow the argument list.

:EQUIVALENT - The value of this keyword argument should be a list of KIF sentences that specify biconditional constraints on the relation that are not meant as part of the definition of the relation.

:EQUIVALENT constraints are logically equivalent to :IFF-DEF constraints. The purpose of the distinction between definitional and nondefinitional constraints is to support terminological reasoning apart from other types of deductive inference. The :EQUIVALENT sentences are assertions used in nonterminological inference.

:IFF-DEF - The value of this keyword argument should be a KIF sentence that "completely defines" the relation. This is just like the :DEF keyword, except that the supplied sentence specifies both necessary and sufficient conditions for the relation to hold on any given bindings for the <var> arguments. For example:

    (define-relation has-mother (?child ?mother)
       "child's mother"
       :iff-def (and (has-parent ?child ?mother)
       (female ?mother)))

is logically equivalent to

    (<=> (has-mother ?parent ?child)
         (and (has-parent ?child ?other) 
         (female ?mother)))It is not legal use both the :DEF and :IFF-DEF keywords in the
same definition.

:IMPLEMENTATION - The value of this keyword argument should be a symbol (usually a keyword) which names the target representation system in which the definition should be defined. This is independent of the theory in which the defined is defined. If the :IMPLEMENTATION argument is not supplied, the current implementation is assumed (see IN-IMPLEMENTATION.)

:ISSUES - The value of this argument should be a Lisp "tree" of strings. The tree can be either a string, or a list of strings, or a list of (<label> <any-lisp-object>) pairs, where <label> is a string or symbol that names the type of the comment. For examples,

   :issues ("This is a footnote about FOO."
            (:example (= (foo ?x) (inverse (bar ?x))))
            ("Why not do it this way?

:SUFFICIENT - The value of this keyword arg should be a KIF sentence that specifies sufficient constraints for the relation to hold for a given binding of the <var> arguments. The :SUFFICIENT sentence thus specifies conditions under which the relation may be inferred; it may be used as a backward chaining deductive rule whose consequent is an instantiation of the relation.

A list of sentences may be supplied instead of a single sentence; Ontolingua will automatically construct a disjunction of all the supplied :SUFFICIENT sentences in this case.

:THEORY - The value of this keyword argument should be a symbol which names the theory in which the definition should be defined. If the :THEORY argument is not supplied, the current theory is assumed (see IN-THEORY.)

:DEFAULT-SLOT-VALUES, :INSTANCE-SLOTS, and :CLASS-SLOTS - These keyword arguments are discussed below, under "Alternate Slot Syntax."

Second Order Sentences

Within the :AXIOM-DEF there may be sentences that specify properties of the relation being defined, rather than properties of the instances related by the relation being defined. Such sentences use the names of relations as arguments to special "second order" relations. For example, consider the following definition:

    (define-relation in-module (?port ?module)
      "Function from a port to its associated module.
       Each port has at most one associated module."
      :def (and (port ?port)
 		(module ?module))
      :axiom-def (SINGLE-VALUED in-module))

In the :AXIOM-DEF sentence, IN-MODULE is said to be a SINGLE-VALUED relation, which means:

    (=> (and (in-module ?x ?y) (in-module ?x ?z)) (= ?y ?z))

The symbol IN-MODULE denotes the relation of that name. Since the argument to SINGLE-VALUED, IN-MODULE, is also a relation, SINGLE-VALUED is called a second-order relation.

Second order relations capture many conventions for defining and organizing terms in concise ways. For example, in the following definition, MODULE-PORTS is defined as the inverse of IN-MODULE. That is all that needs to be stated about this term; everything true of IN-MODULE is true of MODULE-PORTS with its arguments reversed:

    (define-relation module-ports (?module ?port)
      "The ports associated with a module."
      :axiom-def (INVERSE module-ports in-module))

Terminologically, second-order sentences are always considered to be definitional. Only a restricted set of second-order relations are allowed; these are defined in the frame ontology.Alternate Slot Syntax

Ontolingua supports additional syntax for writing some definition sentences in a frame/slot style instead of the predicate calculus style of KIF. This additional syntax is supported via three additional definition keywords, whose associated values are lists of sentences in the following format, called a SLOT-VALUE-SPEC:

    (slot-name slot-value1 slot-value2 ...) 

SLOT-NAME is the name of a binary relation. The first argument to this binary-relation (the frame) is made implicit by the keyword with which the sentence is associated, and each SLOT-VALUE is a second argument to the relation.

During the translation process, Ontolingua will transform such a sentence into the equivalent KIF sentences

    (slot-name frame slot-value-1)
    (slot-name frame slot-value-2)

These resulting sentences will be added to the :AXIOM-DEF, :CONSTRAINTS, :AXIOM-CONSTRAINTS, or :DEFAULT-CONSTRAINTS sentences depending on the keyword with which the original slot-syntax sentences are associated.

The three keywords supported in this manner are as follows:

:CLASS-SLOTS - The associated value should be a list of SLOT-VALUE-SPECs whose frames are taken to be the relation being defined. Thus, the relations corresponding to the slot names are second-order relations (see "Second Order Sentences" above.) Sentences translated from :CLASS-SLOTS are added to the :AXIOM-DEF sentence.

:INSTANCE-SLOTS - This keyword is only valid in the definition of unary relations (or equivalently, classes.) The associated value should be a list of SLOT-VALUE-SPECs sentences whose frames are taken to be individuals for which the unary relation holds. Sentences translated from :INSTANCE-SLOTS are added to the :CONSTRAINTS sentence.

An extended slot syntax is supported for this keyword which allows values for "facets" of slots to be provided. Within the SLOT-VALUE-SPECS any of the slot-values may be a list of the form:

   (facet facet-value1 facet-value2 ...)

Ontolingua will transform these into the equivalent KIF sentences:

   (facet relation slot facet-value1)
   (facet relation slot facet-value2)

:DEFAULT-SLOT-VALUES - This keyword is only valid in the definition of unary relations (or equivalently, classes.) The associated value should be a list SLOT-VALUE-SPECs sentences whose frames are taken to be individuals for which the unary relation holds. Sentences translated form :DEFAULT-SLOT-VALUES are added to the :DEFAULT-CONSTRAINTS sentences, and will therefore hold for each instance of the class until and unless a contrary assertion is made about that instance.