Hamming spaces #
The Hamming metric counts the number of places two members of a (finite) Pi type differ. The Hamming norm is the same as the Hamming metric over additive groups, and counts the number of places a member of a (finite) Pi type differs from zero.
This is a useful notion in various applications, but in particular it is relevant in coding theory, in which it is fundamental for defining the minimum distance of a code.
Main definitions #
hammingDist x y
: the Hamming distance betweenx
andy
, the number of entries which differ.hammingNorm x
: the Hamming norm ofx
, the number of non-zero entries.Hamming β
: a type synonym forΠ i, β i
withdist
andnorm
provided by the above.Hamming.toHamming
,Hamming.ofHamming
: functions for casting betweenHamming β
andΠ i, β i
.- the Hamming norm forms a normed group on
Hamming β
.
The Hamming distance function to the naturals.
Equations
- hammingDist x y = (Finset.filter (fun (i : ι) => x i ≠ y i) Finset.univ).card
Instances For
Corresponds to dist_self
.
Corresponds to dist_nonneg
.
Corresponds to dist_comm
.
Corresponds to dist_triangle
.
Corresponds to dist_triangle_left
.
Corresponds to dist_triangle_right
.
Corresponds to swap_dist
.
Corresponds to eq_of_dist_eq_zero
.
Corresponds to dist_eq_zero
.
Corresponds to zero_eq_dist
.
Corresponds to dist_ne_zero
.
Corresponds to dist_pos
.
Corresponds to dist_smul
with the discrete norm on α
.
The Hamming weight function to the naturals.
Equations
- hammingNorm x = (Finset.filter (fun (x_1 : ι) => x x_1 ≠ 0) Finset.univ).card
Instances For
Corresponds to dist_zero_right
.
Corresponds to dist_zero_left
.
Corresponds to norm_nonneg
.
Corresponds to norm_zero
.
Corresponds to norm_eq_zero
.
Corresponds to norm_ne_zero_iff
.
Corresponds to norm_pos_iff
.
Corresponds to dist_eq_norm
.
Type synonym for a Pi type which inherits the usual algebraic instances, but is equipped with
the Hamming metric and norm, instead of Pi.normedAddCommGroup
which uses the sup norm.
Instances For
Instances inherited from normal Pi types.
Equations
- Hamming.instFintypeHamming = Pi.fintype
Equations
- (_ : Nontrivial (Hamming β)) = (_ : Nontrivial ((i : ι) → β i))
Equations
- Hamming.instDecidableEqHamming = Fintype.decidablePiFintype
Equations
- Hamming.instSMulWithZeroHammingInstZeroHamming = Pi.smulWithZero α
Equations
- Hamming.instAddCommMonoidHamming = Pi.addCommMonoid
Equations
- Hamming.instAddCommGroupHamming = Pi.addCommGroup
Equations
- Hamming.instModuleHammingInstAddCommMonoidHamming α β = Pi.module ι (fun (i : ι) => β i) α
API to/from the type synonym.
Hamming.toHamming
is the identity function to the Hamming
of a type.
Equations
- Hamming.toHamming = Equiv.refl ((i : ι) → β i)
Instances For
Hamming.ofHamming
is the identity function from the Hamming
of a type.
Equations
- Hamming.ofHamming = Equiv.refl (Hamming β)
Instances For
Instances equipping Hamming
with hammingNorm
and hammingDist
.
Equations
- Hamming.instDistHamming = { dist := fun (x y : Hamming β) => ↑(hammingDist (Hamming.ofHamming x) (Hamming.ofHamming y)) }
Equations
- One or more equations did not get rendered due to their size.
Equations
- (_ : DiscreteTopology (Hamming β)) = (_ : DiscreteTopology (Hamming β))
Equations
- Hamming.instMetricSpaceHamming = MetricSpace.ofT0PseudoMetricSpace (Hamming β)
Equations
- Hamming.instNormHamming = { norm := fun (x : Hamming β) => ↑(hammingNorm (Hamming.ofHamming x)) }
Equations
- Hamming.instNormedAddCommGroupHamming = NormedAddCommGroup.mk