Search in sources :

Example 11 with Relation

use of com.dat3m.dartagnan.wmm.relation.Relation in project Dat3M by hernanponcedeleon.

the class VisitorRelation method visitExprIdentity.

@Override
public Relation visitExprIdentity(CatParser.ExprIdentityContext ctx) {
    boolean orig = base.recursiveDef;
    base.recursiveDef = false;
    FilterAbstract filter = ctx.e.accept(base.filterVisitor);
    Relation relation = base.relationRepository.getRelation(RelSetIdentity.class, filter);
    base.recursiveDef = orig;
    return relation;
}
Also used : RecursiveRelation(com.dat3m.dartagnan.wmm.relation.RecursiveRelation) Relation(com.dat3m.dartagnan.wmm.relation.Relation) FilterAbstract(com.dat3m.dartagnan.program.filter.FilterAbstract)

Example 12 with Relation

use of com.dat3m.dartagnan.wmm.relation.Relation in project Dat3M by hernanponcedeleon.

the class ExecutionGraph method constructMappings.

// --------------------------------------------------
private void constructMappings(boolean createOnlyAxiomRelevantGraphs) {
    Set<RelationGraph> graphs = new HashSet<>();
    Set<Constraint> constraints = new HashSet<>();
    for (Axiom axiom : verificationTask.getAxioms()) {
        Constraint constraint = getOrCreateConstraintFromAxiom(axiom);
        constraints.add(constraint);
    }
    if (!createOnlyAxiomRelevantGraphs) {
        for (Relation rel : verificationTask.getRelationDependencyGraph().getNodeContents()) {
            if (!EXCLUDED_RELS.contains(rel.getName())) {
                RelationGraph graph = getOrCreateGraphFromRelation(rel);
                graphs.add(graph);
            }
        }
    }
    caatModel = CAATModel.from(graphs, constraints);
}
Also used : Relation(com.dat3m.dartagnan.wmm.relation.Relation) RelationGraph(com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.RelationGraph) AcyclicityConstraint(com.dat3m.dartagnan.solver.caat.constraints.AcyclicityConstraint) IrreflexivityConstraint(com.dat3m.dartagnan.solver.caat.constraints.IrreflexivityConstraint) EmptinessConstraint(com.dat3m.dartagnan.solver.caat.constraints.EmptinessConstraint) Constraint(com.dat3m.dartagnan.solver.caat.constraints.Constraint) Axiom(com.dat3m.dartagnan.wmm.axiom.Axiom) HashSet(java.util.HashSet)

Example 13 with Relation

use of com.dat3m.dartagnan.wmm.relation.Relation 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 14 with Relation

use of com.dat3m.dartagnan.wmm.relation.Relation in project Dat3M by hernanponcedeleon.

the class RefinementTask method createDefaultWmm.

private Wmm createDefaultWmm() {
    Wmm baseline = new Wmm();
    RelationRepository repo = baseline.getRelationRepository();
    Relation rf = repo.getRelation(RF);
    if (baselines.contains(UNIPROC)) {
        // ---- acyclic(po-loc | rf) ----
        Relation poloc = repo.getRelation(POLOC);
        Relation co = repo.getRelation(CO);
        Relation fr = repo.getRelation(FR);
        Relation porf = new RelUnion(poloc, rf);
        repo.addRelation(porf);
        Relation porfco = new RelUnion(porf, co);
        repo.addRelation(porfco);
        Relation porfcofr = new RelUnion(porfco, fr);
        repo.addRelation(porfcofr);
        baseline.addAxiom(new Acyclic(porfcofr));
    }
    if (baselines.contains(NO_OOTA)) {
        // ---- acyclic (dep | rf) ----
        Relation data = repo.getRelation(DATA);
        Relation ctrl = repo.getRelation(CTRL);
        Relation addr = repo.getRelation(ADDR);
        Relation dep = new RelUnion(data, addr);
        repo.addRelation(dep);
        dep = new RelUnion(ctrl, dep);
        repo.addRelation(dep);
        Relation hb = new RelUnion(dep, rf);
        repo.addRelation(hb);
        baseline.addAxiom(new Acyclic(hb));
    }
    if (baselines.contains(ATOMIC_RMW)) {
        // ---- empty (rmw & fre;coe) ----
        Relation rmw = repo.getRelation(RMW);
        Relation coe = repo.getRelation(COE);
        Relation fre = repo.getRelation(FRE);
        Relation frecoe = new RelComposition(fre, coe);
        repo.addRelation(frecoe);
        Relation rmwANDfrecoe = new RelIntersection(rmw, frecoe);
        repo.addRelation(rmwANDfrecoe);
        baseline.addAxiom(new Empty(rmwANDfrecoe));
    }
    return baseline;
}
Also used : Relation(com.dat3m.dartagnan.wmm.relation.Relation) Empty(com.dat3m.dartagnan.wmm.axiom.Empty) RelUnion(com.dat3m.dartagnan.wmm.relation.binary.RelUnion) Wmm(com.dat3m.dartagnan.wmm.Wmm) Acyclic(com.dat3m.dartagnan.wmm.axiom.Acyclic) RelComposition(com.dat3m.dartagnan.wmm.relation.binary.RelComposition) RelIntersection(com.dat3m.dartagnan.wmm.relation.binary.RelIntersection) RelationRepository(com.dat3m.dartagnan.wmm.utils.RelationRepository)

Example 15 with Relation

use of com.dat3m.dartagnan.wmm.relation.Relation in project Dat3M by hernanponcedeleon.

the class RelationRepository method getRelation.

public Relation getRelation(Class<?> cls, Object... args) {
    Class<?>[] argClasses = getArgsForClass(cls);
    try {
        Method method = cls.getMethod("makeTerm", argClasses);
        String term = (String) method.invoke(null, args);
        Relation relation;
        if (containsRelation(term)) {
            relation = relationMap.get(term);
        } else {
            Constructor<?> constructor = cls.getConstructor(argClasses);
            relation = (Relation) constructor.newInstance(args);
            addRelation(relation);
        }
        return relation;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
Also used : UnaryRelation(com.dat3m.dartagnan.wmm.relation.unary.UnaryRelation) RecursiveRelation(com.dat3m.dartagnan.wmm.relation.RecursiveRelation) Relation(com.dat3m.dartagnan.wmm.relation.Relation) BinaryRelation(com.dat3m.dartagnan.wmm.relation.binary.BinaryRelation) Method(java.lang.reflect.Method)

Aggregations

Relation (com.dat3m.dartagnan.wmm.relation.Relation)15 RecursiveRelation (com.dat3m.dartagnan.wmm.relation.RecursiveRelation)9 ParsingException (com.dat3m.dartagnan.exception.ParsingException)3 FilterAbstract (com.dat3m.dartagnan.program.filter.FilterAbstract)3 RelationGraph (com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.RelationGraph)2 Wmm (com.dat3m.dartagnan.wmm.Wmm)2 Axiom (com.dat3m.dartagnan.wmm.axiom.Axiom)2 RelComposition (com.dat3m.dartagnan.wmm.relation.binary.RelComposition)2 RelUnion (com.dat3m.dartagnan.wmm.relation.binary.RelUnion)2 RelationRepository (com.dat3m.dartagnan.wmm.utils.RelationRepository)2 CatParser (com.dat3m.dartagnan.parsers.CatParser)1 Event (com.dat3m.dartagnan.program.event.core.Event)1 MemEvent (com.dat3m.dartagnan.program.event.core.MemEvent)1 AcyclicityConstraint (com.dat3m.dartagnan.solver.caat.constraints.AcyclicityConstraint)1 Constraint (com.dat3m.dartagnan.solver.caat.constraints.Constraint)1 EmptinessConstraint (com.dat3m.dartagnan.solver.caat.constraints.EmptinessConstraint)1 IrreflexivityConstraint (com.dat3m.dartagnan.solver.caat.constraints.IrreflexivityConstraint)1 Edge (com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge)1 EmptyGraph (com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.base.EmptyGraph)1 IdentityGraph (com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.base.IdentityGraph)1