Basic properties of holors
Holors are indexed collections of tensor coefficients. Confusingly, they are often called tensors in physics and in the neural network community.
A holor is simply a multidimensional array of values. The size of a
holor is specified by a list ℕ
, whose length is called the dimension
of the holor.
The tensor product of x₁ : holor α ds₁
and x₂ : holor α ds₂
is the
holor given by (x₁ ⊗ x₂) (i₁ ++ i₂) = x₁ i₁ * x₂ i₂
. A holor is "of
rank at most 1" if it is a tensor product of one-dimensional holors.
The CP rank of a holor x
is the smallest N such that x
is the sum
of N holors of rank at most 1.
Based on the tensor library found in https://www.isa-afp.org/entries/Deep_Learning.html
References
holor_index ds
is the type of valid index tuples to identify an entry of a holor of dimensions ds
Equations
- holor_index ds = {is // list.forall₂ has_lt.lt is ds}
Equations
- holor_index.assoc_right = cast holor_index.assoc_right._proof_1
Equations
- holor_index.assoc_left = cast holor_index.assoc_left._proof_1
Equations
- holor.inhabited = {default := λ (t : holor_index ds), inhabited.default α}
Equations
- holor.has_zero = {zero := λ (t : holor_index ds), 0}
Equations
- holor.has_add = {add := λ (x y : holor α ds) (t : holor_index ds), x t + y t}
Equations
- holor.has_neg = {neg := λ (a : holor α ds) (t : holor_index ds), -a t}
Equations
- holor.add_semigroup = {add := λ (a a_1 : holor α ds), id (λ (a_2 : holor_index ds), add_semigroup.add (a a_2) (a_1 a_2)), add_assoc := _}
Equations
- holor.add_comm_semigroup = {add := λ (a a_1 : holor α ds), id (λ (a_2 : holor_index ds), add_comm_semigroup.add (a a_2) (a_1 a_2)), add_assoc := _, add_comm := _}
Equations
- holor.add_monoid = {add := λ (a a_1 : holor α ds), id (λ (a_2 : holor_index ds), add_monoid.add (a a_2) (a_1 a_2)), add_assoc := _, zero := id (λ (a : holor_index ds), add_monoid.zero), zero_add := _, add_zero := _}
Equations
- holor.add_comm_monoid = {add := λ (a a_1 : holor α ds), id (λ (a_2 : holor_index ds), add_comm_monoid.add (a a_2) (a_1 a_2)), add_assoc := _, zero := id (λ (a : holor_index ds), add_comm_monoid.zero), zero_add := _, add_zero := _, add_comm := _}
Equations
- holor.add_group = {add := λ (a a_1 : holor α ds), id (λ (a_2 : holor_index ds), add_group.add (a a_2) (a_1 a_2)), add_assoc := _, zero := id (λ (a : holor_index ds), add_group.zero), zero_add := _, add_zero := _, neg := λ (a : holor α ds), id (λ (a_1 : holor_index ds), add_group.neg (a a_1)), add_left_neg := _}
Equations
- holor.add_comm_group = {add := λ (a a_1 : holor α ds), id (λ (a_2 : holor_index ds), add_comm_group.add (a a_2) (a_1 a_2)), add_assoc := _, zero := id (λ (a : holor_index ds), add_comm_group.zero), zero_add := _, add_zero := _, neg := λ (a : holor α ds), id (λ (a_1 : holor_index ds), add_comm_group.neg (a a_1)), add_left_neg := _, add_comm := _}
Equations
- holor.has_scalar = {smul := λ (a : α) (x : holor α ds) (t : holor_index ds), a * x t}
Equations
- holor.semimodule = pi.semimodule (holor_index ds) (λ (a : holor_index ds), α) α
The 1-dimensional "unit" holor with 1 in the j
th position.
Equations
- holor.unit_vec d j = λ (ti : holor_index [d]), ite (ti.val = [j]) 1 0
The original holor can be recovered from its slices by multiplying with unit vectors and summing up.
- nil : ∀ {α : Type} [_inst_1 : has_mul α] (x : holor α list.nil), x.cprank_max1
- cons : ∀ {α : Type} [_inst_1 : has_mul α] {d : ℕ} {ds : list ℕ} (x : holor α [d]) (y : holor α ds), y.cprank_max1 → (x.mul y).cprank_max1
cprank_max1 x
means x
has CP rank at most 1, that is,
it is the tensor product of 1-dimensional holors.
- zero : ∀ {α : Type} [_inst_1 : has_mul α] [_inst_2 : add_monoid α] {ds : list ℕ}, holor.cprank_max 0 0
- succ : ∀ {α : Type} [_inst_1 : has_mul α] [_inst_2 : add_monoid α] (n : ℕ) {ds : list ℕ} (x y : holor α ds), x.cprank_max1 → holor.cprank_max n y → holor.cprank_max (n + 1) (x + y)
cprank_max N x
means x
has CP rank at most N
, that is,
it can be written as the sum of N holors of rank at most 1.