LSP-based extractor for Dafny proof/annotation tasks:
focus: full program with exactly one/*[CODE HERE]*/per task in the target lemma.focus --modular: same, but axiomatize other lemmas by adding{:axiom}and removing bodies.sketch: full program with all extractable statements in the target lemma removed (deleted). Output is the complete lemma body. One task per lemma.extract: convert JSON tasks to individual.dfyfiles (creates<id>.dfyfor program and<id>_output.dfyfor solution).axiomatize: transform a file to axiomatize all lemmas except the target, writing the result to a new file.minimize: minimize lemma proofs by greedily removing unnecessary statements while maintaining verification.
python3.12 -m venv .venv
source .venv/bin/activate
pip install -e .export DAFNY_LSP_CMD="dafny server"
# or: export DAFNY_LSP_CMD="dotnet /path/to/DafnyLanguageServer.dll"# Focus (regular): full program + one CODE_HERE_MARKER per task
python -m dafny_tasker.cli focus --file examples/bs_demo.dfy --lemma binarySearchCorrect --out focus.jsonl
# Focus (modular): axiomatized other lemmas
python -m dafny_tasker.cli focus --file examples/bs_demo.dfy --lemma binarySearchCorrect --out modular.jsonl --modular
# Focus (multiple files): process all lemmas in all files
python -m dafny_tasker.cli focus --inputs 'bench/*_solution.dfy' --out focus_all.json --json-list# Sketch: full program with all statements removed (one task per lemma)
python -m dafny_tasker.cli sketch --file examples/bs_demo.dfy --lemma binarySearchCorrect --out sketch.jsonl
# Sketch (multiple files): process all lemmas in all files
python -m dafny_tasker.cli sketch --inputs 'bench/*_solution.dfy' --out sketches.json --json-list
# Sketch (modular): with axiomatized other lemmas
python -m dafny_tasker.cli sketch --inputs 'bench/*_solution.dfy' --out sketches_modular.json --json-list --modular# Extract programs from tasks
# Creates <id>.dfy (program) and <id>_output.dfy (solution) for each task
python -m dafny_tasker.cli extract --input sketches.json --out programs_dir/
# Works with both JSON and JSONL formats
python -m dafny_tasker.cli extract --input focus_tasks.jsonl --out focus_programs/# Axiomatize: transform file to axiomatize all lemmas except the target
python -m dafny_tasker.cli axiomatize --file examples/bs_demo.dfy --lemma binarySearchCorrect --out axiomatized.dfy
# Axiomatize: infer target lemma from CODE_HERE_MARKER location
python -m dafny_tasker.cli axiomatize --file examples/bs_demo.dfy --out axiomatized.dfyThe minimize command reduces lemma proofs to their minimal form by greedily removing unnecessary statements while maintaining verification. It processes each lemma by:
- First attempting to verify with an empty body
- If that fails, trying to remove each extractable statement one-by-one in reverse order (bottom-up)
- Keeping removals that maintain successful verification
- Generating a JSON report with detailed statistics
# Minimize: remove unnecessary statements from lemma proofs
python -m dafny_tasker.cli minimize --file examples/bs_demo.dfy --out minimized/
# Minimize (multiple files): process all lemmas in all files
python -m dafny_tasker.cli minimize --inputs 'bench/*_solution.dfy' --out minimized_bench/
# Minimize (specific lemma): only minimize a specific lemma
python -m dafny_tasker.cli minimize --file examples/bs_demo.dfy --lemma binarySearchHelperCorrect --out minimized/
# Minimize (modular): with axiomatized other lemmas
python -m dafny_tasker.cli minimize --file examples/bs_demo.dfy --out minimized/ --modular
# Minimize (custom timeout): adjust verification timeout per attempt (default: 30s)
python -m dafny_tasker.cli minimize --file examples/bs_demo.dfy --out minimized/ --timeout 60
# Minimize (specific statement types): only consider assert statements for removal
python -m dafny_tasker.cli minimize --file examples/bs_demo.dfy --out minimized/ --extract-types assertOutput:
- Minimized
.dfyfiles written to output directory (one per input file) minimize_report.jsonwith detailed statistics about what was removed from each lemma