Download data/lean/OAI/Combinatorics/Permanent/Stability.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 7.68 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/Permanent/Stability.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/Permanent/Stability.lean
-
curl -L -o Stability.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/Permanent/Stability.lean
7.68 kB
| import OAI.Combinatorics.Permanent.Model | |
| namespace OAI | |
| noncomputable section | |
| namespace FourRow | |
| open scoped BigOperators | |
| /- Quantitative exponent-two stability estimates. -/ | |
| def rowSq (a : Site β β) : β := β j, a j ^ 2 | |
| def rowDist (a : Site β β) : β := β j, (a j - 1) ^ 2 | |
| def rowDot (a b : Site β β) : β := β j, a j * b j | |
| def pairEntries (a b : Site β β) : Fin 6 β β := | |
| ![a 0 * b 1 + a 1 * b 0, | |
| a 0 * b 2 + a 2 * b 0, | |
| a 0 * b 3 + a 3 * b 0, | |
| a 1 * b 2 + a 2 * b 1, | |
| a 1 * b 3 + a 3 * b 1, | |
| a 2 * b 3 + a 3 * b 2] | |
| def pairSq (a b : Site β β) : β := β j, pairEntries a b j ^ 2 | |
| theorem rowSq_nonneg (a : Site β β) : 0 β€ rowSq a := | |
| Finset.sum_nonneg fun _ _ => sq_nonneg _ | |
| theorem rowDist_nonneg (a : Site β β) : 0 β€ rowDist a := | |
| Finset.sum_nonneg fun _ _ => sq_nonneg _ | |
| theorem pairSq_nonneg (a b : Site β β) : 0 β€ pairSq a b := | |
| Finset.sum_nonneg fun _ _ => sq_nonneg _ | |
| theorem pairSq_identity (a b : Site β β) : | |
| pairSq a b = rowSq a * rowSq b + rowDot a b ^ 2 - | |
| 2 * β j, (a j * b j) ^ 2 := by | |
| simp only [pairSq, pairEntries, rowSq, rowDot, Fin.sum_univ_six, | |
| Fin.sum_univ_four, Matrix.cons_val_zero, Matrix.cons_val_one, | |
| Matrix.cons_val] | |
| ring | |
| theorem pairSq_comm (a b : Site β β) : pairSq a b = pairSq b a := by | |
| simp only [pairSq_identity, rowDot, mul_comm] | |
| theorem rowDot_sq_le (a b : Site β β) : | |
| rowDot a b ^ 2 β€ rowSq a * rowSq b := | |
| Finset.sum_mul_sq_le_sq_mul_sq Finset.univ a b | |
| theorem rowDot_sq_le_four (a b : Site β β) : | |
| rowDot a b ^ 2 β€ 4 * β j, (a j * b j) ^ 2 := by | |
| have h := Finset.sum_mul_sq_le_sq_mul_sq Finset.univ | |
| (fun j : Site => (1 : β)) (fun j => a j * b j) | |
| simpa [rowDot] using h | |
| theorem pair_stability_one (a b : Site β β) | |
| (ha : β j, 0 β€ a j) (hb : β j, 0 β€ b j) | |
| (haq : rowSq a = 4) (hbq : rowSq b = 4) : | |
| rowDist a β€ 9 * (24 - pairSq a b) := by | |
| let t := rowDot a b | |
| let s := β j, (a j * b j) ^ 2 | |
| let d := β j, (a j - b j) ^ 2 | |
| let e := β j, (a j * b j - 1) ^ 2 | |
| let D := 24 - pairSq a b | |
| have ht0 : 0 β€ t := Finset.sum_nonneg fun j _ => mul_nonneg (ha j) (hb j) | |
| have ht2 : t ^ 2 β€ 16 := by | |
| have h := rowDot_sq_le a b | |
| rw [haq, hbq] at h | |
| norm_num at h | |
| exact h | |
| have ht4 : t β€ 4 := by nlinarith | |
| have htprod : 0 β€ t * (4 - t) := mul_nonneg ht0 (by linarith) | |
| have hts : t ^ 2 β€ 4 * s := rowDot_sq_le_four a b | |
| have hD : D = 8 - t ^ 2 + 2 * s := by | |
| dsimp [D, t, s] | |
| rw [pairSq_identity, haq, hbq] | |
| ring | |
| have hd : d = 8 - 2 * t := by | |
| have h : d = rowSq a + rowSq b - 2 * t := by | |
| dsimp [d, rowSq, t, rowDot] | |
| simp only [Fin.sum_univ_four] | |
| ring | |
| rw [h, haq, hbq] | |
| ring | |
| have he : e = s - 2 * t + 4 := by | |
| dsimp [e, s, t, rowDot] | |
| simp only [Fin.sum_univ_four] | |
| ring | |
| have hdD : d β€ D := by nlinarith | |
| have heD : 2 * e β€ D := by nlinarith | |
| have hpoint (j : Site) : (a j - 1) ^ 2 β€ | |
| 8 * (a j - b j) ^ 2 + 2 * (a j * b j - 1) ^ 2 := by | |
| have haj : a j ^ 2 β€ 4 := by | |
| calc | |
| a j ^ 2 β€ rowSq a := | |
| Finset.single_le_sum (fun i _ => sq_nonneg (a i)) (Finset.mem_univ j) | |
| _ = 4 := haq | |
| have h1 : (a j - 1) ^ 2 β€ (a j ^ 2 - 1) ^ 2 := by | |
| nlinarith [mul_nonneg (mul_nonneg (ha j) (show 0 β€ a j + 2 by linarith [ha j])) | |
| (sq_nonneg (a j - 1))] | |
| have h2 : (a j ^ 2 - a j * b j) ^ 2 β€ 4 * (a j - b j) ^ 2 := by | |
| nlinarith [mul_nonneg (show 0 β€ 4 - a j ^ 2 by linarith) | |
| (sq_nonneg (a j - b j))] | |
| nlinarith [sq_nonneg (a j ^ 2 - 2 * a j * b j + 1)] | |
| have hs := Finset.sum_le_sum (fun j (_ : j β (Finset.univ : Finset Site)) => hpoint j) | |
| have hbound : rowDist a β€ 8 * d + 2 * e := by | |
| simpa only [rowDist, Finset.sum_add_distrib, β Finset.mul_sum] using hs | |
| linarith | |
| theorem pair_stability (a b : Site β β) | |
| (ha : β j, 0 β€ a j) (hb : β j, 0 β€ b j) | |
| (haq : rowSq a = 4) (hbq : rowSq b = 4) : | |
| rowDist a + rowDist b β€ 18 * (24 - pairSq a b) := by | |
| have h1 := pair_stability_one a b ha hb haq hbq | |
| have h2 := pair_stability_one b a hb ha hbq haq | |
| rw [pairSq_comm b a] at h2 | |
| linarith | |
| theorem sum_perm_succ {n : β} (f : Equiv.Perm (Fin (n + 1)) β β) : | |
| β Ο, f Ο = β i : Fin (n + 1), β Ο : Equiv.Perm (Fin n), | |
| f (Equiv.Perm.decomposeFin.symm (i, Ο)) := by | |
| rw [β Equiv.sum_comp Equiv.Perm.decomposeFin.symm f] | |
| exact Fintype.sum_prod_type _ | |
| theorem decompose4_two (i : Fin 4) (e : Equiv.Perm (Fin 3)) : | |
| Equiv.Perm.decomposeFin.symm (i, e) 2 = Equiv.swap 0 i (e 1).succ := | |
| Equiv.Perm.decomposeFin_symm_apply_succ e i 1 | |
| theorem decompose4_three (i : Fin 4) (e : Equiv.Perm (Fin 3)) : | |
| Equiv.Perm.decomposeFin.symm (i, e) 3 = Equiv.swap 0 i (e 2).succ := | |
| Equiv.Perm.decomposeFin_symm_apply_succ e i 2 | |
| theorem decompose3_two (i : Fin 3) (e : Equiv.Perm (Fin 2)) : | |
| Equiv.Perm.decomposeFin.symm (i, e) 2 = Equiv.swap 0 i (e 1).succ := | |
| Equiv.Perm.decomposeFin_symm_apply_succ e i 1 | |
| theorem permanent_pair_identity (f : Functions) : | |
| (β Ο : Perm, β i, f i (Ο i)) = | |
| β j : Fin 6, pairEntries (f 0) (f 1) j * | |
| pairEntries (f 2) (f 3) (Fin.rev j) := by | |
| change (β Ο : Equiv.Perm (Fin 4), β i : Fin 4, f i (Ο i)) = _ | |
| simp only [sum_perm_succ, Fin.sum_univ_succ, Fintype.sum_unique, | |
| Fin.prod_univ_four, pairEntries] | |
| simp [decompose4_two, decompose4_three, decompose3_two, | |
| Equiv.swap_apply_def, Fin.rev] | |
| ring | |
| def uniformLaw : Law := fun _ => 1 / 24 | |
| def totalDist (f : Functions) : β := β i, rowDist (f i) | |
| theorem totalDist_nonneg (f : Functions) : 0 β€ totalDist f := | |
| Finset.sum_nonneg fun i _ => rowDist_nonneg (f i) | |
| theorem pairSq_le (a b : Site β β) | |
| (ha : β j, 0 β€ a j) (hb : β j, 0 β€ b j) | |
| (haq : rowSq a = 4) (hbq : rowSq b = 4) : pairSq a b β€ 24 := by | |
| have h := pair_stability_one a b ha hb haq hbq | |
| have h0 := rowDist_nonneg a | |
| linarith | |
| theorem uniform_expectation_eq (f : Functions) : | |
| permanentExpectation uniformLaw f = (β Ο : Perm, β i, f i (Ο i)) / 24 := by | |
| simp only [permanentExpectation, uniformLaw, β Finset.mul_sum] | |
| ring | |
| theorem normalized_uniform_stability (f : Functions) | |
| (hf : β i j, 0 β€ f i j) (hn : β i, rowSq (f i) = 4) : | |
| permanentExpectation uniformLaw f β€ 1 - totalDist f / 1728 := by | |
| let P := permanentExpectation uniformLaw f | |
| let U := pairSq (f 0) (f 1) | |
| let V := pairSq (f 2) (f 3) | |
| have hU0 : 0 β€ U := pairSq_nonneg _ _ | |
| have hV0 : 0 β€ V := pairSq_nonneg _ _ | |
| have hU : U β€ 24 := pairSq_le _ _ (hf 0) (hf 1) (hn 0) (hn 1) | |
| have hV : V β€ 24 := pairSq_le _ _ (hf 2) (hf 3) (hn 2) (hn 3) | |
| have hcs := Finset.sum_mul_sq_le_sq_mul_sq Finset.univ | |
| (pairEntries (f 0) (f 1)) (fun j => pairEntries (f 2) (f 3) (Fin.rev j)) | |
| have hrev : (β j : Fin 6, pairEntries (f 2) (f 3) (Fin.rev j) ^ 2) = V := | |
| Equiv.sum_comp Fin.revPerm (fun j => pairEntries (f 2) (f 3) j ^ 2) | |
| rw [β permanent_pair_identity, hrev] at hcs | |
| change (β Ο : Perm, β i, f i (Ο i)) ^ 2 β€ U * V at hcs | |
| have hP2 : 576 * P ^ 2 β€ U * V := by | |
| dsimp [P] | |
| rw [uniform_expectation_eq] | |
| nlinarith [hcs] | |
| have hUV : U * V β€ 12 * (U + V) := by | |
| nlinarith [mul_nonneg hU0 (show 0 β€ 24 - V by linarith), | |
| mul_nonneg hV0 (show 0 β€ 24 - U by linarith)] | |
| have hd : totalDist f β€ 18 * (48 - U - V) := by | |
| have h1 := pair_stability _ _ (hf 0) (hf 1) (hn 0) (hn 1) | |
| have h2 := pair_stability _ _ (hf 2) (hf 3) (hn 2) (hn 3) | |
| simp only [totalDist, Fin.sum_univ_four] | |
| dsimp [U, V] | |
| linarith | |
| change P β€ _ | |
| nlinarith [sq_nonneg (P - 1)] | |
| end FourRow | |
| end | |
| end OAI | |