Download ConceptBase.cc User Manual - Welcome to BSCW Shared

Transcript
parameter
x: Node;
y: Node
constraint
csps: $ exists x1/Node (x next x1) and (this=sp(x1,y)) $
end
Here, the query class spSet computes the set of length of shortest path between the successors of
a node x and a node y. The length of the shortest path is then simply 0 if x=y or the minimum of
the spSet[x,y] plus 1 if there is a path from x to y, and undefined else. The signature of spSet
must be known for compiling sp and vice versa. ConceptBase has a single-pass compiler. Hence, it
requires the forward declaration. The query spSet is not a function because it returns in general several
numbers. The complete example for computing the length of the shortest path is in the CB-Forum, see
http://merkur.informatik.rwth-aachen.de/pub/bscw.cgi/1694234.
Recursive function definitions require much care. Deductive rules shall always return a result after a
finite computation. This does not hold in general for recursive function definitions when they use arithmetic subexpressions. These subexpressions can create new objects (numbers) on the fly and thus force
ConceotBase into an infinite computation. On the other hand, they are more expressive than pure deductive
rules and thus useful to analyze large models in a quantitative way.
2.6
Query evaluation strategies
ConceptBase employs an SLDNF-style query evaluation method, i.e. query predicates are evaluated topdown much like in standard Prolog. This is known to cause infinite loops for certain recursive rule sets.
To overcome this, the SLDNF evaluator is augmented by a tabling sub-system [SSW94], which detects
recursive predicate calls and answers them from the cached results of a query (the so-called table) rather
than entering an infinite loop. This tabled evaluation computes the fixpoint (=answer) of a query provided
that the overall rule set is stratified. Even more, dynamically stratified rule sets are supported as well. Other
than with the static stratification test, a violation is detected at run time of a query rather than at compile
time.
For a precise definition of stratification, we refer you to the literature on deductive databases. For the
purposes of this manual, consider the following rule:
forall p/Position (exists p1/Position (p moveTo p1) and not (p1 in Win))
==> (p in Win)
ConceptBase internally compiles such rules into a representation where Position, moveTo, and
Win are predicate symbols:
forall p
(exists p1 Position(p) and Position(p1) and moveTo(p,p1) and not Win(p1))
==> Win(p)
Static stratification requires that one can consistently assign stratification levels (=numbers) to the set
of predicate symbols such that
1. If there is a rule with conclusion predicate A and positive condiction predicate B (=not negated), then
the level of A must be greater or equal the level of B.
2. If there is a rule with conclusion predicate A and negated condiction predicate B , then the level of
A must be strictly greater the level of B.
In the example above, the conclusion predicate Win depends on the condition predicate not Win.
Since we only can assign one level to Win, we cannot find a static stratification for the above rule. The
same argument also works in case of multiple inter-dependent rules. Static stratification can be tested at
compile-time of a rule.
46