{
Assert(node.getKind() == EQUAL && node[0].getType().isInteger());
- NodeManager* nm = NodeManager::currentNM();
-
// cases where we can solve the equality
- for (unsigned i = 0; i < 2; i++)
- {
- if (node[i].isConst())
- {
- Node on = node[1 - i];
- Kind onk = on.getKind();
- if (onk == STRING_STOI)
- {
- Rational r = node[i].getConst<Rational>();
- int sgn = r.sgn();
- Node onEq;
- std::stringstream ss;
- if (sgn >= 0)
- {
- ss << r.getNumerator();
- }
- Node new_ret = on[0].eqNode(nm->mkConst(String(ss.str())));
- return returnRewrite(node, new_ret, "stoi-solve");
- }
- }
- }
+
+ // notice we cannot rewrite str.to.int(x)=n to x="n" due to leading zeroes.
return node;
}
if(s.isNumber()) {
retNode = nm->mkConst(s.toNumber());
} else {
- retNode = nm->mkConst(::CVC4::Rational(-1));
+ retNode = nm->mkConst(Rational(-1));
}
} else if(node[0].getKind() == kind::STRING_CONCAT) {
for(unsigned i=0; i<node[0].getNumChildren(); ++i) {
regress0/strings/rewrites-re-concat.smt2
regress0/strings/rewrites-v2.smt2
regress0/strings/std2.6.1.smt2
- regress0/strings/stoi-solve.smt2
regress0/strings/str003.smt2
regress0/strings/str004.smt2
regress0/strings/str005.smt2
regress1/strings/issue1684-regex.smt2
regress1/strings/issue2060.smt2
regress1/strings/issue2429-code.smt2
+ regress1/strings/issue2981.smt2
regress1/strings/kaluza-fl.smt2
regress1/strings/loop002.smt2
regress1/strings/loop003.smt2
regress1/strings/replaceall-replace.smt2
regress1/strings/rew-020618.smt2
regress1/strings/stoi-400million.smt2
+ regress1/strings/stoi-solve.smt2
regress1/strings/str-code-sat.smt2
regress1/strings/str-code-unsat-2.smt2
regress1/strings/str-code-unsat-3.smt2
+++ /dev/null
-(set-logic ALL)
-(set-info :status sat)
-(set-option :strings-exp true)
-(declare-fun x () String)
-(assert (= (str.to.int x) 12345))
-(check-sat)
--- /dev/null
+(set-info :smt-lib-version 2.6)
+(set-logic QF_SLIA)
+(set-option :strings-exp true)
+(set-info :status sat)
+(declare-const x String)
+(declare-const y String)
+(declare-const m String)
+(declare-const n String)
+(assert (str.in.re x (re.+ (re.range "0" "9"))))
+(assert (= 0 (str.to.int x)))
+(assert (not (= x "")))
+(assert (not (= x "0")))
+(assert (not (= x "3")))
+(assert (not (= x "T")))
+(assert (not (= x "8")))
+(assert (not (= x "")))
+(assert (not (= x "5")))
+(assert (not (= x "<")))
+(assert (not (= x "N")))
+(check-sat)
--- /dev/null
+(set-logic ALL)
+(set-info :status sat)
+(set-option :strings-exp true)
+(declare-fun x () String)
+(assert (= (str.to.int x) 12345))
+(check-sat)