Search in sources :

Example 1 with Edge

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);
}
Also used : PredicateVisitor(com.dat3m.dartagnan.solver.caat.predicates.misc.PredicateVisitor) java.util(java.util) Element(com.dat3m.dartagnan.solver.caat.predicates.sets.Element) AcyclicityConstraint(com.dat3m.dartagnan.solver.caat.constraints.AcyclicityConstraint) DNF(com.dat3m.dartagnan.utils.logic.DNF) CAATPredicate(com.dat3m.dartagnan.solver.caat.predicates.CAATPredicate) Conjunction(com.dat3m.dartagnan.utils.logic.Conjunction) Derivable(com.dat3m.dartagnan.solver.caat.predicates.Derivable) Constraint(com.dat3m.dartagnan.solver.caat.constraints.Constraint) PathAlgorithm.findShortestPath(com.dat3m.dartagnan.solver.caat.misc.PathAlgorithm.findShortestPath) RelationGraph(com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.RelationGraph) Edge(com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge) EdgeDirection(com.dat3m.dartagnan.solver.caat.misc.EdgeDirection) SetPredicate(com.dat3m.dartagnan.solver.caat.predicates.sets.SetPredicate) AcyclicityConstraint(com.dat3m.dartagnan.solver.caat.constraints.AcyclicityConstraint) CAATPredicate(com.dat3m.dartagnan.solver.caat.predicates.CAATPredicate) AcyclicityConstraint(com.dat3m.dartagnan.solver.caat.constraints.AcyclicityConstraint) Constraint(com.dat3m.dartagnan.solver.caat.constraints.Constraint) RelationGraph(com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.RelationGraph) Conjunction(com.dat3m.dartagnan.utils.logic.Conjunction) Edge(com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge) DNF(com.dat3m.dartagnan.utils.logic.DNF)

Example 2 with Edge

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);
}
Also used : IntStream(java.util.stream.IntStream) List(java.util.List) Stream(java.util.stream.Stream) EventData(com.dat3m.dartagnan.verification.model.EventData) Map(java.util.Map) Thread(com.dat3m.dartagnan.program.Thread) Function(java.util.function.Function) Edge(com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge) EdgeDirection(com.dat3m.dartagnan.solver.caat.misc.EdgeDirection) Edge(com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge) EventData(com.dat3m.dartagnan.verification.model.EventData)

Example 3 with Edge

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));
    }
}
Also used : java.util(java.util) Stream(java.util.stream.Stream) EventData(com.dat3m.dartagnan.verification.model.EventData) Thread(com.dat3m.dartagnan.program.Thread) Edge(com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge) EdgeDirection(com.dat3m.dartagnan.solver.caat.misc.EdgeDirection) Edge(com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge) EventData(com.dat3m.dartagnan.verification.model.EventData)

Example 4 with Edge

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));
    }
}
Also used : Edge(com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge) EventData(com.dat3m.dartagnan.verification.model.EventData)

Example 5 with Edge

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));
    }
}
Also used : Edge(com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge)

Aggregations

Edge (com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge)22 EventData (com.dat3m.dartagnan.verification.model.EventData)10 EdgeDirection (com.dat3m.dartagnan.solver.caat.misc.EdgeDirection)7 Stream (java.util.stream.Stream)6 java.util (java.util)5 Function (java.util.function.Function)5 Thread (com.dat3m.dartagnan.program.Thread)3 BigInteger (java.math.BigInteger)3 RelationGraph (com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.RelationGraph)2 Element (com.dat3m.dartagnan.solver.caat.predicates.sets.Element)2 Conjunction (com.dat3m.dartagnan.utils.logic.Conjunction)2 Iterators (com.google.common.collect.Iterators)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Map (java.util.Map)2 Spliterator (java.util.Spliterator)2 IntStream (java.util.stream.IntStream)2 StreamSupport (java.util.stream.StreamSupport)2 Event (com.dat3m.dartagnan.program.event.core.Event)1 RMWStore (com.dat3m.dartagnan.program.event.core.rmw.RMWStore)1