Formal Methods + Local AI. Making decisions auditable, testable, and deterministic.
Build a hybrid system where local LLMs translate natural language to formal specifications while independent SMT solvers make deterministic logical decisions.
Move the LLM out of the position of final logical authority. The solver decides SAT/UNSAT; the LLM only translates and explains.
Microsoft SMT solver — Python API
Independent SMT solver — Python API
Logic programming engine
Datalog engine for provenance
Answer set programming
Theorem prover with Lake build
All tools verified
Alice is KYC verified. Bob is not sanctioned. Transfer $8,000. Policy: transfers over $10,000 require review.
Transfer $12,000. Policy: transfers over $10,000 require enhanced review. Enhanced review NOT completed.
Policy A: block all transfers above $10K. Policy B: KYC-verified customers can transfer any amount. Alice is KYC-verified. Transfer $15,000.
The solver proves properties of the formal model it is given. It cannot prove that the model faithfully represents reality unless the translation step is itself checked.
The most important unresolved question: Does Qwen correctly translate natural language to formal logic?
Ollama format parameter with structured output. Pydantic validation before solvers. Reject malformed JSON automatically.
Generate variants: "over $10K" → "at least $10K" → "exactly $10K". Verify formal model changes in expected ways. Detect semantic translation bugs without trusting a second LLM.
Llama 3.1 8B as independent reviewer. Compare original NL with Qwen's JSON. Flag discrepancies as warnings — NOT as hard gate.
Test operators: > vs >= vs ==. Test negations, exceptions, quantifiers.
/root/fol-labresults/validation_gate/ ├── case_A_original/ │ ├── nl_input.txt │ ├── qwen_json.json │ ├── schema_validation.json │ ├── mutation_diffs.json │ ├── z3_result.txt │ ├── cvc5_result.txt │ ├── metrics.json │ └── final_explanation.txt ├── case_A_mutations/ ├── case_B_original/ ├── case_B_mutations/ ├── case_C_original/ ├── case_C_mutations/ └── summary.md
Use Ollama's format parameter with JSON Schema. More reliable than prompt engineering alone.
Auto-generate semantic variants and verify formal model changes correctly. Catches translation bugs without trusting a second LLM.
Always use REAL Z3 and CVC5. Never mock the solvers — that defeats the entire purpose.
Qwen3-Coder-30B-A3B does NOT support thinking mode. Don't use <thinking> blocks.
The second LLM is advisory only. Disagreement → flag for review. Agreement → NOT proof of correctness.
Save structured justifications (source_clause → extracted_rule → operator → threshold), not internal model "thoughts".
This architecture addresses a fundamental problem in AI safety: how to make LLM decisions auditable and deterministic.
Every decision has a formal proof trail.
Same formal constraints → same solver result.
When things go wrong, distinguish translation error from logic error.
Formal specifications can be reviewed by humans, lawyers, regulators.
The objective is NOT "make AI regulation deterministic." The objective is to identify exactly which parts can be made explicit, testable, auditable, and reproducible — and where human/legal judgment remains mandatory.