Pick-up notes for continuing the
claude/v2-grammar-proofs-audit-1yqgxh work on another machine
(e.g. the Claude Code desktop app). Everything here is committed to that
branch, so it travels with the code.
Goal: machine-check every necessary/sufficient proof for the grammar
that exists in this repo (grammar/wokelang.ebnf), install the
provers, and report only proofs that actually run. The grammar was
reconciled to one source of truth, and the proof obligations were
mechanized in Lean 4 (mirrored to Coq where sensible).
Open PR: #106 — CFL pumping lemma, machine-checked from scratch in
Lean (branch claude/v2-grammar-proofs-audit-1yqgxh).
Merged on the way here: #102 (parser metatheory + grammar reconciliation), #103 (no-left-recursion + lexer + classification, Lean+Coq), #104 (Coq parser port + §7.1 not-regular), #105 (§7.3 CFL positive closure).
Single-file, Mathlib-free. lean <file> / coqc <file> must exit 0
with no errors.
| File | What it proves | Status |
|---|---|---|
|
core language metatheory (sorry-audit resolved) |
✅ |
|
Pratt-parser metatheory: prefix/completeness/determinism/injectivity |
✅ |
|
no-left-recursion (+ found a real spec bug in |
✅ |
|
Coq port of the parser metatheory |
✅ |
|
§7.1 not-regular:
bespoke pigeonhole + |
✅ |
|
§7.3 CFL positive closure under ∪, ·, * |
✅ |
|
CFL pumping
lemma |
✅ |
Trust base for the proofs: the standard classical kernel constants only
(propext, Classical.choice, Quot.sound) — no holes, no
project-specific assumptions. Confirm with Lean’s kernel-dependency
printout per file.
The claim-by-claim map lives in
docs/proofs/verification/GRAMMAR-PROOF-INVENTORY.md.
The provers are NOT in the repo — they were installed in the (ephemeral) cloud container. Reinstall the pinned versions locally.
The exact, Mathlib-free steps are in
.github/workflows/lean-proofs.yml:
ver=4.30.0
curl -sSL -o /tmp/lean.tar.zst \
"https://github.com/leanprover/lean4/releases/download/v${ver}/lean-${ver}-linux.tar.zst"
sudo mkdir -p /opt/lean
sudo tar --use-compress-program=unzstd -xf /tmp/lean.tar.zst -C /opt/lean
export PATH="/opt/lean/lean-${ver}-linux/bin:$PATH" # use the macOS/win tarball on those OSesThen, from the repo root:
for f in WokeLang WokeGrammar WokeGrammarStructure WokeGrammarRegular WokeGrammarCFL WokeGrammarPumping; do
lean docs/proofs/verification/$f.lean && echo "OK $f"
doneDone (in WokeGrammarPumping.lean):
-
Finiteness-aware
IsCFL— a language is CF iff some ε-free BNF grammar with anenum/cardnonterminal bound generates exactly it (matchescfl_pumping). -
aⁿbⁿcⁿ ∉ CFL(anbncn_not_cfl) — viacfl_pumping: pumping down toi = 0forcescount_a = count_b = count_cin the deleted part, so the window spans anaand ac; the positional core (prefix_pure,abc_window) then gives|vwx| > p, contradicting|vwx| ≤ p. This is the canonical non-CFL and the crux of the ∩/¬ non-closure result. -
The explicit ∩ non-closure statement (
cfl_not_closed_inter) — the two witness CFLsL₁ = {aⁱbⁱcʲ}andL₂ = {aᵐbⁿcⁿ}are each proved context-free by an explicit ε-free BNF grammar (R1,R2) with full exact generation (soundness via tree inversionsound_all1/sound_all2, completeness via tree builders), andL₁ ∩ L₂ = {aⁿbⁿcⁿ}(inter_eq) is discharged byanbncn_not_cfl. Done.
§7 is now fully machine-checked end-to-end. The only further extension
one could add is closure under complement as a standalone theorem,
which needs CFL ∪-closure for this BNF IsCFL (the positive closure
exists in WokeGrammarCFL.lean under a relation-based IsCFL); the
De Morgan corollary is noted in cfl_not_closed_inter’s docstring.
Plan: land it as its own follow-up PR (incremental, same as the pumping lemma).
On PR #106, the genuinely-relevant checks are green (Trusted-base reduction policy; the Lean/Coq compile gates). Three checks are red but are pre-existing infrastructure failures unrelated to these proofs, and every prior merged PR (#102–#105) carried them too:
-
Licence consistency — root
LICENSESPDX mismatch. -
Workflow security linter — a
trufflehog@mainunpinned-action finding. -
Hypatia Neurosymbolic Analysis — scanner infrastructure.
Per the Claude Code docs, use teleport to carry the conversation
context + branch + uncommitted changes from web into the local CLI /
desktop app: claude --teleport <session-id> (one-way: web → local).
See https://code.claude.com/docs/en/claude-code-on-the-web. Even without
it, the branch and PR #106 hold all the work.