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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations