math / data /lean /OAI /LinearAlgebra /MatrixMultiplication /Recovery /PermutationMatchingHalves.lean
Download data/lean/OAI/LinearAlgebra/MatrixMultiplication/Recovery/PermutationMatchingHalves.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 4.53 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/MatrixMultiplication/Recovery/PermutationMatchingHalves.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/LinearAlgebra/MatrixMultiplication/Recovery/PermutationMatchingHalves.lean
-
curl -L -o PermutationMatchingHalves.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/MatrixMultiplication/Recovery/PermutationMatchingHalves.lean
4.53 kB
| import OAI.LinearAlgebra.MatrixMultiplication.Recovery.PermutationMatchingMoments | |
| namespace OAI | |
| /-! Finite orbit symmetries, masks and exact recovery operations. -/ | |
| noncomputable section | |
| namespace MatrixMultiplication.PermutationMatching | |
| open scoped BigOperators | |
| open Classical | |
| variable {P : Type*} [Fintype P] [DecidableEq P] | |
| def twoHalfCount (A B : Finset P) (left right : Equiv.Perm P) : β := | |
| β i : P, if left i β A β§ right i β B then 1 else 0 | |
| theorem twoHalfCount_eq_matchingCount (A B : Finset P) | |
| (left right : Equiv.Perm P) : | |
| twoHalfCount A B left right = | |
| matchingCount A B (left.symm.trans right) := by | |
| classical | |
| unfold twoHalfCount matchingCount membership | |
| calc | |
| _ = β i : P, if i β A β§ right (left.symm i) β B then (1 : β) else 0 := by | |
| simpa only [Equiv.symm_apply_apply] using | |
| Equiv.sum_comp left (fun i => | |
| if i β A β§ right (left.symm i) β B then (1 : β) else 0) | |
| _ = β i : P, if i β A then | |
| (if right (left.symm i) β B then (1 : β) else 0) else 0 := by | |
| apply Finset.sum_congr rfl | |
| intro i _ | |
| split_ifs <;> simp_all | |
| _ = _ := by | |
| simp only [Equiv.trans_apply, Fintype.sum_ite_mem] | |
| apply Finset.sum_congr rfl | |
| intro i _ | |
| apply if_congr <;> rfl | |
| def relativePairEquiv : | |
| (Equiv.Perm P Γ Equiv.Perm P) β (Equiv.Perm P Γ Equiv.Perm P) where | |
| toFun lr := (lr.1, lr.1.symm.trans lr.2) | |
| invFun lq := (lq.1, lq.1.trans lq.2) | |
| left_inv := by | |
| rintro β¨left, rightβ© | |
| dsimp only | |
| apply Prod.ext | |
| Β· rfl | |
| Β· ext i | |
| simp | |
| right_inv := by | |
| rintro β¨left, relativeβ© | |
| dsimp only | |
| apply Prod.ext | |
| Β· rfl | |
| Β· ext i | |
| simp | |
| theorem average_relativePerm (f : Equiv.Perm P β β) : | |
| average (fun lr : Equiv.Perm P Γ Equiv.Perm P => | |
| f (lr.1.symm.trans lr.2)) = average f := by | |
| calc | |
| _ = average (fun lq : Equiv.Perm P Γ Equiv.Perm P => f lq.2) := | |
| average_equiv relativePairEquiv (fun lq => f lq.2) | |
| _ = _ := average_prod_snd f | |
| theorem average_twoHalfCount (A B : Finset P) (f : β β β) : | |
| average (fun lr : Equiv.Perm P Γ Equiv.Perm P => | |
| f (twoHalfCount A B lr.1 lr.2)) = | |
| average (fun p : Equiv.Perm P => f (matchingCount A B p)) := by | |
| simp_rw [twoHalfCount_eq_matchingCount] | |
| exact average_relativePerm (fun p => f (matchingCount A B p)) | |
| theorem twoHalfCount_statisticPositions {X Y S T : Type*} | |
| (leftWord : P β X) (rightWord : P β Y) (sl : X β S) (sr : Y β T) | |
| (s : S) (t : T) (left right : Equiv.Perm P) : | |
| twoHalfCount (statisticPositions leftWord sl s) | |
| (statisticPositions rightWord sr t) left right = | |
| β i : P, if sl (leftWord (left i)) = s β§ sr (rightWord (right i)) = t | |
| then (1 : β) else 0 := by | |
| classical | |
| simp [twoHalfCount, statisticPositions] | |
| section Families | |
| variable {C : Type*} (Q : C β Type*) | |
| def relativeFamily | |
| (left right : β c, Equiv.Perm (Q c)) : β c, Equiv.Perm (Q c) := | |
| fun c => (left c).symm.trans (right c) | |
| def relativeFamilyPairEquiv : | |
| ((β c, Equiv.Perm (Q c)) Γ (β c, Equiv.Perm (Q c))) β | |
| ((β c, Equiv.Perm (Q c)) Γ (β c, Equiv.Perm (Q c))) where | |
| toFun lr := (lr.1, relativeFamily Q lr.1 lr.2) | |
| invFun lq := (lq.1, fun c => (lq.1 c).trans (lq.2 c)) | |
| left_inv := by | |
| rintro β¨left, rightβ© | |
| dsimp only | |
| apply Prod.ext | |
| Β· rfl | |
| Β· funext c | |
| ext i | |
| simp [relativeFamily] | |
| right_inv := by | |
| rintro β¨left, relativeβ© | |
| dsimp only | |
| apply Prod.ext | |
| Β· rfl | |
| Β· funext c | |
| ext i | |
| simp [relativeFamily] | |
| variable [Fintype C] [DecidableEq C] | |
| [β c, Fintype (Q c)] [β c, DecidableEq (Q c)] | |
| theorem average_relativeFamily (f : (β c, Equiv.Perm (Q c)) β β) : | |
| average (fun lr : | |
| (β c, Equiv.Perm (Q c)) Γ (β c, Equiv.Perm (Q c)) => | |
| f (relativeFamily Q lr.1 lr.2)) = average f := by | |
| calc | |
| _ = average (fun lq : | |
| (β c, Equiv.Perm (Q c)) Γ (β c, Equiv.Perm (Q c)) => f lq.2) := | |
| average_equiv (relativeFamilyPairEquiv Q) (fun lq => f lq.2) | |
| _ = _ := average_prod_snd f | |
| omit [DecidableEq C] in | |
| theorem sum_twoHalfCount_eq_matchingCount | |
| (A B : β c, Finset (Q c)) (left right : β c, Equiv.Perm (Q c)) : | |
| (β c, twoHalfCount (A c) (B c) (left c) (right c)) = | |
| β c, matchingCount (A c) (B c) (relativeFamily Q left right c) := by | |
| simp only [twoHalfCount_eq_matchingCount, relativeFamily] | |
| end Families | |
| end MatrixMultiplication.PermutationMatching | |
| end | |
| end OAI | |