Search in sources :

Example 31 with Decl

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

the class BugTests method testFelix_11262007.

public final void testFelix_11262007() {
    Relation x6 = Relation.unary("R2");
    List<String> atomlist = Arrays.asList("X", "Y", "Z");
    Universe universe = new Universe(atomlist);
    TupleFactory factory = universe.factory();
    Bounds bounds = new Bounds(universe);
    bounds.bound(x6, factory.allOf(1));
    final Variable x32 = Variable.unary("a");
    final Decls x31 = x32.oneOf(x6);
    final Variable x36 = Variable.unary("b");
    final Decls x35 = x36.oneOf(x32.join(x6.product(x6)));
    final Formula x29 = x36.some().forSome(x35).forSome(x31);
    Solver solver = new Solver();
    solver.options().setSolver(SATFactory.DefaultSAT4J);
    solver.options().setBitwidth(4);
    solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT);
    solver.options().setSymmetryBreaking(20);
    solver.options().setSkolemDepth(0);
    final Set<Decl> decls = new LinkedHashSet<Decl>();
    solver.options().setReporter(new AbstractReporter() {

        @Override
        public void skolemizing(Decl decl, Relation skolem, List<Decl> predecl) {
            decls.add(decl);
        }
    });
    Solution sol = solver.solve(x29, bounds);
    assertEquals(2, decls.size());
    assertTrue(decls.contains(x31));
    assertTrue(decls.contains(x35));
    assertNotNull(sol.instance());
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Solver(kodkod.engine.Solver) Variable(kodkod.ast.Variable) Decls(kodkod.ast.Decls) Bounds(kodkod.instance.Bounds) TupleFactory(kodkod.instance.TupleFactory) Universe(kodkod.instance.Universe) Decl(kodkod.ast.Decl) Formula(kodkod.ast.Formula) Relation(kodkod.ast.Relation) AbstractReporter(kodkod.engine.config.AbstractReporter) Solution(kodkod.engine.Solution)

Example 32 with Decl

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

the class BugTests method doTestAleks_03102013.

private final void doTestAleks_03102013() {
    Relation r = Relation.unary("R");
    Relation s = Relation.binary("f");
    Variable v = Variable.unary("e");
    Decl decl = v.oneOf(r);
    Expression shared = v.join(s);
    Formula expr = (shared.difference(shared)).one().forAll(decl);
    Formula fin = expr.and(expr.not());
    List<Object> atomlist = new LinkedList<Object>();
    atomlist.add("R$0");
    atomlist.add("R$1");
    atomlist.add("R$2");
    Universe universe = new Universe(atomlist);
    TupleFactory factory = universe.factory();
    Bounds bounds = new Bounds(universe);
    bounds.bound(r, factory.allOf(1));
    bounds.bound(s, factory.allOf(2));
    Solver solver = new Solver();
    solver.options().setSolver(SATFactory.DefaultSAT4J);
    solver.options().setBitwidth(4);
    solver.options().setSkolemDepth(0);
    solver.options().setLogTranslation(0);
    Solution sol = solver.solve(fin, bounds);
    assertNull(sol.instance());
}
Also used : Solver(kodkod.engine.Solver) Variable(kodkod.ast.Variable) Bounds(kodkod.instance.Bounds) TupleFactory(kodkod.instance.TupleFactory) Universe(kodkod.instance.Universe) Decl(kodkod.ast.Decl) LinkedList(java.util.LinkedList) Formula(kodkod.ast.Formula) Relation(kodkod.ast.Relation) IntExpression(kodkod.ast.IntExpression) Expression(kodkod.ast.Expression) Solution(kodkod.engine.Solution)

Aggregations

Decl (kodkod.ast.Decl)32 Formula (kodkod.ast.Formula)12 Variable (kodkod.ast.Variable)12 QuantifiedFormula (kodkod.ast.QuantifiedFormula)9 Decls (kodkod.ast.Decls)7 Expression (kodkod.ast.Expression)6 IntExpression (kodkod.ast.IntExpression)6 Relation (kodkod.ast.Relation)6 SumExpression (kodkod.ast.SumExpression)5 Solution (kodkod.engine.Solution)5 Test (org.junit.Test)5 BinaryFormula (kodkod.ast.BinaryFormula)4 BooleanFactory (kodkod.engine.bool.BooleanFactory)4 BooleanMatrix (kodkod.engine.bool.BooleanMatrix)4 BooleanValue (kodkod.engine.bool.BooleanValue)4 Instance (kodkod.instance.Instance)4 HashSet (java.util.HashSet)3 ComparisonFormula (kodkod.ast.ComparisonFormula)3 IntComparisonFormula (kodkod.ast.IntComparisonFormula)3 MultiplicityFormula (kodkod.ast.MultiplicityFormula)3