A DSL and tools for neural network certification
Project description
ConstraintFlow
ConstraintFlow is a domain-specific language (DSL) and toolchain for specifying, verifying, and compiling neural network certifiers. It bridges the gap between high-level formal specifications and efficient tensor-based runtimes, enabling precise and verifiable DNN analysis.
📚 Features
ConstraintFlow allows you to:
- Specify certifiers declaratively using
.cffiles. - Verify certifiers automatically for soundness.
- Compile high-level specifications into optimized tensor-based code.
- Execute compiled certifiers on neural network models.
🚀 Quick Start
Installation
Clone the repository and install in editable mode:
git clone https://github.com/your-username/constraintflow.git
cd constraintflow
pip install -e .
Prepare Models
Create a directory for neural networks:
mkdir nets/
Download pretrained DNNs from ERAN and place them inside nets/.
CLI Usage
ConstraintFlow provides the following commands with optional flags:
provesound
constraintflow provesound example.cf [OPTIONS]
Options:
| Flag | Description | Default |
|---|---|---|
--nprev |
Number of previous states to consider | 1 |
--nsymb |
Number of symbols to track | 1 |
compile
constraintflow compile example.cf [OPTIONS]
Options:
| Flag | Description | Default |
|---|---|---|
--output-path |
Directory for generated code | output/ |
run
constraintflow run example.cf [OPTIONS]
Options:
| Flag | Description | Default |
|---|---|---|
--network |
Network name | mnist_relu_3_50 |
--network-format |
Format of the network file | onnx |
--dataset |
Dataset to use (mnist or cifar) |
mnist |
--batch-size |
Batch size | 1 |
--eps |
Epsilon | 0.01 |
--train |
Use training dataset | False |
--print-intermediate-results |
Print intermediate results during execution | False |
--no-sparsity |
Disable sparsity optimizations | False |
--output-path |
Path where compiled program is stored | output/ |
--compile |
Compile the program before running | False |
📄 Citations
If you use ConstraintFlow in your research, please cite the following papers:
@InProceedings{constraintflow,
author = {Avaljot Singh and Yasmin Sarita and Charith Mendis and Gagandeep Singh},
title = {ConstraintFlow: A DSL for Specification and Verification of Neural Network Analyses},
booktitle = {Static Analysis},
year = {2024},
publisher = {Springer Nature Switzerland},
}
@InProceedings{provesound,
author = {Avaljot Singh and Yasmin Sarita and Charith Mendis and Gagandeep Singh},
title = {Automated Verification of Soundness of DNN Certifiers},
booktitle = {OOPSLA},
year = {2025},
}
@Article{compiler,
author = {Avaljot Singh and Yasmin Sarita and Aditya Mishra and Ishaan Goyal and Gagandeep Singh and Charith Mendis},
title = {A Tensor-Based Compiler and Runtime for Neuron-Level DNN Certifier Specifications},
journal = {arXiv},
year = {2025},
}
🛠 Development
Requirements
- Python 3.9+
antlr4-python3-runtime==4.9.2
Running Locally
Install the requirements:
pip install -r requirements.txt
You can then run, compile, or verify any .cf file using the CLI.
📄 License
MIT License. See LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file constraintflow-0.1.1.tar.gz.
File metadata
- Download URL: constraintflow-0.1.1.tar.gz
- Upload date:
- Size: 158.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
187f815e8fb800c82363395569a29c01ddb0fa67a3fa3cdb2c303b4869398c69
|
|
| MD5 |
322fcd59aeff24786da0d87ce7ee1dd5
|
|
| BLAKE2b-256 |
53e2105511109828956b0d0f63fd183821dc4af2e4bfce515154c36152afee60
|
File details
Details for the file constraintflow-0.1.1-py3-none-any.whl.
File metadata
- Download URL: constraintflow-0.1.1-py3-none-any.whl
- Upload date:
- Size: 268.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cafd438061e66e7c7fd1b94a3d88a22b0b7801a6a6bb9df08d04893e7eb54488
|
|
| MD5 |
1366361f95c346b0ad69eee7d59e1b38
|
|
| BLAKE2b-256 |
cfa3fe4e6e62bd426fdd7de59040cf4aee5ff283d040ee1cc3a6e2cf12c09b6c
|