Search in sources :

Example 11 with A4Options

use of edu.mit.csail.sdg.translator.A4Options in project org.alloytools.alloy by AlloyTools.

the class DemoFileSystem method runFor3.

void runFor3(Expr expr) throws Err {
    A4Options opt = new A4Options();
    Command cmd = new Command(false, 3, 3, 3, expr.and(fact));
    A4Solution sol = TranslateAlloyToKodkod.execute_command(NOP, sigs, cmd, opt);
    System.out.println(sol.toString().trim());
    if (sol.satisfiable()) {
        System.out.println("In particular, File = " + sol.eval(file));
        System.out.println("In particular, Dir = " + sol.eval(dir));
        System.out.println("In particular, contains = " + sol.eval(contains));
        System.out.println("In particular, parent = " + sol.eval(parent));
    }
    System.out.println();
}
Also used : Command(edu.mit.csail.sdg.ast.Command) A4Options(edu.mit.csail.sdg.translator.A4Options) A4Solution(edu.mit.csail.sdg.translator.A4Solution)

Example 12 with A4Options

use of edu.mit.csail.sdg.translator.A4Options in project org.alloytools.alloy by AlloyTools.

the class ExampleCompilingFromSource method compileModuleAndRun.

public static void compileModuleAndRun(String model) throws Err {
    A4Reporter rep = new A4Reporter();
    // parse model from string
    CompModule world = CompUtil.parseEverything_fromString(rep, model);
    ConstList<Command> commands = world.getAllCommands();
    if (commands.size() != 1)
        throw new ErrorAPI("Must specify exactly one command; number of commands found: " + commands.size());
    Command cmd = commands.get(0);
    A4Options opt = new A4Options();
    opt.solver = A4Options.SatSolver.SAT4J;
    // solve
    A4Solution sol = TranslateAlloyToKodkod.execute_command(rep, world.getAllSigs(), cmd, opt);
    // print solution
    System.out.println(sol);
    for (Sig sig : world.getAllReachableSigs()) {
        System.out.println("traversing sig: " + sig);
        SafeList<Field> fields = sig.getFields();
        for (Field field : fields) {
            System.out.println("  traversing field: " + field);
            A4TupleSet ts = (sol.eval(field));
            for (A4Tuple t : ts) {
                System.out.print("    [");
                for (int i = 0; i < t.arity(); i++) System.out.print(t.atom(i) + " ");
                System.out.println("]");
            }
        }
    }
}
Also used : ErrorAPI(edu.mit.csail.sdg.alloy4.ErrorAPI) A4Reporter(edu.mit.csail.sdg.alloy4.A4Reporter) A4TupleSet(edu.mit.csail.sdg.translator.A4TupleSet) Sig(edu.mit.csail.sdg.ast.Sig) Field(edu.mit.csail.sdg.ast.Sig.Field) A4Tuple(edu.mit.csail.sdg.translator.A4Tuple) CompModule(edu.mit.csail.sdg.parser.CompModule) Command(edu.mit.csail.sdg.ast.Command) A4Options(edu.mit.csail.sdg.translator.A4Options) A4Solution(edu.mit.csail.sdg.translator.A4Solution)

Aggregations

A4Options (edu.mit.csail.sdg.translator.A4Options)12 Command (edu.mit.csail.sdg.ast.Command)10 A4Solution (edu.mit.csail.sdg.translator.A4Solution)10 Module (edu.mit.csail.sdg.ast.Module)7 A4Reporter (edu.mit.csail.sdg.alloy4.A4Reporter)4 Expr (edu.mit.csail.sdg.ast.Expr)3 Sig (edu.mit.csail.sdg.ast.Sig)3 CompModule (edu.mit.csail.sdg.parser.CompModule)3 Err (edu.mit.csail.sdg.alloy4.Err)2 ErrorWarning (edu.mit.csail.sdg.alloy4.ErrorWarning)2 XMLNode (edu.mit.csail.sdg.alloy4.XMLNode)2 Decl (edu.mit.csail.sdg.ast.Decl)2 Func (edu.mit.csail.sdg.ast.Func)2 Test (org.junit.Test)2 ErrorAPI (edu.mit.csail.sdg.alloy4.ErrorAPI)1 VizGUI (edu.mit.csail.sdg.alloy4viz.VizGUI)1 SimpleCallback1 (edu.mit.csail.sdg.alloy4whole.SimpleReporter.SimpleCallback1)1 SimpleTask1 (edu.mit.csail.sdg.alloy4whole.SimpleReporter.SimpleTask1)1 ExprHasName (edu.mit.csail.sdg.ast.ExprHasName)1 Field (edu.mit.csail.sdg.ast.Sig.Field)1