Search in sources :

Example 31 with TupleSet

use of com.dat3m.dartagnan.wmm.utils.TupleSet in project Dat3M by hernanponcedeleon.

the class RelRangeIdentity method addEncodeTupleSet.

@Override
public void addEncodeTupleSet(TupleSet tuples) {
    TupleSet activeSet = new TupleSet(Sets.intersection(Sets.difference(tuples, encodeTupleSet), maxTupleSet));
    encodeTupleSet.addAll(activeSet);
    activeSet.removeAll(getMinTupleSet());
    // TODO: Optimize using minSets (but no CAT uses this anyway)
    if (!activeSet.isEmpty()) {
        TupleSet r1Set = new TupleSet();
        for (Tuple tuple : activeSet) {
            r1Set.addAll(r1.getMaxTupleSet().getBySecond(tuple.getFirst()));
        }
        r1.addEncodeTupleSet(r1Set);
    }
}
Also used : TupleSet(com.dat3m.dartagnan.wmm.utils.TupleSet) Tuple(com.dat3m.dartagnan.wmm.utils.Tuple)

Example 32 with TupleSet

use of com.dat3m.dartagnan.wmm.utils.TupleSet in project Dat3M by hernanponcedeleon.

the class RelTrans method getMinTupleSet.

@Override
public TupleSet getMinTupleSet() {
    if (minTupleSet == null) {
        // TODO: Make sure this is correct and efficient
        ExecutionAnalysis exec = analysisContext.get(ExecutionAnalysis.class);
        minTupleSet = new TupleSet(r1.getMinTupleSet());
        boolean changed;
        int size = minTupleSet.size();
        do {
            minTupleSet.addAll(minTupleSet.postComposition(r1.getMinTupleSet(), (t1, t2) -> exec.isImplied(t1.getFirst(), t1.getSecond()) || exec.isImplied(t2.getSecond(), t1.getSecond())));
            changed = minTupleSet.size() != size;
            size = minTupleSet.size();
        } while (changed);
        removeMutuallyExclusiveTuples(minTupleSet);
    }
    return minTupleSet;
}
Also used : VerificationTask(com.dat3m.dartagnan.verification.VerificationTask) ExecutionAnalysis(com.dat3m.dartagnan.program.analysis.ExecutionAnalysis) BooleanFormula(org.sosy_lab.java_smt.api.BooleanFormula) Set(java.util.Set) Relation(com.dat3m.dartagnan.wmm.relation.Relation) Sets(com.google.common.collect.Sets) BooleanFormulaManager(org.sosy_lab.java_smt.api.BooleanFormulaManager) Context(com.dat3m.dartagnan.verification.Context) TupleSet(com.dat3m.dartagnan.wmm.utils.TupleSet) Map(java.util.Map) SolverContext(org.sosy_lab.java_smt.api.SolverContext) Event(com.dat3m.dartagnan.program.event.core.Event) Tuple(com.dat3m.dartagnan.wmm.utils.Tuple) TupleSet(com.dat3m.dartagnan.wmm.utils.TupleSet) ExecutionAnalysis(com.dat3m.dartagnan.program.analysis.ExecutionAnalysis)

Example 33 with TupleSet

use of com.dat3m.dartagnan.wmm.utils.TupleSet in project Dat3M by hernanponcedeleon.

the class RelTrans method getMaxTupleSet.

@Override
public TupleSet getMaxTupleSet() {
    if (maxTupleSet == null) {
        transitiveReachabilityMap = r1.getMaxTupleSet().transMap();
        maxTupleSet = new TupleSet();
        for (Event e1 : transitiveReachabilityMap.keySet()) {
            for (Event e2 : transitiveReachabilityMap.get(e1)) {
                maxTupleSet.add(new Tuple(e1, e2));
            }
        }
        removeMutuallyExclusiveTuples(maxTupleSet);
    }
    return maxTupleSet;
}
Also used : TupleSet(com.dat3m.dartagnan.wmm.utils.TupleSet) Event(com.dat3m.dartagnan.program.event.core.Event) Tuple(com.dat3m.dartagnan.wmm.utils.Tuple)

Example 34 with TupleSet

use of com.dat3m.dartagnan.wmm.utils.TupleSet in project Dat3M by hernanponcedeleon.

the class RelTrans method encodeApprox.

@Override
protected BooleanFormula encodeApprox(SolverContext ctx) {
    BooleanFormulaManager bmgr = ctx.getFormulaManager().getBooleanFormulaManager();
    BooleanFormula enc = bmgr.makeTrue();
    TupleSet minSet = getMinTupleSet();
    TupleSet r1Max = r1.getMaxTupleSet();
    for (Tuple tuple : fullEncodeTupleSet) {
        if (minSet.contains(tuple)) {
            if (Relation.PostFixApprox) {
                enc = bmgr.and(enc, bmgr.implication(getExecPair(tuple, ctx), this.getSMTVar(tuple, ctx)));
            } else {
                enc = bmgr.and(enc, bmgr.equivalence(this.getSMTVar(tuple, ctx), getExecPair(tuple, ctx)));
            }
            continue;
        }
        BooleanFormula orClause = bmgr.makeFalse();
        Event e1 = tuple.getFirst();
        Event e2 = tuple.getSecond();
        if (r1Max.contains(tuple)) {
            orClause = bmgr.or(orClause, r1.getSMTVar(tuple, ctx));
        }
        for (Tuple t : r1Max.getByFirst(e1)) {
            Event e3 = t.getSecond();
            if (e3.getCId() != e1.getCId() && e3.getCId() != e2.getCId() && transitiveReachabilityMap.get(e3).contains(e2)) {
                BooleanFormula tVar = minSet.contains(t) ? this.getSMTVar(t, ctx) : r1.getSMTVar(t, ctx);
                orClause = bmgr.or(orClause, bmgr.and(tVar, this.getSMTVar(e3, e2, ctx)));
            }
        }
        if (Relation.PostFixApprox) {
            enc = bmgr.and(enc, bmgr.implication(orClause, this.getSMTVar(tuple, ctx)));
        } else {
            enc = bmgr.and(enc, bmgr.equivalence(this.getSMTVar(tuple, ctx), orClause));
        }
    }
    return enc;
}
Also used : TupleSet(com.dat3m.dartagnan.wmm.utils.TupleSet) BooleanFormulaManager(org.sosy_lab.java_smt.api.BooleanFormulaManager) Event(com.dat3m.dartagnan.program.event.core.Event) BooleanFormula(org.sosy_lab.java_smt.api.BooleanFormula) Tuple(com.dat3m.dartagnan.wmm.utils.Tuple)

Example 35 with TupleSet

use of com.dat3m.dartagnan.wmm.utils.TupleSet in project Dat3M by hernanponcedeleon.

the class RelTransRef method initializeRelationAnalysis.

@Override
public void initializeRelationAnalysis(VerificationTask task, Context context) {
    super.initializeRelationAnalysis(task, context);
    identityEncodeTupleSet = new TupleSet();
    transEncodeTupleSet = new TupleSet();
}
Also used : TupleSet(com.dat3m.dartagnan.wmm.utils.TupleSet)

Aggregations

TupleSet (com.dat3m.dartagnan.wmm.utils.TupleSet)47 Tuple (com.dat3m.dartagnan.wmm.utils.Tuple)36 Event (com.dat3m.dartagnan.program.event.core.Event)27 BooleanFormula (org.sosy_lab.java_smt.api.BooleanFormula)16 BooleanFormulaManager (org.sosy_lab.java_smt.api.BooleanFormulaManager)16 ExecutionAnalysis (com.dat3m.dartagnan.program.analysis.ExecutionAnalysis)11 Thread (com.dat3m.dartagnan.program.Thread)10 Relation (com.dat3m.dartagnan.wmm.relation.Relation)8 SolverContext (org.sosy_lab.java_smt.api.SolverContext)8 Sets (com.google.common.collect.Sets)7 MemEvent (com.dat3m.dartagnan.program.event.core.MemEvent)5 Set (java.util.Set)5 AliasAnalysis (com.dat3m.dartagnan.program.analysis.AliasAnalysis)4 HashSet (java.util.HashSet)4 Collectors (java.util.stream.Collectors)4 Tag (com.dat3m.dartagnan.program.event.Tag)3 WmmAnalysis (com.dat3m.dartagnan.wmm.analysis.WmmAnalysis)3 LogManager (org.apache.logging.log4j.LogManager)3 Logger (org.apache.logging.log4j.Logger)3 GlobalSettings (com.dat3m.dartagnan.GlobalSettings)2