AFTD Auto-Formalizing Theoretical Domains

CodingTheory.Johnson.hdist

defimported Lean

For binary words $x,y$ of length $n$, the Hamming distance is the number of coordinates on which they differ: $\mathrm{hdist}(x,y) = \abs{\{\, i : x_i \neq y_i \,\}}$.

Statement

set_option autoImplicit true in
set_option relaxedAutoImplicit true in
open scoped BigOperators RealInnerProductSpace in
open Finset in
noncomputable def CodingTheory.Johnson.hdist {n : ℕ} (x y : BitVec n) : ℕ
Defined in
TCSlib, `CodingTheory.Johnson.hdist`
Lean proof
By Allan Li, Frederick Dehmel, 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.
Verified
07 Oct 2026
Axioms
none listed
Built on 1
Used by 4

Lean source view module on GitHub

set_option autoImplicit true in
set_option relaxedAutoImplicit true in
open scoped BigOperators RealInnerProductSpace in
open Finset in
noncomputable def CodingTheory.Johnson.hdist {n : ℕ} (x y : BitVec n) : ℕ :=
  (Finset.univ.filter (fun i => x i ≠ y i)).card
See it in the graphDiscuss this resultChallenge it