Code Monkey home page Code Monkey logo

delphi's Introduction

Delphi

Delphi is a prototype implementation of SyMO and SMTO (see https://www2.eecs.berkeley.edu/Pubs/TechRpts/2021/EECS-2021-10.html). Example benchmarks can be found here: https://github.com/polgreen/oracles

Building

Prerequisites: All prerequisties for CBMC must be installed (https://github.com/diffblue/cbmc/blob/develop/COMPILING.md). Plus Z3 and CVC4(version 1.8 or greater) must be added to $PATH.

update the gitsubmodule (CBMC)

git submodule init
git submodule update

Ensure you have the dependencies for CBMC installed (Flex and Bison, and GNU make) (see https://github.com/diffblue/cbmc/blob/develop/COMPILING.md). Then download and patch minisat, and compile cbmc as follows:

cd lib/cbmc/src
make minisat2-download
make

Compile delphi

cd delphi/src
make

The binary is found at delphi/src/delphi/delphi.

To run delphi on a file:

delphi file.smt2

To run delphi on a synthesis file:

delphi file.sl

To run delphi in interactive mode use command delphi --smto or 'delphi --symo`

Input format

Delphi accepts an extension of the SyGuS-IF language. The following declares an oracle function symbol of name NAME, associated to an oracle binaryname with type IntxInt->Bool. You do not need to declare the oracle separately, this one declaration is sufficient:

(declare-oracle-fun NAME binaryname ((x Int)(y Int)) Bool)

The following declares an oracle binaryname that accepts two input integers, and returns a single boolean. These values are substituted into the expression (= (f x y) z) to generate a synthesis constraint:

(oracle-constraint binaryname ((x Int)(y Int))((z Bool))
 (= (f x y) z) )

Input files must have the file extension '.smt' if the problem is an SMTO problem and '.sl' if the problem is a synthesis problem.

Examples

SMTO

The following SMTO example checks whether there exist 3 prime factors fo 76:

(declare-oracle-fun isPrime isprime (Int) Bool)
(declare-fun f1 () Int)
(declare-fun f2 () Int)
(declare-fun f3 () Int)
(assert (and (isPrime f1)(isPrime f2)(isPrime f3)))
(assert (= (* f1 f2 f3) 76))
(check-sat) 

The oracle for isprime can be found here: https://github.com/polgreen/oracles/tree/master/prime_oracle

SyMO

The following SyMo example uses two oracles to synthesise a function that performs a pixel by pixel transformation on an image.

(synth-fun tweak ((pixel (_ BitVec 8))) (_ BitVec 8))
; correctness (verification)
(declare-oracle-fun pixel_correct ./pixel_oracle_brighter.sh ((-> (_ BitVec 8) (_ BitVec 8))) Bool)

(constraint (pixel_correct tweak))

; hints (synthesis)
(oracle-constraint
  ./pixel_oracle_brighter.sh
  ((tweak (-> (_ BitVec 8) (_ BitVec 8))))
  ((correct Bool) (pixelIn (_ BitVec 8)) (pixelOut (_ BitVec 8)))
  (=> (not correct) (= (tweak pixelIn) pixelOut)))
(check-synth)

The oracles for the image transformations can be found here: https://github.com/polgreen/oracles/tree/master/image_oracles

delphi's People

Contributors

anishpdoshi avatar erbaoxuecs avatar kroening avatar perry0513 avatar polgreen 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.