Skip to main content

Program Synthesis by Sketching

Project description

Simple Sketch (Program Synthesis by Sketching)

This project is a part of the course 236347 Software Synthesis and Automated Reasoning (SSAR) at the Technion.

Description

The goal of software synthesis is to generate programs automatically from specifications. In Sketching, insight is communicated through a partial program, a sketch that expresses the high-level structure of an implementation but leaves holes in place of the low-level details.

Simple Sketch can Synthesis a program based on a set of input and output examples, or by adding assertions to the program.

Simple Sketch uses counterexample guided inductive synthesis procedure (CEGIS) to synthesize a program.

Look at the examples section in the GUI to see how to use the program.

Note: This project is still under development. Check updates regularly at the SimpleSketch repository

IMPORTANT: The tests (under /tests) still fail, because the tests are not updated to the new version of the program (the new parser) The tests will be updated soon. In the meantime, you can use the examples in the GUI to test the program.

Example

i := ??;
y := i*i + x * ??;
assert (y == x + x + 9);

The above program is a simple example of a program synthesis problem. The goal is to find a program that satisfies the specification.

After running the program, the output is:

i := 3;
y := i*i + x * 2;
assert (y == x + x + 9);

Installation

Build from source

git clone https://github.com/maher-bisan/SimpleSketch.git
cd simple_sketch
python3.11 -m venv .venv
source .venv/bin/activate
pip install .

On windows, run the following command instead:

python -m venv .venv
.venv\Scripts\activate
pip install .

Install from PyPI

pip install simpleSketch

Documentation

Under construction. In the meantime, you can read the docstrings in the code.

Grammar

while_lang grammar

start: statements

statements: statement | statements statement

statement: "skip" ";" | declaration | assignment | "if" "(" expr ")" "{" statements "}" 
| "if" "(" expr ")" "{" statements "}"  "else" "{" statements "}" | "while" "(" expr ")" "{" statements "}" | "assert" "(" expr ")" ";" | "assume" "(" expr ")" ";"

declaration: type id ";" | type id = expr ";" | array_type id ";" | array_type id = id ";"

assignment: id = expr ";" | id [ expr ] = expr ";"

array_type: "Array" type

type: "int" | "float" | "bool"

expr: expr "and" expr | expr "or" expr | "not" expr 
| expr "==" expr | expr "!=" expr | expr "<" expr | expr ">" expr | expr "<=" expr | expr ">=" expr
| expr "+" expr | expr "-" expr | expr "*" expr | expr "/" expr | expr "**" expr
| atom

atom: "(" expr ")" | id | hole | id "[" expr "]" | int | float | bool

hole: "??" | "int?" | "bool?" | "float?"

bool : "True" | "False"

Usage

Open the GUI

In the terminal, run the following command:

If you installed from PyPI

simpleSketch-gui

If you built from source

python3.11 src/simple_sketch/simple_sketch_gui/simple_sketch_gui.py

Examples

After opening the GUI, you can select an example from the dropdown menu, at the sidebar.

Run a program

To run a program, click the "Run" button. Click the "Clear" button to clear the entire text areas.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simpleSketch-0.0.8.tar.gz (67.7 kB view details)

Uploaded Source

Built Distribution

simpleSketch-0.0.8-py3-none-any.whl (73.1 kB view details)

Uploaded Python 3

File details

Details for the file simpleSketch-0.0.8.tar.gz.

File metadata

  • Download URL: simpleSketch-0.0.8.tar.gz
  • Upload date:
  • Size: 67.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for simpleSketch-0.0.8.tar.gz
Algorithm Hash digest
SHA256 2f0d0bfe1fbfd79ae63379f5a3766a0f44248a1bf78bb0d0394d6a7c642e488c
MD5 fb45f9babc65df71bafb81d50d4836e5
BLAKE2b-256 8caee6326ecec7afc3a9f0b6cf913361003d474049121c5182879309e786a2c4

See more details on using hashes here.

File details

Details for the file simpleSketch-0.0.8-py3-none-any.whl.

File metadata

File hashes

Hashes for simpleSketch-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 ee6042de82f83b3c9ec914dc2280393a3f73fb2b175f229d3513e32c83d4886a
MD5 fde0e23ae916c50b9f0238bd5793f5c6
BLAKE2b-256 e2eb3851a7e4589460e45da276613f1dd0106aecd15426ec15a5a32d88ad4eb1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page