Repository navigation
§7.3 CFL closure under union / concatenation / Kleene star (Lean, from scratch) - #105
Merged
Merged
Conversation
…(Lean) WokeGrammarCFL.lean proves grammar-proofs.md §7.3 (positive direction) without Mathlib: the class of context-free languages is closed under union, concatenation, and Kleene star. - A CFG production relation P : N -> List (N + T) -> Prop with a mutual derivation relation Gen/GenL; IsCFL L := some grammar generates exactly L. - One reusable core lemma embGen_iff: embedding a grammar's nonterminals into a larger disjoint grammar preserves the generated language (lift + a generalized- index structural reflection). - Union/concat/star grammar constructions (none -> S1 | S2 ; none -> S1 S2 ; none -> eps | S1 S) with full language-equality proofs: cfl_union, cfl_concat, cfl_star. Plus cfl_single (non-vacuity). sorry-free; #print axioms shows propext only. CI-gated via lean-proofs.yml. The WokeLang surface grammar is context-free, so it inhabits this class and these operations apply. Only §7.3 non-closure under intersection/complement remains scoped (needs the CFL pumping lemma). Inventory + prose §7 notes updated. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015oyMquf4daB6hMhmqB1wAL
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.
Closes the last open item from
grammar-proofs.md§7.3 (positive direction):the class of context-free languages is closed under union, concatenation, and
Kleene star — machine-checked from scratch (no Mathlib).
WokeGrammarCFL.lean(Lean 4.30.0, CI-gated,sorry-free,propext-only)P : N → List (N ⊕ T) → Propwith a mutualderivation relation
Gen/GenL;IsCFL L := ∃ grammar generating exactly L.embGen_iff: embedding a grammar's nonterminalsinto a larger disjoint grammar preserves the generated language. This is the
load-bearing result — a lift direction plus a generalized-index structural
reflection (the index is generalized to a variable + equation so Lean's mutual
brecOnaccepts the recursion).proof:
cfl_union—none → S1 \| S2cfl_concat—none → S1 S2cfl_star—none → ε \| S1 S(the self-recursive one; handled via a mutualGen/GenLforward pass)cfl_single—{[t]}is context-free (non-vacuity).#print axioms→propextonly. The WokeLang surface grammar is context-free, soit inhabits this class and these operations apply to it.
Still scoped (honestly)
§7.3 non-closure under intersection / complement needs the pumping lemma for
CFLs (e.g. to show
aⁿbⁿcⁿis not context-free) — a separate larger development,recorded in
GRAMMAR-PROOF-INVENTORY.mdrather than stubbed.Status of the whole grammar-proofs effort
With this PR, every prose claim in
grammar-proofs.mdis now machine-checkedexcept the §7.3 negative-closure results: parser metatheory (Lean + Coq),
no-left-recursion (+ the guard-pattern bug found), lexer munch/priority,
LL(1)✗/LL(2)✓, §7.1 not-regular, and §7.3 positive closure.
🤖 Generated with Claude Code
https://claude.ai/code/session_015oyMquf4daB6hMhmqB1wAL
Generated by Claude Code