Search in sources :

Example 1 with Assert

use of dartagnan.expression.Assert in project Dat3M by hernanponcedeleon.

the class Encodings method AssertFromModel.

public static Assert AssertFromModel(Program p, Model model, Context ctx) {
    Assert ass = new Assert();
    Set<Location> locs = p.getEvents().stream().filter(e -> e instanceof MemEvent).map(e -> e.getLoc()).collect(Collectors.toSet());
    for (Location loc : locs) {
        ass.addPair(loc, Integer.valueOf(model.getConstInterp(ctx.mkIntConst(loc.getName() + "_final")).toString()));
    }
    Set<Event> executedEvents = p.getEvents().stream().filter(e -> model.getConstInterp(e.executes(ctx)).isTrue()).collect(Collectors.toSet());
    Set<Register> regs = executedEvents.stream().filter(e -> e instanceof Local | e instanceof Load).map(e -> e.getReg()).collect(Collectors.toSet());
    for (Register reg : regs) {
        Set<Integer> ssaRegIndexes = new HashSet<Integer>();
        for (Event e : executedEvents) {
            if (!(e instanceof Load | e instanceof Local)) {
                continue;
            }
            if (e.getReg() != reg) {
                continue;
            }
            ssaRegIndexes.add(e.getSsaRegIndex());
        }
        Integer lastRegIndex = Collections.max(ssaRegIndexes);
        String regVarName = String.format("T%s_%s_%s", reg.getMainThread(), reg.getName(), lastRegIndex);
        ass.addPair(reg, Integer.valueOf(model.getConstInterp(ctx.mkIntConst(regVarName)).toString()));
    }
    return ass;
}
Also used : IntStream(java.util.stream.IntStream) com.microsoft.z3(com.microsoft.z3) Event(dartagnan.program.Event) Set(java.util.Set) Assert(dartagnan.expression.Assert) Utils(dartagnan.utils.Utils) Collectors(java.util.stream.Collectors) Init(dartagnan.program.Init) HashSet(java.util.HashSet) Register(dartagnan.program.Register) Local(dartagnan.program.Local) Load(dartagnan.program.Load) MemEvent(dartagnan.program.MemEvent) Program(dartagnan.program.Program) Collections(java.util.Collections) Store(dartagnan.program.Store) Location(dartagnan.program.Location) Load(dartagnan.program.Load) Local(dartagnan.program.Local) Assert(dartagnan.expression.Assert) Register(dartagnan.program.Register) MemEvent(dartagnan.program.MemEvent) Event(dartagnan.program.Event) MemEvent(dartagnan.program.MemEvent) Location(dartagnan.program.Location) HashSet(java.util.HashSet)

Aggregations

com.microsoft.z3 (com.microsoft.z3)1 Assert (dartagnan.expression.Assert)1 Event (dartagnan.program.Event)1 Init (dartagnan.program.Init)1 Load (dartagnan.program.Load)1 Local (dartagnan.program.Local)1 Location (dartagnan.program.Location)1 MemEvent (dartagnan.program.MemEvent)1 Program (dartagnan.program.Program)1 Register (dartagnan.program.Register)1 Store (dartagnan.program.Store)1 Utils (dartagnan.utils.Utils)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 IntStream (java.util.stream.IntStream)1