Download data/lean/OAI/LinearAlgebra/MatrixFields/Histories/GroupOrbitCount.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 52 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/MatrixFields/Histories/GroupOrbitCount.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/LinearAlgebra/MatrixFields/Histories/GroupOrbitCount.lean
-
curl -L -o GroupOrbitCount.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/MatrixFields/Histories/GroupOrbitCount.lean
52 kB
import Mathlib
import OAI.LinearAlgebra.MatrixFields.Histories.HistoryPositions
import OAI.LinearAlgebra.MatrixFields.Tensors.CWStageCStatistics
namespace OAI
namespace MatrixAllFields
open scoped BigOperators Topology Polynomial
section
noncomputable section
namespace MatrixMultiplication.RecoverySupport
variable {K X Y Z : Type*} [Zero K] [Fintype X] [Fintype Y] [Fintype Z]
def support (Q : X β Y β Z β K) : Finset (X Γ Y Γ Z) := by
classical
exact Finset.univ.filter fun p => Q p.1 p.2.1 p.2.2 β 0
theorem support_card_le (Q : X β Y β Z β K) :
(support Q).card β€ Fintype.card X * Fintype.card Y * Fintype.card Z := by
classical
have h := Finset.card_filter_le (s := (Finset.univ : Finset (X Γ Y Γ Z)))
(p := fun p => Q p.1 p.2.1 p.2.2 β 0)
simpa only [support, Finset.card_univ, Fintype.card_prod, Nat.mul_assoc] using h
theorem support_card_le_exp (Q : X β Y β Z β K) {bX bY bZ : β} (N : β)
(hX : (Fintype.card X : β) β€ Real.exp (bX * N))
(hY : (Fintype.card Y : β) β€ Real.exp (bY * N))
(hZ : (Fintype.card Z : β) β€ Real.exp (bZ * N)) :
((support Q).card : β) β€ Real.exp ((bX + bY + bZ) * N) := by
have hcard : ((support Q).card : β) β€
(Fintype.card X : β) * Fintype.card Y * Fintype.card Z := by
exact_mod_cast support_card_le Q
calc
((support Q).card : β) β€
(Fintype.card X : β) * Fintype.card Y * Fintype.card Z := hcard
_ β€ (Real.exp (bX * N) * Real.exp (bY * N)) * Real.exp (bZ * N) :=
mul_le_mul (mul_le_mul hX hY (Nat.cast_nonneg _) (Real.exp_pos _).le)
hZ (Nat.cast_nonneg _) (mul_nonneg (Real.exp_pos _).le (Real.exp_pos _).le)
_ = Real.exp ((bX + bY + bZ) * N) := by
rw [β Real.exp_add, β Real.exp_add]
congr 1
ring
theorem word_card_eq_exp {d : β} (hd : 0 < d) (a N : β) :
(Fintype.card (Fin (a * N) β Fin d) : β) =
Real.exp (((a : β) * Real.log (d : β)) * N) := by
have hdr : 0 < (d : β) := by exact_mod_cast hd
simp only [Fintype.card_fun, Fintype.card_fin, Nat.cast_pow]
calc
(d : β) ^ (a * N) = Real.exp (((a * N : β) : β) * Real.log (d : β)) := by
rw [Real.exp_nat_mul, Real.exp_log hdr]
_ = Real.exp (((a : β) * Real.log (d : β)) * N) := by
simp only [Nat.cast_mul]
congr 1
ring
theorem card_le_exp_of_word_embedding {d : β} (hd : 0 < d) (a N : β)
(e : X βͺ (Fin (a * N) β Fin d)) :
(Fintype.card X : β) β€ Real.exp (((a : β) * Real.log (d : β)) * N) := by
rw [β word_card_eq_exp hd a N]
exact_mod_cast Fintype.card_le_of_injective e e.injective
theorem support_card_le_exp_of_word_embeddings (Q : X β Y β Z β K)
{d : β} (hd : 0 < d) (a N : β)
(ex : X βͺ (Fin (a * N) β Fin d))
(ey : Y βͺ (Fin (a * N) β Fin d))
(ez : Z βͺ (Fin (a * N) β Fin d)) :
((support Q).card : β) β€ Real.exp ((3 * (a : β) * Real.log (d : β)) * N) := by
have h := support_card_le_exp Q N
(card_le_exp_of_word_embedding hd a N ex)
(card_le_exp_of_word_embedding hd a N ey)
(card_le_exp_of_word_embedding hd a N ez)
convert h using 1
congr 1
ring
def cw5SupportRate (a : β) : β := 3 * (a : β) * Real.log 7 + 1
theorem cw5SupportRate_pos (a : β) : 0 < cw5SupportRate a := by
have hlog : 0 β€ Real.log 7 := Real.log_nonneg (by norm_num)
have h := mul_nonneg (mul_nonneg (by norm_num : (0 : β) β€ 3) (Nat.cast_nonneg a)) hlog
unfold cw5SupportRate
linarith
theorem cw5_support_card_le_exp (Q : X β Y β Z β K) (a N : β)
(ex : X βͺ (Fin (a * N) β Fin 7))
(ey : Y βͺ (Fin (a * N) β Fin 7))
(ez : Z βͺ (Fin (a * N) β Fin 7)) :
((support Q).card : β) β€ Real.exp (cw5SupportRate a * N) := by
apply (support_card_le_exp_of_word_embeddings Q (by norm_num) a N ex ey ez).trans
apply Real.exp_le_exp.mpr
unfold cw5SupportRate
simp only [Nat.cast_ofNat]
exact mul_le_mul_of_nonneg_right (le_add_of_nonneg_right zero_le_one) (Nat.cast_nonneg N)
end MatrixMultiplication.RecoverySupport
end
end
end MatrixAllFields
namespace MatrixAllFields
open scoped BigOperators Topology Polynomial
section
noncomputable section
open scoped BigOperators
namespace MatrixMultiplication.HistorySupport
variable {H : Type*}
abbrev HistoryWords (P : H β Type*) (l r : H β β) (d : β) :=
β h, P h β ((Fin (l h) β Fin d) Γ (Fin (r h) β Fin d))
def totalLength [Fintype H] (P : H β Type*) [β h, Fintype (P h)]
(l r : H β β) : β :=
β h, Fintype.card (P h) * (l h + r h)
variable [Fintype H] [DecidableEq H]
variable (P : H β Type*) [β h, Fintype (P h)] [β h, DecidableEq (P h)]
variable (l r : H β β)
theorem card_historyWords (d : β) :
Fintype.card (HistoryWords P l r d) = d ^ totalLength P l r := by
change Fintype.card (β h, P h β ((Fin (l h) β Fin d) Γ (Fin (r h) β Fin d))) = _
rw [Fintype.card_pi]
simp only [Fintype.card_fun, Fintype.card_prod, Fintype.card_fin, β pow_add, β pow_mul]
rw [Finset.prod_pow_eq_pow_sum]
congr 1
unfold totalLength
apply Finset.sum_congr rfl
intro h _
exact Nat.mul_comm _ _
theorem card_historyWords_le_pow {d : β} (hd : 0 < d) (a N : β)
(hlen : totalLength P l r β€ a * N) :
Fintype.card (HistoryWords P l r d) β€ d ^ (a * N) := by
rw [card_historyWords]
exact Nat.pow_le_pow_right hd hlen
theorem card_historyWords_le_exp {d : β} (hd : 0 < d) (a N : β)
(hlen : totalLength P l r β€ a * N) :
(Fintype.card (HistoryWords P l r d) : β) β€
Real.exp (((a : β) * Real.log (d : β)) * N) := by
have hpow : ((d ^ (a * N) : β) : β) =
Real.exp (((a : β) * Real.log (d : β)) * N) := by
simpa only [Fintype.card_fun, Fintype.card_fin] using
RecoverySupport.word_card_eq_exp hd a N
rw [β hpow]
exact_mod_cast card_historyWords_le_pow P l r hd a N hlen
theorem support_card_le_exp {K : Type*} [Zero K] {d : β} (hd : 0 < d)
(Q : HistoryWords P l r d β HistoryWords P l r d β HistoryWords P l r d β K)
(a N : β) (hlen : totalLength P l r β€ a * N) :
((RecoverySupport.support Q).card : β) β€
Real.exp ((3 * (a : β) * Real.log (d : β)) * N) := by
have hdim := card_historyWords_le_exp P l r hd a N hlen
have h := RecoverySupport.support_card_le_exp Q N hdim hdim hdim
convert h using 1
congr 1
ring
theorem cw5_support_card_le_exp {K : Type*} [Zero K]
(Q : HistoryWords P l r 7 β HistoryWords P l r 7 β HistoryWords P l r 7 β K)
(a N : β) (hlen : totalLength P l r β€ a * N) :
((RecoverySupport.support Q).card : β) β€
Real.exp (RecoverySupport.cw5SupportRate a * N) := by
apply (support_card_le_exp P l r (by norm_num) Q a N hlen).trans
apply Real.exp_le_exp.mpr
unfold RecoverySupport.cw5SupportRate
simp only [Nat.cast_ofNat]
exact mul_le_mul_of_nonneg_right (le_add_of_nonneg_right zero_le_one) (Nat.cast_nonneg N)
end MatrixMultiplication.HistorySupport
end
end
end MatrixAllFields
namespace MatrixAllFields
open scoped BigOperators Topology Polynomial
section
noncomputable section
namespace MatrixMultiplication.AllFieldHistory
open AllFieldParameters
open scoped BigOperators
attribute [local instance] Classical.propDecidable Classical.decEq
theorem work_source_amount_pos {K : β} (allocation : Allocation) (w : PlacedWork K) :
0 < amount allocation (w.1.source, w.2) := by
apply div_pos _ (by norm_num)
cases w.1 with
| stageA h => exact initialAmount_pos h.val
| stageB h => exact aAmount_pos h.val
| stageC h => exact partAmount_pos allocation h
theorem work_source_population_pos {K : β} (allocation : Allocation) {dilation : β}
(hd : 0 < dilation) (w : PlacedWork K) :
0 < population allocation dilation (w.1.source, w.2) :=
(AllFieldPopulationCounts.count_pos_iff _ (amount_nonneg allocation) hd _).mpr
(work_source_amount_pos allocation w)
abbrev PositiveBranch {K : β} (allocation : Allocation) (w : PlacedWork K) :=
{b : w.1.Branch // 0 < amount allocation (w.1.child b false, w.2)}
theorem branchPopulation_pos_iff {K : β} (allocation : Allocation) {dilation : β}
(hd : 0 < dilation) (w : PlacedWork K) (b : w.1.Branch) :
0 < branchPopulation allocation dilation w b β
0 < amount allocation (w.1.child b false, w.2) :=
AllFieldPopulationCounts.count_pos_iff _ (amount_nonneg allocation) hd _
theorem positive_branch_minimum {K : β} (allocation : Allocation) (dilation : β)
(w : PlacedWork K) (b : PositiveBranch allocation w) :
dilation β€ branchPopulation allocation dilation w b.val :=
AllFieldPopulationCounts.dilation_le_count _ (amount_nonneg allocation) dilation _ b.property
theorem positive_joint_class_minimum {K : β} (allocation : Allocation) {dilation : β}
(hd : 0 < dilation) (w : PlacedWork K) (u : JointPopulation.Shape)
(hu : 0 < jointCounts allocation dilation w u) : dilation β€ jointCounts allocation dilation w u := by
obtain β¨b, rfl, hbβ© := shapeCounts_positive _ _ u hu
rw [jointCounts_at]
exact positive_branch_minimum allocation dilation w
β¨b, (branchPopulation_pos_iff allocation hd w b).mp hbβ©
def activeLengthRate {K tick : β} (allocation : Allocation) : β :=
β h : Active K tick, amount allocation (h.val.1.source, h.val.2) *
(2 * h.val.1.halfLength : β)
def activePositions {K tick : β} (allocation : Allocation) (dilation : β)
(h : Active K tick) : Type :=
Fin (population allocation dilation (h.val.1.source, h.val.2))
instance {K tick : β} (allocation : Allocation) (dilation : β) (h : Active K tick) :
Fintype (activePositions allocation dilation h) := inferInstanceAs (Fintype (Fin _))
theorem active_totalLength_cast {K tick : β} (allocation : Allocation) (dilation : β) :
(HistorySupport.totalLength (activePositions (K := K) (tick := tick) allocation dilation)
activeHalfLength activeHalfLength : β) =
(populationLength (K := K) allocation dilation : β) *
activeLengthRate (K := K) (tick := tick) allocation := by
simp only [HistorySupport.totalLength, Nat.cast_sum, Nat.cast_mul,
activeLengthRate, Finset.mul_sum]
apply Finset.sum_congr rfl
intro h hh
simp only [Fintype.card_eq_nat_card]
simp only [activePositions, Nat.card_fin, population_cast, activeHalfLength]
push_cast
ring
def activeLengthBudget {K tick : β} (allocation : Allocation) : β :=
Nat.ceil (activeLengthRate (K := K) (tick := tick) allocation)
theorem active_totalLength_le {K tick : β} (allocation : Allocation) (dilation : β) :
HistorySupport.totalLength (activePositions (K := K) (tick := tick) allocation dilation)
activeHalfLength activeHalfLength β€
activeLengthBudget (K := K) (tick := tick) allocation *
populationLength (K := K) allocation dilation := by
have h := active_totalLength_cast (K := K) (tick := tick) allocation dilation
have hc : activeLengthRate (K := K) (tick := tick) allocation β€
(activeLengthBudget (K := K) (tick := tick) allocation : β) := Nat.le_ceil _
have hb := mul_le_mul_of_nonneg_left hc
(Nat.cast_nonneg (populationLength (K := K) allocation dilation) :
(0 : β) β€ populationLength (K := K) allocation dilation)
rw [β h] at hb
exact_mod_cast hb.trans_eq (mul_comm _ _)
theorem active_cw5_support_bound {F : Type*} [Zero F] {K tick : β}
(allocation : Allocation) (dilation : β)
(Q : HistorySupport.HistoryWords
(activePositions (K := K) (tick := tick) allocation dilation)
activeHalfLength activeHalfLength 7 β
HistorySupport.HistoryWords
(activePositions (K := K) (tick := tick) allocation dilation)
activeHalfLength activeHalfLength 7 β
HistorySupport.HistoryWords
(activePositions (K := K) (tick := tick) allocation dilation)
activeHalfLength activeHalfLength 7 β F) :
((RecoverySupport.support Q).card : β) β€
Real.exp (RecoverySupport.cw5SupportRate
(activeLengthBudget (K := K) (tick := tick) allocation) *
(populationLength (K := K) allocation dilation : β)) :=
HistorySupport.cw5_support_card_le_exp _ _ _ Q _ _
(active_totalLength_le allocation dilation)
end MatrixMultiplication.AllFieldHistory
end
end
end MatrixAllFields
namespace MatrixAllFields
open scoped BigOperators Topology Polynomial
section
noncomputable section
namespace MatrixMultiplication.AllFieldHistorySupport
open AllFieldHistory
open scoped BigOperators
attribute [local instance] Classical.propDecidable Classical.decEq
theorem population_dilation {K : β} (allocation : Allocation) (m : β) (h : History K) :
population allocation m h = m * population allocation 1 h := by
simp only [population, AllFieldPopulationCounts.count, one_mul]
theorem branchPopulation_dilation {K : β} (allocation : Allocation) (m : β)
(w : PlacedWork K) (b : w.1.Branch) :
branchPopulation allocation m w b = m * branchPopulation allocation 1 w b := by
simp only [branchPopulation, population, AllFieldPopulationCounts.count, one_mul]
theorem jointCounts_dilation {K : β} (allocation : Allocation) (m : β)
(w : PlacedWork K) (u : JointPopulation.Shape) :
jointCounts allocation m w u = m * jointCounts allocation 1 w u := by
simp only [jointCounts, shapeCounts, branchPopulation, population,
AllFieldPopulationCounts.count, one_mul, Finset.mul_sum, mul_ite, mul_zero]
theorem activeCounts_dilation {K tick : β} (allocation : Allocation) (m : β)
(h : Active K tick) (u : JointPopulation.Shape) :
activeCounts allocation m h u = m * activeCounts allocation 1 h u :=
jointCounts_dilation allocation m h.val u
theorem activeCounts_pos_iff {K tick m : β} (allocation : Allocation) (hm : 0 < m)
(h : Active K tick) (u : JointPopulation.Shape) :
0 < activeCounts allocation m h u β 0 < activeCounts allocation 1 h u := by
rw [activeCounts_dilation]
exact Nat.mul_pos_iff_of_pos_left hm
theorem dilation_le_activeCounts {K tick : β} (allocation : Allocation) (m : β)
(h : Active K tick) (u : JointPopulation.Shape)
(hpos : 0 < activeCounts allocation 1 h u) : m β€ activeCounts allocation m h u := by
rw [activeCounts_dilation]
calc
m = m * 1 := (Nat.mul_one m).symm
_ β€ m * activeCounts allocation 1 h u := Nat.mul_le_mul_left m hpos
theorem two_le_activeCounts {K tick m : β} (allocation : Allocation) (hm : 2 β€ m)
(h : Active K tick) (u : JointPopulation.Shape)
(hpos : 0 < activeCounts allocation 1 h u) : 2 β€ activeCounts allocation m h u :=
hm.trans (dilation_le_activeCounts allocation m h u hpos)
theorem totalLength_dilation {K tick : β} (allocation : Allocation) (m : β)
(l r : Active K tick β β) :
HistorySupport.totalLength (JointPopulation.Positions (activeCounts allocation m)) l r =
m * HistorySupport.totalLength (JointPopulation.Positions (activeCounts allocation 1)) l r := by
simp only [HistorySupport.totalLength, JointPopulation.Positions, Fintype.card_fin,
activeCounts_dilation allocation m, β Finset.mul_sum, Nat.mul_assoc]
def fixedBaseLength {K tick : β} (allocation : Allocation) : β :=
HistorySupport.totalLength
(JointPopulation.Positions (activeCounts (K := K) (tick := tick) allocation 1))
activeHalfLength activeHalfLength
def supportRate {K tick : β} (allocation : Allocation) : β :=
RecoverySupport.cw5SupportRate (fixedBaseLength (K := K) (tick := tick) allocation)
theorem supportRate_pos {K tick : β} (allocation : Allocation) :
0 < supportRate (K := K) (tick := tick) allocation :=
RecoverySupport.cw5SupportRate_pos _
abbrev ActiveRawPairs {K tick : β} (allocation : Allocation) (m : β) :=
JointCanonicalization.RawPairs (activeCounts (K := K) (tick := tick) allocation m)
(JointCanonicalCW.Left activeHalfLength) (JointCanonicalCW.Right activeHalfLength)
theorem raw_support_card_le_exp {K tick : β} {F : Type*} [Zero F]
(allocation : Allocation) (m : β)
(Q : ActiveRawPairs (K := K) (tick := tick) allocation m β
ActiveRawPairs (K := K) (tick := tick) allocation m β
ActiveRawPairs (K := K) (tick := tick) allocation m β F) :
((RecoverySupport.support Q).card : β) β€
Real.exp (supportRate (K := K) (tick := tick) allocation * m) := by
apply HistorySupport.cw5_support_card_le_exp
(JointPopulation.Positions (activeCounts (K := K) (tick := tick) allocation m))
activeHalfLength activeHalfLength Q (fixedBaseLength (K := K) (tick := tick) allocation) m
rw [totalLength_dilation]
exact le_of_eq (Nat.mul_comm _ _)
abbrev ActiveClass (K tick : β) := Active K tick Γ JointPopulation.Shape
def selectedBaseCount {K tick : β} (allocation : Allocation)
(D : Finset (ActiveClass K tick)) : β :=
β c β D, activeCounts allocation 1 c.1 c.2
def selectedBasePopulation {K tick : β} (allocation : Allocation)
(D : Finset (ActiveClass K tick)) : β := (selectedBaseCount allocation D : β)
abbrev selectedPositions {K tick : β} (allocation : Allocation) (m : β)
(D : Finset (ActiveClass K tick)) (c : D) :=
JointCanonicalization.ClassPositions (activeCounts allocation m) c.val
theorem selected_count_dilation {K tick : β} (allocation : Allocation) (m : β)
(D : Finset (ActiveClass K tick)) :
(β c β D, activeCounts allocation m c.1 c.2) = m * selectedBaseCount allocation D := by
simp only [selectedBaseCount, activeCounts_dilation allocation m, Finset.mul_sum]
theorem selectedBaseCount_pos {K tick : β} (allocation : Allocation)
(D : Finset (ActiveClass K tick)) (hD : D.Nonempty)
(hpos : β c β D, 0 < activeCounts allocation 1 c.1 c.2) :
0 < selectedBaseCount allocation D :=
Finset.sum_pos hpos hD
theorem selectedBasePopulation_pos {K tick : β} (allocation : Allocation)
(D : Finset (ActiveClass K tick)) (hD : D.Nonempty)
(hpos : β c β D, 0 < activeCounts allocation 1 c.1 c.2) :
0 < selectedBasePopulation allocation D := by
unfold selectedBasePopulation
exact_mod_cast selectedBaseCount_pos allocation D hD hpos
theorem selected_populationSize {K tick : β} (allocation : Allocation) (m : β)
(D : Finset (ActiveClass K tick)) :
PermutationMatching.populationSize (selectedPositions allocation m D) =
selectedBasePopulation allocation D * (m : β) := by
simp only [PermutationMatching.populationSize, selectedPositions,
JointCanonicalization.ClassPositions, Fintype.card_fin]
rw [Finset.sum_coe_sort D
(fun c : ActiveClass K tick => (activeCounts allocation m c.1 c.2 : β))]
simp only [activeCounts_dilation allocation m, Nat.cast_mul, β Finset.mul_sum,
selectedBasePopulation, selectedBaseCount, Nat.cast_sum]
exact mul_comm _ _
theorem selected_two_le {K tick m : β} (allocation : Allocation) (hm : 2 β€ m)
(D : Finset (ActiveClass K tick))
(hpos : β c β D, 0 < activeCounts allocation 1 c.1 c.2) (c : D) :
2 β€ Fintype.card (selectedPositions allocation m D c) := by
simpa only [selectedPositions, JointCanonicalization.ClassPositions, Fintype.card_fin] using
two_le_activeCounts allocation hm c.val.1 c.val.2 (hpos c.val c.property)
theorem selected_classWeight_formula {K tick m : β} (allocation : Allocation)
(hm : 0 < m) (D : Finset (ActiveClass K tick)) (c : D) :
PermutationMatching.classWeight (selectedPositions allocation m D) c =
(activeCounts allocation 1 c.val.1 c.val.2 : β) / selectedBasePopulation allocation D := by
rw [PermutationMatching.classWeight, selected_populationSize]
simp only [selectedPositions, JointCanonicalization.ClassPositions, Fintype.card_fin,
activeCounts_dilation allocation m, Nat.cast_mul]
rw [mul_comm (selectedBasePopulation allocation D) (m : β)]
exact mul_div_mul_left _ _ (Nat.cast_ne_zero.mpr (Nat.ne_of_gt hm))
theorem selected_classWeight_eq_one {K tick m : β} (allocation : Allocation)
(hm : 0 < m) (D : Finset (ActiveClass K tick)) (c : D) :
PermutationMatching.classWeight (selectedPositions allocation m D) c =
PermutationMatching.classWeight (selectedPositions allocation 1 D) c :=
(selected_classWeight_formula allocation hm D c).trans
(selected_classWeight_formula allocation (by decide : 0 < (1 : β)) D c).symm
theorem selected_classProductMixture_eq_one {K tick m : β} (allocation : Allocation)
(hm : 0 < m) (D : Finset (ActiveClass K tick)) (left right : D β β) :
PermutationMatching.classProductMixture (selectedPositions allocation m D) left right =
PermutationMatching.classProductMixture (selectedPositions allocation 1 D) left right := by
unfold PermutationMatching.classProductMixture
apply Finset.sum_congr rfl
intro c _
rw [selected_classWeight_eq_one allocation hm D c]
theorem work_source_amount_pos {K : β} (allocation : Allocation) (w : PlacedWork K) :
0 < amount allocation (w.1.source, w.2) := by
rcases w with β¨w, phiβ©
unfold amount
apply div_pos _ (by norm_num)
cases w with
| stageA h => exact initialAmount_pos h.val
| stageB h => exact aAmount_pos h.val
| stageC h => exact partAmount_pos allocation h
theorem work_source_population_pos {K m : β} (allocation : Allocation) (hm : 0 < m)
(w : PlacedWork K) : 0 < population allocation m (w.1.source, w.2) :=
(AllFieldPopulationCounts.count_pos_iff (amount allocation) (amount_nonneg allocation)
hm (w.1.source, w.2)).2 (work_source_amount_pos allocation w)
def positiveClasses {K tick : β} (allocation : Allocation) (h : Active K tick) :
Finset (ActiveClass K tick) :=
Finset.univ.filter fun c => c.1 = h β§ 0 < activeCounts allocation 1 c.1 c.2
theorem positiveClasses_positive {K tick : β} (allocation : Allocation) (h : Active K tick)
(c : ActiveClass K tick) (hc : c β positiveClasses allocation h) :
0 < activeCounts allocation 1 c.1 c.2 := (Finset.mem_filter.mp hc).2.2
theorem positiveClasses_baseCount {K tick : β} (allocation : Allocation) (h : Active K tick) :
selectedBaseCount allocation (positiveClasses allocation h) =
population allocation 1 (h.val.1.source, h.val.2) := by
have hkeep (n : β) : (if 0 < n then n else 0) = n := by
split_ifs <;> omega
calc
selectedBaseCount allocation (positiveClasses allocation h) =
β u, activeCounts allocation 1 h u := by
simp [selectedBaseCount, positiveClasses, Finset.sum_filter, ite_and, hkeep,
Fintype.sum_prod_type]
_ = population allocation 1 (h.val.1.source, h.val.2) :=
jointCounts_sum allocation 1 h.val
theorem positiveClasses_basePopulation_pos {K tick : β} (allocation : Allocation)
(h : Active K tick) : 0 < selectedBasePopulation allocation (positiveClasses allocation h) := by
unfold selectedBasePopulation
rw [positiveClasses_baseCount]
exact_mod_cast work_source_population_pos allocation (by decide : 0 < (1 : β)) h.val
theorem positiveClasses_nonempty {K tick : β} (allocation : Allocation) (h : Active K tick) :
(positiveClasses allocation h).Nonempty := by
by_contra hn
have hempty := Finset.not_nonempty_iff_eq_empty.mp hn
have hp := positiveClasses_basePopulation_pos allocation h
simp [selectedBasePopulation, selectedBaseCount, hempty] at hp
theorem positiveClasses_populationSize {K tick : β} (allocation : Allocation) (m : β)
(h : Active K tick) :
PermutationMatching.populationSize
(selectedPositions allocation m (positiveClasses allocation h)) =
(population allocation 1 (h.val.1.source, h.val.2) : β) * m := by
rw [selected_populationSize]
simp only [selectedBasePopulation, positiveClasses_baseCount]
end MatrixMultiplication.AllFieldHistorySupport
end
end
end MatrixAllFields
namespace MatrixAllFields
open scoped BigOperators Topology Polynomial
section
noncomputable section
namespace MatrixMultiplication.AllFieldHistoryIncomingMasks
open MatrixMultiplication.Foundation AllFieldHistory AllFieldParameters
open AllFieldHistoryChildLaws AllFieldHistorySupport
open scoped BigOperators
attribute [local instance] Classical.propDecidable Classical.decEq
variable {K tick : β}
def joinHalves (w : Work K) :
((Fin w.halfLength β Fin 7) Γ (Fin w.halfLength β Fin 7)) β
(Fin (currentLength w.source) β Fin 7) :=
match w with
| .stageA _ => fun x => Fin.append x.1 x.2
| .stageB _ => fun x => Fin.append x.1 x.2
| .stageC _ => fun x => Fin.append x.1 x.2
def sourcePositionsEquiv (allocation : Allocation) (m : β) (h : Active K tick) :
JointPopulation.Positions (activeCounts allocation m) h β
Fin (population allocation m (h.val.1.source, h.val.2)) :=
finCongr (jointCounts_sum allocation m h.val)
def incomingWord (allocation : Allocation) (m : β) (h : Active K tick)
(w : ActiveRawPairs (K := K) (tick := tick) allocation m) :
HistoryWord allocation m (h.val.1.source, h.val.2) :=
fun p => joinHalves h.val.1 (w h ((sourcePositionsEquiv allocation m h).symm p))
def received (allocation : Allocation) (m : β) (Ξ΅ : β) (side : Fin 3)
(w : ActiveRawPairs (K := K) (tick := tick) allocation m) : Prop :=
β h : Active K tick,
residentMask allocation m Ξ΅ (h.val.1.source, h.val.2) side
(incomingWord allocation m h w)
end MatrixMultiplication.AllFieldHistoryIncomingMasks
end
end
end MatrixAllFields
namespace MatrixAllFields
open scoped BigOperators Topology Polynomial
section
noncomputable section
namespace MatrixMultiplication.AllFieldHistoryBranchWeights
open AllFieldHistory AllFieldHistorySupport AllFieldParameters
open scoped BigOperators
attribute [local instance] Classical.propDecidable Classical.decEq
theorem stageB_branchPopulation_rat {K : β} (allocation : Allocation) (dilation : β)
(h : APositive K) (b : BSplit h) (phi : Placement) :
(branchPopulation allocation dilation (.stageB h, phi) b : β) =
(population allocation dilation (.afterA h.val, phi) : β) *
stageBLaw (aShape h.val) (bSplit β¨h, b, falseβ©) := by
simp only [branchPopulation, Work.child, population_cast, amount, canonicalAmount, bAmount]
ring
theorem stageB_branchPopulation_real {K : β} (allocation : Allocation) (dilation : β)
(h : APositive K) (b : BSplit h) (phi : Placement) :
(branchPopulation allocation dilation (.stageB h, phi) b : β) =
(population allocation dilation (.afterA h.val, phi) : β) *
(stageBLaw (aShape h.val) (bSplit β¨h, b, falseβ©) : β) := by
exact_mod_cast stageB_branchPopulation_rat allocation dilation h b phi
theorem stageB_branchWeight_rat {K dilation : β} (allocation : Allocation)
(hd : 0 < dilation) (h : APositive K) (b : BSplit h) (phi : Placement) :
(branchPopulation allocation dilation (.stageB h, phi) b : β) /
(population allocation dilation (.afterA h.val, phi) : β) =
stageBLaw (aShape h.val) (bSplit β¨h, b, falseβ©) := by
have hpos := AllFieldHistorySupport.work_source_population_pos allocation hd (.stageB h, phi)
have hden : (population allocation dilation (.afterA h.val, phi) : β) β 0 := by
exact_mod_cast Nat.ne_of_gt hpos
apply (div_eq_iff hden).2
rw [stageB_branchPopulation_rat]
exact mul_comm _ _
theorem stageB_branchWeight_real {K dilation : β} (allocation : Allocation)
(hd : 0 < dilation) (h : APositive K) (b : BSplit h) (phi : Placement) :
(branchPopulation allocation dilation (.stageB h, phi) b : β) /
(population allocation dilation (.afterA h.val, phi) : β) =
(stageBLaw (aShape h.val) (bSplit β¨h, b, falseβ©) : β) := by
have hpos := AllFieldHistorySupport.work_source_population_pos allocation hd (.stageB h, phi)
have hden : (population allocation dilation (.afterA h.val, phi) : β) β 0 := by
exact_mod_cast Nat.ne_of_gt hpos
apply (div_eq_iff hden).2
rw [stageB_branchPopulation_real]
exact mul_comm _ _
theorem shapeCounts_weighted_sum {I : Type*} [Fintype I]
(code : I β JointPopulation.Shape) (weight : I β β)
(f : JointPopulation.Shape β β) :
(β u, (shapeCounts code weight u : β) * f u) =
β b, (weight b : β) * f (code b) := by
simp only [shapeCounts, Nat.cast_sum, Nat.cast_ite, Nat.cast_zero, Finset.sum_mul]
rw [Finset.sum_comm]
apply Finset.sum_congr rfl
intro b _
simp [ite_mul]
end MatrixMultiplication.AllFieldHistoryBranchWeights
end
end
end MatrixAllFields
namespace MatrixAllFields
open scoped BigOperators Topology Polynomial
section
noncomputable section
namespace MatrixMultiplication.AllFieldHistoryStageCIncoming
open AllFieldHistory AllFieldHistorySupport AllFieldParameters
open CWStageCProducts InheritedMasks
open scoped BigOperators
attribute [local instance] Classical.propDecidable Classical.decEq
variable {K tick : β}
def stageCActive (h : PartC K) (phi : Placement)
(ht : FiniteSchedule.lotTick (Work.stageC h).lot (Work.stageC h).stage = tick) :
Active K tick := β¨(.stageC h, phi), htβ©
def positionEquiv (allocation : Allocation) (dilation : β) (h : PartC K)
(phi : Placement)
(ht : FiniteSchedule.lotTick (Work.stageC h).lot (Work.stageC h).stage = tick)
(e : JointPopulation.Target (activeCounts (K := K) (tick := tick) allocation dilation)) :
JointPopulation.Positions (activeCounts (K := K) (tick := tick) allocation dilation) (stageCActive h phi ht) β
CWStageCProducts.Positions (populationAtomCounts allocation dilation (h, phi)) :=
(JointCanonicalization.positionEquiv (activeCounts (K := K) (tick := tick) allocation dilation) e
(stageCActive h phi ht)).trans
(branchPositionEquiv allocation dilation (.stageC h, phi))
theorem positionEquiv_shape (allocation : Allocation) (dilation : β) (h : PartC K)
(phi : Placement)
(ht : FiniteSchedule.lotTick (Work.stageC h).lot (Work.stageC h).stage = tick)
(e : JointPopulation.Target (activeCounts (K := K) (tick := tick) allocation dilation))
(j : JointPopulation.Positions (activeCounts (K := K) (tick := tick) allocation dilation) (stageCActive h phi ht)) :
branchShape (.stageC h, phi) (positionEquiv allocation dilation h phi ht e j).1 =
(e (stageCActive h phi ht)).val j := by
exact (branchPositionEquiv_shape allocation dilation (.stageC h, phi)
(JointCanonicalization.positionEquiv (activeCounts (K := K) (tick := tick) allocation dilation) e
(stageCActive h phi ht) j)).trans
(JointCanonicalization.positionEquiv_shape (activeCounts (K := K) (tick := tick) allocation dilation) e
(stageCActive h phi ht) j)
theorem positionEquiv_symm_shape (allocation : Allocation) (dilation : β) (h : PartC K)
(phi : Placement)
(ht : FiniteSchedule.lotTick (Work.stageC h).lot (Work.stageC h).stage = tick)
(e : JointPopulation.Target (activeCounts (K := K) (tick := tick) allocation dilation))
(p : CWStageCProducts.Positions (populationAtomCounts allocation dilation (h, phi))) :
(e (stageCActive h phi ht)).val ((positionEquiv allocation dilation h phi ht e).symm p) =
branchShape (.stageC h, phi) p.1 := by
have hp := positionEquiv_shape allocation dilation h phi ht e
((positionEquiv allocation dilation h phi ht e).symm p)
simpa only [Equiv.apply_symm_apply] using hp.symm
theorem typeWindow_of_target_side_weights (allocation : Allocation) {dilation : β}
(hd : 0 < dilation) (h : PartC K) (phi : Placement)
(ht : FiniteSchedule.lotTick (Work.stageC h).lot (Work.stageC h).stage = tick)
(e : JointPopulation.Target (activeCounts (K := K) (tick := tick) allocation dilation))
(w : ActiveRawPairs (K := K) (tick := tick) allocation dilation) (side : Fin 3)
(hweights : β j : JointPopulation.Positions (activeCounts (K := K) (tick := tick) allocation dilation)
(stageCActive h phi ht),
CWLeafStatistics.weight ((w (stageCActive h phi ht) j).1 (0 : Fin 1)) =
(JointPopulation.shapeSide side ((e (stageCActive h phi ht)).val j)).val β§
CWLeafStatistics.weight ((w (stageCActive h phi ht) j).2 (0 : Fin 1)) =
activeParentShape (stageCActive h phi ht) side -
(JointPopulation.shapeSide side ((e (stageCActive h phi ht)).val j)).val)
(Ξ· : β) (hΞ· : 0 β€ Ξ·) :
typeWindow
(fun a : Fin 6 =>
(littleLaw (cParameterParent h) (cShapeParent h) (phi.symm side) a : β)) Ξ·
(fun j => CWCompleteStatistics.twoStatistic
(Matrix.vecCons ((w (stageCActive h phi ht) j).1 (0 : Fin 1)) (Matrix.vecCons ((w (stageCActive h phi ht) j).2 (0 : Fin 1)) Matrix.vecEmpty))) := by
let p := positionEquiv allocation dilation h phi ht e
let words : CWStageCProducts.Positions (populationAtomCounts allocation dilation (h, phi)) β
CWStageCProducts.Word := fun j =>
(Matrix.vecCons ((w (stageCActive h phi ht) (p.symm j)).1 (0 : Fin 1)) (Matrix.vecCons ((w (stageCActive h phi ht) (p.symm j)).2 (0 : Fin 1)) Matrix.vecEmpty))
have hgeometry (j : CWStageCProducts.Positions
(populationAtomCounts allocation dilation (h, phi))) :
CWLeafStatistics.weight (words j 0) =
branchAtom (stageCDistinguished (cShapeParent h)) j.1 (phi.symm side) β§
CWLeafStatistics.weight (words j 1) =
CWStageCProducts.shape (stageCDistinguished (cShapeParent h)) (phi.symm side) -
branchAtom (stageCDistinguished (cShapeParent h)) j.1 (phi.symm side) := by
have hw := hweights (p.symm j)
have hs := positionEquiv_symm_shape allocation dilation h phi ht e j
change (e (stageCActive h phi ht)).val (p.symm j) = _ at hs
rw [hs] at hw
simpa only [words, Matrix.cons_val_zero, Matrix.cons_val_one,
activeParentShape, stageCActive, Work.parentShape, branchShape,
encodePhysicalShape_side, physicalShape, Work.splitShape, cSplit,
branchAtom_eq_stageCAtom, shape_eq_parent (cShapeParent h) (bShape_size h.1.val)
h.1.property] using hw
have hwindow := typeWindow_of_placed_side_weights
(populationAtomCounts allocation dilation (h, phi))
(cParameterParent h) (cShapeParent h) (bShape_size h.1.val) h.1.property
(population allocation dilation (.partC h, phi))
(AllFieldHistorySupport.work_source_population_pos allocation hd (.stageC h, phi))
(populationAtomCounts_parent allocation dilation (h, phi))
phi side words hgeometry Ξ· hΞ·
exact (JointCanonicalization.typeWindow_reindex _ Ξ·
(fun j => CWCompleteStatistics.twoStatistic
(Matrix.vecCons ((w (stageCActive h phi ht) j).1 (0 : Fin 1)) (Matrix.vecCons ((w (stageCActive h phi ht) j).2 (0 : Fin 1)) Matrix.vecEmpty)))
p.symm).mp hwindow
end MatrixMultiplication.AllFieldHistoryStageCIncoming
end
end
end MatrixAllFields
namespace MatrixAllFields
open scoped BigOperators Topology Polynomial
section
namespace MatrixMultiplication.PermutationMatching
open scoped BigOperators
open Classical
noncomputable section
variable {C : Type*} [Fintype C] [DecidableEq C]
{P X Y : C β Type*}
[β c, Fintype (P c)] [β c, DecidableEq (P c)]
[β c, Fintype (X c)] [β c, DecidableEq (X c)]
[β c, Fintype (Y c)] [β c, DecidableEq (Y c)]
abbrev PairProfile (P X Y : C β Type*) [β c, Fintype (P c)] :=
InheritedMasks.Profile P X Γ InheritedMasks.Profile P Y
def pairProfile (w : CompleteWordPair P X Y) : PairProfile P X Y :=
(InheritedMasks.profile P X w.left, InheritedMasks.profile P Y w.right)
omit [Fintype C] [DecidableEq C] [β c, DecidableEq (P c)]
[β c, Fintype (X c)] [β c, Fintype (Y c)] in
theorem pairProfile_smul (g : HalfClassPermutations P)
(w : CompleteWordPair P X Y) : pairProfile (g β’ w) = pairProfile w := by
apply Prod.ext
Β· apply (InheritedMasks.profile_eq_iff P X _ _).mpr
exact β¨fun c => g.1 c, fun c => by
funext i
simpβ©
Β· apply (InheritedMasks.profile_eq_iff P Y _ _).mpr
exact β¨fun c => g.2 c, fun c => by
funext i
simpβ©
omit [Fintype C] [DecidableEq C]
[β c, Fintype (P c)] [β c, DecidableEq (P c)]
[β c, Fintype (X c)] [β c, DecidableEq (X c)]
[β c, Fintype (Y c)] [β c, DecidableEq (Y c)] in
private theorem completeWordPair_ext {w v : CompleteWordPair P X Y}
(hl : w.left = v.left) (hr : w.right = v.right) : w = v := by
cases w
cases v
cases hl
cases hr
rfl
omit [Fintype C] [DecidableEq C] [β c, DecidableEq (P c)]
[β c, Fintype (X c)] [β c, Fintype (Y c)] in
theorem pairProfile_eq_iff (w v : CompleteWordPair P X Y) :
pairProfile w = pairProfile v β
β g : HalfClassPermutations P, g β’ w = v := by
constructor
Β· intro h
have hl := (InheritedMasks.profile_eq_iff P X w.left v.left).mp
(congrArg Prod.fst h)
have hr := (InheritedMasks.profile_eq_iff P Y w.right v.right).mp
(congrArg Prod.snd h)
obtain β¨el, helβ© := hl
obtain β¨er, herβ© := hr
refine β¨(fun c => (el c)β»ΒΉ, fun c => (er c)β»ΒΉ), ?_β©
apply completeWordPair_ext
Β· funext c i
exact congrFun (hel c) i
Β· funext c i
exact congrFun (her c) i
Β· rintro β¨g, rflβ©
exact (pairProfile_smul g w).symm
omit [Fintype C] [DecidableEq C] [β c, DecidableEq (P c)]
[β c, Fintype (X c)] [β c, Fintype (Y c)] in
theorem pairProfile_eq_iff_orbitRel (w v : CompleteWordPair P X Y) :
pairProfile w = pairProfile v β
MulAction.orbitRel (HalfClassPermutations P) (CompleteWordPair P X Y) w v := by
constructor
Β· intro h
obtain β¨g, hgβ© := (pairProfile_eq_iff v w).mp h.symm
exact β¨g, hgβ©
Β· rintro β¨g, rflβ©
exact pairProfile_smul g v
abbrev PairOrbit (P X Y : C β Type*) :=
MulAction.orbitRel.Quotient (HalfClassPermutations P) (CompleteWordPair P X Y)
def pairOrbitProfile : PairOrbit P X Y β PairProfile P X Y :=
Quotient.lift pairProfile fun w v h => (pairProfile_eq_iff_orbitRel w v).mpr h
omit [Fintype C] [DecidableEq C] [β c, DecidableEq (P c)]
[β c, Fintype (X c)] [β c, Fintype (Y c)] in
theorem pairOrbitProfile_injective :
Function.Injective (pairOrbitProfile (P := P) (X := X) (Y := Y)) := by
intro q r
induction q using Quotient.inductionOn with
| h w =>
induction r using Quotient.inductionOn with
| h v =>
intro h
apply Quotient.sound
exact (pairProfile_eq_iff_orbitRel w v).mp h
omit [β c, DecidableEq (P c)] in
theorem card_pairOrbits_le :
Nat.card (PairOrbit P X Y) β€
(β c, (Fintype.card (P c) + 1) ^ Fintype.card (X c)) *
(β c, (Fintype.card (P c) + 1) ^ Fintype.card (Y c)) := by
have : Finite (PairOrbit P X Y) :=
Finite.of_injective pairOrbitProfile pairOrbitProfile_injective
let := Fintype.ofFinite (PairOrbit P X Y)
rw [Nat.card_eq_fintype_card]
calc
_ β€ Fintype.card (PairProfile P X Y) :=
Fintype.card_le_of_injective pairOrbitProfile pairOrbitProfile_injective
_ = _ := by
rw [Fintype.card_prod, InheritedMasks.card_profile, InheritedMasks.card_profile]
omit [β c, DecidableEq (P c)] in
theorem card_pairOrbits_le_common_bound (m : β)
(hm : β c, Fintype.card (P c) β€ m) :
Nat.card (PairOrbit P X Y) β€ (m + 1) ^
((β c, Fintype.card (X c)) + β c, Fintype.card (Y c)) := by
refine (card_pairOrbits_le (P := P) (X := X) (Y := Y)).trans ?_
calc
_ β€ (β c, (m + 1) ^ Fintype.card (X c)) *
(β c, (m + 1) ^ Fintype.card (Y c)) := by
apply Nat.mul_le_mul
Β· exact Finset.prod_le_prod fun c _ =>
Nat.pow_le_pow_left (Nat.add_le_add_right (hm c) 1) _
Β· exact Finset.prod_le_prod fun c _ =>
Nat.pow_le_pow_left (Nat.add_le_add_right (hm c) 1) _
_ = _ := by rw [Finset.prod_pow_eq_pow_sum, Finset.prod_pow_eq_pow_sum, pow_add]
end
end MatrixMultiplication.PermutationMatching
end
end MatrixAllFields
namespace MatrixAllFields
open scoped BigOperators Topology Polynomial
section
noncomputable section
namespace MatrixMultiplication.AllFieldHistoryOrbitCount
open AllFieldHistory AllFieldHistorySupport PermutationMatching
open scoped BigOperators
attribute [local instance] Classical.propDecidable Classical.decEq
abbrev Classes (K tick : β) := ActiveClass K tick
abbrev Positions {K tick : β} (allocation : Allocation) (m : β)
(c : Classes K tick) :=
JointCanonicalization.ClassPositions (activeCounts allocation m) c
abbrev Letters {K tick : β} (c : Classes K tick) :=
Fin (activeHalfLength c.1) β Fin 7
abbrev ActualOrbit {K tick : β} (allocation : Allocation) (m : β) :=
PairOrbit (Positions (K := K) (tick := tick) allocation m)
(Letters (K := K) (tick := tick)) (Letters (K := K) (tick := tick))
noncomputable instance actualOrbitFintype {K tick : β}
(allocation : Allocation) (m : β) :
Fintype (ActualOrbit (K := K) (tick := tick) allocation m) := by
haveI : Finite (ActualOrbit (K := K) (tick := tick) allocation m) :=
Finite.of_injective pairOrbitProfile pairOrbitProfile_injective
exact Fintype.ofFinite _
def basePopulationBound {K tick : β} (allocation : Allocation) : β :=
β c : Classes K tick, activeCounts allocation 1 c.1 c.2
def orbitDegree (K tick : β) : β :=
2 * β c : Classes K tick, 7 ^ activeHalfLength c.1
theorem card_letters {K tick : β} (c : Classes K tick) :
Fintype.card (Letters c) = 7 ^ activeHalfLength c.1 := by
simp only [Letters, Fintype.card_fun, Fintype.card_fin]
theorem class_card_le {K tick : β} (allocation : Allocation) (m : β)
(c : Classes K tick) :
Fintype.card (Positions allocation m c) β€
basePopulationBound (K := K) (tick := tick) allocation * m := by
have hc : activeCounts allocation 1 c.1 c.2 β€
basePopulationBound (K := K) (tick := tick) allocation := by
unfold basePopulationBound
exact Finset.single_le_sum
(fun (d : Classes K tick) _ => Nat.zero_le (activeCounts allocation 1 d.1 d.2))
(Finset.mem_univ c)
simp only [Positions, JointCanonicalization.ClassPositions, Fintype.card_fin,
activeCounts_dilation allocation m]
simpa only [Nat.mul_comm] using Nat.mul_le_mul_left m hc
theorem card_actualOrbit_le {K tick : β} (allocation : Allocation) (m : β) :
Nat.card (ActualOrbit (K := K) (tick := tick) allocation m) β€
(basePopulationBound (K := K) (tick := tick) allocation * m + 1) ^
orbitDegree K tick := by
simpa only [ActualOrbit, orbitDegree, card_letters, two_mul] using
(card_pairOrbits_le_common_bound
(P := Positions (K := K) (tick := tick) allocation m)
(X := Letters (K := K) (tick := tick))
(Y := Letters (K := K) (tick := tick))
(basePopulationBound (K := K) (tick := tick) allocation * m)
(class_card_le allocation m))
theorem card_actualOrbit_le_polynomial {K tick : β}
(allocation : Allocation) (m : β) :
Nat.card (ActualOrbit (K := K) (tick := tick) allocation m) β€
(basePopulationBound (K := K) (tick := tick) allocation + 1) ^ orbitDegree K tick *
(m + 1) ^ orbitDegree K tick := by
refine (card_actualOrbit_le allocation m).trans ?_
rw [β mul_pow]
apply Nat.pow_le_pow_left
nlinarith [Nat.zero_le (basePopulationBound (K := K) (tick := tick) allocation)]
def orbitPrefactor {K tick : β} (allocation : Allocation) : β :=
((basePopulationBound (K := K) (tick := tick) allocation + 1 : β) : β) ^
orbitDegree K tick
theorem orbitPrefactor_pos {K tick : β} (allocation : Allocation) :
0 < orbitPrefactor (K := K) (tick := tick) allocation := by
unfold orbitPrefactor
positivity
theorem card_actualOrbit_le_polynomial_real {K tick : β}
(allocation : Allocation) (m : β) :
(Nat.card (ActualOrbit (K := K) (tick := tick) allocation m) : β) β€
orbitPrefactor (K := K) (tick := tick) allocation *
((m : β) + 1) ^ orbitDegree K tick := by
unfold orbitPrefactor
exact_mod_cast card_actualOrbit_le_polynomial (K := K) (tick := tick) allocation m
theorem usedOrbits_card_le {K tick : β} (allocation : Allocation) (m : β)
(s : Finset (ActualOrbit (K := K) (tick := tick) allocation m)) :
s.card β€ (basePopulationBound (K := K) (tick := tick) allocation + 1) ^
orbitDegree K tick * (m + 1) ^ orbitDegree K tick := by
have hs : s.card β€ Nat.card (ActualOrbit (K := K) (tick := tick) allocation m) := by
rw [Nat.card_eq_fintype_card]
exact s.card_le_univ
exact hs.trans (card_actualOrbit_le_polynomial allocation m)
theorem usedOrbits_card_le_real {K tick : β} (allocation : Allocation) (m : β)
(s : Finset (ActualOrbit (K := K) (tick := tick) allocation m)) :
(s.card : β) β€ orbitPrefactor (K := K) (tick := tick) allocation *
((m : β) + 1) ^ orbitDegree K tick := by
unfold orbitPrefactor
exact_mod_cast usedOrbits_card_le allocation m s
theorem taggedUsedOrbits_card_le_real {K tick : β} (allocation : Allocation) (m : β)
(s : Finset (Fin 3 Γ ActualOrbit (K := K) (tick := tick) allocation m)) :
(s.card : β) β€ (3 * orbitPrefactor (K := K) (tick := tick) allocation) *
((m : β) + 1) ^ orbitDegree K tick := by
have hs : s.card β€ 3 * Nat.card
(ActualOrbit (K := K) (tick := tick) allocation m) := by
simpa only [Fintype.card_prod, Fintype.card_fin, Nat.card_eq_fintype_card] using
s.card_le_univ
have hsreal : (s.card : β) β€ 3 * (Nat.card
(ActualOrbit (K := K) (tick := tick) allocation m) : β) := by
exact_mod_cast hs
calc
_ β€ 3 * (Nat.card (ActualOrbit (K := K) (tick := tick) allocation m) : β) := hsreal
_ β€ 3 * (orbitPrefactor (K := K) (tick := tick) allocation *
((m : β) + 1) ^ orbitDegree K tick) :=
mul_le_mul_of_nonneg_left (card_actualOrbit_le_polynomial_real allocation m)
(by norm_num)
_ = _ := (mul_assoc _ _ _).symm
end MatrixMultiplication.AllFieldHistoryOrbitCount
end
end
end MatrixAllFields
namespace MatrixAllFields
open scoped BigOperators Topology Polynomial
section
noncomputable section
namespace MatrixMultiplication.AllFieldGroupOrbitCount
open AllFieldHistory AllFieldHistorySupport PermutationMatching
open scoped BigOperators
attribute [local instance] Classical.propDecidable Classical.decEq
abbrev GroupClasses (K tick : β) (sigma : Placement) :=
ActiveOrder K tick sigma Γ JointPopulation.Shape
abbrev GroupPositions {K tick : β} (allocation : Allocation) (m : β)
{sigma : Placement} (c : GroupClasses K tick sigma) :=
Fin (activeCounts allocation m c.1.val c.2)
abbrev GroupLetters {K tick : β} {sigma : Placement} (c : GroupClasses K tick sigma) :=
Fin (activeHalfLength c.1.val) β Fin 7
abbrev GroupOrbit {K tick : β} (allocation : Allocation) (m : β) (sigma : Placement) :=
PairOrbit (GroupPositions (K := K) (tick := tick) (sigma := sigma) allocation m)
(GroupLetters (K := K) (tick := tick) (sigma := sigma))
(GroupLetters (K := K) (tick := tick) (sigma := sigma))
noncomputable instance groupOrbitFintype {K tick : β}
(allocation : Allocation) (m : β) (sigma : Placement) :
Fintype (GroupOrbit (K := K) (tick := tick) allocation m sigma) := by
haveI : Finite (GroupOrbit (K := K) (tick := tick) allocation m sigma) :=
Finite.of_injective pairOrbitProfile pairOrbitProfile_injective
exact Fintype.ofFinite _
def groupDegree (K tick : β) (sigma : Placement) : β :=
2 * β c : GroupClasses K tick sigma, 7 ^ activeHalfLength c.1.val
theorem card_groupLetters {K tick : β} {sigma : Placement}
(c : GroupClasses K tick sigma) :
Fintype.card (GroupLetters c) = 7 ^ activeHalfLength c.1.val := by
simp only [GroupLetters, Fintype.card_fun, Fintype.card_fin]
theorem groupClass_card_le {K tick : β} (allocation : Allocation) (m : β)
{sigma : Placement} (c : GroupClasses K tick sigma) :
Fintype.card (GroupPositions allocation m c) β€
AllFieldHistoryOrbitCount.basePopulationBound (K := K) (tick := tick) allocation * m :=
AllFieldHistoryOrbitCount.class_card_le allocation m (c.1.val, c.2)
theorem card_groupOrbit_le {K tick : β}
(allocation : Allocation) (m : β) (sigma : Placement) :
Nat.card (GroupOrbit (K := K) (tick := tick) allocation m sigma) β€
(AllFieldHistoryOrbitCount.basePopulationBound (K := K) (tick := tick) allocation * m + 1) ^
groupDegree K tick sigma := by
simpa only [GroupOrbit, groupDegree, card_groupLetters, two_mul] using
(card_pairOrbits_le_common_bound
(P := GroupPositions (K := K) (tick := tick) (sigma := sigma) allocation m)
(X := GroupLetters (K := K) (tick := tick) (sigma := sigma))
(Y := GroupLetters (K := K) (tick := tick) (sigma := sigma))
(AllFieldHistoryOrbitCount.basePopulationBound (K := K) (tick := tick) allocation * m)
(groupClass_card_le allocation m))
theorem card_groupOrbit_le_polynomial {K tick : β}
(allocation : Allocation) (m : β) (sigma : Placement) :
Nat.card (GroupOrbit (K := K) (tick := tick) allocation m sigma) β€
(AllFieldHistoryOrbitCount.basePopulationBound (K := K) (tick := tick) allocation + 1) ^
groupDegree K tick sigma * (m + 1) ^ groupDegree K tick sigma := by
refine (card_groupOrbit_le allocation m sigma).trans ?_
rw [β mul_pow]
apply Nat.pow_le_pow_left
nlinarith [Nat.zero_le
(AllFieldHistoryOrbitCount.basePopulationBound (K := K) (tick := tick) allocation)]
def groupOrbitPrefactor {K tick : β} (allocation : Allocation) (sigma : Placement) : β :=
((AllFieldHistoryOrbitCount.basePopulationBound (K := K) (tick := tick) allocation + 1 : β) : β) ^
groupDegree K tick sigma
theorem groupOrbitPrefactor_pos {K tick : β} (allocation : Allocation) (sigma : Placement) :
0 < groupOrbitPrefactor (K := K) (tick := tick) allocation sigma := by
unfold groupOrbitPrefactor
positivity
theorem card_groupOrbit_le_polynomial_real {K tick : β}
(allocation : Allocation) (m : β) (sigma : Placement) :
(Nat.card (GroupOrbit (K := K) (tick := tick) allocation m sigma) : β) β€
groupOrbitPrefactor (K := K) (tick := tick) allocation sigma *
((m : β) + 1) ^ groupDegree K tick sigma := by
unfold groupOrbitPrefactor
exact_mod_cast card_groupOrbit_le_polynomial (K := K) (tick := tick) allocation m sigma
theorem usedGroupOrbits_card_le_real {K tick : β} (allocation : Allocation) (m : β)
(sigma : Placement)
(s : Finset (GroupOrbit (K := K) (tick := tick) allocation m sigma)) :
(s.card : β) β€ groupOrbitPrefactor (K := K) (tick := tick) allocation sigma *
((m : β) + 1) ^ groupDegree K tick sigma := by
have hs : s.card β€ Nat.card (GroupOrbit (K := K) (tick := tick) allocation m sigma) := by
rw [Nat.card_eq_fintype_card]
exact s.card_le_univ
have hsreal : (s.card : β) β€
(Nat.card (GroupOrbit (K := K) (tick := tick) allocation m sigma) : β) := by
exact_mod_cast hs
exact hsreal.trans (card_groupOrbit_le_polynomial_real allocation m sigma)
theorem taggedUsedGroupOrbits_card_le_real {K tick : β}
(allocation : Allocation) (m : β) (sigma : Placement)
(s : Finset (Fin 3 Γ GroupOrbit (K := K) (tick := tick) allocation m sigma)) :
(s.card : β) β€ (3 * groupOrbitPrefactor (K := K) (tick := tick) allocation sigma) *
((m : β) + 1) ^ groupDegree K tick sigma := by
have hs : s.card β€ 3 * Nat.card
(GroupOrbit (K := K) (tick := tick) allocation m sigma) := by
simpa only [Fintype.card_prod, Fintype.card_fin, Nat.card_eq_fintype_card] using
s.card_le_univ
have hsreal : (s.card : β) β€ 3 * (Nat.card
(GroupOrbit (K := K) (tick := tick) allocation m sigma) : β) := by
exact_mod_cast hs
calc
_ β€ 3 * (Nat.card (GroupOrbit (K := K) (tick := tick) allocation m sigma) : β) := hsreal
_ β€ 3 * (groupOrbitPrefactor (K := K) (tick := tick) allocation sigma *
((m : β) + 1) ^ groupDegree K tick sigma) :=
mul_le_mul_of_nonneg_left (card_groupOrbit_le_polynomial_real allocation m sigma)
(by norm_num)
_ = _ := (mul_assoc _ _ _).symm
end MatrixMultiplication.AllFieldGroupOrbitCount
end
end
end MatrixAllFields
end OAI
import Mathlib
import OAI.LinearAlgebra.MatrixFields.Histories.HistoryPositions
import OAI.LinearAlgebra.MatrixFields.Tensors.CWStageCStatistics
namespace OAI
namespace MatrixAllFields
open scoped BigOperators Topology Polynomial
section
noncomputable section
namespace MatrixMultiplication.RecoverySupport
variable {K X Y Z : Type*} [Zero K] [Fintype X] [Fintype Y] [Fintype Z]
def support (Q : X β Y β Z β K) : Finset (X Γ Y Γ Z) := by
classical
exact Finset.univ.filter fun p => Q p.1 p.2.1 p.2.2 β 0
theorem support_card_le (Q : X β Y β Z β K) :
(support Q).card β€ Fintype.card X * Fintype.card Y * Fintype.card Z := by
classical
have h := Finset.card_filter_le (s := (Finset.univ : Finset (X Γ Y Γ Z)))
(p := fun p => Q p.1 p.2.1 p.2.2 β 0)
simpa only [support, Finset.card_univ, Fintype.card_prod, Nat.mul_assoc] using h
theorem support_card_le_exp (Q : X β Y β Z β K) {bX bY bZ : β} (N : β)
(hX : (Fintype.card X : β) β€ Real.exp (bX * N))
(hY : (Fintype.card Y : β) β€ Real.exp (bY * N))
(hZ : (Fintype.card Z : β) β€ Real.exp (bZ * N)) :
((support Q).card : β) β€ Real.exp ((bX + bY + bZ) * N) := by
have hcard : ((support Q).card : β) β€
(Fintype.card X : β) * Fintype.card Y * Fintype.card Z := by
exact_mod_cast support_card_le Q
calc
((support Q).card : β) β€
(Fintype.card X : β) * Fintype.card Y * Fintype.card Z := hcard
_ β€ (Real.exp (bX * N) * Real.exp (bY * N)) * Real.exp (bZ * N) :=
mul_le_mul (mul_le_mul hX hY (Nat.cast_nonneg _) (Real.exp_pos _).le)
hZ (Nat.cast_nonneg _) (mul_nonneg (Real.exp_pos _).le (Real.exp_pos _).le)
_ = Real.exp ((bX + bY + bZ) * N) := by
rw [β Real.exp_add, β Real.exp_add]
congr 1
ring
theorem word_card_eq_exp {d : β} (hd : 0 < d) (a N : β) :
(Fintype.card (Fin (a * N) β Fin d) : β) =
Real.exp (((a : β) * Real.log (d : β)) * N) := by
have hdr : 0 < (d : β) := by exact_mod_cast hd
simp only [Fintype.card_fun, Fintype.card_fin, Nat.cast_pow]
calc
(d : β) ^ (a * N) = Real.exp (((a * N : β) : β) * Real.log (d : β)) := by
rw [Real.exp_nat_mul, Real.exp_log hdr]
_ = Real.exp (((a : β) * Real.log (d : β)) * N) := by
simp only [Nat.cast_mul]
congr 1
ring
theorem card_le_exp_of_word_embedding {d : β} (hd : 0 < d) (a N : β)
(e : X βͺ (Fin (a * N) β Fin d)) :
(Fintype.card X : β) β€ Real.exp (((a : β) * Real.log (d : β)) * N) := by
rw [β word_card_eq_exp hd a N]
exact_mod_cast Fintype.card_le_of_injective e e.injective
theorem support_card_le_exp_of_word_embeddings (Q : X β Y β Z β K)
{d : β} (hd : 0 < d) (a N : β)
(ex : X βͺ (Fin (a * N) β Fin d))
(ey : Y βͺ (Fin (a * N) β Fin d))
(ez : Z βͺ (Fin (a * N) β Fin d)) :
((support Q).card : β) β€ Real.exp ((3 * (a : β) * Real.log (d : β)) * N) := by
have h := support_card_le_exp Q N
(card_le_exp_of_word_embedding hd a N ex)
(card_le_exp_of_word_embedding hd a N ey)
(card_le_exp_of_word_embedding hd a N ez)
convert h using 1
congr 1
ring
def cw5SupportRate (a : β) : β := 3 * (a : β) * Real.log 7 + 1
theorem cw5SupportRate_pos (a : β) : 0 < cw5SupportRate a := by
have hlog : 0 β€ Real.log 7 := Real.log_nonneg (by norm_num)
have h := mul_nonneg (mul_nonneg (by norm_num : (0 : β) β€ 3) (Nat.cast_nonneg a)) hlog
unfold cw5SupportRate
linarith
theorem cw5_support_card_le_exp (Q : X β Y β Z β K) (a N : β)
(ex : X βͺ (Fin (a * N) β Fin 7))
(ey : Y βͺ (Fin (a * N) β Fin 7))
(ez : Z βͺ (Fin (a * N) β Fin 7)) :
((support Q).card : β) β€ Real.exp (cw5SupportRate a * N) := by
apply (support_card_le_exp_of_word_embeddings Q (by norm_num) a N ex ey ez).trans
apply Real.exp_le_exp.mpr
unfold cw5SupportRate
simp only [Nat.cast_ofNat]
exact mul_le_mul_of_nonneg_right (le_add_of_nonneg_right zero_le_one) (Nat.cast_nonneg N)
end MatrixMultiplication.RecoverySupport