Download Flora-2: User`s Manual

Transcript
5 BASIC FLORA-2 SYNTAX
10
2. O[M -> {V1 , . . . , Vn }], O[M *-> {V1 , . . . , Vn }]
3. C[M => T], C[M *=> T]
In all of the above cases, O, C, M, Vi , and Ti are HiLog terms, i.e., expressions of the form, a,
f(?X), ?X(s, ?Y), ?X(f, ?Y)(?X, g(k)), etc., where ?X and ?Y are variables and lowercase letters
f, s, etc., are constants.
Expressions (1) and (2) above are data atoms for value-returning methods. They specify
that a method expression M applied to an object O returns the result object V in case (1),
or a set of objects, V1 , ..., Vn , in case (2). In all cases, methods are assumed to be setvalued. However, later we will see that cardinality constraints can be imposed on methods,
so it would be possible to state that a particular method is functional or has some other
cardinality property. The formula (2) says that the result consists of several objects, which
includes V1 , V2 , ..., Vn . Note that we emphasized “includes” to make it plain that other facts
and rules in the knowledge base can specify additional objects that must be included among
the method result.
When n = 1 in (2), the curly braces can be omitted. For instance, O[M -> V1 ]. In fact, the
single expression (2) is equivalent to a the following set of expressions, where the result set is
split into singletons:
O[M -> V1 ]
O[M -> V2 ]
...
O[M -> Vn ]
When M is a constant, e.g., abc, then we say that it is an attribute; for example, John[name
-> ’John’]. When M has the form f(X,Y,Z) then we refer to it as a method, f, with
arguments X, Y, and Z; for example, John[salary(1998) -> 50000]. However, as we saw
earlier, method expressions can be much more general than these two possibilities, as they
can be arbitrary HiLog terms.
The expression (3) above is a signature atom. It specifies a type constraint, which says that
the method expression, M, when applied to objects that belong to class C, must yield objects
that belong to class T.
Note: Flora-2 does not automatically enforce type constraints. However, run-time type
checking is possible—see Section 26.2.
Objects are grouped into classes using ISA-atoms:
4. O : C
5. C :: D
The expression (4) states that O is an instance of class C, while (5) states that C is a subclass
of D.
User-defined equality