7.2.1
-- The predicate declaration declares the name, description and term-types,
if any, for a mediator predicate. The pred-name token is the predicate
name and descriptor-string is an English description of the predicate.
The syntax for the term-types is defined in
section 5.3. Hermes any and
number types, which can be used in domain function declarations
(see sections 6.2.6
and 6.2.5 respectively) cannot
be used in predicate declarations. However, complex data types can be used
in predicate declarations.
WebHermes predicate descriptors use a simple HTML-like markup syntax to map additional functionality from predicate variables to web controls.
${VarName} within a descriptor denotes values web hermes will return; This allows result application from one query to a secondary query input (and thus the formation of conjunctions).
&{VarName} within a descriptor denotes values which can be entered from the web browser.
*{VarName} within a descriptor denotes values which must be entered from the web browser.
The
Hermes search engine looks for referenced data in declared directory
paths, following listed order, prior to checking the current working directory.
Should a mediator file omit such directory declarations, then the search
engine checks only the current working directory for data files.
7.2.3
-- The data declaration declares the target domain, source file, and
structure for referenced data files. The term-type token allows
structure declaration -- actually, the returned data type -- for the referenced
data file (see section 5.3 for term-type
syntax). As stated above, mediator data declarations cannot contain the
generic number, or any, term-types.
Note that the data types listed in Fig. 7-6 correspond to familiar database concepts where a relation is a set of records, a quadtree is a set of points, and so forth. Moreover, the quadtree and relation domain data declarations use the '@' notation to specify a (remote) host data file server (See section 5.11).
Fig. 7-8 lists a short mediator of common file display functions. To call
these predicates from within another mediator, the author need only specify
the declaration "include ('actions.med')." within the mediator
file. This capability directly supports modular system development -- Larger
mediator applications, such as a multimedia system, can be derived from
smaller key components like integrated text and image databases.
7.4.1
-- Predicates are analogous to typical verb forms; When used in clause
form (see section 7.5) they make statements about the
terms they contain. Query predicates form questions regarding the addressed
terms (section 7.6). Additionally, Hermes annotates
its predicates with real-valued expressions to indicate the predicate confidence
level. Normal truth values range from 0.0, for no certainty, to
1.0, for total certainty (Hermes will, however, accept
truth values outside this range);
Citing
from the top down in Fig. 7-13 we find that predicate p is true
with a certainty of at least 50 percent, "supplier3" has 27
of "part5" available, some supplier can supply some number of
"part9", and that "part4" is hot with at least 75 percent
certainty.
7.4.2
-- Comparison literals: Hermes supports a typical set of comparison
operations, which evaluate to true or false, used to test terms for equality,
inequality and ordering. Working left to right, the comparison operators
listed in Fig. 7-14 retain the usual mathematical meanings of less-than,
less-than-or-equal, equal, not-equal, greater-than-or-equal, and greater-than.
Hermes mandates that compared terms be of the same type and must
be constants (instantiated) at evaluation time. For further clarification,
a specific breakdown of comparison operation subtleties with respect to
Hermes types follows:
The ingres:select domain function, cited in Fig. 7-15, causes
the Hermes search engine to iterate through a list of supplier records
selected for a specific part. Should the user query cite a specific supplier,
as in Fig. 7-16, then the equality operator highlighted in Fig. 7-15 gets
evaluated as a comparison between the current records Supplier
field value and the specified Supplier constant. Where the user
requests a general list of part suppliers (i.e. variable Supplier
as in Fig. 7-17),
7.4.4
-- The constant and variable literals each take one variable as their
term and are used to determine whether the target term is of the type indicated;
The constant literal evaluates to true if its term is instantiated to a
constant, otherwise it returns false. Likewise, the variable literal
returns true if its term is un-instantiated (and thus still a variable).
Hermes constant and variable literals serve two basic
purposes. First, domain function inputs must all be constants when the
domain function evaluates; the constant literal acts as a safety
to ensure this. Second, the constant and variable literals
provide a simple means to select among available predicate rules (where
more than one exists) based on input (which input terms are constants).
In this respect, the mediator author can tailor predicate rules to vary
according to input and ideally provide the most efficient function calls
to answer the query. In theory, there can be 2n versions
of a rule where n is the predicate arity which corresponds to term instantiation
combinations. In practice, many cases can be simplified or combined; A
binary table (see Fig. 7-20) often proves useful for visualizing potential
rule case combinations and partitions (Note: Consider only predicate terms
which apply to domain function inputs).
The rule table in Fig. 7-20 shows the eight (three variables: 23
= 8) potential constant / variable term combinations
for the supplier_part relation (see Fig. 7-19). For this mediator,
the author chose to ignore selections by quantity; The mediator thus ignores
the Quantity term and focuses only on the Part and Supplier
terms with constant / variable tests. This effectively
drops the constant / variable term combinations to four
(highlighted in Fig. 7-20) as the remaining combinations render duplicates
for the Supplier and Part term combinations. Additionally,
the current ingres:select domain function can select on only one
condition at time. With this in mind, the mediator author combines two
cases, rule one and three from the Fig. 7-20 table, into the first mediator
predicate rule in Fig. 7-19. Thus the mediator provides only three rules
to address the four (highlighted) term combinations.
The second predicate rule applies for cases where the user provides the Supplier but not the Part term, Hermes executes the ingres:select domain function on Supplier, rendering a list of parts and quantities available from the given supplier.
The final predicate rule, applicable where both Part and Supplier terms remain variable, causes Hermes to retrieve all relation records via the ingres:all domain function.
7.4.5
-- The default literal enables Hermes to instantiate the target-variable
term with a constant if the term remains un-instantiated at execution time;
If target-variable term is already instantiated at execution,
then the literal simply returns true and Hermes skips to the next
rule entry. If the value-term calls a domain function,
then it gets evaluated to a constant prior to target-variable
instantiation. Note: Both arguments, target-variable and
value-term, must evaluate to the same Hermes type.
Additionally, if the value-term remains variable at execution
time, Hermes will issue a run-time error.
A typical default literal use is to ensure that a variable has
a value as a domain function input. The factory predicate called in Fig.
7-22 instantiates the FactoryLongitude and FactoryLatitude
values based on the predicate Factory name input. Next, the default
literal ensures that the Radius term is instantiated prior to
allowing the quadtree:range domain function execution.
Another default literal use might be to ensure that
a variable has a an input comparison value (see reference comparison section
example i.e. default (NeedQuantity, 1)
Fig. 7-24 shows perhaps the most common form of Hermes in
literal usage where the predicate invokes the in literal with a variable
test-term and domain function call for the list. This causes
Hermes to iteratively instantiate the test-term
with the current tgt-list-term values (derived here thru
the quadtree domain) and complete the remaining rule literal processing.
Upon issuing a predicate solution, the search engine then backtracks to
the in literal, increments the list cursor and instantiates the
test-term with the next available list element. This continues
until Hermes processes all tgt-list-term elements
at which point the in literal fails, causing a false return value.
Hermes
data file through calls such as: out (Color, 'badcolor.hrm').
Fig.
7-28 shows a mediator solving the minimum_cost rule by temporarily
storing selected part supplier records to the costs.hrm file (via
the is literal), and then finding the minimum cost supplier record
through the Hermes:mimimum domain function. Note: Use of the is
literal mandates a data declaration in the mediator file for the target
storage file.
7.6
-- Hermes queries typically ask data questions by instantiating
specific variables of the appropriate mediator predicates. Queries most
often involve only one predicate such as that in Fig. 7-31 which requests
prices and suppliers of "widget4". Hermes supports compound
queries as well; Fig. 7-32 requests a list of suppliers offering widget4
at a cost of 50 or less. It sometimes proves more efficient, however, to
write an additional predicate which captures the compound query functionality.![]()