Struct chalk_engine::Minimums
source · pub(crate) struct Minimums {
pub(crate) positive: TimeStamp,
pub(crate) negative: TimeStamp,
}
Expand description
The Minimums
structure is used to track the dependencies between
some item E on the evaluation stack. In particular, it tracks
cases where the success of E depends (or may depend) on items
deeper in the stack than E (i.e., with lower DFNs).
positive
tracks the lowest index on the stack to which we had a
POSITIVE dependency (e.g. foo(X) :- bar(X)
) – meaning that in
order for E to succeed, the dependency must succeed. It is
initialized with the index of the predicate on the stack. So
imagine we have a stack like this:
// 0 foo(X) <-- bottom of stack
// 1 bar(X)
// 2 baz(X) <-- top of stack
In this case, positive
would be initially 0, 1, and 2 for foo
,
bar
, and baz
respectively. This reflects the fact that the
answers for foo(X)
depend on the answers for foo(X)
. =)
Now imagine that we had a clause baz(X) :- foo(X)
, inducing a
cycle. In this case, we would update positive
for baz(X)
to be
0, reflecting the fact that its answers depend on the answers for
foo(X)
. Similarly, the minimum for bar
would (eventually) be
updated, since it too transitively depends on foo
. foo
is
unaffected.
negative
tracks the lowest index on the stack to which we had a
NEGATIVE dependency (e.g., foo(X) :- not { bar(X) }
) – meaning
that for E to succeed, the dependency must fail. This is initially
usize::MAX
, reflecting the fact that the answers for foo(X)
do
not depend on not(foo(X))
. When negative cycles are encountered,
however, this value must be updated.
Fields§
§positive: TimeStamp
§negative: TimeStamp