Search in sources :

Example 16 with Event

use of dartagnan.program.Event in project Dat3M by hernanponcedeleon.

the class EncodingsCAT method satComp.

public static BoolExpr satComp(String name, String r1, String r2, Set<Event> events, Context ctx) throws Z3Exception {
    BoolExpr enc = ctx.mkTrue();
    for (Event e1 : events) {
        for (Event e2 : events) {
            BoolExpr orClause = ctx.mkFalse();
            for (Event e3 : events) {
                orClause = ctx.mkOr(orClause, ctx.mkAnd(edge(r1, e1, e3, ctx), edge(r2, e3, e2, ctx)));
            }
            enc = ctx.mkAnd(enc, ctx.mkEq(edge(name, e1, e2, ctx), orClause));
        }
    }
    return enc;
}
Also used : Event(dartagnan.program.Event)

Example 17 with Event

use of dartagnan.program.Event in project Dat3M by hernanponcedeleon.

the class EncodingsCAT method satCycleDef.

public static BoolExpr satCycleDef(String name, Set<Event> events, Context ctx) throws Z3Exception {
    BoolExpr enc = ctx.mkTrue();
    for (Event e1 : events) {
        Set<BoolExpr> source = new HashSet<BoolExpr>();
        Set<BoolExpr> target = new HashSet<BoolExpr>();
        for (Event e2 : events) {
            source.add(cycleEdge(name, e1, e2, ctx));
            target.add(cycleEdge(name, e2, e1, ctx));
            enc = ctx.mkAnd(enc, ctx.mkImplies(cycleEdge(name, e1, e2, ctx), ctx.mkAnd(e1.executes(ctx), e2.executes(ctx), edge(name, e1, e2, ctx), cycleVar(name, e1, ctx), cycleVar(name, e2, ctx))));
        }
        enc = ctx.mkAnd(enc, ctx.mkImplies(cycleVar(name, e1, ctx), ctx.mkAnd(encodeEO(source, ctx), encodeEO(target, ctx))));
    }
    return enc;
}
Also used : Event(dartagnan.program.Event) HashSet(java.util.HashSet)

Example 18 with Event

use of dartagnan.program.Event in project Dat3M by hernanponcedeleon.

the class EncodingsCAT method satTO.

public static BoolExpr satTO(String name, Set<Event> events, Context ctx) throws Z3Exception {
    BoolExpr enc = ctx.mkTrue();
    for (Event e1 : events) {
        enc = ctx.mkAnd(enc, ctx.mkImplies(e1.executes(ctx), ctx.mkGt(intVar(name, e1, ctx), ctx.mkInt(0))));
        enc = ctx.mkAnd(enc, ctx.mkImplies(e1.executes(ctx), ctx.mkLe(intVar(name, e1, ctx), ctx.mkInt(events.size()))));
        for (Event e2 : events) {
            enc = ctx.mkAnd(enc, ctx.mkImplies(edge(name, e1, e2, ctx), ctx.mkLt(intVar(name, e1, ctx), intVar(name, e2, ctx))));
            enc = ctx.mkAnd(enc, ctx.mkImplies(ctx.mkAnd(e1.executes(ctx), e2.executes(ctx)), ctx.mkImplies(ctx.mkLt(intVar(name, e1, ctx), intVar(name, e2, ctx)), edge(name, e1, e2, ctx))));
            if (e1 != e2) {
                enc = ctx.mkAnd(enc, ctx.mkImplies(ctx.mkAnd(e1.executes(ctx), e2.executes(ctx)), ctx.mkNot(ctx.mkEq(intVar(name, e1, ctx), intVar(name, e2, ctx)))));
                enc = ctx.mkAnd(enc, ctx.mkImplies(ctx.mkAnd(e1.executes(ctx), e2.executes(ctx)), ctx.mkOr(edge(name, e1, e2, ctx), edge(name, e2, e1, ctx))));
            }
        }
    }
    return enc;
}
Also used : Event(dartagnan.program.Event)

Example 19 with Event

use of dartagnan.program.Event in project Dat3M by hernanponcedeleon.

the class Encodings method satTransFixPoint.

public static BoolExpr satTransFixPoint(String name, Set<Event> events, Context ctx) throws Z3Exception {
    BoolExpr enc = ctx.mkTrue();
    int bound = (int) (Math.ceil(Math.log(events.size())) + 1);
    for (Event e1 : events) {
        for (Event e2 : events) {
            enc = ctx.mkAnd(enc, ctx.mkEq(Utils.edge(String.format("%s0", name), e1, e2, ctx), Utils.edge(name, e1, e2, ctx)));
            enc = ctx.mkAnd(enc, ctx.mkEq(Utils.edge(String.format("%s^+", name), e1, e2, ctx), Utils.edge(String.format("%s%s", name, bound), e1, e2, ctx)));
        }
    }
    for (int i : IntStream.range(0, bound).toArray()) {
        for (Event e1 : events) {
            for (Event e2 : events) {
                BoolExpr orClause = ctx.mkFalse();
                for (Event e3 : events) {
                    orClause = ctx.mkOr(orClause, ctx.mkAnd(Utils.edge(String.format("%s%s", name, i), e1, e3, ctx), Utils.edge(String.format("%s%s", name, i), e3, e2, ctx)));
                }
                enc = ctx.mkAnd(enc, ctx.mkEq(Utils.edge(String.format("%s%s", name, i + 1), e1, e2, ctx), ctx.mkOr(Utils.edge(name, e1, e2, ctx), orClause)));
            }
        }
    }
    return enc;
}
Also used : Event(dartagnan.program.Event) MemEvent(dartagnan.program.MemEvent)

Example 20 with Event

use of dartagnan.program.Event in project Dat3M by hernanponcedeleon.

the class Encodings method satTransIDL.

public static BoolExpr satTransIDL(String name, Set<Event> events, Context ctx) throws Z3Exception {
    BoolExpr enc = ctx.mkTrue();
    for (Event e1 : events) {
        for (Event e2 : events) {
            BoolExpr orClause = ctx.mkFalse();
            for (Event e3 : events) {
                orClause = ctx.mkOr(orClause, ctx.mkAnd(Utils.edge(String.format("%s^+", name), e1, e3, ctx), Utils.edge(String.format("%s^+", name), e3, e2, ctx), ctx.mkGt(Utils.intCount(String.format("(%s^+;%s^+)", name, name), e1, e2, ctx), Utils.intCount(String.format("%s^+", name), e1, e3, ctx)), ctx.mkGt(Utils.intCount(String.format("(%s^+;%s^+)", name, name), e1, e2, ctx), Utils.intCount(String.format("%s^+", name), e3, e2, ctx))));
            }
            enc = ctx.mkAnd(enc, ctx.mkEq(Utils.edge(String.format("(%s^+;%s^+)", name, name), e1, e2, ctx), orClause));
            enc = ctx.mkAnd(enc, ctx.mkEq(Utils.edge(String.format("%s^+", name), e1, e2, ctx), ctx.mkOr(ctx.mkAnd(Utils.edge(name, e1, e2, ctx), ctx.mkGt(Utils.intCount(String.format("%s^+", name), e1, e2, ctx), Utils.intCount(name, e1, e2, ctx))), ctx.mkAnd(Utils.edge(String.format("(%s^+;%s^+)", name, name), e1, e2, ctx), ctx.mkGt(Utils.intCount(String.format("%s^+", name), e1, e2, ctx), Utils.intCount(String.format("(%s^+;%s^+)", name, name), e1, e2, ctx))))));
        }
    }
    return enc;
}
Also used : Event(dartagnan.program.Event) MemEvent(dartagnan.program.MemEvent)

Aggregations

Event (dartagnan.program.Event)30 MemEvent (dartagnan.program.MemEvent)26 Local (dartagnan.program.Local)16 Program (dartagnan.program.Program)16 Collectors (java.util.stream.Collectors)16 Set (java.util.Set)15 Load (dartagnan.program.Load)13 Location (dartagnan.program.Location)13 Register (dartagnan.program.Register)13 com.microsoft.z3 (com.microsoft.z3)12 Init (dartagnan.program.Init)12 Store (dartagnan.program.Store)12 Utils.edge (dartagnan.utils.Utils.edge)11 HighLocation (dartagnan.program.HighLocation)7 Utils.lastValueLoc (dartagnan.utils.Utils.lastValueLoc)7 Utils.lastValueReg (dartagnan.utils.Utils.lastValueReg)7 Utils.ssaReg (dartagnan.utils.Utils.ssaReg)7 HashSet (java.util.HashSet)7 BoolExpr (com.microsoft.z3.BoolExpr)6 If (dartagnan.program.If)6