|
23 | 23 | ; their values, as given by sol. The env argument is assumed to be a
|
24 | 24 | ; dictionary from constant? to symbol?.
|
25 | 25 | (define (decode-model env sol)
|
26 |
| - (let ([i-sol (inline (α-rename sol) env)]) |
| 26 | + (let ([i-sol (inline (α-rename (prune-model sol)) env)]) |
27 | 27 | (for/hash ([(decl id) (in-dict env)]
|
28 | 28 | #:when (and (constant? decl) (hash-has-key? i-sol id)))
|
29 | 29 | (values decl (interpret (hash-ref i-sol id) (term-type decl))))))
|
|
72 | 72 | ,(substitute body (for/hash ([p params] [α α-params])
|
73 | 73 | (values (car p) α)))))]))))
|
74 | 74 |
|
| 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 | + |
75 | 93 | ; Given an s-expression B and a map M from symbols to values,
|
76 | 94 | ; returns a B' that replaces each occurrence of a key K in M with M[K].
|
77 | 95 | (define (substitute body env)
|
|
151 | 169 | re-solve the constraints using a Z3 instance with the following options:
|
152 | 170 | (z3 #:options (hash ':pp.decimal 'true ':pp.decimal-precision N))"
|
153 | 171 | expr))]
|
154 |
| - [sym (error "Unrecognized symbol: " sym)])])])) |
| 172 | + [sym (error 'decoder "Unrecognized symbol: ~s in ~s" sym expr)])])])) |
155 | 173 |
|
156 | 174 | (define optable
|
157 | 175 | (hash '= @equal? 'ite ite
|
|
0 commit comments