// NodeManager::currentNM()->mkNode(kind::GEQ, t[0], d_zero),
// t[0], NodeManager::currentNM()->mkNode(kind::UMINUS, t[0])));
Node num = t[0];
- Node pret = NodeManager::currentNM()->mkNode(kind::STRING_ITOS, num);
+ Node pret = t;//NodeManager::currentNM()->mkNode(kind::STRING_ITOS, num);
Node lenp = NodeManager::currentNM()->mkNode(kind::STRING_LENGTH, pret);
- /*Node lem = NodeManager::currentNM()->mkNode(kind::IFF,
- t.eqNode(NodeManager::currentNM()->mkConst(::CVC4::String("0"))),
- t[0].eqNode(d_zero));
- new_nodes.push_back(lem);*/
+ Node nonneg = NodeManager::currentNM()->mkNode(kind::GEQ, t[0], d_zero);
+ Node lem = NodeManager::currentNM()->mkNode(kind::ITE, nonneg,
+ NodeManager::currentNM()->mkNode(kind::GT, lenp, d_zero),
+ t.eqNode(NodeManager::currentNM()->mkConst( ::CVC4::String("") ))//lenp.eqNode(d_zero)
+ );
+ new_nodes.push_back(lem);
+ //non-neg
Node b1 = NodeManager::currentNM()->mkBoundVar("x", NodeManager::currentNM()->integerType());
Node b1v = NodeManager::currentNM()->mkNode(kind::BOUND_VAR_LIST, b1);
Node g1 = Rewriter::rewrite( NodeManager::currentNM()->mkNode( kind::AND, NodeManager::currentNM()->mkNode( kind::GEQ, b1, d_zero ),
argTypes, NodeManager::currentNM()->integerType()),
"uf type conv M");
- new_nodes.push_back( num.eqNode(NodeManager::currentNM()->mkNode(kind::APPLY_UF, ufP, d_zero)) );
- new_nodes.push_back( NodeManager::currentNM()->mkNode(kind::GT, lenp, d_zero) );
+ lem = num.eqNode(NodeManager::currentNM()->mkNode(kind::APPLY_UF, ufP, d_zero));
+ new_nodes.push_back( lem );
Node ufx = NodeManager::currentNM()->mkNode(kind::APPLY_UF, ufP, b1);
Node ufx1 = NodeManager::currentNM()->mkNode(kind::APPLY_UF, ufP, NodeManager::currentNM()->mkNode(kind::MINUS,b1,one));
Node conc = Rewriter::rewrite( NodeManager::currentNM()->mkNode(kind::AND, svec) );
conc = NodeManager::currentNM()->mkNode( kind::IMPLIES, g1, conc );
conc = NodeManager::currentNM()->mkNode( kind::FORALL, b1v, conc );
+ conc = NodeManager::currentNM()->mkNode( kind::IMPLIES, nonneg, conc );
new_nodes.push_back( conc );
/*conc = Rewriter::rewrite(NodeManager::currentNM()->mkNode(kind::IMPLIES,
}
} else if(node.getKind() == kind::STRING_ITOS) {
if(node[0].isConst()) {
- int i = node[0].getConst<Rational>().getNumerator().toUnsignedInt();
- std::string stmp = static_cast<std::ostringstream*>( &(std::ostringstream() << i) )->str();
- retNode = NodeManager::currentNM()->mkConst( ::CVC4::String(stmp) );
+ std::string stmp = node[0].getConst<Rational>().getNumerator().toString();
+ //std::string stmp = static_cast<std::ostringstream*>( &(std::ostringstream() << node[0]) )->str();
+ if(stmp[0] == '-') {
+ retNode = NodeManager::currentNM()->mkConst( ::CVC4::String("") );
+ } else {
+ retNode = NodeManager::currentNM()->mkConst( ::CVC4::String(stmp) );
+ }
}
} else if(node.getKind() == kind::STRING_STOI) {
if(node[0].isConst()) {
CVC4::String s = node[0].getConst<String>();
- int rt = s.toNumber();
- retNode = NodeManager::currentNM()->mkConst(::CVC4::Rational(rt));
+ if(s.isNumber()) {
+ std::string stmp = s.toString();
+ retNode = NodeManager::currentNM()->mkConst(::CVC4::Rational(stmp.c_str()));
+ } else {
+ retNode = NodeManager::currentNM()->mkConst(::CVC4::Rational(-1));
+ }
} else if(node[0].getKind() == kind::STRING_CONCAT) {
for(unsigned i=0; i<node[0].getNumChildren(); ++i) {
if(node[0][i].isConst()) {
+++ /dev/null
-(set-logic QF_S)\r
-(set-info :status sat)\r
-(set-option :strings-exp true)\r
-\r
-(declare-fun x () String)\r
-(declare-fun y () String)\r
-(declare-fun z () String)\r
-(declare-fun i () Int)\r
-\r
-(assert (>= i 420))\r
-(assert (= x (int.to.str i)))\r
-(assert (= x (str.++ y "0" z)))\r
-(assert (not (= y "")))\r
-(assert (not (= z "")))\r
-\r
-\r
-\r
-(check-sat)
\ No newline at end of file
+++ /dev/null
-(set-logic QF_S)\r
-(set-info :status sat)\r
-(set-option :strings-exp true)\r
-\r
-(declare-fun i () Int)\r
-(declare-fun s () String)\r
-\r
-(assert (< 67 (str.to.int s)))\r
-(assert (= (str.len s) 2))\r
-(assert (not (= s "68")))\r
-\r
-(check-sat)\r
--- /dev/null
+(set-logic QF_S)\r
+(set-info :status sat)\r
+(set-option :strings-exp true)\r
+\r
+(declare-fun x () String)\r
+(declare-fun y () String)\r
+(declare-fun i () Int)\r
+(declare-fun j () Int)\r
+(declare-fun z () String)\r
+\r
+;big num test\r
+(assert (= x (int.to.str 4785582390527685649)))\r
+;should be ""\r
+(assert (= y (int.to.str (- 9))))\r
+\r
+;big num\r
+(assert (= i (str.to.int "783914785582390527685649")))\r
+;should be -1\r
+(assert (= j (str.to.int "-783914785582390527685649")))\r
+\r
+(check-sat)
\ No newline at end of file
--- /dev/null
+(set-logic QF_S)\r
+(set-info :status sat)\r
+(set-option :strings-exp true)\r
+\r
+(declare-fun x () String)\r
+(declare-fun y () String)\r
+(declare-fun z () String)\r
+(declare-fun i () Int)\r
+\r
+(assert (>= i 420))\r
+(assert (= x (int.to.str i)))\r
+(assert (= x (str.++ y "0" z)))\r
+(assert (not (= y "")))\r
+(assert (not (= z "")))\r
+\r
+\r
+\r
+(check-sat)
\ No newline at end of file
--- /dev/null
+(set-logic QF_S)\r
+(set-info :status sat)\r
+(set-option :strings-exp true)\r
+\r
+(declare-fun i () Int)\r
+(declare-fun s () String)\r
+\r
+(assert (< 67 (str.to.int s)))\r
+(assert (= (str.len s) 2))\r
+(assert (not (= s "68")))\r
+\r
+(check-sat)\r