Skip to content

Commit

Permalink
Addressing issue #64 and issue #98: rewrite existential multi-head rules
Browse files Browse the repository at this point in the history
  • Loading branch information
CerielJacobs committed Nov 22, 2022
1 parent dd28102 commit cfc7b0d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
8 changes: 7 additions & 1 deletion src/vlog/common/concepts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,13 @@ void Program::addRule(std::vector<Literal> heads, std::vector<Literal> body,
rewriteRule(heads, body);
} else {
Rule rule(allrules.size(), heads, body, isEGD);
addRule(rule);
if (heads.size() > 1 && rule.isExistential()) {
// Work-around for bug in existential multihead rules, github issue #98 and issue #64.
// Easiest fix is to just rewrite these rules.
rewriteRule(heads, body);
} else {
addRule(rule);
}
}
}

Expand Down
16 changes: 9 additions & 7 deletions src/vlog/forward/seminaiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1831,14 +1831,16 @@ void SemiNaiver::printCountAllIDBs(std::string prefix) {
for (PredId_t i = 0; i < program->getNPredicates(); ++i) {
if (predicatesTables[i] != NULL) {
if (program->isPredicateIDB(i)) {
size_t count = predicatesTables[i]->getNAllRows();
if (count == 0) {
emptyRel++;
}
std::string predname = program->getPredicateName(i);
LOG(DEBUGL) << prefix << "Cardinality of " <<
predname << ": " << count;
c += count;
if (predname.rfind("__Generated", 0) != 0) {
// Only count original predicates.
size_t count = predicatesTables[i]->getNAllRows();
LOG(DEBUGL) << prefix << "Cardinality of " << predname << ": " << count;
if (count == 0) {
emptyRel++;
}
c += count;
}
}
}
}
Expand Down

0 comments on commit cfc7b0d

Please sign in to comment.