# From Pen-and-Paper to Machine-Checked Proofs: Lean for System Identification

Lean 4 proofs can check a system identification lemma and expose a gap

Mejari, Manas, Piga, Dario, Forgione, Marco · arXiv · 2026-11-13

- **Problem** Proofs in system identification often run for pages and skip routine steps about limits and convergence. Reviewers rarely recheck each line, so gaps and errors can reach the published literature.
- **Method** Lean 4 is an interactive proof assistant that writes theorems and proofs as code. Its small kernel checks every step, so the reader only needs to trust the kernel and the statement.
- **Results** Formalizing Ljung's inverse-filter lemma shows its claim holds almost surely, not for every realisation. A simple counterexample shows the condition cannot be dropped.

## Why unchecked steps matter in system identification proofs

Proofs in system identification and control often run for pages, mixing matrix inequalities, probabilistic arguments and asymptotic analyses. Authors condense delicate steps about limits, expectations or modes of convergence for readability, for lack of space, or simply by oversight. Refereeing such proofs in detail is demanding, so implicit assumptions, gaps and imprecisions still reach the published literature.

Occasional outright errors reach the literature too, which is why a second, mechanical check matters.

A small, trusted program, the so-called kernel, checks every step of that formal proof.

The control community has explored these tools as well, with proofs in Coq, KeYmaera X and Lean. In system identification, the authors know of no such effort reported to date.

The paper uses Ljung's lemma on the inversion of the noise filter as a test case. Formalizing it in Lean requires each condensed routine step to be justified, even though Ljung's proof omits them. The formalization shows that the claim holds almost surely, not for every realisation. Lean's kernel doesn't need trust in the author, only in the kernel and in the statement itself.

## How a Lean proof is read

Lean 4 treats a statement as a type and a proof as a term of that type, so checking a proof means checking that the term has the claimed type. The kernel performs this check mechanically, so the reader doesn't need to trust whoever or whatever wrote the proof. The user only needs to trust the kernel, and to make sure the formal statement matches the intended claim.

Most proofs are written in tactic mode, where a sequence of commands transforms the current goal. Lean reports No goals once the original statement is proven, which is the signal that the proof is complete.

Lean proofs typically build on established results, such as theorems already proved in Mathlib, instead of re-deriving known facts. The first example proves 0 \< 1 − ρ from the hypothesis ρ \< 1 in a single call to linarith. The tactic state lists the assumptions, such as ρ : R and h : ρ \< 1, above the turnstile symbol ⊢. The same result can be obtained by rewriting the goal with sub\_pos and then closing it with exact h.

The rewrite matches the left-hand side of the equivalence against the goal, so a and b need not be written out.

Placing sorry closes any goal, but Lean then warns that the declaration uses sorry. The #print axioms command lists the axioms a theorem depends on, which exposes any sorry. Those three standard axioms mean there are no incomplete steps or custom axioms.

Checking proofs is handled by Lean's kernel, so a reader doesn't need to re-check each line by hand. The kernel only checks proofs, not statements, so a formally valid proof can still prove a different claim. The authors reviewed the statements in this paper against the original results.

## Identifiability needs a nonzero regressor

Identifiability from one data point asks whether equal outputs force equal parameters. The paper's pen-and-paper proof has two directions: a zero regressor destroys identifiability, and a nonzero regressor allows cancellation. Without sufficient excitation, the data don't determine the parameters uniquely, so the system is unidentifiable.

Lean defines Identifiable as a proposition, so the statement is a checkable object rather than an informal phrase. The theorem identifiable\_iff\_PE splits the equivalence into its two implications with the constructor tactic. In the only-if direction, a zero regressor lets θ1 = 0 and θ2 = 1 give the same output, so identifiability yields 0 = 1.

The tactic norm\_num then refutes 0 = 1, which closes that branch. In the if direction, the nonzero regressor is cancelled with the Mathlib lemma mul\_left\_cancel0.

The estimator\_exact theorem takes the nonzero hypothesis as an explicit input. Lean defines division for every real number, with y/0 equal to 0. Under zero excitation, the estimate 0/0 equals 0 whatever θ is, so the claim would be false. The proof substitutes the data and then calls field\_simp, which may cancel φ1 only because hφ is in context.

Lean therefore forces the persistent excitation condition into the statement, and the only-if part shows it can't be dropped.

## Invariance of an interval

The section asks how an induction argument for interval invariance becomes Lean code, using a scalar system with a coefficient a. Lemma 3 states that for x\_{k+1} = a x\_k with \|a\| ≤ 1, any interval R := \[−r, r\] is invariant. The pen-and-paper proof works by induction, bounding \|x\_{k+1}\| by \|a\|\|x\_k\|, then by \|x\_k\|, and finally by r. The base case uses the assumption x\_0 ∈ R, so \|x\_0\| ≤ r holds directly.

The Lean version splits the argument into a one-step claim and an induction over k. The one-step claim, interval\_invariant, takes a, r and x with the hypotheses \|a\| ≤ 1 and \|x\| ≤ r. Its calc chain rewrites \|ax\| as \|a\| \* \|x\| with abs\_mul, then applies mul\_le\_mul\_of\_nonneg\_right and one\_mul. The last step closes the bound with the hypothesis hx, so the chain ends at r.

The trajectory is defined by recursion: traj a x\_0 0 returns x\_0, and traj a x\_0 (k+1) returns a times traj a x\_0 k. So traj a x\_0 k gives x\_k for every k, and the dynamics x\_{k+1} = a x\_k is built into the definition. The theorem traj\_bounded states that if \|a\| ≤ 1 and \|x\_0\| ≤ r, then \|traj a x\_0 k\| ≤ r for every k. The proof runs by induction on k, with the base case closed by unfolding traj and using h0.

In the successor case, Lean keeps the induction hypothesis ih and must show the bound at k + 1. After unfolding traj, the goal becomes \|a \* traj a x\_0 k\| ≤ r, which matches the one-step claim exactly. The proof reuses interval\_invariant on traj a x\_0 k with the hypotheses ha and ih, so the step closes.

## The gap in Ljung's inverse-filter lemma

Ljung's lemma says that if H is stable and 1/H is analytic on \|z\| ≥ 1, the filter built from the coefficients of 1/H recovers the white noise. Step A builds the convolution identity from the power series of H and 1/H, collecting powers of z with ℓ = k + s. Step B then rewrites a double sum of the noise and uses that identity to obtain e(t).

The step that stalls in Lean is the second equality in Step B, which swaps the order of an infinite double sum. The original sum adds the terms row by row, over s and then over k, while the rearranged sum runs along antidiagonals k + s = ℓ. Such a swap needs a justification, and the proof takes it for granted.

For e(t) = 2^{-t}, the filtered signal v(t) is identically zero. The terms of this sequence do not decay in k, because the sequence grows into the past as fast as h̃ decays. Lemma 4 does not exclude such a sequence, so the stated identity fails for some realisations. Lean did not find this counterexample by itself, but it refused to verify the interchange until a justification was supplied.

The authors offer two ways to justify the interchange, and both lead to the same identity. For bounded noise, Fubini's theorem for series applies once the double series converges absolutely, as in condition (8). If \|e(t)\| ≤ M, the bound X\_t ≤ M ‖h̃‖₁ ‖h‖₁ is finite, and the identity holds for every realisation. For white noise with finite variance λ, the bounded-noise hypothesis is too restrictive, because the realisations can be unbounded.

Tonelli's theorem gives E X\_t ≤ √λ ‖h̃‖₁ ‖h‖₁, so X\_t is finite with probability one for all t.

So the condition holds almost surely for white noise, and the lemma holds with probability one rather than for every realisation. The counterexample shows the condition cannot be dropped, since its sequence is not excluded by the lemma's hypotheses.

## What holds for bounded and white noise

The interchange of the double sum in Step B is justified by Fubini's theorem for series, once the double series converges absolutely. The authors write this condition as X\_t, the sum of \|h̃(k)\| \|h(s)\| \|e(t-k-s)\| over k and s at least 0, required to be finite. Bounded noise is the first case, and there the condition holds for every realisation.

If \|e(t)\| is at most M, then X\_t is at most M times the ℓ1 norms of h̃ and h, which is finite.

White noise with finite variance λ may have unbounded realisations, so the authors need a weaker argument. By Tonelli's theorem, the expectation of X\_t is bounded by √λ times the two ℓ1 norms, using E\|e(s)\| at most √λ. Because that bound is finite, X\_t is finite with probability one for every t in Z. On each such realisation Fubini's theorem applies, so the identity holds with probability one, not for every realisation.

Lemma 5 states the precise form for possibly unbounded noise, with three hypotheses named A1, A2 and A3. A1 requires both H and H⁻¹ to be stable, and A2 requires the series (6) to converge for every \|z\| at least 1. A3 requires sup over t of E\|e(t)\| to be finite, which is the uniform first-moment bound the interchange needs. Zero-mean white noise with finite variance λ satisfies A3, because E\|e(t)\| is at most √λ.

## A template for system identification results in Lean

The paper lays out a four-step template for writing a system identification result in Lean 4. The first step declares parameters and data as Lean types, such as a scalar parameter with type R. A parameter vector can be a structure or Fin d to R, and a random signal can be Z to Ω to R on a probability space. The second step defines the model, or its predictor, with def as a function of the parameter.

The paper points to traj in Box 2 and to the filter H(q)e(t) in Lemma\_3\_1\_Ljung.lean as examples.

The third step states the property as a theorem whose proof starts as sorry. Every assumption is a named hypothesis, such as hA1, hA2 and hA3 for (A1) to (A3) of Lemma 5. The fourth step replaces sorry one tactic at a time while reading the goal state.

The template file defines a signal as Z to R, and a model structure as a curried function of θ, u and y. IsIdentifiable states global identifiability: equal predictions for two parameters force the parameters to be equal. For the ARX model, the authors define ARXParams with coefficients a for past outputs and b for past inputs. The predictor arx sums the a-terms over y and the b-terms over u, with the lags t minus 1 minus i.

The pulse function returns one at time s and zero elsewhere, and serves as the test signal of the proof.

The ARX proof first assumes that the two parameter sets give the same predictor, and then compares them coefficient by coefficient. A pulse in y with u equal to zero gives the predicted value minus a\_i, which isolates each a\_i. A pulse in u with y equal to zero gives the predicted value b\_i, which isolates each b\_i. The listing proves that the ARX structure is strictly globally identifiable, as stated in Ljung (1999, Sec.

4.6). Lean's kernel checks every such step, but it checks proofs and not whether the statement matches the intended claim.

## What still needs human checking

Lean's kernel checks every inference, but it does not check whether the statement it accepts is the intended claim. Kernel checks proofs, not statements, so a formally valid proof can still verify a claim that differs from the theory. The authors must confirm that the formal assumptions and conclusion faithfully represent the intended result.

The kernel is the only part the user needs to trust, since it is widely scrutinised and has independent implementations.

Writing Lean code can be tedious, but step-by-step checking is handled entirely by the kernel. LLMs can help read and write the code, and they can translate arguments into Lean and propose intermediate lemmas. Whether a proof comes from a human or an AI system, the kernel checks it in the same way. Human supervision therefore stays essential to judge whether the formal statement matches the intended result.

The paper's own formalized material is limited to two toy examples, the template case, and one textbook lemma. The code was tested with Lean v4.35.0 and the matching Mathlib release.

## Paper info

- **Authors**: Mejari, Manas, Piga, Dario, Forgione, Marco
- **Venue**: arXiv · Preprint
- **First published**: 2026-11-13
- **Added**: 2026-11-16
- **Updated**: 2026-11-13
- **Version**: v1
- **arXiv**: 2611.18220
- **Category**: eess.SY · cs.AI
- **Original paper terms**: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)
- **What we show**: Paper info, commentary and permitted figures from the original paper

[Original paper ↗](https://arxiv.org/abs/2611.18220v1) · [PDF ↗](https://arxiv.org/pdf/2611.18220v1)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Abstract

Mathematical proofs in scientific papers are often long and intricate, relying on chains of references to earlier results. This makes it difficult for readers and reviewers to verify each and every step. Interactive theorem proving offers a complement: the theorem and its proof are written as code, and every inference is checked by a small, trusted piece of software called the kernel. This paper serves as an introduction to the Lean 4 proof assistant for a system identification and control audience, assuming no prior exposure to formal methods. We first show how a Lean proof is read using two elementary examples: the first on identifiability, the second on set invariance. We then illustrate how Lean can be used to analyse results from the literature, taking as example a classic lemma on the inversion of the noise filter in prediction-error identification (Ljung, 1999, Lemma 3.1). Since in Lean every step must be justified, the formalization brings to light a subtle point: the original claim of that lemma holds almost surely, although not for every realisation, as its statement may suggest. A simple counterexample makes this concrete. Finally, the paper discusses guidelines and perspectives on the use of Lean in system identification research.

## Quote from the paper

Mejari, Manas, Piga, Dario, Forgione, Marco (2026). From Pen-and-Paper to Machine-Checked Proofs: Lean for System Identification. arXiv:2611.18220v1. https://arxiv.org/abs/2611.18220v1

**BibTeX**

```
@misc{manas2026from,
  title = {{From Pen-and-Paper to Machine-Checked Proofs: Lean for System Identification}},
  author = {Mejari, Manas and Piga, Dario and Forgione, Marco},
  year = {2026},
  eprint = {2611.18220},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.18220v1}
}
```

## Other paper commentary

- [Tracing Uncertainties of Extreme El Niño Prediction to Mesoscale Ocean Currents](https://refivu.com/en/papers/e50737f2-d670-42f4-9b3c-5a4a5eaf3da4-tracing-uncertainties-of-extreme-el-nino-prediction-to.md)
- [Causally Constrained and Uncertainty-Aware Cardiopulmonary Risk Prediction](https://refivu.com/en/papers/2c2b5714-498e-4c41-a2bc-142d04049204-causally-constrained-and-uncertainty-aware-cardiopulmonary.md)
- [Continuous Cuffless Blood Pressure Estimation Using PPG From Methods to Clinical Translation](https://refivu.com/en/papers/180bf06e-b537-4a2e-ae36-d6f387368854-continuous-cuffless-blood-pressure-estimation-using-ppg-from.md)
- [STEALTH: Steganographic Text Encoding Agnostic to Low-Level Tensor Hardware](https://refivu.com/en/papers/ef9a2b6e-544f-4504-8701-7328a175bfce-stealth-steganographic-text-encoding-agnostic-to-low-level.md)
- [Speed-to-Power Dominates Energy Costs for AI Data Centers: Technoeconomic Analysis of Powering AI in the Continental United States](https://refivu.com/en/papers/59c862ce-9112-44ef-844c-60828dd3cb56-speed-to-power-dominates-energy-costs-for-ai.md)
- [Bellman Contraction under MMD: A Unified Framework](https://refivu.com/en/papers/bc47e65f-4140-46f1-829a-ce2a7aea1312-bellman-contraction-under-mmd-a-unified-framework.md)
- [Reasoning Models Confabulate to Defend Injected Beliefs About Their Own Requests](https://refivu.com/en/papers/ce562014-a4fd-4785-a292-99b457ab2649-reasoning-models-confabulate-to-defend-injected-beliefs.md)
- [FEND: Far-End Detection in Outbound Voice AI Calls](https://refivu.com/en/papers/8f9be405-cbfb-49aa-8c22-204722d38a37-fend-far-end-detection-in-outbound-voice-ai.md)
- [MarathonTS: a benchmark of long synthetic time series from window assembly and long-series generators](https://refivu.com/en/papers/8582319e-a186-4e8a-b713-0a6f33889f8f-marathonts-a-benchmark-of-long-synthetic-time-series.md)
- [Who Counts as Exposed? Measurement Choices in an Open, Re-estimable Index of Occupational AI Exposure](https://refivu.com/en/papers/bc2cfc93-d47d-40b5-b11c-31874b253264-who-counts-as-exposed-measurement-choices-in-an.md)
- [Do Machines Learn Deviance From Their Peers? A Randomized Test of Differential Association With AI Agents](https://refivu.com/en/papers/58c15c7f-5939-4116-a0a3-1907381f3dd8-do-machines-learn-deviance-from-their-peers-a.md)
- [OmniScore-Bench: Evaluating Vision-Language Models on Musical Score Reading](https://refivu.com/en/papers/52a66343-13c0-4f0a-9029-97ce4948ded7-omniscore-bench-evaluating-vision-language-models-on-musical.md)

## Terms in this paper

- [Large Language Models](https://refivu.com/en/terms/f2404476b183-large-language-models)
- [Lean 4](https://refivu.com/en/terms/fd09b069af07-lean-4)
- [Identifiability](https://refivu.com/en/terms/8811d6460b38-identifiability)
- [kernel](https://refivu.com/en/terms/0a753944f571-kernel)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/96a42630-24d1-4b73-800f-c3eb329e5262-from-pen-and-paper-to-machine-checked-proofs)
