Giter VIP home page Giter VIP logo

scala-smtlib's People

Contributors

chocolatier avatar colder avatar ftc avatar jad-hamza avatar kmn4 avatar lbulej avatar manoskouk avatar mantognini avatar regb avatar samarion avatar zgrannan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

scala-smtlib's Issues

Compatibility issue with newer versions of Z3/SMTLib

System info:

$ z3 -version
Z3 version 4.8.10 - 64 bit

Using the latest commit of scala-smtlib, models are not annotated with the model symbol anymore, for example a model return by the latest z3 is the following:

(
  (define-fun z () Int
    1)
  (define-fun y () Int
    1)
  (define-fun x () Int
    2)
)

While on older version, it was:

(model 
  (define-fun y () Int
    1)
  (define-fun x () Int
    2)
  (define-fun z () Int
    1)
)

No unit test is currently broken because they use hard-coded models.
The fix is quite simple in essence: removing lines 130 to 133 of ParserCommandResponses is enough to get responses to parse again. This has to be mirrored in the printer too.

However, properly fixing it probably requires dealing with both the old and the new format.

Full Code Examples

I appreciate the small examples in the Getting Started section of the README page. Are there full code examples that use scala-smtlib similar to those found in that Getting Started section? I tried browsing through the codebase, but there does not seem to be full examples included. Please correct me if I'm wrong.

Thanks,
Josh

License

I'm working on a couple of projects (some open source, some commercial) that use SMT solvers from Scala. I'd like to avoid re-inventing the wheel and would be interesting in using / contributing to this library. Could you add a LICENSE file to this repo to clarify its licensing terms? Thanks!

Exception CVC4Interpreter.buildDefault

Calling CVC4Interpreter.buildDefault yields an EOFException. However, adding -i or --no-incremental in the parameter list resolves the issue
(tested with CVC4 v1.5)

package org.combinators.cls.smt.examples
import smtlib.interpreters.CVC4Interpreter

object foo extends App {
  def bI: CVC4Interpreter = {
    val executable = "cvc4"
    val args = Array("-q",
      "--produce-models",
      "--no-incremental",
      "--dt-rewrite-error-sel",
      "--print-success",
      "--lang", "smt")
    new CVC4Interpreter(executable, args)
  }
  bI //works
  CVC4Interpreter.buildDefault //fails
}
Exception in thread "main" smtlib.parser.Parser$UnexpectedEOFException: Unexpected end of file. Expected: [OParen]
	at smtlib.parser.ParserCommon.check(ParserCommon.scala:90)
	at smtlib.parser.ParserCommon.check$(ParserCommon.scala:88)
	at smtlib.parser.Parser.check(Parser.scala:8)
	at smtlib.parser.ParserCommandsResponses.parseGenResponse(ParserCommandsResponses.scala:31)
	at smtlib.parser.ParserCommandsResponses.parseGenResponse$(ParserCommandsResponses.scala:27)
	at smtlib.parser.Parser.parseGenResponse(Parser.scala:8)
	at smtlib.interpreters.CVC4Interpreter.<init>(CVC4Interpreter.scala:14)
	at smtlib.interpreters.CVC4Interpreter$.buildDefault(CVC4Interpreter.scala:42)
	at org.combinators.cls.smt.examples.foo$.delayedEndpoint$org$combinators$cls$smt$examples$foo$1(foo.scala:16)
	at org.combinators.cls.smt.examples.foo$delayedInit$body.apply(foo.scala:4)
	at scala.Function0.apply$mcV$sp(Function0.scala:34)
	at scala.Function0.apply$mcV$sp$(Function0.scala:34)
	at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
	at scala.App.$anonfun$main$1$adapted(App.scala:76)
	at scala.collection.immutable.List.foreach(List.scala:389)
	at scala.App.main(App.scala:76)
	at scala.App.main$(App.scala:74)
	at org.combinators.cls.smt.examples.foo$.main(foo.scala:4)
	at org.combinators.cls.smt.examples.foo.main(foo.scala)

Publish most recent version to Maven central

According to mvnrepository, the last published artifact of this library has been 0.2.2-12-g91e7214.

Most notably, support for Scala 2.13 is not yet published on Maven central, while it is supported by the version hosted in this repository.

Are there any plans to publish the latest version?

Stack overflow on pretty-printing

I have an example test with combinatorial explosion (yeah, it sucks I know) which makes scala-smtlib crash due to a stack overflow in the PrettyPrinter methods.

I don't know exactly how this works now in the latest scala versions, but would it be possible to annotate methods for tail recursion or something?

CVC4Interpreter parsing issues regarding DefineFunRec

Just like DefineFunsRec, DefineFunRec also yields 3x success which should be considered in the parseResponseOf function of CVC4Interpreter :

case DefineFunRec(_) =>
 // CVC4 translates definefunrec in three commands per function,
 // and thus emits 3x (success)
 val res = for (i <- 1 to 3) yield {
   parser.parseGenResponse
 }

 res.find(_ != Success).getOrElse(Success)

Integration tests failing

When I run integration tests, I get the following for most of the tests:

smtlib.parser.Parser$UnexpectedEOFException: Unexpected end of file. Expected: [OParen]
[info]   at smtlib.parser.ParserCommon$class.check(ParserCommon.scala:90)

Here is the full output of running sbt it:test. All unit tests pass when running sbt test.

Specs that might be relevant:

  • scala-smtlib commit 3e23701
  • sbt version 0.13.7
  • openjdk version "1.8.0_131"
  • Z3 version 4.5.1
  • CVC4 version 1.5
  • Debian GNU/Linux 8
  • Linux kernel 4.9.0-0.bpo.3-amd64

Pretty printing `SetLogic(ALL)` gives a match error

I am getting the following error:

scala> semantics.HeapConsistencyChecker.test()
scala.MatchError: ALL (of class smtlib.parser.Commands$ALL$)
  at smtlib.printer.TerminalTreesPrinter$class.printLogic(TerminalTreesPrinter.scala:62)
  at smtlib.printer.RecursivePrinter$.printLogic(RecursivePrinter.scala:10)
  at smtlib.printer.RecursivePrinter$.printCommand(RecursivePrinter.scala:162)
  at smtlib.printer.RecursivePrinter$$anonfun$printScript$1.apply(RecursivePrinter.scala:16)
  at smtlib.printer.RecursivePrinter$$anonfun$printScript$1.apply(RecursivePrinter.scala:15)
  at scala.collection.immutable.List.foreach(List.scala:381)
  at smtlib.printer.RecursivePrinter$.printScript(RecursivePrinter.scala:15)
  at smtlib.printer.Printer$class.toString(Printer.scala:27)
  at smtlib.printer.RecursivePrinter$.toString(RecursivePrinter.scala:10)
  at semantics.HeapConsistencyChecker$.test(HeapConsistencyChecker.scala:12)
  ... 43 elided

when trying to run:

object Test {
  import smtlib.parser.Commands._
  import smtlib.parser.Terms._
  import smtlib.theories.Ints._

  def test() {
    val x = QualifiedIdentifier(SimpleIdentifier(SSymbol("x")))
    val y = QualifiedIdentifier(SimpleIdentifier(SSymbol("y")))
    val pf = smtlib.printer.RecursivePrinter.toString(Script(
      List(SetLogic(ALL),
           DeclareFun(SSymbol("x"), Seq(), IntSort()),
           DeclareFun(SSymbol("y"), Seq(), IntSort()),
           Assert(LessThan(NumeralLit(0), Add(x, y))),
           CheckSat()
           ))) //(assert (< 0 (+ x y)))
    print(pf)
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.