blob: ed251ed30c1dbb88a71b8c83cd3e895c01187276 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
/********************************************************************
* AUTHORS: Vijay Ganesh, David L. Dill
*
* BEGIN DATE: November, 2005
*
* LICENSE: Please view LICENSE file in the home dir of this Program
********************************************************************/
// -*- c++ -*-
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <ctime>
#include <unistd.h>
#include <signal.h>
//#include <zlib.h>
#include <stdio.h>
#include "../AST/AST.h"
#include "parsePL_defs.h"
#include "../sat/Solver.h"
#include "../sat/SolverTypes.h"
#include "../sat/VarOrder.h"
#include <unistd.h>
#ifdef EXT_HASH_MAP
using namespace __gnu_cxx;
#endif
/* GLOBAL FUNCTION: parser
*/
extern int yyparse();
//extern int smtlibparse();
/* GLOBAL VARS: Some global vars for the Main function.
*
*/
const char * prog = "stp";
int linenum = 1;
const char * usage = "Usage: %s [-option] [infile]\n";
std::string helpstring = "\n\n";
// Amount of memory to ask for at beginning of main.
static const intptr_t INITIAL_MEMORY_PREALLOCATION_SIZE = 4000000;
// Used only in smtlib lexer/parser
BEEV::ASTNode SingleBitOne;
BEEV::ASTNode SingleBitZero;
/******************************************************************************
* MAIN FUNCTION:
*
* step 0. Parse the input into an ASTVec.
* step 1. Do BV Rewrites
* step 2. Bitblasts the ASTNode.
* step 3. Convert to CNF
* step 4. Convert to SAT
* step 5. Call SAT to determine if input is SAT or UNSAT
******************************************************************************/
int main(int argc, char ** argv) {
char * infile;
extern FILE *yyin;
// Grab some memory from the OS upfront to reduce system time when individual
// hash tables are being allocated
if (sbrk(INITIAL_MEMORY_PREALLOCATION_SIZE) == ((void *) -1)) {
// FIXME: figure out how to get and print the real error message.
BEEV::FatalError("Initial allocation of memory failed.");
}
//populate the help string
helpstring += "-r : switch refinement off (optimizations are ON by default)\n";
helpstring += "-w : switch wordlevel solver off (optimizations are ON by default)\n";
helpstring += "-a : switch optimizations off (optimizations are ON by default)\n";
helpstring += "-s : print function statistics\n";
helpstring += "-v : print nodes \n";
helpstring += "-c : construct counterexample\n";
helpstring += "-d : check counterexample\n";
helpstring += "-p : print counterexample\n";
helpstring += "-x : flatten nested XORs\n";
helpstring += "-h : help\n";
for(int i=1; i < argc;i++) {
if(argv[i][0] == '-')
switch(argv[i][1]) {
case 'a' :
BEEV::optimize = false;
BEEV::wordlevel_solve = false;
break;
case 'b':
BEEV::print_STPinput_back = true;
break;
case 'c':
BEEV::construct_counterexample = true;
break;
case 'd':
BEEV::construct_counterexample = true;
BEEV::check_counterexample = true;
break;
case 'e':
BEEV::variable_activity_optimize = true;
break;
case 'f':
BEEV::smtlib_parser_enable = true;
break;
case 'h':
fprintf(stderr,usage,prog);
cout << helpstring;
//BEEV::FatalError("");
return -1;
break;
case 'l' :
BEEV::linear_search = true;
break;
case 'n':
BEEV::print_output = true;
break;
case 'p':
BEEV::print_counterexample = true;
break;
case 'q':
BEEV::print_arrayval_declaredorder = true;
break;
case 'r':
BEEV::arrayread_refinement = false;
break;
case 's' :
BEEV::stats = true;
break;
case 'u':
BEEV::arraywrite_refinement = false;
break;
case 'v' :
BEEV::print_nodes = true;
break;
case 'w':
BEEV::wordlevel_solve = false;
break;
case 'x':
BEEV::xor_flatten = true;
break;
case 'z':
BEEV::print_sat_varorder = true;
break;
default:
fprintf(stderr,usage,prog);
cout << helpstring;
//BEEV::FatalError("");
return -1;
break;
}
else {
infile = argv[i];
yyin = fopen(infile,"r");
if(yyin == NULL) {
fprintf(stderr,"%s: Error: cannot open %s\n",prog,infile);
BEEV::FatalError("");
}
}
}
#ifdef NATIVE_C_ARITH
#else
CONSTANTBV::ErrCode c = CONSTANTBV::BitVector_Boot();
if(0 != c) {
cout << CONSTANTBV::BitVector_Error(c) << endl;
return 0;
}
#endif
//want to print the output always from the commandline.
BEEV::print_output = true;
BEEV::globalBeevMgr_for_parser = new BEEV::BeevMgr();
SingleBitOne = BEEV::globalBeevMgr_for_parser->CreateOneConst(1);
SingleBitZero = BEEV::globalBeevMgr_for_parser->CreateZeroConst(1);
//BEEV::smtlib_parser_enable = true;
yyparse();
}//end of Main
|