[{"data":1,"prerenderedAt":4},["ShallowReactive",2],{"25uoGHfWJT":3},"\u003Cp align=\"center\">\n  \u003Cimg src=\"docs/logo.svg\" alt=\"TNLean\" width=\"440\">\n\u003C/p>\n\n\u003Cp align=\"center\">\n  \u003Cb>Tensor-network theory, formalized in Lean 4.\u003C/b>\n\u003C/p>\n\n[![Lean Action CI](https://github.com/LionSR/TNLean/actions/workflows/lean_action_ci.yml/badge.svg)](https://github.com/LionSR/TNLean/actions/workflows/lean_action_ci.yml)\n[![Compile blueprint](https://github.com/LionSR/TNLean/actions/workflows/blueprint.yml/badge.svg)](https://github.com/LionSR/TNLean/actions/workflows/blueprint.yml)\n![sorries](https://img.shields.io/endpoint?url=https://sirui-lu.com/TNLean/badges/sorries.json)\n![axioms](https://img.shields.io/endpoint?url=https://sirui-lu.com/TNLean/badges/axioms.json)\n![Lean](https://img.shields.io/endpoint?url=https://sirui-lu.com/TNLean/badges/lean.json)\n![Mathlib](https://img.shields.io/endpoint?url=https://sirui-lu.com/TNLean/badges/mathlib.json)\n\nTNLean is a [Lean 4](https://lean-lang.org/) library, built on\n[Mathlib](https://github.com/leanprover-community/mathlib4), that formalizes\nthe mathematics of tensor networks: matrix product states (MPS), the quantum\nchannels and transfer operators that govern them, and the theorems relating\nthe two. Every result is checked by Lean down to the axioms it assumes.\n\nThe first released part of the library is the **fundamental theorem of matrix\nproduct states** (Pérez-García, Verstraete, Wolf, Cirac 2007; Cirac,\nPérez-García, Schuch, Verstraete 2017): two tensors generate the same quantum\nstates at every system size exactly when an invertible change of basis on the\nbond indices, a gauge transformation, relates them. Proving this required\nformalizing the quantum-information theory the proof rests on, following\nWolf's *Quantum Channels & Operations*: channel representations, Schwarz\ninequalities, quantum Perron-Frobenius theory, and the quantum Wielandt\ninequality. The library also contains material beyond the fundamental\ntheorem, at varying levels of completeness; the sections below say what is\nproved and what is not.\n\nThe mathematics is written up in the\n[blueprint](https://lionsr.github.io/TNLean/blueprint/), which states each\ndefinition and theorem in ordinary mathematical language and links it to the\nLean proof. It is available as a\n[web version](https://lionsr.github.io/TNLean/blueprint/), a\n[full PDF](https://lionsr.github.io/TNLean/blueprint.pdf), and a\n[separate FT-MPS PDF](https://lionsr.github.io/TNLean/blueprint-ch01-12.pdf),\nthe fundamental-theorem part that is being released first. The generated\n[API documentation](https://lionsr.github.io/TNLean/docs/) covers every\ndeclaration in the Lean source.\n\nThe agent-driven workflow used to build this library is described in the\ncompanion paper: S. Lu, E. Tjoa, J. I. Cirac, *Multi-agent Autoformalization\nof Tensor Network Theory*,\n[arXiv:2607.07857](https://arxiv.org/abs/2607.07857). Most of the\nformalization was carried out by agents running on\n[TeXRA](https://texra.ai), whose `lean-env-action` also sets up the Lean and\nblueprint toolchain used in the workflows under `.github/workflows/`.\n\nThe library loads as a single import (Lean 4 / Mathlib `v4.32.0`):\n\n```lean\nimport TNLean\n```\n\nThis is a research formalization in progress, not a finished textbook. Some\nfiles contain unfinished proofs (`sorry`) or results assumed as axioms; the\nbadges above track the current counts.\n\n## What is proved\n\n### The fundamental theorem of matrix product states\n\nAn MPS describes a quantum state on a chain by assigning a matrix `A^i` to\neach local basis state; products of these matrices give the state's\ncoefficients. The library defines these tensors (`MPSTensor d D`) and proves\nthe fundamental theorem in both of its forms.\n\nThe single-block case: if a tensor is injective (its matrices span the full\nmatrix algebra) and two tensors generate the same states, then they are\nrelated by a gauge transformation.\n\n```lean\ntheorem MPSTensor.fundamentalTheorem_singleBlock {A B : MPSTensor d D}\n    (hA : IsInjective A) (hAB : SameMPV A B) : GaugeEquiv A B\n```\n\nThe general case: an arbitrary tensor decomposes into normal blocks, and the\nlibrary constructs this canonical form, the basis of normal tensors that\nmakes it unique, and the multi-block theorem\n(`MPSTensor.fundamentalTheorem_equal_canonicalForm`): two canonical forms\ngenerating the same states at every length are related by a single invertible\ngauge. The exact hypotheses of each theorem are stated in its Lean signature\nand in the blueprint.\n\nAs a first physics application, the library proves that an on-site symmetry\nof an injective MPS induces a projective representation on the bond space,\nwhose cohomology class is a well-defined invariant of the symmetric tensor.\nThis is the MPS ingredient in the classification of one-dimensional\nsymmetry-protected topological phases.\n\n### Quantum channels and Perron-Frobenius theory\n\nFollowing Wolf's *Quantum Channels & Operations*, the library develops\nquantum channels on finite-dimensional matrix algebras: the Choi, Kraus, and\nStinespring representations, Kadison-Schwarz inequalities with their equality\ncase and the multiplicative domain, fixed-point structure, irreducibility,\nperipheral spectra, and quantum Markov semigroups. The chapters most relevant\nto MPS are the most developed.\n\nA recurring tool is the quantum Perron-Frobenius theorem: every positive map\nhas a positive-semidefinite eigenvector with positive eigenvalue. The proof\nruns through a Brouwer fixed-point argument on density matrices; Brouwer's\ntheorem itself is imported from an external Lean formalization (via Scarf's\nlemma) rather than assumed.\n\n```lean\ntheorem exists_posSemidef_eigenvector [NeZero D]\n    (E : Matrix (Fin D) (Fin D) ℂ →ₗ[ℂ] Matrix (Fin D) (Fin D) ℂ)\n    (hpos : IsPositiveMap E)\n    (hNZ : ∀ {ρ : Matrix (Fin D) (Fin D) ℂ}, ρ.PosSemidef → ρ ≠ 0 → E ρ ≠ 0) :\n    ∃ (ρ : Matrix (Fin D) (Fin D) ℂ) (r : ℝ),\n      ρ.PosSemidef ∧ ρ ≠ 0 ∧ 0 \u003C r ∧ E ρ = (r : ℂ) • ρ\n```\n\n### Quantum Wielandt theory\n\nThe quantum Wielandt inequality controls how quickly products of a tensor's\nmatrices span the whole matrix algebra, which determines the blocking length\nafter which a normal tensor becomes injective. For a normal tensor the\nlibrary proves a spanning length of at most `D^2`, where `D` is the bond\ndimension:\n\n```lean\ntheorem cumulativeSpan_eq_top_of_isNormal_bound [NeZero D]\n    (A : MPSTensor d D) (hN : IsNormal A) :\n    cumulativeSpan A (D ^ 2) = ⊤\n```\n\nSharpening this bound to match the constants in the literature is ongoing.\n\n## What is in progress\n\nBeyond the released core, the library develops several neighboring topics,\neach at an earlier stage.\n\n- **Parent Hamiltonians.** Local Hamiltonians whose ground space is the MPS,\n  with frustration-freeness and ground-state uniqueness proved for injective\n  and normal tensors. The estimates that would give a spectral gap are not\n  yet done.\n- **Matrix-product density operators.** Mixed-state analogues of MPS, their\n  canonical and zero-correlation-length forms, and renormalization fixed\n  points. This is a foundation, not yet a complete classification.\n- **Projected entangled pair states (PEPS).** The two-dimensional\n  generalization of MPS, with fundamental-theorem results for normal PEPS on\n  finite graphs.\n- **Entropy.** Von Neumann entropy, strong subadditivity, and quantum Markov\n  chains.\n- **Examples.** Concrete states such as AKLT, GHZ, even parity, and the\n  $\\mathbb{Z}/2\\mathbb{Z}$ models, alongside algebraic variants of the\n  fundamental theorem.\n\nWhere a formal statement does not exactly match its cited source, the\ndiscrepancy is recorded as a mathematical note under `docs/paper-gaps/`.\n\n## Organization of the source\n\nThe file `TNLean.lean` collects everything that is imported as one library;\nlegacy material in `TNLean/Archive/` is kept out of it. The source is grouped\nas follows.\n\n| Path | Contents |\n|---|---|\n| `TNLean/Algebra`, `TNLean/Analysis`, `TNLean/Topology` | Linear algebra of matrices: traces, Gram matrices, Frobenius norms, Skolem-Noether, and convergence and fixed-point results. |\n| `TNLean/Axioms` | The few results still assumed as axioms, isolated in dedicated modules so the assumption boundary stays auditable (the `axioms` badge counts them). |\n| `TNLean/Entropy` | Von Neumann entropy, strong subadditivity, mutual information, and quantum Markov chains. |\n| `TNLean/Channel` | Quantum channels: representations, Schwarz theory, fixed points, irreducibility, peripheral spectra, and semigroups. |\n| `TNLean/QPF`, `TNLean/Spectral` | Perron-Frobenius theory, spectral gaps, and correlation-decay estimates. |\n| `TNLean/MPS/Core`, `TNLean/MPS/Chain`, `TNLean/MPS/Overlap` | Matrix product states: tensors, words, blocking, transfer maps, and overlap matrices. |\n| `TNLean/MPS/FundamentalTheorem`, `.../BNT`, `.../CanonicalForm`, `.../Periodic`, `.../Structure`, `.../Irreducible` | The fundamental theorem in its single-block, multi-block, canonical-form, and periodic versions. |\n| `TNLean/MPS/Symmetry` | On-site and virtual symmetry, cohomology of cocycles, and string order. |\n| `TNLean/MPS/ParentHamiltonian` | Parent Hamiltonians, their ground spaces, and uniqueness of the ground state. |\n| `TNLean/MPS/MPDO`, `TNLean/MPS/RFP` | Matrix-product density operators and renormalization fixed points. |\n| `TNLean/MPS/Examples` | Worked examples (AKLT, GHZ, even parity, $\\mathbb{Z}/2\\mathbb{Z}$). |\n| `TNLean/Wielandt` | The quantum Wielandt inequality and primitivity. |\n| `TNLean/PEPS` | Projected entangled pair states on finite graphs. |\n| `TNLean/PiAlgebra` | Algebraic variants of the fundamental theorem. |\n| `blueprint/`, `docs/` | The mathematical companion text, conventions, and notes on gaps from the sources. |\n\n## Status\n\nThe README does not track which individual results are complete; the\nauthoritative, always-current picture is:\n\n- the `sorries` and `axioms` badges at the top of this page, counting\n  unfinished proofs and assumed results;\n- the [blueprint](https://lionsr.github.io/TNLean/blueprint/), which marks\n  each theorem as formalized or not; and\n- `docs/paper-gaps/`, which records where a formal statement diverges from\n  its cited source.\n\n## Building\n\nThe Lean version is pinned by `lean-toolchain`; Mathlib is pinned in\n`lakefile.toml` and `lake-manifest.json`.\n\n```bash\n# Optional but recommended: download pre-built Mathlib artifacts.\nlake exe cache get\n\n# Build the default target, which is TNLean.\nlake build\n\n# Equivalently, build the public Lean library target.\nlake build TNLean\n\n# Check a single file during development.\nlake env lean TNLean/MPS/FundamentalTheorem/Basic.lean\n```\n\nRepository-specific notes from past Lean/Mathlib upgrades are collected in\n[`docs/upgrade_4_29.md`](docs/upgrade_4_29.md).\n\n## Blueprint and documentation\n\nThe blueprint in `blueprint/` states the definitions and theorems in ordinary\nmathematical language and links each one to its Lean proof. It is built with\n`leanblueprint` on top of a successful `lake build`:\n\n```bash\nlake build TNLean\ncd blueprint\nleanblueprint checkdecls\nleanblueprint web   # or: leanblueprint pdf / leanblueprint all\n```\n\nThe FT-MPS release volume is built by\n`scripts/build_blueprint_ch01_12.sh` and published automatically with the\nrest of the site.\n\nConventions for contributors are collected in `AGENTS.md`, `CLAUDE.md`, and\n`docs/`.\n\n## License\n\nThe Lean source, the blueprint, and the other original content of this\nrepository are released under the Apache License 2.0 (see\n[`LICENSE`](LICENSE)). The `Papers/` directory contains the arXiv sources of\nthe papers being formalized; these are third-party works that remain under\ntheir authors' copyright and are **not** covered by the repository license.\nSee [`Papers/NOTICE.md`](Papers/NOTICE.md).\n\n## References\n\nThe formalization draws principally on the following sources.\n\n- D. Pérez-García, F. Verstraete, M. M. Wolf, J. I. Cirac,\n  *Matrix Product State Representations*,\n  [arXiv:quant-ph/0608197](https://arxiv.org/abs/quant-ph/0608197),\n  Quantum Inf. Comput. **7** (2007).\n- M. Sanz, D. Pérez-García, M. M. Wolf, J. I. Cirac,\n  *A quantum version of Wielandt's inequality*,\n  [arXiv:0909.5347](https://arxiv.org/abs/0909.5347),\n  IEEE Trans. Inf. Theory **56**(9), 4668--4673 (2010).\n- J. I. Cirac, D. Pérez-García, N. Schuch, F. Verstraete,\n  *Matrix Product Density Operators: Renormalization Fixed Points and Boundary Theories*,\n  [arXiv:1606.00608](https://arxiv.org/abs/1606.00608),\n  Ann. Phys. **378**, 100--149 (2017).\n- G. De las Cuevas, J. I. Cirac, N. Schuch, D. Pérez-García,\n  *Irreducible forms of Matrix Product States: Theory and Applications*,\n  [arXiv:1708.00029](https://arxiv.org/abs/1708.00029),\n  J. Math. Phys. **58**, 121901 (2017).\n- J. I. Cirac, D. Pérez-García, N. Schuch, F. Verstraete,\n  *Matrix Product States and Projected Entangled Pair States*,\n  [arXiv:2011.12127](https://arxiv.org/abs/2011.12127),\n  Rev. Mod. Phys. **93**, 045003 (2021).\n- A. Molnár, J. Garre-Rubio, D. Pérez-García, N. Schuch, J. I. Cirac,\n  *Normal projected entangled pair states generating the same state*,\n  [arXiv:1804.04964](https://arxiv.org/abs/1804.04964),\n  New J. Phys. **20**, 113017 (2018).\n- D. Pérez-García, M. M. Wolf, M. Sanz, F. Verstraete, J. I. Cirac,\n  *String Order and Symmetries in Quantum Spin Lattices*,\n  [arXiv:0802.0447](https://arxiv.org/abs/0802.0447),\n  Phys. Rev. Lett. **100**, 167202 (2008).\n- C. Fernández-González, N. Schuch, M. M. Wolf, J. I. Cirac, D. Pérez-García,\n  *Frustration free gapless Hamiltonians for Matrix Product States*,\n  [arXiv:1210.6613](https://arxiv.org/abs/1210.6613),\n  Commun. Math. Phys. **333**, 299--333 (2015).\n- N. Schuch, I. Cirac, D. Pérez-García,\n  *PEPS as ground states: Degeneracy and topology*,\n  [arXiv:1001.3807](https://arxiv.org/abs/1001.3807),\n  Ann. Phys. **325**, 2153--2192 (2010).\n- J. I. Cirac, J. Garre-Rubio, D. Pérez-García,\n  *Mathematical open problems in projected entangled pair states*,\n  [arXiv:1903.09439](https://arxiv.org/abs/1903.09439),\n  Rev. Mat. Complut. **32**, 579--599 (2019).\n- M. M. Wolf, *Quantum Channels & Operations: Guided Tour* (2012).\n- [Mathlib4](https://github.com/leanprover-community/mathlib4), the Lean 4\n  mathematics library.\n",1784558033347]