Search in sources :

Example 1 with EventDomain

use of com.dat3m.dartagnan.solver.caat4wmm.EventDomain in project Dat3M by hernanponcedeleon.

the class CoreReasoner method toCoreReason.

public Conjunction<CoreLiteral> toCoreReason(Conjunction<CAATLiteral> baseReason) {
    RelationRepository repo = memoryModel.getRelationRepository();
    EventDomain domain = executionGraph.getDomain();
    List<CoreLiteral> coreReason = new ArrayList<>(baseReason.getSize());
    for (CAATLiteral lit : baseReason.getLiterals()) {
        if (lit instanceof ElementLiteral) {
            Event e = domain.getObjectById(((ElementLiteral) lit).getElement().getId()).getEvent();
            // We only have static tags, so all of them reduce to execution literals
            coreReason.add(new ExecLiteral(e, lit.isNegative()));
        } else {
            EdgeLiteral edgeLit = (EdgeLiteral) lit;
            Edge edge = edgeLit.getEdge();
            Event e1 = domain.getObjectById(edge.getFirst()).getEvent();
            Event e2 = domain.getObjectById(edge.getSecond()).getEvent();
            Tuple tuple = new Tuple(e1, e2);
            Relation rel = repo.getRelation(lit.getName());
            if (lit.isPositive() && rel.getMinTupleSet().contains(tuple)) {
                // Statically present edges
                addExecReason(tuple, coreReason);
            } else if (lit.isNegative() && !rel.getMaxTupleSet().contains(tuple)) {
            // Statically absent edges
            } else {
                if (rel instanceof RelFencerel) {
                    // We should do this transformation directly on the Wmm to avoid this special reasoning
                    if (lit.isNegative()) {
                        throw new UnsupportedOperationException(String.format("FenceRel %s is not allowed on the rhs of differences.", rel));
                    }
                    addFenceReason(rel, edge, coreReason);
                } else if (rel.getName().equals(LOC)) {
                    coreReason.add(new AddressLiteral(tuple, lit.isNegative()));
                } else if (rel.getName().equals(RF) || rel.getName().equals(CO)) {
                    coreReason.add(new RelLiteral(rel.getName(), tuple, lit.isNegative()));
                } else {
                    // TODO: Right now, we assume many relations like Data, Ctrl and Addr to be
                    // static.
                    addExecReason(tuple, coreReason);
                }
            }
        }
    }
    minimize(coreReason);
    return new Conjunction<>(coreReason);
}
Also used : CAATLiteral(com.dat3m.dartagnan.solver.caat.reasoning.CAATLiteral) ArrayList(java.util.ArrayList) RelationRepository(com.dat3m.dartagnan.wmm.utils.RelationRepository) Relation(com.dat3m.dartagnan.wmm.relation.Relation) EventDomain(com.dat3m.dartagnan.solver.caat4wmm.EventDomain) ElementLiteral(com.dat3m.dartagnan.solver.caat.reasoning.ElementLiteral) RelFencerel(com.dat3m.dartagnan.wmm.relation.base.stat.RelFencerel) Conjunction(com.dat3m.dartagnan.utils.logic.Conjunction) Event(com.dat3m.dartagnan.program.event.core.Event) Edge(com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge) EdgeLiteral(com.dat3m.dartagnan.solver.caat.reasoning.EdgeLiteral) Tuple(com.dat3m.dartagnan.wmm.utils.Tuple)

Example 2 with EventDomain

use of com.dat3m.dartagnan.solver.caat4wmm.EventDomain in project Dat3M by hernanponcedeleon.

the class CoreReasoner method addFenceReason.

private void addFenceReason(Relation rel, Edge edge, List<CoreLiteral> coreReasons) {
    FenceGraph fenceGraph = (FenceGraph) executionGraph.getRelationGraph(rel);
    EventDomain domain = executionGraph.getDomain();
    EventData e1 = domain.getObjectById(edge.getFirst());
    EventData e2 = domain.getObjectById(edge.getSecond());
    EventData f = fenceGraph.getNextFence(e1);
    coreReasons.add(new ExecLiteral(f.getEvent()));
    if (!exec.isImplied(f.getEvent(), e1.getEvent())) {
        coreReasons.add(new ExecLiteral(e1.getEvent()));
    }
    if (!exec.isImplied(f.getEvent(), e2.getEvent())) {
        coreReasons.add(new ExecLiteral(e2.getEvent()));
    }
}
Also used : EventDomain(com.dat3m.dartagnan.solver.caat4wmm.EventDomain) FenceGraph(com.dat3m.dartagnan.solver.caat4wmm.basePredicates.FenceGraph) EventData(com.dat3m.dartagnan.verification.model.EventData)

Aggregations

EventDomain (com.dat3m.dartagnan.solver.caat4wmm.EventDomain)2 Event (com.dat3m.dartagnan.program.event.core.Event)1 Edge (com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge)1 CAATLiteral (com.dat3m.dartagnan.solver.caat.reasoning.CAATLiteral)1 EdgeLiteral (com.dat3m.dartagnan.solver.caat.reasoning.EdgeLiteral)1 ElementLiteral (com.dat3m.dartagnan.solver.caat.reasoning.ElementLiteral)1 FenceGraph (com.dat3m.dartagnan.solver.caat4wmm.basePredicates.FenceGraph)1 Conjunction (com.dat3m.dartagnan.utils.logic.Conjunction)1 EventData (com.dat3m.dartagnan.verification.model.EventData)1 Relation (com.dat3m.dartagnan.wmm.relation.Relation)1 RelFencerel (com.dat3m.dartagnan.wmm.relation.base.stat.RelFencerel)1 RelationRepository (com.dat3m.dartagnan.wmm.utils.RelationRepository)1 Tuple (com.dat3m.dartagnan.wmm.utils.Tuple)1 ArrayList (java.util.ArrayList)1