Download data/lean/OAI/LinearAlgebra/MatrixMultiplication/FieldConstruction/ScheduledYield.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 11.7 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/MatrixMultiplication/FieldConstruction/ScheduledYield.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/LinearAlgebra/MatrixMultiplication/FieldConstruction/ScheduledYield.lean
-
curl -L -o ScheduledYield.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/MatrixMultiplication/FieldConstruction/ScheduledYield.lean
11.7 kB
| import OAI.LinearAlgebra.MatrixMultiplication.FieldConstruction.NativeCapacity | |
| import OAI.LinearAlgebra.MatrixMultiplication.FieldConstruction.ActiveSums | |
| import OAI.LinearAlgebra.MatrixMultiplication.FieldConstruction.ActiveLaws | |
| import OAI.LinearAlgebra.MatrixMultiplication.FieldConstruction.InitialEntropy | |
| import OAI.LinearAlgebra.MatrixMultiplication.FieldConstruction.StageCCapacity | |
| import OAI.LinearAlgebra.MatrixMultiplication.Entropy.ConditionalContinuity | |
| import Mathlib.Topology.Order.OrderClosed | |
| namespace OAI | |
| /-! Tensor extraction over arbitrary fields and its asymptotic rate. -/ | |
| noncomputable section | |
| namespace MatrixMultiplication.AllFieldScheduledYield | |
| open MatrixMultiplication.Foundation AllFieldParameters AllFieldHistory AllFieldNativeCapacity | |
| open Filter | |
| open scoped BigOperators Topology | |
| def workCapacity {K : β} : Work K β Staggering.Capacity := | |
| shapeCapacity stageACapacity stageBCapacity stageCCapacity | |
| theorem workCapacity_stageC {K : β} (h : PartC K) (i : Fin 3) : | |
| workCapacity (Work.stageC h) i = finiteEntropy | |
| (AllFieldStageCCapacity.stageCMarginal (cParameterParent h) (cShapeParent h) | |
| (cPriority h i)) := by | |
| rw [AllFieldStageCCapacity.stageCMarginal_priority_entropy] | |
| rfl | |
| private theorem sum_interiorPairs (f : Shape Γ Shape β β) : | |
| (interiorPairs.map f).sum = | |
| (positiveSecond.map fun t => | |
| (((below t).filter positive).map fun u => f (t,u)).sum).sum := by | |
| unfold interiorPairs | |
| have h : β xs : List Shape, | |
| ((xs.flatMap fun t => ((below t).filter positive).map fun u => (t,u)).map f).sum = | |
| (xs.map fun t => (((below t).filter positive).map fun u => f (t,u)).sum).sum := by | |
| intro xs | |
| induction xs with | |
| | nil => simp | |
| | cons t xs ih => simp [ih, List.map_map, Function.comp_def] | |
| exact h positiveSecond | |
| theorem stageCSourceCapacity_native (allocation : Allocation) : | |
| stageCSourceCapacity allocation stageCCapacity = | |
| nativeLC (fun i => (allocation.mass i : β)) := by | |
| funext i | |
| unfold stageCSourceCapacity stageCSourceSum nativeLC | |
| rw [sum_interiorPairs] | |
| apply congrArg List.sum | |
| apply List.map_congr_left | |
| intro t ht | |
| apply congrArg List.sum | |
| apply List.map_congr_left | |
| intro u hu | |
| rw [show (β part : Fin 3, (allocation.mass part : β) * stageCCapacity t u part i) = | |
| (1 - (allocation.mass i : β)) * Real.log 2 + | |
| (allocation.mass i : β) * binaryEntropyRate (binaryParameter t u) from | |
| AllFieldStageCCapacity.allocation_capacity allocation (binaryParameter t u) i] | |
| rfl | |
| theorem active_native_capacity (K tick : β) (allocation : Allocation) : | |
| activeAggregateCapacity allocation tick (workCapacity (K := K)) = | |
| FiniteSchedule.tickCapacity K nativeLA nativeLB | |
| (nativeLC (fun i => (allocation.mass i : β))) tick := by | |
| rw [workCapacity, activeAggregateCapacity_shapeCapacity, | |
| stageCSourceCapacity_native] | |
| rfl | |
| theorem physical_order_native_capacity (K tick : β) (allocation : Allocation) | |
| (sigma : Placement) : | |
| physicalTickCapacity allocation tick (workCapacity (K := K)) sigma = | |
| fun i => (1 / 6 : β) * FiniteSchedule.tickCapacity K nativeLA nativeLB | |
| (nativeLC (fun i => (allocation.mass i : β))) tick i := by | |
| rw [physicalTickCapacity_eq_sixth, active_native_capacity] | |
| theorem order_capacity_eq_physical (K tick : β) (allocation : Allocation) | |
| (sigma : Placement) (i : Fin 3) : | |
| (β h : ActiveOrder K tick sigma, | |
| AllFieldActiveLaws.orderMass allocation h * workCapacity h.val.val.1 i) = | |
| physicalTickCapacity allocation tick (workCapacity (K := K)) sigma i := by | |
| rw [physicalTickCapacity_eq_sixth] | |
| rw [β (canonicalActiveEquivOrder K tick sigma).sum_comp | |
| (fun h : ActiveOrder K tick sigma => | |
| AllFieldActiveLaws.orderMass allocation h * workCapacity h.val.val.1 i)] | |
| simp only [AllFieldActiveLaws.orderMass, canonicalActiveEquivOrder, amount, | |
| Rat.cast_div, Rat.cast_ofNat, activeAggregateCapacity, | |
| PhysicalOrders.aggregateCapacity, workAmount] | |
| rw [Finset.mul_sum] | |
| apply Finset.sum_congr rfl | |
| intro h hh | |
| change ((canonicalAmount allocation h.val.source : β) / 6) * | |
| workCapacity h.val i = (1 / 6 : β) * | |
| ((canonicalAmount allocation h.val.source : β) * workCapacity h.val i) | |
| ring | |
| theorem order_capacity_eq_native (K tick : β) (allocation : Allocation) | |
| (sigma : Placement) (i : Fin 3) : | |
| (β h : ActiveOrder K tick sigma, | |
| AllFieldActiveLaws.orderMass allocation h * workCapacity h.val.val.1 i) = | |
| (1 / 6 : β) * FiniteSchedule.tickCapacity K nativeLA nativeLB | |
| (nativeLC (fun j => (allocation.mass j : β))) tick i := by | |
| rw [order_capacity_eq_physical, physical_order_native_capacity] | |
| theorem order_dilation_capacity (K tick : β) (allocation : Allocation) | |
| (sigma : Placement) (i : Fin 3) : | |
| (β h : ActiveOrder K tick sigma, | |
| ((populationLength (K := K) allocation 1 : β) * | |
| AllFieldActiveLaws.orderMass allocation h) * workCapacity h.val.val.1 i) = | |
| (populationLength (K := K) allocation 1 : β) * | |
| ((1 / 6 : β) * FiniteSchedule.tickCapacity K nativeLA nativeLB | |
| (nativeLC (fun j => (allocation.mass j : β))) tick i) := by | |
| simp_rw [mul_assoc] | |
| rw [β Finset.mul_sum, order_capacity_eq_native] | |
| def physicalYield (K : β) (allocation : Allocation) : β := | |
| β tick β Finset.range (K + 2), β sigma : Placement, | |
| Staggering.minCapacity (physicalTickCapacity allocation tick | |
| (workCapacity (K := K)) sigma) | |
| def scheduledYield (K : β) (allocation : Fin 3 β β) : β := | |
| β tick β Finset.range (K + 2), Staggering.minCapacity | |
| (FiniteSchedule.tickCapacity K nativeLA nativeLB (nativeLC allocation) tick) | |
| theorem physicalYield_eq_scheduled (K : β) (allocation : Allocation) : | |
| physicalYield K allocation = scheduledYield K (fun i => (allocation.mass i : β)) := by | |
| unfold physicalYield scheduledYield | |
| apply Finset.sum_congr rfl | |
| intro tick htick | |
| rw [sum_physicalTick_minima, active_native_capacity] | |
| theorem balanced_scheduledYield (K : β) (hK : 2 β€ K) (hgap : nativeB < nativeHigh) : | |
| scheduledYield K nativeLambda = (K : β) * nativeCstar - nativeBeta := | |
| FiniteSchedule.finite_schedule_yield K hK nativeLA nativeLB | |
| (nativeLC nativeLambda) nativeCstar (native_balanced hgap) | |
| theorem nativeLC_tendsto {J : Type*} {filter : Filter J} | |
| {allocation : J β Fin 3 β β} {limit : Fin 3 β β} | |
| (h : β i, Tendsto (fun j => allocation j i) filter (π (limit i))) (i : Fin 3) : | |
| Tendsto (fun j => nativeLC (allocation j) i) filter (π (nativeLC limit i)) := by | |
| simp_rw [nativeLC_expansion] | |
| exact tendsto_const_nhds.sub (((h i).const_mul 3).mul_const (nativeHigh - nativeB)) | |
| theorem tickCapacity_tendsto (K tick : β) {J : Type*} {filter : Filter J} | |
| {allocation : J β Fin 3 β β} {limit : Fin 3 β β} | |
| (h : β i, Tendsto (fun j => allocation j i) filter (π (limit i))) (i : Fin 3) : | |
| Tendsto (fun j => FiniteSchedule.tickCapacity K nativeLA nativeLB | |
| (nativeLC (allocation j)) tick i) filter | |
| (π (FiniteSchedule.tickCapacity K nativeLA nativeLB (nativeLC limit) tick i)) := by | |
| have hc : Tendsto (fun j => if FiniteSchedule.stageActive K tick 2 then | |
| nativeLC (allocation j) i else 0) filter | |
| (π (if FiniteSchedule.stageActive K tick 2 then nativeLC limit i else 0)) := by | |
| by_cases hh : FiniteSchedule.stageActive K tick 2 | |
| Β· simpa only [hh, ite_true] using nativeLC_tendsto h i | |
| Β· simpa only [hh, ite_false] using (tendsto_const_nhds : | |
| Tendsto (fun _ : J => (0 : β)) filter (π 0)) | |
| exact (tendsto_const_nhds.add tendsto_const_nhds).add hc | |
| theorem scheduledYield_tendsto (K : β) {J : Type*} {filter : Filter J} | |
| {allocation : J β Fin 3 β β} {limit : Fin 3 β β} | |
| (h : β i, Tendsto (fun j => allocation j i) filter (π (limit i))) : | |
| Tendsto (fun j => scheduledYield K (allocation j)) filter | |
| (π (scheduledYield K limit)) := by | |
| unfold scheduledYield | |
| apply tendsto_finsetSum | |
| intro tick htick | |
| exact (tickCapacity_tendsto K tick h 0).min | |
| ((tickCapacity_tendsto K tick h 1).min (tickCapacity_tendsto K tick h 2)) | |
| theorem physicalYield_tendsto_balanced (K : β) (hK : 2 β€ K) | |
| (hgap : nativeB < nativeHigh) (allocation : β β Allocation) | |
| (h : β i, Tendsto (fun j => ((allocation j).mass i : β)) atTop (π (nativeLambda i))) : | |
| Tendsto (fun j => physicalYield K (allocation j)) atTop | |
| (π ((K : β) * nativeCstar - nativeBeta)) := by | |
| simp_rw [physicalYield_eq_scheduled] | |
| rw [β balanced_scheduledYield K hK hgap] | |
| exact scheduledYield_tendsto K h | |
| theorem exists_balanced_allocation_sequence (hgap : nativeB < nativeHigh) | |
| (hfeas : β i, nativeCstar - (nativeLA i + nativeLB i) < nativeHigh) : | |
| β allocation : β β Allocation, | |
| β i, Tendsto (fun j => ((allocation j).mass i : β)) atTop (π (nativeLambda i)) := by | |
| have hpos (i : Fin 3) : 0 < nativeLambda i := | |
| Staggering.balanceFraction_pos nativeLA nativeLB nativeHigh nativeB hgap hfeas i | |
| let p : FiniteLaw (Fin 3) := { | |
| mass := nativeLambda | |
| nonneg := fun i => (hpos i).le | |
| total := Staggering.sum_balanceFraction nativeLA nativeLB nativeHigh nativeB hgap } | |
| obtain β¨q, hqβ© := ConditionalLabels.exists_rational_law_sequence p | |
| have he : βαΆ j in atTop, β i, 0 < (q j).toFiniteLaw.mass i := | |
| Filter.eventually_all.mpr (fun i => (hq i).eventually_const_lt (hpos i)) | |
| obtain β¨N, hNβ© := Filter.eventually_atTop.mp he | |
| let allocation : β β Allocation := fun j => { | |
| mass := (q (j + N)).mass | |
| positive := fun i => by | |
| have hi := hN (j + N) (by omega) i | |
| change (0 : β) < ((q (j + N)).mass i : β) at hi | |
| exact_mod_cast hi | |
| total := (q (j + N)).total } | |
| refine β¨allocation, fun i => ?_β© | |
| exact (hq i).comp (tendsto_add_atTop_nat N) | |
| theorem exists_physicalYield_limit (K : β) (hK : 2 β€ K) | |
| (hgap : nativeB < nativeHigh) | |
| (hfeas : β i, nativeCstar - (nativeLA i + nativeLB i) < nativeHigh) : | |
| β allocation : β β Allocation, | |
| Tendsto (fun j => physicalYield K (allocation j)) atTop | |
| (π ((K : β) * nativeCstar - nativeBeta)) := by | |
| obtain β¨allocation, haβ© := exists_balanced_allocation_sequence hgap hfeas | |
| exact β¨allocation, physicalYield_tendsto_balanced K hK hgap allocation haβ© | |
| theorem initial_capacity (K : β) : | |
| JointOrdinaryPopulationSelection.entropyRate (fun _ : Fin K => (1 : β)) | |
| (fun _ : Fin K => AllFieldInitialEntropy.orderedInitialLaw) - | |
| JointOrdinaryPopulationSelection.degreeRate (fun _ : Fin K => (1 : β)) | |
| (fun _ : Fin K => AllFieldInitialEntropy.orderedInitialLaw) = | |
| (K : β) * AllFieldInitialEntropy.nativeH0 := | |
| AllFieldInitialEntropy.ordinary_capacity_all_lots K | |
| theorem initial_dilation_capacity (K : β) (allocation : Allocation) : | |
| JointOrdinaryPopulationSelection.entropyRate | |
| (fun _ : Fin K => (populationLength (K := K) allocation 1 : β)) | |
| (fun _ : Fin K => AllFieldInitialEntropy.orderedInitialLaw) - | |
| JointOrdinaryPopulationSelection.degreeRate | |
| (fun _ : Fin K => (populationLength (K := K) allocation 1 : β)) | |
| (fun _ : Fin K => AllFieldInitialEntropy.orderedInitialLaw) = | |
| (populationLength (K := K) allocation 1 : β) * | |
| ((K : β) * AllFieldInitialEntropy.nativeH0) := by | |
| simp only [JointOrdinaryPopulationSelection.entropyRate, | |
| JointOrdinaryPopulationSelection.degreeRate, JointOrdinaryPopulationSelection.sideDegreeRate, | |
| AllFieldInitialEntropy.orderedInitialLaw_side_entropy, Finset.sum_const, | |
| Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, max_self] | |
| ring | |
| end MatrixMultiplication.AllFieldScheduledYield | |
| end | |
| end OAI | |