Chiasmus: Formal Reasoning Engine Gives LLMs Code Analysis Superpowers
Key Takeaways
- ▸Chiasmus pairs LLMs with formal reasoning engines (Z3 constraint solver, Tau Prolog logic engine) for exhaustive code analysis
- ▸Replaces grep-based searching with structured parsing (tree-sitter) and logical queries, enabling true semantic code understanding
- ▸Neurosymbolic approach: LLMs provide perception and language understanding; symbolic solvers provide provable reasoning and verification
Summary
Chiasmus, an open-source MCP server, addresses a fundamental weakness in how large language models analyze code. While traditional LLM code assistants rely on grep and ad hoc pattern matching to search through source files and reconstruct call chains, these methods fail for complex structural questions like 'Can user input reach this SQL query through any chain of calls?' or 'What's all the dead code in this module?' These problems require exhaustive structural analysis that grep simply cannot provide.
The project implements a neurosymbolic AI approach, combining the pattern recognition and language understanding of neural networks (LLMs) with the deterministic reasoning power of symbolic systems. Chiasmus leverages Z3 for constraint solving and Tau Prolog for logic programming, while using tree-sitter to parse source files into structured abstract syntax trees. These ASTs are converted into Prolog facts representing code structure—method definitions, call relationships, imports—which the logic solver can query to answer code structure questions with certainty.
Supporting Python, Go, TypeScript, JavaScript, and Clojure out of the box, Chiasmus enables LLMs to perform exhaustive code analysis including reachability analysis, dead code detection, and impact analysis while using a fraction of the tokens required by grep-based approaches. By shifting from text search to formal logical reasoning, the tool demonstrates how symbolic reasoning can complement LLM capabilities to build more reliable AI-assisted development tools.
- Dramatically more token-efficient and accurate than traditional grep-based code analysis approaches
- Open-source MCP server enabling enhanced code assistant capabilities for Claude and other LLMs


