use of ai.grakn.graql.internal.reasoner.atom.predicate.NeqPredicate in project grakn by graknlabs.
the class ResolutionPlan method isValid.
/**
* @return true if the plan doesn't lead to any non-ground neq predicate
*/
private boolean isValid() {
// check for neq groundness
Set<NeqPredicate> nonGroundPredicates = new HashSet<>();
Set<Var> mappedVars = new HashSet<>();
for (Atom atom : plan) {
mappedVars.addAll(atom.getVarNames());
atom.getPredicates(NeqPredicate.class).forEach(neq -> {
// look for non-local non-ground predicates
if (!mappedVars.containsAll(neq.getVarNames()) && !atom.getVarNames().containsAll(neq.getVarNames())) {
nonGroundPredicates.add(neq);
} else {
// if this is ground for this atom but non-ground for another it is ground
if (nonGroundPredicates.contains(neq))
nonGroundPredicates.remove(neq);
}
});
}
return nonGroundPredicates.isEmpty();
}
Aggregations