Search in sources :

Example 86 with Bounds

use of kodkod.instance.Bounds in project org.alloytools.alloy by AlloyTools.

the class GEO091 method main.

/**
 * Usage: java examples.tptp.GEO191 [univ size]
 */
public static void main(String[] args) {
    if (args.length < 1)
        usage();
    try {
        final int n = Integer.parseInt(args[0]);
        final Solver solver = new Solver();
        solver.options().setSolver(SATFactory.MiniSat);
        final GEO091 model = new GEO091();
        final Formula f = model.checkTheorem_2_13();
        System.out.println(model.theorem_2_13());
        final Bounds b = model.bounds(n);
        final Solution sol = solver.solve(f, b);
        System.out.println(sol);
    // System.out.println((new
    // Evaluator(sol.instance())).evaluate(model.axioms().and(model.theorem213().not())));
    } catch (NumberFormatException nfe) {
        usage();
    }
}
Also used : Formula(kodkod.ast.Formula) Solver(kodkod.engine.Solver) Bounds(kodkod.instance.Bounds) Solution(kodkod.engine.Solution)

Example 87 with Bounds

use of kodkod.instance.Bounds in project org.alloytools.alloy by AlloyTools.

the class ALG195 method main.

/**
 * Usage: java examples.tptp.ALG195
 */
public static void main(String[] args) {
    try {
        final ALG195 model = new ALG195();
        final Solver solver = new Solver();
        solver.options().setSolver(SATFactory.MiniSat);
        final Formula f = model.checkCO1();
        final Bounds b = model.bounds();
        // System.out.println(model.decls());
        // System.out.println(model.ax2ax7());
        // System.out.println(b);
        final Solution sol = solver.solve(f, b);
        if (sol.instance() == null) {
            System.out.println(sol);
        } else {
            System.out.println(sol.stats());
            model.display(sol.instance());
        }
    } catch (NumberFormatException nfe) {
        usage();
    }
}
Also used : Formula(kodkod.ast.Formula) Solver(kodkod.engine.Solver) Bounds(kodkod.instance.Bounds) Solution(kodkod.engine.Solution)

Example 88 with Bounds

use of kodkod.instance.Bounds in project org.alloytools.alloy by AlloyTools.

the class ALG197 method bounds.

/**
 * Returns the bounds the problem (axioms 1, 4, 9-11, last formula of 14-15, and
 * first formula of 16-22).
 *
 * @return the bounds for the problem
 */
@Override
public final Bounds bounds() {
    final Bounds b = super.bounds();
    final TupleFactory f = b.universe().factory();
    final TupleSet op1h = b.upperBound(op1).clone();
    final TupleSet op2h = b.upperBound(op2).clone();
    // axiom
    final TupleSet op1l = f.setOf(f.tuple("e16", "e16", "e15"));
    // 14,
    // line
    // 6
    // axiom
    final TupleSet op2l = f.setOf(f.tuple("e26", "e26", "e25"));
    // 15,
    // line
    // 6
    op1h.removeAll(f.area(f.tuple("e16", "e16", "e10"), f.tuple("e16", "e16", "e16")));
    op1h.addAll(op1l);
    op2h.removeAll(f.area(f.tuple("e26", "e26", "e20"), f.tuple("e26", "e26", "e26")));
    op2h.addAll(op2l);
    b.bound(op1, op1l, op1h);
    b.bound(op2, op2l, op2h);
    final TupleSet high = f.area(f.tuple("e10", "e20"), f.tuple("e15", "e26"));
    // first line of axioms 16-22
    for (int i = 0; i < 7; i++) {
        Tuple t = f.tuple("e16", "e2" + i);
        high.add(t);
        b.bound(h[i], f.setOf(t), high);
        high.remove(t);
    }
    return b;
}
Also used : TupleSet(kodkod.instance.TupleSet) Bounds(kodkod.instance.Bounds) TupleFactory(kodkod.instance.TupleFactory) Tuple(kodkod.instance.Tuple)

Example 89 with Bounds

use of kodkod.instance.Bounds in project org.alloytools.alloy by AlloyTools.

the class ALG197 method main.

/**
 * Usage: java examples.tptp.ALG197
 */
public static void main(String[] args) {
    try {
        final ALG197 model = new ALG197();
        final Solver solver = new Solver();
        solver.options().setSolver(SATFactory.MiniSat);
        final Formula f = model.checkCO1();
        final Bounds b = model.bounds();
        final Solution sol = solver.solve(f, b);
        if (sol.instance() == null) {
            System.out.println(sol);
        } else {
            System.out.println(sol.stats());
            model.display(sol.instance());
        }
    } catch (NumberFormatException nfe) {
        usage();
    }
}
Also used : Formula(kodkod.ast.Formula) Solver(kodkod.engine.Solver) Bounds(kodkod.instance.Bounds) Solution(kodkod.engine.Solution)

Example 90 with Bounds

use of kodkod.instance.Bounds in project org.alloytools.alloy by AlloyTools.

the class GEO092 method main.

/**
 * Usage: ava examples.tptp.GEO192 [# curves] [# points]
 */
public static void main(String[] args) {
    if (args.length < 2)
        usage();
    try {
        final int n = Integer.parseInt(args[0]);
        final Solver solver = new Solver();
        solver.options().setSolver(SATFactory.MiniSat);
        final GEO092 model = new GEO092();
        final Formula f = model.checkProposition2141();
        System.out.println(model.proposition2141());
        final Bounds b = model.bounds(n);
        final Solution sol = solver.solve(f, b);
        System.out.println(sol);
    // System.out.println((new
    // Evaluator(sol.instance())).evaluate(model.axioms().and(model.theorem213().not())));
    } catch (NumberFormatException nfe) {
        usage();
    }
}
Also used : Formula(kodkod.ast.Formula) Solver(kodkod.engine.Solver) Bounds(kodkod.instance.Bounds) Solution(kodkod.engine.Solution)

Aggregations

Bounds (kodkod.instance.Bounds)140 Formula (kodkod.ast.Formula)83 Universe (kodkod.instance.Universe)79 TupleFactory (kodkod.instance.TupleFactory)76 Solution (kodkod.engine.Solution)75 Solver (kodkod.engine.Solver)67 TupleSet (kodkod.instance.TupleSet)55 Relation (kodkod.ast.Relation)49 ArrayList (java.util.ArrayList)45 Expression (kodkod.ast.Expression)21 Variable (kodkod.ast.Variable)21 IntExpression (kodkod.ast.IntExpression)20 Instance (kodkod.instance.Instance)12 Decls (kodkod.ast.Decls)11 Evaluator (kodkod.engine.Evaluator)8 HigherOrderDeclException (kodkod.engine.fol2sat.HigherOrderDeclException)7 UnboundLeafException (kodkod.engine.fol2sat.UnboundLeafException)7 ConsoleReporter (kodkod.engine.config.ConsoleReporter)6 Tuple (kodkod.instance.Tuple)6 LinkedHashSet (java.util.LinkedHashSet)5