verified-nondim
Nondimensionalize ODE models automatically, and let Lean 4 check the result.
pip install verified-nondim
Three parameters, one that matters
from nondim import Model, nondimensionalize
sir = Model.from_strings(
"SIR",
equations={"S": "-beta*S*I", "I": "beta*S*I - gamma*I"},
params="beta gamma N",
same_units=[("S", "N"), ("I", "N")], # S and I are counted in the same units as N
)
reduced = nondimensionalize(sir, ["gamma", "N"], names={"t": "tau", "S": "X", "I": "Y", "beta": "R0"})
print(reduced.summary())
tau = gamma*t
X = S/N
Y = I/N
R0 = N*beta/gamma
reduced system:
dX/dtau = -R0*X*Y
dY/dtau = Y*(R0*X - 1)
parameters 3 -> 1: R0
The tool reads the equations, finds every change of units they allow, and uses those to set parameters to 1. The number it can remove is a matrix rank, so it is the best possible.
Ask for what you want
from nondim import solve
print(solve(sir, eliminate_at_least=2, keep=["beta"]))
print(solve(sir, eliminate_at_least=3))
print(solve(sir, want={"x": "beta*N"}))
SAT: normalize ['gamma', 'N'] (removes 2 >= 2).
UNSAT: only 2 independent scaling direction(s) act on ['beta', 'gamma', 'N'], so at most 2 of them can be removed (asked for 3).
UNSAT: x = N*beta is not dimensionless: scaling #2 multiplies it by lambda^1.
Ask what data can tell you
from nondim import analyze_identifiability
observed = Model.from_strings(
"SIR_reported",
equations={"S": "-beta*S*I", "I": "beta*S*I - gamma*I"},
params="beta gamma rho",
outputs={"y": "rho*I"}, # we only see a fraction rho of cases
)
print(analyze_identifiability(observed).summary())
NOT identifiable (moved by a scaling): ['beta', 'rho']
parameter groups the data can see: ['gamma', 'rho/beta']
Let Lean check it
nondim init-lean proofs # a Lean 4 + Mathlib project with the certificates
cd proofs && lake exe cache get && lake build
Every claim above becomes a theorem that Lean re-proves. From the SIR certificate:
theorem symmetries : Amat * Kmat = 0 := by decide +kernel
theorem rank_Apar : Apar.rank = 2 := by unfold Apar; eval_rank
theorem constraint2_unsat : 3 > Acand2.rank := by have h := constraint2_rank; omega
The Python code is never trusted: if it were wrong, the Lean build would fail.
More
nondim tourwalks through all of this in seven steps;nondim listshows the built-in models.- Guide · the math by hand · design decisions and sources · testing · examples
- Scope: right-hand sides built from products, quotients and sums of powers (no
exporlog). Results are verified relative to the equations and unit links you supply.
MIT license.
Metadata
Release files for verified-nondim 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| verified_nondim-0.1.0.tar.gz | 195.5 kB | Without provenance | Details for verified_nondim-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| verified_nondim-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for verified_nondim-0.1.0-py3-none-any.whl |
Total release size: 269.6 kB
Release files / verified_nondim-0.1.0.tar.gz
| Download URL | verified_nondim-0.1.0.tar.gz |
|---|---|
| Size | 195.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e8085c50b181de140135bfdc15054f304380051f8b1bd5e22c6fcea9a204b9a5
|
|
BLAKE2b-256 checksum How to use checksums |
25d7f33a3850a7c452dcf9fa9f6e759d8ed7b02a2c5442b8ed26b64d3f36b18f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|
Release files / verified_nondim-0.1.0-py3-none-any.whl
| Download URL | verified_nondim-0.1.0-py3-none-any.whl |
|---|---|
| Size | 74.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
273d2b3e8850f97f82b893cc3bc048dbdff1fc48a999d72fe17164e5cecdd9e0
|
|
BLAKE2b-256 checksum How to use checksums |
0e9b2b9489ae61b9711c1a9a4a2e24a91675d5f2ef0a2d84d10496a35539f96d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|
Security for verified-nondim 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.