return n.isConst() && n.getConst<Rational>().sgn() == 0;
}
+Node mkOne(const TypeNode& tn, bool isNeg)
+{
+ return NodeManager::currentNM()->mkConstRealOrInt(tn, isNeg ? -1 : 1);
+}
+
bool isTranscendentalKind(Kind k)
{
// many operators are eliminated during rewriting
/** Is n (integer or real) zero? */
bool isZero(const Node& n);
+/** Make one of the given type, maybe negated */
+Node mkOne(const TypeNode& tn, bool isNeg = false);
+
// Returns an node that is the identity of a select few kinds.
inline Node getIdentityType(const TypeNode& tn, Kind k)
{
const std::vector<Node>& args)
{
NodeManager* nm = NodeManager::currentNM();
- auto zero = nm->mkConst<Rational>(CONST_RATIONAL, 0);
- auto one = nm->mkConst<Rational>(CONST_RATIONAL, 1);
- auto mone = nm->mkConst<Rational>(CONST_RATIONAL, -1);
- auto pi = nm->mkNullaryOperator(nm->realType(), Kind::PI);
- auto mpi = nm->mkNode(Kind::MULT, mone, pi);
Trace("nl-ext-checker") << "Checking " << id << std::endl;
for (const auto& c : children)
{
}
}
}
+ Node zero = nm->mkConstRealOrInt(mon.getType(), Rational(0));
switch (sign)
{
case -1:
#include "expr/node.h"
#include "proof/proof.h"
-#include "theory/arith/arith_msum.h"
+#include "theory/arith/arith_utilities.h"
#include "theory/arith/inference_manager.h"
#include "theory/arith/nl/ext/ext_state.h"
#include "theory/arith/nl/nl_model.h"
namespace nl {
SplitZeroCheck::SplitZeroCheck(Env& env, ExtState* data)
- : EnvObj(env), d_data(data), d_zero_split(d_data->d_env.getUserContext())
+ : EnvObj(env), d_data(data), d_zero_split(userContext())
{
}
Node v = d_data->d_ms_vars[i];
if (d_zero_split.insert(v))
{
- Node eq = rewrite(v.eqNode(d_data->d_zero));
+ Node eq = rewrite(v.eqNode(mkZero(v.getType())));
Node lem = eq.orNode(eq.negate());
CDProof* proof = nullptr;
if (d_data->isProofEnabled())
#include "expr/node.h"
#include "proof/proof.h"
#include "theory/arith/arith_msum.h"
+#include "theory/arith/arith_utilities.h"
#include "theory/arith/inference_manager.h"
#include "theory/arith/nl/ext/ext_state.h"
#include "theory/arith/nl/nl_model.h"
for (unsigned j = 0; j < it->second.size(); j++)
{
Node tc = it->second[j];
- if (tc != d_data->d_one)
+ Node one = mkOne(tc.getType());
+ if (tc != one)
{
Node tc_diff = d_data->d_mdb.getContainsDiffNl(tc, t);
Assert(!tc_diff.isNull());
Assert(false);
return false;
}
- Node val = nm->mkConst(CONST_RATIONAL,
- -c.getConst<Rational>() / b.getConst<Rational>());
+ Node val = nm->mkConstReal(-c.getConst<Rational>() / b.getConst<Rational>());
if (TraceIsOn("nl-ext-cm"))
{
Trace("nl-ext-cm") << "check-model-bound : exact : " << var << " = ";
// to mapping from the linear solver. This ensures that if the nonlinear
// solver assumes that n = 0, then this assumption is recorded in the overall
// model.
- d_arithVal[n] = d_zero;
- return d_zero;
+ Node zero = mkZero(n.getType());
+ d_arithVal[n] = zero;
+ return zero;
}
bool NlModel::hasAssignment(Node v) const
MULT,
nm->mkConstReal(Rational(1)
/ d_mbp_coeff[rr][j].getConst<Rational>()),
- value[t]);
+ nm->mkNode(TO_REAL, value[t]));
value[t] = rewrite(value[t]);
}
// check if new best, if we have not already set it.
Assert(!value[t].isNull() && !best_bound_value[t].isNull());
if (value[t] != best_bound_value[t])
{
- Kind k = rr == 0 ? GEQ : LEQ;
- Node cmp_bound = nm->mkNode(k, value[t], best_bound_value[t]);
- cmp_bound = rewrite(cmp_bound);
// Should be comparing two constant values which should rewrite
// to a constant. If a step failed, we assume that this is not
// the new best bound. We might not be comparing constant
// values (for instance if transcendental functions are
- // involved), in which case we do update the best bound value.
- if (!cmp_bound.isConst() || !cmp_bound.getConst<bool>())
+ // involved), in which case we do not update the best bound value.
+ if (!value[t].isConst() || !best_bound_value[t].isConst())
+ {
+ new_best = false;
+ break;
+ }
+ Rational rt = value[t].getConst<Rational>();
+ Rational brt = best_bound_value[t].getConst<Rational>();
+ bool cmp = rr == 0 ? rt >= brt : rt <= brt;
+ if (!cmp)
{
new_best = false;
break;
Node CegInstantiator::applySubstitution( TypeNode tn, Node n, std::vector< Node >& vars, std::vector< Node >& subs, std::vector< TermProperties >& prop,
std::vector< Node >& non_basic, TermProperties& pv_prop, bool try_coeff ) {
+ NodeManager* nm = NodeManager::currentNM();
n = rewrite(n);
computeProgVars( n );
bool is_basic = canApplyBasicSubstitution( n, non_basic );
pv_prop.d_coeff = rewrite(pv_prop.d_coeff);
Trace("sygus-si-apply-subs-debug") << "Combined coeff : " << pv_prop.d_coeff << std::endl;
std::vector< Node > children;
+ TypeNode type = n.getType();
for( std::map< Node, Node >::iterator it = msum.begin(); it != msum.end(); ++it ){
- Node c_coeff;
- if( !msum_coeff[it->first].isNull() ){
- c_coeff = rewrite(NodeManager::currentNM()->mkConstReal(
- pv_prop.d_coeff.getConst<Rational>()
- / msum_coeff[it->first].getConst<Rational>()));
- }else{
- c_coeff = pv_prop.d_coeff;
+ Rational c_coeff = pv_prop.d_coeff.getConst<Rational>();
+ Node mc = msum_coeff[it->first];
+ if (!mc.isNull())
+ {
+ Assert(mc.isConst());
+ c_coeff = c_coeff / mc.getConst<Rational>();
}
if( !it->second.isNull() ){
- c_coeff = NodeManager::currentNM()->mkNode( MULT, c_coeff, it->second );
+ Assert(it->second.isConst());
+ c_coeff = c_coeff * it->second.getConst<Rational>();
}
- Assert(!c_coeff.isNull());
- Node c;
- if( msum_term[it->first].isNull() ){
- c = c_coeff;
- }else{
- c = NodeManager::currentNM()->mkNode( MULT, c_coeff, msum_term[it->first] );
+ Node c = nm->mkConstRealOrInt(type, c_coeff);
+ Node v = msum_term[it->first];
+ if (!v.isNull())
+ {
+ Assert(v.getType() == type);
+ c = nm->mkNode(MULT, c, v);
}
children.push_back( c );
Trace("sygus-si-apply-subs-debug") << "Add child : " << c << std::endl;
}
- Node nretc = children.size() == 1
- ? children[0]
- : NodeManager::currentNM()->mkNode(ADD, children);
+ Node nretc =
+ children.size() == 1 ? children[0] : nm->mkNode(ADD, children);
nretc = rewrite(nretc);
//ensure that nret does not contain vars
if (!expr::hasSubterm(nretc, vars))