Skip to content

Commit

Permalink
Keep duplicate clauses for btree_sum
Browse files Browse the repository at this point in the history
  • Loading branch information
remysucre committed May 11, 2022
1 parent 2fe0709 commit 917a36f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
10 changes: 10 additions & 0 deletions src/ast/transform/MinimiseProgram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,12 @@ bool MinimiseProgramTransformer::reduceLocallyEquivalentClauses(TranslationUnit&
for (auto&& cl : program.getClauses(*rel)) {
auto* clause = &*cl;
bool added = false;
const auto* head = clause->getHead();
const auto* relation = program.getRelation(*head);
// keep duplicate clauses for btree_sum
if (relation->getRepresentation() == RelationRepresentation::BTREE_SUM) {
continue;
}

for (std::vector<Clause*>& eqClass : equivalenceClasses) {
const auto& normedRep = normalisations.getNormalisation(eqClass[0]);
Expand Down Expand Up @@ -353,6 +359,10 @@ bool MinimiseProgramTransformer::removeRedundantClauses(TranslationUnit& transla
return false;
}
const auto* head = clause->getHead();
const auto* relation = program.getRelation(*head);
if (relation->getRepresentation() == RelationRepresentation::BTREE_SUM) {
return false;
}
for (const auto* lit : clause->getBodyLiterals()) {
if (*head == *lit) {
return true;
Expand Down
13 changes: 6 additions & 7 deletions src/synthesiser/Relation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,17 +317,16 @@ void DirectRelation::generateTypeStruct(std::ostream& out) {
std::size_t attrib = ind[i];
const auto& typecast = typecasts[attrib];
std::string lt;
if (i + 1 == bound && isAggregate) {
if (aggregateOp == "max") {
if (i + 1 == bound && isAggregate && aggregateOp == "max") {
lt = ">";
} else if (aggregateOp == "sum") {
lt = "!=";
}
} else {
lt = "<";
}

out << "(" << typecast << "(a[" << attrib << "])" << lt << typecast << "(b[" << attrib << "]))";
if (i + 1 == bound && aggregateOp == "sum") {
out << "true";
} else {
out << "(" << typecast << "(a[" << attrib << "])" << lt << typecast << "(b[" << attrib << "]))";
}
if (i + 1 < bound) {
out << "|| ((" << typecast << "(a[" << attrib << "]) == " << typecast << "(b[" << attrib
<< "])) && (";
Expand Down

0 comments on commit 917a36f

Please sign in to comment.