This clang-fe branch uses Clang compiler as the front-end, which is still under development by Aaditya Naik.
- python-2.7
- PyTorch 0.4.0
- python library: numpy, tqdm, pyparsing
- gcc/g++ 5.4.0 (or higher)
- make, cmake
code2inv uses the Z3 theorem prover to verify the correctness of generated loop invariants. Follow these steps to build Z3:
- Clone the source code of Z3 from https://github.com/Z3Prover/z3
- Run
python scripts/mk_make.py --prefix /usr/local/; cd build; make -j16; make install
Remember to set environment variables DYLD_LIBRARY_PATH and PYTHONPATH to contain paths for Z3 shared libraries and Z3Py, respectively. These paths will be indicated upon successful installation of Z3.
The frontend is used to extract program graphs and verification conditions (VCs) from the input C programs. The program graphs and VCs for our benchmarks are already included in the benchmarks directory. To build the frontend, follow the instructions in README in code2inv-fe.
Install the dev version of this package:
pip install -e .
cd code2inv/prog_generator, then directly run the script ./run_solver.sh
To modify the script run_solver.sh:
- Set the
data_folderoption to the code folder that contains foldersgraph/andsmt2/which are created by the front-end pre-processor - Set the
file_listoption to the file that contains a list of code names. Seecode2inv/benchmarks/names.txtas an example. - Set the
single_sampleoption to be the index of code where you want to find the loopinv for. - Adjust other parameters if necessary. Make sure to change parameters like
max_and, max_or, max_depth, list_opto make sure the loopinv space is large enough (but not too large).
cd code2inv/prog_generator Then run: ./pretraining.sh ${dataset} ${prog_idx} ${agg_check} where dataset is the data name, prog_idx stands for the set of random perturbed programs, and agg_check can be 0 or 1, denoting whether more aggressive checker should be used.
cd code2inv/prog_generator Then run: ./fine_tuning.sh ${dataset} ${prog_idx} ${agg_check} ${init_epoch} where the last argument init_epoch stands for the model dump of corresponding epoch.