Esempio n. 1
0
void ArithStaticLearner::addBound(TNode n) {

  CDNodeToMinMaxMap::const_iterator minFind = d_minMap.find(n[0]);
  CDNodeToMinMaxMap::const_iterator maxFind = d_maxMap.find(n[0]);

  Rational constant = n[1].getConst<Rational>();
  DeltaRational bound = constant;

  switch(Kind k = n.getKind()) {
  case kind::LT:
    bound = DeltaRational(constant, -1);
    /* fall through */
  case kind::LEQ:
    if (maxFind == d_maxMap.end() || (*maxFind).second > bound) {
      d_maxMap.insert(n[0], bound);
      Debug("arith::static") << "adding bound " << n << endl;
    }
    break;
  case kind::GT:
    bound = DeltaRational(constant, 1);
    /* fall through */
  case kind::GEQ:
    if (minFind == d_minMap.end() || (*minFind).second < bound) {
      d_minMap.insert(n[0], bound);
      Debug("arith::static") << "adding bound " << n << endl;
    }
    break;
  default:
    Unhandled(k);
    break;
  }
}
Esempio n. 2
0
std::ostream& operator<<(std::ostream& os,  const Algorithms a){
  switch(a){
  case None:    os << "AlgNone"; break;
  case Lookup:  os << "AlgLookup"; break;
  case RowSum:  os << "AlgRowSum"; break;
  case Simplex: os << "AlgSimplex"; break;
  default:
    Unhandled();
  }

  return os;
}
Esempio n. 3
0
ostream& operator<<(ostream& out, enum Result::Validity v) {
  switch (v) {
    case Result::INVALID:
      out << "INVALID";
      break;
    case Result::VALID:
      out << "VALID";
      break;
    case Result::VALIDITY_UNKNOWN:
      out << "VALIDITY_UNKNOWN";
      break;
    default:
      Unhandled(v);
  }
  return out;
}
Esempio n. 4
0
ostream& operator<<(ostream& out, enum Result::Sat s) {
  switch (s) {
    case Result::UNSAT:
      out << "UNSAT";
      break;
    case Result::SAT:
      out << "SAT";
      break;
    case Result::SAT_UNKNOWN:
      out << "SAT_UNKNOWN";
      break;
    default:
      Unhandled(s);
  }
  return out;
}
Esempio n. 5
0
void PicklerPrivate::toCaseConstant(TNode n) {
  Kind k = n.getKind();
  Assert(metaKindOf(k) == kind::metakind::CONSTANT);
  switch(k) {
  case kind::CONST_BOOLEAN:
    d_current << mkConstantHeader(k, 1);
    d_current << mkBlockBody(n.getConst<bool>());
    break;
  case kind::CONST_RATIONAL: {
    std::string asString;
    Assert(k == kind::CONST_RATIONAL);
    const Rational& q = n.getConst<Rational>();
    asString = q.toString(16);
    toCaseString(k, asString);
    break;
  }
  case kind::BITVECTOR_EXTRACT_OP: {
    BitVectorExtract bve = n.getConst<BitVectorExtract>();
    d_current << mkConstantHeader(k, 2);
    d_current << mkBlockBody(bve.high);
    d_current << mkBlockBody(bve.low);
    break;
  }
  case kind::CONST_BITVECTOR: {
    // irritating: we incorporate the size of the string in with the
    // size of this constant, so it appears as one big constant and
    // doesn't confuse anybody
    BitVector bv = n.getConst<BitVector>();
    std::string asString = bv.getValue().toString(16);
    d_current << mkConstantHeader(k, 2 + asString.size());
    d_current << mkBlockBody(bv.getSize());
    toCaseString(k, asString);
    break;
  }
  case  kind::BITVECTOR_SIGN_EXTEND_OP: {
    BitVectorSignExtend bvse = n.getConst<BitVectorSignExtend>();
    d_current << mkConstantHeader(k, 1);
    d_current << mkBlockBody(bvse.signExtendAmount);
    break;
  }
  default:
    Unhandled(k);
  }
}
Esempio n. 6
0
std::ostream& operator<<(std::ostream& os, EqualityStatus s)
{
  switch (s)
  {
    case EQUALITY_TRUE_AND_PROPAGATED:
      os << "EQUALITY_TRUE_AND_PROPAGATED";
      break;
    case EQUALITY_FALSE_AND_PROPAGATED:
      os << "EQUALITY_FALSE_AND_PROPAGATED";
      break;
    case EQUALITY_TRUE: os << "EQUALITY_TRUE"; break;
    case EQUALITY_FALSE: os << "EQUALITY_FALSE"; break;
    case EQUALITY_TRUE_IN_MODEL: os << "EQUALITY_TRUE_IN_MODEL"; break;
    case EQUALITY_FALSE_IN_MODEL: os << "EQUALITY_FALSE_IN_MODEL"; break;
    case EQUALITY_UNKNOWN: os << "EQUALITY_UNKNOWN"; break;
    default: Unhandled(); break;
  }
  return os;
}
Esempio n. 7
0
bool checkConstantMembership(TNode elementTerm, TNode setTerm)
{
  switch(setTerm.getKind()) {
  case kind::EMPTYSET:
    return false;
  case kind::SET_SINGLETON:
    return elementTerm == setTerm[0];
  case kind::UNION:
    return checkConstantMembership(elementTerm, setTerm[0]) ||
      checkConstantMembership(elementTerm, setTerm[1]);
  case kind::INTERSECTION:
    return checkConstantMembership(elementTerm, setTerm[0]) &&
      checkConstantMembership(elementTerm, setTerm[1]);
  case kind::SETMINUS:
    return checkConstantMembership(elementTerm, setTerm[0]) &&
      !checkConstantMembership(elementTerm, setTerm[1]);
  default:
    Unhandled();
  }
}
Esempio n. 8
0
void PicklerPrivate::toCaseNode(TNode n)
{
  Debug("pickler") << "toCaseNode: " << n << std::endl;
  Kind k = n.getKind();
  kind::MetaKind m = metaKindOf(k);
  switch(m) {
  case kind::metakind::CONSTANT:
    toCaseConstant(n);
    break;
  case kind::metakind::VARIABLE:
    toCaseVariable(n);
    break;
  case kind::metakind::OPERATOR:
  case kind::metakind::PARAMETERIZED:
    toCaseOperator(n);
    break;
  default:
    Unhandled(m);
  }
}
Esempio n. 9
0
void Theory$camel::check(Effort level) {

    while(!done()) {
        // Get all the assertions
        Assertion assertion = get();
        TNode fact = assertion.assertion;

        Debug("$dir") << "Theory$camel::check(): processing " << fact << std::endl;

        // Do the work
        switch(fact.getKind()) {

        /* cases for all the theory's kinds go here... */

        default:
            Unhandled(fact.getKind());
        }
    }

}/* Theory$camel::check() */
Esempio n. 10
0
Expr Pickler::fromPickle(Pickle& p) {
  Assert(d_private->atDefaultState());

  d_private->d_current.swap(*p.d_data);

  while(!d_private->d_current.empty()) {
    Block front = d_private->d_current.dequeue();

    Kind k = (Kind)front.d_header.d_kind;
    kind::MetaKind m = metaKindOf(k);

    Node result = Node::null();
    switch(m) {
    case kind::metakind::VARIABLE:
      result = d_private->fromCaseVariable(k);
      break;
    case kind::metakind::CONSTANT:
      result = d_private->fromCaseConstant(k, front.d_headerConstant.d_constblocks);
      break;
    case kind::metakind::OPERATOR:
    case kind::metakind::PARAMETERIZED:
      result = d_private->fromCaseOperator(k, front.d_headerOperator.d_nchildren);
      break;
    default:
      Unhandled(m);
    }
    Assert(result != Node::null());
    d_private->d_stack.push(result);
  }

  Assert(d_private->d_current.empty());
  Assert(d_private->d_stack.size() == 1);
  Node res = d_private->d_stack.top();
  d_private->d_stack.pop();

  Assert(d_private->atDefaultState());

  return d_private->d_nm->toExpr(res);
}
Esempio n. 11
0
Node PicklerPrivate::fromCaseConstant(Kind k, uint32_t constblocks) {
  switch(k) {
  case kind::CONST_BOOLEAN: {
    Assert(constblocks == 1);
    Block val = d_current.dequeue();

    bool b= val.d_body.d_data;
    return d_nm->mkConst<bool>(b);
  }
  case kind::CONST_RATIONAL: {
    std::string s = fromCaseString(constblocks);
    Rational q(s, 16);
    return d_nm->mkConst<Rational>(q);
  }
  case kind::BITVECTOR_EXTRACT_OP: {
    Block high = d_current.dequeue();
    Block low = d_current.dequeue();
    BitVectorExtract bve(high.d_body.d_data, low.d_body.d_data);
    return d_nm->mkConst<BitVectorExtract>(bve);
  }
  case kind::CONST_BITVECTOR: {
    unsigned size = d_current.dequeue().d_body.d_data;
    Block header CVC4_UNUSED = d_current.dequeue();
    Assert(header.d_headerConstant.d_kind == kind::CONST_BITVECTOR);
    Assert(header.d_headerConstant.d_constblocks == constblocks - 2);
    Integer value(fromCaseString(constblocks - 2));
    BitVector bv(size, value);
    return d_nm->mkConst(bv);
  }
  case  kind::BITVECTOR_SIGN_EXTEND_OP: {
    Block signExtendAmount = d_current.dequeue();
    BitVectorSignExtend bvse(signExtendAmount.d_body.d_data);
    return d_nm->mkConst<BitVectorSignExtend>(bvse);
  }
  default:
    Unhandled(k);
  }
}
Esempio n. 12
0
ostream& operator<<(ostream& out, enum Result::UnknownExplanation e) {
  switch (e) {
    case Result::REQUIRES_FULL_CHECK:
      out << "REQUIRES_FULL_CHECK";
      break;
    case Result::INCOMPLETE:
      out << "INCOMPLETE";
      break;
    case Result::TIMEOUT:
      out << "TIMEOUT";
      break;
    case Result::RESOURCEOUT:
      out << "RESOURCEOUT";
      break;
    case Result::MEMOUT:
      out << "MEMOUT";
      break;
    case Result::INTERRUPTED:
      out << "INTERRUPTED";
      break;
    case Result::NO_STATUS:
      out << "NO_STATUS";
      break;
    case Result::UNSUPPORTED:
      out << "UNSUPPORTED";
      break;
    case Result::OTHER:
      out << "OTHER";
      break;
    case Result::UNKNOWN_REASON:
      out << "UNKNOWN_REASON";
      break;
    default:
      Unhandled(e);
  }
  return out;
}
Esempio n. 13
0
Result Result::asValidityResult() const {
  if (d_which == TYPE_VALIDITY) {
    return *this;
  }

  if (d_which == TYPE_SAT) {
    switch (d_sat) {
      case SAT:
        return Result(INVALID, d_inputName);

      case UNSAT:
        return Result(VALID, d_inputName);

      case SAT_UNKNOWN:
        return Result(VALIDITY_UNKNOWN, d_unknownExplanation, d_inputName);

      default:
        Unhandled(d_sat);
    }
  }

  // TYPE_NONE
  return Result(VALIDITY_UNKNOWN, NO_STATUS, d_inputName);
}
Esempio n. 14
0
Result Result::asSatisfiabilityResult() const {
  if (d_which == TYPE_SAT) {
    return *this;
  }

  if (d_which == TYPE_VALIDITY) {
    switch (d_validity) {
      case INVALID:
        return Result(SAT, d_inputName);

      case VALID:
        return Result(UNSAT, d_inputName);

      case VALIDITY_UNKNOWN:
        return Result(SAT_UNKNOWN, d_unknownExplanation, d_inputName);

      default:
        Unhandled(d_validity);
    }
  }

  // TYPE_NONE
  return Result(SAT_UNKNOWN, NO_STATUS, d_inputName);
}
Esempio n. 15
0
std::string LogicInfo::getLogicString() const {
  CheckArgument(d_locked, *this, "This LogicInfo isn't locked yet, and cannot be queried");
  if(d_logicString == "") {
    LogicInfo qf_all_supported;
    qf_all_supported.disableQuantifiers();
    qf_all_supported.lock();
    if(hasEverything()) {
      d_logicString = "ALL_SUPPORTED";
    } else if(*this == qf_all_supported) {
      d_logicString = "QF_ALL_SUPPORTED";
    } else {
      size_t seen = 0; // make sure we support all the active theories

      stringstream ss;
      if(!isQuantified()) {
        ss << "QF_";
      }
      if(d_theories[THEORY_ARRAY]) {
        ss << (d_sharingTheories == 1 ? "AX" : "A");
        ++seen;
      }
      if(d_theories[THEORY_UF]) {
        ss << "UF";
        ++seen;
      }
      if(d_theories[THEORY_BV]) {
        ss << "BV";
        ++seen;
      }
      if(d_theories[THEORY_DATATYPES]) {
        ss << "DT";
        ++seen;
      }
      if(d_theories[THEORY_ARITH]) {
        if(isDifferenceLogic()) {
          ss << (areIntegersUsed() ? "I" : "");
          ss << (areRealsUsed() ? "R" : "");
          ss << "DL";
        } else {
          ss << (isLinear() ? "L" : "N");
          ss << (areIntegersUsed() ? "I" : "");
          ss << (areRealsUsed() ? "R" : "");
          ss << "A";
        }
        ++seen;
      }

      if(seen != d_sharingTheories) {
        Unhandled("can't extract a logic string from LogicInfo; at least one "
                  "active theory is unknown to LogicInfo::getLogicString() !");
      }

      if(seen == 0) {
        ss << "SAT";
      }

      d_logicString = ss.str();
    }
  }
  return d_logicString;
}