Skip to content

Commit cf9dff6

Browse files
Jonathan D.A. Jewellclaude
andcommitted
feat: add HOL4 tests and update NEUROSYM.scm with v2 radial network spec
- Add 12 unit tests for HOL4 prover backend - Parser tests: simple term, numeral, application, lambda, forall, exists - Type tests: bool, num, arrow (function type) - Backend tests: creation, config, term conversion - Fix type mismatches using correct HOL4Type variants (TyCon, TyFun) - Update NEUROSYM.scm to v2.0.0 with radial network architecture spec - Document RBFN for similarity-based proof acceleration - Include similarity matching, prover integration, axiom theory alignment - Add workflow, challenges, and ECHIDNA-specific integration notes Test results: 114 unit tests, 38 integration tests all passing Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent f106963 commit cf9dff6

2 files changed

Lines changed: 217 additions & 5 deletions

File tree

.machine_readable/NEUROSYM.scm

Lines changed: 77 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,85 @@
11
;; SPDX-License-Identifier: AGPL-3.0-or-later
2-
;; NEUROSYM.scm - Neurosymbolic integration config for echidna
2+
;; NEUROSYM.scm - Neurosymbolic integration config for ECHIDNA
33

44
(define neurosym-config
5-
`((version . "1.0.0")
5+
`((version . "2.0.0")
6+
7+
;; Current implementation (v1): GNN + Transformer
68
(symbolic-layer
79
((type . "scheme")
810
(reasoning . "deductive")
911
(verification . "formal")))
12+
1013
(neural-layer
11-
((embeddings . false)
12-
(fine-tuning . false)))
13-
(integration . ())))
14+
((architecture . "gnn-transformer")
15+
(embeddings . true)
16+
(fine-tuning . false)
17+
(prover-encoders . ("agda" "coq" "lean" "isabelle" "z3" "cvc5"
18+
"metamath" "hol-light" "mizar" "pvs" "acl2" "hol4"))))
19+
20+
(integration
21+
((rust-julia-api . "http")
22+
(api-port . 8081)
23+
(caching . true)
24+
(diversity-ranking . true)))
25+
26+
;; v2 Planned: Radial Basis Function Network Integration
27+
(v2-radial-network
28+
((status . "planned")
29+
(description . "RBFN for similarity-based proof acceleration")
30+
31+
;; Core concept: Radial networks (RBFNs) for similarity matching
32+
(similarity-matching
33+
((feature-extraction . "Encode proofs, theorems, problem states as vectors using embeddings from proof terms, syntax trees, or semantic graphs")
34+
(similarity-metric . "Gaussian kernel radial basis functions to measure similarity between new problems and solved proofs/axioms")
35+
(clustering . "Group similar proofs/problem states for efficient axiom retrieval")))
36+
37+
;; Integration with multi-prover system
38+
(prover-integration
39+
;; A. Preprocessing: Axiom/Proof Embedding
40+
((embedding-layer . "Convert axioms, lemmas, proof steps to shared vector space via GNN for syntax trees or transformers for proof scripts")
41+
(radial-basis . "Train RBFN on embeddings to map similar proofs/theorems to nearby regions")
42+
43+
;; B. Real-Time Acceleration
44+
(query-matching . "Embed new problem state and query RBFN for most similar axioms/proof fragments")
45+
(proof-guidance . (
46+
"Prune search spaces (SAT solvers, tableau methods)"
47+
"Suggest relevant lemmas (Lean4/Coq tactics)"
48+
"Prioritize solver strategies based on historical success"))
49+
50+
;; C. Dynamic Learning
51+
(feedback-loop . "Update RBFN with new embeddings as solver proves theorems")
52+
(active-learning . "Focus on regions where solver struggles")))
53+
54+
;; Axiom theory alignment
55+
(axiom-theory
56+
((axiom-selection . "Prioritize frequently-used axioms from similar proofs")
57+
(hierarchical-abstraction . "Abstract over low-level proof steps for higher-level reasoning")
58+
(consistency-checks . "Cross-validate retrieved axioms against problem's logical context")))
59+
60+
;; Implementation architecture
61+
(architecture
62+
((symbolic-core . "Handles formal logic and verification via prover backends")
63+
(neural-accelerator . "RBFN guides search, reduces redundant computations")
64+
(database-backend . "Graph database for embeddings (ArangoDB/Virtuoso)")
65+
(approximate-nn . "FAISS/Annoy for scalable nearest-neighbor search")))
66+
67+
;; Workflow
68+
(workflow
69+
("1. Input: New conjecture from any of 12 provers"
70+
"2. Embed: Convert conjecture and context to vector"
71+
"3. Retrieve: RBFN returns similar proofs/axioms from database"
72+
"4. Solve: Solver uses hints to construct proof, fallback to exhaustive search"
73+
"5. Update: Add new proof embedding to RBFN"))
74+
75+
;; Challenges
76+
(challenges
77+
((soundness . "Ensure suggestions are logically valid via formal verification")
78+
(scalability . "Use approximate NN for large proof corpora")
79+
(interpretability . "Visualize similarity space with UMAP/t-SNE")))
80+
81+
;; ECHIDNA-specific integration
82+
(echidna-integration
83+
((tree-of-thought . "RBFN acts as subsequent selector for proof tree exploration")
84+
(anti-tampering . "Hash embeddings with SHAKE-256 for proof integrity")
85+
(proactive-suggestions . "Preemptively suggest optimizations based on proof patterns")))))))

src/rust/provers/hol4.rs

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2115,3 +2115,143 @@ impl ProverBackend for Hol4Backend {
21152115
self.config = config;
21162116
}
21172117
}
2118+
2119+
// ============================================================================
2120+
// Tests
2121+
// ============================================================================
2122+
2123+
#[cfg(test)]
2124+
mod tests {
2125+
use super::*;
2126+
2127+
#[test]
2128+
fn test_parse_simple_term() {
2129+
let mut parser = HOL4Parser::new("x");
2130+
let term = parser.parse_term().unwrap();
2131+
match term {
2132+
HOL4Term::Var { name, .. } => assert_eq!(name, "x"),
2133+
_ => panic!("Expected variable"),
2134+
}
2135+
}
2136+
2137+
#[test]
2138+
fn test_parse_numeral() {
2139+
let mut parser = HOL4Parser::new("42");
2140+
let term = parser.parse_term().unwrap();
2141+
assert_eq!(term, HOL4Term::Numeral(42));
2142+
}
2143+
2144+
#[test]
2145+
fn test_parse_application() {
2146+
let mut parser = HOL4Parser::new("f x");
2147+
let term = parser.parse_term().unwrap();
2148+
match term {
2149+
HOL4Term::App { func, arg } => {
2150+
match *func {
2151+
HOL4Term::Var { name, .. } => assert_eq!(name, "f"),
2152+
_ => panic!("Expected function variable"),
2153+
}
2154+
match *arg {
2155+
HOL4Term::Var { name, .. } => assert_eq!(name, "x"),
2156+
_ => panic!("Expected argument variable"),
2157+
}
2158+
}
2159+
_ => panic!("Expected application"),
2160+
}
2161+
}
2162+
2163+
#[test]
2164+
fn test_parse_lambda() {
2165+
let mut parser = HOL4Parser::new("\\x. x");
2166+
let term = parser.parse_term().unwrap();
2167+
match term {
2168+
HOL4Term::Abs { var, body, .. } => {
2169+
assert_eq!(var, "x");
2170+
match *body {
2171+
HOL4Term::Var { name, .. } => assert_eq!(name, "x"),
2172+
_ => panic!("Expected variable in body"),
2173+
}
2174+
}
2175+
_ => panic!("Expected lambda abstraction"),
2176+
}
2177+
}
2178+
2179+
#[test]
2180+
fn test_parse_forall() {
2181+
let mut parser = HOL4Parser::new("!x. P x");
2182+
let term = parser.parse_term().unwrap();
2183+
match term {
2184+
HOL4Term::Quant { quantifier, var, .. } => {
2185+
assert_eq!(quantifier, HOL4Quantifier::Forall);
2186+
assert_eq!(var, "x");
2187+
}
2188+
_ => panic!("Expected forall quantification"),
2189+
}
2190+
}
2191+
2192+
#[test]
2193+
fn test_parse_exists() {
2194+
let mut parser = HOL4Parser::new("?x. P x");
2195+
let term = parser.parse_term().unwrap();
2196+
match term {
2197+
HOL4Term::Quant { quantifier, var, .. } => {
2198+
assert_eq!(quantifier, HOL4Quantifier::Exists);
2199+
assert_eq!(var, "x");
2200+
}
2201+
_ => panic!("Expected exists quantification"),
2202+
}
2203+
}
2204+
2205+
#[test]
2206+
fn test_parse_type_bool() {
2207+
let mut parser = HOL4Parser::new("bool");
2208+
let ty = parser.parse_type().unwrap();
2209+
assert_eq!(ty, HOL4Type::TyCon("bool".to_string()));
2210+
}
2211+
2212+
#[test]
2213+
fn test_parse_type_num() {
2214+
let mut parser = HOL4Parser::new("num");
2215+
let ty = parser.parse_type().unwrap();
2216+
assert_eq!(ty, HOL4Type::TyCon("num".to_string()));
2217+
}
2218+
2219+
#[test]
2220+
fn test_parse_type_arrow() {
2221+
let mut parser = HOL4Parser::new("num -> bool");
2222+
let ty = parser.parse_type().unwrap();
2223+
match ty {
2224+
HOL4Type::TyFun { domain, range } => {
2225+
assert_eq!(*domain, HOL4Type::TyCon("num".to_string()));
2226+
assert_eq!(*range, HOL4Type::TyCon("bool".to_string()));
2227+
}
2228+
_ => panic!("Expected function type"),
2229+
}
2230+
}
2231+
2232+
#[test]
2233+
fn test_term_to_universal() {
2234+
let term = HOL4Term::Numeral(42);
2235+
let universal = Hol4Backend::hol4_to_term(&term);
2236+
match universal {
2237+
Term::Const(name) => assert_eq!(name, "42"),
2238+
_ => panic!("Expected constant"),
2239+
}
2240+
}
2241+
2242+
#[test]
2243+
fn test_hol4_backend_creation() {
2244+
let backend = Hol4Backend::new(ProverConfig::default());
2245+
assert_eq!(backend.kind(), ProverKind::HOL4);
2246+
}
2247+
2248+
#[test]
2249+
fn test_hol4_config() {
2250+
let config = ProverConfig {
2251+
executable: PathBuf::from("/usr/bin/hol4"),
2252+
..Default::default()
2253+
};
2254+
let backend = Hol4Backend::new(config);
2255+
assert_eq!(backend.config().executable, PathBuf::from("/usr/bin/hol4"));
2256+
}
2257+
}

0 commit comments

Comments
 (0)