Documentation

CslibFrontier.Foundations.FieldTheory.Finite.Coordinates

Binary-field arithmetic in coordinates #

A basis over ZMod 2 identifies field elements with bit coordinates. A multiplication table lists the products of basis vectors; fieldMul uses it to multiply arbitrary coordinate lists. These operations are shared by affine dispersers, hardness encodings and small-bias spaces.

Main definitions #

Main results #

noncomputable def Cslib.BinaryField.ofBits {F : Type u_1} [Field F] [Algebra (ZMod 2) F] {ι : Type u_2} [Fintype ι] (b : Module.Basis ι (ZMod 2) F) (v : ι → Bool) :
F

The element of F whose coordinates in the basis b are the bits v j.

noncomputable def Cslib.BinaryField.fieldOfBits {F : Type u_1} [Field F] [Algebra (ZMod 2) F] {n : ℕ} (B : Module.Basis (Fin n) (ZMod 2) F) (a : List Bool) :
F

The field element whose coordinates in the basis B are the first n bits of a; missing bits are zero.

theorem Cslib.BinaryField.repr_fieldOfBits {F : Type u_1} [Field F] [Algebra (ZMod 2) F] {n : ℕ} (B : Module.Basis (Fin n) (ZMod 2) F) (a : List Bool) (u : Fin n) :
@[simp]
theorem Cslib.BinaryField.fieldOfBits_nil {F : Type u_1} [Field F] [Algebra (ZMod 2) F] {n : ℕ} (B : Module.Basis (Fin n) (ZMod 2) F) :
theorem Cslib.BinaryField.fieldOfBits_listXor {F : Type u_1} [Field F] [Algebra (ZMod 2) F] {n : ℕ} (B : Module.Basis (Fin n) (ZMod 2) F) (words : List (List Bool)) :

The coordinates of a sum: listXor adds coordinate words.

The coordinates of the product B u * B w in the multiplication table tab.

Multiplication in coordinates: the coordinates of the product of the elements with coordinates a and b, the sum of the products B u * B w read from the multiplication table tab of the basis, for the bits a u = b w = 1.

def Cslib.BinaryField.IsMulTable {F : Type u_1} [Field F] [Algebra (ZMod 2) F] {n : ℕ} (B : Module.Basis (Fin n) (ZMod 2) F) (tab : List (List (List Bool))) :

A multiplication table of the basis B: tab lists, for u, w < n, the coordinates of the product B u * B w.

theorem Cslib.BinaryField.fieldOfBits_fieldMul {F : Type u_1} [Field F] [Algebra (ZMod 2) F] {n : ℕ} {B : Module.Basis (Fin n) (ZMod 2) F} {tab : List (List (List Bool))} (htab : IsMulTable B tab) (a b : List Bool) :

With a multiplication table of the basis B, fieldMul multiplies: the element with coordinates fieldMul tab a b is the product of those with coordinates a and b.

theorem Cslib.BinaryField.fieldOfBits_foldl_ite {F : Type u_1} [Field F] [Algebra (ZMod 2) F] {n : ℕ} {B : Module.Basis (Fin n) (ZMod 2) F} {tab : List (List (List Bool))} (htab : IsMulTable B tab) {X : Type u_3} (c : X → Prop) [DecidablePred c] (f : X → List Bool) (l : List X) (init : List Bool) :
fieldOfBits B (List.foldl (fun (acc : List Bool) (x : X) => if c x then acc else fieldMul tab acc (f x)) init l) = fieldOfBits B init * (List.map (fun (x : X) => fieldOfBits B (f x)) (List.filter (fun (x : X) => !decide (c x)) l)).prod

A fold of products in coordinates, skipping the elements with c x, multiplies the selected factors.

theorem Cslib.BinaryField.fieldOfBits_foldl_fieldMul {F : Type u_1} [Field F] [Algebra (ZMod 2) F] {n : ℕ} {B : Module.Basis (Fin n) (ZMod 2) F} {tab : List (List (List Bool))} (htab : IsMulTable B tab) {X : Type u_3} (f : X → List Bool) (l : List X) (init : List Bool) :
fieldOfBits B (List.foldl (fun (acc : List Bool) (x : X) => fieldMul tab acc (f x)) init l) = fieldOfBits B init * (List.map (fun (x : X) => fieldOfBits B (f x)) l).prod

A fold of products in coordinates multiplies all the factors.