arXiv:2610.36343cs.LOOct 2026

Manuscript Offprint

arXiv:2610.36343

Reasoning about the Genetic Code in Lean

Colin T. Jones, Tyler R. Josephson

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

The genetic code exhibits redundancy, meaning that multiple distinct nucleotide sequences can encode the same amino acid sequence, a property mathematically characterized as non-injectivity. While this phenomenon is well studied in molecular biology, its rigorous verification within a computational framework remains limited. In this work, we present a machine-verified model of the central dogma of molecular biology using the Lean 4 interactive theorem prover. We formalize nucleic acid bases and amino acids as inductive types and define transcription and translation as functions mapping DNA sequences to RNA and subsequently to polypeptides. Within this framework, we prove key properties of these biological processes, including the redundancy of the genetic code, injectivity of transcription, and the non-injectivity of translation. Additionally, we formalize auxiliary processes such as DNA replication and mutation, and verify properties such as length conservation under transcription and point mutations. Finally, we demonstrate how Lean 4 helps prevent semantic errors in our code, showing its effectiveness as a tool for advancing reliable, bug-free scientific computing, particularly within the life sciences.

1 Introduction

Formal verification is used in computer science to provide machine-checked proofs that programs are correct [7, 23]. The capabilities provide unique promise to complex sciences like biology, where both software and hand-written work can be prone to error [1]. For instance, the 2011 Nature paper, "Genomic signatures to guide the use of chemotherapeutics" was retracted due to reproducibility issues [20]. The researchers used software with off-by-one indexing errors, generating false positives and rendering large swaths of their data analysis incorrect [3]. These types of errors could be proved absent using formal methods like Lean [5].

∗^{*}Corresponding author: tjo@umbc.edu

In this work, we explore how genomic semantics can be represented in a theorem proving system, by developing proofs of the redundancy of the standard genetic code using Lean. Lean offers a powerful environment for encoding mathematical structures, constructing formal proofs, and verifying their correctness with machine-level precision [7, 5, 2]. Our goal is to bridge the gap between computational biology and formal methods by developing a verified model of the codon-to-amino acid mapping and proving key properties of this system. Specifically, we define the standard genetic code as a finite mapping within Lean, formalize the definition of redundancy in this context, and construct proofs demonstrating the non-injectivity of the genetic code. Using this framework, we also formalize DNA replication, reverse transcription, and simple mutations, along with additional proofs such as length conservation and injectivity.

From a mathematical perspective, biology is the study of dynamic systems governed by constraints, probabilities, and optimization principles. Unlike physics or chemistry, which often follow predictable laws, biology includes a level of complexity and variability and is typically stated as an inexact science that can tolerate the discrepancy between theory and reality [11]. Still, it contains some mostly universal patterns that can be described and understood using math and proven with theorems. One of these mostly universal patterns that applies to almost all forms of life is the genetic code [19, 12, 28].

The genetic code is the set of rules by which deoxyribonucleic acid (DNA) is converted into nucleotide triplets, or codons, in messenger RNA (mRNA) and then translated into amino acid sequences of proteins. The conversion from DNA to mRNA is denoted as transcription, whereas, the conversion from mRNA to a polypeptide is denoted as translation. The direction in which information is transferred from DNA to RNA to protein is known as central dogma of molecular biology. Other important pathways relating to the genetic code include DNA replication and reverse transcription. DNA replication is used by an organism to copy and paste its genetic code in the form of DNA to preserve and spread its information through growth and reproduction. Reverse transcription in some ways violates the direction of information transfer dictated by the central dogma of molecular biology; it is a process in which information from RNA is converted to DNA.

A fundamental property of the genetic code is its redundancy, where multiple codons can encode the same amino acid [6, 13, 18]. For example, the amino acid leucine is specified by six different codons. This redundancy is not merely an artifact of combinatorics; it plays critical roles in error minimization and evolutionary adaptation [10, 6, 9, 14, 22]. Another important property of the genetic code is the faithfulness in both forward and reverse transcription (disregarding intron processing which will be discussed) as well as DNA replication, which can be represented as length conservation. Additionally, while the entire genetic code is redundant, only the process of translation itself is non-injective; the other processes are purely one-to-one or injective.

Although the biological implications of genetic code redundancy and its other properties have been extensively studied, their formal verification within a rigorous logical and computational framework remains largely unexplored. Most of the literature focuses on systems biology or molecular signaling pathways. Ahmad, Hasan, and Siddique formalized TP53 and other tumor related pathways in the HOL4 interactive theorem prover [1]. Another interesting look into formal verification comes from Bahrami et al., who utilized Coq to develop a model neural network, potentially providing insight into medical applications [4].