Skip to content

Commit 0713a63

Browse files
author
Leo Alt
committed
README changes
1 parent 6f8b14c commit 0713a63

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

README.md

+25-7
Original file line numberDiff line numberDiff line change
@@ -144,36 +144,54 @@ for (var contractName in output.contracts['test.sol']) {
144144
}
145145
```
146146

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
148148
Solidity's SMTChecker. If you have an SMT solver installed locally, it can
149149
be used to solve the given queries, where the callback must synchronously
150150
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.
153161

154162
#### Example usage with smtSolver callback
155163

156164
```javascript
157165
var solc = require('solc');
158-
var smt = require('smtsolver');
166+
const smtchecker = require('solc/smtchecker');
167+
const smtsolver = require('solc/smtsolver');
159168
// Note that this example only works via node and not in the browser.
160169

161170
var input = {
162171
language: 'Solidity',
163172
sources: {
164173
'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" ]
166181
}
167182
}
168183
};
169184

170185
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+
)
172190
);
173191

174192
```
175193
The assertion is clearly false, and an ``assertion failure`` warning
176-
should be returned.
194+
should be returned, together with a counterexample.
177195

178196
#### Low-level API
179197

0 commit comments

Comments
 (0)