Reputation: 33
I have a predicate in my Alloy model, called LS, which gets an instance of a sig called st. I am trying to evaluate this predicate on an instance of st, called st$0, in the source code. I can find the solution of type A4Solution, called ans. But I don't know how I can evaluate this predicate on this solution.
Upvotes: 0
Views: 178
Reputation: 3857
Here is how you can in general evaluate predicates using the API
String fileName = "<file path to your alloy model>";
Module world = CompUtil.parseEverything_fromFile(rep, null, fileName);
A4Options opt = new A4Options();
opt.solver = A4Options.SatSolver.SAT4J;
// run the first command for the sake of this example
Command cmd = world.getAllCommands().get(0);
A4Solution sol = TranslateAlloyToKodkod.execute_command(rep, world.getAllReachableSigs(), cmd, opt);
// evaluate the first defined function/predicate applied to the first defined Sig
Func func = world.getAllFunc().get(0);
Sig sig = world.getAllSigs().get(0);
System.out.println(sol.eval(func.call(sig)));
Upvotes: 1