You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -33,10 +33,10 @@ You will implement several key functions for each part:
33
33
34
34
### 📌 Grading criteria:
35
35
36
-
-**Parts 1 & 2**: Autograded. Full credit if you pass all tests within 30 minutes of runtime.
36
+
-**Parts 1 & 2**: Autograded. Full credit if you pass all tests within 10 minutes of runtime.
37
37
(Hint: the reference solution runs most tasks in <1s, hardest ones in <10s.)
38
-
-**Part 3**: Graded manually. Your LLM must solve at least 60% of test cases.
39
-
Upload your llm_synthesis_report.json with all prompts/responses—it’s your proof of work.
38
+
-**Part 3**: Autograded. Your LLM must solve at least 80% of test cases.
39
+
Upload your llm_synthesis_report.json with all prompts/responses.
40
40
41
41
For Gradescope submission, zip the following 6 (or 7) files:
42
42
-`strings.py`
@@ -45,7 +45,7 @@ For Gradescope submission, zip the following 6 (or 7) files:
45
45
-`string_synthesizer.py`
46
46
-`llm_string_synthesizer.py`
47
47
-`llm_synthesis_report.json`
48
-
- (Optional) `readme.md` — for notes, acknowledgements, and AI/collaboration credits.
48
+
- (Optional) `readme.md` — for notes, acknowledgements, and AI/collaboration credits, specified below.
49
49
50
50
### 🤝 Collaboration Policy
51
51
@@ -77,7 +77,7 @@ Excessive usage will be monitored, and we may revoke keys if abused.
77
77
78
78
### 📚 Reference
79
79
80
-
The design of the synthesizer and the Shape DSL is adapted from [PSET1](https://people.csail.mit.edu/asolar/SynthesisCourse/Assignment1.htm) in MIT’s [Introduction to Program Synthesis](https://people.csail.mit.edu/asolar/SynthesisCourse/index.htm), taught by [Prof. Armando Solar-Lezama](https://people.csail.mit.edu/asolar/).
80
+
The design of the synthesizer and the Shape DSL is adapted from [pset1](https://people.csail.mit.edu/asolar/SynthesisCourse/Assignment1.htm) in MIT’s [Introduction to Program Synthesis](https://people.csail.mit.edu/asolar/SynthesisCourse/index.htm), taught by [Prof. Armando Solar-Lezama](https://people.csail.mit.edu/asolar/).
81
81
82
82
# 🚀 Part 0: Setting Up
83
83
@@ -205,7 +205,7 @@ def grow(
205
205
> - Progress tracking:
206
206
> When you start generating large numbers of programs, visualization helps. Use `tqdm` to show a progress bar and keep your sanity.
207
207
208
-
### 🔨 Part 1(b). Eliminating (Observationally) Equivalent Shapes
208
+
### 🔨 Part 1(b). Eliminating Observationally Equivalent Shapes
209
209
210
210
Now that you can **grow** shapes, the next challenge is to keep your search space from exploding.
211
211
For this, we’ll turn to the more general `BottomUpSynthesizer` (in `enumerative_synthesis.py`) and implement a pruning step: **eliminating observationally equivalent programs**.
@@ -238,10 +238,7 @@ def eliminate_equivalents(
238
238
> 💡 Hints & Tips
239
239
> - Use the provided `compute_signature()` method (already implemented) to evaluate programs and produce signatures. These signatures will be your deduplication keys.
240
240
> - Keep track of which signatures you’ve already seen using `Set` or `Dict`.
241
-
> Be careful: different programs may map to the *same* signature—yield only the first and discard the rest.
242
241
> -**Important**: use `yield` instead of returning a list. This way, the synthesizer can stop early if it finds a successful program before exhausting the search space.
243
-
> - The `cache` is your friend: store previously computed outputs there to save time when the same program shows up again.
244
-
245
242
246
243
### 🔨 Part 1(c). Bottom-up Synthesizing Shapes
247
244
@@ -280,15 +277,9 @@ If no solution is found after `max_iterations`, you may `raise ValueError` (whic
280
277
> * Manage your **cache** carefully. Without caching signatures, performance will tank as you repeatedly re-evaluate the same programs.
281
278
> * When calling `eliminate_equivalents`, remember that the **test inputs** (`test_inputs`) are just the $(x, y)$ coordinates from the examples.
282
279
283
-
### 🎁 Wrapping Up Part 1
284
-
285
-
Once you’ve implemented all three core functions:
286
-
287
-
*`grow()` in `shape_synthesizer.py`
288
-
*`eliminate_equivalents()` in `enumerative_synthesis.py`
289
-
*`synthesize()` in `enumerative_synthesis.py`
280
+
### ⚡ Expected Outcome
290
281
291
-
…it’s time to test your synthesizer:
282
+
Once you’ve implemented all three core functions, it’s time to test your synthesizer:
292
283
293
284
```bash
294
285
python test_part1.py
@@ -297,7 +288,7 @@ python test_part1.py
297
288
If all goes well, you’ll see your synthesizer solving the test cases one by one.
298
289
The goal right now would be to make it faster.
299
290
300
-
Make sure your synthesizer can pass all test cases within 30 minutes (paralleled) on GradeScope.
291
+
Make sure your synthesizer can pass all test cases within **10 minutes** (paralleled) on GradeScope.
301
292
For reference, our solution takes about **30 seconds** to pass all test cases (sequentially) on a MacBook Pro with an Apple M1 Pro chip and Python 3.13.0:
302
293
303
294
```bash
@@ -415,6 +406,15 @@ Design new operations and add them as classes under `strings.py`.
415
406
Now look at the `grow()` function in `StringSynthesizer` (`string_synthesizer.py`).
416
407
This should work just like Part 1, except with string operations.
417
408
409
+
```python
410
+
#TODO
411
+
defgrow(
412
+
self,
413
+
program_list: List[StringExpression],
414
+
examples: List[Tuple[str, str]]
415
+
) -> List[StringExpression]:
416
+
```
417
+
418
418
> **Hints:**
419
419
>
420
420
> * For operations that require extra integer arguments (e.g., substring indices), you can use the provided `common_indices = [0, 1, 2, ...]` as candidate constants.
@@ -445,9 +445,7 @@ Executed in 102.80 secs fish external
445
445
sys time 1.25 secs 757.00 micros 1.25 secs
446
446
```
447
447
448
-
✅ You will receive full credit if your synthesizer finishes all test cases within **30 minutes (parallelized)**.
449
-
450
-
---
448
+
✅ You will receive full credit if your synthesizer finishes all test cases within **10 minutes (parallelized)**.
451
449
452
450
### 🚨 Note on Hard Test Cases
453
451
@@ -460,3 +458,93 @@ python test_part2.py --hard
460
458
```
461
459
462
460
Feel free to try, but beware of the combinatorial explosion.
461
+
462
+
# 🤖 Part 3: LLM Synthesis for Strings
463
+
464
+
We’ve now reached the final stage. At the age of **foundation models**, why not invite an LLM to help us synthesize string expressions in your very own DSL?
465
+
LLM would address the limitation of the combinatorial explosion as well as the requirement for pre-defined terminals in bottom-up synthesis.
466
+
467
+
In this part, you will implement two functions inside `llm_string_synthesizer.py`:
0 commit comments