Skip to content

Commit d54c389

Browse files
committed
z3: bump version to 4.12.6
4.12.6 is the latest version released last week. The main motivation for the upgrade, though, is to get past 4.12.3, as subsequent versions (4.12.4 onward) support aarch64 for Linux.
1 parent edf682d commit d54c389

File tree

3 files changed

+38
-21
lines changed

3 files changed

+38
-21
lines changed

rosette/private/install.rkt

+15-17
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
; far more obvious.
2121
(define z3-install-failure #f)
2222

23-
(define z3-version "4.8.8")
23+
(define z3-version "4.12.6")
2424

2525
(define (print-failure path msg)
2626
(printf "\n\n********** Failed to install Z3 **********\n\n")
@@ -66,19 +66,17 @@
6666
(not (equal? (resolve-path p) p)))))
6767

6868
(define (get-z3-url)
69-
; TODO: Z3 packages a macOS aarch64 binary as of 4.8.16, so remove this special case when we update
70-
; to a newer Z3 version.
71-
(if (and (equal? (system-type 'os*) 'macosx) (equal? (system-type 'arch) 'aarch64))
72-
(values "https://github.com/emina/rosette/releases/download/4.1/z3-4.8.8-aarch64-osx-13.3.1.zip" "z3")
73-
(let ()
74-
(define site "https://github.com/Z3Prover/z3/releases/download")
75-
(define-values (os exe)
76-
(match (list (system-type 'os*) (system-type 'arch))
77-
['(linux x86_64) (values "x64-ubuntu-16.04" "z3")]
78-
[`(macosx ,_) (values "x64-osx-10.14.6" "z3")]
79-
['(windows x86_64) (values "x64-win" "z3.exe")]
80-
[any (raise-user-error 'get-z3-url "No Z3 binary available for system type '~a" any)]))
81-
(define name (format "z3-~a-~a" z3-version os))
82-
(values
83-
(format "~a/z3-~a/~a.zip" site z3-version name)
84-
(format "~a/bin/~a" name exe)))))
69+
(define site "https://github.com/Z3Prover/z3/releases/download")
70+
(define-values (os exe)
71+
(match (list (system-type 'os*) (system-type 'arch))
72+
['(linux x86_64) (values "x64-glibc-2.35" "z3")]
73+
['(linux aarch64) (values "arm64-glibc-2.35" "z3")]
74+
['(macosx x86_64) (values "x64-osx-11.7.10" "z3")]
75+
['(macosx aarch64) (values "arm64-osx-11.0" "z3")]
76+
['(windows x86_64) (values "x64-win" "z3.exe")]
77+
['(windows aarch64) (values "arm64-win" "z3.exe")]
78+
[any (raise-user-error 'get-z3-url "No Z3 binary available for system type '~a" any)]))
79+
(define name (format "z3-~a-~a" z3-version os))
80+
(values
81+
(format "~a/z3-~a/~a.zip" site z3-version name)
82+
(format "~a/bin/~a" name exe)))

rosette/solver/smt/dec.rkt

+20-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
; their values, as given by sol. The env argument is assumed to be a
2424
; dictionary from constant? to symbol?.
2525
(define (decode-model env sol)
26-
(let ([i-sol (inline (α-rename sol) env)])
26+
(let ([i-sol (inline (α-rename (prune-model sol)) env)])
2727
(for/hash ([(decl id) (in-dict env)]
2828
#:when (and (constant? decl) (hash-has-key? i-sol id)))
2929
(values decl (interpret (hash-ref i-sol id) (term-type decl))))))
@@ -72,6 +72,24 @@
7272
,(substitute body (for/hash ([p params] [α α-params])
7373
(values (car p) α)))))]))))
7474

75+
; Given a map M from symbols to SMTLib function definitions of the form
76+
; (define-fun id ((param type) ...) ret body),
77+
; this procedure eliminate bindings for intermediate expressions,
78+
; which are ids that start with "e" (e.g. "e20"),
79+
; originally defined with define-fun (as opposed to declare-fun) in the query.
80+
; In particular, old versions of Z3 did this pruning automatically,
81+
; and Rosette had been working under this assumption.
82+
; Newer versions of Z3 however included extra bindings,
83+
; so we are pruning them away.
84+
(define (prune-model sol)
85+
(for/hash ([(k v) (in-immutable-hash sol)]
86+
#:unless (match v
87+
[`(define-fun ,(app symbol->string id) ,_ ,_ ,_)
88+
#:when (string-prefix? id "e")
89+
#t]
90+
[_ #f]))
91+
(values k v)))
92+
7593
; Given an s-expression B and a map M from symbols to values,
7694
; returns a B' that replaces each occurrence of a key K in M with M[K].
7795
(define (substitute body env)
@@ -151,7 +169,7 @@
151169
re-solve the constraints using a Z3 instance with the following options:
152170
(z3 #:options (hash ':pp.decimal 'true ':pp.decimal-precision N))"
153171
expr))]
154-
[sym (error "Unrecognized symbol: " sym)])])]))
172+
[sym (error 'decoder "Unrecognized symbol: ~s in ~s" sym expr)])])]))
155173

156174
(define optable
157175
(hash '= @equal? 'ite ite

test/query/solve.rkt

+3-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@
6565
(check-pred
6666
unknown?
6767
(solve
68-
(begin (assert (> (* xi xi) 3))
69-
(assert (= (+ (* xr xr xr) (* xr yr)) 3.0))))))))
68+
(assert (forall (list xi)
69+
(exists (list xr)
70+
(= yi (* (- xi xr) (- xi xr)))))))))))
7071

7172
(define regression-tests
7273
(test-suite+ "Solve regression tests."

0 commit comments

Comments
 (0)