ErrorCorrectingCodes.Codeword.weight
defimported Lean
The Hamming weight of $c$ is $d(c, \mathbf{0})$.
Statement
set_option autoImplicit true in set_option relaxedAutoImplicit true in set_option linter.unusedSectionVars false in open Set Filter Asymptotics Finset in variable {α : Type*} [Fintype α] [Nonempty α] [DecidableEq α] [Field α] in variable {n k : ℕ} in def ErrorCorrectingCodes.Codeword.weight (c : Codeword n α) : ℕ
- Defined in
- TCSlib, `ErrorCorrectingCodes.Codeword.weight`
- Lean proof
- By Allan Li, Hydroxyi (from the file's git history), from github.com/Shilun-Allan-Li/tcslib at
c8a02591b1e5(Apache-2.0). Compiled here against leanprover/lean4:v4.33.1, Mathlib v4.33.1; written for leanprover/lean4:v4.25.0.ErrorCorrectingCodes.Codeword.weight← ErrorCorrectingCodes.Codeword.weight (TCSlib/ErrorCorrectingCodes/Basic.lean:150): verbatim
- Verified
- 07 Oct 2026
- Axioms
- none listed
- Built on 3
- ErrorCorrectingCodes.Codeword.hamming_distanceHamming distance between two codewords, wrapping Mathlib's
hammingDist. - ErrorCorrectingCodes.CodewordA codeword of length $n$ over alphabet $\alpha$ is a function $c : \mathrm{Fin}\,n \to \alpha$.
- ErrorCorrectingCodes.Codeword.zeroPointwise addition, subtraction, and the all-zero codeword.
- ErrorCorrectingCodes.Codeword.hamming_distanceHamming distance between two codewords, wrapping Mathlib's
- Used by 3
- ErrorCorrectingCodes.Codeword.prob_leq_ball_sizeWeight distribution of a random linear image is dominated by a Hamming ball. Let $\alpha$ be a finite field, let $n$ and $k \ge 1$ be…
- ErrorCorrectingCodes.Codeword.existence_boundExistence bound via union bound. Let $\alpha$ be a finite nonempty field, let $n$ and $k$ be natural numbers with $k \ge 1$, and let $d$…
- ErrorCorrectingCodes.Codeword.gv_boundGilbert–Varshamov bound for linear codes. Let $\alpha$ be a finite field with $q = \abs{\alpha}$ elements, and let $n, k, d$ be natural…
Lean source view module on GitHub
set_option autoImplicit true in set_option relaxedAutoImplicit true in set_option linter.unusedSectionVars false in open Set Filter Asymptotics Finset in variable {α : Type*} [Fintype α] [Nonempty α] [DecidableEq α] [Field α] in variable {n k : ℕ} in /-- The Hamming weight of a codeword: its distance from the all-zeros word. -/ def ErrorCorrectingCodes.Codeword.weight (c : Codeword n α) : ℕ := hamming_distance c zero