Skip to content

Grammar proofs, extensions: Coq parser port + §7.1 not-regular (from scratch)#104

Merged
hyperpolymath merged 2 commits into
mainfrom
claude/v2-grammar-proofs-audit-1yqgxh
Jun 26, 2026
Merged

Grammar proofs, extensions: Coq parser port + §7.1 not-regular (from scratch)#104
hyperpolymath merged 2 commits into
mainfrom
claude/v2-grammar-proofs-audit-1yqgxh

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Follow-up to #102 and #103, delivering the two scoped extensions. Both new files
are CI-gated and axiom-free (Print Assumptions / #print axioms checked).

Extension A — Coq port of the universal parser proof (WokeGrammarParser.v)

Full Coq 8.18.0 mirror of WokeGrammar.lean: a faithful fuel-based
precedence-climbing parser, the concrete precedence/associativity/rejection
battery, and the universal round-trip —

  • prefix_rt (the parser inverts the fully-parenthesised renderer rp),
  • parse_closed, completeness_rp (∀ e, parseAll (rp e) = Some e),
  • parse_deterministic (unambiguity), rp_injective.

Print Assumptions: all axiom-free ("Closed under the global context") — even
cleaner than the Lean development. Lean and Coq now carry the parser metatheory at
full parity.

Extension B — §7.1 not regular, from scratch (WokeGrammarRegular.lean)

Mathlib has the automata library but it's unavailable offline (egress-blocked), so
this is built from scratch in core Lean:

  • a bespoke finite pigeonhole (proved by induction, collapsing the codomain);
  • a Fin k DFA model (runFrom, runFrom_append);
  • the fooling-set / pigeonhole argument on aⁿbⁿ (the combinatorial heart of
    the pumping lemma): among a⁰..aᵏ two prefixes reach the same state, so aʲbⁱ
    reaches the same final state as the accepted aⁱbⁱ, forcing the DFA to accept
    aʲbⁱ ∉ L — contradiction.

aⁿbⁿ ≅ (ⁿ x )ⁿ, the grammar's balanced-nesting sublanguage, so the WokeLang
expression language is non-regular. sorry-free (classical-logic axioms only).
The prose §7 note and GRAMMAR-PROOF-INVENTORY.md are updated accordingly.

Honestly scoped

§7.3 CFL closure / non-closure remains the one un-mechanized item: it is a
general fact about the class CFL (not this grammar) requiring a full
grammar-derivation module (a 3-way mutual Derives relation + relabeling
reflection lemmas for each construction; the negative direction additionally needs
the CFL pumping lemma). Recorded in the inventory rather than stubbed. Happy to do
it as a dedicated follow-up.

CI

lean-proofs.yml / coq-proofs.yml gain steps for the two new files. Local: all
five grammar-proof files (3 Lean + 2 Coq) compile exit-0; axiom footprints verified.

🤖 Generated with Claude Code

https://claude.ai/code/session_015oyMquf4daB6hMhmqB1wAL


Generated by Claude Code

claude added 2 commits June 26, 2026 22:01
…arity)

WokeGrammarParser.v mirrors WokeGrammar.lean's expression-grammar proofs in
Coq 8.18.0: a faithful fuel-based precedence-climbing parser + the concrete
precedence/associativity/rejection battery + the universal round-trip:

- prefix_rt (the parser inverts the fully-parenthesised renderer rp),
- parse_closed, completeness_rp (∀ e, parseAll (rp e) = Some e),
- parse_deterministic (unambiguity), rp_injective.

Print Assumptions: all axiom-free ("Closed under the global context") — even
cleaner than the Lean development. CI-gated via coq-proofs.yml.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015oyMquf4daB6hMhmqB1wAL
…igeonhole)

WokeGrammarRegular.lean proves grammar-proofs.md §7.1 (the WokeLang expression
language is not regular) without Mathlib:
- a bespoke finite pigeonhole proved from scratch in core Lean;
- a Fin k DFA model (runFrom, runFrom_append);
- the fooling-set / pigeonhole argument on a^n b^n (the combinatorial heart of
  the pumping lemma): among k+1 prefixes a^0..a^k two reach the same state, so
  a^j b^i reaches the same final state as the accepted a^i b^i, forcing the DFA
  to accept a^j b^i (j != i) which is not in the language — contradiction.

a^n b^n is isomorphic to the grammar's balanced nesting (^n x )^n, so the
expression language is non-regular. sorry-free (classical-logic axioms only);
CI-gated via lean-proofs.yml. The prose §7 note and GRAMMAR-PROOF-INVENTORY.md
are updated (T7.1 now machine-checked; §7.3 CFL closure remains scoped).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015oyMquf4daB6hMhmqB1wAL
@hyperpolymath
hyperpolymath marked this pull request as ready for review June 26, 2026 22:13
@hyperpolymath
hyperpolymath merged commit 12971c7 into main Jun 26, 2026
27 of 30 checks passed
@hyperpolymath
hyperpolymath deleted the claude/v2-grammar-proofs-audit-1yqgxh branch June 26, 2026 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants