How ellisk42/ec works
Project type and purpose
• DreamCoder is a research‐grade, multi‐language system (Python + OCaml + Rust) that implements a wake–sleep algorithm to learn small programs for a variety of “domains” (lists, text editing, Logo graphics, regex, etc.).
• It also embeds a few‐shot recognition network (Prototypical Networks) as an optional stage.
File structure
• Top‐level directories:
• bin/ — Python entry scripts for each domain (text.py, list.py, logo.py, tower.py, graphs.py, etc.)
• dreamcoder/ — core Python library: orchestration of wake–sleep phases, grammar, enumeration controller, likelihood model, checkpointing.
• solvers/ — OCaml code: domain primitives, the exhaustively enumerative solver, grammar/fragment routines.
• rust_compressor/ — Rust program: post‐enumeration compressor to identify shared subexpressions.
• protonet-networks/ — Python code (PyTorch) for few‐shot recognition.
• data/ & PBE_Strings_Track/ & data/sygus/ — task definitions, ground‐truth programs, benchmarks.
• docs/, tests/ — documentation and integration/unit tests.
• singularity — container recipe.
• Makefile, README, requirements.txt — build & dependency info.
README
• Confirms: Python scripts launch tasks, spawn OCaml solver processes, run recognition (neural net), call Rust compressor, checkpoint in pickles, graph results.
• Points to docs/software-architecture.md for deeper dive.
Main components & their interactions
a. Components:
1. Python Orchestrator (dreamcoder/ + bin/)
2. OCaml Solver Binaries (built from solvers/)
3. Rust Compressor (rust_compressor/)
4. Recognition Network (protonet-networks/)
5. Data Store (data/, PBE_Strings_Track/)
6. Checkpoint & Graphing (pickle files + bin/graphs.py)
7. Container/DevOps (singularity recipe, Makefile)
b. Relationships / Data flow:
• Python Orchestrator loads task definitions from Data Store.
• For each wake phase:
• Enumeration: orchestrator invokes OCaml Solver (via subprocess / shatter) → generates frontiers of candidate programs.
• Recognition: orchestrator calls Recognition Network to score and rank candidates (optional PyTorch).
• Compressor: orchestrator invokes Rust Compressor on frontiers → extracts shared fragments / updates DSL.
• Sleep phase: Python updates probabilistic grammar (fragmentGrammar.py) / likelihoodModel.py.
• Checkpoint: orchestrator writes Python pickle files with state.
• Graphing: bin/graphs.py reads pickle checkpoint → outputs performance plots.
c. Architectural patterns & principles:
• Pipeline (wake–sleep loop): sequential stages (enumerate → recognize → compress → update).
• Modular multi‐language: clear language boundaries (Python for orchestration, OCaml for enumeration, Rust for compression, PyTorch for recognition).
• Extensible domains: dreamcoder/domains subpackages for each problem domain; drop‐in new domains.
• Interprocess communication via subprocess calls and file I/O (JSON, pickles).
d. Key frameworks & libs:
• Python: ZMQ (maybe), dill/pickle, argparse, PyTorch (recognition), numpy.
• OCaml: ppx_jane, core, re2, yojson, menhir, ZeroMQ?
• Rust: serde_json, structopt, rayon?
• Container: Singularity.
• Tests: pytest / custom shell scripts.
Essential elements to capture
• Wake–sleep loop at center, with four major stages (enumeration, recognition, compression, grammar update).
• Multi‐language boundaries and subprocess invocation.
• Data inputs (task definitions) and outputs (pickles, graphs).
• Extensibility: domain plugin directory and prototypical networks folder.
• Build & container layer (Makefile, singularity) as an outer shell ensuring reproducibility.