Java Code Examples for kodkod.ast.Variable#unary()
The following examples show how to use
kodkod.ast.Variable#unary() .
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: SET967.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** * Returns d2_xboole_0 axiom. * * @return d2_xboole_0 */ public final Formula d2_xboole_0() { final Variable a = Variable.unary("A"); final Variable b = Variable.unary("B"); final Variable c = Variable.unary("C"); return c.eq(set_union2(a, b)).iff(in.join(c).eq(in.join(a).union(in.join(b)))).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV)).and(c.oneOf(UNIV))); }
Example 2
Source File: TranslatorTest.java From kodkod with MIT License | 5 votes |
@Test public final void testTranslateComprehension() { final Variable v1 = Variable.unary("v1"), v2 = Variable.unary("v2"); // some { v1: r11 + r12 | some v1.r21 } assertTrue(isSatisfiable((v1.join(r2[1]).some()).comprehension(v1.oneOf(r1[1].union(r1[2]))).some())); // one { v1: r13, v2: r12 | v1->v2 in r23 } assertTrue(isSatisfiable((v1.product(v2).in(r2[3]).comprehension(v1.oneOf(r1[3]).and(v2.oneOf(r1[2])))).one())); // one { v1: r13, v2: r12 | v2->v1 in ~r23 } assertTrue(isSatisfiable((v2.product(v1).in(r2[3].transpose()).comprehension(v1.oneOf(r1[3]).and(v2.oneOf(r1[2])))).one())); }
Example 3
Source File: DNACuts.java From kodkod with MIT License | 5 votes |
/** * Returns declarations constraints. * @return declarations constraints. */ public Formula declarations() { final Variable l = Variable.unary("l"); final Formula f0 = l.join(base).one().forAll(l.oneOf(Link)); final Formula f1 = CutLink.union(JoinLink).eq(Link); final Formula f2 = CutLink.intersection(JoinLink).no(); return f0.and(f1).and(f2); }
Example 4
Source File: MED001.java From kodkod with MIT License | 5 votes |
/** * Returns the su_completion axiom. * @return su_completion */ public final Formula su_completion() { final Variable x0 = Variable.unary("X0"); final Expression x1 = UNIV.difference(x0.join(gt)); final Formula f0 = x1.in(bsecretioni); return f0.implies(x1.in(drugsu).and(x0.in(bcapacityex).not())).forAll(x0.oneOf(UNIV)); }
Example 5
Source File: MED001.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** * Returns the uptake_completion axiom. * * @return uptake_completion */ public final Formula uptake_completion() { final Variable x0 = Variable.unary("X0"); final Expression x1 = UNIV.difference(x0.join(gt)); final Formula f0 = x1.in(releaselg).not(); return f0.implies(x1.in(uptakelg)).forAll(x0.oneOf(UNIV)); }
Example 6
Source File: GEO158.java From kodkod with MIT License | 5 votes |
/** * Returns all the 'type' declarations. * @return the type declarations */ public Formula decls() { final Expression cc = curve.product(curve); final Expression pc = point.product(curve); final Formula f0 = partOf.in(cc); final Formula f1 = closed.in(curve).and(open.in(curve)); final Formula f2 = meet.in(point.product(cc)).and(sum.in(curve.product(cc))); final Formula f3 = incident.in(pc).and(endPoint.in(pc)).and(innerPoint.in(pc)); // all C1, C2: Curve | one C2.(C1.sum) final Variable c1 = Variable.unary("C1"); final Variable c2 = Variable.unary("C2"); final Formula f4 = c2.join(c1.join(sum)).one().forAll(c1.oneOf(curve).and(c2.oneOf(curve))); return f0.and(f1).and(f2).and(f3).and(f4); }
Example 7
Source File: NUM374.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** * Returns the sum_product_distribution axiom. * * @return sum_product_distribution */ public final Formula sumProductDistribution() { // ! [X,Y,Z] : product(X,sum(Y,Z)) = sum(product(X,Y),product(X,Z)) )). final Variable x = Variable.unary("X"); final Variable y = Variable.unary("Y"); final Variable z = Variable.unary("Z"); return product(x, sum(y, z)).eq(sum(product(x, y), product(x, z))).forAll(x.oneOf(UNIV).and(y.oneOf(UNIV)).and(z.oneOf(UNIV))); }
Example 8
Source File: GEO158.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** * Returns the c4 axiom. * * @return c4 */ public final Formula c4() { // all C: Curve, P: Point | P->C in innerPoint => some P.meet & sum.C final Variable c = Variable.unary("C"); final Variable p = Variable.unary("P"); final Formula f0 = p.product(c).in(innerPoint); final Formula f1 = p.join(meet).intersection(sum.join(c)).some(); return f0.implies(f1).forAll(c.oneOf(curve).and(p.oneOf(point))); }
Example 9
Source File: CeilingsAndFloors.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** * Returns the noSharing constraint. * * @return all m, n: Man | !(m = n) => !(m.floor = n.floor || m.ceiling = * n.ceiling) */ public Formula noSharing() { final Variable m = Variable.unary("m1"), n = Variable.unary("n1"); // all m, n: Man | !(m = n) => !(m.floor = n.floor || m.ceiling = // n.ceiling) final Formula body = (m.join(floor).eq(n.join(floor))).or(m.join(ceiling).eq(n.join(ceiling))); return (m.eq(n).not().implies(body.not())).forAll(m.oneOf(Man).and(n.oneOf(Man))); }
Example 10
Source File: GEO115.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** * Returns the conjecture theorem_3_8_5. * * @return theorem_3_8_5 */ public final Formula theorem385() { // all c: curve, p, q, r: point | // c->p->q->r in between => // incident.c - q in q.(p.(c.between)) + ((c.between).r).q final Variable c = Variable.unary("C"); final Variable p = Variable.unary("P"); final Variable q = Variable.unary("Q"); final Variable r = Variable.unary("R"); final Formula f0 = c.product(p).product(q).product(r).in(between); final Expression e0 = q.join(p.join(c.join(between))); final Expression e1 = c.join(between).join(r).join(q); final Formula f1 = incident.join(c).difference(q).in(e0.union(e1)); return f0.implies(f1).forAll(p.oneOf(point).and(q.oneOf(point)).and(r.oneOf(point)).and(c.oneOf(curve))); }
Example 11
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 12
Source File: GEO158.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** * Returns the sum_defn axiom. * * @return sum_defn */ public final Formula sumDefn() { // all C, C1, C2: Curve | C1->C2->C in sum iff // incident.C = incident.C1 + incident.C2 final Variable c1 = Variable.unary("C1"); final Variable c2 = Variable.unary("C2"); final Variable c = Variable.unary("C"); final Formula f0 = c1.product(c2).product(c).in(sum); final Formula f1 = incident.join(c).eq(incident.join(c1).union(incident.join(c2))); return f0.iff(f1).forAll(c.oneOf(curve).and(c1.oneOf(curve)).and(c2.oneOf(curve))); }
Example 13
Source File: ToyLists.java From kodkod with MIT License | 4 votes |
/** * Returns a formula stating that the equivTo relation is reflexive. * @return negation of a formula stating that the equivTo relation is reflexive. */ public Formula equivReflexivity() { //all L: List | L in L.equivTo final Variable a = Variable.unary("a"); return a.in(equivTo(a)).forAll(a.oneOf(list)); }
Example 14
Source File: SET967.java From kodkod with MIT License | 4 votes |
/** * Returns fc2_xboole_0 axiom. * @return fc2_xboole_0 */ public final Formula fc2_xboole_0() { final Variable a = Variable.unary("A"); final Variable b = Variable.unary("B"); return empty(a).not().implies(empty(set_union2(a, b)).not()).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV))); }
Example 15
Source File: SET943.java From kodkod with MIT License | 4 votes |
/** * Returns commutativity_k2_xboole_0 axiom. * @return commutativity_k2_xboole_0 */ public final Formula commutativity_k2_xboole_0() { final Variable a = Variable.unary("A"); final Variable b = Variable.unary("B"); return set_union2(a, b).eq(set_union2(b, a)).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV))); }
Example 16
Source File: Dijkstra.java From kodkod with MIT License | 4 votes |
/** * Returns the GrabMutex predicate for states s1, s2, process p and mutex m. * @return * <pre> * pred State.GrabMutex (p: Process, m: Mutex, s': State) { * // a process can only act if it is not * // waiting for a mutex * !this::IsStalled(p) * // can only grab a mutex we do not yet hold * m !in p.(this.holds) * this::IsFree (m) => { * // if the mutex is free, we now hold it, * // and do not become stalled * p.(s'.holds) = p.(this.holds) + m * no p.(s'.waits) * } else { * // if the mutex was not free, * // we still hold the same mutexes we held, * // and are now waiting on the mutex * // that we tried to grab. * p.(s'.holds) = p.(this.holds) * p.(s'.waits) = m * } * all otherProc: Process - p | { * otherProc.(s'.holds) = otherProc.(this.holds) * otherProc.(s'.waits) = otherProc.(this.waits) * } * } * </pre> */ public Formula grabMutex(Expression s1, Expression s2, Expression p, Expression m) { final Formula f1 = isStalled(s1,p).not().and(m.in(p.join(s1.join(holds))).not()); final Formula isFree = isFree(s1,m); final Formula f2 = p.join(s2.join(holds)).eq(p.join(s1.join(holds)).union(m)); final Formula f3 = p.join(s2.join(waits)).no(); final Formula f4 = isFree.implies(f2.and(f3)); final Formula f5 = p.join(s2.join(holds)).eq(p.join(s1.join(holds))); final Formula f6 = p.join(s2.join(waits)).eq(m); final Formula f7 = isFree.not().implies(f5.and(f6)); final Variable otherProc = Variable.unary("otherProc"); final Formula f8 = otherProc.join(s2.join(holds)).eq(otherProc.join(s1.join(holds))); final Formula f9 = otherProc.join(s2.join(waits)).eq(otherProc.join(s1.join(waits))); final Formula f10 = f8.and(f9).forAll(otherProc.oneOf(Process.difference(p))); return Formula.and(f1, f4, f7, f10); }
Example 17
Source File: MGT066.java From kodkod with MIT License | 4 votes |
/** * Returns meaning_postulate_greater_comparable * @return meaning_postulate_greater_comparable */ public final Formula meaningPostulateGreaterComparable() { final Variable x = Variable.unary("X"); final Variable y = Variable.unary("Y"); return x.eq(y).or(y.in(x.join(lt))).or(x.in(y.join(lt))).forAll(x.oneOf(Expression.UNIV).and(y.oneOf(Expression.UNIV))); }
Example 18
Source File: SET948.java From kodkod with MIT License | 4 votes |
/** * Returns d4_tarski axiom. * @return d4_tarski */ public final Formula d4_tarski() { final Variable a = Variable.unary("A"); final Variable b = Variable.unary("B"); return b.eq(union(a)).iff(in.join(b).eq(in.join(in.join(a)))).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV))); }
Example 19
Source File: Quasigroups7.java From org.alloytools.alloy with Apache License 2.0 | 2 votes |
/** * Returns axiom 6. * * @return ax6 */ public final Formula ax6() { final Variable x = Variable.unary("x"), y = Variable.unary("y"); return x.eq(op2(op2(op2(y, x), y), y)).forAll(x.oneOf(s2).and(y.oneOf(s2))); }
Example 20
Source File: SkolemizationTest.java From kodkod with MIT License | 2 votes |
private final void testSkolems(Multiplicity mult) { final Variable va = Variable.unary("va"); final Variable vb = Variable.unary("vb"); final Set<String> skolems = new HashSet<String>(4); Decl da = va.declare(mult, r1a); Decl db = vb.declare(mult, r1b); skolems.add("$"+va.name()); Instance inst = solve(va.in(r1b.join(r2b)).forAll(da).not()); assertSkolems(bounds, inst, skolems); inst = solve((r2b.some().implies(va.in(r1b.join(r2b)).forAll(da))).not()); assertSkolems(bounds, inst, skolems); inst = solve(va.in(r1b.join(r2b)).forSome(da)); assertSkolems(bounds, inst, skolems); inst = solve(va.in(r1b.join(r2b)).forSome(da).and(va.in(r1b).not().forAll(mult==Multiplicity.ONE ? da : va.oneOf(r1a)))); assertSkolems(bounds, inst, skolems); final Expression e0 = va.join(r2a); final Formula f0 = e0.some().forSome(va.oneOf(r1a)); final Formula f1 = e0.no().forAll(va.oneOf(r2a.join(r1b))); inst = solve(f0.and(f1)); assertSkolems(bounds, inst, skolems); skolems.add("$"+vb.name()); inst = solve(va.in(vb.join(r2b)).forSome(da.and(vb.oneOf(va.join(r2a))))); assertSkolems(bounds, inst, skolems); inst = solve((va.in(vb.join(r2b)).forAll(vb.oneOf(va.join(r2a))).forAll(da)).not()); assertSkolems(bounds, inst, skolems); inst = solve(va.in(vb.join(r2b)).forAll(da.and(db)).not()); assertSkolems(bounds, inst, skolems); inst = solve(va.in(vb.join(r2b)).forSome(da.and(db))); assertSkolems(bounds, inst, skolems); inst = solve(va.in(r1b.join(r2b)).forSome(da).and(r1b.in(vb).forAll(db).not())); assertSkolems(bounds, inst, skolems); }