예제 #1
0
 /**
  * Returns the conjecture proposition_2_14_1.
  *
  * @return proposition_2_14_1
  */
 public final Formula proposition2141() {
   // all c1, c2: curve, p: point |
   //  p->c1->c2 in meet && c1->c2 in sum.open =>
   //  all q: point - p | c1 + c2 !in q.incident
   final Variable c1 = Variable.unary("C1");
   final Variable c2 = Variable.unary("C2");
   final Variable p = Variable.unary("P");
   final Variable q = Variable.unary("Q");
   final Expression e0 = c1.product(c2);
   final Formula f0 = p.product(e0).in(meet).and(e0.in(sum.join(open)));
   final Formula f1 = c1.union(c2).in(q.join(incident)).not().forAll(q.oneOf(point.difference(p)));
   return f0.implies(f1).forAll(c1.oneOf(curve).and(c2.oneOf(curve)).and(p.oneOf(point)));
 }
예제 #2
0
 /**
  * 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("");
     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));
 }