Polynomial Program Synthesis Tool: PolySynth
We have provided these instructions for Linux machine (e.g., Ubuntu). Most of these commands will also work on MacOS.
-
Install Python3 on your computer. Also install pip with command:
sudo apt-get install python3-pip. -
Clone the Git repository https://github.com/hitarths/polysynth
-
Change your directory to the root folder of cloned repository and install all the required packages by running the following command:
pip install lark==1.1.2 z3-solver==4.11.2.0 sympy==1.11.1
Once you are done with the basic setup, we are ready to run our code on any example.
Follow the following steps to run the synthesizer on a given benchmark:
-
Open the terminal and change the directory to
Code/ -
All the examples/benchmarks are stored in the folder
benchmarks-polysynth -
The easiest way to run an example is to type the following command:
sh run_polysynth_all_benchmarks.shfrom the root directory of the repository. -
Suppose you want to run the synthesizer for the example
Closest_cube_root, then you would run the following command:python3 synthesizer.py --filename Examples/Closest_cube_root/closest_cube_root.c
The main options for the synthesizer.py are the following two:
--filename: The path to the template for the polynomial preogram with holes that has to be synthesized--target: The path to the folder where the output files and synthesized program should be saved
Few other technical arguments that can be passed are given in the following. In general, one can ignore setting them and the synthesizer will run using the default configuration.
--apply-heuristics: Set it to0to disable our abstraction refinement based heuristics, otherwise1(default is1)--apply-handelman: Set it to0to disable applying handelman theorem to generate QP, otherwise1(default is1)--only-smtlib-files: Set it to1to only generatesmtlib2files that can be passed to other solvers. The default value is0and thez3solver will be automatically be used to solve the QP and synthesize the program.--h-degree: Thehdegree is used during application of Handelman theorem and Putinar's Stallensatze. The default value is2. Please refer to the paper for more details.
First install the Racket with following commands:
sudo add-apt-repository ppa:plt/racket
sudo apt update
sudo apt-get install racket
Now, install Rosette:
raco pkg install rosette
Now, you should be able to run racket with command racket.
For setting up Sketch, please follow the instructions on the link: https://github.com/asolarlez/sketch-frontend/wiki.
We have provided the shell script to run Rosette/Sketch on single example as well as on all the supported benchmarks.
-
To run a single benchmark on Rosette:
./run_rosette_one_example.sh -
To run a single benchmark on Sketch:
./run_sketch_one_example.sh -
To run a single benchmark on PolySynth:
./run_polysynth_one_example.sh -
To run a all supported benchmark benchmark on PolySynth:
./run_polysynth_all_benchmarks.sh -
To run a all supported benchmark benchmark on Rosette:
sh run_rosette_all_benchmarks.sh -
To run a all supported benchmark on Sketch:
sh run_sketch_all_benchmarks.sh
You can open these shell file to check the full commands.