Newer
Older
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# IMPORTANT
This is a slightly modified version of the STP Solver.
For the Original see: https://github.com/stp/stp
As the Oritinal this is distibuted under the MIT OSS License: https://opensource.org/licenses/MIT
################################################################################################################################
# Original README
[](https://opensource.org/licenses/MIT)
[](https://travis-ci.org/stp/stp)
[](https://ci.appveyor.com/project/msoos/stp)
[](https://stp.readthedocs.io/en/latest/?badge=latest)
[](https://scan.coverity.com/projects/861)
[](https://www.codacy.com/app/soos.mate/cryptominisat?utm_source=github.com&utm_medium=referral&utm_content=msoos/cryptominisat&utm_campaign=Badge_Grade)
[](https://coveralls.io/github/stp/stp?branch=master)
# STP
STP is a constraint solver (or SMT solver) aimed at solving constraints of bitvectors and arrays. These types of constraints can be generated by program analysis tools, theorem provers, automated bug finders, cryptographic attack tools, intelligent fuzzers, model checkers, and by many other applications.
* Homepage: https://stp.github.io/
* Ubuntu PPA: https://launchpad.net/~simple-theorem-prover/+archive/ubuntu/ppa/+packages
* Docker image: `docker pull msoos/stp`
## Build and install
For a quick install:
```
sudo apt-get install cmake bison flex libboost-all-dev python perl minisat
git clone https://github.com/stp/stp
cd stp
mkdir build
cd build
cmake ..
make
sudo make install
```
For more detailed instructions, see towards the end of the page.
## Input format
The file based input formats that STP reads are the: CVC, SMT-LIB1, and SMT-LIB2 formats. The SMT-LIB2 format is the recommended file format, because it is parsed by all modern bitvector solvers. Only quantifier-free bitvectors and arrays are implemented from the SMTLibv2 format.
### Usage
Run with an SMTLibv2 file:
```
stp myproblem.smt
```
Overflowing a 32b integer using the python interface:
```
import stp
In [1]: import stp
In [2]: a = stp.Solver()
In [3]: x = a.bitvec('x')
In [4]: y = a.bitvec('y')
In [5]: a.add(x + y < 20)
In [6]: a.add(x > 10)
In [7]: a.add(y > 10)
In [8]: a.check()
Out[8]: True
In [9]: a.model()
Out[9]: {'x': 4294967287L, 'y': 11L}
```
With Docker:
```
docker pull msoos/stp
echo "(set-logic QF_BV)
(assert (= (bvsdiv (_ bv3 2) (_ bv2 2)) (_ bv0 2)))
(check-sat)
(exit)" | docker run --rm -i msoos/stp
```
## Architecture
The system performs word-level preprocessing followed by translation to SAT which is then solved by a SAT solver. In particular, we introduce several new heuristics for the preprocessing step, including abstraction-refinement in the context of arrays, a new bitvector linear arithmetic equation solver, and some interesting simplifications. These heuristics help us achieve several magnitudes of order performance over other tools, and also over straight-forward translation to SAT. STP has been heavily tested on thousands of examples sourced from various real-world applications such as program analysis and bug-finding tools like EXE, and equivalence checking tools and theorem-provers.
## Detailed Building and Installation
STP is built with [CMake](https://cmake.org/), version 3.0.2 or newer. CMake is a
meta build system that generates build files for other tools such as
make(1), Visual Studio, Xcode, etc.
### Configuration variables
Here are a few interesting configuration variables. These apply to all
generators.
- ``CMAKE_BUILD_TYPE`` - The build type (e.g. Release)
- ``CMAKE_INSTALL_PREFIX`` - The prefix for install (e.g. /usr/local )
- ``ENABLE_ASSERTIONS`` - If TRUE STP will be built with asserts.
- ``ENABLE_TESTING`` - Enable running tests
- ``ENABLE_PYTHON_INTERFACE`` - Enable building the Python interface
- ``PYTHON_EXECUTABLE`` - Set python executable in case you have more than one python installed
- ``SANITIZE`` - Use Clang's sanitization checks
- ``STATICCOMPILE`` - Build static libraries and binaries instead of dynamic
### Dependencies
STP relies on : boost, flex, bison and minisat. You can install these by:
```
$ sudo apt-get install cmake bison flex libboost-all-dev python perl minisat
```
STP uses minisat as its SAT solver by default but it also supports other SAT solvers including CryptoMiniSat as an optional extra. If installed, it will be detected during the cmake and used:
```
$ git clone https://github.com/msoos/cryptominisat
$ cd cryptominisat
$ mkdir build && cd build
$ cmake ..
$ make
$ sudo make install
$ sudo ldconfig
```
### Building a static library and binary
```
$ mkdir build && cd build
$ cmake -DSTATICCOMPILE=ON ..
$ make
$ sudo make install
$ sudo ldconfig```
```
### Configuration and build options
To tweak the build configuration:
* Run ``cmake-gui /path/to/stp/source/root`` instead of ``cmake``. This
user interface lets you control the value of various configuration
variables and lets you pick the build system generator.
* Run ``ccmake`` instead of ``cmake``. This provides an ncurses terminal
interface for changing configuration variables.
* Pass ``-D<VARIABLE>=<VALUE>`` options to ``cmake`` (not very user friendly).
It is probably best if you **only** configure this way if you are writing
scripts.
You can also tweak configuration later by running `make edit_cache` and edit any configuration variables, reconfigure and then regenerate the build system. After configuration, build by running `make`.
You can use the `-j<n>` flag to significantly to decrease build time by running `<n>` jobs in parallel (e.g. `make -j4`).
### Testing
```
git clone https://github.com/stp/stp
git submodule update --init
pip install lit
mkdir build
cd build
cmake -DENABLE_TESTING=ON ..
make
make check
```
### Installing
To install run `make install` and to uninstall run `make uninstall`. The root of installation is controlled by the `CMAKE_INSTALL_PREFIX` variable at configure time. You can change this by running `make edit_cache` and editing the value of `CMAKE_INSTALL_PREFIX`.
### Building on Visual Studio
Let's assume you put STP's source into c:\projects\stp and you have cygwin and
git installed. Get zlib:
```
cd C:\projects
git clone https://github.com/madler/zlib
cd zlib
git checkout v1.2.8
mkdir build
mkdir myinstall
cd build
cmake -DCMAKE_INSTALL_PREFIX="..\myinstall" ..
cmake --build .
cmake --build . --target install
```
Get minisat:
```
cd C:\projects
git clone https://github.com/stp/minisat
cd minisat
mkdir build
mkdir myinstall
cd build
cmake -DCMAKE_INSTALL_PREFIX="..\myinstall" -DZLIB_ROOT="..\..\zlib\myinstall" ..
cmake --build .
cmake --build . --target install
```
Get flex, bison, perl:
```
C:\cygwin64\setup-x86_64.exe -qnNd -R C:/cygwin64 -s http://cygwin.mirror.constant.com -l C:/cygwin64/var/cache/setup --packages "flex,bison,perl"
```
Finally, Build STP:
```
cd C:\projects
git clone https://github.com/stp/stp
git submodule update --init --recursive
mkdir build
cd build
cmake -DBoost_USE_STATIC_LIBS=ON -DENABLE_TESTING=ON -DPYTHON_EXECUTABLE="C:\Program Files\Python36\\python.exe" -DLIT_TOOL="C:\Program Files\Python36\Scripts\\lit.exe" -DMINISAT_LIBDIR="..\..\minisat\myinstall\lib" -DMINISAT_INCLUDE_DIRS="..\..\minisat\myinstall\include" -DZLIB_ROOT="..\..\zlib\myinstall" -DCMAKE_PREFIX_PATH="C:\cygwin64" ..
cmake --build .
cmake --build . --target install
```
### Building Docker
```
git clone https://github.com/stp/stp
cd stp
docker build -t stp .
echo "(set-logic QF_BV)
(assert (= (bvsdiv (_ bv3 2) (_ bv2 2)) (_ bv0 2)))
(check-sat)
(exit)" | docker run --rm -i stp
```
# Authors
* Vijay Ganesh
* Trevor Hansen
* Mate Soos
* Dan Liew
* Ryan Govostes
* And many others...