An executable Lean 4 research prototype for checking narrow ICD-10-CM coding certificates against clinician-reviewed structured notes. The checker supports two fixture concepts (R50.9 and I10), 12 named theorems, and 23 synthetic regression fixtures. It does not implement the ICD-10-CM classification or extract diagnoses from patient prose.
The model proposal contains a note identifier, policy revision, concept, quotation, and Unicode-scalar offset. Lean checks the quotation, source identity, outpatient setting, valid calendar date, effective window, reviewed certainty, and concept agreement. Missing support produces none; an uncertain or negated reviewed condition cannot produce an accepted certificate.
Install Lean with the official instructions. The lean-toolchain pins leanprover/lean4:v4.35.0; no Mathlib or third-party Lean packages are required.
lake build
lake exe clinical_demo
python3 scripts/check_proofs.pyExpected output ends with 23/23 synthetic clinical fixtures passed. A compile-time example also evaluates every fixture through Lean's proof checker.
- Whitepaper: architecture, theorem inventory, evaluation, and limits.
- Model: input structures, executable checker, and proofs.
- Fixtures: accepted cases and rejected mutations.
- Source manifest: authoritative references and explicit synthetic data provenance.
The input's clinician-reviewed semantic annotations are a trust boundary. Exact text matching does not establish that an annotation correctly interprets negation, temporality, clinical causation, or the full medical record. A model-generated annotation must be reviewed before it is treated as a ReviewedNote. This repository contains no patient data, trained model, model weights, real-world accuracy estimate, billing integration, or operational clinical workflow.
The complete synthetic note is Fever. Its reviewed concept is affirmed fever in a current outpatient encounter, and its certificate quotes that same text at offset zero. The checker yields some "R50.9". Changing the proposed concept to hypertension, changing the quotation, changing the reviewed certainty, or using a policy date outside the fixture's effective window causes rejection. Essential hypertension is the second deliberately restricted phrase and maps to I10 only with matching reviewed input.
These two mappings are illustrative identifiers, not a complete coding recommendation. Classification conventions, exclusions, sequencing, specificity, and the full record still require a complete reviewed coding system.
Authored software and documentation are MIT licensed; referenced third-party sources retain their own terms. Research by Matha Labs, November 15, 2026.
Read the Matha Labs research article, download the whitepaper PDF, or inspect its editable source. The published evaluation uses synthetic fixtures only.