lean4-htt/tests/elab_bench
Joachim Breitner 06fb4bec52
feat: require indentation in commands, allow empty tactic sequences (#13229)
This PR wraps the top-level command parser with `withPosition` to
enforce indentation in `by` blocks, combined with an empty-by fallback
for better error messages.

This subsumes #3215 (which introduced `withPosition commandParser` but
without the empty-by fallback). It is also related to #9524, which
explores elaboration with empty tactic sequences — this PR reuses that
idea for the empty-by fallback, so that a `by` not followed by an
indented tactic produces an elaboration error (unsolved goals) rather
than a parse error.

**Changes:**
- `topLevelCommandParserFn` now uses `(withPosition commandParser).fn`,
setting the saved position at the start of each top-level command
- `tacticSeqIndentGt` gains an empty tactic sequence fallback
(`pushNone`) so that missing indentation produces an elaboration error
(unsolved goals) instead of a parse error
- `isEmptyBy` in `goalsAt?` removed: with strict `by` indentation, empty
`by` blocks parse successfully via `pushNone` (producing empty nodes)
rather than producing `.missing` syntax, making the `isEmptyBy` check
dead code. The `isEmpty` helper in `isSyntheticTacticCompletion`
continues to work correctly because it handles both `.missing` and empty
nodes from `pushNone` (via the vacuously-true `args.all isEmpty` on
`#[]`)
- Test files updated to indent `by` blocks and expression continuations
that were previously at column 0

**Behavior:**
- Top-level `by` blocks now require indentation (column > 0 for commands
at column 0)
- Commands indented inside `section` require proofs to be indented past
the command's column
- `#guard_msgs in example : True := by` works because tactic indentation
is checked against the outermost command's column
- Expression continuations (not just `by`) must also be indented past
the command, which is slightly more strict but more consistent
- `have : True := by` followed by a dedent now correctly puts `this` in
scope in the outer tactic block (the `have` is structurally complete
with an unsolved-goal error, rather than a parse error)

**Code changes observed in practice (lean4 test suite + Mathlib):**

- `by` blocks: top-level `theorem ... := by` / `decreasing_by` followed
by tactics at column 0 must be indented
- `variable` continuations: `variable {A : Type*} [Foo A]\n{B : Type*}`
where the second line starts at column 0 must be indented (most common
category in Mathlib)
- Expression continuations: `def f : T :=\nexpr` or `#synth Foo\n[args]`
where the body/arguments start at column 0
- Structure literals: `.symm\n{ toFun := ...` where the struct literal
starts at column 0

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 14:05:47 +00:00
..
big_beq.lean
big_beq.lean.out.ignored
big_beq_rec.lean
big_beq_rec.lean.out.ignored
big_deceq.lean
big_deceq.lean.out.ignored
big_deceq_rec.lean
big_deceq_rec.lean.out.ignored
big_do.lean
big_do.lean.out.expected
big_match.lean
big_match.lean.out.ignored
big_match_nat.lean
big_match_nat.lean.out.ignored
big_match_nat_split.lean
big_match_nat_split.lean.out.ignored
big_match_partial.lean
big_match_partial.lean.out.ignored
big_omega.lean
big_omega_MT.lean
big_omega_MT.lean.init.sh
big_struct.lean
big_struct_dep.lean
big_struct_dep1.lean
bv_decide_inequality.lean
bv_decide_inequality.lean.no_test chore: speed up test suite slightly (#12969) 2026-03-20 12:24:32 +00:00
bv_decide_large_aig.lean
bv_decide_large_aig.lean.out.expected
bv_decide_mod.lean
bv_decide_mod.lean.no_test chore: speed up test suite slightly (#12969) 2026-03-20 12:24:32 +00:00
bv_decide_mul.lean
bv_decide_realworld.lean
bv_decide_rewriter.lean
cbv_aes.lean chore: fix spelling errors (#13274) 2026-04-04 07:34:34 +00:00
cbv_arm_ldst.lean chore: disable cbv usage warning (#12986) 2026-03-19 14:12:04 +00:00
cbv_arm_ldst.lean.no_test chore: speed up test suite slightly (#12969) 2026-03-20 12:24:32 +00:00
cbv_decide.lean chore: speed up test suite slightly (#12969) 2026-03-20 12:24:32 +00:00
cbv_decide.lean.out.ignored
cbv_dedup.lean chore: disable cbv usage warning (#12986) 2026-03-19 14:12:04 +00:00
cbv_divisors.lean chore: speed up test suite slightly (#12969) 2026-03-20 12:24:32 +00:00
cbv_divisors.lean.out.ignored
cbv_leroy.lean chore: speed up test suite slightly (#12969) 2026-03-20 12:24:32 +00:00
cbv_leroy.lean.out.ignored
cbv_merge_sort.lean chore: speed up test suite slightly (#12969) 2026-03-20 12:24:32 +00:00
cbv_merge_sort.lean.out.ignored
cbv_system_f.lean
cbv_system_f.lean.no_test chore: speed up test suite slightly (#12969) 2026-03-20 12:24:32 +00:00
charactersIn.lean chore: speed up test suite slightly (#12969) 2026-03-20 12:24:32 +00:00
charactersIn.lean.out.ignored
delayed_assign.lean test: add instantiateMVars tests and benchmark for delayed assignments (#12808) 2026-03-06 10:59:13 +00:00
delayed_sharing.lean test: add instantiateMVars tests and benchmark for delayed assignments (#12808) 2026-03-06 10:59:13 +00:00
grind_bitvec2.lean
grind_bitvec2.lean.no_test chore: speed up test suite slightly (#12969) 2026-03-20 12:24:32 +00:00
grind_list2.lean
grind_ring_5.lean
iterators.lean
mut_rec_wf.lean
mut_rec_wf.lean.out.ignored
omega_stress.lean
omega_stress.lean.out.ignored
reduceMatch.lean
riscv-ast.lean
riscv-ast.lean.no_test chore: speed up test suite slightly (#12969) 2026-03-20 12:24:32 +00:00
run_bench.sh chore: speed up test suite slightly (#12969) 2026-03-20 12:24:32 +00:00
run_test.sh chore: improve how test suite interacts with stages (#12913) 2026-03-16 15:20:03 +00:00
simp_arith1.lean
simp_bubblesort_256.lean
simp_congr.lean feat: require indentation in commands, allow empty tactic sequences (#13229) 2026-04-08 14:05:47 +00:00
simp_congr.lean.init.sh
simp_local.lean
simp_subexpr.lean
simp_subexpr.lean.out.ignored
string_simp_ne.lean feat: name the functional argument to brecOn in structural recursion (#12987) 2026-03-23 13:40:18 +00:00
string_simp_ne.lean.out.ignored test: add elab_bench for string literal simp performance (#12883) 2026-03-11 16:06:26 +00:00
workspaceSymbols.lean
workspaceSymbols.lean.out.ignored