sneak preview of improved syntax

Tom Gruber <Gruber@sumex-aim.stanford.edu>
Full-Name: Tom Gruber
Message-id: <2874882747-9098820@KSL-Mac-69>
Date: Wed, 6 Feb 91  18:32:27 PST
From: Tom Gruber <Gruber@sumex-aim.stanford.edu>
To: ontolingua@sumex-aim.stanford.edu
Subject: sneak preview of improved syntax
I have been working on an improved version of ontolingua, but it is
not yet complete.  Since much of it has to do with syntax, I thought
it would be useful to show you the documentation for the new version.
Here's the doc string for define-relation, which is pretty much the
same for define-class and define-function.

The major changes are
  * :def and :iff-def allow you to mix first-order and second-order
statements, so you needn't separate them in the :second-order clause
(and it also lets you say whether a second-order statement is
definitional or not (you can also use them in :implies statements).
  * slot syntax.  You can make a define-relation look like a frame.

I'll send out complete documentation and the implementation as soon as
they are ready (in a week or few).
						tom

(defmacro ontolingua:define-relation
	  (relation-name arguments documentation
           &rest keyword-args
	   &key
	   (def              ())
	   (iff-def          ())
	   (equivalent       ())
	   (sufficient       ())
	   (implies          ())
	   (default-implies  ())
	   (second-order     ())   ;:issues?
           (slot-values      ())
           (instance-slot-values ())
           (default-instance-slot-values ())
           &allow-other-keys)
"Defines a relation called RELATION-NAME.

RELATION-NAME is a symbol.  Conversion of names into the conventions of
  target languages is done automatically (e.g., Cyc uses strings with conventions 
  for case and word delimiters).

ARGUMENTS indicates the arity of the relation and names the related entities.
   e.g. (define-relation father-of ($father $child)...
   Within the sentences in the body of the define-relation, 
   the arguments are treated as variables bound to the objects related by the relation.
   The arguments must be symbols.  The KIF convention is to use a $ prefix, but
   ontolingua will transform them for you.

DOCUMENTATION

DEF is a KIF sentence that \"defines\" the relation.
   That is, it is a sentence using the variables in ARGUMENTS as free variables
   that holds when the relation is asserted on specific instances.
   The DEF sentence may also use second-order relations that mention RELATION-NAME
   as an argument, such as (INVERSE <relation-name> <inverse-relation-name>).
   See \"Second Order Relations\" below.

   The purpose of the DEF sentence is to specify constraints on consistent use of 
   the relation; it should reflect the textual definition given as the DOCUMENTATION string.
   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)
       :def (and (person $child) (person $parent)))
   is logically equivalent to
     (=> (has-parent $parent $child) 
         (and (person $parent) (person $child))).

IFF-DEF is a KIF sentence that \"completely defines\" the relation.
   It is exactly like DEF except that the sentence specifies both necessary
   and sufficient conditions on the relation.  For example,
     (define-relation has-mother ($child $mother)
       :iff-def (and (has-parent $child $mother)
                     (female $mother)))
   is logically equivalent to
     (<=> (has-mother $parent $child)
          (and (has-parent $child $mother) (female $mother)))
              
IMPLIES is a KIF sentence that specifies necessary constraints (=>)
  on the relation that are not meant as part of the definition of the relation.
  The IMPLIES sentence is true for any bindings of ARGUMENTS in which
  the relation holds; it \"follows\" from the definition.

  IMPLIES sentences are logically equivalent to DEF sentences, and
  take the same form (i.e., sentences with terms that may include free 
  variables from the ARGUMENTS list or relation names such as RELATION-NAME).
  
  The purpose of the distinction between definitional and nondefinitional 
  constraints is to support terminological reasoning apart from other
  classes of deductive inference.  The IMPLIES sentence is an assertion
  used in nonterminological inference, such as forward chaining.
  For example,
    (define-relation older-than ($older $younger)
      ...
      :implies (before (birthdate $older) (birthdate $younger)))

SUFFICIENT is a KIF sentence that specifies sufficient (=>) constraints 
  on the relation. The SUFFICIENT sentence specifies conditions under which 
  the relation may be inferred; the relation is satisfied when the SUFFICIENT 
  sentence holds with a given binding for ARGUMENTS.  The SUFFICIENT sentence 
  can be used as a backward chaining deductive rule whose consequent is
  an instantiation of the relation.

      
EQUIVALENT is a KIF sentence that specifies IFF (<=>) 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
  classes of deductive inference.  The EQUIVALENT sentence is an assertion
  used in nonterminological inference.


DEFAULT-IMPLIES is a KIF sentence that specifies what \"follows by default\"
  from the relation.  The precise operational semantics of nonmonotonic inference
  will depend on the target implementation.  However, the intended use of
  DEFAULT-IMPLIES is to specify \"default rules\" whose anticendent is the
  relation with ARGUMENTS as free variables and consequent is the DEFAULT-IMPLIES
  sentence.  The DEFAULT-IMPLIES sentence has the same form as the 
  DEF and IMPLIES sentences, except that second-order relations are not allowed. 

  When a ground assertion using the relation is asserted, then the
  DEFAULT-IMPLIES sentence will hold (\"by default\") for those bindings
  of ARGUMENTS until and unless a sentence that contradicts the
  DEFAULT-IMPLIES sentence is asserted for those bindings.

  For example,
    (define-relation country-of-citizenship ($person $country)
       ...
       :DEFAULT-IMPLIES (exists $language
                           (and (languages-spoken $person $language)
                                (official-languages $country $language)))



On SECOND-ORDER relations

  Within the DEF, IFF-DEF, IMPLIES, and EQUIVALENT sentences there may 
  clauses that specify properties of the relation being defined,
  denoted by RELATION-NAME, as opposed to instances of the relation, denoted
  by the free variables in ARGUMENTS.  The clauses in these sentences use
  the name of the relations, such as the currently defined relation RELATION-NAME,
  as arguments to special \"second-order\" relations, whereas first-order sentences 
  use variables or constants denoting individuals (instances).

  In the following example, the relation in-module is defined.
  In the SECOND-ORDER sentence, in-module is said to be the
  \"inverse\" of of the relation module-ports, which means that
  (<=> (in-module $x $y) (module-ports $y $x)).  The symbol in-module,
  denoting the relation of that name, is used as an argument to the 
  second order relation inverse which relates two relations.  Similarly,
  the second order relation single-valued says that the relation
  in-module is functional, which means 
  (=> (and (in-module $x $y) (in-module $x $z)) (= $y $z)).

   (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))
     :second-order (and (inverse in-module module-ports)
                        (single-valued in-module))))

  The set of second-order relations allowed is restricted.  Ontolingua
  supports the relations listed on
  ontolingua:*supported-second-order-relations*.  In a future release
  there may be a definition facility for second order relations
  themselves.  The purpose of the second order relations is to capture
  conventions about knowledge organization and inference that can be
  implemented efficiently by target systems that Ontolingua translates
  into.

Alternate SLOT SYNTAX

  Ontolingua supports an alternate syntax for define-relation, which
  allows one to write definitions in a frame/slot notation instead
  of the predicate calculus style of KIF sentences. In the frame/slot
  syntax, relational sentences are written as 
    (slot-name slot-value1 slot-value2 ...) 
  where slot-name is the name of a binary relation, the first argument
  to the relation (the frame) is *omitted*, and each slot-value is a
  second argument to the relation.  For N slot values, there are
  corresponding N sentences of the form (slot-name <frame>
  <slot-value>).  Ontolingua will translate a list of slot-value
  statements into a conjunction of sentences appropriate for DEF, IFF,
  etc.  Three keyword arguments to define-relation provide a way to
  desacribe slot values of three types of frames associated with a
  definition.

:SLOT-VALUES ((slot-name slot-value1 slot-value2 ...) (slot-name2 ...) ...)
  SLOT-VALUES expressions are about the frame representing the relation itself.
  Thus, relations corresponding to slot-name1, slot-name2, etc. are
  second-order relations (see \"on second order relations\" above),
  and the translated sentences are added to the DEF sentence.

:INSTANCE-SLOT-VALUES ((slot-name slot-value1 slot-value2 ...) ...)
  INSTANCE-SLOT-VALUES expressions are about the frames representing the
  instances of the relation. This argument only makes sense for unary
  relations, which are customarily defined with DEFINE-CLASS.  Sentences
  translated from INSTANCE-SLOT-VALUES expressions are added to the
  IMPLIES sentence.
  
:DEFAULT-INSTANCE-SLOT-VALUES ((slot-name slot-value1 slot-value2 ...) ...)
  DEFAULT-INSTANCE-SLOT-VALUES expressions are about the frames
  representing the instances of the relation, like INSTANCE-SLOT-VALUES.
  The difference is that sentences translated from INSTANCE-SLOT-VALUES
  expressions are added to the DEFAULT-IMPLIES sentence.  This argument
  only makes sense for unary relations, which are customarily defined
  with DEFINE-CLASS.  The semantics of these sentences is that these
  slot values will hold for instances of the relation unless an
  inconsistent slot value is asserted.  For example, if a
  DEFAULT-INSTANCE-SLOT-VALUES includeed (slot1 value1), and slot1 is a
  relation declared to be single-valued in its definition, then
  instances of RELATION-NAME will have value1 as the value of slot1
  unless an alternate value is asserted directly, which overrides the
  inherited value.
"