@@ -3,36 +3,43 @@ var execSync = require('child_process').execSync;
3
3
var fs = require ( 'fs' ) ;
4
4
var tmp = require ( 'tmp' ) ;
5
5
6
+ // Timeout in ms.
6
7
const timeout = 10000 ;
7
8
8
9
var potentialSolvers = [
9
10
{
10
11
name : 'z3' ,
12
+ command : 'z3' ,
11
13
params : '-smt2 rlimit=20000000 rewriter.pull_cheap_ite=true fp.spacer.q3.use_qgen=true fp.spacer.mbqi=false fp.spacer.ground_pobs=false'
12
14
} ,
15
+ {
16
+ name : 'Eldarica' ,
17
+ command : 'eld' ,
18
+ params : '-horn -t:' + ( timeout / 1000 )
19
+ } ,
13
20
{
14
21
name : 'cvc4' ,
22
+ command : 'cvc4' ,
15
23
params : '--lang=smt2 --tlimit=' + timeout
16
24
}
17
25
] ;
18
- var solvers = potentialSolvers . filter ( solver => commandExistsSync ( solver . name ) ) ;
26
+ var solvers = potentialSolvers . filter ( solver => commandExistsSync ( solver . command ) ) ;
19
27
20
- function solve ( query ) {
21
- if ( solvers . length === 0 ) {
22
- throw new Error ( 'No SMT solver available. Assertion checking will not be performed.' ) ;
28
+ function solve ( query , solver ) {
29
+ if ( solver === undefined ) {
30
+ if ( solvers . length === 0 ) {
31
+ throw new Error ( 'No SMT solver available. Assertion checking will not be performed.' ) ;
32
+ } else {
33
+ solver = solvers [ 0 ] ;
34
+ }
23
35
}
24
36
25
37
var tmpFile = tmp . fileSync ( { postfix : '.smt2' } ) ;
26
38
fs . writeFileSync ( tmpFile . name , query ) ;
27
- // TODO For now only the first SMT solver found is used.
28
- // At some point a computation similar to the one done in
29
- // SMTPortfolio::check should be performed, where the results
30
- // given by different solvers are compared and an error is
31
- // reported if solvers disagree (i.e. SAT vs UNSAT).
32
39
var solverOutput ;
33
40
try {
34
41
solverOutput = execSync (
35
- solvers [ 0 ] . name + ' ' + solvers [ 0 ] . params + ' ' + tmpFile . name , {
42
+ solver . command + ' ' + solver . params + ' ' + tmpFile . name , {
36
43
stdio : 'pipe'
37
44
}
38
45
) . toString ( ) ;
@@ -44,7 +51,9 @@ function solve (query) {
44
51
if (
45
52
! solverOutput . startsWith ( 'sat' ) &&
46
53
! solverOutput . startsWith ( 'unsat' ) &&
47
- ! solverOutput . startsWith ( 'unknown' )
54
+ ! solverOutput . startsWith ( 'unknown' ) &&
55
+ ! solverOutput . startsWith ( '(error' ) &&
56
+ ! solverOutput . startsWith ( 'error' )
48
57
) {
49
58
throw new Error ( 'Failed to solve SMT query. ' + e . toString ( ) ) ;
50
59
}
@@ -56,5 +65,5 @@ function solve (query) {
56
65
57
66
module . exports = {
58
67
smtSolver : solve ,
59
- availableSolvers : solvers . length
68
+ availableSolvers : solvers
60
69
} ;
0 commit comments