Java Code Examples for kodkod.ast.Relation#product()
The following examples show how to use
kodkod.ast.Relation#product() .
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: BugTests.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
public final void testFelix_06192008() { Relation x5 = Relation.unary("R"); List<String> atomlist = Arrays.asList("X"); 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("X")); bounds.bound(x5, x5_upper); Variable x10 = Variable.unary("a"); Expression x11 = x5.difference(x5); Decls x9 = x10.oneOf(x11); Variable x14 = Variable.nary("b", 2); Expression x15 = x5.product(x5); Decls x13 = x14.setOf(x15); Expression x19 = x5.product(x5); Formula x17 = x14.in(x19); Expression x22 = x10.product(x10); Formula x21 = x22.eq(x14); Formula x16 = x17.and(x21); Formula x12 = x16.forSome(x13); Formula x7 = x12.forAll(x9); // System.out.println(x7); Solver solver = new Solver(); solver.options().setSolver(SATFactory.DefaultSAT4J); solver.options().setBitwidth(4); // solver.options().setFlatten(false); solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); solver.options().setSymmetryBreaking(20); // System.out.println("Depth=0..."); System.out.flush(); solver.options().setSkolemDepth(0); assertEquals(Solution.Outcome.TRIVIALLY_SATISFIABLE, solver.solve(x7, bounds).outcome()); // System.out.println("Depth=1..."); System.out.flush(); solver.options().setSkolemDepth(1); final Solution sol = solver.solve(x7, bounds); assertEquals(Solution.Outcome.SATISFIABLE, sol.outcome()); assertEquals(2, sol.instance().relations().size()); for (Relation r : sol.instance().relations()) { assertTrue(sol.instance().tuples(r).isEmpty()); } }
Example 2
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 3
Source File: RegressionTests.java From kodkod with MIT License | 4 votes |
@Test public final void testFelix_06192008() { Relation x5 = Relation.unary("R"); List<String> atomlist = Arrays.asList("X"); 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("X")); bounds.bound(x5, x5_upper); Variable x10=Variable.unary("a"); Expression x11=x5.difference(x5); Decls x9=x10.oneOf(x11); Variable x14=Variable.nary("b",2); Expression x15=x5.product(x5); Decls x13=x14.setOf(x15); Expression x19=x5.product(x5); Formula x17=x14.in(x19); Expression x22=x10.product(x10); Formula x21=x22.eq(x14); Formula x16=x17.and(x21); Formula x12=x16.forSome(x13); Formula x7= x12.forAll(x9); // System.out.println(x7); Solver solver = new Solver(); solver.options().setSolver(SATFactory.DefaultSAT4J); solver.options().setBitwidth(4); solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); solver.options().setSymmetryBreaking(20); // System.out.println("Depth=0..."); System.out.flush(); solver.options().setSkolemDepth(0); assertEquals(Solution.Outcome.TRIVIALLY_SATISFIABLE, solver.solve(x7, bounds).outcome()); // System.out.println("Depth=1..."); System.out.flush(); solver.options().setSkolemDepth(1); final Solution sol = solver.solve(x7, bounds); assertEquals(Solution.Outcome.SATISFIABLE, sol.outcome()); assertEquals(2, sol.instance().relations().size()); for(Relation r : sol.instance().relations()) { assertTrue(sol.instance().tuples(r).isEmpty()); } }
Example 4
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()); }