use of com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge 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.relationGraphs.Edge in project Dat3M by hernanponcedeleon.
the class ExternalGraph method edgeStream.
@Override
public Stream<Edge> edgeStream(int id, EdgeDirection dir) {
EventData e = getEvent(id);
Function<EventData, Edge> edgeMapping = dir == EdgeDirection.OUTGOING ? (x -> new Edge(id, x.getId())) : (x -> new Edge(x.getId(), id));
return threadEventsMap.entrySet().stream().filter(x -> x.getKey() != e.getThread()).flatMap(x -> x.getValue().stream()).map(edgeMapping);
}
use of com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge in project Dat3M by hernanponcedeleon.
the class FenceGraph method edgeStream.
@Override
public Stream<Edge> edgeStream(int id, EdgeDirection dir) {
EventData e = getEvent(id);
if (!e.isMemoryEvent()) {
return Stream.empty();
}
List<EventData> threadEvents = model.getThreadEventsMap().get(e.getThread());
if (dir == EdgeDirection.OUTGOING) {
EventData fence = getNextFence(e);
return fence == null ? Stream.empty() : threadEvents.subList(fence.getLocalId() + 1, threadEvents.size()).stream().filter(EventData::isMemoryEvent).map(x -> new Edge(id, x.getId()));
} else {
EventData fence = getPreviousFence(e);
return fence == null ? Stream.empty() : threadEvents.subList(0, fence.getLocalId()).stream().filter(EventData::isMemoryEvent).map(x -> new Edge(x.getId(), id));
}
}
use of com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge in project Dat3M by hernanponcedeleon.
the class ProgramOrderGraph method edgeStream.
@Override
public Stream<Edge> edgeStream(int id, EdgeDirection dir) {
EventData e = getEvent(id);
List<EventData> threadEvents = model.getThreadEventsMap().get(e.getThread());
if (dir == EdgeDirection.OUTGOING) {
return threadEvents.subList(e.getLocalId() + 1, threadEvents.size()).stream().map(x -> new Edge(id, x.getId()));
} else {
return threadEvents.subList(0, e.getLocalId()).stream().map(x -> new Edge(x.getId(), id));
}
}
use of com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge in project Dat3M by hernanponcedeleon.
the class IdentityGraph method repopulate.
@Override
public void repopulate() {
final int size = domain.size();
edges = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
edges.add(new Edge(i, i));
}
}
Aggregations