Skip to content

Commit 572b9b7

Browse files
hyperpolymathclaude
andcommitted
feat(corpus): Coq + Lean 4 + Idris 2 adapters; cross-prover semantic classes
Step 2 of the N-dim VeriSim corpus plan. Adds three prover adapters mirroring `corpus/agda.rs` and a `semantic_class` extension to the synonym schema for cross-prover equivalence joins. ## Adapters * `corpus/coq.rs` — `(* … *)` nestable comments, dot-terminated sentences, classified by leading keyword. Recognises Theorem / Lemma / Fact / Corollary / Proposition / Remark (with Proof. … Qed./Defined./Admitted.), Definition / Fixpoint / CoFixpoint / Function, Inductive / CoInductive, Record / Structure, Axiom / Variable / Parameter / Hypothesis / Conjecture (postulates), Module, Section, Require Import / Export. Hazards: `Admitted`, `Axiom`. 7 unit tests + verified on echidna's `proofs/coq/` fixtures (5 modules, 108 entries). * `corpus/lean.rs` — `--` line + `/- … -/` nestable + `/-- … -/` doc comments. Top-level keyword detection by `trim_start` (column 0 was too restrictive — comment-stripping pushes decls off-column). Recognises def / theorem / lemma / example / abbrev / inductive / structure / class / instance / axiom / constant / namespace. Strips `@[…]` attributes and `private` / `protected` / `noncomputable` / `partial` / `unsafe` / `mutual` modifiers before keyword match. Hazards: `sorry`, `admit`. 9 unit tests + verified on jtv-proofs (7 modules, 147 entries). * `corpus/idris2.rs` — closest to Agda. Recognises `module M.N` (no `where`), `import` / `import public`, postulate-blocks, postulate single-line, data / record / interface, `name : ty` + multi-clause body, doc comments `||| …`, pragmas `%foreign / %default / %hint`. Hazards: `believe_me`, `assert_total`, `assert_smaller`, `idris_crash`, `unsafePerformIO`. 7 unit tests + verified on eclexia/src/abi (4 modules, 93 entries). ## Cross-prover semantic class `SynonymEntry` gains `semantic_class: Option<String>`. Two entries (potentially from different prover tables) sharing the same class are semantically equivalent. Coarse classes only — fine equivalence belongs in the OpenTheory/Dedukti exchange layer. Seeded across 4 provers: * `well-foundedness`: WellFounded (Agda/Lean/Idris) ↔ well_founded (Coq) * `accessibility`: Acc (Agda/Coq/Lean) ↔ Accessible (Idris 2) * `wf-induction`: wf-induction / well_founded_induction / WellFounded.induction / wfRec * `wf-subrelation-transport`: Subrelation.wellFounded (Agda) New CLI: `echidna corpus crossquery <semantic-class>` loads every prover's synonym table and prints all entries tagged with the class. Verified end-to-end: ``` $ echidna corpus crossquery well-foundedness Agda: WellFounded Coq: well_founded Lean: WellFounded Idris2: WellFounded 4 entries across 4 provers ``` ## Tests 30 corpus tests pass (7 Coq + 9 Lean + 7 Idris 2 + 7 existing Agda). 4 synonyms tests pass. Existing 1006-test suite unaffected (SynonymEntry construction site in suggest/variant.rs updated for the new optional field). ## Known limitations (deferred to Step 3 + capstone) * Adapters store dependency edges by short name; cross-module name collisions widen reverse-closures (documented in Step 1 commit). Step 3's VeriSim octad migration is the natural fix — the Provenance octad lets us key dependencies on stable content hashes, not text names. * Each prover's corpus is its own JSON file. Cross-prover queries via `corpus crossquery` go through the synonym layer, not the corpus layer. The capstone DSL unifies them. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent e599868 commit 572b9b7

11 files changed

Lines changed: 2277 additions & 13 deletions

File tree

data/synonyms/agda.toml

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
# ---------------------------------------------------------------------------
1515

1616
[[synonym]]
17-
canonical = "WellFounded"
18-
aliases = ["WellFounded _<_", "Wellfounded"]
19-
tactic_class = "wf-statement"
20-
notes = """
17+
canonical = "WellFounded"
18+
aliases = ["WellFounded _<_", "Wellfounded"]
19+
tactic_class = "wf-statement"
20+
semantic_class = "well-foundedness"
21+
notes = """
2122
`WellFounded R` is `∀ x → Acc R x` in `Induction.WellFounded`.
2223
Two constructive proof strategies, both used in echo-types:
2324
@@ -36,10 +37,11 @@ prove `rank-mono`, transport.
3637
"""
3738

3839
[[synonym]]
39-
canonical = "Acc"
40-
aliases = ["Acc R x", "accessible", "Accessible"]
41-
tactic_class = "wf-witness"
42-
notes = """
40+
canonical = "Acc"
41+
aliases = ["Acc R x", "accessible", "Accessible"]
42+
tactic_class = "wf-witness"
43+
semantic_class = "accessibility"
44+
notes = """
4345
Accessibility predicate: `Acc R x` says every `R`-descending sequence
4446
from `x` is finite. Constructed via `acc : (∀ y → R y x → Acc R y) → Acc R x`.
4547
@@ -66,14 +68,15 @@ problem under `--without-K` (see the `<ᵇ-ψα` blocker in
6668
# ---------------------------------------------------------------------------
6769

6870
[[synonym]]
69-
canonical = "Subrelation.wellFounded"
70-
aliases = [
71+
canonical = "Subrelation.wellFounded"
72+
aliases = [
7173
"Induction.WellFounded.Subrelation.wellFounded",
7274
"subrel-wf",
7375
"wf-from-subrelation",
7476
]
75-
tactic_class = "wf-transport"
76-
notes = """
77+
tactic_class = "wf-transport"
78+
semantic_class = "wf-subrelation-transport"
79+
notes = """
7780
`Subrelation R ⇒ S → WellFounded S → WellFounded R`. The first
7881
argument is `R ⇒ S`, the implication of relations. Used to
7982
*push WF down* a subrelation: if you can show the small relation

data/synonyms/coq.toml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,37 @@ notes = """
148148
When unfold loops or produces unwieldy goals, prefer `change` for
149149
surgical control.
150150
"""
151+
152+
# ---------------------------------------------------------------------------
153+
# Well-foundedness (cross-prover semantic class)
154+
# ---------------------------------------------------------------------------
155+
156+
[[synonym]]
157+
canonical = "well_founded"
158+
aliases = ["well_founded R", "Wf"]
159+
tactic_class = "wf-statement"
160+
semantic_class = "well-foundedness"
161+
notes = """
162+
`well_founded R` in `Coq.Init.Wf`: every chain in `R` is finite.
163+
Same conceptual role as Agda's `WellFounded`, Lean's `WellFounded`,
164+
and Idris 2's `WellFounded`.
165+
"""
166+
167+
[[synonym]]
168+
canonical = "Acc"
169+
aliases = ["Acc R x", "accessible"]
170+
tactic_class = "wf-witness"
171+
semantic_class = "accessibility"
172+
notes = """
173+
`Acc R x` in `Coq.Init.Wf`: `x` is `R`-accessible.
174+
"""
175+
176+
[[synonym]]
177+
canonical = "well_founded_induction"
178+
aliases = ["Fix", "Fix_F"]
179+
tactic_class = "wf-recursor"
180+
semantic_class = "wf-induction"
181+
notes = """
182+
The recursor derived from `well_founded`: prove `P x` from
183+
`(forall y, R y x -> P y) -> P x`.
184+
"""

data/synonyms/idris2.toml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# SPDX-License-Identifier: PMPL-1.0-or-later
2+
#
3+
# Idris 2 + base / contrib library synonyms.
4+
# Schema: see data/synonyms/README.adoc.
5+
# Seeded 2026-04-28 alongside the cross-prover semantic-class
6+
# extension (Step 2 of the N-dim VeriSim corpus plan).
7+
8+
# ---------------------------------------------------------------------------
9+
# Well-foundedness (cross-prover semantic class)
10+
# ---------------------------------------------------------------------------
11+
12+
[[synonym]]
13+
canonical = "WellFounded"
14+
aliases = ["WellFounded R", "Wf"]
15+
tactic_class = "wf-statement"
16+
semantic_class = "well-foundedness"
17+
notes = """
18+
`WellFounded R` in `Control.WellFounded` (base): every R-chain is
19+
finite. Same conceptual role as Agda's `WellFounded`, Coq's
20+
`well_founded`, and Lean 4's `WellFounded`.
21+
"""
22+
23+
[[synonym]]
24+
canonical = "Accessible"
25+
aliases = ["Acc", "Acc R x"]
26+
tactic_class = "wf-witness"
27+
semantic_class = "accessibility"
28+
notes = """
29+
`Accessible R x` in `Control.WellFounded`. Idris 2's name differs
30+
from the others; the type-shape is identical.
31+
"""
32+
33+
[[synonym]]
34+
canonical = "wfRec"
35+
aliases = ["WellFounded.induction", "well-founded-induction"]
36+
tactic_class = "wf-recursor"
37+
semantic_class = "wf-induction"
38+
notes = """
39+
Well-founded recursion derived from `WellFounded`.
40+
"""
41+
42+
# ---------------------------------------------------------------------------
43+
# Banned / dangerous patterns
44+
# ---------------------------------------------------------------------------
45+
46+
[[synonym]]
47+
canonical = "believe_me"
48+
aliases = ["unsafeCoerce", "Obj.magic"]
49+
tactic_class = "danger"
50+
notes = """
51+
Idris 2's unsafe cast. BANNED across the whole hyperpolymath estate
52+
(panic-attack rejects). Use a constructive proof or a `partial`
53+
totality annotation instead.
54+
"""
55+
56+
[[synonym]]
57+
canonical = "assert_total"
58+
aliases = ["assert_smaller", "%total-fudge"]
59+
tactic_class = "danger"
60+
notes = """
61+
Tells the totality checker to trust this call without proof. Avoid;
62+
restructure to a structurally-decreasing recursion or use
63+
`well-founded-recursion` with an explicit measure.
64+
"""
65+
66+
[[synonym]]
67+
canonical = "idris_crash"
68+
aliases = ["partial-stub"]
69+
tactic_class = "stub"
70+
notes = """
71+
Per project memory (Cerro-Torre 2026-04-25): `partial + idris_crash`
72+
is the accepted pattern for postulate-style stubs that downstream
73+
proofs are allowed to depend on, provided the dependent is also
74+
annotated `partial` and the design intent is documented.
75+
76+
Not preferred for new code, but recognised as the workaround when
77+
Idris 2 0.8.0's `postulate` is unavailable in the desired position.
78+
"""

data/synonyms/lean4.toml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,38 @@ notes = """
155155
`conv => rw [h]` — surgical rewrite at a specific subterm.
156156
When `rw` fails to match, drop to `conv` for finer control.
157157
"""
158+
159+
# ---------------------------------------------------------------------------
160+
# Well-foundedness (cross-prover semantic class)
161+
# ---------------------------------------------------------------------------
162+
163+
[[synonym]]
164+
canonical = "WellFounded"
165+
aliases = ["WellFounded R", "Wf"]
166+
tactic_class = "wf-statement"
167+
semantic_class = "well-foundedness"
168+
notes = """
169+
`WellFounded R` in core Lean 4: every R-chain is finite. Mathlib
170+
adds `WellFoundedRelation` as an instance class. Same conceptual
171+
role as Agda's `WellFounded`, Coq's `well_founded`, and Idris 2's
172+
`WellFounded`.
173+
"""
174+
175+
[[synonym]]
176+
canonical = "Acc"
177+
aliases = ["Acc r x", "Accessible"]
178+
tactic_class = "wf-witness"
179+
semantic_class = "accessibility"
180+
notes = """
181+
`Acc r x` in core Lean 4: `x` is `r`-accessible.
182+
"""
183+
184+
[[synonym]]
185+
canonical = "WellFounded.induction"
186+
aliases = ["WellFoundedRecursion", "termination_by"]
187+
tactic_class = "wf-recursor"
188+
semantic_class = "wf-induction"
189+
notes = """
190+
The induction principle from `WellFounded`. `termination_by` in a
191+
`def` body invokes the same machinery for recursive definitions.
192+
"""

0 commit comments

Comments
 (0)