Grammar hygiene: remove two redundant parse paths (ambiguity reduction)#7
Merged
Conversation
`context` was reachable both as a direct alternative of the top-level `theory` rule and via `theory -> statement -> context`, so every theory had (at least) two parses at the root, multiplying the Earley chart for the whole file. `statement` already provides `context`, so the direct alternative is removed. Measured on proof snippets: ambiguous-node counts drop ~33% (e.g. a nested proof 6682 -> 4455), with 0 regressions and 2 of 6 sampled timeouts recovered. Full unit suite still green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
`by` appeared both as a repeated proof step and as a terminal proof step in `proof_prove`, so any proof ending in `by ...` had two parses, compounding through nested proofs. The repeated-step `by` already covers the terminal position, so the terminal copy is removed. Measured on proof snippets (on top of the previous fix): ambiguous-node counts drop a further ~40% (nested proof 4455 -> 2707; by simp 7 -> 3), with 0 real regressions (ok->fail) on the sampled corpus. Full unit suite still green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
christiankissig
added a commit
that referenced
this pull request
Jul 7, 2026
Grammar hygiene: remove two redundant parse paths (ambiguity reduction)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Removes two genuine duplicate parse paths in the grammar, found while investigating the Earley timeout bucket. Both are safe structural cleanups that shrink the parse forest with zero regressions.
contextas a directtheoryalternativecontextis already reachable viatheory → statement → context, so every theory had ≥2 parses at the rootbyinproof_provebyalready appears as a repeated proof step, which covers the terminal position; the duplicate gave everyby-terminated proof two parsesEffect on ambiguous-node counts (proof snippets): a nested proof drops from 6682 → 2707 (~60%);
by simpfrom 10 → 3.Honest scope: this is hygiene, not a speed fix
Profiling shows parse wall-clock is dominated by Earley chart breadth (millions of
Item.__init__/ symbol__eq__inpredict_and_complete's set-dedup), which scales with grammar breadth × input length — not with the output ambiguity these changes remove. Accordingly, wall-clock is essentially unchanged (e.g. an 8 KB proof-heavy file stays ~11.6 s). These changes are worth keeping because they remove real redundancy and reduce the SPPF/memory, but they do not address the timeout bucket.The actual speed levers (documented for follow-up): reduce per-proof-step prediction breadth (
proof_prove/proof_state/methodalternations), the keyword-vs-nameandembeddedterminal overlaps the dynamic lexer can't prune, or a different parse strategy. The opt-in--timeoutfrom #5 remains the pragmatic guard meanwhile.Testing
ok→failcriterion (timeout flakiness excluded): 0 real regressions; 2 sampled timeouts recovered.🤖 Generated with Claude Code