File size: 1,754 Bytes
cdec422
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import OAI.LinearAlgebra.MatrixMultiplication.JointExtraction.CoarseHashing
import Mathlib.Tactic.FinCases

namespace OAI

/-! Joint tensor extraction, compatibility and entropy estimates. -/

noncomputable section
namespace MatrixMultiplication.JointCoarseReorder
open JointCoarseHashing
open scoped BigOperators
attribute [local instance] Classical.propDecidable

def tripleSide {P : Type*} (s : Fin 3) (t : Triple P) : Word P :=
  ![t.1, t.2.1, t.2.2] s

def reorder {P : Type*} (sigma : Equiv.Perm (Fin 3)) (t : Triple P) : Triple P :=
  (tripleSide (sigma 0) t, tripleSide (sigma 1) t, tripleSide (sigma 2) t)

@[simp] theorem tripleSide_reorder {P : Type*} (sigma : Equiv.Perm (Fin 3))
    (t : Triple P) (s : Fin 3) :
    tripleSide s (reorder sigma t) = tripleSide (sigma s) t := by
  fin_cases s <;> rfl

theorem reorder_injective {P : Type*} (sigma : Equiv.Perm (Fin 3)) :
    Function.Injective (reorder (P := P) sigma) := by
  intro t u h
  have hs (s : Fin 3) : tripleSide s t = tripleSide s u := by
    have hh := congrArg (tripleSide (sigma.symm s)) h
    simpa only [tripleSide_reorder, sigma.apply_symm_apply] using hh
  exact Prod.ext (hs 0) (Prod.ext (hs 1) (hs 2))

theorem reorder_support {P : Type*} (sigma : Equiv.Perm (Fin 3)) (S : P → ℕ)
    (t : Triple P) (ht : HasSupportSum S t) : HasSupportSum S (reorder sigma t) := by
  intro p
  have hsum : (∑ i : Fin 3, (tripleSide (sigma i) t p).val) =
      ∑ i : Fin 3, (tripleSide i t p).val :=
    Equiv.sum_comp sigma (fun i : Fin 3 => (tripleSide i t p).val)
  simpa [reorder, tripleSide, Fin.sum_univ_succ, Nat.add_assoc] using hsum.trans (by
    simpa [tripleSide, Fin.sum_univ_succ, Nat.add_assoc] using ht p)

end MatrixMultiplication.JointCoarseReorder

end

end OAI