bool InstStrategySimplex::doInstantiation2( Node f, Node ic, Node term, ArithVar x, InstMatch& m, Node var, bool minus_delta ){ // make term ( beta - term )/coeff bool vIsInteger = var.getType().isInteger(); Node beta = getTableauxValue( x, minus_delta ); if( !vIsInteger || beta.getType().isInteger() ){ Node instVal = NodeManager::currentNM()->mkNode( MINUS, beta, term ); if( !d_ceTableaux[ic][x][var].isNull() ){ if( vIsInteger ){ Assert( d_ceTableaux[ic][x][var]==NodeManager::currentNM()->mkConst( Rational(-1) ) ); instVal = NodeManager::currentNM()->mkNode( MULT, d_ceTableaux[ic][x][var], instVal ); }else{ Assert( d_ceTableaux[ic][x][var].getKind()==CONST_RATIONAL ); Node coeff = NodeManager::currentNM()->mkConst( Rational(1) / d_ceTableaux[ic][x][var].getConst<Rational>() ); instVal = NodeManager::currentNM()->mkNode( MULT, coeff, instVal ); } } instVal = Rewriter::rewrite( instVal ); //use as instantiation value for var int vn = var.getAttribute(InstVarNumAttribute()); m.setValue( vn, instVal ); Debug("quant-arith") << "Add instantiation " << m << std::endl; return d_quantEngine->addInstantiation( f, m ); }else{ return false; } }
Node BvToBoolPreprocessor::liftNode(TNode current) { Node result; if (hasLiftCache(current)) { result = getLiftCache(current); }else if (isConvertibleBvAtom(current)) { result = convertBvAtom(current); addToLiftCache(current, result); } else { if (current.getNumChildren() == 0) { result = current; } else { NodeBuilder<> builder(current.getKind()); if (current.getMetaKind() == kind::metakind::PARAMETERIZED) { builder << current.getOperator(); } for (unsigned i = 0; i < current.getNumChildren(); ++i) { Node converted = liftNode(current[i]); Assert (converted.getType() == current[i].getType()); builder << converted; } result = builder; addToLiftCache(current, result); } } Assert (result != Node()); Assert(result.getType() == current.getType()); Debug("bv-to-bool") << "BvToBoolPreprocessor::liftNode " << current << " => \n" << result << "\n"; return result; }
Node AbstractionModule::reverseAbstraction(Node assertion, NodeNodeMap& seen) { if (seen.find(assertion) != seen.end()) return seen[assertion]; if (isAbstraction(assertion)) { Node interp = getInterpretation(assertion); seen[assertion] = interp; Assert (interp.getType() == assertion.getType()); return interp; } if (assertion.getNumChildren() == 0) { seen[assertion] = assertion; return assertion; } NodeBuilder<> result(assertion.getKind()); if (assertion.getMetaKind() == kind::metakind::PARAMETERIZED) { result << assertion.getOperator(); } for (unsigned i = 0; i < assertion.getNumChildren(); ++i) { result << reverseAbstraction(assertion[i], seen); } Node res = result; seen[assertion] = res; return res; }
/** Match one argument to the corresponding parameter. */ void matchArg(Node & arg, Node par) { Node argType = arg->getType(); Node parType = par->getType(); if (argType->isPort() && parType->isPort()) { PortKind argPK = arg->getPortKind(); Node argProt = argType->getProtocol(); PortKind parPK = par->getPortKind(); Node parProt = parType->getProtocol(); bool protsat = true; if (parPK == SERVER && ! satisfies(parProt->getLTS(), argProt->getLTS())) { Error() << "Parameter protocol" << par->getPos() << "does not satisfy argument protocol" << arg->getPos() << REPORT; protsat = false; } else if (parPK == CLIENT && ! satisfies(argProt->getLTS(), parProt->getLTS())) { Error() << "Argument protocol" << arg->getPos() << "does not satisfy parameter protocol" << par->getPos() << REPORT; protsat = false; } if (protsat) { set<Node> fields = merge(argProt->getFieldDecs(), parProt->getFieldDecs()); for (set<Node>::iterator i = fields.begin(); i != fields.end(); ++i) for (set<Node>::iterator j = i; j != fields.end(); ++j) if (i != j && (*i)->getNameString() == (*j)->getNameString()) { // cerr << "Tieing " << (*i)->getNameString() << " and " << (*j)->getNameString() << endl; // 090207 Node t = (*i)->getTie(); (*i)->setTie((*j)->getTie()); (*j)->setTie(t); } } } else if (argType->isPort()) Error() << "Argument is a port ..." << arg->getPos() << "... but parameter is not." << par->getPos() << REPORT; else if (parType->isPort()) Error() << "Parameter is a port ..." << par->getPos() << "... but argument is not." << arg->getPos() << REPORT; else if (par->isAlias()) { if ( ! sameType(argType, parType)) Error() << "Argument ..." << arg->getPos() << "... does not match parameter." << par->getPos() << REPORT; else if (arg->kind() == NAME_NODE) { if (arg->isConstant()) // 090228 Error() << "A constant ..." << arg->getPos() << "... cannot be passed as an alias" << par->getPos() << REPORT; if ( ! arg->isAlias()) // 081206 arg->setPassByReference(); } else Error() << "Argument must be a name ..." << arg->getPos() << "... to match aliased parameter" << par->getPos() << REPORT; } else coerce(argType, parType, arg); }
Node ArithInstantiator::getModelBasedProjectionValue( CegInstantiator * ci, Node e, Node t, bool isLower, Node c, Node me, Node mt, Node theta, Node inf_coeff, Node delta_coeff ) { Node val = t; Trace("cbqi-bound2") << "Value : " << val << std::endl; Assert( !e.getType().isInteger() || t.getType().isInteger() ); Assert( !e.getType().isInteger() || mt.getType().isInteger() ); //add rho value //get the value of c*e Node ceValue = me; Node new_theta = theta; if( !c.isNull() ){ Assert( c.getType().isInteger() ); ceValue = NodeManager::currentNM()->mkNode( MULT, ceValue, c ); ceValue = Rewriter::rewrite( ceValue ); if( new_theta.isNull() ){ new_theta = c; }else{ new_theta = NodeManager::currentNM()->mkNode( MULT, new_theta, c ); new_theta = Rewriter::rewrite( new_theta ); } Trace("cbqi-bound2") << "...c*e = " << ceValue << std::endl; Trace("cbqi-bound2") << "...theta = " << new_theta << std::endl; } if( !new_theta.isNull() && e.getType().isInteger() ){ Node rho; //if( !mt.getType().isInteger() ){ //round up/down //mt = NodeManager::currentNM()->mkNode( //} if( isLower ){ rho = NodeManager::currentNM()->mkNode( MINUS, ceValue, mt ); }else{ rho = NodeManager::currentNM()->mkNode( MINUS, mt, ceValue ); } rho = Rewriter::rewrite( rho ); Trace("cbqi-bound2") << "...rho = " << me << " - " << mt << " = " << rho << std::endl; Trace("cbqi-bound2") << "..." << rho << " mod " << new_theta << " = "; rho = NodeManager::currentNM()->mkNode( INTS_MODULUS_TOTAL, rho, new_theta ); rho = Rewriter::rewrite( rho ); Trace("cbqi-bound2") << rho << std::endl; Kind rk = isLower ? PLUS : MINUS; val = NodeManager::currentNM()->mkNode( rk, val, rho ); val = Rewriter::rewrite( val ); Trace("cbqi-bound2") << "(after rho) : " << val << std::endl; } if( !inf_coeff.isNull() ){ Assert( !d_vts_sym[0].isNull() ); val = NodeManager::currentNM()->mkNode( PLUS, val, NodeManager::currentNM()->mkNode( MULT, inf_coeff, d_vts_sym[0] ) ); val = Rewriter::rewrite( val ); } if( !delta_coeff.isNull() ){ //create delta here if necessary val = NodeManager::currentNM()->mkNode( PLUS, val, NodeManager::currentNM()->mkNode( MULT, delta_coeff, ci->getQuantifiersEngine()->getTermDatabase()->getVtsDelta() ) ); val = Rewriter::rewrite( val ); } return val; }
Node* NodeList::addOrUpdateNode(sockaddr* publicSocket, sockaddr* localSocket, char nodeType, uint16_t nodeId) { NodeList::iterator node = end(); if (publicSocket) { for (node = begin(); node != end(); node++) { if (node->matches(publicSocket, localSocket, nodeType)) { // we already have this node, stop checking break; } } } if (node == end()) { // if we already had this node AND it's a solo type then bust out of here if (soloNodeOfType(nodeType)) { return NULL; } // we didn't have this node, so add them Node* newNode = new Node(publicSocket, localSocket, nodeType, nodeId); if (socketMatch(publicSocket, localSocket)) { // likely debugging scenario with two nodes on local network // set the node active right away newNode->activatePublicSocket(); } if (newNode->getType() == NODE_TYPE_VOXEL_SERVER || newNode->getType() == NODE_TYPE_AVATAR_MIXER || newNode->getType() == NODE_TYPE_AUDIO_MIXER) { // this is currently the cheat we use to talk directly to our test servers on EC2 // to be removed when we have a proper identification strategy newNode->activatePublicSocket(); } addNodeToList(newNode); return newNode; } else { if (node->getType() == NODE_TYPE_AUDIO_MIXER || node->getType() == NODE_TYPE_VOXEL_SERVER) { // until the Audio class also uses our nodeList, we need to update // the lastRecvTimeUsecs for the audio mixer so it doesn't get killed and re-added continously node->setLastHeardMicrostamp(usecTimestampNow()); } // we had this node already, do nothing for now return &*node; } }
Node *Node::nextTraversalByType(const char *typeString) { if (typeString == NULL) return NULL; String type(typeString); for (Node *node = nextTraversal(); node != NULL; node = node->nextTraversal()) { if (node->getType() != NULL) { if (type.compareTo(node->getType()) == 0) return node; } } return NULL; }
bool QuantifiersEngine::addSplitEquality( Node n1, Node n2, bool reqPhase, bool reqPhasePol ){ //Assert( !areEqual( n1, n2 ) ); //Assert( !areDisequal( n1, n2 ) ); Kind knd = n1.getType()==NodeManager::currentNM()->booleanType() ? IFF : EQUAL; Node fm = NodeManager::currentNM()->mkNode( knd, n1, n2 ); return addSplit( fm ); }
void FirstOrderModel::initializeModelForTerm( Node n ){ if( n.getKind()==APPLY_UF ){ Node op = n.getOperator(); if( d_uf_model_tree.find( op )==d_uf_model_tree.end() ){ TypeNode tn = op.getType(); tn = tn[ (int)tn.getNumChildren()-1 ]; //only generate models for predicates and functions with uninterpreted range types if( tn==NodeManager::currentNM()->booleanType() || tn.isSort() ){ d_uf_model_tree[ op ] = uf::UfModelTree( op ); d_uf_model_gen[ op ].clear(); } } } /* if( n.getType().isArray() ){ while( n.getKind()==STORE ){ n = n[0]; } Node nn = getRepresentative( n ); if( d_array_model.find( nn )==d_array_model.end() ){ d_array_model[nn] = arrays::ArrayModel( nn, this ); } } */ for( int i=0; i<(int)n.getNumChildren(); i++ ){ initializeModelForTerm( n[i] ); } }
Node AbstractionModule::abstractSignatures(TNode assertion) { Debug("bv-abstraction") << "AbstractionModule::abstractSignatures "<< assertion <<"\n"; // assume the assertion has been fully abstracted Node signature = getGeneralizedSignature(assertion); Debug("bv-abstraction") << " with sig "<< signature <<"\n"; NodeNodeMap::iterator it = d_signatureToFunc.find(signature); if (it!= d_signatureToFunc.end()) { std::vector<Node> args; TNode func = it->second; // pushing the function symbol args.push_back(func); TNodeSet seen; collectArguments(assertion, signature, args, seen); std::vector<TNode> real_args; for (unsigned i = 1; i < args.size(); ++i) { real_args.push_back(args[i]); } d_argsTable.addEntry(func, real_args); Node result = utils::mkNode(kind::EQUAL, utils::mkNode(kind::APPLY_UF, args), utils::mkConst(1, 1u)); Debug("bv-abstraction") << "=> "<< result << "\n"; Assert (result.getType() == assertion.getType()); return result; } return assertion; }
void BvToBoolPreprocessor::addToBoolCache(TNode term, Node new_term) { Assert (new_term != Node()); Assert (!hasBoolCache(term)); Assert (utils::getSize(term) == 1); Assert (new_term.getType().isBoolean()); d_boolCache[term] = new_term; }
void ArrayInfo::addIndex(const Node a, const TNode i) { Assert(a.getType().isArray()); Assert(!i.getType().isArray()); // temporary for flat arrays Trace("arrays-ind")<<"Arrays::addIndex "<<a<<"["<<i<<"]\n"; CTNodeList* temp_indices; Info* temp_info; CNodeInfoMap::iterator it = info_map.find(a); if(it == info_map.end()) { temp_indices = new(true) CTNodeList(ct); temp_indices->push_back(i); temp_info = new Info(ct, bck); temp_info->indices = temp_indices; info_map[a] = temp_info; } else { temp_indices = (*it).second->indices; if (! inList(temp_indices, i)) { temp_indices->push_back(i); } } if(Trace.isOn("arrays-ind")) { printList((*(info_map.find(a))).second->indices); } }
void Tetgen::cleanBadTetra(double min_value) { Node* nd; Tetra* itet; double mindens,minvolm; mindens = cr_crowd->getCurrentMinDensity(); minvolm = mindens * mindens * mindens * rate_minvolm; int n = getSize(); for(int i = 0; i < n; i++) { itet = getTetra(i); if(itet->getVolume() > minvolm && itet->getValue() > min_value) continue; for(int j = 0; j < 4; j++) { nd = itet->getNode(j); if(nd->getType() == 0 ) continue; if(eraseNode(nd)) break; } n = getSize(); } }
void BVToBool::addToLiftCache(TNode term, Node new_term) { Assert(new_term != Node()); Assert(!hasLiftCache(term)); Assert(term.getType() == new_term.getType()); d_liftCache[term] = new_term; }
void Signatures::createA_Sig(vector<Node*> vNodes){ for (int i=0;i< nets.size();i++){ SetNode net = nets[i]; /* * Generates A_Sign_NES */ //Get Net_Pred SetNode net_pred = nets_pred[i]; SetNode a_sign_nes; if(!net_pred.empty()) a_sign_nes = net_pred; A_sig_NES.push_back(a_sign_nes); /* * Generates A_Sign_NS */ SetNode netAux; for (SetNode::iterator ni = net.begin(); ni != net.end(); ni++) { Node *node = *ni; if(node->getType()== typeA){ netAux.insert(node); } } A_sig_NS.push_back(netAux); } }
CandidateGeneratorQEAll::CandidateGeneratorQEAll( QuantifiersEngine* qe, Node mpat ) : d_match_pattern( mpat ), d_qe( qe ){ d_match_pattern_type = mpat.getType(); Assert( mpat.getKind()==INST_CONSTANT ); d_f = quantifiers::TermDb::getInstConstAttr( mpat ); d_index = mpat.getAttribute(InstVarNumAttribute()); }
Node DynamicRewriter::OpInternalSymTrie::getSymbol(Node n) { std::vector<TypeNode> ctypes; for (const Node& cn : n) { ctypes.push_back(cn.getType()); } ctypes.push_back(n.getType()); OpInternalSymTrie* curr = this; for (unsigned i = 0, size = ctypes.size(); i < size; i++) { curr = &(curr->d_children[ctypes[i]]); } if (!curr->d_sym.isNull()) { return curr->d_sym; } // make UF operator TypeNode utype; if (ctypes.size() == 1) { utype = ctypes[0]; } else { utype = NodeManager::currentNM()->mkFunctionType(ctypes); } Node f = NodeManager::currentNM()->mkSkolem( "ufd", utype, "internal op for dynamic_rewriter"); curr->d_sym = f; return f; }
Node *Node::next(const int type) const { for (Node *node = next(); node != NULL; node = node->next()) { if (node->getType() == type) return node; } return NULL; }
void BVToBool::addToBoolCache(TNode term, Node new_term) { Assert(new_term != Node()); Assert(!hasBoolCache(term)); Assert(bv::utils::getSize(term) == 1); Assert(new_term.getType().isBoolean()); d_boolCache[term] = new_term; }
int InstStrategySimplex::process( Node f, Theory::Effort effort, int e ){ if( e<2 ){ return STATUS_UNFINISHED; }else if( e==2 ){ //Notice() << f << std::endl; //Notice() << "Num inst rows = " << d_th->d_instRows[f].size() << std::endl; //Notice() << "Num inst constants = " << d_quantEngine->getNumInstantiationConstants( f ) << std::endl; for( int i=0; i<d_quantEngine->getTermDatabase()->getNumInstantiationConstants( f ); i++ ){ Node ic = d_quantEngine->getTermDatabase()->getInstantiationConstant( f, i ); Debug("quant-arith-simplex") << "InstStrategySimplex check " << ic << ", rows = " << d_instRows[ic].size() << std::endl; for( int j=0; j<(int)d_instRows[ic].size(); j++ ){ ArithVar x = d_instRows[ic][j]; if( !d_ceTableaux[ic][x].empty() ){ Debug("quant-arith-simplex") << "Check row " << ic << " " << x << std::endl; //instantiation row will be A*e + B*t = beta, // where e is a vector of terms , and t is vector of ground terms. // Say one term in A*e is coeff*e_i, where e_i is an instantiation constant // We will construct the term ( beta - B*t)/coeff to use for e_i. InstMatch m; //By default, choose the first instantiation constant to be e_i. Node var = d_ceTableaux[ic][x].begin()->first; if( var.getType().isInteger() ){ std::map< Node, Node >::iterator it = d_ceTableaux[ic][x].begin(); //try to find coefficent that is +/- 1 while( !var.isNull() && !d_ceTableaux[ic][x][var].isNull() && d_ceTableaux[ic][x][var]!=d_negOne ){ ++it; if( it==d_ceTableaux[ic][x].end() ){ var = Node::null(); }else{ var = it->first; } } //otherwise, try one that divides all ground term coefficients? DO_THIS } if( !var.isNull() ){ Debug("quant-arith-simplex") << "Instantiate with var " << var << std::endl; doInstantiation( f, ic, d_tableaux_term[ic][x], x, m, var ); }else{ Debug("quant-arith-simplex") << "Could not find var." << std::endl; } ////choose a new variable based on alternation strategy //int index = d_counter%(int)d_th->d_ceTableaux[x].size(); //Node var; //for( std::map< Node, Node >::iterator it = d_th->d_ceTableaux[x].begin(); it != d_th->d_ceTableaux[x].end(); ++it ){ // if( index==0 ){ // var = it->first; // break; // } // index--; //} //d_th->doInstantiation( f, d_th->d_tableaux_term[x], x, &m, var ); } } } } return STATUS_UNKNOWN; }
Node *Node::next(const char *typeString) { String type(typeString); for (Node *node = next(); node != NULL; node = node->next()) { if (type.compareTo(node->getType()) == 0) return node; } return NULL; }
Node *SceneGraph::getNodes(const int type) const { Node *node = getNodes(); if (node == NULL) return NULL; if (node->getType() == type) return node; return node->next(type); }
/** Coerce 'expr' from type 'fromType' to type 'toType'. */ void coerce(Node fromType, Node toType, Node & expr) { // expr->showDebug("coerce"); // 090817 // fromType->showDebug("from"); // 090817 // toType->showDebug("to"); // 090817 if (expr->kind() == NUM_NODE && expr->getType() == BaseNode::theIntegerNode) { int val = expr->getIntVal(); if (toType == BaseNode::theUnsignedIntegerNode && val < 0) { Error() << "Literal cannot be converted to unsigned Integer." << expr->getPos() << REPORT; return; } else if (toType == BaseNode::theByteNode && (val < -128 || val > 127)) { Error() << "Literal cannot be converted to Byte." << expr->getPos() << REPORT; return; } else if (toType == BaseNode::theUnsignedByteNode && (val < 0 || val > 255)) { Error() << "Literal cannot be converted to Unsigned Byte." << expr->getPos() << REPORT; return; } } if (expr->kind() == CHAR_NODE && toType == BaseNode::theTextNode) { expr = new TextNode(expr->getPos(), expr->getConstValue()); return; } // Integer can be converted to Enumeration. if (isIntType(fromType) && toType->isEnumType()) { List args; args.push_back(toType); args.push_back(expr); expr = new FunctionNode(expr->getPos(), funIntegerEnum, args); return; } FuncDef *fun = getConversion(fromType, toType); if (fun == funIdentity) return; if (fun == funBottom) { Error() << "Expression cannot be coerced to required type." << expr->getPos() << REPORT; return; } List args; args.push_back(expr); expr = new FunctionNode(expr->getPos(), fun, args); }
bool RepSetIterator::setFunctionDomain( Node op, RepBoundExt* rext ){ Trace("rsi") << "Make rsi for " << op << std::endl; Assert( d_types.empty() ); TypeNode tn = op.getType(); for( size_t i=0; i<tn.getNumChildren()-1; i++ ){ d_types.push_back( tn[i] ); } d_owner = op; return initialize( rext ); }
qint64 LimitedNodeList::sendPacket(std::unique_ptr<NLPacket> packet, const Node& destinationNode) { Q_ASSERT(!packet->isPartOfMessage()); if (!destinationNode.getActiveSocket()) { return 0; } emit dataSent(destinationNode.getType(), packet->getDataSize()); destinationNode.recordBytesSent(packet->getDataSize()); return sendPacket(std::move(packet), *destinationNode.getActiveSocket(), destinationNode.getConnectionSecret()); }
std::vector<Node*> UsesTable::getUsers(synt_type st) { std::vector<Node*> users; for(std::unordered_map<Node*, std::vector<Node*>>::iterator it = table.begin(); it != table.end(); ++it) { Node* node = it->first; synt_type nt = node->getType(); if (nt == st || (st == statement && (nt == assignment || nt == ifelse || nt == whileLoop))) { users.push_back(node); } } return users; }
BoundedIntegers::IntRangeModel::IntRangeModel(BoundedIntegers * bi, Node r, context::Context* c, context::Context* u, bool isProxy) : d_bi(bi), d_range(r), d_curr_max(-1), d_lit_to_range(u), d_range_assertions(c), d_has_range(c,false), d_curr_range(c,-1), d_ranges_proxied(u) { if( options::fmfBoundIntLazy() ){ d_proxy_range = isProxy ? r : NodeManager::currentNM()->mkSkolem( "pbir", r.getType() ); }else{ d_proxy_range = r; } if( !isProxy ){ Trace("bound-int") << "Introduce proxy " << d_proxy_range << " for " << d_range << std::endl; } }
QDebug operator<<(QDebug debug, const Node &node) { char publicAddressBuffer[16] = {'\0'}; unsigned short publicAddressPort = loadBufferWithSocketInfo(publicAddressBuffer, node.getPublicSocket()); //char localAddressBuffer[16] = {'\0'}; //unsigned short localAddressPort = loadBufferWithSocketInfo(localAddressBuffer, node.localSocket); debug << "#" << node.getNodeID() << node.getTypeName() << node.getType(); debug.nospace() << publicAddressBuffer << ":" << publicAddressPort; return debug.nospace(); }
Node CandidateGeneratorQEAll::getNextCandidate() { while( !d_eq.isFinished() ){ Node n = (*d_eq); ++d_eq; if( n.getType()==d_match_pattern.getType() ){ //an equivalence class with the same type as the pattern, return it return n; } } return Node::null(); }
Node CandidateGeneratorQELitEq::getNextCandidate(){ while( !d_eq.isFinished() ){ Node n = (*d_eq); ++d_eq; if( n.getType().isSubtypeOf( d_match_pattern[0].getType() ) ){ //an equivalence class with the same type as the pattern, return reflexive equality return NodeManager::currentNM()->mkNode( d_match_pattern.getKind(), n, n ); } } return Node::null(); }