A note to maintainers

Computational biology is accumulating mathematical debt. The formulas underlying our tools, including Michaelis-Menten, Hardy-Weinberg, pharmacokinetic decay, and Shannon entropy, have been implemented, re-implemented, and approximated across thousands of codebases, rarely with machine-checked proofs that the implementation faithfully reflects the published claim.

K-Lean was built to address this: 96 Lean 4 contracts (385 theorems), each sorry-free, each verifiable by the Lean kernel. We serve them as a live REST API (Rust, 3,095+ req/s, GCP single instance) so any project can call machine-checked biology math directly, no formal methods toolchain required.

We reach out to projects directly, not to promote, but to contribute. The researchers most likely to benefit are those already working on these problems. Some find this immediately relevant. Many do not. Both outcomes are legitimate, and both help us sharpen our work.

If we have contacted your project and it is not a fit, we respect that without reservation. If you would prefer we not engage with your repository going forward, please say so and we will stop immediately.

We are researchers building infrastructure we believe the field needs. We welcome scrutiny, pushback, and honest feedback.

Contributions & feedback welcome: info@kenosian.com

What K-Lean does
LayerTechnologyWhat it verifies
Phase AJSON Schema + TTTPSI/O contract + operator-independent timestamp seal
Phase BLean 4 kernel checkBounds, monotonicity, conservation laws, machine-checked
Phase CStandalone lake packageUse in your own Lean 4 project without Mathlib PR approval
Quick start
Use in your Lean 4 project

Add to your lakefile.lean, (repository re-organizing; install available again shortly)

require KLean from git
  "..." @ "main"

-- then import any contract:
import KLean.Contracts.MichaelisMenten
import KLean.Contracts.PhenoAge
Verify locally
# clone the repository (re-organizing, back shortly)
cd kenosian-lean4
lake build
# Lean 4 elaborates all theorems. No sorry. No trust.
Check a theorem
#check KLean.MichaelisMenten.velocity_monotone
#check KLean.HardyWeinberg.hardy_weinberg_equilibrium
#check KLean.ContactProbability.sigmoid_pos
Contract coverage

96 contracts across 10 domains. Every theorem is sorry-free, verified by the Lean 4 kernel. No sorry. No trust required.

For every contract, each domain, each key theorem (named exactly as in the Lean source), and what it proves, see the complete library page: Browse all 96 contracts →

Real-world applications

K-Lean contracts are in active use for verifying computational models in ongoing research. In one case, a biomedical researcher applied ErythropoiesisODE.lean to formally verify boundary conditions of an erythropoiesis model, confirming RBC count non-negativity and convergence under physiological stimulation rates. The machine-verified contract replaced a manual parameter review step.

Domains
DomainRepresentative contracts
Enzyme kinetics & drug responseMichaelisMenten · HillEquation · IC50Relationship · CatalyticEfficiency
Longevity & biological agePhenoAge · Telomere · GompertzMortality · SenolyticSelectivity
Clinical & renal functionCkdEpi · MeldScore · OsmoticPressure · ErythropoiesisODE
Genetics & population biologyHardyWeinberg · SirEpidemic · CodingSequenceLength · GOEnrichmentClosure
AlphaFold & protein structureProteinRMSD · TmScore · AlphaFoldConfidence · SequenceIdentity
Biophysics & physical chemistryBeerLambert · NernstEquation · ArrheniusEquation · GibbsFreeEnergy
Mitochondria & cell biologyProtonMotiveForce · AtpSynthaseEfficiency · NADPlusRatio · MrnaHalfLife
Pharmacokinetics & lab methodsFirstOrderPK · PcrAmplification · ShannonEntropy
Synthetic biologySynNotch · Riboswitch · LongevityProtocol · CodonAdaptationIndex
ML & single-cell analysisGPPosteriorVariance · PseudotimeOrdering · SparseApproximationBound
Academic usage (paper appendix pattern)

K-Lean follows the leanblueprint academic standard:

\appendix
\section{Formal Verification (K-Lean)}
All numerical claims in this paper have been machine-verified using Lean 4.
See FORMALIZATION.md.

Reference as:

@software{klean2026,
  title  = {K-Lean: Machine-Verified Mathematical Contracts for Biology},
  author = {Jang, Peter},
  year   = {2026},
  note   = {Lean 4 formal proofs, sorry-free}
}
CI integration

K-Lean contracts are mathematical specifications. To connect them to your implementation, no Lean installation required, translate each invariant into a property test.

Python / pytest-hypothesis
from hypothesis import given, strategies as st

@given(st.text(alphabet="ACGT", min_size=1))
def test_gc_content_bounds(seq):
    gc = compute_gc_content(seq)
    assert 0.0 <= gc <= 1.0          # KLean.GCContent invariant

@given(st.floats(min_value=0), st.floats(min_value=0))
def test_mrna_halflife_positive(k, t):
    result = mrna_concentration(k, t)
    assert result >= 0               # KLean.MrnaHalfLife invariant
R / testthat
test_that("gc_content bounds", {
  expect_true(gc_content(seq) >= 0 && gc_content(seq) <= 1)
})
Coming soon: klean-py (Rust / PyO3)
# pip install kenoslean   (coming soon)
from klean import gc_content, mrna_halflife, sequence_identity

We are building a Rust implementation of all 96 contracts, compiled to a Python extension via PyO3. This closes the gap between formal Lean specification and running Python code, no Lean toolchain required in your CI.

klean-server (live)

A Rust-native HTTP API (Axum) serving all 96 contracts at 3,095+ req/s (GCP, single instance), with sub-millisecond per-call latency. No Lean toolchain required.

import requests
r = requests.post("https://kpp.kenosian.com/v1/michaelis_menten",
    json={"substrate": 0.5, "km": 0.1, "vmax": 2.0})
print(r.json())
curl https://kpp.kenosian.com/klean/v1/gc_content?sequence=ATCGATCG
Phase A: API integration

K-Lean contracts are enforced at runtime via the KPP API (kpp.kenosian.com):

curl -X POST https://kpp.kenosian.com/api/v1/verify/klean \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "tool_id": "klean:bloodwork:phenoage:v1",
    "request_payload": {"chronological_age": 45, "albumin": 4.1},
    "response_payload": {"phenotypic_age": 38.2}
  }'

Returns a TTTPS-sealed badge with roughtime_k ≥ 3 (operator-independent timestamp).

Honest scope
What this audits, and what it does not

K-Lean verifies computational integrity: that a function matches its published formula. It does not assert:

  • Clinical or biological correctness
  • Efficacy of the underlying algorithms
  • Safety for medical use
Contributing & license

All theorems must be sorry-free. CI checks this on every push (grep -r "sorry" KLean/ && exit 1). We welcome contributions, new biology contracts, proof improvements, or domain extensions. Issues and pull requests welcome.

Licensed under Apache 2.0.

K-Lean is the first Lean 4 library for computational biology. Analogous: TLA+ : distributed protocols :: K-Lean : biological computation.