Search in sources :

Example 1 with Axiom

use of com.dat3m.dartagnan.wmm.axiom.Axiom in project Dat3M by hernanponcedeleon.

the class WmmEncoder method encodeConsistency.

// Encodes all axioms. This should be called after <encodeRelations>
public BooleanFormula encodeConsistency(SolverContext ctx) {
    checkInitialized();
    logger.info("Encoding consistency");
    BooleanFormulaManager bmgr = ctx.getFormulaManager().getBooleanFormulaManager();
    BooleanFormula expr = bmgr.makeTrue();
    for (Axiom ax : memoryModel.getAxioms()) {
        expr = bmgr.and(expr, ax.consistent(ctx));
    }
    return expr;
}
Also used : BooleanFormulaManager(org.sosy_lab.java_smt.api.BooleanFormulaManager) Axiom(com.dat3m.dartagnan.wmm.axiom.Axiom) BooleanFormula(org.sosy_lab.java_smt.api.BooleanFormula)

Example 2 with Axiom

use of com.dat3m.dartagnan.wmm.axiom.Axiom in project Dat3M by hernanponcedeleon.

the class WmmEncoder method encodeRelations.

// Initializes everything just like encodeAnarchicSemantics but also encodes all
// relations that are needed for the axioms (but does NOT encode the axioms themselves yet)
// NOTE: It avoids encoding relations that do NOT affect the axioms, i.e. unused relations
public BooleanFormula encodeRelations(SolverContext ctx) {
    checkInitialized();
    logger.info("Encoding relations");
    BooleanFormulaManager bmgr = ctx.getFormulaManager().getBooleanFormulaManager();
    BooleanFormula enc = encodeAnarchicSemantics(ctx);
    for (Axiom ax : memoryModel.getAxioms()) {
        enc = bmgr.and(enc, ax.getRelation().encode(ctx));
    }
    return enc;
}
Also used : BooleanFormulaManager(org.sosy_lab.java_smt.api.BooleanFormulaManager) Axiom(com.dat3m.dartagnan.wmm.axiom.Axiom) BooleanFormula(org.sosy_lab.java_smt.api.BooleanFormula)

Example 3 with Axiom

use of com.dat3m.dartagnan.wmm.axiom.Axiom in project Dat3M by hernanponcedeleon.

the class RelationAnalysis method run.

private void run(VerificationTask task, Context context) {
    // Init data context so that each relation is able to compute its may/must sets.
    Wmm memoryModel = task.getMemoryModel();
    for (Axiom ax : memoryModel.getAxioms()) {
        ax.getRelation().updateRecursiveGroupId(ax.getRelation().getRecursiveGroupId());
    }
    for (RecursiveGroup recursiveGroup : memoryModel.getRecursiveGroups()) {
        recursiveGroup.setDoRecurse();
    }
    // ------------------------------------------------
    for (String relName : Wmm.BASE_RELATIONS) {
        memoryModel.getRelationRepository().getRelation(relName).initializeRelationAnalysis(task, context);
    }
    for (Relation rel : memoryModel.getRelationRepository().getRelations()) {
        rel.initializeRelationAnalysis(task, context);
    }
    for (Axiom ax : memoryModel.getAxioms()) {
        ax.initializeRelationAnalysis(task, context);
    }
    // ------------------------------------------------
    for (String relName : Wmm.BASE_RELATIONS) {
        Relation baseRel = memoryModel.getRelationRepository().getRelation(relName);
        baseRel.getMaxTupleSet();
        baseRel.getMinTupleSet();
    }
    for (RecursiveGroup recursiveGroup : memoryModel.getRecursiveGroups()) {
        recursiveGroup.initMaxTupleSets();
        recursiveGroup.initMinTupleSets();
    }
    for (Axiom ax : memoryModel.getAxioms()) {
        ax.getRelation().getMaxTupleSet();
        ax.getRelation().getMinTupleSet();
    }
}
Also used : Relation(com.dat3m.dartagnan.wmm.relation.Relation) RecursiveGroup(com.dat3m.dartagnan.wmm.utils.RecursiveGroup) Wmm(com.dat3m.dartagnan.wmm.Wmm) Axiom(com.dat3m.dartagnan.wmm.axiom.Axiom)

Example 4 with Axiom

use of com.dat3m.dartagnan.wmm.axiom.Axiom in project Dat3M by hernanponcedeleon.

the class SymmetryEncoder method sort.

private void sort(List<Tuple> row) {
    if (!breakBySyncDegree) {
        // ===== Natural order =====
        row.sort(Comparator.naturalOrder());
        return;
    }
    // ====== Sync-degree based order ======
    // Setup of data structures
    Set<Event> inEvents = new HashSet<>();
    Set<Event> outEvents = new HashSet<>();
    for (Tuple t : row) {
        inEvents.add(t.getFirst());
        outEvents.add(t.getSecond());
    }
    Map<Event, Integer> combInDegree = new HashMap<>(inEvents.size());
    Map<Event, Integer> combOutDegree = new HashMap<>(outEvents.size());
    List<Axiom> axioms = memoryModel.getAxioms();
    for (Event e : inEvents) {
        int syncDeg = axioms.stream().mapToInt(ax -> ax.getRelation().getMinTupleSet().getBySecond(e).size() + 1).max().orElse(0);
        combInDegree.put(e, syncDeg);
    }
    for (Event e : outEvents) {
        int syncDec = axioms.stream().mapToInt(ax -> ax.getRelation().getMinTupleSet().getByFirst(e).size() + 1).max().orElse(0);
        combOutDegree.put(e, syncDec);
    }
    // Sort by sync degrees
    row.sort(Comparator.<Tuple>comparingInt(t -> combInDegree.get(t.getFirst()) * combOutDegree.get(t.getSecond())).reversed());
}
Also used : Event(com.dat3m.dartagnan.program.event.core.Event) Axiom(com.dat3m.dartagnan.wmm.axiom.Axiom) Tuple(com.dat3m.dartagnan.wmm.utils.Tuple)

Example 5 with Axiom

use of com.dat3m.dartagnan.wmm.axiom.Axiom 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)

Aggregations

Axiom (com.dat3m.dartagnan.wmm.axiom.Axiom)6 Relation (com.dat3m.dartagnan.wmm.relation.Relation)2 BooleanFormula (org.sosy_lab.java_smt.api.BooleanFormula)2 BooleanFormulaManager (org.sosy_lab.java_smt.api.BooleanFormulaManager)2 Thread (com.dat3m.dartagnan.program.Thread)1 Event (com.dat3m.dartagnan.program.event.core.Event)1 Store (com.dat3m.dartagnan.program.event.core.Store)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 RelationGraph (com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.RelationGraph)1 Wmm (com.dat3m.dartagnan.wmm.Wmm)1 RecursiveGroup (com.dat3m.dartagnan.wmm.utils.RecursiveGroup)1 Tuple (com.dat3m.dartagnan.wmm.utils.Tuple)1 TupleSet (com.dat3m.dartagnan.wmm.utils.TupleSet)1 HashSet (java.util.HashSet)1