File size: 3,615 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 | import Mathlib
import OAI.LinearAlgebra.MatrixFields.Tensors.TerminalRelabel
namespace OAI
namespace MatrixAllFields
open scoped BigOperators Topology Polynomial
section
open scoped BigOperators
open MatrixMultiplication.Foundation
namespace MatrixMultiplication.CommonDimensions
variable {K H : Type*} [CommSemiring K] [Fintype H] [DecidableEq H]
def familyProduct {X Y Z : H β Type*} (T : β h, Tensor K (X h) (Y h) (Z h)) :
Tensor K (β h, X h) (β h, Y h) (β h, Z h) :=
fun x y z => β h, T h (x h) (y h) (z h)
def pairWords (A B : H β Type*) :
((β h, A h) Γ (β h, B h)) β (β h, A h Γ B h) where
toFun x h := (x.1 h, x.2 h)
invFun x := (fun h => (x h).1, fun h => (x h).2)
left_inv _ := rfl
right_inv _ := rfl
omit [DecidableEq H] in
theorem matrix_familyProduct (A B C : H β Type*)
[β h, DecidableEq (A h)] [β h, DecidableEq (B h)] [β h, DecidableEq (C h)] :
Tensor.pullback (pairWords A B) (pairWords B C) (pairWords C A)
(familyProduct (fun h => Tensor.matrixCoefficients (K := K) (A h) (B h) (C h))) =
Tensor.matrixCoefficients (β h, A h) (β h, B h) (β h, C h) := by
classical
funext x y z
simp only [Tensor.pullback, pairWords, familyProduct, Tensor.matrixCoefficients,
Equiv.coe_fn_mk]
by_cases matched : x.2 = y.1 β§ y.2 = z.1 β§ z.2 = x.1
Β· simp [matched.1, matched.2.1, matched.2.2]
Β· have mismatch : Β¬ β index : H,
x.2 index = y.1 index β§ y.2 index = z.1 index β§ z.2 index = x.1 index := by
intro pointwise
exact matched β¨funext (fun index => (pointwise index).1),
funext (fun index => (pointwise index).2.1),
funext (fun index => (pointwise index).2.2)β©
obtain β¨index, mismatchβ© := not_forall.mp mismatch
simp only [matched, ite_false]
apply Finset.prod_eq_zero (Finset.mem_univ index)
simp only [mismatch, ite_false]
theorem matrix_familyProduct_restrict (A B C : H β Type*)
[β h, Fintype (A h)] [β h, Fintype (B h)] [β h, Fintype (C h)]
[β h, DecidableEq (A h)] [β h, DecidableEq (B h)] [β h, DecidableEq (C h)] :
β (a : ((β h, A h) Γ (β h, B h)) β (β h, A h Γ B h) β K)
(b : ((β h, B h) Γ (β h, C h)) β (β h, B h Γ C h) β K)
(c : ((β h, C h) Γ (β h, A h)) β (β h, C h Γ A h) β K),
Tensor.restrict a b c
(familyProduct (fun h => Tensor.matrixCoefficients (K := K) (A h) (B h) (C h))) =
Tensor.matrixCoefficients (β h, A h) (β h, B h) (β h, C h) := by
classical
refine β¨(fun x s => if s = pairWords A B x then 1 else 0),
(fun y s => if s = pairWords B C y then 1 else 0),
(fun z s => if s = pairWords C A z then 1 else 0), ?_β©
rw [β Tensor.pullback_eq_restrict]
exact matrix_familyProduct A B C
theorem dimension_card (a : H β β) :
Fintype.card (β h, Fin (a h)) = β h, a h := by simp
theorem volume_card (a b c : H β β) :
Fintype.card (β h, Fin (a h)) * Fintype.card (β h, Fin (b h)) *
Fintype.card (β h, Fin (c h)) = β h, a h * b h * c h := by
simp [Finset.prod_mul_distrib]
theorem common_oriented_dimensions {S : Type*}
(a b c : S β H β β) (aβ bβ cβ : H β β)
(ha : β s h, a s h = aβ h) (hb : β s h, b s h = bβ h)
(hc : β s h, c s h = cβ h) (s : S) :
(Fintype.card (β h, Fin (a s h)), Fintype.card (β h, Fin (b s h)),
Fintype.card (β h, Fin (c s h))) =
(β h, aβ h, β h, bβ h, β h, cβ h) := by
simp [ha, hb, hc]
end MatrixMultiplication.CommonDimensions
end
end MatrixAllFields
end OAI
|