Package kodkod.ast

Examples of kodkod.ast.BinaryFormula


   
    final ListIterator<Formula> itr = formulas.listIterator();
    while(itr.hasNext()) {
      final Formula f = itr.next();
      if (f instanceof BinaryFormula) {
        final BinaryFormula bin = (BinaryFormula) f;
        if (bin.op()==FormulaOperator.AND) {
          itr.remove();
          itr.add(bin.left());
          itr.add(bin.right());
          itr.previous();
          itr.previous();
        }
      } else if (f instanceof NaryFormula) {
        final NaryFormula nf = (NaryFormula) f;
View Full Code Here


   * @return  an unmodifiable set consisting of children of the given formula, if the formula is a binary or an nary conjunction.  Otherwise
   * returns a singleton set containing the formula itself.
   */
  public static Set<Formula> conjuncts(Formula formula) {
    if (formula instanceof BinaryFormula) {
      final BinaryFormula bin = (BinaryFormula) formula;
      if (bin.op()==FormulaOperator.AND) {
        final Formula left = bin.left(), right = bin.right();
        if (left==right) return Collections.singleton(left);
        else return new AbstractSet<Formula>() {
          @Override
          public boolean contains(Object o) { return left==o || right==o; }
          @Override
View Full Code Here

    Formula k2pos(Formula formula, Expr expr) throws Err {
        if (solved) throw new ErrorFatal("Cannot alter the k->pos mapping since solve() has completed.");
        if (formula==null || expr==null || k2pos.containsKey(formula)) return formula;
        k2pos.put(formula, expr);
        if (formula instanceof BinaryFormula) {
            BinaryFormula b = (BinaryFormula)formula;
            if (b.op() == FormulaOperator.AND) { k2pos(b.left(), expr); k2pos(b.right(), expr); }
        }
        return formula;
    }
View Full Code Here

    Formula k2pos(Formula formula, Pos pos) throws Err {
        if (solved) throw new ErrorFatal("Cannot alter the k->pos mapping since solve() has completed.");
        if (formula==null || pos==null || pos==Pos.UNKNOWN || k2pos.containsKey(formula)) return formula;
        k2pos.put(formula, pos);
        if (formula instanceof BinaryFormula) {
            BinaryFormula b = (BinaryFormula)formula;
            if (b.op() == FormulaOperator.AND) { k2pos(b.left(), pos); k2pos(b.right(), pos); }
        }
        return formula;
    }
View Full Code Here

          if (f.op() == FormulaOperator.AND) {
             for(Iterator<Formula> i = f.iterator(); i.hasNext();) if (!simplify_in(i.next())) return false;
          }
       }
       if (form instanceof BinaryFormula) {
          BinaryFormula f = (BinaryFormula)form;
          if (f.op() == FormulaOperator.AND) {
             return simplify_in(f.left()) && simplify_in(f.right());
          }
       }
       if (form instanceof ComparisonFormula) {
          ComparisonFormula f = (ComparisonFormula)form;
          if (f.op() == ExprCompOperator.SUBSET) {
             if (!simplify_in(f.left(), f.right())) return false;
          }
          if (f.op() == ExprCompOperator.EQUALS) {
             if (!simplify_in(f.left(), f.right())) return false;
             if (!simplify_in(f.right(), f.left())) return false;
          }
       }
       return true;
    }
View Full Code Here

          if (f.op() == FormulaOperator.AND) {
             for(Iterator<Formula> i = f.iterator(); i.hasNext();) if (!simplify_eq(i.next())) return false;
          }
       }
       if (form instanceof BinaryFormula) {
          BinaryFormula f = (BinaryFormula)form;
          if (f.op() == FormulaOperator.AND) {
             return simplify_eq(f.left()) && simplify_eq(f.right());
          }
       }
       if (form instanceof ComparisonFormula) {
          ComparisonFormula f = (ComparisonFormula)form;
          if (f.op() == ExprCompOperator.EQUALS) {
             if (!simplify_equal(f.left(), f.right())) return false;
          }
       }
       return true;
    }
View Full Code Here

TOP

Related Classes of kodkod.ast.BinaryFormula

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.