Coder Social home page Coder Social logo

puneet / guidedsampler Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rafaeltupynamba/guidedsampler

0.0 2.0 0.0 433 KB

GuidedSampler: Coverage-guided Sampling of SMT Solutions

License: BSD 3-Clause "New" or "Revised" License

Makefile 0.02% C++ 39.98% Python 60.00%

guidedsampler's Introduction

GuidedSampler

GuidedSampler: Coverage-guided Sampling of SMT Solutions

Paper

Building

Install dependencies

sudo apt install git python g++ make

Clone repos

git clone https://github.com/RafaelTupynamba/GuidedSampler.git
git clone https://github.com/Z3Prover/z3.git

Build z3 (with a patch to collect coverage information from the formula)

cd z3
git checkout bb7ad4e938ec3ade23282142119e77c838b1f7d1
cp ../GuidedSampler/z3-patch/mk_util.py scripts/mk_util.py
cp ../GuidedSampler/z3-patch/rewriter_def.h src/ast/rewriter/rewriter_def.h
cp ../GuidedSampler/z3-patch/model.cpp src/model/model.cpp
cp ../GuidedSampler/z3-patch/permutation_matrix.h src/util/lp/permutation_matrix.h
python scripts/mk_make.py
cd build
make
sudo make install
cd ../..

Build GuidedSampler

cd GuidedSampler
make

Running

Example runs:

#  Collect a set of internal predicates to be used as coverage predicates
./guidedsampler -n 1000000 -t 1800.0 --get-internal-predicates formula.smt2

# Sample solutions to the formula, guided by the internal predicates, using the default GuidedSampler strategy (--random-soft-preds)
./guidedsampler -n 1000000 -t 1800.0 --use-internal-predicates --random-soft-preds formula.smt2

#  Generate a set of random predicates to be used as coverage predicates
./guidedsampler -n 1000000 -t 1800.0 --get-random-predicates formula.smt2

# Sample solutions to the formula, guided by the random predicates, using the default GuidedSampler strategy (--random-soft-preds)
./guidedsampler -n 1000000 -t 1800.0 --use-random-predicates --random-soft-preds formula.smt2

GuidedSampler will create a file formula.smt2.samples with the samples generated and print statistics to standard output. The file formula.smt2.samples has two lines for each produced sample. The first number represents the number of atomic mutations which were used to generate this sample. Then, the sample is displayed in a compact format. The next line starting with "P:" displays the coverage class of the sample.

The option -n can be used to specify the maximum number of samples produced and the option -t can be used to specify the maximum time allowed for sampling.

The option --get-internal-predicates can be used to collect an interesting set of internal predicates from the formula itself. The predicates are chosen by sampling solutions to the formula using the SMTSampler algorithm and then collecting coverage statistics from the internal nodes of the formula. We identify a subset of the nodes that exhibit diverse coverage behavior and save the subformulas corresponding to those nodes as the coverage predicates.

The option --use-internal-predicates can be used to sample solutions to the formula guided by the set of internal predicates. The set of internal predicates must have already been collected in a previous run using the option --get-internal-predicates.

The option --get-random-predicates can be used to generate a set of random predicates over the variables of the formula.

The option --use-random-predicates can be used to sample solutions to the formula guided by the set of random predicates. The set of random predicates must have already been collected in a previous run using the option --get-random-predicates.

Six different approaches can be used for sampling, as described in the GuidedSampler paper.

--pred-hard: baseline approach with hard constraints (BH)

--pred-soft: baseline approach with soft constraints (BS)

no option: SMTSampler approach (S0)

--flip-preds: approach S1, includes flipping coverage predicates to generate neighboring solutions

--remove-repeated: approach S2, includes S1 and also discards solutions from repeated coverage classes

--random-soft-preds: the GuidedSampler approach S3, includes S2 and also randomizes the coverage class of the initial base solution

All the samples that GuidedSampler outputs are valid solutions to the formula.

Benchmarks

The benchmarks used come from SMT-LIB. They can be obtained from the following repositories.

QF_AUFBV QF_ABV QF_BV

Paper

FMCAD 2019 paper

GuidedSampler: Coverage-guided Sampling of SMT Solutions

Rafael Dutra, Jonathan Bachrach, Koushik Sen

guidedsampler's People

Contributors

rafaeltupynamba avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.