math / data /lean /OAI /LinearAlgebra /MatrixMultiplication /JointExtraction /PopulationCompatibility.lean
Download data/lean/OAI/LinearAlgebra/MatrixMultiplication/JointExtraction/PopulationCompatibility.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 20.4 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/MatrixMultiplication/JointExtraction/PopulationCompatibility.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/LinearAlgebra/MatrixMultiplication/JointExtraction/PopulationCompatibility.lean
-
curl -L -o PopulationCompatibility.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/MatrixMultiplication/JointExtraction/PopulationCompatibility.lean
20.4 kB
| import OAI.LinearAlgebra.MatrixMultiplication.JointExtraction.Population | |
| import OAI.LinearAlgebra.MatrixMultiplication.JointExtraction.Canonicalization | |
| import OAI.LinearAlgebra.MatrixMultiplication.JointExtraction.CompatibilityIncidence | |
| namespace OAI | |
| /-! Joint tensor extraction, compatibility and entropy estimates. -/ | |
| noncomputable section | |
| namespace MatrixMultiplication.JointPopulationCompatibility | |
| open MatrixMultiplication.Foundation JointPopulation JointTypeCounts InheritedMasks | |
| open JointCompatibilityIncidence | |
| open scoped BigOperators | |
| attribute [local instance] Classical.propDecidable | |
| variable {H : Type*} [Fintype H] [DecidableEq H] | |
| (counts : H β Shape β β) | |
| abbrev ClassKey := H Γ Fin 17 | |
| abbrev ClassPos (b : Position counts β Fin 17) (c : ClassKey (H := H)) := | |
| {i : Positions counts c.1 // b β¨c.1, iβ© = c.2} | |
| def classCounts (s : Fin 3) (c : ClassKey (H := H)) (u : Shape) : β := | |
| if shapeSide s u = c.2 then counts c.1 u else 0 | |
| abbrev FixedSideTargets (s : Fin 3) (b : Position counts β Fin 17) := | |
| {e : Target counts // β h i, shapeSide s ((e h).val i) = b β¨h, iβ©} | |
| def candidateEquiv (s : Fin 3) (b : Position counts β Fin 17) : | |
| FixedSideTargets counts s b β | |
| FixedClassWords (ClassPos counts b) (fun _ => Shape) (classCounts counts s) := by | |
| let split : FixedSideTargets counts s b β | |
| (β h, FixedCoarseWords (counts h) (shapeSide s) (fun i => b β¨h, iβ©)) := | |
| { toFun := fun e h => β¨(e.val h).val, (e.val h).property, e.property hβ© | |
| invFun := fun v => | |
| β¨fun h => β¨(v h).val, (v h).property.1β©, fun h => (v h).property.2β© | |
| left_inv := by | |
| intro e | |
| apply Subtype.ext | |
| funext h | |
| apply Subtype.ext | |
| rfl | |
| right_inv := by | |
| intro v | |
| funext h | |
| apply Subtype.ext | |
| rfl } | |
| let perHistory (h : H) := | |
| (fixedCoarseWordsEquiv (counts h) (shapeSide s) (fun i => b β¨h, iβ©)).trans | |
| (conditionalWordsEquiv (fun i : Positions counts h => b β¨h, iβ©) | |
| (fun a u => if shapeSide s u = a then counts h u else 0)) | |
| refine split.trans ((Equiv.piCongrRight perHistory).trans ?_) | |
| exact | |
| { toFun := fun v c => v c.1 c.2 | |
| invFun := fun v h a => v (h, a) | |
| left_inv := by intro v; rfl | |
| right_inv := by | |
| intro v | |
| funext c | |
| rcases c with β¨h, aβ© | |
| rfl } | |
| omit [Fintype H] [DecidableEq H] in | |
| @[simp] theorem candidateEquiv_apply (s : Fin 3) (b : Position counts β Fin 17) | |
| (e : FixedSideTargets counts s b) (c : ClassKey (H := H)) (i : ClassPos counts b c) : | |
| ((candidateEquiv counts s b e) c).val i = (e.val c.1).val i.val := rfl | |
| omit [Fintype H] [DecidableEq H] in | |
| theorem classCounts_size (s : Fin 3) (b : Position counts β Fin 17) | |
| (e : FixedSideTargets counts s b) (c : ClassKey (H := H)) : | |
| Fintype.card (ClassPos counts b c) = β u, classCounts counts s c u := by | |
| calc | |
| Fintype.card (ClassPos counts b c) = | |
| β u, wordPopulation ((candidateEquiv counts s b e) c).val u := | |
| (wordPopulation_sum _).symm | |
| _ = β u, classCounts counts s c u := | |
| Finset.sum_congr rfl fun u _ => ((candidateEquiv counts s b e) c).property u | |
| theorem fixedSideTargets_card (s : Fin 3) (b : Position counts β Fin 17) | |
| (e : FixedSideTargets counts s b) : | |
| Fintype.card (FixedSideTargets counts s b) = | |
| β c : ClassKey (H := H), Nat.multinomial Finset.univ (classCounts counts s c) := by | |
| rw [Fintype.card_congr (candidateEquiv counts s b)] | |
| exact fixedClassWords_card _ _ _ (classCounts_size counts s b e) | |
| def shapeStatisticCount {A : Type*} [Fintype A] [DecidableEq A] | |
| (e : Target counts) (h : H) (u : Shape) (f : Positions counts h β A) (a : A) : β := | |
| wordPopulation (fun i : Class counts e h u => f i.val) a | |
| theorem scaled_count_window {x n p Ο : β} (hn : 0 < n) | |
| (hw : |x / n - p| β€ Ο) : |x - n * p| β€ n * Ο := by | |
| calc | |
| |x - n * p| = |(x / n - p) * n| := by | |
| rw [sub_mul, div_mul_cancelβ _ hn.ne', mul_comm p n] | |
| _ = |x / n - p| * n := by rw [abs_mul, abs_of_pos hn] | |
| _ β€ Ο * n := mul_le_mul_of_nonneg_right hw hn.le | |
| _ = n * Ο := mul_comm _ _ | |
| omit [Fintype H] [DecidableEq H] in | |
| theorem shape_count_window_of_typeWindow {A : Type*} [Fintype A] [DecidableEq A] | |
| (e : Target counts) (h : H) (u : Shape) (f : Positions counts h β A) | |
| (law : A β β) (Ο : β) | |
| (hw : 0 < counts h u β typeWindow law Ο (fun i : Class counts e h u => f i.val)) : | |
| β a, |(shapeStatisticCount counts e h u f a : β) - | |
| (counts h u : β) * law a| β€ (counts h u : β) * Ο := by | |
| intro a | |
| by_cases hn : 0 < counts h u | |
| Β· apply scaled_count_window (Nat.cast_pos.mpr hn) | |
| simpa only [empiricalLaw, class_card, shapeStatisticCount] using hw hn a | |
| Β· have hn0 : counts h u = 0 := Nat.eq_zero_of_not_pos hn | |
| have hc : shapeStatisticCount counts e h u f a = 0 := by | |
| apply Nat.eq_zero_of_le_zero | |
| let forget : {i : Class counts e h u // f i.val = a} β Class counts e h u := | |
| Subtype.val | |
| have hinj : Function.Injective forget := Subtype.val_injective | |
| have hbound := Fintype.card_le_of_injective forget hinj | |
| calc | |
| shapeStatisticCount counts e h u f a β€ Fintype.card (Class counts e h u) := | |
| hbound | |
| _ = 0 := (class_card counts e h u).trans hn0 | |
| simp only [hc, hn0, Nat.cast_zero, zero_mul, sub_zero, abs_zero, le_refl] | |
| theorem jointCount_le_population {P U Z A : Type*} | |
| [Fintype P] [Fintype U] [DecidableEq U] [DecidableEq A] | |
| (w : P β U) (z : P β Z) (part : Z β A) (u : U) (a : A) : | |
| jointCount w z part u a β€ wordPopulation w u := by | |
| exact Fintype.card_le_of_injective | |
| (fun i : {i : P // w i = u β§ part (z i) = a} => | |
| (β¨i.val, i.property.1β© : {i : P // w i = u})) | |
| (fun _ _ h => Subtype.ext | |
| (congrArg (fun j : {i : P // w i = u} => j.val) h)) | |
| omit [Fintype H] [DecidableEq H] in | |
| theorem class_jointCount_eq {A : Type*} [Fintype A] [DecidableEq A] | |
| (s : Fin 3) (b : Position counts β Fin 17) (e : FixedSideTargets counts s b) | |
| (c : ClassKey (H := H)) (u : Shape) (hu : shapeSide s u = c.2) | |
| (f : Positions counts c.1 β A) (a : A) : | |
| jointCount ((candidateEquiv counts s b e) c).val | |
| (fun i => f i.val) id u a = shapeStatisticCount counts (A := A) e.val c.1 u f a := by | |
| let eFiber : {i : ClassPos counts b c // | |
| ((candidateEquiv counts s b e) c).val i = u β§ f i.val = a} β | |
| {i : Class counts e.val c.1 u // f i.val = a} := | |
| { toFun := fun i => β¨β¨i.val.val, by | |
| simpa only [candidateEquiv_apply] using i.property.1β©, i.property.2β© | |
| invFun := fun i => | |
| β¨β¨i.val.val, by | |
| calc | |
| b β¨c.1, i.val.valβ© = shapeSide s ((e.val c.1).val i.val.val) := | |
| (e.property c.1 i.val.val).symm | |
| _ = shapeSide s u := congrArg (shapeSide s) i.val.property | |
| _ = c.2 := huβ©, | |
| by simpa only [candidateEquiv_apply] using i.val.property, i.propertyβ© | |
| left_inv := by | |
| intro i | |
| apply Subtype.ext | |
| apply Subtype.ext | |
| rfl | |
| right_inv := by | |
| intro i | |
| apply Subtype.ext | |
| apply Subtype.ext | |
| rfl } | |
| unfold jointCount shapeStatisticCount wordPopulation | |
| exact Fintype.card_congr eFiber | |
| omit [Fintype H] [DecidableEq H] in | |
| theorem class_jointCount_zero {A : Type*} [DecidableEq A] | |
| (s : Fin 3) (b : Position counts β Fin 17) (e : FixedSideTargets counts s b) | |
| (c : ClassKey (H := H)) (u : Shape) (hu : shapeSide s u β c.2) | |
| (f : ClassPos counts b c β A) (a : A) : | |
| jointCount ((candidateEquiv counts s b e) c).val f id u a = 0 := by | |
| apply Nat.eq_zero_of_le_zero | |
| calc | |
| jointCount ((candidateEquiv counts s b e) c).val f id u a β€ | |
| wordPopulation ((candidateEquiv counts s b e) c).val u := | |
| jointCount_le_population _ _ _ _ _ | |
| _ = classCounts counts s c u := ((candidateEquiv counts s b e) c).property u | |
| _ = 0 := ite_eq_right hu | |
| omit [Fintype H] [DecidableEq H] in | |
| theorem side_compatibility_iff_class_counts | |
| (A : ClassKey (H := H) β Type*) | |
| [β c, Fintype (A c)] [β c, DecidableEq (A c)] | |
| (s : Fin 3) (b : Position counts β Fin 17) (e : FixedSideTargets counts s b) | |
| (f : β h k, Positions counts h β A (h, k)) | |
| (designated : ClassKey (H := H) β Shape β Prop) | |
| (law : β c, Shape β A c β β) (Ο : β) : | |
| (β h u, designated (h, shapeSide s u) u β β a : A (h, shapeSide s u), | |
| |(shapeStatisticCount counts (A := A (h, shapeSide s u)) | |
| e.val h u (f h (shapeSide s u)) a : β) - | |
| (counts h u : β) * law (h, shapeSide s u) u a| β€ (counts h u : β) * Ο) β | |
| (β c u, designated c u β β a : A c, | |
| |(jointCount ((candidateEquiv counts s b e) c).val | |
| (fun i => f c.1 c.2 i.val) id u a : β) - | |
| (classCounts counts s c u : β) * law c u a| β€ | |
| (classCounts counts s c u : β) * Ο) := by | |
| constructor | |
| Β· intro h c u hd a | |
| by_cases hu : shapeSide s u = c.2 | |
| Β· rw [class_jointCount_eq counts s b e c u hu] | |
| rcases c with β¨hβ, kβ© | |
| dsimp at hu | |
| subst k | |
| simpa only [classCounts, ite_eq_left rfl, ite_true] using h hβ u hd a | |
| Β· rw [class_jointCount_zero counts s b e c u hu] | |
| simp only [classCounts, ite_eq_right hu, Nat.cast_zero, zero_mul, sub_zero, abs_zero, le_refl] | |
| Β· intro h hβ u hd a | |
| have hh := h (hβ, shapeSide s u) u hd a | |
| rw [class_jointCount_eq counts s b e (hβ, shapeSide s u) u rfl] at hh | |
| simpa only [classCounts, ite_eq_left rfl, ite_true] using hh | |
| section Statistics | |
| variable (L R : H β Type*) | |
| (SL SR : ClassKey (H := H) β Type*) | |
| [β c, Fintype (SL c)] [β c, DecidableEq (SL c)] | |
| [β c, Fintype (SR c)] [β c, DecidableEq (SR c)] | |
| (leftStatistic : β c, L c.1 β SL c) | |
| (rightStatistic : β c, R c.1 β SR c) | |
| def statisticWord (b : Position counts β Fin 17) | |
| (w : JointCanonicalization.RawPairs counts L R) (c : ClassKey (H := H)) : | |
| ClassPos counts b c β SL c Γ SR c := | |
| fun i => (leftStatistic c (w c.1 i.val).1, rightStatistic c (w c.1 i.val).2) | |
| def statisticCounts (b : Position counts β Fin 17) | |
| (w : JointCanonicalization.RawPairs counts L R) (c : ClassKey (H := H)) : | |
| SL c Γ SR c β β := | |
| wordPopulation (statisticWord counts L R SL SR leftStatistic rightStatistic b w c) | |
| def statisticElement (b : Position counts β Fin 17) | |
| (w : JointCanonicalization.RawPairs counts L R) : | |
| FixedClassWords (ClassPos counts b) (fun c => SL c Γ SR c) | |
| (statisticCounts counts L R SL SR leftStatistic rightStatistic b w) := | |
| fun c => β¨statisticWord counts L R SL SR leftStatistic rightStatistic b w c, fun _ => rflβ© | |
| variable (designatedLeft designatedRight : ClassKey (H := H) β Shape β Prop) | |
| (leftLaw : β c, Shape β SL c β β) (rightLaw : β c, Shape β SR c β β) (Ο : β) | |
| def Compatible (s : Fin 3) (e : Target counts) | |
| (w : JointCanonicalization.RawPairs counts L R) : Prop := | |
| (β h u, designatedLeft (h, shapeSide s u) u β β a, | |
| |(shapeStatisticCount counts e h u | |
| (fun i => leftStatistic (h, shapeSide s u) (w h i).1) a : β) - | |
| (counts h u : β) * leftLaw (h, shapeSide s u) u a| β€ (counts h u : β) * Ο) β§ | |
| (β h u, designatedRight (h, shapeSide s u) u β β a, | |
| |(shapeStatisticCount counts e h u | |
| (fun i => rightStatistic (h, shapeSide s u) (w h i).2) a : β) - | |
| (counts h u : β) * rightLaw (h, shapeSide s u) u a| β€ (counts h u : β) * Ο) | |
| omit [Fintype H] [DecidableEq H] in | |
| theorem compatible_of_designated_windows (s : Fin 3) (e : Target counts) | |
| (w : JointCanonicalization.RawPairs counts L R) | |
| (hl : β h u, 0 < counts h u β designatedLeft (h, shapeSide s u) u β | |
| typeWindow (leftLaw (h, shapeSide s u) u) Ο | |
| (fun i : Class counts e h u => leftStatistic (h, shapeSide s u) (w h i.val).1)) | |
| (hr : β h u, 0 < counts h u β designatedRight (h, shapeSide s u) u β | |
| typeWindow (rightLaw (h, shapeSide s u) u) Ο | |
| (fun i : Class counts e h u => rightStatistic (h, shapeSide s u) (w h i.val).2)) : | |
| Compatible counts L R SL SR leftStatistic rightStatistic designatedLeft designatedRight | |
| leftLaw rightLaw Ο s e w := by | |
| constructor | |
| Β· intro h u hd | |
| exact shape_count_window_of_typeWindow counts e h u _ _ Ο (fun hn => hl h u hn hd) | |
| Β· intro h u hd | |
| exact shape_count_window_of_typeWindow counts e h u _ _ Ο (fun hn => hr h u hn hd) | |
| omit [Fintype H] [DecidableEq H] in | |
| theorem compatible_iff_kernel (s : Fin 3) (b : Position counts β Fin 17) | |
| (e : FixedSideTargets counts s b) (w : JointCanonicalization.RawPairs counts L R) : | |
| Compatible counts L R SL SR leftStatistic rightStatistic designatedLeft designatedRight | |
| leftLaw rightLaw Ο s e.val w β | |
| DesignatedCompatibility (ClassPos counts b) (fun _ => Shape) (fun c => SL c Γ SR c) | |
| SL SR (classCounts counts s) | |
| (statisticCounts counts L R SL SR leftStatistic rightStatistic b w) | |
| (fun _ p => p.1) (fun _ p => p.2) designatedLeft designatedRight leftLaw rightLaw Ο | |
| (candidateEquiv counts s b e) | |
| (statisticElement counts L R SL SR leftStatistic rightStatistic b w) := by | |
| exact and_congr | |
| (side_compatibility_iff_class_counts counts SL s b e | |
| (fun h k i => leftStatistic (h, k) (w h i).1) designatedLeft leftLaw Ο) | |
| (side_compatibility_iff_class_counts counts SR s b e | |
| (fun h k i => rightStatistic (h, k) (w h i).2) designatedRight rightLaw Ο) | |
| def compatibleTargetCount (s : Fin 3) (b : Position counts β Fin 17) | |
| (w : JointCanonicalization.RawPairs counts L R) : β := | |
| Fintype.card {e : FixedSideTargets counts s b // | |
| Compatible counts L R SL SR leftStatistic rightStatistic designatedLeft designatedRight | |
| leftLaw rightLaw Ο s e.val w} | |
| theorem compatibleTargetCount_eq_kernel (s : Fin 3) (b : Position counts β Fin 17) | |
| (w : JointCanonicalization.RawPairs counts L R) : | |
| compatibleTargetCount counts L R SL SR leftStatistic rightStatistic | |
| designatedLeft designatedRight leftLaw rightLaw Ο s b w = | |
| compatibleCandidateCount (ClassPos counts b) (fun _ => Shape) (fun c => SL c Γ SR c) | |
| SL SR (classCounts counts s) | |
| (statisticCounts counts L R SL SR leftStatistic rightStatistic b w) | |
| (fun _ p => p.1) (fun _ p => p.2) designatedLeft designatedRight leftLaw rightLaw Ο | |
| (statisticElement counts L R SL SR leftStatistic rightStatistic b w) := by | |
| exact Fintype.card_congr ((candidateEquiv counts s b).subtypeEquiv | |
| (fun e => compatible_iff_kernel counts L R SL SR leftStatistic rightStatistic | |
| designatedLeft designatedRight leftLaw rightLaw Ο s b e w)) | |
| theorem compatibleTarget_incidence (s : Fin 3) (b : Position counts β Fin 17) | |
| (e : FixedSideTargets counts s b) (w : JointCanonicalization.RawPairs counts L R) : | |
| Fintype.card (FixedSideTargets counts s b) * | |
| compatibleStatisticCount (ClassPos counts b) (fun _ => Shape) (fun c => SL c Γ SR c) | |
| SL SR (classCounts counts s) | |
| (statisticCounts counts L R SL SR leftStatistic rightStatistic b w) | |
| (fun _ p => p.1) (fun _ p => p.2) designatedLeft designatedRight leftLaw rightLaw Ο | |
| (candidateEquiv counts s b e) = | |
| Fintype.card (FixedClassWords (ClassPos counts b) (fun c => SL c Γ SR c) | |
| (statisticCounts counts L R SL SR leftStatistic rightStatistic b w)) * | |
| compatibleTargetCount counts L R SL SR leftStatistic rightStatistic | |
| designatedLeft designatedRight leftLaw rightLaw Ο s b w := by | |
| rw [compatibleTargetCount_eq_kernel, | |
| Fintype.card_congr (candidateEquiv counts s b)] | |
| exact designated_incidence_count _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| (candidateEquiv counts s b e) | |
| (statisticElement counts L R SL SR leftStatistic rightStatistic b w) | |
| def compatibleByTriple (s : Fin 3) | |
| (t : JointCoarseHashing.Triple (Position counts)) | |
| (w : JointCanonicalization.RawPairs counts L R) : Prop := | |
| β e : Target counts, triple counts e = t β§ | |
| Compatible counts L R SL SR leftStatistic rightStatistic designatedLeft designatedRight | |
| leftLaw rightLaw Ο s e w | |
| omit [Fintype H] [DecidableEq H] in | |
| theorem compatibleByTriple_target (s : Fin 3) (e : Target counts) | |
| (w : JointCanonicalization.RawPairs counts L R) : | |
| compatibleByTriple counts L R SL SR leftStatistic rightStatistic | |
| designatedLeft designatedRight leftLaw rightLaw Ο s (triple counts e) w β | |
| Compatible counts L R SL SR leftStatistic rightStatistic designatedLeft designatedRight | |
| leftLaw rightLaw Ο s e w := by | |
| constructor | |
| Β· rintro β¨f, hf, hwβ© | |
| have he : f = e := triple_injective counts hf | |
| subst f | |
| exact hw | |
| Β· intro hw | |
| exact β¨e, rfl, hwβ© | |
| def compatibleWithCoarse | |
| (ownCoarse : JointCanonicalization.RawPairs counts L R β Position counts β Fin 17) | |
| (s : Fin 3) (t : JointCoarseHashing.Triple (Position counts)) | |
| (w : JointCanonicalization.RawPairs counts L R) : Prop := | |
| (β h i, sideWord counts s t h i = ownCoarse w β¨h, iβ©) β§ | |
| compatibleByTriple counts L R SL SR leftStatistic rightStatistic | |
| designatedLeft designatedRight leftLaw rightLaw Ο s t w | |
| omit [Fintype H] [DecidableEq H] in | |
| theorem compatibleWithCoarse_target | |
| (ownCoarse : JointCanonicalization.RawPairs counts L R β Position counts β Fin 17) | |
| (s : Fin 3) (e : Target counts) (w : JointCanonicalization.RawPairs counts L R) : | |
| compatibleWithCoarse counts L R SL SR leftStatistic rightStatistic | |
| designatedLeft designatedRight leftLaw rightLaw Ο ownCoarse s (triple counts e) w β | |
| (β h i, shapeSide s ((e h).val i) = ownCoarse w β¨h, iβ©) β§ | |
| Compatible counts L R SL SR leftStatistic rightStatistic designatedLeft designatedRight | |
| leftLaw rightLaw Ο s e w := by | |
| exact and_congr Iff.rfl (compatibleByTriple_target counts L R SL SR leftStatistic | |
| rightStatistic designatedLeft designatedRight leftLaw rightLaw Ο s e w) | |
| omit [Fintype H] [DecidableEq H] in | |
| theorem compatibleWithCoarse_shares_side | |
| (ownCoarse : JointCanonicalization.RawPairs counts L R β Position counts β Fin 17) | |
| (s : Fin 3) (t t' : JointCoarseHashing.Triple (Position counts)) | |
| (w : JointCanonicalization.RawPairs counts L R) | |
| (ht : compatibleWithCoarse counts L R SL SR leftStatistic rightStatistic | |
| designatedLeft designatedRight leftLaw rightLaw Ο ownCoarse s t w) | |
| (ht' : compatibleWithCoarse counts L R SL SR leftStatistic rightStatistic | |
| designatedLeft designatedRight leftLaw rightLaw Ο ownCoarse s t' w) : | |
| β h, sideWord counts s t h = sideWord counts s t' h := by | |
| intro h | |
| funext i | |
| exact (ht.1 h i).trans (ht'.1 h i).symm | |
| theorem compatibleWithCoarse_target_count | |
| (ownCoarse : JointCanonicalization.RawPairs counts L R β Position counts β Fin 17) | |
| (s : Fin 3) (w : JointCanonicalization.RawPairs counts L R) : | |
| Fintype.card {e : Target counts // | |
| compatibleWithCoarse counts L R SL SR leftStatistic rightStatistic | |
| designatedLeft designatedRight leftLaw rightLaw Ο ownCoarse s (triple counts e) w} = | |
| compatibleTargetCount counts L R SL SR leftStatistic rightStatistic | |
| designatedLeft designatedRight leftLaw rightLaw Ο s (ownCoarse w) w := by | |
| apply Fintype.card_congr | |
| exact (Equiv.subtypeEquivRight (fun e => compatibleWithCoarse_target counts L R SL SR | |
| leftStatistic rightStatistic designatedLeft designatedRight leftLaw rightLaw Ο | |
| ownCoarse s e w)).trans (Equiv.subtypeSubtypeEquivSubtypeInter | |
| (fun e : Target counts => β h i, shapeSide s ((e h).val i) = ownCoarse w β¨h, iβ©) | |
| (fun e => Compatible counts L R SL SR leftStatistic rightStatistic | |
| designatedLeft designatedRight leftLaw rightLaw Ο s e w)).symm | |
| end Statistics | |
| def designatedYLeft (_ : ClassKey (H := H)) (u : Shape) : Prop := | |
| (shapeSide 2 u).val = 0 | |
| def designatedYRight (parentShape : H β Fin 3 β β) | |
| (c : ClassKey (H := H)) (u : Shape) : Prop := | |
| parentShape c.1 2 - (shapeSide 2 u).val = 0 | |
| def designatedZLeft (_ : ClassKey (H := H)) (u : Shape) : Prop := | |
| (shapeSide 0 u).val * (shapeSide 1 u).val = 0 | |
| def designatedZRight (parentShape : H β Fin 3 β β) | |
| (c : ClassKey (H := H)) (u : Shape) : Prop := | |
| (parentShape c.1 0 - (shapeSide 0 u).val) * | |
| (parentShape c.1 1 - (shapeSide 1 u).val) = 0 | |
| end MatrixMultiplication.JointPopulationCompatibility | |
| end | |
| end OAI | |