Package kodkod.ast

Examples of kodkod.ast.Decls


   */
  public Formula visit(QuantifiedFormula quantFormula) {
    Formula ret = lookup(quantFormula);
    if (ret!=null) return ret;
   
    final Decls decls = (Decls)quantFormula.decls().accept(this);
    final Formula formula = quantFormula.formula().accept(this);
    ret = (decls==quantFormula.decls() && formula==quantFormula.formula()) ?
        quantFormula : formula.quantify(quantFormula.quantifier(), decls);
    return cache(quantFormula,ret);
  }
View Full Code Here


    }

    /** Helper method that translates the formula "r in (a ?->? b)" into a Kodkod formula. */
    private Formula isInBinary(Expression r, ExprBinary ab) throws Err {
        final Expression a=cset(ab.left), b=cset(ab.right);
        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("");
View Full Code Here

         return f1.and(f2);
      }
      if (op == ExprQt.Op.LONE) {
         QuantifiedFormula p1 = (QuantifiedFormula) visit_qt(ExprQt.Op.ALL, xvars, sub);
         QuantifiedFormula p2 = (QuantifiedFormula) visit_qt(ExprQt.Op.ALL, xvars, sub);
         Decls s1 = p1.decls(), s2 = p2.decls(), decls = null;
         Formula f1 = p1.formula(), f2 = p2.formula();
         Formula[] conjuncts = new Formula[s1.size()];
         for(int i=0; i<conjuncts.length; i++) {
            kodkod.ast.Decl d1 = s1.get(i), d2 = s2.get(i);
            conjuncts[i] = d1.variable().eq(d2.variable());
            if (decls==null) decls = d1.and(d2); else decls = decls.and(d1).and(d2);
         }
         return f1.and(f2).implies(Formula.and(conjuncts)).forAll(decls);
      }
      Decls dd = null;
      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);
        }
      }
      final Formula ans = (op==ExprQt.Op.SUM) ? null : cform(sub) ;
      final IntExpression ians = (op!=ExprQt.Op.SUM) ? null : cint(sub) ;
      for(Decl d: xvars) for(ExprHasName v: d.names) env.remove((ExprVar)v);
View Full Code Here

TOP

Related Classes of kodkod.ast.Decls

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.