use of com.dat3m.dartagnan.solver.caat.predicates.CAATPredicate in project Dat3M by hernanponcedeleon.
the class Reasoner method computeViolationReasons.
// ========================== Reason computation ==========================
public DNF<CAATLiteral> computeViolationReasons(Constraint constraint) {
if (!constraint.checkForViolations()) {
return DNF.FALSE();
}
CAATPredicate pred = constraint.getConstrainedPredicate();
Collection<? extends Collection<? extends Derivable>> violations = constraint.getViolations();
List<Conjunction<CAATLiteral>> reasonList = new ArrayList<>(violations.size());
if (constraint instanceof AcyclicityConstraint) {
// For acyclicity constraints, it is likely that we encounter the same
// edge multiple times (as it can be part of different cycles)
// so we memoize the computed reasons and reuse them if possible.
final RelationGraph constrainedGraph = (RelationGraph) pred;
final int mapSize = violations.stream().mapToInt(Collection::size).sum() * 4 / 3;
final Map<Edge, Conjunction<CAATLiteral>> reasonMap = new HashMap<>(mapSize);
for (Collection<Edge> violation : (Collection<Collection<Edge>>) violations) {
Conjunction<CAATLiteral> reason = violation.stream().map(edge -> reasonMap.computeIfAbsent(edge, key -> computeReason(constrainedGraph, key))).reduce(Conjunction.TRUE(), Conjunction::and);
reasonList.add(reason);
}
} else {
for (Collection<? extends Derivable> violation : violations) {
Conjunction<CAATLiteral> reason = violation.stream().map(edge -> computeReason(pred, edge)).reduce(Conjunction.TRUE(), Conjunction::and);
reasonList.add(reason);
}
}
return new DNF<>(reasonList);
}
use of com.dat3m.dartagnan.solver.caat.predicates.CAATPredicate in project Dat3M by hernanponcedeleon.
the class CAATModel method from.
public static CAATModel from(Collection<? extends CAATPredicate> predicates, Collection<? extends Constraint> constraints) {
Set<Constraint> consts = new HashSet<>(constraints);
Set<CAATPredicate> preds = new HashSet<>(predicates);
consts.forEach(c -> preds.add(c.getConstrainedPredicate()));
PredicateHierarchy hierarchy = new PredicateHierarchy(preds);
return new CAATModel(hierarchy, consts);
}
Aggregations