ayushnoori commited on
Commit
389a372
Β·
1 Parent(s): 3f02d46

Refactor directory structure

Browse files
README.md CHANGED
@@ -4,7 +4,7 @@
4
 
5
  Completed for [CS252R: Program Synthesis](https://synthesis.metareflection.club/) at the Harvard John A. Paulson School of Engineering and Applied Sciences, taught Fall 2023 by Prof. Nada Amin.
6
 
7
- ## πŸ› οΈ Inductive Synthesis
8
 
9
  The following notes are adapted from [*Introduction to Program Synthesis*](http://people.csail.mit.edu/asolar/SynthesisCourse/TOC.htm) by Armando Solar-Lezama.
10
 
@@ -25,6 +25,30 @@ Synthesize(inputs, outputs):
25
 
26
  Here, we implement the non-ML subset of BUSTLE, the algorithm proposed by Odena *et al.* (2021). That is, we implement bottom-up enumerative search for simple compound expressions, excluding conditionals, recursion and loops.
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  ## πŸ™πŸ½ Acknowledgements
29
 
30
  I thank [Tyler Holloway](mailto:tylerholloway@g.harvard.edu), teaching fellow in CS252R, for her guidance in completing this implementation of bottom-up enumerative program synthesis.
 
4
 
5
  Completed for [CS252R: Program Synthesis](https://synthesis.metareflection.club/) at the Harvard John A. Paulson School of Engineering and Applied Sciences, taught Fall 2023 by Prof. Nada Amin.
6
 
7
+ ## πŸ› οΈ Background
8
 
9
  The following notes are adapted from [*Introduction to Program Synthesis*](http://people.csail.mit.edu/asolar/SynthesisCourse/TOC.htm) by Armando Solar-Lezama.
10
 
 
25
 
26
  Here, we implement the non-ML subset of BUSTLE, the algorithm proposed by Odena *et al.* (2021). That is, we implement bottom-up enumerative search for simple compound expressions, excluding conditionals, recursion and loops.
27
 
28
+ To run the program, run `synthesizer.py` with the following arguments:
29
+ ```
30
+ usage: synthesizer.py [-h] --domain {arithmetic,string} --examples {addition,subtraction,multiplication,division}
31
+ [--max_weight MAX_WEIGHT]
32
+
33
+ Bottom-up enumerative synthesis in Python.
34
+
35
+ optional arguments:
36
+ -h, --help show this help message and exit
37
+ --domain {arithmetic,string}
38
+ Domain of synthesis (either "arithmetic" or "string").
39
+ --examples {addition,subtraction,multiplication,division}
40
+ Examples to synthesize program from. Must be a valid key in the "examples" dictionary.
41
+ --max_weight MAX_WEIGHT
42
+ Maximum weight of programs to consider before terminating search.
43
+ ```
44
+
45
+ For example, to synthesize programs in the arithmetic domain from the addition examples, run:
46
+ ```
47
+ python3 synthesizer.py --domain arithmetic --examples addition
48
+ ```
49
+
50
+ To add additional input-output examples, modify `examples.py`. Add a new key to the dictionary `examples`` and set the value to be a list of tuples.
51
+
52
  ## πŸ™πŸ½ Acknowledgements
53
 
54
  I thank [Tyler Holloway](mailto:tylerholloway@g.harvard.edu), teaching fellow in CS252R, for her guidance in completing this implementation of bottom-up enumerative program synthesis.
Code/arithmetic.py β†’ arithmetic.py RENAMED
File without changes
project_config.py β†’ config.py RENAMED
@@ -20,6 +20,6 @@ else:
20
  PROJECT_DIR = Path('/Users/an583/Library/CloudStorage/OneDrive-Personal/Academic/College/Junior Year/Fall Term/COMPSCI 252R/cs252r')
21
 
22
  # define project configuration variables
23
- DATA_DIR = PROJECT_DIR / 'Data'
24
- RESULTS_DIR = PROJECT_DIR / 'Results'
25
  SEED = 42
 
20
  PROJECT_DIR = Path('/Users/an583/Library/CloudStorage/OneDrive-Personal/Academic/College/Junior Year/Fall Term/COMPSCI 252R/cs252r')
21
 
22
  # define project configuration variables
23
+ # DATA_DIR = PROJECT_DIR / 'Data'
24
+ # RESULTS_DIR = PROJECT_DIR / 'Results'
25
  SEED = 42
Code/demonstration.ipynb β†’ demonstration.ipynb RENAMED
@@ -28,11 +28,7 @@
28
  "# import arithmetic module\n",
29
  "# from arithmetic import *\n",
30
  "from examples import examples\n",
31
- "\n",
32
- "# import project config file\n",
33
- "import sys\n",
34
- "sys.path.append('..')\n",
35
- "import project_config"
36
  ]
37
  },
38
  {
@@ -51,7 +47,7 @@
51
  "domain = \"arithmetic\"\n",
52
  "examples_key = \"addition\"\n",
53
  "examples = examples[examples_key]\n",
54
- "max_level = 3"
55
  ]
56
  },
57
  {
 
28
  "# import arithmetic module\n",
29
  "# from arithmetic import *\n",
30
  "from examples import examples\n",
31
+ "import config"
 
 
 
 
32
  ]
33
  },
34
  {
 
47
  "domain = \"arithmetic\"\n",
48
  "examples_key = \"addition\"\n",
49
  "examples = examples[examples_key]\n",
50
+ "max_weight = 3"
51
  ]
52
  },
53
  {
Code/examples.py β†’ examples.py RENAMED
File without changes
Code/synthesizer.py β†’ synthesizer.py RENAMED
@@ -13,11 +13,7 @@ import argparse
13
 
14
  # import examples
15
  from examples import examples
16
-
17
- # import project config file
18
- import sys
19
- sys.path.append('..')
20
- import project_config
21
 
22
 
23
  def parse_args(examples):
@@ -39,7 +35,8 @@ def parse_args(examples):
39
  choices=examples.keys(),
40
  help='Examples to synthesize program from. Must be a valid key in the "examples" dictionary.')
41
 
42
- parser.add_argument('--max_levels', type=int, required=False, default=3)
 
43
 
44
  args = parser.parse_args()
45
  return args
@@ -51,7 +48,7 @@ if __name__ == '__main__':
51
  args = parse_args(examples)
52
  print(args.domain)
53
  print(args.examples_key)
54
- print(args.max_levels)
55
 
56
  # run bottom-up enumerative synthesis
57
  # run_synthesizer(args)
 
13
 
14
  # import examples
15
  from examples import examples
16
+ import config
 
 
 
 
17
 
18
 
19
  def parse_args(examples):
 
35
  choices=examples.keys(),
36
  help='Examples to synthesize program from. Must be a valid key in the "examples" dictionary.')
37
 
38
+ parser.add_argument('--max_weight', type=int, required=False, default=3,
39
+ help='Maximum weight of programs to consider before terminating search.')
40
 
41
  args = parser.parse_args()
42
  return args
 
48
  args = parse_args(examples)
49
  print(args.domain)
50
  print(args.examples_key)
51
+ print(args.max_weight)
52
 
53
  # run bottom-up enumerative synthesis
54
  # run_synthesizer(args)