math / data /lean /OAI /LinearAlgebra /MatrixMultiplication /CoppersmithWinograd /CWShapePhysicalPermutation.lean
Download data/lean/OAI/LinearAlgebra/MatrixMultiplication/CoppersmithWinograd/CWShapePhysicalPermutation.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 4.87 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/MatrixMultiplication/CoppersmithWinograd/CWShapePhysicalPermutation.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/LinearAlgebra/MatrixMultiplication/CoppersmithWinograd/CWShapePhysicalPermutation.lean
-
curl -L -o CWShapePhysicalPermutation.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/MatrixMultiplication/CoppersmithWinograd/CWShapePhysicalPermutation.lean
4.87 kB
| import OAI.LinearAlgebra.MatrixMultiplication.CoppersmithWinograd.CWStrands | |
| import OAI.LinearAlgebra.MatrixMultiplication.Tensor.TensorSidePermutation | |
| namespace OAI | |
| /-! CoppersmithβWinograd tensors, tensor powers and local restrictions. -/ | |
| noncomputable section | |
| namespace MatrixMultiplication.CWShapePhysicalPermutation | |
| open MatrixMultiplication.Foundation CWStrands | |
| open scoped BigOperators | |
| variable {F : Type*} [CommRing F] | |
| private theorem tensor_swapXY (q : β) (x y z : Fin (q + 2)) : | |
| FieldCW.tensor F q x y z = FieldCW.tensor F q y x z := by | |
| unfold FieldCW.tensor | |
| simp only [Finset.sum_add_distrib, mul_comm, mul_left_comm, mul_assoc] | |
| ring | |
| private theorem tensor_swapYZ (q : β) (x y z : Fin (q + 2)) : | |
| FieldCW.tensor F q x y z = FieldCW.tensor F q x z y := by | |
| exact (FieldCW.tensor_cyclic F q x y z).trans | |
| ((tensor_swapXY q y z x).trans (FieldCW.tensor_cyclic F q x z y).symm) | |
| private theorem tensor_swapXZ (q : β) (x y z : Fin (q + 2)) : | |
| FieldCW.tensor F q x y z = FieldCW.tensor F q z y x := by | |
| exact (FieldCW.tensor_cyclic F q x y z).trans (tensor_swapXY q y z x) | |
| theorem tensor_permute (q : β) (Ο : Equiv.Perm (Fin 3)) | |
| (a : Fin 3 β Fin (q + 2)) : | |
| FieldCW.tensor F q (a (Ο 0)) (a (Ο 1)) (a (Ο 2)) = | |
| FieldCW.tensor F q (a 0) (a 1) (a 2) := by | |
| have h01 : Ο 0 β Ο 1 := fun h => (by decide : (0 : Fin 3) β 1) (Ο.injective h) | |
| have h02 : Ο 0 β Ο 2 := fun h => (by decide : (0 : Fin 3) β 2) (Ο.injective h) | |
| have h12 : Ο 1 β Ο 2 := fun h => (by decide : (1 : Fin 3) β 2) (Ο.injective h) | |
| generalize hs0 : Ο 0 = s0 at * | |
| generalize hs1 : Ο 1 = s1 at * | |
| generalize hs2 : Ο 2 = s2 at * | |
| fin_cases s0 <;> fin_cases s1 <;> fin_cases s2 <;> try contradiction | |
| Β· rfl | |
| Β· exact (tensor_swapYZ q (a 0) (a 1) (a 2)).symm | |
| Β· exact (tensor_swapXY q (a 0) (a 1) (a 2)).symm | |
| Β· exact (FieldCW.tensor_cyclic F q (a 0) (a 1) (a 2)).symm | |
| Β· exact FieldCW.tensor_cyclic F q (a 2) (a 0) (a 1) | |
| Β· exact (tensor_swapXZ q (a 0) (a 1) (a 2)).symm | |
| theorem strand_permute {P : Type*} [Fintype P] | |
| (Ο : Equiv.Perm (Fin 3)) (a : Fin 3 β P β Fin 7) : | |
| strand (F := F) P (a (Ο 0)) (a (Ο 1)) (a (Ο 2)) = | |
| strand P (a 0) (a 1) (a 2) := by | |
| apply Finset.prod_congr rfl | |
| intro i _ | |
| exact tensor_permute 5 Ο (fun s => a s i) | |
| theorem shapeTensor_permute {P : Type*} [Fintype P] | |
| (Ο : Equiv.Perm (Fin 3)) (g : Fin 3 β β) (a : Fin 3 β P β Fin 7) : | |
| shapeTensor (F := F) P (g β Ο) (a (Ο 0)) (a (Ο 1)) (a (Ο 2)) = | |
| shapeTensor P g (a 0) (a 1) (a 2) := by | |
| have hmask : | |
| (weight (a (Ο 0)) = g (Ο 0) β§ weight (a (Ο 1)) = g (Ο 1) β§ | |
| weight (a (Ο 2)) = g (Ο 2)) β | |
| (weight (a 0) = g 0 β§ weight (a 1) = g 1 β§ weight (a 2) = g 2) := by | |
| constructor | |
| Β· rintro β¨h0, h1, h2β© | |
| have hs (s : Fin 3) : weight (a (Ο s)) = g (Ο s) := by | |
| fin_cases s <;> assumption | |
| exact β¨by simpa using hs (Ο.symm 0), by simpa using hs (Ο.symm 1), | |
| by simpa using hs (Ο.symm 2)β© | |
| Β· rintro β¨h0, h1, h2β© | |
| have hs (s : Fin 3) : weight (a s) = g s := by | |
| fin_cases s <;> assumption | |
| exact β¨hs (Ο 0), hs (Ο 1), hs (Ο 2)β© | |
| have hp := strand_permute (F := F) Ο a | |
| simp only [shapeTensor, Function.comp_apply, hmask, hp] | |
| theorem shapeTensor_prod_permute {I : Type*} [Fintype I] | |
| (P : I β Type*) [β i, Fintype (P i)] | |
| (Ο : I β Equiv.Perm (Fin 3)) (g : I β Fin 3 β β) | |
| (a : β i, Fin 3 β P i β Fin 7) : | |
| (β i, shapeTensor (F := F) (P i) (g i β Ο i) | |
| (a i (Ο i 0)) (a i (Ο i 1)) (a i (Ο i 2))) = | |
| β i, shapeTensor (P i) (g i) (a i 0) (a i 1) (a i 2) := by | |
| apply Finset.prod_congr rfl | |
| intro i _ | |
| exact shapeTensor_permute (Ο i) (g i) (a i) | |
| theorem shapeTensor_prod_permute_ne_zero_iff {I : Type*} [Fintype I] | |
| (P : I β Type*) [β i, Fintype (P i)] | |
| (Ο : I β Equiv.Perm (Fin 3)) (g : I β Fin 3 β β) | |
| (a : β i, Fin 3 β P i β Fin 7) : | |
| (β i, shapeTensor (F := F) (P i) (g i β Ο i) | |
| (a i (Ο i 0)) (a i (Ο i 1)) (a i (Ο i 2))) β 0 β | |
| (β i, shapeTensor (F := F) (P i) (g i) (a i 0) (a i 1) (a i 2)) β 0 := by | |
| rw [shapeTensor_prod_permute] | |
| theorem sidePermutation_shapeTensor {P : Type*} [Fintype P] | |
| (Ο : Equiv.Perm (Fin 3)) (g : Fin 3 β β) : | |
| Tensor.sidePermutation Ο (shapeTensor (F := F) P g) = | |
| shapeTensor P (g β Ο) := by | |
| funext x y z | |
| let a : Fin 3 β P β Fin 7 := ![x, y, z] | |
| change Tensor.sidePermutation Ο (shapeTensor P g) (a 0) (a 1) (a 2) = | |
| shapeTensor P (g β Ο) (a 0) (a 1) (a 2) | |
| rw [Tensor.sidePermutation_apply_coordinates] | |
| have h := shapeTensor_permute (F := F) Ο g (fun s => a (Ο.symm s)) | |
| simpa only [Equiv.symm_apply_apply] using h.symm | |
| end MatrixMultiplication.CWShapePhysicalPermutation | |
| end | |
| end OAI | |