Package kodkod.engine.bool

Examples of kodkod.engine.bool.BooleanValue


      } else if (circuit.size()==0) {
        throw new TrivialFormulaException(annotated.node(), bounds, circuit.op().identity(), log);
      }
      return generateSBP(circuit, interpreter, breaker);
    } else {
      final BooleanValue circuit = (BooleanValue)FOL2BoolTranslator.translate(annotated, interpreter);
      if (circuit.op()==Operator.CONST) {
        throw new TrivialFormulaException(annotated.node(), bounds, (BooleanConstant)circuit, null);
      }
      return generateSBP(annotated, (BooleanFormula)circuit, interpreter, breaker);
    }
  }
View Full Code Here


   */
  private Translation generateSBP(AnnotatedNode<Formula> annotated, BooleanFormula circuit, LeafInterpreter interpreter, SymmetryBreaker breaker)
  throws TrivialFormulaException {
    options.reporter().generatingSBP();
    final BooleanFactory factory = interpreter.factory();
    final BooleanValue sbp = breaker.generateSBP(interpreter, options.symmetryBreaking());
    return flatten(annotated, (BooleanFormula)factory.and(circuit, sbp), interpreter);
  }
View Full Code Here

   */
  private Translation flatten(AnnotatedNode<Formula> annotated, BooleanFormula circuit, LeafInterpreter interpreter) throws TrivialFormulaException
    final BooleanFactory factory = interpreter.factory();
    if (options.flatten()) {
      options.reporter().flattening(circuit);
      final BooleanValue flatCircuit = BooleanFormulaFlattener.flatten(circuit, factory);
      if (flatCircuit.op()==Operator.CONST) {
        throw new TrivialFormulaException(annotated.node(), bounds, (BooleanConstant)flatCircuit, null);
      } else {
        return toCNF((BooleanFormula)flatCircuit, factory.numberOfVariables(), interpreter.vars());
      }
    } else {
View Full Code Here

   */
  @Override
  void log(Formula f, BooleanValue translation, Environment<BooleanMatrix> env) {
    if (logMap.containsKey(f)) {
      assert env.isEmpty();
      final BooleanValue old = logMap.put(f, translation);
      if (old!=null && old!=translation)
        throw new IllegalArgumentException("translation of root corresponding to the formula has already been logged: " + f);
    }
  }
View Full Code Here

  static final BooleanValue flatten(BooleanFormula root, BooleanFactory f) {
    final int oldCompDepth = f.comparisonDepth();
    f.setComparisonDepth(1);
    f.clear(); // remove everything but the variables from the factory
    final BooleanFormulaFlattener flattener = new BooleanFormulaFlattener(root, f);
    final BooleanValue flatRoot = root.accept(flattener, null);
    f.setComparisonDepth(oldCompDepth);
    return flatRoot;
  }
View Full Code Here

          return op.shortCircuit();
      }
      return parent;
    } else { // construct a gate that corresponds to the multigate
//      System.out.println("Unflattenable: " + multigate);
      BooleanValue replacement = cache.get(multigate);

      if (replacement == null) {
        final BooleanAccumulator newGate = BooleanAccumulator.treeGate(op);
        for(Iterator<BooleanFormula> inputs = multigate.iterator(); inputs.hasNext();) {
          if (inputs.next().accept(this,newGate)==op.shortCircuit()) {
View Full Code Here

          if (!rparts.representatives.contains(sym.min())) continue// r does not range over sym
         
          BooleanMatrix m = interpreter.interpret(r);
          for(IndexedEntry<BooleanValue> entry : m) {
            int permIndex = permutation(r.arity(), entry.index(), prevIndex, curIndex);
            BooleanValue permValue = m.get(permIndex);
            if (permIndex==entry.index() || atSameIndex(original, permValue, permuted, entry.value()))
              continue;
           
            original.add(entry.value());
            permuted.add(permValue);     
View Full Code Here

   * @requires l0.size()==l1.size()
   * @return a circuit that compares l0 and l1
   */
  private static final BooleanValue leq(BooleanFactory f, List<BooleanValue> l0, List<BooleanValue> l1) {
    final BooleanAccumulator cmp = BooleanAccumulator.treeGate(Operator.AND);
    BooleanValue prevEquals = BooleanConstant.TRUE;
    for(int i = 0; i < l0.size(); i++) {
      cmp.add(f.implies(prevEquals, f.implies(l0.get(i), l1.get(i))));
      prevEquals = f.and(prevEquals, f.iff(l0.get(i), l1.get(i)));
    }
    return f.accumulate(cmp);
View Full Code Here

   */
  public BooleanMatrix visit(IfExpression ifExpr) {
    BooleanMatrix ret = lookup(ifExpr);
    if (ret!=null) return ret;

    final BooleanValue condition = ifExpr.condition().accept(this);
    final BooleanMatrix thenExpr = ifExpr.thenExpr().accept(this);
    final BooleanMatrix elseExpr = ifExpr.elseExpr().accept(this);
    ret = thenExpr.choice(condition, elseExpr);

    return cache(ifExpr,ret);
View Full Code Here

   * calls cache(...) on it and returns it.
   * @return let t = lookup(quantFormula) | some t => t,
   *   cache(quantFormula, translate(quantFormula))
   */
  public final BooleanValue visit(QuantifiedFormula quantFormula) {
    BooleanValue ret = lookup(quantFormula);
    if (ret!=null) return ret;

    final Quantifier quantifier = quantFormula.quantifier();

    switch(quantifier) {
View Full Code Here

TOP

Related Classes of kodkod.engine.bool.BooleanValue

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.