kodkod.ast.operator.Multiplicity Java Examples
The following examples show how to use
kodkod.ast.operator.Multiplicity.
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 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 #2
Source File: FOL2BoolTranslator.java From kodkod with MIT License | 6 votes |
/** * Calls lookup(multFormula) and returns the cached value, if any. * If a translation has not been cached, translates the formula, * calls cache(...) on it and returns it. * @return let t = lookup(multFormula) | some t => t, * let op = (multFormula.mult).(NO->none + SOME->some + ONE->one + LONE->lone) | * cache(multFormula, op(multFormula.expression.accept(this))) */ public final BooleanValue visit(MultiplicityFormula multFormula) { BooleanValue ret = lookup(multFormula); if (ret!=null) return ret; final BooleanMatrix child = multFormula.expression().accept(this); final Multiplicity mult = multFormula.multiplicity(); switch(mult) { case NO : ret = child.none(); break; case SOME : ret = child.some(); break; case ONE : ret = child.one(); break; case LONE : ret = child.lone(); break; default : throw new IllegalArgumentException("Unknown multiplicity: " + mult); } return cache(multFormula, ret); }
Example #3
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 #4
Source File: Comprehension.java From kodkod with MIT License | 5 votes |
/** * Constructs a comprehension expression with the specified decls * and formula * * @ensures this.decls' = decls && this.formula' = formula * @throws NullPointerException decls = null || formula = null */ Comprehension(Decls declarations, Formula formula) { if (formula == null) throw new NullPointerException("null formula"); for(Decl decl : declarations) { if (decl.variable().arity()>1 || decl.multiplicity()!=Multiplicity.ONE) throw new IllegalArgumentException("Cannot have a higher order declaration in a comprehension: "+decl); } this.decls = declarations; this.formula = formula; }
Example #5
Source File: Decl.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** * Constructs a new declaration from the specified variable and expression, with * the specified order. * * @ensures this.variable' = variable && this.expression' = expression && * this.multiplicity' = mult * @throws NullPointerException variable = null || expression = null || mult = * null * @throws IllegalArgumentException variable.arity != expression.arity */ Decl(Variable variable, Multiplicity mult, Expression expression) { if (mult == Multiplicity.NO) throw new IllegalArgumentException("NO is not a valid multiplicity in a declaration."); if (variable.arity() != expression.arity()) throw new IllegalArgumentException("Unmatched arities in a declaration: " + variable + " and " + expression); if (mult != Multiplicity.SET && expression.arity() > 1) throw new IllegalArgumentException("Cannot use multiplicity " + mult + " with an expression of arity > 1."); this.variable = variable; this.mult = mult; this.expression = expression; }
Example #6
Source File: AbstractReplacer.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** * Calls lookup(pred) and returns the cached value, if any. If a replacement has * not been cached, visits the formula's children. If nothing changes, the * argument is cached and returned, otherwise a replacement formula is cached * and returned. * * @return { p: RelationPredicate | p.name = pred.name && p.relation = * pred.relation.accept(delegate) && p.name = FUNCTION => p.targetMult = * pred.targetMult && p.domain = pred.domain.accept(delegate) && p.range * = pred.range.accept(delegate), p.name = TOTAL_ORDERING => p.ordered = * pred.ordered.accept(delegate) && p.first = * pred.first.accept(delegate) && p.last = pred.last.accept(delegate) } */ @Override public Formula visit(RelationPredicate pred) { Formula ret = lookup(pred); if (ret != null) return ret; final Relation r = (Relation) pred.relation().accept(delegate); switch (pred.name()) { case ACYCLIC : ret = (r == pred.relation()) ? pred : r.acyclic(); break; case FUNCTION : final RelationPredicate.Function fp = (RelationPredicate.Function) pred; final Expression domain = fp.domain().accept(delegate); final Expression range = fp.range().accept(delegate); ret = (r == fp.relation() && domain == fp.domain() && range == fp.range()) ? fp : (fp.targetMult() == Multiplicity.ONE ? r.function(domain, range) : r.partialFunction(domain, range)); break; case TOTAL_ORDERING : final RelationPredicate.TotalOrdering tp = (RelationPredicate.TotalOrdering) pred; final Relation ordered = (Relation) tp.ordered().accept(delegate); final Relation first = (Relation) tp.first().accept(delegate); final Relation last = (Relation) tp.last().accept(delegate); ret = (r == tp.relation() && ordered == tp.ordered() && first == tp.first() && last == tp.last()) ? tp : r.totalOrder(ordered, first, last); break; default : throw new IllegalArgumentException("unknown relation predicate: " + pred.name()); } return cache(pred, ret); }
Example #7
Source File: HOLTranslator.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
private boolean noNewHOLSkolems(Collection<Relation> newSkolems, Collection<Relation> oldSkolems) { Set<Relation> diff = new HashSet<Relation>(newSkolems); diff.removeAll(oldSkolems); for (Relation sk : diff) { Decl d = sk.getSkolemVarDecl(); if (d != null && d.multiplicity() != Multiplicity.ONE) return false; } return true; }
Example #8
Source File: FOL2BoolTranslator.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** * Calls lookup(multFormula) and returns the cached value, if any. If a * translation has not been cached, translates the formula, calls cache(...) on * it and returns it. * * @return let t = lookup(multFormula) | some t => t, let op = * (multFormula.mult).(NO->none + SOME->some + ONE->one + LONE->lone) | * cache(multFormula, op(multFormula.expression.accept(this))) */ @Override public final BooleanValue visit(MultiplicityFormula multFormula) { BooleanValue ret = lookup(multFormula); if (ret != null) return ret; final BooleanMatrix child = multFormula.expression().accept(this); final Multiplicity mult = multFormula.multiplicity(); switch (mult) { case NO : ret = child.none(env); break; case SOME : ret = child.some(env); break; case ONE : ret = child.one(env); break; case LONE : ret = child.lone(env); break; default : throw new IllegalArgumentException("Unknown multiplicity: " + mult); } return cache(multFormula, ret); }
Example #9
Source File: FOL2BoolTranslator.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** * Calls lookup(decl) and returns the cached value, if any. If a translation has * not been cached, translates decl.expression, calls cache(...) on it and * returns it. * * @return let t = lookup(decl) | some t => t, cache(decl, * decl.expression.accept(this)) */ @Override public final BooleanMatrix visit(Decl decl) { BooleanMatrix matrix = lookup(decl); if (matrix != null) return matrix; if (decl.multiplicity() != Multiplicity.ONE) throw new HigherOrderDeclException(decl); return cache(decl, decl.expression().accept(this)); }
Example #10
Source File: MultiplicityFormula.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** * Constructs a new multiplicity formula: multiplicity expression * * @ensures this.expression' = expression && this.multiplicity' = multiplicity * @throws NullPointerException multiplicity = null || expression = null * @throws IllegalArgumentException multiplicity = SET */ MultiplicityFormula(Multiplicity multiplicity, Expression expression) { if (multiplicity == Multiplicity.SET) throw new IllegalArgumentException("invalid expression mulitplicity: SET"); if (multiplicity == null || expression == null) throw new NullPointerException("null arg"); this.multiplicity = multiplicity; this.expression = expression; }
Example #11
Source File: TranslatorTest.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
private final void testTranslateNonEmptyMultiplicity(Multiplicity mult) { testTranslateMultiplicity(mult, true, false); testIntersectionMultiplicity(mult, r1[1], r1[2], t112); testIntersectionMultiplicity(mult, r2[1], r2[2], t212); testIntersectionMultiplicity(mult, r3[1], r3[2], t312); }
Example #12
Source File: TranslatorTest.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
private final void testIntersectionMultiplicity(Multiplicity mult, Relation p, Relation q, Tuple intersection) { final Instance m = solve(p.intersection(q).apply(mult)); assertNotNull(m); final Set<Tuple> ps = m.tuples(p), qs = m.tuples(q); assertFalse(ps.isEmpty()); assertFalse(qs.isEmpty()); assertTrue(ps.contains(intersection)); assertTrue(qs.contains(intersection)); }
Example #13
Source File: TranslatorTest.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
private final void testTranslateMultiplicity(Multiplicity mult, boolean trueTest, boolean falseTest) { for (int i = 0; i < 4; i++) { assertTrue(isSatisfiable(r1[i].apply(mult))); assertTrue(isSatisfiable(r2[i].apply(mult))); // assertTrue(solve(r3[i].apply(mult))); } // mult rx1 & rx3 assertEquals(falseTest, isSatisfiable(r1[1].intersection(r1[3]).apply(mult))); assertEquals(falseTest, isSatisfiable(r2[1].intersection(r2[3]).apply(mult))); assertEquals(falseTest, isSatisfiable(r3[1].intersection(r3[3]).apply(mult))); // mult rx3 - rx3 assertEquals(falseTest, isSatisfiable(r1[3].difference(r1[3]).apply(mult))); assertEquals(falseTest, isSatisfiable(r2[3].difference(r2[3]).apply(mult))); assertEquals(falseTest, isSatisfiable(r3[3].difference(r3[3]).apply(mult))); // mult r11->r13 & r21 assertEquals(trueTest, isSatisfiable(r1[1].product(r1[3]).intersection(r2[1]).apply(mult))); // mult r11->r21 & r31 assertEquals(trueTest, isSatisfiable(r1[1].product(r2[1]).intersection(r3[1]).apply(mult))); // mult rx1 + rx3 assertEquals(trueTest, isSatisfiable(r1[1].union(r1[3]).apply(mult))); assertEquals(trueTest, isSatisfiable(r2[1].union(r2[3]).apply(mult))); assertEquals(trueTest, isSatisfiable(r3[1].union(r3[3]).apply(mult))); // mult r21.r13 assertEquals(trueTest, isSatisfiable(r2[1].join(r1[3]).apply(mult))); // mult r31.r21 assertEquals(trueTest, isSatisfiable(r3[1].join(r2[1]).apply(mult))); // mult ^r21 assertEquals(trueTest, isSatisfiable(r2[1].closure().apply(mult))); // mult ~r23 assertEquals(trueTest, isSatisfiable(r2[3].transpose().apply(mult))); }
Example #14
Source File: TranslatorTest.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
public final void testTranslateMultiplicityFormula_LONE() { // testTranslateMultiplicity(MultiplicityFormula.Multiplicity.LONE, // true, true); assertEquals(true, isSatisfiable(r3[1].union(r3[3]).apply(Multiplicity.LONE))); // assertEquals(true, // isSatisfiable(r3[3].difference(r3[1]).apply(MultiplicityFormula.Multiplicity.LONE))); }
Example #15
Source File: SkolemizationTest.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
private final void testNoSkolems(Multiplicity mult) { final Variable v = Variable.unary("v"); final Decl d = v.declare(mult, r1a); testNoSkolems(d, v.join(r2a).some().forAll(d).not()); testNoSkolems(d, v.join(r2a).some().forSome(d)); }
Example #16
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 #17
Source File: HamiltonianCycle2.java From kodkod with MIT License | 5 votes |
private HamiltonianCycle2(Bounds bounds, Expression[] pts, Multiplicity ptMult, Relation vertex, Relation edges) { this.pts = pts; this.ptMult = ptMult; this.vertex = vertex; this.edges = edges; this.bounds = bounds; }
Example #18
Source File: HamiltonianCycle2.java From kodkod with MIT License | 5 votes |
/** * Returns an ext encoded instance of HamiltonianCycle2. * @return an ext encoded instance of HamiltonianCycle2. */ public static HamiltonianCycle2 extEncoding(String file, Graph.Format format ) { final Graph<?> graph = format.parse(file); final Relation edges = Relation.binary("edges"); 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 Universe univ = new Universe(graph.nodes()); final Bounds bounds = new Bounds(univ); final TupleFactory f = univ.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(graph.start()==null ? univ.atom(0) : graph.start())); for(int i = 1; i < pts.length; i++) { bounds.bound(pts[i], f.range(f.tuple(univ.atom(1)), f.tuple(univ.atom(univ.size()-1)))); } bounds.boundExactly(vertex, f.allOf(1)); return new HamiltonianCycle2(bounds, pts, Multiplicity.ONE, vertex, edges); }
Example #19
Source File: Decl.java From kodkod with MIT License | 5 votes |
/** * Constructs a new declaration from the specified variable and * expression, with the specified order. * * @ensures this.variable' = variable && this.expression' = expression && this.multiplicity' = mult * @throws NullPointerException variable = null || expression = null || mult = null * @throws IllegalArgumentException variable.arity != expression.arity */ Decl(Variable variable, Multiplicity mult, Expression expression) { if (mult==Multiplicity.NO) throw new IllegalArgumentException("NO is not a valid multiplicity in a declaration."); if (variable.arity() != expression.arity()) throw new IllegalArgumentException("Unmatched arities in a declaration: " + variable + " and " + expression); if (mult != Multiplicity.SET && expression.arity()>1) throw new IllegalArgumentException("Cannot use multiplicity " + mult + " with an expression of arity > 1."); this.variable = variable; this.mult = mult; this.expression = expression; }
Example #20
Source File: RelationPredicate.java From kodkod with MIT License | 5 votes |
/** * Constructs a new function predicate over the given relation and domain, * with the specified target multiplicity. * @ensures this.name' = FUNCTION && this.relation' = relation && this.domain' = domain && * this.range' = range * @throws IllegalArgumentException relation.arity != 2 || domain.arity != 1 || range.arity != 1 || * targetMult !in ONE + LONE */ Function(Relation relation, Expression domain, Multiplicity targetMult, Expression range) { super(relation); if (targetMult != Multiplicity.ONE && targetMult != Multiplicity.LONE) throw new IllegalArgumentException("invalid target multiplicity for a function: " + targetMult); if (domain.arity() != 1 || range.arity() != 1) throw new IllegalArgumentException("invalid arity: " + domain + " or " + range); this.targetMult = targetMult; this.domain = domain; this.range = range; }
Example #21
Source File: SumExpression.java From kodkod with MIT License | 5 votes |
/** * Constructs a sum expression * @ensures this.decls' = decls && this.intExpr' = intExpr * @throws IllegalArgumentException some d: decls.children | d.multiplicty != ONE */ SumExpression(Decls decls, IntExpression intExpr) { for(Decl d : decls) { if (d.multiplicity()!=Multiplicity.ONE) throw new IllegalArgumentException(d + " is not a scalar declaration."); } this.decls = decls; this.intExpr = intExpr; }
Example #22
Source File: AbstractReplacer.java From kodkod with MIT License | 5 votes |
/** * Calls lookup(pred) and returns the cached value, if any. * If a replacement has not been cached, visits the formula's * children. If nothing changes, the argument is cached and * returned, otherwise a replacement formula is cached and returned. * @return { p: RelationPredicate | p.name = pred.name && p.relation = pred.relation.accept(this) && * p.name = FUNCTION => p.targetMult = pred.targetMult && * p.domain = pred.domain.accept(this) && * p.range = pred.range.accept(this), * p.name = TOTAL_ORDERING => p.ordered = pred.ordered.accept(this) && * p.first = pred.first.accept(this) && * p.last = pred.last.accept(this) } */ public Formula visit(RelationPredicate pred) { Formula ret = lookup(pred); if (ret!=null) return ret; final Relation r = (Relation)pred.relation().accept(this); switch(pred.name()) { case ACYCLIC : ret = (r==pred.relation()) ? pred : r.acyclic(); break; case FUNCTION : final RelationPredicate.Function fp = (RelationPredicate.Function) pred; final Expression domain = fp.domain().accept(this); final Expression range = fp.range().accept(this); ret = (r==fp.relation() && domain==fp.domain() && range==fp.range()) ? fp : (fp.targetMult()==Multiplicity.ONE ? r.function(domain, range) : r.partialFunction(domain,range)); break; case TOTAL_ORDERING : final RelationPredicate.TotalOrdering tp = (RelationPredicate.TotalOrdering) pred; final Relation ordered = (Relation) tp.ordered().accept(this); final Relation first = (Relation)tp.first().accept(this); final Relation last = (Relation)tp.last().accept(this); ret = (r==tp.relation() && ordered==tp.ordered() && first==tp.first() && last==tp.last()) ? tp : r.totalOrder(ordered, first, last); break; default : throw new IllegalArgumentException("unknown relation predicate: " + pred.name()); } return cache(pred,ret); }
Example #23
Source File: FOL2BoolTranslator.java From kodkod with MIT License | 5 votes |
/** * Calls lookup(decl) and returns the cached value, if any. * If a translation has not been cached, translates decl.expression, * calls cache(...) on it and returns it. * @return let t = lookup(decl) | * some t => t, cache(decl, decl.expression.accept(this)) */ public final BooleanMatrix visit(Decl decl) { BooleanMatrix matrix = lookup(decl); if (matrix!=null) return matrix; if (decl.multiplicity()!=Multiplicity.ONE) throw new HigherOrderDeclException(decl); return cache(decl, decl.expression().accept(this)); }
Example #24
Source File: PrettyPrinter.java From kodkod with MIT License | 5 votes |
/** * @ensures this.tokens' = * concat[ this.tokens, tokenize[ node.variable ], ":", tokenize[ node.expression ] **/ public void visit(Decl node) { node.variable().accept(this); colon(); if (node.multiplicity()!=Multiplicity.ONE) { append(node.multiplicity()); space(); } node.expression().accept(this); }
Example #25
Source File: TranslatorTest.java From kodkod with MIT License | 5 votes |
private final void testIntersectionMultiplicity(Multiplicity mult, Relation p, Relation q, Tuple intersection) { final Instance m = solve(p.intersection(q).apply(mult)); assertNotNull(m); final Set<Tuple> ps = m.tuples(p), qs = m.tuples(q); assertFalse(ps.isEmpty()); assertFalse(qs.isEmpty()); assertTrue(ps.contains(intersection)); assertTrue(qs.contains(intersection)); }
Example #26
Source File: TranslatorTest.java From kodkod with MIT License | 5 votes |
private final void testTranslateNonEmptyMultiplicity(Multiplicity mult) { testTranslateMultiplicity(mult, true, false); testIntersectionMultiplicity(mult, r1[1], r1[2], t112); testIntersectionMultiplicity(mult, r2[1], r2[2], t212); testIntersectionMultiplicity(mult, r3[1], r3[2], t312); }
Example #27
Source File: TranslatorTest.java From kodkod with MIT License | 5 votes |
private final void testTranslateMultiplicity(Multiplicity mult, boolean trueTest, boolean falseTest) { for (int i = 0; i < 4; i++) { assertTrue(isSatisfiable(r1[i].apply(mult))); assertTrue(isSatisfiable(r2[i].apply(mult))); // assertTrue(solve(r3[i].apply(mult))); } // mult rx1 & rx3 assertEquals(falseTest, isSatisfiable(r1[1].intersection(r1[3]).apply(mult))); assertEquals(falseTest, isSatisfiable(r2[1].intersection(r2[3]).apply(mult))); assertEquals(falseTest, isSatisfiable(r3[1].intersection(r3[3]).apply(mult))); // mult rx3 - rx3 assertEquals(falseTest, isSatisfiable(r1[3].difference(r1[3]).apply(mult))); assertEquals(falseTest, isSatisfiable(r2[3].difference(r2[3]).apply(mult))); assertEquals(falseTest, isSatisfiable(r3[3].difference(r3[3]).apply(mult))); // mult r11->r13 & r21 assertEquals(trueTest, isSatisfiable(r1[1].product(r1[3]).intersection(r2[1]).apply(mult))); // mult r11->r21 & r31 assertEquals(trueTest, isSatisfiable(r1[1].product(r2[1]).intersection(r3[1]).apply(mult))); // mult rx1 + rx3 assertEquals(trueTest, isSatisfiable(r1[1].union(r1[3]).apply(mult))); assertEquals(trueTest, isSatisfiable(r2[1].union(r2[3]).apply(mult))); assertEquals(trueTest, isSatisfiable(r3[1].union(r3[3]).apply(mult))); // mult r21.r13 assertEquals(trueTest, isSatisfiable(r2[1].join(r1[3]).apply(mult))); // mult r31.r21 assertEquals(trueTest, isSatisfiable(r3[1].join(r2[1]).apply(mult))); // mult ^r21 assertEquals(trueTest, isSatisfiable(r2[1].closure().apply(mult))); // mult ~r23 assertEquals(trueTest, isSatisfiable(r2[3].transpose().apply(mult))); }
Example #28
Source File: SkolemizationTest.java From kodkod with MIT License | 5 votes |
private final void testNoSkolems(Multiplicity mult) { final Variable v = Variable.unary("v"); final Decl d = v.declare(mult, r1a); testNoSkolems(d, v.join(r2a).some().forAll(d).not()); testNoSkolems(d, v.join(r2a).some().forSome(d)); }
Example #29
Source File: SkolemizationTest.java From kodkod with MIT License | 5 votes |
@Test public final void testSkolems() { testSkolems(Multiplicity.ONE); testSkolems(Multiplicity.LONE); testSkolems(Multiplicity.SOME); testSkolems(Multiplicity.SET); }
Example #30
Source File: PrettyPrinter.java From quetzal with Eclipse Public License 2.0 | 5 votes |
/** * @effects this.tokens' = * concat[ this.tokens, tokenize[ node.variable ], ":", tokenize[ node.expression ] **/ public void visit(Decl node) { if (displayed(node)) return; final boolean oldTop = notTop(); node.variable().accept(this); colon(); if (node.multiplicity()!=Multiplicity.ONE) { append(node.multiplicity()); space(); } node.expression().accept(this); top = oldTop; }