deduceAllFacts method
Update the KB with all the implications of a list of facts.
facts can be specified as a Map.
Implementation
void deduceAllFacts(Map<Logic, bool?> facts) {
// Keep frequently used attributes locally, so we'll avoid extra
// attribute access overhead
final fullImplications = rules.fullImplications;
final betaTriggers = rules.betaTriggers;
final betaRules = rules.betaRules;
final factsCopy = Map<Logic, bool?>.from(facts);
while (factsCopy.isNotEmpty) {
final betaMayTrigger = <int>{};
// --- alpha chains ---
for (final entry in factsCopy.entries) {
final (k, v) = (entry.key, entry.value);
if (!_tell(k, v) || v == null) {
continue;
}
// lookup routing tables
for (final (key, value) in fullImplications[(k, v)]) {
_tell(key, value);
}
betaMayTrigger.addAll(betaTriggers[(k, v)]);
}
// --- beta chains ---
factsCopy.clear();
for (final bIdx in betaMayTrigger) {
final (bcond, bimpl) = betaRules[bIdx];
if (bcond.every(((Logic, bool) kv) => _entries[kv.$1] == kv.$2)) {
factsCopy[bimpl.$1] = bimpl.$2;
}
}
}
}