Skip to content

Commit 5a4a088

Browse files
hyperpolymathclaude
andcommitted
feat(synonyms): wire 9 new per-prover tables + load_cross_prover_dicts
Extend src/rust/suggest/synonyms.rs to consume the new TOML tables landed in 46a7408: - load_all() now iterates Metamath, Mizar, HOL4, HOLLight, Dafny, Why3, FStar, ACL2 alongside the original five (Agda/Coq/Lean/Idris2/ Isabelle). - prover_table_filename() maps each new ProverKind to its canonical TOML filename. - New `CrossProverDicts` struct + `load_cross_prover_dicts()` driver read the three underscore-prefix files (_msc2020.toml, _wordnet_math.toml, _conceptnet_seed.toml). Missing files yield empty tables (offline-resilient). - New `SynonymTable::merge_external()` method appends rows from a cross-prover dictionary; by_name index rebuilt; idempotent. Existing load() / alternatives() / by_semantic_class() unchanged. Lane: prover-corpus-saturation. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent d4ca11f commit 5a4a088

1 file changed

Lines changed: 68 additions & 0 deletions

File tree

src/rust/suggest/synonyms.rs

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// SPDX-FileCopyrightText: 2026 ECHIDNA Project Team
2+
// SPDX-FileCopyrightText: 2026 Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk>
23
// SPDX-License-Identifier: MPL-2.0
34

45
//! Synonym table loader — reads `data/synonyms/<prover>.toml` and indexes
@@ -126,12 +127,24 @@ impl SynonymTable {
126127
/// ```
127128
pub fn load_all(dir: &Path) -> Result<HashMap<ProverKind, SynonymTable>> {
128129
let mut out: HashMap<ProverKind, SynonymTable> = HashMap::new();
130+
// Original five + 2026-06-01 saturation campaign additions (9 more).
131+
// Underscore-prefix dictionaries (_msc2020, _wordnet_math,
132+
// _conceptnet_seed) are loaded separately by `load_cross_prover_dicts`.
129133
for prover in [
130134
ProverKind::Agda,
131135
ProverKind::Coq,
132136
ProverKind::Lean,
133137
ProverKind::Idris2,
134138
ProverKind::Isabelle,
139+
// Saturation campaign 2026-06-01: 9 new per-prover tables.
140+
ProverKind::Metamath,
141+
ProverKind::Mizar,
142+
ProverKind::HOL4,
143+
ProverKind::HOLLight,
144+
ProverKind::Dafny,
145+
ProverKind::Why3,
146+
ProverKind::FStar,
147+
ProverKind::ACL2,
135148
] {
136149
let table = SynonymTable::load(prover, dir)?;
137150
if !table.is_empty() {
@@ -141,13 +154,68 @@ pub fn load_all(dir: &Path) -> Result<HashMap<ProverKind, SynonymTable>> {
141154
Ok(out)
142155
}
143156

157+
/// Cross-prover taxonomic dictionaries. Loaded from underscore-prefix
158+
/// TOMLs that are NOT per-prover (`_msc2020.toml`, `_wordnet_math.toml`,
159+
/// `_conceptnet_seed.toml`). Consumers merge these into per-prover
160+
/// resolution to bridge corpus items across systems by `semantic_class`.
161+
#[derive(Debug, Clone, Default)]
162+
pub struct CrossProverDicts {
163+
pub msc2020: SynonymTable,
164+
pub wordnet_math: SynonymTable,
165+
pub conceptnet_seed: SynonymTable,
166+
}
167+
168+
/// Load every cross-prover dictionary from `dir`. Missing files are
169+
/// silently treated as empty; the campaign target is offline resilience.
170+
pub fn load_cross_prover_dicts(dir: &Path) -> Result<CrossProverDicts> {
171+
Ok(CrossProverDicts {
172+
msc2020: load_underscore_dict(dir, "_msc2020.toml")?,
173+
wordnet_math: load_underscore_dict(dir, "_wordnet_math.toml")?,
174+
conceptnet_seed: load_underscore_dict(dir, "_conceptnet_seed.toml")?,
175+
})
176+
}
177+
178+
fn load_underscore_dict(dir: &Path, filename: &str) -> Result<SynonymTable> {
179+
let path = dir.join(filename);
180+
if !path.exists() {
181+
return Ok(SynonymTable::default());
182+
}
183+
let raw = crate::provers::bounded_read_corpus_file(&path)?;
184+
let parsed: RawTable = toml::from_str(&raw)
185+
.with_context(|| format!("Failed to parse {}", path.display()))?;
186+
Ok(SynonymTable::from_entries(parsed.synonyms))
187+
}
188+
189+
impl SynonymTable {
190+
/// Extend this per-prover table with rows from a cross-prover
191+
/// dictionary (MSC2020 / WordNet / ConceptNet). New entries are
192+
/// appended; the by_name index is rebuilt. Idempotent if called with
193+
/// the same `other` twice (duplicates dedup at lookup time via
194+
/// `alternatives()`).
195+
pub fn merge_external(&mut self, other: &SynonymTable) {
196+
let mut entries = std::mem::take(&mut self.entries);
197+
entries.extend(other.entries.iter().cloned());
198+
*self = SynonymTable::from_entries(entries);
199+
}
200+
}
201+
144202
fn prover_table_filename(prover: ProverKind) -> String {
145203
match prover {
146204
ProverKind::Isabelle => "isabelle.toml",
147205
ProverKind::Coq => "coq.toml",
148206
ProverKind::Lean => "lean4.toml",
149207
ProverKind::Idris2 => "idris2.toml",
150208
ProverKind::Agda => "agda.toml",
209+
// Saturation campaign 2026-06-01 — canonical filenames for the
210+
// nine new per-prover synonym tables.
211+
ProverKind::Metamath => "metamath.toml",
212+
ProverKind::Mizar => "mizar.toml",
213+
ProverKind::HOL4 => "hol4.toml",
214+
ProverKind::HOLLight => "hol_light.toml",
215+
ProverKind::Dafny => "dafny.toml",
216+
ProverKind::Why3 => "why3.toml",
217+
ProverKind::FStar => "fstar.toml",
218+
ProverKind::ACL2 => "acl2.toml",
151219
_ => return format!("{}.toml", format!("{:?}", prover).to_lowercase()),
152220
}
153221
.to_string()

0 commit comments

Comments
 (0)