Java Code Examples for kodkod.ast.Variable#oneOf()
The following examples show how to use
kodkod.ast.Variable#oneOf() .
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: SkolemizationTest.java From org.alloytools.alloy with Apache License 2.0 | 6 votes |
public final void testDeepSkolems() { solver.options().setSkolemDepth(3); testDeepSkolems(Multiplicity.ONE); testDeepSkolems(Multiplicity.LONE); testDeepSkolems(Multiplicity.SOME); testDeepSkolems(Multiplicity.SET); final Variable va = Variable.unary("va"); final Variable vb = Variable.unary("vb"); Decl da1 = va.oneOf(r1a); Decl db = vb.oneOf(r1b); final Formula f0 = va.in(vb.join(r2b)); final Formula f1 = f0.forAll(db).not().forAll(da1); final Formula f2 = f0.forSome(db).forSome(da1); Instance inst = solve(f1.and(f2)); assertEquals(bounds.relations().size() + 3, inst.relations().size()); }
Example 2
Source File: EvaluatorTest.java From kodkod with MIT License | 6 votes |
@Test public final void testComprehension() { final Variable[] vars = new Variable[3]; final Decl[] decls = new Decl[3]; for (int i = 0; i < 3; i++) { Variable v = Variable.unary("v"+i); Decl d = v.oneOf(person); vars[i] = v; decls[i] = d; } // {v0: Person | no v0.shaken} = univ - shaken.Person assertEquals(eval(vars[0].join(shaken).no().comprehension(decls[0])), eval(univ.difference(shaken.join(person)))); // {v0, v1: Person | v1 in v0.shaken} = shaken assertEquals(eval(vars[1].in(vars[0].join(shaken)).comprehension(decls[0].and(decls[1]))), value(shaken)); // {v0, v1, v2: Person | no v1.shaken} = Person->(univ - shaken.Person)->Person assertEquals(eval(vars[1].join(shaken).no().comprehension(decls[0].and(decls[1]).and(decls[2]))), eval(person.product(univ.difference(shaken.join(person))).product(person))); }
Example 3
Source File: SkolemizationTest.java From kodkod with MIT License | 6 votes |
@Test public final void testDeepSkolems() { solver.options().setSkolemDepth(3); testDeepSkolems(Multiplicity.ONE); testDeepSkolems(Multiplicity.LONE); testDeepSkolems(Multiplicity.SOME); testDeepSkolems(Multiplicity.SET); final Variable va = Variable.unary("va"); final Variable vb = Variable.unary("vb"); Decl da1 = va.oneOf(r1a); Decl db = vb.oneOf(r1b); final Formula f0 = va.in(vb.join(r2b)); final Formula f1 = f0.forAll(db).not().forAll(da1); final Formula f2 = f0.forSome(db).forSome(da1); Instance inst = solve(f1.and(f2)); assertEquals(bounds.relations().size()+3, inst.relations().size()); }
Example 4
Source File: EvaluatorTest.java From org.alloytools.alloy with Apache License 2.0 | 6 votes |
public final void testComprehension() { final Variable[] vars = new Variable[3]; final Decl[] decls = new Decl[3]; for (int i = 0; i < 3; i++) { Variable v = Variable.unary("v" + i); Decl d = v.oneOf(person); vars[i] = v; decls[i] = d; } // {v0: Person | no v0.shaken} = univ - shaken.Person assertEquals(eval(vars[0].join(shaken).no().comprehension(decls[0])), eval(univ.difference(shaken.join(person)))); // {v0, v1: Person | v1 in v0.shaken} = shaken assertEquals(eval(vars[1].in(vars[0].join(shaken)).comprehension(decls[0].and(decls[1]))), value(shaken)); // {v0, v1, v2: Person | no v1.shaken} = Person->(univ - // shaken.Person)->Person assertEquals(eval(vars[1].join(shaken).no().comprehension(decls[0].and(decls[1]).and(decls[2]))), eval(person.product(univ.difference(shaken.join(person))).product(person))); }
Example 5
Source File: BugTests.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
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()); }
Example 6
Source File: BoundsComputer.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** * Helper method that returns the constraint that the sig has exactly "n" * elements, or at most "n" elements */ private Formula size(Sig sig, int n, boolean exact) { Expression a = sol.a2k(sig); if (n <= 0) return a.no(); if (n == 1) return exact ? a.one() : a.lone(); Formula f = exact ? Formula.TRUE : null; Decls d = null; Expression sum = null; while (n > 0) { n--; Variable v = Variable.unary("v" + Integer.toString(TranslateAlloyToKodkod.cnt++)); kodkod.ast.Decl dd = v.oneOf(a); if (d == null) d = dd; else d = dd.and(d); if (sum == null) sum = v; else { if (f != null) f = v.intersection(sum).no().and(f); sum = v.union(sum); } } if (f != null) return sum.eq(a).and(f).forSome(d); else return a.no().or(sum.eq(a).forSome(d)); }
Example 7
Source File: RegressionTests.java From kodkod with MIT License | 5 votes |
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()); // fin = (all e: R | one ((e . f) - (e . f))) && // !(all e: R | one ((e . f) - (e . f))) 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()); }
Example 8
Source File: SkolemizationTest.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
private final void testDeepSkolems(Multiplicity mult) { final Variable va = Variable.unary("va"); final Variable vb = Variable.unary("vb"); final Variable vc = Variable.unary("vc"); final Variable vd = Variable.unary("vd"); final Set<String> skolems = new HashSet<String>(4); Decl da1 = va.oneOf(r1a); Decl db = vb.declare(mult, r1b); Decl dc = vc.declare(mult, r1a); Decl dc1 = vc.oneOf(r1a); Decl dd = vd.declare(mult, r1b); Decl dd1 = vd.oneOf(r1b); skolems.add("$" + vb.name()); Instance inst = solve(va.in(vb.join(r2b)).forSome(db).forAll(da1)); assertSkolems(bounds, inst, skolems); skolems.add("$" + vc.name()); inst = solve(va.in(vb.join(r2b).union(vd.join(r2b)).union(vc)).forSome(db).forAll(da1).forSome(dc).forAll(dd1)); assertSkolems(bounds, inst, skolems); inst = solve(va.in(vb.join(r2b).union(vd.join(r2b)).union(vc)).forSome(db).forSome(dc).forAll(da1.and(dd1))); assertSkolems(bounds, inst, skolems); skolems.add("$" + vd.name()); inst = solve(va.in(vb.join(r2b).union(vd.join(r2b)).union(vc)).forSome(db).forAll(da1).forSome(dc).not().forAll(dd).not()); assertSkolems(bounds, inst, skolems); inst = solve(va.in(vb.join(r2b).union(vd.join(r2b)).union(vc)).forAll(dc).forAll(db).forSome(da1).not().forAll(dd1)); skolems.remove("$" + vd.name()); assertSkolems(bounds, inst, skolems); inst = solve(va.in(vb.join(r2b).union(vd.join(r2b)).union(vc)).forSome(db).forAll(dc1).forAll(da1).forAll(dd1)); skolems.remove("$" + vc.name()); assertSkolems(bounds, inst, skolems); }
Example 9
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 10
Source File: BugTests.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
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()); }
Example 11
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 12
Source File: HamiltonianCycle2.java From kodkod with MIT License | 4 votes |
/** * Returns a log encoded instance of HamiltonianCycle2. * @return a log encoded instance of HamiltonianCycle2. */ public static HamiltonianCycle2 logEncoding(String file, Graph.Format format ) { final Graph<?> graph = format.parse(file); final Relation edges = Relation.binary("edges"); final Relation enc = Relation.binary("enc"); final Relation vertex = Relation.unary("vertex"); final Relation[] pts = new Relation[graph.nodes().size()]; for(int i = 0; i < pts.length; i++) { pts[i] = Relation.unary("p"+i); } final int bits = 33 - Integer.numberOfLeadingZeros(pts.length-1); final List<Object> atoms = new ArrayList<Object>(pts.length + bits); atoms.addAll(graph.nodes()); for(int i = 0; i < bits; i++) { atoms.add(new Bit(i)); } final Bounds bounds = new Bounds(new Universe(atoms)); final TupleFactory f = bounds.universe().factory(); final TupleSet edgeBound = f.noneOf(2); for(Object from : graph.nodes()) { for (Object to : graph.edges(from)) edgeBound.add(f.tuple(from, to)); } bounds.boundExactly(edges, edgeBound); bounds.boundExactly(pts[0], f.setOf(atoms.get(pts.length))); for(int i = 1; i < pts.length; i++) { bounds.bound(pts[i], f.range(f.tuple(atoms.get(pts.length)), f.tuple(atoms.get(atoms.size()-1)))); } bounds.boundExactly(vertex, f.range(f.tuple(atoms.get(0)), f.tuple(atoms.get(pts.length-1)))); final TupleSet encBound = f.noneOf(2); for(int i = 1; i <= pts.length; i++) { final Object iatom = atoms.get(i-1); for(int j = 0; j < bits; j++) { if ((i & (1<<j)) != 0) { encBound.add(f.tuple(iatom, atoms.get(pts.length+j))); } } } bounds.boundExactly(enc, encBound); final Expression[] exprs = new Expression[pts.length]; final Variable v = Variable.unary("v"); final Decls d = v.oneOf(vertex); for(int i = 0; i < exprs.length; i++) { exprs[i] = pts[i].eq(v.join(enc)).comprehension(d); } return new HamiltonianCycle2(bounds, exprs, Multiplicity.SOME, vertex, edges); }
Example 13
Source File: RegressionTests.java From kodkod with MIT License | 4 votes |
@Test public final void testBGP_03172011() { Relation x5 = Relation.unary("s012"); Relation x8 = Relation.unary("zero"); Relation x9 = Relation.unary("one"); Relation x12 = Relation.nary("next", 2); Universe universe = new Universe(Arrays.asList( "0", "1", "2", "3")); TupleFactory factory = universe.factory(); Bounds bounds = new Bounds(universe); bounds.boundExactly(x5, factory.setOf("0","1","2")); bounds.boundExactly(x8, factory.setOf("0")); bounds.bound(x9, factory.setOf("1"), factory.setOf("1","2")); TupleSet x12_upper = factory.noneOf(2); x12_upper.add(factory.tuple("1","2")); x12_upper.add(factory.tuple("2","3")); bounds.boundExactly(x12, x12_upper); Variable x714 = Variable.unary("x714"); Decls x713 = x714.oneOf(x8.union(x9)); Variable x720 = Variable.unary("x720"); Expression x723 = x8.union(x9); Expression x724 = x9.join(x12); Expression x722 = x723.union(x724); Expression x721 = x722.difference(x714); Decls x719 = x720.oneOf(x721); Variable x727 = Variable.unary("x727"); Expression x732 = x714.union(x720); Expression x728 = x5.difference(x732); Decls x726 = x727.oneOf(x728); Variable x735 = Variable.unary("x735"); Decls x734 = x735.oneOf(x8); Variable x893 = Variable.unary("x893"); Decls x892 = x893.oneOf(x727); Formula x894 = x720.no(); Formula x891 = x894.forAll(x892); Formula x712 = x891.forSome(x713.and(x719).and(x726).and(x734)); Formula x267 = Formula.FALSE.or(x712); Solver solver = new Solver(); solver.options().setSolver(SATFactory.MiniSat); solver.options().setBitwidth(4); solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); solver.options().setSymmetryBreaking(20); solver.options().setSkolemDepth(0); final Solution sol = solver.solve(x267, bounds); assertEquals(sol.outcome(), Solution.Outcome.TRIVIALLY_UNSATISFIABLE); }
Example 14
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 15
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 16
Source File: RegressionTests.java From kodkod with MIT License | 4 votes |
@Test 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()); }
Example 17
Source File: SkolemizationTest.java From kodkod with MIT License | 4 votes |
private final void testDeepSkolems(Multiplicity mult) { final Variable va = Variable.unary("va"); final Variable vb = Variable.unary("vb"); final Variable vc = Variable.unary("vc"); final Variable vd = Variable.unary("vd"); final Set<String> skolems = new HashSet<String>(4); Decl da1 = va.oneOf(r1a); Decl db = vb.declare(mult, r1b); Decl dc = vc.declare(mult, r1a); Decl dc1 = vc.oneOf(r1a); Decl dd = vd.declare(mult, r1b); Decl dd1 = vd.oneOf(r1b); skolems.add("$"+vb.name()); Instance inst = solve(va.in(vb.join(r2b)).forSome(db).forAll(da1)); assertSkolems(bounds, inst, skolems); skolems.add("$"+vc.name()); inst = solve(va.in(vb.join(r2b).union(vd.join(r2b)).union(vc)). forSome(db).forAll(da1).forSome(dc).forAll(dd1)); assertSkolems(bounds, inst, skolems); inst = solve(va.in(vb.join(r2b).union(vd.join(r2b)).union(vc)). forSome(db).forSome(dc).forAll(da1.and(dd1))); assertSkolems(bounds, inst, skolems); skolems.add("$"+vd.name()); inst = solve(va.in(vb.join(r2b).union(vd.join(r2b)).union(vc)). forSome(db).forAll(da1).forSome(dc).not().forAll(dd).not()); assertSkolems(bounds, inst, skolems); inst = solve(va.in(vb.join(r2b).union(vd.join(r2b)).union(vc)). forAll(dc).forAll(db).forSome(da1).not().forAll(dd1)); skolems.remove("$"+vd.name()); assertSkolems(bounds, inst, skolems); inst = solve(va.in(vb.join(r2b).union(vd.join(r2b)).union(vc)). forSome(db).forAll(dc1).forAll(da1).forAll(dd1)); skolems.remove("$"+vc.name()); assertSkolems(bounds, inst, skolems); }
Example 18
Source File: BugTests.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
public final void testBGP_03172011() { Relation x5 = Relation.unary("s012"); Relation x8 = Relation.unary("zero"); Relation x9 = Relation.unary("one"); Relation x12 = Relation.nary("next", 2); Universe universe = new Universe(Arrays.asList("0", "1", "2", "3")); TupleFactory factory = universe.factory(); Bounds bounds = new Bounds(universe); bounds.boundExactly(x5, factory.setOf("0", "1", "2")); bounds.boundExactly(x8, factory.setOf("0")); bounds.bound(x9, factory.setOf("1"), factory.setOf("1", "2")); TupleSet x12_upper = factory.noneOf(2); x12_upper.add(factory.tuple("1", "2")); x12_upper.add(factory.tuple("2", "3")); bounds.boundExactly(x12, x12_upper); Variable x714 = Variable.unary("x714"); Decls x713 = x714.oneOf(x8.union(x9)); Variable x720 = Variable.unary("x720"); Expression x723 = x8.union(x9); Expression x724 = x9.join(x12); Expression x722 = x723.union(x724); Expression x721 = x722.difference(x714); Decls x719 = x720.oneOf(x721); Variable x727 = Variable.unary("x727"); Expression x732 = x714.union(x720); Expression x728 = x5.difference(x732); Decls x726 = x727.oneOf(x728); Variable x735 = Variable.unary("x735"); Decls x734 = x735.oneOf(x8); Variable x893 = Variable.unary("x893"); Decls x892 = x893.oneOf(x727); Formula x894 = x720.no(); Formula x891 = x894.forAll(x892); Formula x712 = x891.forSome(x713.and(x719).and(x726).and(x734)); Formula x267 = Formula.FALSE.or(x712); Solver solver = new Solver(); solver.options().setSolver(SATFactory.MiniSat); solver.options().setBitwidth(4); // solver.options().setFlatten(false); solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); solver.options().setSymmetryBreaking(20); solver.options().setSkolemDepth(0); final Solution sol = solver.solve(x267, bounds); assertEquals(sol.outcome(), Solution.Outcome.TRIVIALLY_UNSATISFIABLE); }