@@ -144,36 +144,54 @@ for (var contractName in output.contracts['test.sol']) {
144
144
}
145
145
```
146
146
147
- The `` smtSolver `` callback function is used to solve SMT queries generated by
147
+ Since version 0.5.1, the `` smtSolver `` callback function is used to solve SMT queries generated by
148
148
Solidity's SMTChecker. If you have an SMT solver installed locally, it can
149
149
be used to solve the given queries, where the callback must synchronously
150
150
return either an error or the result from the solver. A default
151
- `` smtSolver `` callback is distributed by `` solc-js `` , which relies on either
152
- Z3 or CVC4 being installed locally.
151
+ `` smtSolver `` callback is included in this package via the module
152
+ `` smtchecker.js `` which exports the `` smtCallback `` function that takes 1) a
153
+ function that takes queries and returns the solving result, and 2) a solver
154
+ configuration object. The module `` smtsolver.js `` has a few pre defined solver
155
+ configurations, and relies on Z3, Eldarica or CVC4 being installed locally. It
156
+ exports the list of locally found solvers and a function that invokes a given
157
+ solver.
158
+
159
+ The API of the SMT callback is ** experimental** and can change at any time.
160
+ The last change was in version 0.8.11.
153
161
154
162
#### Example usage with smtSolver callback
155
163
156
164
``` javascript
157
165
var solc = require (' solc' );
158
- var smt = require (' smtsolver' );
166
+ const smtchecker = require (' solc/smtchecker' );
167
+ const smtsolver = require (' solc/smtsolver' );
159
168
// Note that this example only works via node and not in the browser.
160
169
161
170
var input = {
162
171
language: ' Solidity' ,
163
172
sources: {
164
173
' test.sol' : {
165
- content: ' pragma experimental SMTChecker; contract C { function f(uint x) public { assert(x > 0); } }'
174
+ content: ' contract C { function f(uint x) public { assert(x > 0); } }'
175
+ }
176
+ },
177
+ settings: {
178
+ modelChecker: {
179
+ engine: " chc" ,
180
+ solvers: [ " smtlib2" ]
166
181
}
167
182
}
168
183
};
169
184
170
185
var output = JSON .parse (
171
- solc .compile (JSON .stringify (input), { smtSolver: smt .smtSolver })
186
+ solc .compile (
187
+ JSON .stringify (input),
188
+ { smtSolver: smtchecker .smtCallback (smtsolver .smtSolver , smtsolver .availableSolvers [0 ]) }
189
+ )
172
190
);
173
191
174
192
```
175
193
The assertion is clearly false, and an `` assertion failure `` warning
176
- should be returned.
194
+ should be returned, together with a counterexample .
177
195
178
196
#### Low-level API
179
197
0 commit comments