Skip to content

Commit 22de8d6

Browse files
authored
Merge pull request #145 from jad-hamza/strpp
Stop Z3 zombies and add support for str.++
2 parents cd9632a + 165133d commit 22de8d6

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/main/scala/inox/solvers/SolverFactory.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ object SolverFactory {
3636
import _root_.smtlib.interpreters._
3737

3838
lazy val hasZ3 = try {
39-
new Z3Interpreter("z3", Array("-in", "-smt2"))
39+
new Z3Interpreter("z3", Array("-in", "-smt2")).interrupt()
4040
true
4141
} catch {
4242
case _: java.io.IOException => false
4343
}
4444

4545
lazy val hasCVC4 = try {
46-
new CVC4Interpreter("cvc4", Array("-q", "--lang", "smt2.5"))
46+
new CVC4Interpreter("cvc4", Array("-q", "--lang", "smt2.5")).interrupt()
4747
true
4848
} catch {
4949
case _: java.io.IOException => false
@@ -131,7 +131,7 @@ object SolverFactory {
131131
case None if noPrefixName.startsWith("smt-z3:") =>
132132
val z3Exec = getZ3Executable(noPrefixName)
133133
val hasZ3Exec = try {
134-
new Z3Interpreter(z3Exec, Array("-in", "-smt2"))
134+
new Z3Interpreter(z3Exec, Array("-in", "-smt2")).interrupt()
135135
true
136136
} catch {
137137
case _: java.io.IOException => false

src/main/scala/inox/solvers/smtlib/Z3Target.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ trait Z3Target extends SMTLIBTarget with SMTLIBDebugger {
153153
case (FunctionApplication(QualifiedIdentifier(SimpleIdentifier(SSymbol("seq.unit")), None), Seq(SHexadecimal(hex))), _) =>
154154
StringLiteral(utils.StringUtils.decode(hex.repr))
155155

156+
case (FunctionApplication(QualifiedIdentifier(SimpleIdentifier(SSymbol("str.++")), None), strs), _) =>
157+
val strings = strs.map(fromSMT(_, Some(StringType())))
158+
if (strings.isEmpty) StringLiteral("")
159+
else strings.tail.foldRight(strings.head)(StringConcat(_, _))
160+
156161
case (QualifiedIdentifier(ExtendedIdentifier(SSymbol("as-array"), k: SSymbol), _), Some(tpe @ MapType(keyType, valueType))) =>
157162
val Some(Lambda(Seq(arg), body)) = context.getFunction(k, FunctionType(Seq(keyType), valueType))
158163

src/main/scala/inox/solvers/unrolling/UnrollingSolver.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ trait AbstractUnrollingSolver extends Solver { self =>
831831
}).recover {
832832
case e @ (_: InternalSolverError | _: Unsupported) =>
833833
if (reporter.isDebugEnabled) reporter.debug(e)
834-
else if (!silentErrors) reporter.error(e.getMessage)
834+
else if (!silentErrors && !abort) reporter.error(e.getMessage)
835835
config.cast(Unknown)
836836
}.get)
837837
}

0 commit comments

Comments
 (0)