Repository navigation
Import categorial, Lambek, and minimalist grammar equivalences - #1066
Conversation
|
Advisory cross-file review against Lean Pool's supervisory rubric. This is not by itself a significance, source-verification, or merge verdict. [Low impact] No blocking issue was found in the latest changes; external source fidelity remains unverified. SummaryImports three grammar equivalences, their supporting translations and proofs, and a bridge to Mathlib’s context-free languages.
Reviews (3) · Last reviewed commit: "Clarify grammar sources and share normal..." · Reviewed by Greptile |
Proof profile (new / modified Lean files)
This build covers the changed modules and their dependency cones on top of the restored cache. The serial per-file sums below are useful for ranking slow files, not as a build budget. Total heartbeats: 534,433 maxHeartbeats units across 25 valid files (11,728 added LOC). Sum of Count-heartbeats wall-clock total: 94.38 s. Repeated import cost inside Heartbeat values sum disjoint root command traces with LOC counts added lines in the profiled Lean files from this PR diff.
Aggregate phase totals
Slowest changed modules (from
|
| Changed module | Lake time |
|---|---|
LeanPool.FormalLinguistics.MGtoMCFG |
10.00 s |
LeanPool.FormalLinguistics.MCFGtoMG |
6.30 s |
LeanPool.FormalLinguistics.CNF |
3.60 s |
LeanPool.FormalLinguistics.BinMCFG |
3.40 s |
LeanPool.FormalLinguistics.MathlibBridge |
2.50 s |
LeanPool.FormalLinguistics.LambekFreeGroup |
2.20 s |
LeanPool.FormalLinguistics.LambekThin |
2.10 s |
LeanPool.FormalLinguistics.MGMCFGEquiv |
1.60 s |
LeanPool.FormalLinguistics.ABGtoCFG |
1.50 s |
LeanPool.FormalLinguistics.MG |
1.20 s |
LeanPool.FormalLinguistics.ABG |
1.10 s |
LeanPool.FormalLinguistics.CFG |
1.10 s |
Per-file `lean --profile` output
LeanPool/FormalLinguistics.lean
import took 132ms
cumulative profiling times:
elaboration 0.113ms
import 132ms
initialization 26.8ms
interpretation 2.48ms
linting 0.288ms
parsing 0.0423ms
real 0.92
user 0.37
sys 0.63
LeanPool/FormalLinguistics/ABG.lean
import took 127ms
cumulative profiling times:
attribute application 0.512ms
blocked (unaccounted) 52.1ms
compilation (IR) 0.468ms
compilation (LCNF base) 4.76ms
compilation (LCNF impure) 2.03ms
compilation (LCNF mono) 3.14ms
congr simp thm 1.26ms
elaboration 92.7ms
fix level params 0.805ms
import 127ms
initialization 27.1ms
instantiate metavars 3.74ms
interpretation 2.33ms
let-to-have transformation 1.04ms
linting 19.2ms
parsing 13.8ms
process pre-definitions 16.1ms
share common exprs 4.87ms
simp 51.7ms
tactic execution 115ms
type checking 65.3ms
typeclass inference 20.7ms
real 1.09
user 0.82
sys 0.58
LeanPool/FormalLinguistics/ABGtoCFG.lean
import took 126ms
cumulative profiling times:
attribute application 0.0953ms
blocked (unaccounted) 58ms
compilation (IR) 0.453ms
compilation (LCNF base) 7.42ms
compilation (LCNF impure) 1.95ms
compilation (LCNF mono) 3.52ms
congr simp thm 1.81ms
elaboration 52.1ms
fix level params 0.517ms
import 126ms
initialization 27ms
instantiate metavars 2.47ms
interpretation 2.38ms
let-to-have transformation 0.0896ms
linting 9.04ms
parsing 6.26ms
process pre-definitions 54.5ms
share common exprs 2.84ms
simp 73.4ms
tactic execution 69.8ms
type checking 42.5ms
typeclass inference 5.71ms
real 1.10
user 0.70
sys 0.59
LeanPool/FormalLinguistics/BarHillel.lean
import took 124ms
cumulative profiling times:
attribute application 0.0706ms
compilation (IR) 0.227ms
compilation (LCNF base) 1.63ms
compilation (LCNF impure) 0.972ms
compilation (LCNF mono) 1.43ms
congr simp thm 0.52ms
elaboration 19.7ms
fix level params 0.248ms
import 124ms
initialization 28.2ms
instantiate metavars 0.805ms
interpretation 2.25ms
let-to-have transformation 0.0901ms
linting 4.18ms
parsing 4.42ms
process pre-definitions 5.06ms
share common exprs 1.22ms
simp 17.7ms
tactic execution 43.8ms
type checking 6.41ms
typeclass inference 10.1ms
real 0.97
user 0.50
sys 0.61
LeanPool/FormalLinguistics/BinMCFG.lean
import took 124ms
cumulative profiling times:
attribute application 0.574ms
blocked (unaccounted) 367ms
compilation (IR) 1.9ms
compilation (LCNF base) 17.3ms
compilation (LCNF impure) 9.65ms
compilation (LCNF mono) 13.7ms
congr simp thm 9.57ms
elaboration 238ms
fix level params 3.15ms
import 124ms
initialization 26.7ms
instantiate metavars 18.8ms
interpretation 2.34ms
let-to-have transformation 1.82ms
linting 56.8ms
parsing 37.7ms
process pre-definitions 238ms
share common exprs 18.4ms
simp 516ms
tactic execution 554ms
type checking 332ms
typeclass inference 67.1ms
real 1.82
user 2.56
sys 0.59
LeanPool/FormalLinguistics/CFG.lean
import took 128ms
cumulative profiling times:
attribute application 0.424ms
blocked (unaccounted) 17.2ms
compilation (IR) 0.375ms
compilation (LCNF base) 2.85ms
compilation (LCNF impure) 1.56ms
compilation (LCNF mono) 2.43ms
congr simp thm 0.817ms
elaboration 97.8ms
fix level params 0.609ms
import 128ms
initialization 34.9ms
instantiate metavars 2.39ms
interpretation 2.3ms
let-to-have transformation 0.16ms
linting 15.4ms
parsing 10.2ms
process pre-definitions 48ms
share common exprs 3.17ms
simp 22ms
tactic execution 60.2ms
type checking 54.6ms
typeclass inference 20.7ms
real 1.04
user 0.74
sys 0.59
LeanPool/FormalLinguistics/CFGtoABG.lean
import took 123ms
cumulative profiling times:
attribute application 0.0544ms
compilation (IR) 0.325ms
compilation (LCNF base) 4.62ms
compilation (LCNF impure) 1.47ms
compilation (LCNF mono) 2.07ms
congr simp thm 1.32ms
elaboration 28ms
fix level params 0.492ms
import 123ms
initialization 27.4ms
instantiate metavars 2.05ms
interpretation 2.44ms
let-to-have transformation 0.062ms
linting 8.05ms
parsing 4.51ms
process pre-definitions 4.84ms
share common exprs 2.17ms
simp 27.3ms
tactic execution 85.8ms
type checking 15.8ms
typeclass inference 2.44ms
real 1.00
user 0.60
sys 0.61
LeanPool/FormalLinguistics/CNF.lean
import took 127ms
cumulative profiling times:
attribute application 0.793ms
blocked (unaccounted) 459ms
compilation (IR) 2.76ms
compilation (LCNF base) 40.3ms
compilation (LCNF impure) 12.8ms
compilation (LCNF mono) 22.5ms
congr simp thm 11.3ms
elaboration 292ms
fix level params 3.04ms
import 127ms
initialization 27ms
instantiate metavars 11.9ms
interpretation 2.44ms
let-to-have transformation 1.19ms
linting 59.9ms
parsing 38.2ms
process pre-definitions 85.5ms
share common exprs 16.1ms
simp 954ms
tactic execution 456ms
type checking 167ms
typeclass inference 87.3ms
real 2.05
user 2.65
sys 0.61
LeanPool/FormalLinguistics/Fixpoint.lean
import took 124ms
cumulative profiling times:
attribute application 0.131ms
blocked (unaccounted) 18.6ms
compilation (IR) 0.362ms
compilation (LCNF base) 2.64ms
compilation (LCNF impure) 1.5ms
compilation (LCNF mono) 2.67ms
congr simp thm 1.46ms
elaboration 43.6ms
fix level params 0.478ms
import 124ms
initialization 27.2ms
instantiate metavars 1.3ms
interpretation 2.3ms
let-to-have transformation 0.963ms
linting 15.3ms
parsing 11ms
process pre-definitions 7.2ms
share common exprs 1.8ms
simp 27.2ms
tactic execution 97.6ms
type checking 36ms
typeclass inference 30.7ms
real 0.98
user 0.64
sys 0.62
LeanPool/FormalLinguistics/GNF.lean
import took 124ms
cumulative profiling times:
attribute application 0.362ms
blocked (unaccounted) 2.17ms
compilation (IR) 0.878ms
compilation (LCNF base) 6.55ms
compilation (LCNF impure) 3.77ms
compilation (LCNF mono) 6.56ms
congr simp thm 3.21ms
elaboration 84.1ms
fix level params 1.1ms
import 124ms
initialization 27.3ms
instantiate metavars 5.04ms
interpretation 2.37ms
let-to-have transformation 0.144ms
linting 18.6ms
parsing 10.7ms
process pre-definitions 11.3ms
share common exprs 5.39ms
simp 161ms
tactic execution 113ms
type checking 78.4ms
typeclass inference 18ms
real 1.13
user 0.92
sys 0.60
LeanPool/FormalLinguistics/Imports.lean
import took 894ms
cumulative profiling times:
declTypeLinter 0.0976ms
elaboration 0.0922ms
import 894ms
initialization 27.4ms
interpretation 79.5ms
linting 0.219ms
module linting 0.0226ms
parsing 0.00247ms
tacticAnalysis 0.131ms
real 1.75
user 0.71
sys 0.75
LeanPool/FormalLinguistics/Lambek.lean
import took 125ms
cumulative profiling times:
attribute application 0.421ms
blocked (unaccounted) 25.3ms
compilation (IR) 0.843ms
compilation (LCNF base) 7.66ms
compilation (LCNF impure) 3.84ms
compilation (LCNF mono) 5.86ms
congr simp thm 1.96ms
elaboration 101ms
fix level params 0.773ms
import 125ms
initialization 27.7ms
instantiate metavars 3.63ms
interpretation 2.31ms
let-to-have transformation 1.06ms
linting 20.3ms
parsing 13ms
process pre-definitions 20.7ms
share common exprs 4.32ms
simp 65.4ms
tactic execution 143ms
type checking 57ms
typeclass inference 20.2ms
real 1.13
user 0.87
sys 0.60
LeanPool/FormalLinguistics/LambekCore.lean
import took 131ms
cumulative profiling times:
attribute application 0.122ms
blocked (unaccounted) 1.54ms
compilation (IR) 1.02ms
compilation (LCNF base) 9.37ms
compilation (LCNF impure) 3.49ms
compilation (LCNF mono) 6.06ms
elaboration 36.3ms
fix level params 0.0772ms
import 131ms
initialization 27.1ms
instantiate metavars 0.0979ms
interpretation 2.38ms
let-to-have transformation 0.0906ms
linting 5.77ms
parsing 6.18ms
process pre-definitions 8.16ms
share common exprs 0.415ms
type checking 15.5ms
typeclass inference 6.31ms
real 0.94
user 0.48
sys 0.58
LeanPool/FormalLinguistics/LambekCut.lean
import took 127ms
cumulative profiling times:
attribute application 0.125ms
blocked (unaccounted) 3.76ms
compilation (IR) 0.147ms
compilation (LCNF base) 0.828ms
compilation (LCNF impure) 0.781ms
compilation (LCNF mono) 0.873ms
congr simp thm 2.65ms
elaboration 53.6ms
fix level params 1.2ms
import 127ms
initialization 27.2ms
instantiate metavars 7.83ms
interpretation 2.26ms
let-to-have transformation 0.175ms
linting 29.2ms
parsing 15.7ms
process pre-definitions 15.3ms
share common exprs 7.91ms
simp 213ms
tactic execution 180ms
type checking 42.5ms
typeclass inference 14.4ms
real 1.12
user 0.96
sys 0.58
LeanPool/FormalLinguistics/LambekFreeGroup.lean
import took 126ms
cumulative profiling times:
attribute application 2.17ms
blocked (unaccounted) 195ms
compilation (IR) 0.523ms
compilation (LCNF base) 4.12ms
compilation (LCNF impure) 2.33ms
compilation (LCNF mono) 4.21ms
congr simp thm 10.9ms
elaboration 154ms
fix level params 2.01ms
import 126ms
initialization 30.9ms
instantiate metavars 9.38ms
interpretation 2.34ms
let-to-have transformation 0.57ms
linting 51.5ms
parsing 33.3ms
process pre-definitions 26.6ms
share common exprs 10.8ms
simp 291ms
tactic execution 550ms
type checking 191ms
typeclass inference 146ms
real 1.34
user 1.82
sys 0.60
LeanPool/FormalLinguistics/LambekInterpolation.lean
import took 125ms
cumulative profiling times:
attribute application 0.874ms
blocked (unaccounted) 48.2ms
compilation (IR) 0.638ms
compilation (LCNF base) 8.1ms
compilation (LCNF impure) 2.24ms
compilation (LCNF mono) 3.27ms
congr simp thm 9.17ms
elaboration 75.1ms
fix level params 1.85ms
import 125ms
initialization 32.2ms
instantiate metavars 30.4ms
interpretation 7.29ms
let-to-have transformation 0.159ms
linting 33.6ms
parsing 11.2ms
process pre-definitions 17.5ms
share common exprs 16ms
simp 500ms
tactic execution 426ms
type checking 329ms
typeclass inference 40.5ms
real 2.09
user 1.90
sys 0.61
LeanPool/FormalLinguistics/LambekPentus.lean
import took 127ms
cumulative profiling times:
attribute application 0.286ms
blocked (unaccounted) 331ms
compilation (IR) 0.465ms
compilation (LCNF base) 5.8ms
compilation (LCNF impure) 1.95ms
compilation (LCNF mono) 3.29ms
congr simp thm 6.32ms
elaboration 140ms
fix level params 2.32ms
import 127ms
initialization 27.4ms
instantiate metavars 12.3ms
interpretation 2.39ms
let-to-have transformation 0.374ms
linting 48ms
parsing 30.1ms
process pre-definitions 78ms
share common exprs 13.3ms
simp 251ms
tactic execution 514ms
type checking 264ms
typeclass inference 67.4ms
real 1.52
user 1.75
sys 0.61
LeanPool/FormalLinguistics/LambekThin.lean
import took 126ms
cumulative profiling times:
attribute application 0.571ms
blocked (unaccounted) 82.2ms
compilation (IR) 0.117ms
compilation (LCNF base) 0.644ms
compilation (LCNF impure) 0.459ms
compilation (LCNF mono) 0.581ms
congr simp thm 4.61ms
elaboration 92.2ms
fix level params 1.31ms
import 126ms
initialization 31.8ms
instantiate metavars 10.1ms
interpretation 2.3ms
let-to-have transformation 0.144ms
linting 17.6ms
parsing 7.92ms
process pre-definitions 10.7ms
share common exprs 7.83ms
simp 88.8ms
tactic execution 274ms
type checking 191ms
typeclass inference 23.3ms
real 1.40
user 1.15
sys 0.59
LeanPool/FormalLinguistics/MCFG.lean
import took 123ms
cumulative profiling times:
attribute application 0.598ms
blocked (unaccounted) 45.4ms
compilation (IR) 1.33ms
compilation (LCNF base) 12.4ms
compilation (LCNF impure) 5.77ms
compilation (LCNF mono) 8.7ms
congr simp thm 3ms
elaboration 102ms
fix level params 0.3ms
import 123ms
initialization 28ms
instantiate metavars 0.535ms
interpretation 2.22ms
let-to-have transformation 0.714ms
linting 8.81ms
parsing 7.42ms
process pre-definitions 47.4ms
share common exprs 1.42ms
simp 35ms
tactic execution 33.6ms
type checking 46ms
typeclass inference 22.7ms
real 1.11
user 0.74
sys 0.62
LeanPool/FormalLinguistics/MCFGtoMG.lean
import took 126ms
process pre-definitions took 134ms
type checking took 109ms
cumulative profiling times:
attribute application 2.51ms
blocked (unaccounted) 375ms
compilation (IR) 3.75ms
compilation (LCNF base) 56.9ms
compilation (LCNF impure) 15.3ms
compilation (LCNF mono) 31.3ms
congr simp thm 15.4ms
elaboration 532ms
fix level params 13.6ms
import 126ms
initialization 31.9ms
instantiate metavars 119ms
interpretation 2.31ms
let-to-have transformation 1.7ms
linting 168ms
parsing 81.5ms
process pre-definitions 288ms
share common exprs 109ms
simp 848ms
tactic execution 1.67s
type checking 711ms
typeclass inference 126ms
real 3.14
user 5.22
sys 0.64
LeanPool/FormalLinguistics/MG.lean
import took 124ms
cumulative profiling times:
attribute application 0.985ms
blocked (unaccounted) 10.3ms
compilation (IR) 1.14ms
compilation (LCNF base) 9.81ms
compilation (LCNF impure) 4.79ms
compilation (LCNF mono) 8.31ms
congr simp thm 1.51ms
elaboration 108ms
fix level params 0.508ms
import 124ms
initialization 32.9ms
instantiate metavars 1.56ms
interpretation 2.34ms
let-to-have transformation 0.162ms
linting 12.3ms
parsing 8.18ms
process pre-definitions 8.17ms
share common exprs 2.5ms
simp 10.2ms
tactic execution 53.1ms
type checking 53.1ms
typeclass inference 28.8ms
real 1.11
user 0.72
sys 0.58
LeanPool/FormalLinguistics/MGMCFGEquiv.lean
import took 126ms
cumulative profiling times:
attribute application 1.13ms
blocked (unaccounted) 457ms
compilation (IR) 5.06ms
compilation (LCNF base) 71.6ms
compilation (LCNF impure) 21.7ms
compilation (LCNF mono) 37.1ms
congr simp thm 10.7ms
elaboration 172ms
fix level params 1.29ms
import 126ms
initialization 27.1ms
instantiate metavars 3.18ms
interpretation 2.43ms
let-to-have transformation 0.226ms
linting 23.5ms
parsing 20.7ms
process pre-definitions 37.3ms
share common exprs 13.6ms
simp 351ms
tactic execution 301ms
type checking 103ms
typeclass inference 34.7ms
real 1.87
user 1.62
sys 0.62
LeanPool/FormalLinguistics/MGOriginal.lean
import took 126ms
cumulative profiling times:
attribute application 0.119ms
blocked (unaccounted) 3.22ms
congr simp thm 0.442ms
elaboration 52.3ms
fix level params 0.53ms
import 126ms
initialization 26.9ms
instantiate metavars 1.46ms
interpretation 2.41ms
let-to-have transformation 0.102ms
linting 12.8ms
parsing 8.58ms
process pre-definitions 6.44ms
share common exprs 2.7ms
simp 8.47ms
tactic execution 61.9ms
type checking 35.9ms
typeclass inference 5.95ms
real 0.96
user 0.56
sys 0.58
LeanPool/FormalLinguistics/MGtoMCFG.lean
import took 126ms
tactic execution of Lean.Parser.Tactic.simp took 104ms
process pre-definitions took 161ms
simp took 126ms
simp took 113ms
cumulative profiling times:
attribute application 5.87ms
blocked (unaccounted) 16.3s
compilation (IR) 5.7ms
compilation (LCNF base) 57.5ms
compilation (LCNF impure) 27ms
compilation (LCNF mono) 46.5ms
congr simp thm 64.5ms
dsimp 35.8ms
elaboration 758ms
fix level params 18.7ms
import 126ms
initialization 35.1ms
instantiate metavars 122ms
interpretation 2.31ms
let-to-have transformation 8.73ms
linting 261ms
parsing 172ms
process pre-definitions 385ms
share common exprs 109ms
simp 3.3s
tactic execution 3.28s
type checking 1.17s
typeclass inference 496ms
real 5.05
user 10.60
sys 0.82
LeanPool/FormalLinguistics/MathlibBridge.lean
import took 481ms
cumulative profiling times:
attribute application 0.142ms
compilation (IR) 0.177ms
compilation (LCNF base) 1.02ms
compilation (LCNF impure) 0.869ms
compilation (LCNF mono) 1.07ms
congr simp thm 1.08ms
declTypeLinter 3.98ms
elaboration 28.4ms
fix level params 0.409ms
import 481ms
initialization 27.1ms
instantiate metavars 1.23ms
interpretation 151ms
let-to-have transformation 0.108ms
linting 9.13ms
module linting 0.0252ms
parsing 8ms
process pre-definitions 4.75ms
share common exprs 2.38ms
simp 27.8ms
tactic execution 136ms
tacticAnalysis 3.19ms
type checking 13.7ms
typeclass inference 32.2ms
real 1.50
user 1.02
sys 0.71
Advisory only — never blocks merge. Full log uploaded as the proof-profile artifact.
|
Submitter assessment for My source, proof, and engineering review found the project ready for independent review. Statement and proof scope
Novelty, source and engineering
GitHub checksThe previous repaired head passed all applicable Lean and content checks. |
🤖 LLM review (
|
| Rubric | Verdict | Bottom line |
|---|---|---|
| Faithfulness | ✅ pass |
All three headline equivalences match the card and construct grammar witnesses in both directions. |
| Novelty | ✅ pass |
The pool comparison and pinned Mathlib and Tau Ceti keyword searches found no duplicate of any of the three headlines, with comprehensive semantic coverage of Mathlib and Tau Ceti still unverifiable. |
| Significance | ✅ pass |
The three research-level classifications form a self-contained development with proved grammar translations, Chomsky and Greibach normal forms, and Lambek cut elimination and interpolation. |
| Sources | ✅ pass |
The citations support all three equivalences as scoped in Lean, with the 1960 result corroborated through Bar-Hillel’s later account and the Lambek converse credited to Cohen through Pentus’s introduction. Bar-Hillel’s lectures, Pentus’s paper, Stabler and Keenan, §2 and §2.3 |
| Code quality (advisory) | flag |
The main maintenance costs are oversized grammar enumerations and translation proofs that repeat the same invariants and case analysis. |
| Aspect | Value |
|---|---|
| Proves the claim | ✅ proves_it |
| Assumed, not proved | The card discloses [DecidableEq T] for the first two headlines, and their Mathlib restatements supply it classically. Decidable equality on CFG nonterminals is part of the existential witness and can also be supplied classically. The card discloses the minimalist grammar’s nonempty lexical feature lists and basic goal category. |
| Matches cited source | ✅ matches |
| Fit | ✅ good_fit |
| Level | research |
| Branch | formal language theory |
| Mode | theory_building |
| Code quality | 3 / 5 |
Statement check: Basic categorial grammars and product Lambek grammars with a primitive goal each characterize the context-free languages excluding [], and the stated chain-based Stabler–Keenan variant characterizes the languages of finite linear non-erasing MCFGs of arbitrary rank.
Basic categorial grammars and product Lambek grammars with a primitive goal each generate exactly the context-free languages that exclude the empty word, and the formalized chain-based Stabler–Keenan grammars generate exactly the languages of finite linear non-erasing multiple context-free grammars.
Novelty findings (1)
- partial-overlap —
LeanPool/FormalLinguistics/CNF.lean:775
The pool would maintain two certified conversions to epsilon-free Chomsky normal form. The new computable conversion supplies separate terminal and binary rule lists to the Greibach construction used by the categorial and Lambek translations.
Evidence:ContextFreeGrammar.toCNF_correctinLeanPool/PumpingCfg/ChomskyNormalForm/Translation.leanproves that the finite-set CNF grammar generates exactly the nonempty words of the original grammar. The newFormalLinguistics.cfgToCNF_langstates(cfgToCNF G).Lang w ↔ G.Lang w ∧ w ≠ [], andcfgToABGusesCNFtoGNF.cnfToGNF (cfgToCNF G).
Code quality findings (11)
- oversized-enumeration —
LeanPool/FormalLinguistics/LambekPentus.lean:252
allTypesbounds connective depth and carries forward duplicate types, while the completeness proof needs only types with at mostmprimitive occurrences. A Lean probe with one primitive andm = 3produced 8,164 entries, with 157 distinct types within the required size bound.pentusCFGtakes the cube of the candidate list before filtering binary rules. Enumerate by exact size, combine operands whose sizes sum to that size, and reuse the resulting bounded list in both rule families.
Evidence:allTypesusesallTypes ps n ++ (allTypes ps n).flatMap (fun X => (allTypes ps n).flatMap.GoodrequiresA.size ≤ m ∧ ∀ p ∈ prims A, p ∈ ps. The binary-rule branch ofpentusCFGuses(allTypes ps m).flatMap (fun A => (allTypes ps m).flatMap (fun B =>followed by(allTypes ps m).map (fun D => (D, [Symbol.nt A, Symbol.nt B])). - repeated-computation —
LeanPool/FormalLinguistics/MGtoMCFG.lean:2056
The slot-vector Cartesian product is rebuilt for each head-feature suffix and lexical flag. Move 2 also repeats the licensee-suffix search for each matching profile, and Merge 1 rebuilds the empty slot vector during profile traversal. Compiler output confirms these calls remain inside the traversals. Compute the suffixes, choices by licensee, slot vectors, and empty slot vector once per grammar and pass them to the builders.
Evidence:allProfilesnests[true, false].flatMap fun b =>,(allFeats G).flatMap fun α =>, and(allSlotVectors G (allLics G)).map fun slots => (b, α, slots). Move 2 uses(licFeats G f').filterMap fun δ =>insideprofs.flatMap.merge1Rulesusesif b1 = true ∧ s1 = ((allLics G).map fun _ => none) theninsideprofiles.flatMap. - repeated-computation —
LeanPool/FormalLinguistics/CNF.lean:620
allPairsruns quadratic list deduplication on a Cartesian product that is already duplicate-free, giving quartic equality checks in the number of distinct nonterminals. Both unary reachability and nullability also rescan their universes for the full iteration budget after membership stabilizes. Prove the product is duplicate-free and let the bounded fixed-point iteration stop when the monotone step leaves the candidate count unchanged.
Evidence:allNTsusesdedupList (allNTsRaw G), andallPairsusesdedupList (nonterminals.flatMap fun A => nonterminals.map fun B => (A, B)).unitReachrunsiterN (stepFilter pairs (unitPred G)) pairs.length []andnullableListrunsiterN (stepFilter nonterminals (nullPred G)) nonterminals.length [].Fixpoint.iterNtakes every step via| n + 1, x => iterN f n (f x). - duplicate-rule-generation —
LeanPool/FormalLinguistics/GNF.lean:131
Each binary production with the same left-hand side causes three Greibach rule families to emit another copy of the same rules. A Lean probe with three distinct binary productions sharing a left-hand side produced nine entries inrules2, of which three were distinct. The duplicates carry through to the categorial lexicon. Deduplicate the left-hand sides once before generating those families.
Evidence:allBinLHSisG.binRules.map fun (A, _, _) => A.cnfToGNFuses(allBinLHS G).flatMap fun A =>twice inrules1and once inrules2.GNFtoABG.toABGmapsG.rules2directly with(G.rules2.map fun (U, a, V, W) =>. - duplicate-proof —
LeanPool/FormalLinguistics/MGtoMCFG.lean:941
Both MCFG translations prove the same range length, uniqueness, coordinate membership, and evaluation facts separately for input positions 0 and 1. Put the range lemmas besideMCFG.evalYield, parameterized by input position and component offset. The reverse translation repeats the same two-position split inbuildDom_step_var0andbuildDom_step_var1, which can share a proof parameterized by input position and its bank.
Evidence:range_vars_propsandrange_vars1_propsboth startinduction len generalizing base with.BinMCFG.range_var0_propsandrange_var1_propsboth startinduction d with. BothevalYield_range_varsvariants and both local proofs inBinMCFG.evalYield_joinYielduseinduction mid generalizing pre with. BothbuildDom_step_varproofs beginhave hnd := nodup_buildVars hlin hget hsplitand repeat the membership argument forBank.LandBank.R. - duplicate-proof —
LeanPool/FormalLinguistics/MGtoMCFG.lean:2263
Well-formedness and soundness independently unpack the same nested filters and slot-operation results for all three merge and both move families. A change to how the rules are enumerated therefore requires synchronized proof edits. Give each family a membership lemma exposing the selected profiles, successful slot operations, and resulting rule, and use it from both proofs.
Evidence:merge1Rules_wellFormedandmerge1Rules_soundboth startsimp only [merge1Rules, List.mem_flatMap] at hM1, then unpack the sameList.mem_filterMap. The Merge 2 and Merge 3 pairs follow the same pattern. BothbuildRules_wfandmgToMCFG_soundusecases hcl : clearSlot (T := T) f 1 (allLics G) s withandcases hrel : relocateSlot (T := T) f f' δ (allLics G) s with. - duplicate-definition —
LeanPool/FormalLinguistics/MCFGtoMG.lean:386
Variable collection is implemented in the MCFG rule API, both translators, and inline in the binarization proofs. The reverse translator also copies the evaluator's variable lookup and fallback. Define these operations once inMCFG.leanand reuse them so a change to template evaluation or variable collection reaches every consumer.
Evidence:MCFGRule.varOccurrencesandMGtoMCFG.compsVarsboth usecomp.filterMap funwith| MCFGAtom.var i j => some (i, j). The reverse translator usescs.flatMap compVarsand provesr.varOccurrences = compsVars r.yield := rfl.BinMCFG.varOccurrences_remapYieldinlines the same filter.argPieceandMCFG.evalCompboth usematch args[i]? withandmatch tup[j]? with, with| none => []at both levels. - unused-hypothesis —
LeanPool/FormalLinguistics/MGtoMCFG.lean:894
Three slot lemmas require premises absent from their proof terms. Drop the unused premises so callers only supply the invariants each operation needs. In particular, bothrelocateSlot_eval_and_memcallers can omit the uniqueness and coverage proofs for the license list.
Evidence:not_mem_headLic_of_insertSlotandlocateSlot_evaleach bind(_hsmc : SMC ms).relocateSlot_eval_and_membinds(_hLnd : L.Nodup)and(_hLms : ∀ c, c ∈ ms → ∀ g, c.headLic = some g → g ∈ L). The latter proof uses its separate(hsmc : SMC ms)premise. - duplicate-core-api —
LeanPool/FormalLinguistics/MCFGtoMG.lean:87
Several general list operations and proofs duplicate the pinned Lean library. UseList.zipIdxwith swapped pairs and its indexed membership lemma,List.getElem?_of_mem,List.drop_eq_getElem?_toList_append, andList.reverse_permwithList.Perm.nodup_iff. The same cleanup applies toMG.isSuffix,Fixpoint.nodup_length_le,MGMCFGEquiv's replicate equation, and the conditional lemmas inLambekFreeGroup. This removes independent inductions and wrappers for standard operations.
Evidence:indexFromrecurses with| a :: t => (k, a) :: indexFrom (k + 1) t. The local lookup, drop, and reverse lemmas use∃ idx : Nat, L[idx]? = some x,L.drop k = x :: L.drop (k + 1), and(h : L.reverse.Nodup) : L.Nodup. The other copies use∃ p, p ++ s = l,l1.length ≤ l2.length,List.replicate n x ++ [x] = List.replicate (n + 1) x, and(if c then a else b) = aor(if c then a else b) = b. - duplicate-lemma —
LeanPool/FormalLinguistics/LambekThin.lean:25
Thin sequents and interpolation publish separate copies of the same three occurrence-count lemmas. Cut elimination and interpolation also publish the same antecedent transport lemma. Put these next tooccListandLDer0in the shared core so the proofs use one API.
Evidence:LThin.occList_appendstatesoccList q (a ++ b) = occList q a + occList q b, andLInterp.occList_appendstatesoccList p (Γ ++ Δ) = occList p Γ + occList p Δ. Both usesimp [occList, List.sum_append]and sit beside copies ofoccList_nilandoccList_cons.LCut.castandLInterp.castDeach usee ▸ h. - module-coupling —
LeanPool/FormalLinguistics/LambekCore.lean:9
Importing Lambek cut elimination, thin sequents, interpolation, or free-group proofs pulls in the CFG normal forms through the reverse grammar translation. The general Mathlib CFG bridge also pulls in Pentus, and the Stabler–Keenan equivalence imports the cross-serial example development. Put the Lambek syntax and calculus upstream of the translations, put the general bridge upstream of the theorem restatements, and move the examples to a module that imports the equivalence.
Evidence:LambekCore.leanusespublic import LeanPool.FormalLinguistics.Lambek, andLambek.leanusespublic import LeanPool.FormalLinguistics.BarHillelfor results includingcfg_to_lambek_equiv.MathlibBridge.leanusespublic import LeanPool.FormalLinguistics.LambekPentusand definesCFG.ofMathlib.MGOriginal.leanusespublic import LeanPool.FormalLinguistics.MGMCFGEquiv, whose equivalence theorem is followed bynamespace CrossSerialExample.
Tokens: 10,029,638 in / 52,461 out across 5 model calls · Tier: codex-subscription · Effort: xhigh · Billing: Codex subscription quota (no API credits) · Estimated cost: $40.9055 (Standard API equivalent; uncached input)
Each rubric is an independent review against .github/review-rubrics/ on top of .github/REVIEW_RULES.md. Disagree? Reply on the PR; rules can be updated in a PR of their own.
Vilin97
left a comment
There was a problem hiding this comment.
Source review passed for e69454de7e41202b5deeb4fbb5022e18841eb4ce.
- The new citations credit Michaelis’s forward construction, distinguish the converse papers, and describe the chain-based Stabler–Keenan presentation and primitive-goal specialization of Pentus. Michaelis’s forward construction
- The three deduplication declarations and proofs moved unchanged to
Fixpoint.CNFstill reexports that module, and the minimalist translation now imports the smaller dependency directly. The headline statements and proofs are unchanged. Two older docstrings inMGOriginalstill use “literal” where the module documentation describes the formalization’s variants.
Required Lean CI and importer custody are tracked separately. Lean Action CI
|
/review Head The shared list helpers move to |
Vilin97
left a comment
There was a problem hiding this comment.
Source review passed for 4435287d1d97417e83e6ae1b54c3949c08f8a9cd.
- The four CNF definitions bind repeated computations once. Expanding the new
letbindings gives the previous terms, including the filter order and pair deduplication. The theorem statements and proofs are unchanged. - The revised source notes state the lexical-feature restriction of the Stabler–Keenan variant and credit Pentus and Cohen for the respective directions of the Lambek equivalence.
- Required Lean validation is running for this head. Lean Action CI
|
/review Head
|
Result
Three classical grammar equivalences, with explicit translations and their
correctness proofs.
Bar-Hillel, Gaifman and Shamir (1960)
excluding the empty word. The proof includes cut elimination, thin sequents,
interpolation and free-group machinery. Lambek to CFG uses the primitive-goal
case of Pentus’s Theorem 2. CFG to Lambek uses the Greibach-derived basic
categorial lexicon and its embedding in the Lambek calculus, a direction
Pentus’s introduction credits to Cohen.
Pentus (1993),
Kanazawa (2018), Sections 3–4,
Cohen (1967)
multiple context-free grammars. This variant uses nonempty lexical feature
lists, a distinguished basic goal category, and the shortest-move condition.
It formalizes overt phrasal movement.
Stabler and Keenan, §2 Definition 1 and §2.3,
Michaelis, forward,
Michaelis, converse,
Harkema, converse
The CFG transformations use ordered rule lists. The new Mathlib bridge proves
language preservation in both directions and restates the first two equivalences
using
Language.IsContextFree. The normal forms and the LCFRS transformationsremain available as reusable modules. Lean Pool’s existing
PumpingCfgproject includesContextFreeGrammar.toCNF_correctfor Mathlib’sfinite-set grammar representation. The list-based conversion here supplies
the production data for the Greibach and categorial translations.
Upstream and port
theorem added in the 09:04:03 UTC release.
Version 1.0,
Version 2.0
967b3f2cfa05b52ca253b37d3e58b49abd6d150d, MIT.The entry module carries the complete upstream MIT notice. The upstream
credits Gemini and Claude with drafting proof scripts and the author with
direction and audit. The card records AI provenance on that evidence.
Pinned upstream source
normal forms, grammar translations, and Lambek proof theory. The separate
upstream example file and diagnostic commands stay upstream. Added the
Mathlib bridge as a separate module.
fc4f59e577feb1a4956671bc04ac18aaaf8cd842.Converted to the module system, removed the unused-simp suppression by
fixing its proofs, split five proofs to fit the proof-length gate, and
documented the public definitions.
The repository’s project-scoped declaration, axiom, option, and build
message audits pass with the standard three Lean axioms.
Compile measurements and checks
A clean upstream build with four Lean threads took 11.38 s. The comparable
Lean Pool measurement uses
LEAN_NUM_THREADS=4 lake --no-cache build LeanPool.FormalLinguistics.Importswith prebuilt dependencies and a freshproject build directory. The initial lint-clean core took 9.01 s. Reusing
the unique-mover split lemma removes the repeated chain-membership and
list-mapping arguments in both movement cases, and the merge-rule
constructors share the precomputed grammar profiles. Removed nine redundant
direct imports. The review repair also moves the shared list helpers into
Fixpoint.lean, which removes the dependency on the Chomsky normal-formmodule from the minimalist-grammar pipeline. The CFG normal-form code shares
the nullable symbols and unary-path candidates across each conversion.
Lean confirms the four updated definitions are definitionally equal to their
prior versions. Generated code confirms that empty-production elimination
makes one nullability call before its filters. The first clean optimized
core run took 9.82 s on the shared VM. Three alternating clean builds with
one Lean thread, matched
imports and prebuilt dependencies had median wall times of 22.39 s and
22.34 s. Synchronous command profiling measured 151,651 → 148,067
heartbeats for
MGtoMCFG; the two movement proofs together went from11,219 to 7,636 heartbeats, including the new shared lemma.
The wall-clock runs show variation and establish no material overall
speedup. The complete repaired project, including the Mathlib bridge,
built from fresh project artifacts in 8.17 s with four Lean threads.
Locally passed the warning-as-error project build, generated index check,
Mathlib linters, style checks, full-tree static quality checks, and
project-scoped Lean quality audit. The full Lean Pool build and all
applicable checks run in GitHub CI.