Java Code Examples for kodkod.ast.Relation#in()
The following examples show how to use
kodkod.ast.Relation#in() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IncrementalSolverTest.java From kodkod with MIT License | 6 votes |
@Test public void testSimpleIncrementalSequence() { final Bounds b = new Bounds(new Universe("A0", "A1", "A2")); final TupleFactory t = b.universe().factory(); final Relation r0 = Relation.unary("r0"); final Relation r1 = Relation.unary("r1"); final Relation r2 = Relation.unary("r2"); b.bound(r0, t.setOf("A0","A1")); b.bound(r1, t.setOf("A1","A2")); final Formula[] f = { r0.some(), r1.some(), r0.intersection(r1).no(), r2.in(r0.union(r1)) }; checkModel(solver.solve(f[0], b), f[0]); b.relations().clear(); checkModel(solver.solve(f[1], b), f[0], f[1]); checkModel(solver.solve(f[2], b), f[0], f[1], f[2]); b.bound(r2, t.allOf(1)); checkModel(solver.solve(f[3], b), f[0], f[1], f[2], f[3]); }
Example 2
Source File: BugTests.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
public final void testVincent_02162006() { // set ups universe of atoms [1..257] final List<Integer> atoms = new ArrayList<Integer>(); // change this to 256, and the program works for (int i = 0; i < 257; i++) { atoms.add(i + 1); } final Universe universe = new Universe(atoms); final Bounds bounds = new Bounds(universe); final TupleFactory factory = universe.factory(); // oneRel is bounded to the Integer 1 final Relation oneRel = Relation.unary("oneRel"); // rel can contain anything final Relation rel = Relation.unary("rel"); bounds.bound(oneRel, factory.setOf(factory.tuple(atoms.get(0))), factory.setOf(factory.tuple(atoms.get(0)))); bounds.bound(rel, factory.allOf(1)); // constraint: oneRel in rel Formula formula = oneRel.in(rel); // solve final Instance instance = solver.solve(formula, bounds).instance(); assertNotNull(instance); // System.out.println(instance); }
Example 3
Source File: RegressionTests.java From kodkod with MIT License | 5 votes |
@Test public final void testMarceloSimplified_041912() { final Relation d2 = Relation.unary("Domain_2"); final Relation a1 = Relation.unary("Address_1"); final Relation a2 = Relation.unary("Address_2"); final Relation a3 = Relation.unary("Address_3"); final Expression e = Expression.union(a1, a2, a3); final Expression dstBinding = Expression.union(Expression.product(d2, a1, a3), Expression.product(d2, a3, a3)); final Formula f = a3.in(e.product(a1).override(d2.join(dstBinding)).join(e)); final Universe u = new Universe("a1", "a2", "a3", "d2"); final TupleFactory tf = u.factory(); final Bounds b = new Bounds(u); b.boundExactly(a1, tf.setOf("a1")); b.boundExactly(a2, tf.setOf("a2")); b.boundExactly(a3, tf.setOf("a3")); b.bound(d2, tf.setOf("d2")); final Solver solver = new Solver(); solver.options().setSolver(SATFactory.MiniSat); // System.out.println(f); // System.out.println(b); final Solution sol = solver.solve(f, b); // System.out.println(sol); assertNotNull(sol.instance()); }
Example 4
Source File: RegressionTests.java From kodkod with MIT License | 5 votes |
@Test public final void testVincent_02162006() { // set ups universe of atoms [1..257] final List<Integer> atoms = new ArrayList<Integer>(); // change this to 256, and the program works for (int i=0; i<257; i++) { atoms.add(i+1); } final Universe universe = new Universe(atoms); final Bounds bounds = new Bounds(universe); final TupleFactory factory = universe.factory(); // oneRel is bounded to the Integer 1 final Relation oneRel = Relation.unary("oneRel"); // rel can contain anything final Relation rel = Relation.unary("rel"); bounds.bound(oneRel, factory.setOf(factory.tuple(atoms.get(0))), factory.setOf(factory.tuple(atoms.get(0)))); bounds.bound(rel, factory.allOf(1)); // constraint: oneRel in rel Formula formula = oneRel.in(rel); // solve final Instance instance = solver.solve(formula, bounds).instance(); assertNotNull(instance); //System.out.println(instance); }
Example 5
Source File: BugTests.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
public final void testFelix_11122006() { Relation x0 = Relation.nary("Q", 1); Relation x1 = Relation.nary("B", 1); Relation x2 = Relation.nary("A", 1); Relation x3 = Relation.nary("QQ", 3); List<String> atomlist = Arrays.asList("A", "B", "Q"); Universe universe = new Universe(atomlist); TupleFactory factory = universe.factory(); Bounds bounds = new Bounds(universe); TupleSet x0_upper = factory.noneOf(1); x0_upper.add(factory.tuple("Q")); bounds.boundExactly(x0, x0_upper); TupleSet x1_upper = factory.noneOf(1); x1_upper.add(factory.tuple("B")); bounds.boundExactly(x1, x1_upper); TupleSet x2_upper = factory.noneOf(1); x2_upper.add(factory.tuple("A")); bounds.boundExactly(x2, x2_upper); TupleSet x3_upper = factory.noneOf(3); x3_upper.add(factory.tuple("Q").product(factory.tuple("A")).product(factory.tuple("A"))); x3_upper.add(factory.tuple("Q").product(factory.tuple("B")).product(factory.tuple("B"))); bounds.bound(x3, x3_upper); Expression x7 = x2.product(x2); Expression x8 = x0.join(x3); Formula x6 = x7.in(x8); Formula x5 = x6.not(); Expression x18 = x1.product(x1); Expression x17 = x7.union(x18); Expression x16 = x0.product(x17); Formula x15 = x3.in(x16); Formula x4 = x5.and(x15); Solver solver = new Solver(); solver.options().setSolver(SATFactory.DefaultSAT4J); solver.options().setBitwidth(4); solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); // System.out.println(bounds); // System.out.println(x4); Solution sol = solver.solve(x4, bounds); assertEquals(sol.outcome(), Solution.Outcome.SATISFIABLE); // System.out.println(sol.toString()); }
Example 6
Source File: RegressionTests.java From kodkod with MIT License | 4 votes |
@Test public final void testFelix_11122006() { Relation x0 = Relation.nary("Q", 1); Relation x1 = Relation.nary("B", 1); Relation x2 = Relation.nary("A", 1); Relation x3 = Relation.nary("QQ", 3); List<String> atomlist = Arrays.asList("A", "B", "Q"); Universe universe = new Universe(atomlist); TupleFactory factory = universe.factory(); Bounds bounds = new Bounds(universe); TupleSet x0_upper = factory.noneOf(1); x0_upper.add(factory.tuple("Q")); bounds.boundExactly(x0, x0_upper); TupleSet x1_upper = factory.noneOf(1); x1_upper.add(factory.tuple("B")); bounds.boundExactly(x1, x1_upper); TupleSet x2_upper = factory.noneOf(1); x2_upper.add(factory.tuple("A")); bounds.boundExactly(x2, x2_upper); TupleSet x3_upper = factory.noneOf(3); x3_upper.add(factory.tuple("Q").product(factory.tuple("A")).product(factory.tuple("A"))); x3_upper.add(factory.tuple("Q").product(factory.tuple("B")).product(factory.tuple("B"))); bounds.bound(x3, x3_upper); Expression x7=x2.product(x2); Expression x8=x0.join(x3); Formula x6=x7.in(x8); Formula x5=x6.not(); Expression x18=x1.product(x1); Expression x17=x7.union(x18); Expression x16=x0.product(x17); Formula x15=x3.in(x16); Formula x4=x5.and(x15); Solver solver = new Solver(); solver.options().setSolver(SATFactory.DefaultSAT4J); solver.options().setBitwidth(4); solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); // System.out.println(bounds); // System.out.println(x4); Solution sol = solver.solve(x4,bounds); assertEquals(sol.outcome(), Solution.Outcome.SATISFIABLE); // System.out.println(sol.toString()); }