File size: 5,123 Bytes
4a56cd6 | 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 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | import OAI.LinearAlgebra.MatrixMultiplication.JointExtraction.Extraction
namespace OAI
/-! Joint tensor extraction, compatibility and entropy estimates. -/
noncomputable section
namespace MatrixMultiplication.JointCoarseAssignment
open MatrixMultiplication.Foundation JointExtraction
attribute [local instance] Classical.propDecidable
variable {F X Y Z A B C I V : Type*} [CommSemiring F]
abbrev Triple (A B C : Type*) := A Γ B Γ C
def survives (hx : A β Prop) (hy : B β Prop) (hz : C β Prop)
(e : Triple A B C) : Prop := hx e.1 β§ hy e.2.1 β§ hz e.2.2
def eligible (ambient targets : Finset (Triple A B C))
(hx : A β Prop) (hy : B β Prop) (hz : C β Prop) : Finset (Triple A B C) :=
ambient.filter fun e => e β targets β§ survives hx hy hz e β§
β f β ambient, survives hx hy hz f β f.1 = e.1 β f = e
theorem mem_eligible_iff (ambient targets : Finset (Triple A B C))
(hx : A β Prop) (hy : B β Prop) (hz : C β Prop) (e : Triple A B C) :
e β eligible ambient targets hx hy hz β
e β ambient β§ e β targets β§ survives hx hy hz e β§
β f β ambient, survives hx hy hz f β f.1 = e.1 β f = e := by
simp [eligible]
def assignUseful (eligible : Finset I) (compatible useful : I β V β Prop)
(v : V) : Option I :=
retainAssignment (uniqueAssignment eligible compatible)
(fun v => β i, uniqueAssignment eligible compatible v = some i β§ useful i v) v
theorem assignUseful_spec (eligible : Finset I) (compatible useful : I β V β Prop)
(v : V) (i : I) (h : assignUseful eligible compatible useful v = some i) :
i β eligible β§ compatible i v β§ useful i v β§
β j, j β eligible β compatible j v β j = i := by
classical
have hu : uniqueAssignment eligible compatible v = some i :=
retainAssignment_some _ _ v i h
have hh := uniqueAssignment_spec eligible compatible v i hu
have huse : useful i v := by
unfold assignUseful retainAssignment at h
split_ifs at h with hk
obtain β¨j, hj, hjuβ© := hk
have hji : j = i := Option.some.inj (hj.symm.trans hu)
exact hji βΈ hju
exact β¨hh.1, hh.2.1, huse, hh.2.2β©
def assignments (ambient targets : Finset (Triple A B C))
(hx : A β Prop) (hy : B β Prop) (hz : C β Prop)
(cx : X β A) (cy : Y β B) (cz : Z β C)
(compatibleY : Triple A B C β Y β Prop)
(compatibleZ : Triple A B C β Z β Prop)
(usefulX : Triple A B C β X β Prop)
(usefulY : Triple A B C β Y β Prop)
(usefulZ : Triple A B C β Z β Prop) : Assignment X Y Z (Triple A B C) where
x := assignUseful (eligible ambient targets hx hy hz) (fun e x => cx x = e.1) usefulX
y := assignUseful (eligible ambient targets hx hy hz)
(fun e y => cy y = e.2.1 β§ compatibleY e y) usefulY
z := assignUseful (eligible ambient targets hx hy hz)
(fun e z => cz z = e.2.2 β§ compatibleZ e z) usefulZ
theorem assignments_coherent
(T : Tensor F X Y Z) (ambient targets : Finset (Triple A B C))
(hx : A β Prop) (hy : B β Prop) (hz : C β Prop)
(cx : X β A) (cy : Y β B) (cz : Z β C)
(compatibleY : Triple A B C β Y β Prop)
(compatibleZ : Triple A B C β Z β Prop)
(usefulX : Triple A B C β X β Prop)
(usefulY : Triple A B C β Y β Prop)
(usefulZ : Triple A B C β Z β Prop)
(support : β x y z, T x y z β 0 β (cx x, cy y, cz z) β ambient)
(transferY : β x y z e, T x y z β 0 β (cx x, cy y, cz z) = e β
usefulX e x β compatibleY e y)
(transferZ : β x y z e, T x y z β 0 β (cx x, cy y, cz z) = e β
usefulX e x β usefulY e y β compatibleZ e z) :
Coherent T (assignments ambient targets hx hy hz cx cy cz
compatibleY compatibleZ usefulX usefulY usefulZ) := by
intro x y z i j k hT hxi hyj hzk
have hi := assignUseful_spec (eligible ambient targets hx hy hz)
(fun e x => cx x = e.1) usefulX x i hxi
have hj := assignUseful_spec (eligible ambient targets hx hy hz)
(fun e y => cy y = e.2.1 β§ compatibleY e y) usefulY y j hyj
have hk := assignUseful_spec (eligible ambient targets hx hy hz)
(fun e z => cz z = e.2.2 β§ compatibleZ e z) usefulZ z k hzk
have hie := (mem_eligible_iff ambient targets hx hy hz i).mp hi.1
have hje := (mem_eligible_iff ambient targets hx hy hz j).mp hj.1
have hke := (mem_eligible_iff ambient targets hx hy hz k).mp hk.1
have hs : survives hx hy hz (cx x, cy y, cz z) :=
β¨hi.2.1.symm βΈ hie.2.2.1.1, hj.2.1.1.symm βΈ hje.2.2.1.2.1,
hk.2.1.1.symm βΈ hke.2.2.1.2.2β©
have he : (cx x, cy y, cz z) = i :=
hie.2.2.2 _ (support x y z hT) hs hi.2.1
have hyi : cy y = i.2.1 := congrArg (fun e : Triple A B C => e.2.1) he
have hzi : cz z = i.2.2 := congrArg (fun e : Triple A B C => e.2.2) he
have hij : i = j := hj.2.2.2 i hi.1
β¨hyi, transferY x y z i hT he hi.2.2.1β©
have huy : usefulY i y := hij.symm βΈ hj.2.2.1
have hik : i = k := hk.2.2.2 i hi.1
β¨hzi, transferZ x y z i hT he hi.2.2.1 huyβ©
exact β¨hij, hikβ©
end MatrixMultiplication.JointCoarseAssignment
end
end OAI
|