Java Code Examples for kodkod.ast.Formula#implies()

The following examples show how to use kodkod.ast.Formula#implies() . 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: MED007.java    From org.alloytools.alloy with Apache License 2.0 5 votes vote down vote up
/**
 * Returns transsls2_qilt27 conjecture.
 *
 * @return transsls2_qilt27
 */
public final Formula transsls2_qilt27() {
    final Variable x0 = Variable.unary("X0");
    final Formula f0 = n0.in(s1).and(n0.join(gt).in(conditionhyper)).and(n0.in(bcapacitysn).not()).and(n0.in(qilt27));
    final Formula f1 = n0.product(x0).in(gt).not().and(x0.in(s2)).and(x0.join(gt).in(conditionhyper)).and(x0.in(bcapacityne.union(bcapacityex))).forSome(x0.oneOf(UNIV));
    return f0.implies(f1);
}
 
Example 2
Source File: MED009.java    From org.alloytools.alloy with Apache License 2.0 5 votes vote down vote up
/**
 * Returns transsls2_qige27 conjecture.
 *
 * @return transsls2_qige27
 */
public final Formula transsls2_qige27() {
    final Variable x0 = Variable.unary("X0");
    final Formula f0 = n0.in(s1).and(n0.join(gt).in(conditionhyper)).and(n0.in(bcapacitysn).not()).and(n0.in(qilt27).not());
    final Formula f1 = n0.product(x0).in(gt).not().and(x0.in(s2)).and(x0.join(gt).in(conditionhyper)).and(x0.in(bcapacityne.union(bcapacityex))).forSome(x0.oneOf(UNIV));
    return f0.implies(f1);
}
 
Example 3
Source File: TranslateAlloyToKodkod.java    From org.alloytools.alloy with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public Object visit(ExprITE x) throws Err {
    Formula c = cform(x.cond);
    Object l = visitThis(x.left);
    if (l instanceof Formula) {
        Formula c1 = c.implies((Formula) l);
        Formula c2 = c.not().implies(cform(x.right));
        return k2pos(c1.and(c2), x);
    }
    if (l instanceof Expression) {
        return c.thenElse((Expression) l, cset(x.right));
    }
    return c.thenElse((IntExpression) l, cint(x.right));
}
 
Example 4
Source File: MED007.java    From kodkod with MIT License 5 votes vote down vote up
/**
 * Returns transsls2_qilt27 conjecture.
 * @return transsls2_qilt27
 */
public final Formula transsls2_qilt27() {
	final Variable x0 = Variable.unary("X0");
	final Formula f0 = n0.in(s1).and(n0.join(gt).in(conditionhyper)).
		and(n0.in(bcapacitysn).not()).and(n0.in(qilt27));
	final Formula f1 = n0.product(x0).in(gt).not().and(x0.in(s2)).
		and(x0.join(gt).in(conditionhyper)).and(x0.in(bcapacityne.union(bcapacityex))).
		forSome(x0.oneOf(UNIV));
	return f0.implies(f1);
}
 
Example 5
Source File: MED009.java    From kodkod with MIT License 5 votes vote down vote up
/**
 * Returns transsls2_qige27 conjecture.
 * @return transsls2_qige27
 */
public final Formula transsls2_qige27() {
	final Variable x0 = Variable.unary("X0");
	final Formula f0 = n0.in(s1).and(n0.join(gt).in(conditionhyper)).
		and(n0.in(bcapacitysn).not()).and(n0.in(qilt27).not());
	final Formula f1 = n0.product(x0).in(gt).not().and(x0.in(s2)).
		and(x0.join(gt).in(conditionhyper)).and(x0.in(bcapacityne.union(bcapacityex))).
		forSome(x0.oneOf(UNIV));
	return f0.implies(f1);
}
 
Example 6
Source File: Dijkstra.java    From org.alloytools.alloy with Apache License 2.0 4 votes vote down vote up
/**
 * 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 7
Source File: Dijkstra.java    From kodkod with MIT License 4 votes vote down vote up
/**
 * 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);
}