Documentation

CslibFrontier.Foundations.LinearAlgebra.Tensor.Party.Basic

Tensors over a finite set of parties, restrictions and covers #

A tensor over a finite set I of parties with entries in K (Cslib.PartyTensor K I) has, for each party p, a finite index set Index p (the leg of p), and an entry for each choice of one index per party. The order-three tensors of bilinear complexity (Cslib.Tensor) have three parties and index types fixed in their type; here there may be any finite set of parties, and the index sets are part of the tensor.

Following Strassen, s is a restriction of t, written s ≤ t, when s arises from t by one linear map on each leg: s x = ∑ y, (∏ p, L p (x p) (y p)) * t y. Restriction is a preorder (PartyTensor.instPreorder) and is compatible with the product, party by party (MulLeftMono, MulRightMono), so mul_le_mul' and gcongr apply to it. s is covered by a finite family b (PartyTensor.CoveredBy) when s is a sum of restrictions of the members of b, one of each (a restriction may be 0).

The constructions are the product s * t (Kronecker product, party by party) and its unit 1, the product prod b of a finite family, the powers t ^ k, the push-forward push π t, which gives the leg j of a tensor over J to the party π j, the unit tensor unit K J r of size r and the wire wire K n p q of dimension n between two parties.

Main definitions #

Main results #

References #

structure Cslib.PartyTensor (K I : Type) :

A tensor over the parties I with entries in K: for each party p a finite index set Index p, and an entry for each choice of one index per party. The zero array is allowed.

  • Index : I → Type

    The index set of the leg of a party.

  • fintype (p : I) : Fintype (self.Index p)
  • decEq (p : I) : DecidableEq (self.Index p)
  • entry : ((p : I) → self.Index p) → K

    The entry at a choice of one index per party.

Instances For

    Constructions #

    def Cslib.PartyTensor.push {K I J : Type} [DecidableEq I] [Fintype J] [DecidableEq J] (π : J → I) (t : PartyTensor K J) :

    The push-forward: the leg j of a tensor over J is given to the party π j. A party may get several legs, or none (then its index set has one element).

    theorem Cslib.PartyTensor.push_entry {K I J : Type} [DecidableEq I] [Fintype J] [DecidableEq J] (π : J → I) (t : PartyTensor K J) (x : (q : I) → (push π t).Index q) :
    (push π t).entry x = t.entry fun (j : J) => x (π j) ⟨j, ⋯⟩
    def Cslib.PartyTensor.withEntry {K I : Type} (t : PartyTensor K I) (v : ((p : I) → t.Index p) → K) :

    The same legs with another array.

    @[simp]
    theorem Cslib.PartyTensor.withEntry_entry {K I : Type} (t : PartyTensor K I) (v : ((p : I) → t.Index p) → K) :
    (t.withEntry v).entry = v
    @[instance_reducible]

    The tensor 1: all legs one-dimensional, the entry 1.

    @[instance_reducible]

    The product (Kronecker product, party by party).

    def Cslib.PartyTensor.prod {K I : Type} [CommSemiring K] {κ : Type} [Fintype κ] [DecidableEq κ] (b : κ → PartyTensor K I) :

    The product of a finite family.

    @[instance_reducible]

    The k-th power, the product of k copies: its indices are k-tuples.

    The unit tensor ⟨r⟩_J of size r: the entry is 1 where all indices agree.

    def Cslib.PartyTensor.wire (K : Type) [CommSemiring K] {I : Type} [DecidableEq I] (n : ℕ) (p q : I) :

    The wire ⟨n⟩_pq of dimension n between the parties p and q.

    @[simp]
    theorem Cslib.PartyTensor.one_entry {K I : Type} [CommSemiring K] (x : (p : I) → Index 1 p) :
    entry 1 x = 1
    theorem Cslib.PartyTensor.mul_entry {K I : Type} [CommSemiring K] (s t : PartyTensor K I) (x : (p : I) → (s * t).Index p) :
    (s * t).entry x = (s.entry fun (p : I) => (x p).1) * t.entry fun (p : I) => (x p).2
    theorem Cslib.PartyTensor.prod_entry {K I : Type} [CommSemiring K] {κ : Type} [Fintype κ] [DecidableEq κ] (b : κ → PartyTensor K I) (x : (p : I) → (prod b).Index p) :
    (prod b).entry x = ∏ k : κ, (b k).entry fun (p : I) => x p k
    theorem Cslib.PartyTensor.unit_entry {K J : Type} [CommSemiring K] [Fintype J] (r : ℕ) (x : J → Fin r) :
    (unit K J r).entry x = if ∀ (i j : J), x i = x j then 1 else 0

    Local maps applied to arrays #

    def Cslib.PartyTensor.localApply {K I : Type} [CommSemiring K] [Fintype I] [DecidableEq I] {α β : I → Type} [(p : I) → Fintype (β p)] (L : (p : I) → α p → β p → K) (f : ((p : I) → β p) → K) (x : (p : I) → α p) :
    K

    One linear map on each leg, as a matrix L p : α p → β p → K, applied to an array f on the index tuples of β.

    theorem Cslib.PartyTensor.localApply_comp {K I : Type} [CommSemiring K] [Fintype I] [DecidableEq I] {α β γ : I → Type} [(p : I) → Fintype (β p)] [(p : I) → Fintype (γ p)] (L : (p : I) → α p → β p → K) (M : (p : I) → β p → γ p → K) (f : ((p : I) → γ p) → K) (x : (p : I) → α p) :
    localApply L (localApply M f) x = localApply (fun (p : I) (a : α p) (c : γ p) => ∑ b : β p, L p a b * M p b c) f x

    Local maps compose.

    theorem Cslib.PartyTensor.localApply_sum {K I : Type} [CommSemiring K] [Fintype I] [DecidableEq I] {α β : I → Type} [(p : I) → Fintype (β p)] {κ : Type} [Fintype κ] (L : (p : I) → α p → β p → K) (f : κ → ((p : I) → β p) → K) (x : (p : I) → α p) :
    localApply L (fun (y : (p : I) → β p) => ∑ k : κ, f k y) x = ∑ k : κ, localApply L (f k) x

    Local maps applied to a sum.

    theorem Cslib.PartyTensor.localApply_mul {K I : Type} [CommSemiring K] [Fintype I] [DecidableEq I] {α β α' β' : I → Type} [(p : I) → Fintype (β p)] [(p : I) → Fintype (β' p)] (L : (p : I) → α p → β p → K) (L' : (p : I) → α' p → β' p → K) (f : ((p : I) → β p) → K) (g : ((p : I) → β' p) → K) (x : (p : I) → α p × α' p) :
    localApply (fun (p : I) (a : α p × α' p) (b : β p × β' p) => L p a.1 b.1 * L' p a.2 b.2) (fun (y : (p : I) → β p × β' p) => (f fun (p : I) => (y p).1) * g fun (p : I) => (y p).2) x = (localApply L f fun (p : I) => (x p).1) * localApply L' g fun (p : I) => (x p).2

    Local maps applied to a product of two arrays.

    theorem Cslib.PartyTensor.localApply_prod {K I : Type} [CommSemiring K] [Fintype I] [DecidableEq I] {κ : Type} [Fintype κ] [DecidableEq κ] {α β : κ → I → Type} [(k : κ) → (p : I) → Fintype (β k p)] (L : (k : κ) → (p : I) → α k p → β k p → K) (f : (k : κ) → ((p : I) → β k p) → K) (x : (p : I) → (k : κ) → α k p) :
    localApply (fun (p : I) (a : (k : κ) → α k p) (b : (k : κ) → β k p) => ∏ k : κ, L k p (a k) (b k)) (fun (y : (p : I) → (k : κ) → β k p) => ∏ k : κ, f k fun (p : I) => y p k) x = ∏ k : κ, localApply (L k) (f k) fun (p : I) => x p k

    Local maps applied to a product of a family of arrays.

    theorem Cslib.PartyTensor.localApply_push {K I J : Type} [CommSemiring K] [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] (π : J → I) {α β : J → Type} [(j : J) → Fintype (β j)] (L : (j : J) → α j → β j → K) (f : ((j : J) → β j) → K) (x : (q : I) → (j : { j : J // π j = q }) → α ↑j) :
    localApply (fun (q : I) (a : (j : { j : J // π j = q }) → α ↑j) (b : (j : { j : J // π j = q }) → β ↑j) => ∏ j : { j : J // π j = q }, L (↑j) (a j) (b j)) (fun (y : (p : I) → (j : { j : J // π j = p }) → β ↑j) => f fun (j : J) => y (π j) ⟨j, ⋯⟩) x = localApply L f fun (j : J) => x (π j) ⟨j, ⋯⟩

    Local maps applied to an array whose legs are sorted by parties.

    theorem Cslib.PartyTensor.localApply_map {K I : Type} [CommSemiring K] [Fintype I] [DecidableEq I] {α β : I → Type} [(p : I) → Fintype (β p)] [(p : I) → DecidableEq (β p)] (w : (p : I) → α p → K) (g : (p : I) → α p → β p) (f : ((p : I) → β p) → K) (x : (p : I) → α p) :
    localApply (fun (p : I) (a : α p) (b : β p) => if b = g p a then w p a else 0) f x = (∏ p : I, w p (x p)) * f fun (p : I) => g p (x p)

    Local maps whose matrices have at most one nonzero entry in each row: the row a of the matrix of p has the entry w p a in the column g p a.

    Restrictions #

    @[instance_reducible]

    s ≤ t: s is a restriction of t, it arises from t by one linear map on each leg.

    theorem Cslib.PartyTensor.le_def {K I : Type} [CommSemiring K] [Fintype I] [DecidableEq I] {s t : PartyTensor K I} :
    s ≤ t ↔ ∃ (L : (p : I) → s.Index p → t.Index p → K), ∀ (x : (p : I) → s.Index p), s.entry x = localApply L t.entry x
    theorem Cslib.PartyTensor.le_of_map {K I : Type} [CommSemiring K] [Fintype I] [DecidableEq I] {s t : PartyTensor K I} (w : (p : I) → s.Index p → K) (g : (p : I) → s.Index p → t.Index p) (h : ∀ (x : (p : I) → s.Index p), s.entry x = (∏ p : I, w p (x p)) * t.entry fun (p : I) => g p (x p)) :
    s ≤ t

    If the entry of s at x is a product of leg-wise factors times the entry of t at g x, where g acts leg by leg, then s is a restriction of t.

    theorem Cslib.PartyTensor.le_of_entry_eq {K I : Type} [CommSemiring K] [Fintype I] [DecidableEq I] {s t : PartyTensor K I} (g : (p : I) → s.Index p → t.Index p) (h : ∀ (x : (p : I) → s.Index p), s.entry x = t.entry fun (p : I) => g p (x p)) :
    s ≤ t

    If the entry of s at x is the entry of t at g x, where g acts leg by leg, then s is a restriction of t.

    @[instance_reducible]

    Restriction is a preorder.

    theorem Cslib.PartyTensor.prod_le_prod {K I : Type} [CommSemiring K] [Fintype I] [DecidableEq I] {κ : Type} [Fintype κ] [DecidableEq κ] {a b : κ → PartyTensor K I} (h : ∀ (k : κ), a k ≤ b k) :

    Products of families of restrictions are restrictions.

    theorem Cslib.PartyTensor.push_le_push {K I J : Type} [CommSemiring K] [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] (π : J → I) {s t : PartyTensor K J} (h : s ≤ t) :
    push π s ≤ push π t

    Restrictions stay restrictions when the legs are given to other parties.

    theorem Cslib.PartyTensor.one_le_of_entry_ne_zero {I : Type} [Fintype I] [DecidableEq I] {K : Type} [Field K] [Nonempty I] {t : PartyTensor K I} {y : (p : I) → t.Index p} (h : t.entry y ≠ 0) :
    1 ≤ t

    1 is a restriction of every tensor with a nonzero entry, if there is a party.

    Covers: sums of restrictions #

    def Cslib.PartyTensor.CoveredBy {K I : Type} [CommSemiring K] [Fintype I] [DecidableEq I] {κ : Type} [Fintype κ] (s : PartyTensor K I) (b : κ → PartyTensor K I) :

    s is covered by the family b: it is a sum of restrictions of its members, one restriction of each b k (which may be 0).

    theorem Cslib.PartyTensor.coveredBy_iff {K I : Type} [CommSemiring K] [Fintype I] [DecidableEq I] {κ : Type} [Fintype κ] {s : PartyTensor K I} {b : κ → PartyTensor K I} :
    s.CoveredBy b ↔ ∃ (v : κ → ((p : I) → s.Index p) → K), (∀ (x : (p : I) → s.Index p), s.entry x = ∑ k : κ, v k x) ∧ ∀ (k : κ), s.withEntry (v k) ≤ b k

    s is covered by the b k if and only if its array is a sum of arrays, the k-th of which is a restriction of b k.

    theorem Cslib.PartyTensor.CoveredBy.withEntry {K I : Type} [CommSemiring K] [Fintype I] [DecidableEq I] {κ : Type} [Fintype κ] (s : PartyTensor K I) (v : κ → ((p : I) → s.Index p) → K) (h : ∀ (x : (p : I) → s.Index p), s.entry x = ∑ k : κ, v k x) :
    s.CoveredBy fun (k : κ) => s.withEntry (v k)

    If the array of s is the sum of the arrays v k, then s is covered by the tensors with these arrays.

    theorem Cslib.PartyTensor.CoveredBy.single {K I : Type} [CommSemiring K] [Fintype I] [DecidableEq I] {s t : PartyTensor K I} (h : s ≤ t) :
    s.CoveredBy fun (x : Unit) => t

    A restriction is covered by a family with one member.

    theorem Cslib.PartyTensor.CoveredBy.of_entry_eq_zero {K I : Type} [CommSemiring K] [Fintype I] [DecidableEq I] {κ : Type} [Fintype κ] [IsEmpty κ] {s : PartyTensor K I} (h : ∀ (x : (p : I) → s.Index p), s.entry x = 0) (b : κ → PartyTensor K I) :

    A tensor whose array is 0 is covered by the empty family.

    theorem Cslib.PartyTensor.CoveredBy.bind {K I : Type} [CommSemiring K] [Fintype I] [DecidableEq I] {κ : Type} [Fintype κ] {μ : κ → Type} [(k : κ) → Fintype (μ k)] {s : PartyTensor K I} {b : κ → PartyTensor K I} {c : (k : κ) → μ k → PartyTensor K I} (h : s.CoveredBy b) (h' : ∀ (k : κ), (b k).CoveredBy (c k)) :
    s.CoveredBy fun (x : (k : κ) × μ k) => c x.fst x.snd

    Covers compose: if s is covered by the b k and each b k by the c k m, then s is covered by all the c k m.

    theorem Cslib.PartyTensor.CoveredBy.of_le {K I : Type} [CommSemiring K] [Fintype I] [DecidableEq I] {κ : Type} [Fintype κ] {s t : PartyTensor K I} {b : κ → PartyTensor K I} (h : s ≤ t) (h' : t.CoveredBy b) :

    A restriction of a covered tensor is covered by the same family.

    theorem Cslib.PartyTensor.CoveredBy.mono {K I : Type} [CommSemiring K] [Fintype I] [DecidableEq I] {κ : Type} [Fintype κ] {s : PartyTensor K I} {b c : κ → PartyTensor K I} (h : s.CoveredBy b) (h' : ∀ (k : κ), b k ≤ c k) :

    Each member of a cover may be replaced by a tensor of which it is a restriction.

    theorem Cslib.PartyTensor.CoveredBy.reindex {K I : Type} [CommSemiring K] [Fintype I] [DecidableEq I] {κ κ' : Type} [Fintype κ] [Fintype κ'] {s : PartyTensor K I} {b : κ → PartyTensor K I} (h : s.CoveredBy b) (e : κ' ≃ κ) :
    s.CoveredBy fun (k : κ') => b (e k)

    The members of a cover may be renamed.

    theorem Cslib.PartyTensor.CoveredBy.mul {K I : Type} [CommSemiring K] [Fintype I] [DecidableEq I] {κ κ' : Type} [Fintype κ] [Fintype κ'] {s t : PartyTensor K I} {b : κ → PartyTensor K I} {c : κ' → PartyTensor K I} (h : s.CoveredBy b) (h' : t.CoveredBy c) :
    (s * t).CoveredBy fun (k : κ × κ') => b k.1 * c k.2

    The product of two covered tensors is covered by the products of two members.

    theorem Cslib.PartyTensor.CoveredBy.push {K I J : Type} [CommSemiring K] [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] {κ : Type} [Fintype κ] (π : J → I) {s : PartyTensor K J} {b : κ → PartyTensor K J} (h : s.CoveredBy b) :
    (PartyTensor.push π s).CoveredBy fun (k : κ) => PartyTensor.push π (b k)

    A cover stays a cover when the legs are given to other parties.