File size: 3,785 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import OAI.LinearAlgebra.MatrixMultiplication.Completion.HierarchyWords
import OAI.LinearAlgebra.MatrixMultiplication.Completion.Labels

namespace OAI

/-! Readable tensor completion and its finite arithmetic realization. -/

noncomputable section

namespace MatrixMultiplication.CompletionHierarchyWords

open MatrixMultiplication.Foundation

universe u v p q

variable {A : Type u}

namespace ReadableHierarchy

open RecursiveCompletion CompletionLabels.TopologicalFlatten

def ofProgram {Coord : Color → Type v} {Context : Type q} {Code : Type p}
    [Fintype Code] {depth : ℕ} (s : Program A Coord Context Code depth)
    (ctx : Context) (hctx : ∀ a, s.context a = ctx)
    (joint : Function.Injective (fun a => (s.view .B a, s.view .C a, s.view .A a))) :
    ReadableHierarchy A (Coord .B) (Coord .C) (Coord .A) where
  Label := fun _ => Code
  fintypeLabel := fun _ => inferInstance
  labels := s.labels
  depth := depth
  pair := s.pair
  x := s.view .B
  y := s.view .C
  z := s.view .A
  coordinates_injective := joint
  readXYX n _ prior own := s.read n .B ctx (Program.recordArray n prior) own
  readXYY n _ prior own := s.read n .C ctx (Program.recordArray n prior) own
  readXZX n _ prior own := s.read n .B ctx (Program.recordArray n prior) own
  readXZZ n _ prior own := s.read n .A ctx (Program.recordArray n prior) own
  readYZY n _ prior own := s.read n .C ctx (Program.recordArray n prior) own
  readYZZ n _ prior own := s.read n .A ctx (Program.recordArray n prior) own
  readXYX_readable n hn hp a := by
    change s.read n .B ctx (Program.recordArray n (labelRecordOf s.labels n a))
      (s.view .B a) = s.labels n a
    rw [Program.recordArray_labelRecordOf, ← hctx a]
    exact s.readable n hn a .B (Or.inl (by simp only [hp, firstSide]))
  readXYY_readable n hn hp a := by
    change s.read n .C ctx (Program.recordArray n (labelRecordOf s.labels n a))
      (s.view .C a) = s.labels n a
    rw [Program.recordArray_labelRecordOf, ← hctx a]
    exact s.readable n hn a .C (Or.inr (by simp only [hp, secondSide]))
  readXZX_readable n hn hp a := by
    change s.read n .B ctx (Program.recordArray n (labelRecordOf s.labels n a))
      (s.view .B a) = s.labels n a
    rw [Program.recordArray_labelRecordOf, ← hctx a]
    exact s.readable n hn a .B (Or.inl (by simp only [hp, firstSide]))
  readXZZ_readable n hn hp a := by
    change s.read n .A ctx (Program.recordArray n (labelRecordOf s.labels n a))
      (s.view .A a) = s.labels n a
    rw [Program.recordArray_labelRecordOf, ← hctx a]
    exact s.readable n hn a .A (Or.inr (by simp only [hp, secondSide]))
  readYZY_readable n hn hp a := by
    change s.read n .C ctx (Program.recordArray n (labelRecordOf s.labels n a))
      (s.view .C a) = s.labels n a
    rw [Program.recordArray_labelRecordOf, ← hctx a]
    exact s.readable n hn a .C (Or.inl (by simp only [hp, firstSide]))
  readYZZ_readable n hn hp a := by
    change s.read n .A ctx (Program.recordArray n (labelRecordOf s.labels n a))
      (s.view .A a) = s.labels n a
    rw [Program.recordArray_labelRecordOf, ← hctx a]
    exact s.readable n hn a .A (Or.inr (by simp only [hp, secondSide]))

theorem ofProgram_complete {Coord : Color → Type v} {Context : Type q} {Code : Type p}
    [Fintype Code] {depth : ℕ} (s : Program A Coord Context Code depth)
    (ctx : Context) (hctx : ∀ a, s.context a = ctx)
    (joint : Function.Injective (fun a => (s.view .B a, s.view .C a, s.view .A a)))
    (complete : s.Complete) :
    Function.Injective (labelRecordOf (ofProgram s ctx hctx joint).labels depth) := by
  intro a b h
  apply complete a b ((hctx a).trans (hctx b).symm)
  intro n hn
  exact label_eq_of_record_eq s.labels h hn

end ReadableHierarchy

end MatrixMultiplication.CompletionHierarchyWords

end

end OAI