Download data/lean/OAI/LinearAlgebra/MatrixMultiplication/Separation/ComplexFiniteControl.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 5.99 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/MatrixMultiplication/Separation/ComplexFiniteControl.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/LinearAlgebra/MatrixMultiplication/Separation/ComplexFiniteControl.lean
-
curl -L -o ComplexFiniteControl.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/MatrixMultiplication/Separation/ComplexFiniteControl.lean
5.99 kB
| import Mathlib.Data.Fintype.EquivFin | |
| import Mathlib.Data.Fintype.BigOperators | |
| import Mathlib.Logic.Equiv.Sum | |
| import Mathlib.Algebra.Order.BigOperators.Ring.Finset | |
| import Mathlib.Algebra.BigOperators.Group.Finset.Piecewise | |
| import Mathlib.Combinatorics.Additive.AP.Three.Defs | |
| import Mathlib.Basic.Real.Basic | |
| import Mathlib.Data.Rat.Lemmas | |
| import Mathlib.Tactic.FieldSimp | |
| import Mathlib.Tactic.Linarith | |
| import Mathlib.Tactic.Ring | |
| namespace OAI | |
| /-! Finite type counts, hierarchy separation and tensor execution bounds. -/ | |
| namespace MatrixMultiplication.Foundation | |
| namespace FiniteControl | |
| open scoped BigOperators | |
| theorem every_path_safe {State : Type*} (Safe : β β State β Prop) | |
| (Allows : β β State β State β Prop) (n : β) (path : β β State) | |
| (initial : Safe 0 (path 0)) | |
| (closed : β t < n, β s s', Safe t s β Allows t s s' β Safe (t + 1) s') | |
| (steps : β t < n, Allows t (path t) (path (t + 1))) : | |
| β t β€ n, Safe t (path t) := by | |
| intro t | |
| induction t with | |
| | zero => intro _; exact initial | |
| | succ t ih => | |
| intro ht | |
| have htn : t < n := Nat.lt_of_succ_le ht | |
| exact closed t htn (path t) (path (t + 1)) | |
| (ih (Nat.le_of_lt htn)) (steps t htn) | |
| theorem exists_population_preserving_equiv {I J Node : Type*} | |
| [Fintype I] [Fintype J] [DecidableEq Node] | |
| (f : I β Node) (g : J β Node) | |
| (counts : β node, Fintype.card {i // f i = node} = | |
| Fintype.card {j // g j = node}) : | |
| β e : I β J, β i, g (e i) = f i := by | |
| classical | |
| let ef : β node, {i // f i = node} β {j // g j = node} := | |
| fun node => Fintype.equivOfCardEq (counts node) | |
| refine β¨(Equiv.sigmaFiberEquiv f).symm.trans | |
| ((Equiv.sigmaCongrRight ef).trans (Equiv.sigmaFiberEquiv g)), ?_β© | |
| intro i | |
| exact (ef (f i) β¨i, rflβ©).property | |
| theorem population_product_eq {I J Node M : Type*} | |
| [Fintype I] [Fintype J] [DecidableEq Node] [CommMonoid M] | |
| (f : I β Node) (g : J β Node) | |
| (counts : β node, Fintype.card {i // f i = node} = | |
| Fintype.card {j // g j = node}) (cost : Node β M) : | |
| (β i, cost (f i)) = β j, cost (g j) := by | |
| obtain β¨e, heβ© := exists_population_preserving_equiv f g counts | |
| calc | |
| (β i, cost (f i)) = β i, cost (g (e i)) := by | |
| apply Finset.prod_congr rfl | |
| intro i _ | |
| rw [he i] | |
| _ = β j, cost (g j) := e.prod_comp (fun j => cost (g j)) | |
| theorem exists_common_bank_multiple {Node : Type*} [Fintype Node] | |
| (denominator blockSize : Node β β) | |
| (denominator_pos : β node, 0 < denominator node) | |
| (blockSize_pos : β node, 0 < blockSize node) : | |
| β bank : β, 0 < bank β§ | |
| β node, denominator node * blockSize node β£ bank := by | |
| classical | |
| refine β¨β node, denominator node * blockSize node, ?_, ?_β© | |
| Β· exact Finset.prod_pos fun node _ => | |
| Nat.mul_pos (denominator_pos node) (blockSize_pos node) | |
| Β· intro node | |
| exact Finset.dvd_prod_of_mem (fun node => denominator node * blockSize node) | |
| (Finset.mem_univ node) | |
| theorem exists_exact_rational_tiling {Node : Type*} [Fintype Node] | |
| (weight : Node β β) (nonnegative : β node, 0 β€ weight node) | |
| (blockSize : Node β β) (blockSize_pos : β node, 0 < blockSize node) : | |
| β bank : β, 0 < bank β§ β node, β copies : β, | |
| (bank : β) * weight node = (copies * blockSize node : β) := by | |
| obtain β¨bank, bank_pos, divisibleβ© := exists_common_bank_multiple | |
| (fun node => (weight node).den) blockSize | |
| (fun node => (weight node).den_pos) blockSize_pos | |
| refine β¨bank, bank_pos, ?_β© | |
| intro node | |
| obtain β¨multiple, hmultipleβ© := divisible node | |
| refine β¨multiple * (weight node).num.toNat, ?_β© | |
| have hnum : ((weight node).num.toNat : β) = ((weight node).num : β) := by | |
| exact_mod_cast Int.toNat_of_nonneg (Rat.num_nonneg.mpr (nonnegative node)) | |
| have hden : ((weight node).den : β) β 0 := by | |
| exact_mod_cast (weight node).den_ne_zero | |
| calc | |
| (bank : β) * weight node = | |
| (bank : β) * (((weight node).num : β) / ((weight node).den : β)) := by | |
| rw [(weight node).num_div_den] | |
| _ = ((multiple * (weight node).num.toNat) * blockSize node : β) := by | |
| rw [hmultiple] | |
| push_cast | |
| rw [hnum] | |
| field_simp [hden] | |
| theorem target_relation_of_windows (a b c : β€) (x y z d : β) | |
| (hd : 0 < d) (tight : x + y + z = 0) | |
| (hx : |x - (a : β) * d| β€ d / 10) | |
| (hy : |y - (b : β) * d| β€ d / 10) | |
| (hz : |z + 2 * (c : β) * d| β€ d / 10) : | |
| a + b = c + c := by | |
| obtain β¨hxβ, hxββ© := abs_le.mp hx | |
| obtain β¨hyβ, hyββ© := abs_le.mp hy | |
| obtain β¨hzβ, hzββ© := abs_le.mp hz | |
| let k : β€ := a + b - 2 * c | |
| have hkcast : (k : β) = (a : β) + (b : β) - 2 * (c : β) := by | |
| simp [k] | |
| have hlow : -(1 : β) < (k : β) := by | |
| by_contra hn | |
| have hn' : (k : β) β€ -1 := le_of_not_gt hn | |
| have hm := mul_le_mul_of_nonneg_right hn' (le_of_lt hd) | |
| rw [hkcast] at hm | |
| nlinarith | |
| have hhigh : (k : β) < 1 := by | |
| by_contra hn | |
| have hn' : 1 β€ (k : β) := le_of_not_gt hn | |
| have hm := mul_le_mul_of_nonneg_right hn' (le_of_lt hd) | |
| rw [hkcast] at hm | |
| nlinarith | |
| have hsmall : |(k : β)| < 1 := abs_lt.mpr β¨hlow, hhighβ© | |
| have hsmallInt : |k| < 1 := by exact_mod_cast hsmall | |
| have hk : k = 0 := Int.abs_lt_one_iff.mp hsmallInt | |
| dsimp [k] at hk | |
| linarith | |
| theorem synchronized_targets_of_windows (targets : Set β€) | |
| (free : ThreeAPFree targets) (a b c : β€) | |
| (ha : a β targets) (hb : b β targets) (hc : c β targets) | |
| (x y z d : β) (hd : 0 < d) (tight : x + y + z = 0) | |
| (hx : |x - (a : β) * d| β€ d / 10) | |
| (hy : |y - (b : β) * d| β€ d / 10) | |
| (hz : |z + 2 * (c : β) * d| β€ d / 10) : | |
| a = b β§ a = c := by | |
| have hrelation := target_relation_of_windows a b c x y z d hd tight hx hy hz | |
| have hac : a = c := free ha hc hb hrelation | |
| exact β¨by linarith, hacβ© | |
| end FiniteControl | |
| end MatrixMultiplication.Foundation | |
| end OAI | |