Documentation

CslibFrontier.Foundations.Data.Sigma.OneHot

One-hot encodings of dependent functions #

The one-hot encoding of a function g : ∀ d, E d is the family of bits indexed by the pairs ⟨d, e⟩, with bit ⟨d, e⟩ set exactly when g d = e (Pi.oneHot). It is injective (Pi.oneHot_injective), and its range consists of the families with exactly one set bit over each point (Pi.exists_oneHot_eq_iff).

Main definitions #

Main results #

def Pi.oneHot {D : Type u_1} {E : D → Type u_2} [(d : D) → DecidableEq (E d)] (g : (d : D) → E d) (p : (d : D) × E d) :

The one-hot encoding of g: the bit at ⟨d, e⟩ is set exactly when g d = e.

@[simp]
theorem Pi.oneHot_apply {D : Type u_1} {E : D → Type u_2} [(d : D) → DecidableEq (E d)] (g : (d : D) → E d) (d : D) (e : E d) :
oneHot g ⟨d, e⟩ = decide (g d = e)
theorem Pi.oneHot_injective {D : Type u_1} {E : D → Type u_2} [(d : D) → DecidableEq (E d)] :
theorem Pi.exists_oneHot_eq_iff {D : Type u_1} {E : D → Type u_2} [(d : D) → DecidableEq (E d)] (a : (d : D) × E d → Bool) :
(∃ (g : (d : D) → E d), oneHot g = a) ↔ ∀ (d : D), ∃! e : E d, a ⟨d, e⟩ = true

A family of bits is a one-hot encoding exactly when every point has one set bit.