Package kodkod.ast

Examples of kodkod.ast.Variable


        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));
    }
View Full Code Here


   */
  public Decl visit(Decl decl) {
    Decl ret = lookup(decl);
    if (ret!=null) return ret;
   
    final Variable variable = (Variable) decl.variable().accept(this);
    final Expression expression = decl.expression().accept(this);
    ret = (variable==decl.variable() && expression==decl.expression()) ?
        decl : variable.declare(decl.multiplicity(), expression);
    return cache(decl,ret);
  }
View Full Code Here

                totalOrderPredicates.add((Relation)elem); totalOrderPredicates.add((Relation)first); totalOrderPredicates.add(lst); totalOrderPredicates.add((Relation)next);
                return k2pos(((Relation)next).totalOrder((Relation)elem, (Relation)first, lst), x);
            }
            Formula f1 = elem.in(first.join(next.reflexiveClosure())); // every element is in the total order
            Formula f2 = next.join(first).no(); // first element has no predecessor
            Variable e = Variable.unary("");
            Formula f3 = e.eq(first).or(next.join(e).one()); // each element (except the first) has one predecessor
            Formula f4 = e.eq(elem.difference(next.join(elem))).or(e.join(next).one()); // each element (except the last) has one successor
            Formula f5 = e.in(e.join(next.closure())).not(); // there are no cycles
            return k2pos(f3.and(f4).and(f5).forAll(e.oneOf(elem)).and(f1).and(f2), x);
        }
        // This says  no(a&b) and no((a+b)&c) and no((a+b+c)&d)...
        // Emperically this seems to be more efficient than "no(a&b) and no(a&c) and no(b&c)"
        Formula answer = null;
        Expression a = null;
View Full Code Here

        Decls d=null, d2=null;
        Formula ans1, ans2;
        // "R in A ->op B" means for each tuple a in A, there are "op" tuples in r that begins with a.
        Expression atuple=null, ar=r;
        for(int i=a.arity(); i>0; i--) {
           Variable v=Variable.unary("");
           if (a.arity()==1) d=v.oneOf(a); else if (d==null) d=v.oneOf(Relation.UNIV); else d=v.oneOf(Relation.UNIV).and(d);
           ar=v.join(ar);
           if (atuple==null) atuple=v; else atuple=atuple.product(v);
        }
        ans1=isIn(ar, ab.right);
        switch(ab.op) {
           case ISSEQ_ARROW_LONE:
           case ANY_ARROW_LONE: case SOME_ARROW_LONE: case ONE_ARROW_LONE: case LONE_ARROW_LONE: ans1=ar.lone().and(ans1); break;
           case ANY_ARROW_ONE:  case SOME_ARROW_ONE:  case ONE_ARROW_ONE:  case LONE_ARROW_ONE:  ans1=ar.one().and(ans1)break;
           case ANY_ARROW_SOME: case SOME_ARROW_SOME: case ONE_ARROW_SOME: case LONE_ARROW_SOME: ans1=ar.some().and(ans1); break;
        }
        if (a.arity()>1) { Formula tmp=isIn(atuple, ab.left); if (tmp!=Formula.TRUE) ans1=tmp.implies(ans1); }
        ans1=ans1.forAll(d);
        // "R in A op-> B" means for each tuple b in B, there are "op" tuples in r that end with b.
        Expression btuple=null, rb=r;
        for(int i=b.arity(); i>0; i--) {
           Variable v=Variable.unary("");
           if (b.arity()==1) d2=v.oneOf(b); else if (d2==null) d2=v.oneOf(Relation.UNIV); else d2=v.oneOf(Relation.UNIV).and(d2);
           rb=rb.join(v);
           if (btuple==null) btuple=v; else btuple=v.product(btuple);
        }
        ans2=isIn(rb, ab.left);
        switch(ab.op) {
           case LONE_ARROW_ANY: case LONE_ARROW_SOME: case LONE_ARROW_ONE: case LONE_ARROW_LONE: ans2=rb.lone().and(ans2); break;
           case ONE_ARROW_ANY:  case ONE_ARROW_SOME:  case ONE_ARROW_ONE:  case ONE_ARROW_LONE:  ans2=rb.one().and(ans2)break;
View Full Code Here

      List<Formula> guards = new ArrayList<Formula>();
      for(Decl dep: xvars) {
        final Expr dexexpr = addOne(dep.expr);
        final Expression dv = cset(dexexpr);
        for(ExprHasName dex: dep.names) {
           final Variable v = Variable.nary(skolem(dex.label), dex.type().arity());
           final kodkod.ast.Decl newd;
           env.put((ExprVar)dex, v);
           if (dex.type().arity()!=1) {
              guards.add(isIn(v, dexexpr));
              newd = v.setOf(dv);
           } else switch(dexexpr.mult()) {
              case SETOF: newd = v.setOf(dv); break;
              case SOMEOF: newd = v.someOf(dv); break;
              case LONEOF: newd = v.loneOf(dv); break;
              default: newd = v.oneOf(dv);
           }
           if (frame!=null) frame.kv2typepos(v, dex.type(), dex.pos);
           if (dd==null) dd = newd; else dd = dd.and(newd);
        }
      }
View Full Code Here

TOP

Related Classes of kodkod.ast.Variable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.