Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for STP and Yices2 solvers #272

Closed
wants to merge 13 commits into from
20 changes: 19 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,25 @@ jobs:
ninja &&
popd &&
popd &&
cp bitwuzla/build/src/main/bitwuzla bin/
cp bitwuzla/build/src/main/bitwuzla bin/ &&
sudo apt-get install -y git cmake bison flex libboost-all-dev python2 perl &&
git clone https://github.com/stp/stp &&
pushd stp &&
git submodule init && git submodule update &&
./scripts/deps/setup-gtest.sh &&
./scripts/deps/setup-outputcheck.sh &&
./scripts/deps/setup-cms.sh &&
./scripts/deps/setup-minisat.sh &&
mkdir build &&
pushd build &&
cmake .. &&
cmake --build . &&
popd &&
popd &&
cp stp/build/stp bin/stp &&
sudo add-apt-repository -y ppa:sri-csl/formal-methods &&
sudo apt-get update &&
sudo apt-get install -y yices2
- name: Install Rosette
run: raco pkg install --auto --name rosette
- name: Compile Rosette tests
Expand Down
69 changes: 69 additions & 0 deletions rosette/solver/smt/stp.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#lang racket

(require racket/runtime-path
"server.rkt" "env.rkt"
"../solver.rkt"
(prefix-in base/ "base-solver.rkt"))

(provide (rename-out [make-stp stp]) stp? stp-available?)

(define-runtime-path stp-path (build-path ".." ".." ".." "bin" "stp"))
(define stp-opts '("--SMTLIB2" "-p"))

(define (stp-available?)
(not (false? (base/find-solver "stp" stp-path #f))))

(define (make-stp [solver #f] #:options [options (hash)] #:logic [logic #f] #:path [path #f])
(define config
(cond
[(stp? solver)
(base/solver-config solver)]
[else
(define real-stp-path (base/find-solver "stp" stp-path path))
(when (and (false? real-stp-path) (not (getenv "PLT_PKG_BUILD_SERVICE")))
(error 'stp "stp binary is not available (expected to be at ~a); try passing the #:path argument to (stp)" (path->string (simplify-path stp-path))))
(base/config options real-stp-path logic)]))
(stp (server (base/config-path config) stp-opts (base/make-send-options config)) config '() '() '() (env) '()))

(struct stp base/solver ()
#:property prop:solver-constructor make-stp
#:methods gen:custom-write
[(define (write-proc self port mode) (fprintf port "#<stp>"))]
#:methods gen:solver
[
(define (solver-features self)
'(qf_bv))

(define (solver-options self)
(base/solver-options self))

(define (solver-assert self bools)
(base/solver-assert self bools))

(define (solver-minimize self nums)
(base/solver-minimize self nums))

(define (solver-maximize self nums)
(base/solver-maximize self nums))

(define (solver-clear self)
(base/solver-clear self))

(define (solver-shutdown self)
(base/solver-shutdown self))

(define (solver-push self)
(base/solver-push self))

(define (solver-pop self [k 1])
(base/solver-pop self k))

(define (solver-check self)
(base/solver-check self))

(define (solver-debug self)
(base/solver-debug self))])

(define (set-default-options server)
void)

69 changes: 69 additions & 0 deletions rosette/solver/smt/yices-smt2.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#lang racket

(require racket/runtime-path
"server.rkt" "env.rkt"
"../solver.rkt"
(prefix-in base/ "base-solver.rkt"))

(provide (rename-out [make-yices-smt2 yices-smt2]) yices-smt2? yices-smt2-available?)

(define-runtime-path yices-smt2-path (build-path ".." ".." ".." "bin" "yices-smt2"))
(define yices-smt2-opts '("--incremental"))

(define (yices-smt2-available?)
(not (false? (base/find-solver "yices-smt2" yices-smt2-path #f))))
(define default-logic 'QF_BV) ;; YICES_2 needs a default logic set otherwise it will error
(define (make-yices-smt2 [solver #f] #:options [options (hash)] #:logic [logic default-logic] #:path [path #f])
(define config
(cond
[(yices-smt2? solver)
(base/solver-config solver)]
[else
(define real-yices-smt2-path (base/find-solver "yices-smt2" yices-smt2-path path))
(when (and (false? real-yices-smt2-path) (not (getenv "PLT_PKG_BUILD_SERVICE")))
(error 'yices-smt2 "yices-smt2 binary is not available (expected to be at ~a); try passing the #:path argument to (yices-smt2)" (path->string (simplify-path yices-smt2-path))))
(base/config options real-yices-smt2-path logic)]))
(yices-smt2 (server (base/config-path config) yices-smt2-opts (base/make-send-options config)) config '() '() '() (env) '()))

(struct yices-smt2 base/solver ()
#:property prop:solver-constructor make-yices-smt2
#:methods gen:custom-write
[(define (write-proc self port mode) (fprintf port "#<yices-smt2>"))]
#:methods gen:solver
[
(define (solver-features self)
'(qf_bv))

(define (solver-options self)
(base/solver-options self))

(define (solver-assert self bools)
(base/solver-assert self bools))

(define (solver-minimize self nums)
(base/solver-minimize self nums))

(define (solver-maximize self nums)
(base/solver-maximize self nums))

(define (solver-clear self)
(base/solver-clear self))

(define (solver-shutdown self)
(base/solver-shutdown self))

(define (solver-push self)
(base/solver-push self))

(define (solver-pop self [k 1])
(base/solver-pop self k))

(define (solver-check self)
(base/solver-check self))

(define (solver-debug self)
(base/solver-debug self))])

(define (set-default-options server)
void)

108 changes: 58 additions & 50 deletions test/all-rosette-tests.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
rosette/solver/smt/boolector
rosette/solver/smt/cvc5
rosette/solver/smt/bitwuzla
rosette/solver/smt/stp
rosette/solver/smt/yices-smt2
"config.rkt")

(error-print-width default-error-print-width)


Expand All @@ -19,39 +20,39 @@


(require-all-tests
"base/type.rkt"
"base/term.rkt"
"base/bool.rkt"
"base/merge.rkt"
"base/store.rkt"
"base/vc.rkt"
"base/eval-guarded.rkt"
"base/list.rkt"
"base/vector.rkt"
"base/bvseq.rkt"
"base/forall.rkt"
"base/bitvector.rkt"
"base/bvlib.rkt"
"base/equality.rkt"
"base/uninterpreted.rkt"
"base/real.rkt"
"base/quantified.rkt"
"base/finitize.rkt"
"base/distinct.rkt"
"base/generics.rkt"
; "base/type.rkt"
; "base/term.rkt"
; "base/bool.rkt"
; "base/merge.rkt"
; "base/store.rkt"
; "base/vc.rkt"
; "base/eval-guarded.rkt"
; "base/list.rkt"
; "base/vector.rkt"
; "base/bvseq.rkt"
; "base/forall.rkt"
; "base/bitvector.rkt"
; "base/bvlib.rkt"
; "base/equality.rkt"
; "base/uninterpreted.rkt"
; "base/real.rkt"
; "base/quantified.rkt"
; "base/finitize.rkt"
; "base/distinct.rkt"
; "base/generics.rkt"
"base/push-pop.rkt"
"base/optimize-order.rkt"
"base/reflect.rkt"
"base/decode.rkt"
"query/solve.rkt"
"query/verify.rkt"
"query/synthesize.rkt"
"query/solve+.rkt"
"query/synthax.rkt"
"query/grammar.rkt"
"query/optimize.rkt"
"lib/destruct.rkt"
"profile/test.rkt"
; "base/optimize-order.rkt"
; "base/reflect.rkt"
; "base/decode.rkt"
; "query/solve.rkt"
; "query/verify.rkt"
; "query/synthesize.rkt"
; "query/solve+.rkt"
; "query/synthax.rkt"
; "query/grammar.rkt"
; "query/optimize.rkt"
; "lib/destruct.rkt"
; "profile/test.rkt"
"trace/test.rkt")


Expand All @@ -76,23 +77,30 @@


(define (slow-tests)
(when (cvc4-available?)
(printf "===== Running CVC4 tests =====\n")
(run-tests-with-solver cvc4))

(when (boolector-available?)
(printf "===== Running Boolector tests =====\n")
(run-tests-with-solver boolector))

(when (cvc5-available?)
(printf "===== Running cvc5 tests =====\n")
(run-tests-with-solver cvc5))

(when (bitwuzla-available?)
(printf "===== Running bitwuzla tests =====\n")
(run-tests-with-solver bitwuzla))
; (when (cvc4-available?)
; (printf "===== Running CVC4 tests =====\n")
; (run-tests-with-solver cvc4))

; (when (boolector-available?)
; (printf "===== Running Boolector tests =====\n")
; (run-tests-with-solver boolector))

; (when (cvc5-available?)
; (printf "===== Running cvc5 tests =====\n")
; (run-tests-with-solver cvc5))

; (when (bitwuzla-available?)
; (printf "===== Running bitwuzla tests =====\n")
; (run-tests-with-solver bitwuzla))
(when (stp-available?)
(printf "===== Running stp tests =====\n")
(run-tests-with-solver stp))
; (when (yices-smt2-available?)
; (printf "===== Running yices-smt2 tests =====\n")
; (run-tests-with-solver yices-smt2))
)

(module+ test
(fast-tests)
(slow-tests))
; (fast-tests)
(slow-tests)
)
2 changes: 1 addition & 1 deletion test/base/bitvector.rkt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#lang racket

(require rackunit rackunit/text-ui racket/generator (rename-in rackunit [check-exn rackunit/check-exn])
rosette/solver/solution
rosette/solver/solution
rosette/lib/roseunit rosette/solver/smt/boolector
racket/fixnum
rosette/base/core/term
Expand Down
2 changes: 1 addition & 1 deletion test/base/push-pop.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
(define push-pop-tests
(test-suite+ "Tests for the push / pop interface."
#:features '(qf_bv)
(output-smt "push-pop-tests.smt2")
(define solver (current-solver))
(check-exn exn:fail? (thunk (solver-pop solver)))

Expand Down