Machine-verified computational biology contracts, Lean 4 kernel-checked, Rust-accelerated
Project description
kenoslean
Machine-verified computational biology contracts — Lean 4 kernel-checked, Rust-accelerated, exposed to Python.
Each function in this package corresponds to a contract whose mathematical
invariants are stated and proven in a Lean 4 module (KLean.Contracts.*). The
Rust implementation reproduces the algorithm; pre-condition violations raise
ValueError, and post-conditions are guarded with debug_assert! in debug
builds.
Naming. The PyPI distribution is
kenoslean(the namekleanwas already taken on PyPI by an unrelated project). The import module name isklean:pip install kenoslean # distributionimport klean # module
Quick start
import klean
klean.gc_content("ATGCGCATGC") # 0.5 — GCContent ∈ [0,1]
klean.mrna_halflife_concentration(100.0, 0.1, 5.0) # MrnaHalfLife > 0
klean.sequence_identity("ACGT", "ACGG") # 0.75 — SequenceIdentity ∈ [0,1]
klean.nussinov("GGGAAACCC") # 3 — max non-crossing base pairs
What is and is not proven (honest scope)
The Lean kernel checks are about algorithmic correctness and bounds, not about closing open scientific problems. Specifically:
- Nussinov (
nussinov): the Lean theoremnussinov_optimalproves the DP recurrence returns exactly the maximum number of non-crossing canonical base pairs (sound + achievable). This is a proof about the counting algorithm, with a parameterized pairing cost. It is not a claim that RNA minimum-free-energy (MFE) structure is "solved": the realistic Turner nearest-neighbor energy table is left as open input, and stacking-rule optimality under the full Turner model is not proven here. - Real-valued contracts (concentrations, kinetics, ages, etc.): the Lean
proofs are over the reals (ℝ). The Rust/Python runtime uses IEEE-754
f64. A formal floating-point error bound is not proven — runtime values are numerically close but the gap betweenf64and ℝ is not certified here.
In one line: we prove algorithm optimality / invariants (parameterized cost); the empirical energy tables are open inputs, and Real-valued results carry no proven floating-point error bound (only runtime closeness).
Contracts
mRNA / Ribosome, sequence analysis, pharmacokinetics, longevity, statistics,
thermodynamics, enzyme kinetics, spectroscopy/transport, growth/population
dynamics, clinical/physiology, molecular biology, structural alignment, and RNA
secondary structure (Nussinov). See the module docstring in klean for the
full list and the backing Lean module names.
Build from source
Requires a Rust toolchain and maturin.
maturin build --release # produces target/wheels/kenoslean-*.whl
pip install target/wheels/kenoslean-*.whl
HTTP server (separate binary)
The same contracts are also served over HTTP by the klean-server binary
(Rust/Axum), built with the server feature:
cargo build --release --bin klean-server --features server
./target/release/klean-server # listens on 0.0.0.0:8090
Endpoints (each response carries "verified": true):
GET /health
GET /v1/gc_content?seq=ATGCATGC
GET /v1/sequence_identity?seq1=ACGT&seq2=ACGG
GET /v1/shannon_entropy?p=0.5
GET /v1/mrna_halflife_concentration?initial=100&decay_rate=0.1&time=5
GET /v1/mrna_halflife?decay_rate=0.1
GET /v1/ribosome_density?n_ribosomes=10&length=100
GET /v1/translation_rate?codon_rate=5&ribosome_density=0.5&mrna_copies=10
GET /v1/first_order_pk?c0=100&ke=0.1&time=5
GET /v1/ic50?ki=10&substrate=5&km=2
GET /v1/michaelis_menten?vmax=100&km=5&substrate=10
GET /v1/biological_age?pheno=45&telomere=42&epigenetic=48
GET /v1/telomere_length?age=50
GET /v1/gompertz_hazard?alpha=0.0001&beta=0.08&time=65
GET /v1/hardy_weinberg?p=0.6
License
MIT
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 Distributions
Built Distributions
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 kenoslean-0.1.0-cp313-cp313-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: kenoslean-0.1.0-cp313-cp313-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 297.0 kB
- Tags: CPython 3.13, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0968e9088470639ff2e944a62a368e05251f029c0b62e9552f083f8265b2a0c2
|
|
| MD5 |
17fe80d17f68f002a18894987bc0f557
|
|
| BLAKE2b-256 |
c53570df5581413d89d96529ec5fa2ca222ed397c623ef974063ff01c03accae
|
File details
Details for the file kenoslean-0.1.0-cp38-abi3-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: kenoslean-0.1.0-cp38-abi3-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 258.8 kB
- Tags: CPython 3.8+, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba83d9277d550c40f32dab12d0465d754fbbc24e5c7740ce547ee280eddc7901
|
|
| MD5 |
f8cffe76c59d1df8e3d83cb3e4679449
|
|
| BLAKE2b-256 |
464f325a1d5806ded2299e784a27485ac25234057d765bee97d3f2b4117bd1ac
|
File details
Details for the file kenoslean-0.1.0-cp38-abi3-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: kenoslean-0.1.0-cp38-abi3-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 298.0 kB
- Tags: CPython 3.8+, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
44f9cb4d4680f2ed1473ae1d41f1282b9f1ecf2b50ab135d19b6d32586f09c76
|
|
| MD5 |
1cf23b2f6325490dd28f277da01f6821
|
|
| BLAKE2b-256 |
408b4b018185263e7fedbbf9801f64e23d340d43a6a6926b4a66f095b6311799
|
File details
Details for the file kenoslean-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: kenoslean-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 260.5 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e302ca2d2d9333a1e3d83c18f0bd109ce7135c81ba108b40a1357fb7697f3d29
|
|
| MD5 |
787cf3654e957ea3807a1c693a68853f
|
|
| BLAKE2b-256 |
f387ff92c730b5991942f5c4e66ac1c8e37643fe84e477d629c6a5cd4099e777
|