Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Based binary chain complexes and homological distance

Definition
ZengPryadko2019

by Rui Chao · Sep 10, 2026 · Mathlib 0df444a (Lean v4.33.1)

chaincomplexescodingtheoryhomologicalalgebraquantumerrorcorrectiontensorproducts

This definition bundle formalizes the based binary chain-complex data used in Zeng--Pryadko's distance theorem.

A binary word with coordinate type III is a function I→F2I\to\mathbb F_2I→F2​. A BasedBinaryChainComplex contains finite based chain groups AjA_jAj​ in every nonnegative degree and paper-indexed boundary maps ∂j:Aj→Aj−1\partial_j:A_j\to A_{j-1}∂j​:Aj​→Aj−1​. If the complex has length mmm, the two endpoint maps are exactly the implicit trivial operators of Eq. (1):

∂0:A0⟶{0},∂m+1:{0}⟶Am.\partial_0:A_0\longrightarrow\{0\},\qquad \partial_{m+1}:\{0\}\longrightarrow A_m.∂0​:A0​⟶{0},∂m+1​:{0}⟶Am​.

Both are zero maps. It also contains the equations ∂j∂j+1=0\partial_j\partial_{j+1}=0∂j​∂j+1​=0 and a finite length above which all chain groups have dimension zero.

Exactly as in Eq. (4) of Zeng--Pryadko, the homological distance is

dj=min⁡{wt⁡(x):x∈ker⁡∂j∖im⁡∂j+1}.d_j=\min\{\operatorname{wt}(x):x\in\ker\partial_j\setminus \operatorname{im}\partial_{j+1}\}.dj​=min{wt(x):x∈ker∂j​∖im∂j+1​}.

In particular, the endpoint cases are

d0=min⁡{wt⁡(x):x∈A0∖im⁡∂1}d_0=\min\{\operatorname{wt}(x):x\in A_0\setminus \operatorname{im}\partial_1\}d0​=min{wt(x):x∈A0​∖im∂1​}

and

dm=min⁡{wt⁡(x):0≠x∈ker⁡∂m},d_m=\min\{\operatorname{wt}(x):0\ne x\in\ker\partial_m\},dm​=min{wt(x):0=x∈ker∂m​},

because ker⁡∂0=A0\ker\partial_0=A_0ker∂0​=A0​ and im⁡∂m+1={0}\operatorname{im}\partial_{m+1}=\{0\}im∂m+1​={0}.

Distances take values in N∪{∞}\mathbb N\cup\{\infty\}N∪{∞}, with the minimum of the empty set equal to ∞\infty∞. Thus a trivial homology group has infinite distance, following the paper's convention.

For a binary matrix represented as a linear map P:F2C→F2RP:\mathbb F_2^C\to \mathbb F_2^RP:F2C​→F2R​, the associated one-complex K(P)\mathcal K(P)K(P) has

d1(K(P))=min⁡{wt⁡(x):Px=0, x≠0}d_1(\mathcal K(P))=\min\{\operatorname{wt}(x):Px=0,\ x\ne0\}d1​(K(P))=min{wt(x):Px=0, x=0}

and

d0(K(P))=min⁡{wt⁡(y):y∉im⁡P}.d_0(\mathcal K(P))=\min\{\operatorname{wt}(y):y\notin\operatorname{im}P\}.d0​(K(P))=min{wt(y):y∈/imP}.

For arbitrary finite-length based complexes A\mathcal AA and B\mathcal BB, the bundle defines every degree of A×B\mathcal A\times\mathcal BA×B, its boundary maps, proves that consecutive product boundaries compose to zero, defines its homological distance, and min⁡idi(A)dj−i(B)\min_i d_i(\mathcal A)d_{j-i}(\mathcal B)mini​di​(A)dj−i​(B). It also constructs the one-complex K(P)\mathcal K(P)K(P) as a specialization.

Formalization Note. Finite coordinate types are allowed to be empty, so endpoint chain groups require no separate exceptional definition. Hamming weight is computed in the displayed bases, as required by the theorem.

Definition code
import Mathlib.InformationTheory.Hamming
import Mathlib.LinearAlgebra.Dimension.Finite
import Mathlib.LinearAlgebra.Matrix.ToLin

namespace ZengPryadko2019

/-- A binary word whose coordinates are indexed by `ι`. -/
abbrev BinaryWord (ι : Type*) := ι → ZMod 2

/--
Minimum Hamming weight of a nonzero homology class.  The infimum of the empty
set is `⊤`, so the distance is infinite when the homology group is trivial,
as in Zeng--Pryadko.
-/
noncomputable def homologicalDistance
    {ι κ μ : Type*} [Fintype ι] [DecidableEq ι]
    (d : BinaryWord ι →ₗ[ZMod 2] BinaryWord κ)
    (dNext : BinaryWord μ →ₗ[ZMod 2] BinaryWord ι) : WithTop ℕ :=
  sInf {w : WithTop ℕ | ∃ x : BinaryWord ι,
    d x = 0 ∧ x ∉ LinearMap.range dNext ∧ w = hammingNorm x}

/-- Coordinate expansion of a linear map between standard finite bases. -/
theorem linearMap_apply_eq_sum {m n : ℕ}
    (f : BinaryWord (Fin n) →ₗ[ZMod 2] BinaryWord (Fin m))
    (x : BinaryWord (Fin n)) (i : Fin m) :
    f x i = ∑ k : Fin n, f (Pi.single k 1) i * x k := by
  have h := congrFun (LinearMap.toMatrix'_mulVec f x) i
  simpa [Matrix.mulVec, dotProduct, LinearMap.toMatrix'_apply] using h.symm

/-- Linear maps acting on separate finite coordinate directions commute. -/
theorem linearMap_apply_separateDirections
    {m n p q : ℕ}
    (f : BinaryWord (Fin n) →ₗ[ZMod 2] BinaryWord (Fin m))
    (g : BinaryWord (Fin q) →ₗ[ZMod 2] BinaryWord (Fin p))
    (e : Fin n → Fin q → ZMod 2) (a : Fin m) (b : Fin p) :
    f (fun a' => g (fun b' => e a' b') b) a =
      g (fun b' => f (fun a' => e a' b') a) b := by
  calc
    f (fun a' => g (fun b' => e a' b') b) a =
        ∑ a' : Fin n, f (Pi.single a' 1) a * g (fun b' => e a' b') b :=
      linearMap_apply_eq_sum f _ a
    _ = ∑ a' : Fin n, ∑ b' : Fin q,
        f (Pi.single a' 1) a * (g (Pi.single b' 1) b * e a' b') := by
      apply Finset.sum_congr rfl
      intro a' _
      rw [linearMap_apply_eq_sum g]
      simp only [Finset.mul_sum]
    _ = ∑ b' : Fin q, ∑ a' : Fin n,
        g (Pi.single b' 1) b * (f (Pi.single a' 1) a * e a' b') := by
      rw [Finset.sum_comm]
      apply Finset.sum_congr rfl
      intro b' _
      apply Finset.sum_congr rfl
      intro a' _
      ring
    _ = ∑ b' : Fin q,
        g (Pi.single b' 1) b * f (fun a' => e a' b') a := by
      apply Finset.sum_congr rfl
      intro b' _
      rw [linearMap_apply_eq_sum f]
      simp only [Finset.mul_sum]
    _ = g (fun b' => f (fun a' => e a' b') a) b :=
      (linearMap_apply_eq_sum g _ b).symm

/-- A coordinatewise form of additivity for linear maps on binary words. -/
theorem linearMap_apply_pointwise_add {m n : ℕ}
    (f : BinaryWord (Fin n) →ₗ[ZMod 2] BinaryWord (Fin m))
    (x y : BinaryWord (Fin n)) (i : Fin m) :
    f (fun k => x k + y k) i = f x i + f y i := by
  change f (x + y) i = f x i + f y i
  rw [map_add]
  rfl

/-- Coordinate type below degree `j`, with the zero space below degree zero. -/
abbrev BoundaryTarget (dimension : ℕ → ℕ) : ℕ → Type
  | 0 => Empty
  | j + 1 => Fin (dimension j)

/--
A finite-length based binary chain complex in nonnegative degrees, indexed
exactly as in Zeng--Pryadko: `boundary j` is `∂_j : A_j → A_(j-1)`.  At
degree zero its codomain is the zero-dimensional space indexed by `Empty`.
-/
structure BasedBinaryChainComplex where
  dimension : ℕ → ℕ
  boundary : ∀ j : ℕ,
    BinaryWord (Fin (dimension j)) →ₗ[ZMod 2]
      BinaryWord (BoundaryTarget dimension j)
  boundary_boundary : ∀ j : ℕ, (boundary j).comp (boundary (j + 1)) = 0
  length : ℕ
  dimension_eq_zero_of_length_lt : ∀ i : ℕ, length < i → dimension i = 0

/--
Homological distance in degree `j`, exactly as Eq. (4) of Zeng--Pryadko:
the least weight in `ker ∂_j \ im ∂_(j+1)`.
-/
noncomputable def chainDistanceAt
    (A : BasedBinaryChainComplex) (j : ℕ) : WithTop ℕ :=
  homologicalDistance (A.boundary j) (A.boundary (j + 1))

/-- A decomposition of the total degree `j` into two nonnegative degrees. -/
def TensorDegreePair (j : ℕ) :=
  {p : Fin (j + 1) × Fin (j + 1) // p.1.val + p.2.val = j}

noncomputable instance tensorDegreePairFintype (j : ℕ) :
    Fintype (TensorDegreePair j) :=
  Fintype.ofInjective (fun p : TensorDegreePair j => p.1) Subtype.val_injective

noncomputable instance tensorDegreePairDecidableEq (j : ℕ) :
    DecidableEq (TensorDegreePair j) := Classical.decEq _

/--
The based coordinate type of the degree-`j` group of a tensor product.  The
component indexed by `(i,k)` with `i+k=j` is `Aᵢ ⊗ Bₖ`.
-/
def TensorDegreeIndex (A B : BasedBinaryChainComplex) (j : ℕ) :=
  Σ p : TensorDegreePair j,
    Fin (A.dimension p.1.1.val) × Fin (B.dimension p.1.2.val)

noncomputable instance tensorDegreeIndexFintype
    (A B : BasedBinaryChainComplex) (j : ℕ) :
    Fintype (TensorDegreeIndex A B j) := by
  classical
  unfold TensorDegreeIndex
  infer_instance

noncomputable instance tensorDegreeIndexDecidableEq
    (A B : BasedBinaryChainComplex) (j : ℕ) :
    DecidableEq (TensorDegreeIndex A B j) := Classical.decEq _

/-- Increase the left degree in a decomposition of a total degree. -/
def tensorDegreePairLeft {j : ℕ} (p : TensorDegreePair j) :
    TensorDegreePair (j + 1) :=
  ⟨(⟨p.1.1.val + 1, by omega⟩, ⟨p.1.2.val, by omega⟩), by
    change (p.1.1.val + 1) + p.1.2.val = j + 1
    have hp : p.1.1.val + p.1.2.val = j := p.2
    omega⟩

/-- Increase the right degree in a decomposition of a total degree. -/
def tensorDegreePairRight {j : ℕ} (p : TensorDegreePair j) :
    TensorDegreePair (j + 1) :=
  ⟨(⟨p.1.1.val, by omega⟩, ⟨p.1.2.val + 1, by omega⟩), by
    change p.1.1.val + (p.1.2.val + 1) = j + 1
    have hp : p.1.1.val + p.1.2.val = j := p.2
    omega⟩

/-- Index inclusion for the contribution of the boundary of `A`. -/
def tensorIndexLeft (A B : BasedBinaryChainComplex) {j : ℕ}
    (p : TensorDegreePair j)
    (a : Fin (A.dimension (p.1.1.val + 1)))
    (b : Fin (B.dimension p.1.2.val)) : TensorDegreeIndex A B (j + 1) :=
  ⟨tensorDegreePairLeft p, a, b⟩

/-- Index inclusion for the contribution of the boundary of `B`. -/
def tensorIndexRight (A B : BasedBinaryChainComplex) {j : ℕ}
    (p : TensorDegreePair j)
    (a : Fin (A.dimension p.1.1.val))
    (b : Fin (B.dimension (p.1.2.val + 1))) : TensorDegreeIndex A B (j + 1) :=
  ⟨tensorDegreePairRight p, a, b⟩

/--
The degree-`j+1` boundary of the tensor product of two arbitrary finite based
binary chain complexes.
-/
def tensorBoundary (A B : BasedBinaryChainComplex) (j : ℕ) :
    BinaryWord (TensorDegreeIndex A B (j + 1)) →ₗ[ZMod 2]
  BinaryWord (TensorDegreeIndex A B j) where
  toFun e := fun z =>
    A.boundary (z.1.1.1.val + 1)
          (fun a => e (tensorIndexLeft A B z.1 a z.2.2)) z.2.1 +
      B.boundary (z.1.1.2.val + 1)
          (fun b => e (tensorIndexRight A B z.1 z.2.1 b)) z.2.2
  map_add' x y := by
    funext z
    change
      A.boundary (z.1.1.1.val + 1)
            ((fun a => x (tensorIndexLeft A B z.1 a z.2.2)) +
              (fun a => y (tensorIndexLeft A B z.1 a z.2.2))) z.2.1 +
          B.boundary (z.1.1.2.val + 1)
            ((fun b => x (tensorIndexRight A B z.1 z.2.1 b)) +
              (fun b => y (tensorIndexRight A B z.1 z.2.1 b))) z.2.2 =
        (A.boundary (z.1.1.1.val + 1)
              (fun a => x (tensorIndexLeft A B z.1 a z.2.2)) z.2.1 +
            B.boundary (z.1.1.2.val + 1)
              (fun b => x (tensorIndexRight A B z.1 z.2.1 b)) z.2.2) +
          (A.boundary (z.1.1.1.val + 1)
              (fun a => y (tensorIndexLeft A B z.1 a z.2.2)) z.2.1 +
            B.boundary (z.1.1.2.val + 1)
              (fun b => y (tensorIndexRight A B z.1 z.2.1 b)) z.2.2)
    rw [map_add, map_add]
    simp only [Pi.add_apply]
    abel
  map_smul' q x := by
    funext z
    change
      A.boundary (z.1.1.1.val + 1)
            (q • fun a => x (tensorIndexLeft A B z.1 a z.2.2)) z.2.1 +
          B.boundary (z.1.1.2.val + 1)
            (q • fun b => x (tensorIndexRight A B z.1 z.2.1 b)) z.2.2 =
        q •
          (A.boundary (z.1.1.1.val + 1)
              (fun a => x (tensorIndexLeft A B z.1 a z.2.2)) z.2.1 +
            B.boundary (z.1.1.2.val + 1)
              (fun b => x (tensorIndexRight A B z.1 z.2.1 b)) z.2.2)
    rw [map_smul, map_smul]
    exact (smul_add q _ _).symm

theorem tensorBoundary_apply (A B : BasedBinaryChainComplex) (j : ℕ)
    (e : BinaryWord (TensorDegreeIndex A B (j + 1)))
    (z : TensorDegreeIndex A B j) :
    tensorBoundary A B j e z =
      A.boundary (z.1.1.1.val + 1)
          (fun a => e (tensorIndexLeft A B z.1 a z.2.2)) z.2.1 +
        B.boundary (z.1.1.2.val + 1)
          (fun b => e (tensorIndexRight A B z.1 z.2.1 b)) z.2.2 := rfl

theorem tensorDegreePair_mixed {j : ℕ} (p : TensorDegreePair j) :
    tensorDegreePairRight (tensorDegreePairLeft p) =
      tensorDegreePairLeft (tensorDegreePairRight p) := by
  apply Subtype.ext
  apply Prod.ext <;> apply Fin.ext <;> rfl

theorem tensorIndex_mixed (A B : BasedBinaryChainComplex) {j : ℕ}
    (p : TensorDegreePair j)
    (a : Fin (A.dimension (p.1.1.val + 1)))
    (b : Fin (B.dimension (p.1.2.val + 1))) :
    tensorIndexRight A B (tensorDegreePairLeft p) a b =
      tensorIndexLeft A B (tensorDegreePairRight p) a b := by
  apply Sigma.ext (tensorDegreePair_mixed p)
  rfl

theorem tensorBoundary_tensorIndexLeft (A B : BasedBinaryChainComplex) {j : ℕ}
    (e : BinaryWord (TensorDegreeIndex A B (j + 2)))
    (p : TensorDegreePair j)
    (a : Fin (A.dimension (p.1.1.val + 1)))
    (b : Fin (B.dimension p.1.2.val)) :
    tensorBoundary A B (j + 1) e (tensorIndexLeft A B p a b) =
      A.boundary (p.1.1.val + 2)
          (fun a' => e (tensorIndexLeft A B (tensorDegreePairLeft p) a' b)) a +
        B.boundary (p.1.2.val + 1)
          (fun b' => e (tensorIndexRight A B (tensorDegreePairLeft p) a b')) b := rfl

theorem tensorBoundary_tensorIndexRight (A B : BasedBinaryChainComplex) {j : ℕ}
    (e : BinaryWord (TensorDegreeIndex A B (j + 2)))
    (p : TensorDegreePair j)
    (a : Fin (A.dimension p.1.1.val))
    (b : Fin (B.dimension (p.1.2.val + 1))) :
    tensorBoundary A B (j + 1) e (tensorIndexRight A B p a b) =
      A.boundary (p.1.1.val + 1)
          (fun a' => e (tensorIndexLeft A B (tensorDegreePairRight p) a' b)) a +
        B.boundary (p.1.2.val + 2)
          (fun b' => e (tensorIndexRight A B (tensorDegreePairRight p) a b')) b := rfl

/-- Consecutive tensor-product boundaries compose to zero. -/
theorem tensorBoundary_boundary (A B : BasedBinaryChainComplex) (j : ℕ) :
    (tensorBoundary A B j).comp (tensorBoundary A B (j + 1)) = 0 := by
  apply LinearMap.ext
  intro e
  funext z
  rcases z with ⟨p, a, b⟩
  change
    A.boundary (p.1.1.val + 1)
          (fun a' => tensorBoundary A B (j + 1) e (tensorIndexLeft A B p a' b)) a +
        B.boundary (p.1.2.val + 1)
          (fun b' => tensorBoundary A B (j + 1) e (tensorIndexRight A B p a b')) b = 0
  simp_rw [tensorBoundary_tensorIndexLeft, tensorBoundary_tensorIndexRight]
  rw [linearMap_apply_pointwise_add, linearMap_apply_pointwise_add]
  have hA :
      A.boundary (p.1.1.val + 1)
          (A.boundary (p.1.1.val + 2)
            (fun a'' => e (tensorIndexLeft A B (tensorDegreePairLeft p) a'' b))) a = 0 := by
    have h := congrArg
      (fun L => L (fun a'' => e (tensorIndexLeft A B (tensorDegreePairLeft p) a'' b)))
      (A.boundary_boundary (p.1.1.val + 1))
    exact congrFun (by simpa [LinearMap.comp_apply] using h) a
  have hB :
      B.boundary (p.1.2.val + 1)
          (B.boundary (p.1.2.val + 2)
            (fun b'' => e (tensorIndexRight A B (tensorDegreePairRight p) a b''))) b = 0 := by
    have h := congrArg
      (fun L => L (fun b'' => e (tensorIndexRight A B (tensorDegreePairRight p) a b'')))
      (B.boundary_boundary (p.1.2.val + 1))
    exact congrFun (by simpa [LinearMap.comp_apply] using h) b
  have hMixed :
      A.boundary (p.1.1.val + 1)
          (fun a' =>
            B.boundary (p.1.2.val + 1)
              (fun b' => e (tensorIndexRight A B (tensorDegreePairLeft p) a' b')) b) a =
        B.boundary (p.1.2.val + 1)
          (fun b' =>
            A.boundary (p.1.1.val + 1)
              (fun a' => e (tensorIndexLeft A B (tensorDegreePairRight p) a' b')) a) b := by
    calc
      _ = B.boundary (p.1.2.val + 1)
          (fun b' =>
            A.boundary (p.1.1.val + 1)
              (fun a' => e (tensorIndexRight A B (tensorDegreePairLeft p) a' b')) a) b :=
        linearMap_apply_separateDirections
          (A.boundary (p.1.1.val + 1)) (B.boundary (p.1.2.val + 1))
          (fun a' b' => e (tensorIndexRight A B (tensorDegreePairLeft p) a' b')) a b
      _ = _ := by
        apply congrArg (fun x => B.boundary (p.1.2.val + 1) x b)
        funext b'
        apply congrArg (fun x => A.boundary (p.1.1.val + 1) x a)
        funext a'
        exact congrArg e (tensorIndex_mixed A B p a' b')
  rw [hA, hB, hMixed]
  ring_nf
  have htwo : (2 : ZMod 2) = 0 := by decide
  rw [htwo, mul_zero]

/-- Coordinate type below tensor-product degree `j`. -/
def TensorBoundaryTarget (A B : BasedBinaryChainComplex) : ℕ → Type
  | 0 => Empty
  | j + 1 => TensorDegreeIndex A B j

/--
The paper-indexed tensor-product boundary in degree `j`.  Thus
`tensorBoundaryAt A B j` has domain `(A × B)_j`, not `(A × B)_(j+1)`.
-/
def tensorBoundaryAt (A B : BasedBinaryChainComplex) : ∀ j : ℕ,
    BinaryWord (TensorDegreeIndex A B j) →ₗ[ZMod 2]
      BinaryWord (TensorBoundaryTarget A B j)
  | 0 => 0
  | j + 1 => tensorBoundary A B j

/-- Consecutive paper-indexed tensor-product boundaries compose to zero. -/
theorem tensorBoundaryAt_boundaryAt
    (A B : BasedBinaryChainComplex) (j : ℕ) :
    (tensorBoundaryAt A B j).comp (tensorBoundaryAt A B (j + 1)) = 0 := by
  cases j with
  | zero => rfl
  | succ j => exact tensorBoundary_boundary A B j

/--
Homological distance of the tensor product in degree `j`, in the exact
`ker ∂_j \ im ∂_(j+1)` form of Eq. (4).
-/
noncomputable def tensorProductDistanceAt
    (A B : BasedBinaryChainComplex) (j : ℕ) : WithTop ℕ :=
  homologicalDistance (tensorBoundaryAt A B j) (tensorBoundaryAt A B (j + 1))

/-- The right-hand side `minᵢ dᵢ(A) dⱼ₋ᵢ(B)` of Eq. (11). -/
noncomputable def componentDistanceMinimum
    (A B : BasedBinaryChainComplex) (j : ℕ) : WithTop ℕ :=
  sInf {w : WithTop ℕ | ∃ i : Fin (j + 1),
    w = chainDistanceAt A i.val * chainDistanceAt B (j - i.val)}

/-- The length-one based chain complex induced by an `r × c` binary matrix. -/
def oneComplex {r c : ℕ}
    (P : BinaryWord (Fin c) →ₗ[ZMod 2] BinaryWord (Fin r)) :
    BasedBinaryChainComplex where
  dimension
    | 0 => r
    | 1 => c
    | _ + 2 => 0
  boundary
    | 0 => 0
    | 1 => P
    | _ + 2 => 0
  boundary_boundary := by
    intro i
    cases i <;> simp
  length := 1
  dimension_eq_zero_of_length_lt := by
    intro i hi
    match i with
    | 0 => omega
    | 1 => omega
    | _ + 2 => rfl

/-- Distance in the degree immediately below `j`, with `⊤` below degree zero. -/
noncomputable def chainDistanceBefore
    (A : BasedBinaryChainComplex) : ℕ → WithTop ℕ
  | 0 => ⊤
  | j + 1 => chainDistanceAt A j

end ZengPryadko2019
Source
Weilei Zeng and Leonid P. Pryadko, Higher-dimensional quantum hypergraph-product codes, arXiv:1810.01519v2, Eqs. (1)-(4), (6)-(11), and (13), https://arxiv.org/abs/1810.01519
Read-back

What the Lean code literally says, in plain math · gpt-5.6-sol

Blind read-back of Def_ZengPryadko2019.lean

1. BinaryWord

For every type ι\iotaι, BinaryWord declares the type of all functions x:ι→Z/2Zx:\iota\to\mathbb Z/2\mathbb Zx:ι→Z/2Z. No finiteness or decidable-equality assumption is part of this abbreviation; if ι\iotaι is empty, this function type has exactly one element, the empty (and hence zero) word.

2. homologicalDistance

For arbitrary types ι,κ,μ\iota,\kappa,\muι,κ,μ, assuming only that ι\iotaι is finite and has decidable equality, and for Z/2Z\mathbb Z/2\mathbb ZZ/2Z-linear maps d:(ι→Z/2Z)→(κ→Z/2Z)d:(\iota\to\mathbb Z/2\mathbb Z)\to(\kappa\to\mathbb Z/2\mathbb Z)d:(ι→Z/2Z)→(κ→Z/2Z) and dnext:(μ→Z/2Z)→(ι→Z/2Z)d_{\mathrm{next}}:(\mu\to\mathbb Z/2\mathbb Z)\to(\iota\to\mathbb Z/2\mathbb Z)dnext​:(μ→Z/2Z)→(ι→Z/2Z), homologicalDistance is the infimum in N∪{⊤}\mathbb N\cup\{\top\}N∪{⊤} of the set of values www for which there exists a word x:ι→Z/2Zx:\iota\to\mathbb Z/2\mathbb Zx:ι→Z/2Z satisfying d(x)=0d(x)=0d(x)=0, x∉range⁡(dnext)x\notin\operatorname{range}(d_{\mathrm{next}})x∈/range(dnext​), and w=hammingNorm⁡(x)w=\operatorname{hammingNorm}(x)w=hammingNorm(x), where the Hamming norm is the number of coordinates at which xxx is nonzero. Thus it takes the least such Hamming weight when such an xxx exists and is ⊤\top⊤ when no such xxx exists. In particular, 000 is always in the range of a linear map, so a witnessing xxx cannot be the zero word; if ι\iotaι is empty, the only word is zero, the defining set is empty, and the value is ⊤\top⊤. There is no hypothesis that d∘dnext=0d\circ d_{\mathrm{next}}=0d∘dnext​=0, and neither κ\kappaκ nor μ\muμ is required to be finite.

3. linearMap_apply_eq_sum

For all natural numbers m,nm,nm,n, every Z/2Z\mathbb Z/2\mathbb ZZ/2Z-linear map f:(Fin⁡n→Z/2Z)→(Fin⁡m→Z/2Z)f:(\operatorname{Fin}n\to\mathbb Z/2\mathbb Z)\to(\operatorname{Fin}m\to\mathbb Z/2\mathbb Z)f:(Finn→Z/2Z)→(Finm→Z/2Z), every word x:Fin⁡n→Z/2Zx:\operatorname{Fin}n\to\mathbb Z/2\mathbb Zx:Finn→Z/2Z, and every output coordinate i∈Fin⁡mi\in\operatorname{Fin}mi∈Finm, the declaration asserts

f(x)(i)=∑k∈Fin⁡nf(δk)(i)x(k),f(x)(i)=\sum_{k\in\operatorname{Fin}n} f(\delta_k)(i)x(k),f(x)(i)=k∈Finn∑​f(δk​)(i)x(k),

where δk\delta_kδk​ is the word equal to 111 at kkk and 000 at every other coordinate, and all arithmetic is in Z/2Z\mathbb Z/2\mathbb ZZ/2Z. If n=0n=0n=0, the sum is empty and equals 000; if m=0m=0m=0, there is no possible binder iii, so the assertion has no coordinate instance.

4. linearMap_apply_separateDirections

For all natural numbers m,n,p,qm,n,p,qm,n,p,q, all Z/2Z\mathbb Z/2\mathbb ZZ/2Z-linear maps f:(Fin⁡n→Z/2Z)→(Fin⁡m→Z/2Z)f:(\operatorname{Fin}n\to\mathbb Z/2\mathbb Z)\to(\operatorname{Fin}m\to\mathbb Z/2\mathbb Z)f:(Finn→Z/2Z)→(Finm→Z/2Z) and g:(Fin⁡q→Z/2Z)→(Fin⁡p→Z/2Z)g:(\operatorname{Fin}q\to\mathbb Z/2\mathbb Z)\to(\operatorname{Fin}p\to\mathbb Z/2\mathbb Z)g:(Finq→Z/2Z)→(Finp→Z/2Z), every function e:Fin⁡n→Fin⁡q→Z/2Ze:\operatorname{Fin}n\to\operatorname{Fin}q\to\mathbb Z/2\mathbb Ze:Finn→Finq→Z/2Z, and coordinates a∈Fin⁡ma\in\operatorname{Fin}ma∈Finm and b∈Fin⁡pb\in\operatorname{Fin}pb∈Finp, the declaration asserts

f(a′↦g(b′↦e(a′,b′))(b))(a)=g(b′↦f(a′↦e(a′,b′))(a))(b).f\bigl(a'\mapsto g(b'\mapsto e(a',b'))(b)\bigr)(a) =g\bigl(b'\mapsto f(a'\mapsto e(a',b'))(a)\bigr)(b).f(a′↦g(b′↦e(a′,b′))(b))(a)=g(b′↦f(a′↦e(a′,b′))(a))(b).

Thus the two linear maps, applied in the two separate coordinate directions and then evaluated at a,ba,ba,b, give the same scalar. The quantifiers include n=0n=0n=0 and q=0q=0q=0, in which case the corresponding input words are empty, and if m=0m=0m=0 or p=0p=0p=0 there is respectively no possible aaa or bbb, so the universally quantified assertion is vacuous.

5. linearMap_apply_pointwise_add

For all natural numbers m,nm,nm,n, every Z/2Z\mathbb Z/2\mathbb ZZ/2Z-linear map f:(Fin⁡n→Z/2Z)→(Fin⁡m→Z/2Z)f:(\operatorname{Fin}n\to\mathbb Z/2\mathbb Z)\to(\operatorname{Fin}m\to\mathbb Z/2\mathbb Z)f:(Finn→Z/2Z)→(Finm→Z/2Z), words x,y:Fin⁡n→Z/2Zx,y:\operatorname{Fin}n\to\mathbb Z/2\mathbb Zx,y:Finn→Z/2Z, and coordinate i∈Fin⁡mi\in\operatorname{Fin}mi∈Finm, the declaration asserts f(k↦x(k)+y(k))(i)=f(x)(i)+f(y)(i)f(k\mapsto x(k)+y(k))(i)=f(x)(i)+f(y)(i)f(k↦x(k)+y(k))(i)=f(x)(i)+f(y)(i). If n=0n=0n=0, both inputs are the unique empty word; if m=0m=0m=0, there is no coordinate iii and hence no instance of the assertion.

6. BoundaryTarget

For every dimension function D:N→ND:\mathbb N\to\mathbb ND:N→N, BoundaryTarget declares a degree-indexed coordinate type with BoundaryTarget⁡(D,0)=∅\operatorname{BoundaryTarget}(D,0)=\varnothingBoundaryTarget(D,0)=∅ and BoundaryTarget⁡(D,j+1)=Fin⁡(D(j))\operatorname{BoundaryTarget}(D,j+1)=\operatorname{Fin}(D(j))BoundaryTarget(D,j+1)=Fin(D(j)) for every j∈Nj\in\mathbb Nj∈N. Consequently, a word on the degree-zero boundary target is the unique function from the empty type to Z/2Z\mathbb Z/2\mathbb ZZ/2Z.

7. BasedBinaryChainComplex

BasedBinaryChainComplex declares a structure consisting of: a function D:N→ND:\mathbb N\to\mathbb ND:N→N; for every j∈Nj\in\mathbb Nj∈N, a Z/2Z\mathbb Z/2\mathbb ZZ/2Z-linear map

∂j:(Fin⁡(D(j))→Z/2Z)⟶(BoundaryTarget⁡(D,j)→Z/2Z),\partial_j:(\operatorname{Fin}(D(j))\to\mathbb Z/2\mathbb Z) \longrightarrow (\operatorname{BoundaryTarget}(D,j)\to\mathbb Z/2\mathbb Z),∂j​:(Fin(D(j))→Z/2Z)⟶(BoundaryTarget(D,j)→Z/2Z),

whose target is the empty-coordinate word space when j=0j=0j=0 and is the word space on Fin⁡(D(j−1))\operatorname{Fin}(D(j-1))Fin(D(j−1)) when j>0j>0j>0; a proof that ∂j∘∂j+1=0\partial_j\circ\partial_{j+1}=0∂j​∘∂j+1​=0 for every j∈Nj\in\mathbb Nj∈N; a natural number LLL called length; and a proof that D(i)=0D(i)=0D(i)=0 whenever L<iL<iL<i. The declaration imposes no condition that D(L)D(L)D(L) be nonzero and no minimality condition on LLL. At the lower end, ∂0\partial_0∂0​ has the one-element empty-coordinate codomain and is therefore the zero map. At the upper end, all groups in degrees strictly above LLL have empty coordinate types, ∂L+1\partial_{L+1}∂L+1​ has an empty-coordinate domain and is the zero incoming map to degree LLL, and every still higher boundary also has empty-coordinate domain; when L=0L=0L=0, all positive-degree dimensions vanish while D(0)D(0)D(0) remains unrestricted.

8. chainDistanceAt

For every based binary chain complex AAA and every j∈Nj\in\mathbb Nj∈N, chainDistanceAt A j is the infimum in N∪{⊤}\mathbb N\cup\{\top\}N∪{⊤} of the Hamming weights of all words x:Fin⁡(A.D(j))→Z/2Zx:\operatorname{Fin}(A.D(j))\to\mathbb Z/2\mathbb Zx:Fin(A.D(j))→Z/2Z such that ∂jA(x)=0\partial^A_j(x)=0∂jA​(x)=0 and x∉range⁡(∂j+1A)x\notin\operatorname{range}(\partial^A_{j+1})x∈/range(∂j+1A​); it is ⊤\top⊤ if there is no such word. At j=0j=0j=0, ∂0A\partial^A_0∂0A​ has empty-coordinate codomain and is zero, so every degree-zero word satisfies the kernel condition, although the non-image condition remains. At j=A.Lj=A.Lj=A.L, the incoming map ∂A.L+1A\partial^A_{A.L+1}∂A.L+1A​ has empty-coordinate domain and range {0}\{0\}{0}, so witnesses are precisely nonzero words in ker⁡∂A.LA\ker\partial^A_{A.L}ker∂A.LA​. For every j>A.Lj>A.Lj>A.L, the degree-jjj coordinate type is empty, its sole word is zero and lies in the range of the next boundary, so the defining set is empty and the distance is ⊤\top⊤; these statements also cover A.L=0A.L=0A.L=0.

9. TensorDegreePair

For every j∈Nj\in\mathbb Nj∈N, TensorDegreePair j is the subtype of pairs (i,k)∈Fin⁡(j+1)×Fin⁡(j+1)(i,k)\in\operatorname{Fin}(j+1)\times\operatorname{Fin}(j+1)(i,k)∈Fin(j+1)×Fin(j+1) whose underlying natural values satisfy i+k=ji+k=ji+k=j. Thus both entries lie between 000 and jjj, both endpoint decompositions (0,j)(0,j)(0,j) and (j,0)(j,0)(j,0) are present, and for j=0j=0j=0 the sole element is (0,0)(0,0)(0,0).

10. tensorDegreePairFintype

For every j∈Nj\in\mathbb Nj∈N, tensorDegreePairFintype j noncomputably supplies a finite-type structure on the set of pairs (i,k)∈Fin⁡(j+1)2(i,k)\in\operatorname{Fin}(j+1)^2(i,k)∈Fin(j+1)2 satisfying i+k=ji+k=ji+k=j, using the injective inclusion of that subtype into the finite product. This declaration adds data enabling finite enumeration; it asserts no ordering or chosen enumeration formula.

11. tensorDegreePairDecidableEq

For every j∈Nj\in\mathbb Nj∈N, tensorDegreePairDecidableEq j noncomputably supplies a classical decision procedure for equality between two degree pairs (i,k)(i,k)(i,k) with i+k=ji+k=ji+k=j.

12. TensorDegreeIndex

For every pair of based binary chain complexes A,BA,BA,B and every j∈Nj\in\mathbb Nj∈N, TensorDegreeIndex A B j is the dependent disjoint union

∐0≤i,k≤ji+k=jFin⁡(A.D(i))×Fin⁡(B.D(k)).\coprod_{\substack{0\le i,k\le j\\i+k=j}} \operatorname{Fin}(A.D(i))\times\operatorname{Fin}(B.D(k)).0≤i,k≤ji+k=j​∐​Fin(A.D(i))×Fin(B.D(k)).

An element therefore consists of a degree pair (i,k)(i,k)(i,k) with i+k=ji+k=ji+k=j, an AAA-coordinate a<A.D(i)a<A.D(i)a<A.D(i), and a BBB-coordinate b<B.D(k)b<B.D(k)b<B.D(k). A component is empty if either dimension is zero; at j=0j=0j=0 only the component (0,0)(0,0)(0,0) occurs. If AAA and BBB have recorded lengths LA,LBL_A,L_BLA​,LB​, then this entire index type is empty for j>LA+LBj>L_A+L_Bj>LA​+LB​, because every decomposition i+k=ji+k=ji+k=j then has i>LAi>L_Ai>LA​ or k>LBk>L_Bk>LB​ and hence a zero dimension.

13. tensorDegreeIndexFintype

For every based binary chain complexes A,BA,BA,B and every j∈Nj\in\mathbb Nj∈N, tensorDegreeIndexFintype A B j noncomputably supplies a finite-type structure on the dependent union of triples ((i,k),a,b)((i,k),a,b)((i,k),a,b) with i+k=ji+k=ji+k=j, a<A.D(i)a<A.D(i)a<A.D(i), and b<B.D(k)b<B.D(k)b<B.D(k).

14. tensorDegreeIndexDecidableEq

For every based binary chain complexes A,BA,BA,B and every j∈Nj\in\mathbb Nj∈N, tensorDegreeIndexDecidableEq A B j noncomputably supplies a classical decision procedure for equality between two dependent triples ((i,k),a,b)((i,k),a,b)((i,k),a,b) in the degree-jjj tensor index type.

15. tensorDegreePairLeft

For every implicit j∈Nj\in\mathbb Nj∈N and every degree pair p=(i,k)p=(i,k)p=(i,k) with i+k=ji+k=ji+k=j, tensorDegreePairLeft p is the degree-(j+1)(j+1)(j+1) pair (i+1,k)(i+1,k)(i+1,k). The finite-index bounds and the equality (i+1)+k=j+1(i+1)+k=j+1(i+1)+k=j+1 are included as proof data; this is defined also at j=0j=0j=0, where it sends (0,0)(0,0)(0,0) to (1,0)(1,0)(1,0).

16. tensorDegreePairRight

For every implicit j∈Nj\in\mathbb Nj∈N and every degree pair p=(i,k)p=(i,k)p=(i,k) with i+k=ji+k=ji+k=j, tensorDegreePairRight p is the degree-(j+1)(j+1)(j+1) pair (i,k+1)(i,k+1)(i,k+1). The finite-index bounds and the equality i+(k+1)=j+1i+(k+1)=j+1i+(k+1)=j+1 are included as proof data; this is defined also at j=0j=0j=0, where it sends (0,0)(0,0)(0,0) to (0,1)(0,1)(0,1).

17. tensorIndexLeft

For every based binary chain complexes A,BA,BA,B, implicit j∈Nj\in\mathbb Nj∈N, degree pair p=(i,k)p=(i,k)p=(i,k) with i+k=ji+k=ji+k=j, coordinate a∈Fin⁡(A.D(i+1))a\in\operatorname{Fin}(A.D(i+1))a∈Fin(A.D(i+1)), and coordinate b∈Fin⁡(B.D(k))b\in\operatorname{Fin}(B.D(k))b∈Fin(B.D(k)), tensorIndexLeft A B p a b is the degree-(j+1)(j+1)(j+1) tensor index ((i+1,k),a,b)((i+1,k),a,b)((i+1,k),a,b). If either indicated dimension is zero, the corresponding coordinate binder has no inhabitant, so there is no such indexed value.

18. tensorIndexRight

For every based binary chain complexes A,BA,BA,B, implicit j∈Nj\in\mathbb Nj∈N, degree pair p=(i,k)p=(i,k)p=(i,k) with i+k=ji+k=ji+k=j, coordinate a∈Fin⁡(A.D(i))a\in\operatorname{Fin}(A.D(i))a∈Fin(A.D(i)), and coordinate b∈Fin⁡(B.D(k+1))b\in\operatorname{Fin}(B.D(k+1))b∈Fin(B.D(k+1)), tensorIndexRight A B p a b is the degree-(j+1)(j+1)(j+1) tensor index ((i,k+1),a,b)((i,k+1),a,b)((i,k+1),a,b). If either indicated dimension is zero, the corresponding coordinate binder has no inhabitant, so there is no such indexed value.

19. tensorBoundary

For every based binary chain complexes A,BA,BA,B and every j∈Nj\in\mathbb Nj∈N, tensorBoundary A B j declares a Z/2Z\mathbb Z/2\mathbb ZZ/2Z-linear map from words on the degree-(j+1)(j+1)(j+1) tensor index to words on the degree-jjj tensor index. Explicitly, for an input word eee and an output index z=((i,k),a,b)z=((i,k),a,b)z=((i,k),a,b) with i+k=ji+k=ji+k=j, its value is

∂i+1A(a′↦e((i+1,k),a′,b))(a)+∂k+1B(b′↦e((i,k+1),a,b′))(b),\partial^A_{i+1}\bigl(a'\mapsto e((i+1,k),a',b)\bigr)(a) + \partial^B_{k+1}\bigl(b'\mapsto e((i,k+1),a,b')\bigr)(b),∂i+1A​(a′↦e((i+1,k),a′,b))(a)+∂k+1B​(b′↦e((i,k+1),a,b′))(b),

with addition in Z/2Z\mathbb Z/2\mathbb ZZ/2Z. The first slice ranges over a′∈Fin⁡(A.D(i+1))a'\in\operatorname{Fin}(A.D(i+1))a′∈Fin(A.D(i+1)) and the second over b′∈Fin⁡(B.D(k+1))b'\in\operatorname{Fin}(B.D(k+1))b′∈Fin(B.D(k+1)); the displayed output exists only when a∈Fin⁡(A.D(i))a\in\operatorname{Fin}(A.D(i))a∈Fin(A.D(i)) and b∈Fin⁡(B.D(k))b\in\operatorname{Fin}(B.D(k))b∈Fin(B.D(k)). The definition includes proofs that this coordinate formula preserves addition and scalar multiplication. At j=0j=0j=0, the only possible degree pair in the codomain is (0,0)(0,0)(0,0). If the codomain index type is empty, the output is the unique empty word; empty source components contribute only empty slices.

20. tensorBoundary_apply

For every based binary chain complexes A,BA,BA,B, every j∈Nj\in\mathbb Nj∈N, every word eee on the degree-(j+1)(j+1)(j+1) tensor index, and every degree-jjj tensor index z=((i,k),a,b)z=((i,k),a,b)z=((i,k),a,b) with i+k=ji+k=ji+k=j, the declaration asserts the definitional coordinate equality

(tensorBoundary⁡A,B,je)(z)=∂i+1A(a′↦e((i+1,k),a′,b))(a)+∂k+1B(b′↦e((i,k+1),a,b′))(b).(\operatorname{tensorBoundary}_{A,B,j}e)(z) = \partial^A_{i+1}\bigl(a'\mapsto e((i+1,k),a',b)\bigr)(a) + \partial^B_{k+1}\bigl(b'\mapsto e((i,k+1),a,b')\bigr)(b).(tensorBoundaryA,B,j​e)(z)=∂i+1A​(a′↦e((i+1,k),a′,b))(a)+∂k+1B​(b′↦e((i,k+1),a,b′))(b).

All values and additions are in Z/2Z\mathbb Z/2\mathbb ZZ/2Z; if the degree-jjj tensor index is empty there is no possible zzz, so the universally quantified coordinate statement has no instance.

21. tensorDegreePair_mixed

For every implicit j∈Nj\in\mathbb Nj∈N and every degree pair p=(i,k)p=(i,k)p=(i,k) with i+k=ji+k=ji+k=j, the declaration asserts equality of the degree-(j+2)(j+2)(j+2) dependent pairs obtained by first increasing the left entry and then the right entry or in the opposite order: both are (i+1,k+1)(i+1,k+1)(i+1,k+1). This includes equality of the subtype proof-bearing values, not merely equality of their displayed natural-number coordinates.

22. tensorIndex_mixed

For every based binary chain complexes A,BA,BA,B, implicit j∈Nj\in\mathbb Nj∈N, degree pair p=(i,k)p=(i,k)p=(i,k) with i+k=ji+k=ji+k=j, coordinate a∈Fin⁡(A.D(i+1))a\in\operatorname{Fin}(A.D(i+1))a∈Fin(A.D(i+1)), and coordinate b∈Fin⁡(B.D(k+1))b\in\operatorname{Fin}(B.D(k+1))b∈Fin(B.D(k+1)), the declaration asserts that inserting ((i+1,k),a,b)((i+1,k),a,b)((i+1,k),a,b) by a right-degree increase equals inserting ((i,k+1),a,b)((i,k+1),a,b)((i,k+1),a,b) by a left-degree increase; both sides are the same degree-(j+2)(j+2)(j+2) tensor index ((i+1,k+1),a,b)((i+1,k+1),a,b)((i+1,k+1),a,b). If either coordinate type is empty, the universal assertion is vacuous because no corresponding aaa or bbb exists.

23. tensorBoundary_tensorIndexLeft

For every based binary chain complexes A,BA,BA,B, implicit j∈Nj\in\mathbb Nj∈N, word eee on the degree-(j+2)(j+2)(j+2) tensor index, pair p=(i,k)p=(i,k)p=(i,k) with i+k=ji+k=ji+k=j, coordinate a∈Fin⁡(A.D(i+1))a\in\operatorname{Fin}(A.D(i+1))a∈Fin(A.D(i+1)), and coordinate b∈Fin⁡(B.D(k))b\in\operatorname{Fin}(B.D(k))b∈Fin(B.D(k)), the declaration gives the value of the boundary from degree j+2j+2j+2 to degree j+1j+1j+1 at the left-inserted index ((i+1,k),a,b)((i+1,k),a,b)((i+1,k),a,b) as

∂i+2A(a′↦e((i+2,k),a′,b))(a)+∂k+1B(b′↦e((i+1,k+1),a,b′))(b).\partial^A_{i+2}\bigl(a'\mapsto e((i+2,k),a',b)\bigr)(a) + \partial^B_{k+1}\bigl(b'\mapsto e((i+1,k+1),a,b')\bigr)(b).∂i+2A​(a′↦e((i+2,k),a′,b))(a)+∂k+1B​(b′↦e((i+1,k+1),a,b′))(b).

Here a′a'a′ ranges over Fin⁡(A.D(i+2))\operatorname{Fin}(A.D(i+2))Fin(A.D(i+2)) and b′b'b′ over Fin⁡(B.D(k+1))\operatorname{Fin}(B.D(k+1))Fin(B.D(k+1)), and all arithmetic is in Z/2Z\mathbb Z/2\mathbb ZZ/2Z; if the type of aaa or bbb is empty, there is no instance of the coordinate assertion.

24. tensorBoundary_tensorIndexRight

For every based binary chain complexes A,BA,BA,B, implicit j∈Nj\in\mathbb Nj∈N, word eee on the degree-(j+2)(j+2)(j+2) tensor index, pair p=(i,k)p=(i,k)p=(i,k) with i+k=ji+k=ji+k=j, coordinate a∈Fin⁡(A.D(i))a\in\operatorname{Fin}(A.D(i))a∈Fin(A.D(i)), and coordinate b∈Fin⁡(B.D(k+1))b\in\operatorname{Fin}(B.D(k+1))b∈Fin(B.D(k+1)), the declaration gives the value of the boundary from degree j+2j+2j+2 to degree j+1j+1j+1 at the right-inserted index ((i,k+1),a,b)((i,k+1),a,b)((i,k+1),a,b) as

∂i+1A(a′↦e((i+1,k+1),a′,b))(a)+∂k+2B(b′↦e((i,k+2),a,b′))(b).\partial^A_{i+1}\bigl(a'\mapsto e((i+1,k+1),a',b)\bigr)(a) + \partial^B_{k+2}\bigl(b'\mapsto e((i,k+2),a,b')\bigr)(b).∂i+1A​(a′↦e((i+1,k+1),a′,b))(a)+∂k+2B​(b′↦e((i,k+2),a,b′))(b).

Here a′a'a′ ranges over Fin⁡(A.D(i+1))\operatorname{Fin}(A.D(i+1))Fin(A.D(i+1)) and b′b'b′ over Fin⁡(B.D(k+2))\operatorname{Fin}(B.D(k+2))Fin(B.D(k+2)), and all arithmetic is in Z/2Z\mathbb Z/2\mathbb ZZ/2Z; if the type of aaa or bbb is empty, there is no instance of the coordinate assertion.

25. tensorBoundary_boundary

For every based binary chain complexes A,BA,BA,B and every j∈Nj\in\mathbb Nj∈N, the declaration asserts that the composite of the tensor boundary from degree j+2j+2j+2 to degree j+1j+1j+1 with the tensor boundary from degree j+1j+1j+1 to degree jjj is the zero Z/2Z\mathbb Z/2\mathbb ZZ/2Z-linear map:

tensorBoundary⁡A,B,j∘tensorBoundary⁡A,B,j+1=0.\operatorname{tensorBoundary}_{A,B,j}\circ \operatorname{tensorBoundary}_{A,B,j+1}=0.tensorBoundaryA,B,j​∘tensorBoundaryA,B,j+1​=0.

Equivalently, every degree-(j+2)(j+2)(j+2) word is sent to the zero word on every degree-jjj tensor coordinate. The quantifier includes j=0j=0j=0; if a relevant source or target tensor index type is empty, the corresponding equality reduces to equality of maps involving a one-element empty-coordinate word space.

26. TensorBoundaryTarget

For every based binary chain complexes A,BA,BA,B, TensorBoundaryTarget A B declares a degree-indexed coordinate type with value ∅\varnothing∅ at degree 000 and value TensorDegreeIndex⁡(A,B,j)\operatorname{TensorDegreeIndex}(A,B,j)TensorDegreeIndex(A,B,j) at degree j+1j+1j+1, namely the dependent union of triples ((i,k),a,b)((i,k),a,b)((i,k),a,b) with i+k=ji+k=ji+k=j, a<A.D(i)a<A.D(i)a<A.D(i), and b<B.D(k)b<B.D(k)b<B.D(k). Thus a word on the degree-zero target is the unique empty word, while the target in positive degree j+1j+1j+1 is exactly the tensor coordinate type one degree lower.

27. tensorBoundaryAt

For every based binary chain complexes A,BA,BA,B, tensorBoundaryAt A B declares for each j∈Nj\in\mathbb Nj∈N a Z/2Z\mathbb Z/2\mathbb ZZ/2Z-linear map from words on the degree-jjj tensor index to words on TensorBoundaryTarget A B j: at j=0j=0j=0 it is the zero map from the degree-zero tensor word space to the empty-coordinate word space, and at j+1j+1j+1 it is tensorBoundary A B j, whose value at ((i,k),a,b)((i,k),a,b)((i,k),a,b) with i+k=ji+k=ji+k=j is ∂i+1A(a′↦e((i+1,k),a′,b))(a)+∂k+1B(b′↦e((i,k+1),a,b′))(b)\partial^A_{i+1}(a'\mapsto e((i+1,k),a',b))(a)+\partial^B_{k+1}(b'\mapsto e((i,k+1),a,b'))(b)∂i+1A​(a′↦e((i+1,k),a′,b))(a)+∂k+1B​(b′↦e((i,k+1),a,b′))(b). If the recorded lengths are LA,LBL_A,L_BLA​,LB​, the degree-jjj source index is empty for j>LA+LBj>L_A+L_Bj>LA​+LB​; in particular, the boundary in degree LA+LB+1L_A+L_B+1LA​+LB​+1 has empty domain and is the zero incoming map to the highest possibly nonempty degree, and all higher-degree domains are also empty. The lower endpoint is separately fixed by the j=0j=0j=0 zero-map clause, including when LA=LB=0L_A=L_B=0LA​=LB​=0.

28. tensorBoundaryAt_boundaryAt

For every based binary chain complexes A,BA,BA,B and every j∈Nj\in\mathbb Nj∈N, the declaration asserts

tensorBoundaryAt⁡A,B,j∘tensorBoundaryAt⁡A,B,j+1=0.\operatorname{tensorBoundaryAt}_{A,B,j} \circ \operatorname{tensorBoundaryAt}_{A,B,j+1}=0.tensorBoundaryAtA,B,j​∘tensorBoundaryAtA,B,j+1​=0.

Thus every degree-(j+1)(j+1)(j+1) tensor word is sent to zero after the two consecutive paper-indexed boundary maps. At j=0j=0j=0, the outer boundary is the explicitly defined zero map to the empty-coordinate word space; for j>0j>0j>0 the equality is the corresponding consecutive tensorBoundary equality. The assertion also includes degrees above the sum of the recorded lengths, where the source word spaces are empty-coordinate one-element spaces.

29. tensorProductDistanceAt

For every based binary chain complexes A,BA,BA,B and every j∈Nj\in\mathbb Nj∈N, tensorProductDistanceAt A B j is the infimum in N∪{⊤}\mathbb N\cup\{\top\}N∪{⊤} of the Hamming weights of words xxx on the degree-jjj tensor index such that tensorBoundaryAt⁡A,B,j(x)=0\operatorname{tensorBoundaryAt}_{A,B,j}(x)=0tensorBoundaryAtA,B,j​(x)=0 and xxx is not in the range of tensorBoundaryAt⁡A,B,j+1\operatorname{tensorBoundaryAt}_{A,B,j+1}tensorBoundaryAtA,B,j+1​; it is ⊤\top⊤ when there is no such word. At j=0j=0j=0, the first boundary is explicitly zero, so every degree-zero word satisfies the kernel condition. If the recorded lengths are LA,LBL_A,L_BLA​,LB​, then at j=LA+LBj=L_A+L_Bj=LA​+LB​ the next-degree tensor index is empty and the incoming boundary has range {0}\{0\}{0}, so witnesses are precisely the nonzero words in the kernel at that degree; for every j>LA+LBj>L_A+L_Bj>LA​+LB​, the degree-jjj tensor index itself is empty, its only word is zero and lies in the incoming range, and the distance is ⊤\top⊤. These endpoint statements still apply when one or both lengths are zero.

30. componentDistanceMinimum

For every based binary chain complexes A,BA,BA,B and every j∈Nj\in\mathbb Nj∈N, componentDistanceMinimum A B j is the infimum in N∪{⊤}\mathbb N\cup\{\top\}N∪{⊤} of the nonempty finite set

{chainDistanceAt⁡(A,i) chainDistanceAt⁡(B,j−i)  |  i∈Fin⁡(j+1)},\left\{ \operatorname{chainDistanceAt}(A,i)\, \operatorname{chainDistanceAt}(B,j-i) \;\middle|\; i\in\operatorname{Fin}(j+1) \right\},{chainDistanceAt(A,i)chainDistanceAt(B,j−i)∣i∈Fin(j+1)},

where each factor itself is the infimum of the Hamming weights of degree-appropriate kernel words outside the next-boundary image, or ⊤\top⊤ when no such word exists, and multiplication is multiplication in N∪{⊤}\mathbb N\cup\{\top\}N∪{⊤}. Because i<j+1i<j+1i<j+1, one always has i≤ji\le ji≤j, so the natural-number subtraction j−ij-ij−i does not truncate below zero. Both endpoint choices are included: i=0i=0i=0 contributes d0(A)dj(B)d_0(A)d_j(B)d0​(A)dj​(B) and i=ji=ji=j contributes dj(A)d0(B)d_j(A)d_0(B)dj​(A)d0​(B). When j=0j=0j=0, there is exactly one choice, i=0i=0i=0, so the value is exactly d0(A)d0(B)d_0(A)d_0(B)d0​(A)d0​(B); for j>0j>0j>0, the infimum is the minimum of the j+1j+1j+1 displayed values, allowing repeated values and values equal to ⊤\top⊤.

31. oneComplex

For all natural numbers r,cr,cr,c and every Z/2Z\mathbb Z/2\mathbb ZZ/2Z-linear map P:(Fin⁡c→Z/2Z)→(Fin⁡r→Z/2Z)P:(\operatorname{Fin}c\to\mathbb Z/2\mathbb Z)\to(\operatorname{Fin}r\to\mathbb Z/2\mathbb Z)P:(Finc→Z/2Z)→(Finr→Z/2Z), oneComplex P declares a based binary chain complex with dimensions D(0)=rD(0)=rD(0)=r, D(1)=cD(1)=cD(1)=c, and D(i)=0D(i)=0D(i)=0 for every i≥2i\ge2i≥2; boundaries ∂0=0\partial_0=0∂0​=0 into the empty-coordinate word space, ∂1=P\partial_1=P∂1​=P, and ∂i=0\partial_i=0∂i​=0 for every i≥2i\ge2i≥2; and recorded length 111. It supplies proofs that every consecutive composite is zero and that D(i)=0D(i)=0D(i)=0 whenever 1<i1<i1<i. Thus the lower boundary is zero and the incoming boundary ∂2\partial_2∂2​ at the upper end has empty-coordinate domain and is zero. The construction includes r=0r=0r=0 and c=0c=0c=0: if either is zero its corresponding degree has only the empty word, and the recorded length remains 111 even if the degree-one dimension, or both displayed dimensions, is zero.

32. chainDistanceBefore

For every based binary chain complex AAA, chainDistanceBefore A declares a function N→N∪{⊤}\mathbb N\to\mathbb N\cup\{\top\}N→N∪{⊤} with value ⊤\top⊤ at input 000 and, at input j+1j+1j+1, value equal to the infimum of the Hamming weights of all words x:Fin⁡(A.D(j))→Z/2Zx:\operatorname{Fin}(A.D(j))\to\mathbb Z/2\mathbb Zx:Fin(A.D(j))→Z/2Z satisfying ∂jA(x)=0\partial^A_j(x)=0∂jA​(x)=0 and x∉range⁡(∂j+1A)x\notin\operatorname{range}(\partial^A_{j+1})x∈/range(∂j+1A​), again with value ⊤\top⊤ if no such word exists. Thus input 111 returns the degree-zero distance, while input 000 is fixed to ⊤\top⊤ without testing any boundary or word. If AAA has recorded length LLL, input L+1L+1L+1 returns the possibly finite distance in the highest possibly nonempty degree LLL, whereas every input k>L+1k>L+1k>L+1 returns ⊤\top⊤ because degree k−1k-1k−1 has zero dimension and its sole zero word lies in the next-boundary range; when L=0L=0L=0, input 111 is the degree-zero distance and every input above 111 is ⊤\top⊤.

Human review
  • Endorsed by Shuze Chen · Sep 11, 2026

  • Endorsed by Rui Chao · Sep 11, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me