38 auto constraint =
dynamic_cast<const BinaryConstraint*
>(literal);
40 if (constraint ==
nullptr) {
44 const auto* left = constraint->getLHS();
45 const auto* right = constraint->getRHS();
47 const auto* leftRecord =
dynamic_cast<const RecordInit*
>(left);
48 const auto* rightRecord =
dynamic_cast<const RecordInit*
>(right);
51 if ((leftRecord ==
nullptr) || (rightRecord ==
nullptr)) {
56 if (leftRecord->getChildNodes().size() != rightRecord->getChildNodes().size()) {
61 auto op = constraint->getBaseOperator();
79 assert(left !=
nullptr &&
"Non-record passed to record method");
80 assert(right !=
nullptr &&
"Non-record passed to record method");
82 auto leftChildren = left->getArguments();
83 auto rightChildren = right->getArguments();
85 assert(leftChildren.size() == rightChildren.size());
88 for (
size_t i = 0;
i < leftChildren.size(); ++
i) {
91 replacedContraint.push_back(std::move(newConstraint));
95 if (leftChildren.size() == 0) {
103 return replacedContraint;
109 BinaryConstraint* neqConstraint =
nullptr;
112 for (
auto* literal : clause.getBodyLiterals()) {
119 std::move(std::begin(transformedLiterals), std::end(transformedLiterals),
120 std::back_inserter(newBody));
124 }
else if (neqConstraint ==
nullptr) {
139 if (neqConstraint ==
nullptr) {
141 newClause->setBodyLiterals(std::move(newBody));
142 newClauses.emplace_back(std::move(newClause));
148 for (
auto it = begin(transformedLiterals); it != end(transformedLiterals); ++it) {
151 copyBody.push_back(std::move(*it));
153 newClause->setBodyLiterals(std::move(copyBody));
155 newClauses.push_back(std::move(newClause));
161 bool changed =
false;
162 Program& program = translationUnit.getProgram();
166 for (
const auto* clause : program.getClauses()) {
171 newClauses.emplace_back(clause->clone());
177 program.setClauses(std::move(newClauses));