Skip to content

Commit

Permalink
Fixed Own/mk and renamed test
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam committed Dec 8, 2020
1 parent 200bdfb commit 92a0e3d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
15 changes: 6 additions & 9 deletions src/ram/transform/MakeIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ Own<Condition> MakeIndexTransformer::constructPattern(const std::vector<std::str
// transform condition list so that every strict inequality becomes a weak inequality + filter
// e.g. Tuple[level, element] < <expr> --> Tuple[level, element] <= <expr> and Tuple[level, element] !=
// <expr>
std::vector<std::unique_ptr<Condition>> toAppend;
std::vector<Own<Condition>> toAppend;
auto it = conditionList.begin();
while (it != conditionList.end()) {
auto* binRelOp = dynamic_cast<Constraint*>(it->get());
Expand Down Expand Up @@ -179,13 +179,11 @@ Own<Condition> MakeIndexTransformer::constructPattern(const std::vector<std::str

if (transformable) {
// append the weak version of inequality
toAppend.emplace_back(
std::make_unique<Constraint>(convertStrictToWeakIneqConstraint(binRelOp->getOperator()),
clone(&binRelOp->getLHS()), clone(&binRelOp->getRHS())));
toAppend.emplace_back(mk<Constraint>(convertStrictToWeakIneqConstraint(binRelOp->getOperator()),
clone(&binRelOp->getLHS()), clone(&binRelOp->getRHS())));
// append the != constraint
toAppend.emplace_back(
std::make_unique<Constraint>(convertStrictToNotEqualConstraint(binRelOp->getOperator()),
clone(&binRelOp->getLHS()), clone(&binRelOp->getRHS())));
toAppend.emplace_back(mk<Constraint>(convertStrictToNotEqualConstraint(binRelOp->getOperator()),
clone(&binRelOp->getLHS()), clone(&binRelOp->getRHS())));

// remove the strict version of inequality
it = conditionList.erase(it);
Expand All @@ -195,7 +193,7 @@ Own<Condition> MakeIndexTransformer::constructPattern(const std::vector<std::str
}

std::transform(toAppend.begin(), toAppend.end(), std::back_inserter(conditionList),
[](const std::unique_ptr<Condition>& cond) { return clone(cond); });
[](const Own<Condition>& cond) { return clone(cond); });

// Define a comparator which orders all of the conditions nicely
// 1. Equalities come before inequalities
Expand Down Expand Up @@ -307,7 +305,6 @@ Own<Condition> MakeIndexTransformer::constructPattern(const std::vector<std::str
// don't permit multiple inequalities
// TODO: @SamArch27 invariant that we have at most one indexed inequality per relation
if (firstConstraint && inequality && seenInequality) {
// addCondition(Own<Condition>(clone(cond)));
addCondition(std::move(cond));
continue;
}
Expand Down
16 changes: 8 additions & 8 deletions tests/syntactic/ordered_constraints/ordered_constraints.dl
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Tests that constraints should be totally ordered

.decl A(A:number, B:number)
.decl B(A:number, B:number)
.decl C(A:number, B:number, C:number) inline
.decl D(A:number)
.decl E(A:number)
.decl A(x:number, y:number)
.decl B(x:number, y:number)
.decl C(x:number, y:number, z:number) inline
.decl D(x:number)
.decl E(x:number)

A(-25, -6).
B(-17, -3).

D(A) :- B(A,B), B = strlen("Zldfh").
C(V,V,Z) :- D(Z), B(V,V), !A(V,_), Z != V, Z = V - max J : { D(J)}.
E(C) :- C(_,B,C), C(C,B,C), C(_,B,C), C(_,B,_), C(C,_,C), C(_,B,_).
D(x) :- B(x,y), y = strlen("Zldfh").
C(y,y,x) :- D(x), B(y,y), !A(y,_), x != y, x = y - max z : { D(z)}.
E(z) :- C(_,y,z), C(z,y,z), C(_,y,z), C(_,y,_), C(z,_,z), C(_,y,_).

0 comments on commit 92a0e3d

Please sign in to comment.