Java Code Examples for kodkod.ast.Relation#some()
The following examples show how to use
kodkod.ast.Relation#some() .
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: EnumerationTest.java From org.alloytools.alloy with Apache License 2.0 | 6 votes |
public final void testTrivial() { final Relation r = Relation.unary("r"); final Universe u = new Universe(Arrays.asList("a", "b", "c")); final TupleFactory f = u.factory(); final Bounds b = new Bounds(u); b.bound(r, f.setOf("a"), f.allOf(1)); final Formula someR = r.some(); Iterator<Solution> sol = solver.solveAll(someR, b); // has a trivial instance, followed by 2 non-trivial instances assertEquals(Solution.Outcome.TRIVIALLY_SATISFIABLE, sol.next().outcome()); assertEquals(Solution.Outcome.SATISFIABLE, sol.next().outcome()); assertEquals(Solution.Outcome.SATISFIABLE, sol.next().outcome()); assertEquals(Solution.Outcome.UNSATISFIABLE, sol.next().outcome()); assertFalse(sol.hasNext()); }
Example 2
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 3
Source File: EnumerationTest.java From kodkod with MIT License | 6 votes |
@Test public final void testTrivial() { final Relation r = Relation.unary("r"); final Universe u = new Universe(Arrays.asList("a","b","c")); final TupleFactory f = u.factory(); final Bounds b = new Bounds(u); b.bound(r, f.setOf("a"), f.allOf(1)); final Formula someR = r.some(); Iterator<Solution> sol = solver.solveAll(someR, b); // has a trivial instance, followed by 2 non-trivial instances assertEquals(Solution.Outcome.TRIVIALLY_SATISFIABLE, sol.next().outcome()); assertEquals(Solution.Outcome.SATISFIABLE, sol.next().outcome()); assertEquals(Solution.Outcome.SATISFIABLE, sol.next().outcome()); assertEquals(Solution.Outcome.UNSATISFIABLE, sol.next().outcome()); assertFalse(sol.hasNext()); }
Example 4
Source File: BugTests.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
public final void testFelix_05152007_3() { Relation x5 = Relation.nary("A", 1); List<String> atomlist = Arrays.asList("A[0]", "A[1]", "A[2]"); Universe universe = new Universe(atomlist); TupleFactory factory = universe.factory(); Bounds bounds = new Bounds(universe); TupleSet x5_upper = factory.noneOf(1); x5_upper.add(factory.tuple("A[0]")); x5_upper.add(factory.tuple("A[1]")); x5_upper.add(factory.tuple("A[2]")); bounds.bound(x5, x5_upper); Formula a = x5.some(); Formula a1 = x5.no(); Formula b = a1.and(Formula.TRUE.and(Formula.TRUE)); Formula c = a.and(b); Solver solver = new Solver(); solver.options().setLogTranslation(1); solver.options().setSolver(SATFactory.DefaultSAT4J); solver.options().setBitwidth(4); solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); Solution sol = solver.solve(c, bounds); Set<Formula> core = Nodes.minRoots(c, sol.proof().highLevelCore().values()); assertEquals(2, core.size()); assertTrue(core.contains(a)); assertTrue(core.contains(a1)); }
Example 5
Source File: BugTests.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
public final void testFelix_05152007_1() { Relation x5 = Relation.nary("A", 1); List<String> atomlist = Arrays.asList("A0", "A1", "A2"); Universe universe = new Universe(atomlist); TupleFactory factory = universe.factory(); Bounds bounds = new Bounds(universe); TupleSet x5_upper = factory.noneOf(1); x5_upper.add(factory.tuple("A2")); x5_upper.add(factory.tuple("A1")); x5_upper.add(factory.tuple("A0")); bounds.bound(x5, x5_upper); Formula x7 = x5.some(); Formula x8 = x5.no(); Formula x6 = x7.and(x8); Solver solver = new Solver(); solver.options().setLogTranslation(1); solver.options().setSolver(SATFactory.MiniSatProver); solver.options().setBitwidth(4); solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); Solution sol = solver.solve(x6, bounds); // System.out.println("Sol="+sol); Set<Formula> core = Nodes.minRoots(x6, sol.proof().highLevelCore().values()); assertEquals(2, core.size()); assertTrue(core.contains(x7)); assertTrue(core.contains(x8)); }
Example 6
Source File: RegressionTests.java From kodkod with MIT License | 5 votes |
@Test public final void testFelix_05152007_3() { Relation x5 = Relation.nary("A", 1); List<String> atomlist = Arrays.asList("A[0]", "A[1]", "A[2]"); Universe universe = new Universe(atomlist); TupleFactory factory = universe.factory(); Bounds bounds = new Bounds(universe); TupleSet x5_upper = factory.noneOf(1); x5_upper.add(factory.tuple("A[0]")); x5_upper.add(factory.tuple("A[1]")); x5_upper.add(factory.tuple("A[2]")); bounds.bound(x5, x5_upper); Formula a=x5.some(); Formula a1 = x5.no(); Formula b=a1.and(Formula.TRUE.and(Formula.TRUE)); Formula c=a.and(b); Solver solver = new Solver(); solver.options().setLogTranslation(1); solver.options().setSolver(SATFactory.DefaultSAT4J); solver.options().setBitwidth(4); solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); Solution sol = solver.solve(c,bounds); Set<Formula> core = Nodes.minRoots(c, sol.proof().highLevelCore().values()); assertEquals(2, core.size()); assertTrue(core.contains(a)); assertTrue(core.contains(a1)); }
Example 7
Source File: BugTests.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
public final void testFelix_03062008_2() { Relation x5 = Relation.unary("Role"); Relation x6 = Relation.unary("Session"); List<String> atomlist = Arrays.asList("Role$0", "Session$0", "Session$1"); Universe universe = new Universe(atomlist); TupleFactory factory = universe.factory(); Bounds bounds = new Bounds(universe); TupleSet x5_upper = factory.noneOf(1); x5_upper.add(factory.tuple("Role$0")); bounds.bound(x5, x5_upper); TupleSet x6_upper = factory.noneOf(1); x6_upper.add(factory.tuple("Session$0")); x6_upper.add(factory.tuple("Session$1")); bounds.bound(x6, x6_upper); Variable x11 = Variable.unary("x_a"); Decls x10 = x11.oneOf(x6); Variable x15 = Variable.unary("x_b"); Decls x14 = x15.oneOf(x5); Variable x17 = Variable.unary("x_c"); Decls x16 = x17.oneOf(x5); Decls x13 = x14.and(x16); Expression x20 = x15.product(x17); Expression x19 = x11.product(x20); Formula x18 = x19.some(); Formula x12 = x18.forSome(x13); Formula x9 = x12.forAll(x10); Formula x24 = x5.some(); Formula x23 = x24.not(); Formula x28 = x5.eq(x5); Formula x29 = x6.eq(x6); Formula x25 = x28.and(x29); Formula x22 = x23.and(x25); Formula x8 = x9.and(x22).and(x5.no()).and(x6.no()); Solver solver = new Solver(); solver.options().setSolver(SATFactory.DefaultSAT4J); solver.options().setBitwidth(2); // solver.options().setFlatten(false); solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); solver.options().setSymmetryBreaking(20); solver.options().setSkolemDepth(2); System.out.flush(); Solution sol = solver.solve(x8, bounds); Instance inst = sol.instance(); assertNotNull(inst); for (Relation rel : inst.relations()) { if (rel != x5 && rel != x6) { final TupleSet range = inst.tuples(x6).product(inst.tuples(x5)); assertTrue(range.containsAll(inst.tuples(rel))); } } }
Example 8
Source File: RegressionTests.java From kodkod with MIT License | 4 votes |
@Test public final void testFelix_03062008_2() { Relation x5 = Relation.unary("Role"); Relation x6 = Relation.unary("Session"); List<String> atomlist = Arrays.asList("Role$0", "Session$0", "Session$1"); Universe universe = new Universe(atomlist); TupleFactory factory = universe.factory(); Bounds bounds = new Bounds(universe); TupleSet x5_upper = factory.noneOf(1); x5_upper.add(factory.tuple("Role$0")); bounds.bound(x5, x5_upper); TupleSet x6_upper = factory.noneOf(1); x6_upper.add(factory.tuple("Session$0")); x6_upper.add(factory.tuple("Session$1")); bounds.bound(x6, x6_upper); Variable x11=Variable.unary("x_a"); Decls x10=x11.oneOf(x6); Variable x15=Variable.unary("x_b"); Decls x14=x15.oneOf(x5); Variable x17=Variable.unary("x_c"); Decls x16=x17.oneOf(x5); Decls x13=x14.and(x16); Expression x20=x15.product(x17); Expression x19=x11.product(x20); Formula x18=x19.some(); Formula x12=x18.forSome(x13); Formula x9=x12.forAll(x10); Formula x24=x5.some(); Formula x23=x24.not(); Formula x28=x5.eq(x5); Formula x29=x6.eq(x6); Formula x25=x28.and(x29); Formula x22=x23.and(x25); Formula x8=x9.and(x22).and(x5.no()).and(x6.no()); Solver solver = new Solver(); solver.options().setSolver(SATFactory.DefaultSAT4J); solver.options().setBitwidth(2); solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); solver.options().setSymmetryBreaking(20); solver.options().setSkolemDepth(2); System.out.flush(); Solution sol = solver.solve(x8, bounds); Instance inst = sol.instance(); assertNotNull(inst); for(Relation rel : inst.relations()) { if (rel!=x5 && rel!=x6) { final TupleSet range = inst.tuples(x6).product(inst.tuples(x5)); assertTrue(range.containsAll(inst.tuples(rel))); } } }
Example 9
Source File: RegressionTests.java From kodkod with MIT License | 3 votes |
@Test public final void testFelix_05152007_1() { Relation x5 = Relation.nary("A", 1); List<String> atomlist = Arrays.asList("A0", "A1", "A2"); Universe universe = new Universe(atomlist); TupleFactory factory = universe.factory(); Bounds bounds = new Bounds(universe); TupleSet x5_upper = factory.noneOf(1); x5_upper.add(factory.tuple("A2")); x5_upper.add(factory.tuple("A1")); x5_upper.add(factory.tuple("A0")); bounds.bound(x5, x5_upper); Formula x7=x5.some(); Formula x8=x5.no(); Formula x6=x7.and(x8); Solver solver = new Solver(); solver.options().setLogTranslation(1); solver.options().setSolver(SATFactory.MiniSatProver); solver.options().setBitwidth(4); solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); Solution sol = solver.solve(x6,bounds); // System.out.println("Sol="+sol); Set<Formula> core = Nodes.minRoots(x6, sol.proof().highLevelCore().values()); assertEquals(2, core.size()); assertTrue(core.contains(x7)); assertTrue(core.contains(x8)); }