souffle
2.0.2-371-g6315b36
|
Go to the documentation of this file.
42 std::set<const BinaryConstraint*> relevantEqConstraints;
44 bool containsAggregators =
false;
47 relevantEqConstraints.insert(&bc);
52 for (
const auto* eqConstraint : relevantEqConstraints) {
60 const auto* var =
dynamic_cast<const Variable*
>(
lhs);
61 if (var ==
nullptr)
return;
70 for (
const auto* arg : rec->getArguments()) {
71 const auto* subVar =
dynamic_cast<const Variable*
>(arg);
72 assert(subVar !=
nullptr &&
"expected args to be variables");
81 for (
const auto& var : origDependency) {
84 newDependency.insert(var);
93 for (
const auto& dep : origDependency) {
95 if (!newDep.empty()) {
96 newDependencies.insert(newDep);
99 return newDependencies;
103 bool changed =
false;
104 std::map<std::string, BindingStore::DisjBindingSet> newVariableDependencies;
105 std::set<std::string> variablesToBind;
117 if (newDependencies.empty() || newDependencies.size() < dependencies.size()) {
120 variablesToBind.insert(headVar);
123 newVariableDependencies[headVar] = newDependencies;
124 changed |= (newDependencies != dependencies);
128 for (
auto var : variablesToBind) {
143 if (
const auto* var =
dynamic_cast<const Variable*
>(arg)) {
144 return isBound(var->getName());
145 }
else if (
const auto* term =
dynamic_cast<const Term*
>(arg)) {
146 for (
const auto* subArg : term->getArguments()) {
152 }
else if (isA<Constant>(arg)) {
161 for (
const auto* arg : atom->getArguments()) {
BindingStore(const Clause *clause)
bool contains(const C &container, const typename C::value_type &element)
A utility to check generically whether a given element is contained in a given container.
ConjBindingSet reduceDependency(const ConjBindingSet &origDependency)
Reduce a conjunctive set of dependencies based on the current bound variable set.
std::set< ConjBindingSet > DisjBindingSet
A variable to be utilized within constraints to be handled by the constraint solver.
void generateBindingDependencies(const Clause *clause)
Generate all binding dependencies implied by the constraints within a given clause.
std::set< std::string > stronglyBoundVariables
std::set< std::string > ConjBindingSet
bool reduceDependencies()
Reduce the full set of dependencies for all tracked variables, binding whatever needs to be bound.
BinaryConstraintOp getBaseOperator() const
Return binary operator.
bool isEqConstraint(const BinaryConstraintOp constraintOp)
bool isBound(std::string varName) const
Check if a variable is bound.
void processEqualityBindings(const Argument *lhs, const Argument *rhs)
Add binding dependencies formed on lhs by a <lhs> = <rhs> equality constraint.
Defines the aggregator class.
void addBindingDependency(std::string variable, ConjBindingSet dependency)
Add a new conjunction of variables as a potential binder for a given variable.
size_t numBoundArguments(const Atom *atom) const
Counts the number of bound arguments in the given atom.
void visitDepthFirst(const Node &root, Visitor< R, Ps... > &visitor, Args &... args)
A utility function visiting all nodes within the ast rooted by the given node recursively in a depth-...
std::map< std::string, DisjBindingSet > variableDependencies
Defines a record initialization class.