Search in sources :

Example 21 with Formula

use of kodkod.ast.Formula in project org.alloytools.alloy by AlloyTools.

the class RingElection method main.

/**
 * Usage: java examples.RingElection [# processes] [# times]
 */
public static void main(String[] args) {
    if (args.length < 2)
        usage();
    try {
        final RingElection model = new RingElection();
        final Solver solver = new Solver();
        solver.options().setSolver(SATFactory.MiniSat);
        final int p = Integer.parseInt(args[0]);
        final int t = Integer.parseInt(args[1]);
        final Formula checkAtMostOneElected = model.checkAtMostOneElected();
        final Bounds boundspt = model.bounds(p, t);
        System.out.println("*****check AtMostOneElected for " + p + " Process, " + t + " Time*****");
        Solution sol1 = solver.solve(checkAtMostOneElected, boundspt);
        System.out.println(sol1);
    // // run looplessPath for 13 Time, 3 Process
    // final Formula runLooplessPath =
    // model.declsAndFacts();//.and(model.looplessPath());
    // final Bounds bounds313 = model.bounds(p, t);
    // System.out.println("*****run looplessPath for 13 Time, 3
    // Process*****");
    // System.out.println(runLooplessPath);
    // System.out.println(bounds313);
    // Solution sol2 = solver.solve(runLooplessPath, bounds313);
    // System.out.println(sol2);
    } catch (NumberFormatException nfe) {
        usage();
    }
}
Also used : Formula(kodkod.ast.Formula) Solver(kodkod.engine.Solver) Bounds(kodkod.instance.Bounds) Solution(kodkod.engine.Solution)

Example 22 with Formula

use of kodkod.ast.Formula in project org.alloytools.alloy by AlloyTools.

the class RingElection method looplessPath.

/**
 * Returns the looplessPath predicate
 *
 * @return
 *
 *         <pre>
 * pred looplessPath () {no disj t, t': Time | toSend.t = toSend.t'}
 *         </pre>
 */
public Formula looplessPath() {
    final Variable t1 = Variable.unary("t");
    final Variable t2 = Variable.unary("t'");
    // all t, t': Time | some t&t' || !(toSend.t = toSend.t')
    final Formula f1 = t1.intersection(t2).some().or(toSend.join(t1).eq(toSend.join(t2)).not());
    return f1.forAll(t1.oneOf(Time).and(t2.oneOf(Time)));
}
Also used : Formula(kodkod.ast.Formula) Variable(kodkod.ast.Variable)

Example 23 with Formula

use of kodkod.ast.Formula in project org.alloytools.alloy by AlloyTools.

the class ToyFilesystem method main.

/**
 * Usage: java examples.alloy.ToyFilesystem
 */
public static void main(String[] args) {
    final ToyFilesystem toy = new ToyFilesystem();
    final Formula f = toy.constraints();
    System.out.println(PrettyPrinter.print(f, 2));
    final Bounds b = toy.bounds();
    final Solver solver = new Solver();
    solver.options().setSolver(SATFactory.MiniSat);
    final Solution s = solver.solve(f, b);
    System.out.println(s);
}
Also used : Formula(kodkod.ast.Formula) Solver(kodkod.engine.Solver) Bounds(kodkod.instance.Bounds) Solution(kodkod.engine.Solution)

Example 24 with Formula

use of kodkod.ast.Formula in project org.alloytools.alloy by AlloyTools.

the class Trees method statement5.

/**
 * Returns statement 5.
 *
 * @return
 *
 *         <pre>
 * pred Statement5() {
 * Acyclic() and
 * all u,v: V | (u->v) not in E implies Cyclic(E + (u->v) + (v->u))
 * }
 *         </pre>
 */
public final Formula statement5() {
    final Variable u = Variable.unary("u");
    final Variable v = Variable.unary("v");
    final Formula f0 = u.product(v).in(E).not().implies(cyclic(E.union(u.product(v).union(v.product(u)))));
    final Formula f1 = f0.forAll(u.oneOf(V).and(v.oneOf(V)));
    return acyclic().and(f1);
}
Also used : Formula(kodkod.ast.Formula) Variable(kodkod.ast.Variable)

Example 25 with Formula

use of kodkod.ast.Formula in project org.alloytools.alloy by AlloyTools.

the class Trees method declsAndFacts.

/**
 * Returns the declarations and facts of the model.
 *
 * @return
 *
 *         <pre>
 * sig V { E: set V }
 * fact UndirectedGraph { E = ~E }
 * fact NonEmpty { some V }
 *         </pre>
 */
public final Formula declsAndFacts() {
    final Formula f0 = E.in(V.product(V));
    final Formula f1 = E.eq(E.transpose());
    final Formula f2 = V.some();
    return f0.and(f1).and(f2);
}
Also used : Formula(kodkod.ast.Formula)

Aggregations

Formula (kodkod.ast.Formula)346 Variable (kodkod.ast.Variable)151 Solution (kodkod.engine.Solution)101 Expression (kodkod.ast.Expression)95 Bounds (kodkod.instance.Bounds)83 QuantifiedFormula (kodkod.ast.QuantifiedFormula)72 Solver (kodkod.engine.Solver)67 BinaryFormula (kodkod.ast.BinaryFormula)50 NaryFormula (kodkod.ast.NaryFormula)49 Relation (kodkod.ast.Relation)45 NotFormula (kodkod.ast.NotFormula)43 ComparisonFormula (kodkod.ast.ComparisonFormula)40 IntExpression (kodkod.ast.IntExpression)40 IntComparisonFormula (kodkod.ast.IntComparisonFormula)39 MultiplicityFormula (kodkod.ast.MultiplicityFormula)39 Universe (kodkod.instance.Universe)37 ArrayList (java.util.ArrayList)35 TupleFactory (kodkod.instance.TupleFactory)35 ConstantFormula (kodkod.ast.ConstantFormula)29 TupleSet (kodkod.instance.TupleSet)29