Skip to content

Commit

Permalink
Merge pull request #3 from jamesbornholt/persistent-smtlib
Browse files Browse the repository at this point in the history
Make smtlib servers persistent.
  • Loading branch information
emina committed Oct 7, 2015
2 parents bcb78b9 + b0120c4 commit 8dffbe2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
11 changes: 9 additions & 2 deletions rosette/solver/smt/cmd.rkt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#lang racket

(require racket/syntax
(only-in "smtlib2.rkt" cmd assert check-sat get-model read-solution true false)
(only-in "smtlib2.rkt" cmd assert check-sat get-model reset read-solution true false)
"../../base/term.rkt" "../../base/bool.rkt" "../../base/num.rkt" "../solution.rkt" "../../base/enum.rkt"
"env.rkt" "enc.rkt")

(provide encode decode)
(provide encode decode clear-solver)

; Given an encoding environment, a list of asserts, and
; a solver output port, the encode procedure prints an SMT
Expand Down Expand Up @@ -39,6 +39,13 @@
(default-binding const)))))]
[#f (unsat)]))

; Given a solver input port, the reset procedure prints
; commands necessary to clear the solver's state to the
; given port.
(define (clear-solver port)
(cmd [port]
(reset)))

(define (default-binding const)
(match (type-of const)
[(== @boolean?) #f]
Expand Down
8 changes: 5 additions & 3 deletions rosette/solver/smt/smt.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@
(define/public assert
(lambda in (set! asserts (append asserts (filter-asserts in)))))

(define/public (clear)
(send server shutdown)
(define/public (clear)
(send server write clear-solver)
(set!-values (asserts env) (values '() (make-env))))

(define/public (shutdown) (clear))
(define/public (shutdown)
(clear)
(send server shutdown))

(define/public (debug) (error 'debug "not supported by ~a" this))
(define/public (solve-all) (error 'solve-all "not supported by ~a" this))
Expand Down
2 changes: 2 additions & 0 deletions rosette/solver/smt/smtlib2.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
(define (get-model) (print-cmd "(get-model)\n"))
(define (get-info kw) (print-cmd "(get-info ~a)\n" kw))

(define (reset) (print-cmd "(reset)\n"))

(define (push n) (print-cmd "(push ~a)\n" n))
(define (pop n) (print-cmd "(pop ~a)\n" n))
(define (assert expr) (print-cmd "(assert ~a)" expr))
Expand Down

0 comments on commit 8dffbe2

Please sign in to comment.