Tech Stack: Python, Poetry, cvc5, Jupyter, Pandas, Matplotlib
CRTSolver is a novel Chinese Remainder Theorem-based heuristic algorithm in Python, extending the cvc5 SMT solver to accelerate software/hardware verification workflows.
The algorithm is designed for more efficient and successful solving of QF_NIA problems, combining the CRT-based heuristic with bit-vector encoding to achieve up to 7.8x speedup and a 7.1% higher solve rate over baseline cvc5.
CRTSolver is a prototype SMT solver for non-linear integer equations that leverages a Chinese Remainder Theorem-based heuristic and bit-vector encoding to achieve performance comparable or better than Z3 and cvc5 in quantifier-free non-linear integer arithmetic logic (QF_NIA) under 10-second timeouts and 4GB memory limits, across 38 SMT-LIB benchmarks with one to three variables, quadratic or cubic degree, and mixed SAT/UNSAT status.
The algorithm uses an abstraction–refinement style semi-decision procedure for sets of polynomial equations over the integers. A modulo solver, implemented using cvc5, incrementally solves copies of the problem modulo an ascending sequence of pairwise-coprime moduli. Models from all modulo instances seen so far are combined using the Chinese Remainder Theorem to produce candidate solutions modulo the product of the moduli; these are lifted to a small family of integer candidates, each of which is checked by a second cvc5 instance over the original non-linear integer formula.
Unsatisfiability modulo some modulus proves UNSAT, while a satisfying candidate proves SAT; otherwise additional moduli and candidates are explored. The implementation offers Integer and Bit-Vector modes, using QF_NIA and quantifier-free bit-vector (QF_BV) logic respectively.
During development, it was also necessary to create cvc5 and Z3 batch-solving scripts, which are available as CLI tools within this repository.
You’ll need:
- Linux
- Python 3.10–3.12
- Poetry (for dependency and environment management)
- Visual Studio Code
- Python and Jupyter extensions for VS Code
Optional (for classic Jupyter usage):
jupyterlabornotebookinstalled in your environment
git clone https://github.com/maheenmatin/CRTSolver
cd CRTSolverPoetry will create a virtual environment in .venv inside the project:
poetry config virtualenvs.in-project true
poetry installThis will:
- Install the
crtsolverpackage (fromsrc/) in editable/development mode. - Install all runtime dependencies (cvc5, z3-solver, numpy, pandas, matplotlib, …).
- Install dev dependencies (e.g.
ipykernel) for notebook usage.
The project exposes three console scripts via Poetry:
crt-solvercvc5-solverz3-solver
Each accepts:
--time_limit(int, milliseconds; default:30000)--solver_name(string; used in result output)
In addition, crt-solver accepts:
--integer_mode(flag; if present, use integer mode instead of bit-vector mode)
From the project root:
# CRTSolver (Bit-Vector Mode)
poetry run crt-solver \
--time_limit 30000 \
--solver_name "CRTSolver"
# CRTSolver (Integer Mode)
poetry run crt-solver \
--time_limit 30000 \
--solver_name "CRTSolver" \
--integer_mode
# cvc5
poetry run cvc5-solver \
--time_limit 30000 \
--solver_name "cvc5"
# Z3
poetry run z3-solver \
--time_limit 30000 \
--solver_name "z3"Results are written into the results/ directory.
From the project root:
code .-
Press
Ctrl+Shift+P. -
Run “Python: Select Interpreter”.
-
Choose the interpreter located in
.venv, e.g.:Python 3.x.x ('.venv': poetry) ...
poetry run python -m ipykernel install --user --name=crtsolver-poetryYou can then choose crtsolver-poetry as the kernel in VS Code.
- In VS Code, open:
notebooks/comparative_analysis.ipynb. - In the top-right, select Kernel → choose either:
crtsolver-poetry, or- the
.venvPython environment.
- Run all cells.
The notebook:
-
Uses the installed
crtsolverpackage:from crtsolver.solvers import crt_solver, cvc5_solver, z3_solver
-
Uses
reports.generatorsutilities:from reports.generators import csv_combiner, latex_generator
-
Reads test instances from
tests/. -
Writes solver results to
results/and report artefacts (e.g. combined CSVs, cactus plot PDFs) toreports/.
The reports/generators modules provide post-processing helpers:
csv_combiner.py– combines per-run CSVs fromresults/into a single CSV underreports/.latex_generator.py– consumes the combined CSV and generates LaTeX artefacts.
poetry run python reports/generators/csv_combiner.py
poetry run python reports/generators/latex_generator.pyfrom reports.generators import csv_combiner, latex_generator
csv_combiner.main()
latex_generator.main()CRTSolver/
├── .gitignore
├── LICENSE
├── poetry.lock
├── pyproject.toml
├── README.md
├── third_party_licences/
│ └── ...
├── src/
│ └── crtsolver/
│ ├── __init__.py
│ ├── crt_components/
│ │ ├── __init__.py
│ │ ├── engine/
│ | | └── ...
│ │ ├── helpers/
│ | | └── ...
│ │ |── errors/
│ | | └── ...
│ ├── input_output/
│ │ ├── __init__.py
│ | ├── ...
│ └── solvers/
│ ├── __init__.py
│ ├── crt_solver.py
│ ├── cvc5_solver.py
│ └── z3_solver.py
├── tests/
│ └── ...
├── results/
│ └── ...
├── reports/
│ ├── __init__.py
│ └── generators/
│ ├── __init__.py
│ ├── csv_combiner.py
│ └── latex_generator.py
└── notebooks/
└── comparative_analysis.ipynb