pymwp is a tool for automatically performing static analysis on programs written in C. It analyzes resource usage and determines if a program's variables growth rates are no more than polynomially related to their inputs sizes. It is inspired by "A Flow Calculus of mwp-Bounds for Complexity Analysis". Try our online demo to see it action. For more details on usage and behavior, see pymwp documentation, particularly supported C language features.
Refer to statycc.github.io/pymwp for technical documentation, an online demo, and a presentation of examples.
For a publication, see "pymwp: A Static Analyzer Determining Polynomial Growth Bounds" also available on HAL.
A comprehensive tool user guide, with detailed examples, is available at: statycc.github.io/.github/pymwp. The user guide is the ideal place to start for a general and interactive introduction to pymwp.
Install the latest release from PyPI
pip install pymwp
To analyze a C file, run in terminal:
pymwp path/to_some_file.c
For all available options and help, run:
pymwp --help
You can also use pymwp by importing it in a Python script. See modules documentation for available methods.
from pymwp import Polynomial
from pymwp.matrix import identity_matrix, show
matrix = identity_matrix(3)
matrix[0][1] = Polynomial('m')
matrix[1][0] = Polynomial('w')
matrix[2][1] = Polynomial('p')
show(matrix)
If you want to use the latest stable version (possibly ahead of the latest release, and with special utilities and examples), use pymwp directly from source.
-
Clone the repository
git clone https://github.com/statycc/pymwp.git
-
Set up Python environment (use
venv
)install required packages
python -m pip install -r requirements.txt
For development and testing, install dev dependencies instead:
python -m pip install -r requirements-dev.txt
-
Run the analysis
From project root run:
python -m pymwp path/to_some_file.c
for example:
python -m pymwp c_files/basics/if.c
for all available options and help, run:
python -m pymwp