Download data/lean/OAI/Probability/BinarySweep/Processes/SupportTimeBoundBounds.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 8.12 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/BinarySweep/Processes/SupportTimeBoundBounds.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/BinarySweep/Processes/SupportTimeBoundBounds.lean
-
curl -L -o SupportTimeBoundBounds.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/BinarySweep/Processes/SupportTimeBoundBounds.lean
8.12 kB
| import Mathlib | |
| import OAI.Probability.BinarySweep.Processes.Basic | |
| namespace OAI | |
| noncomputable section | |
| open scoped BigOperators | |
| namespace BinaryCoordinateSweeps | |
| theorem supportTimeBound_bounds (d : β) : | |
| (2 : β) * (d + 1) - 6 β€ supportTimeBound d β§ | |
| supportTimeBound d β€ (2 : β) * (d + 1) := by | |
| let N : β := 2 ^ (d + 1) | |
| have hN : (2 : β) β€ N := by | |
| dsimp [N] | |
| rw [Nat.cast_pow, Nat.cast_ofNat, pow_succ] | |
| have : (1 : β) β€ (2 : β) ^ d := one_le_powβ (by norm_num) | |
| linarith | |
| have hNp : (0 : β) < N := by linarith | |
| have hNne : N β 0 := by exact_mod_cast hNp.ne' | |
| have hfac : (0 : β) < N.factorial := by positivity | |
| have hlog : (0 : β) < Real.log 2 := Real.log_pos (by norm_num) | |
| have hhalf : (1 / 2 : β) β€ Real.log 2 := by | |
| have := Real.one_sub_inv_le_log_of_pos (x := (2 : β)) (by norm_num) | |
| norm_num at this β’ | |
| exact this | |
| have hlogN : Real.log (N : β) = ((d : β) + 1) * Real.log 2 := by | |
| simp [N, Real.log_pow] | |
| have hlogNN : 0 β€ Real.log (N : β) := Real.log_nonneg (by linarith) | |
| have hpi : 0 β€ Real.log (2 * Real.pi) := | |
| Real.log_nonneg (by linarith [Real.pi_gt_three]) | |
| have hst := Stirling.le_log_factorial_stirling hNne | |
| have hfaclow : (N : β) * Real.log N - N β€ Real.log (N.factorial : β) := by | |
| linarith | |
| have hfacup : Real.log (N.factorial : β) β€ (N : β) * Real.log N := by | |
| have h := Real.log_le_log hfac (show (N.factorial : β) β€ (N : β) ^ N by | |
| exact_mod_cast Nat.factorial_le_pow N) | |
| rwa [Real.log_pow] at h | |
| have hconstlow : -(1 : β) β€ Real.log (3 / 4 : β) := by | |
| have := Real.one_sub_inv_le_log_of_pos (x := (3 / 4 : β)) (by norm_num) | |
| norm_num at this | |
| linarith | |
| have hconstup : Real.log (3 / 4 : β) β€ 0 := Real.log_nonpos (by norm_num) (by norm_num) | |
| have hL : Real.log (3 * (N.factorial : β) / 4) = | |
| Real.log (N.factorial : β) + Real.log (3 / 4 : β) := by | |
| rw [show 3 * (N.factorial : β) / 4 = (N.factorial : β) * (3 / 4) by ring] | |
| exact Real.log_mul hfac.ne' (by norm_num) | |
| have hlow : (N : β) * (((d : β) + 1) * Real.log 2) - N - 1 β€ | |
| Real.log (3 * (N.factorial : β) / 4) := by | |
| rw [hL] | |
| rw [hlogN] at hfaclow | |
| linarith | |
| have hup : Real.log (3 * (N.factorial : β) / 4) β€ | |
| (N : β) * (((d : β) + 1) * Real.log 2) := by | |
| rw [hL] | |
| rw [hlogN] at hfacup | |
| linarith | |
| have hrewrite : supportTimeBound d = | |
| 2 * Real.log (3 * (N.factorial : β) / 4) / ((N : β) * Real.log 2) := by | |
| simp only [supportTimeBound, Real.logb] | |
| have hcast : (N : β) = (2 : β) ^ (d + 1) := by simp [N] | |
| rw [β hcast] | |
| ring | |
| rw [hrewrite] | |
| constructor | |
| Β· apply (le_div_iffβ (mul_pos hNp hlog)).mpr | |
| have hprod : (N : β) / 2 β€ (N : β) * Real.log 2 := by | |
| nlinarith [mul_nonneg hNp.le (sub_nonneg.mpr hhalf)] | |
| nlinarith | |
| Β· apply (div_le_iffβ (mul_pos hNp hlog)).mpr | |
| nlinarith | |
| theorem support_ceiling_asymptotic (d : β) : | |
| |(βsupportTimeBound dβ : β) - 2 * (d + 1)| β€ 6 := by | |
| obtain β¨hlow, huppβ© := supportTimeBound_bounds d | |
| have hceilow := Int.le_ceil (supportTimeBound d) | |
| have hup : βsupportTimeBound dβ β€ (2 * (d + 1) : β€) := by | |
| apply Int.ceil_le.mpr | |
| push_cast | |
| exact hupp | |
| have hupR : (βsupportTimeBound dβ : β) β€ 2 * ((d : β) + 1) := by | |
| exact_mod_cast hup | |
| exact abs_le.mpr β¨by linarith, by linarithβ© | |
| def boolSwitch (c : Bool) : Equiv.Perm Bool where | |
| toFun x := x ^^ c | |
| invFun x := x ^^ c | |
| left_inv x := by simp | |
| right_inv x := by simp | |
| lemma sign_boolSwitch (c : Bool) : | |
| Equiv.Perm.sign (boolSwitch c) = if c then (-1 : β€Λ£) else 1 := by | |
| cases c | |
| Β· have : boolSwitch false = 1 := by ext x; cases x <;> rfl | |
| rw [this]; rfl | |
| Β· have : boolSwitch true = Equiv.swap false true := by | |
| ext x; cases x <;> simp [boolSwitch] | |
| rw [this, Equiv.Perm.sign_swap (by decide)]; rfl | |
| lemma realSign_coordinateLayer (d : β) (j : Fin d) | |
| (c : ({i : Fin d // i β j} β Bool) β Bool) : | |
| realSign (coordinateLayer d j c) = β y, (if c y then (-1 : β) else 1) := by | |
| classical | |
| have he : coordinateLayer d j c = | |
| (Equiv.piSplitAt j (fun _ : Fin d => Bool)).trans | |
| ((Equiv.prodCongrLeft (fun y => boolSwitch (c y))).trans | |
| (Equiv.piSplitAt j (fun _ : Fin d => Bool)).symm) := rfl | |
| rw [he] | |
| simp [realSign, Equiv.Perm.sign_prodCongrLeft, sign_boolSwitch, apply_ite] | |
| lemma sum_realSign_coordinateLayer (d : β) (j : Fin d) : | |
| β c : ({i : Fin d // i β j} β Bool) β Bool, | |
| realSign (coordinateLayer d j c) = 0 := by | |
| classical | |
| simp_rw [realSign_coordinateLayer] | |
| rw [β Fintype.prod_sum (fun (_ : {i : Fin d // i β j} β Bool) (b : Bool) => | |
| if b then (-1 : β) else 1)] | |
| simp | |
| lemma realSign_binarySweep (d : β) (c : SweepCoins d) : | |
| realSign (binarySweep d c) = β j, realSign (coordinateLayer d j (c j)) := by | |
| classical | |
| simp [binarySweep, map_list_prod, List.map_reverse, List.prod_reverse, | |
| List.map_ofFn, List.prod_ofFn] | |
| lemma sum_realSign_binarySweep (d : β) (hd : 0 < d) : | |
| β c : SweepCoins d, realSign (binarySweep d c) = 0 := by | |
| classical | |
| simp_rw [realSign_binarySweep] | |
| rw [β Fintype.prod_sum (fun (j : Fin d) (c : ({i : Fin d // i β j} β Bool) β Bool) => | |
| realSign (coordinateLayer d j c))] | |
| apply Finset.prod_eq_zero (i := β¨0, hdβ©) (Finset.mem_univ _) | |
| exact sum_realSign_coordinateLayer d β¨0, hdβ© | |
| lemma finiteLaw_expectation {Ξ© G : Type*} [Fintype Ξ©] [Fintype G] | |
| (f : Ξ© β G) (a : G β β) : | |
| β g, finiteLaw f g * a g = (Fintype.card Ξ© : β)β»ΒΉ * β Ο, a (f Ο) := by | |
| classical | |
| simp only [finiteLaw, Finset.sum_mul] | |
| rw [Finset.sum_comm] | |
| simp [ite_mul, Finset.mul_sum] | |
| theorem binary_sign_annihilated (d : β) (hd : 0 < d) : | |
| β g : Equiv.Perm (Slot d), binaryLaw d g * realSign g = 0 := by | |
| rw [binaryLaw, finiteLaw_expectation, sum_realSign_binarySweep d hd, mul_zero] | |
| lemma coordinateLayer_zero (d : β) (j : Fin d) : | |
| coordinateLayer d j (fun _ => false) = 1 := by | |
| ext x i | |
| simp [coordinateLayer, Equiv.piSplitAt_symm_apply] | |
| intro h | |
| rw [h] | |
| lemma prod_reverse_ofFn_single {G : Type*} [Monoid G] (n : β) (j : Fin n) (g : G) : | |
| (List.ofFn (fun i : Fin n => if i = j then g else 1)).reverse.prod = g := by | |
| induction n with | |
| | zero => exact Fin.elim0 j | |
| | succ n ih => | |
| refine Fin.cases ?_ (fun j => ?_) j | |
| Β· simp [List.ofFn_succ, List.ofFn_const] | |
| Β· simpa [List.ofFn_succ, (Fin.succ_ne_zero j).symm] using ih j | |
| lemma binarySweep_zero (d : β) : binarySweep d (fun _ _ => false) = 1 := by | |
| simp [binarySweep, coordinateLayer_zero, List.ofFn_const] | |
| lemma binarySweep_singleLayer (d : β) (j : Fin d) | |
| (c : ({i : Fin d // i β j} β Bool) β Bool) : | |
| binarySweep d (Function.update ((fun _ _ => false) : SweepCoins d) j c) = coordinateLayer d j c := by | |
| classical | |
| have h (i : Fin d) : | |
| coordinateLayer d i ((Function.update ((fun _ _ => false) : SweepCoins d) j c) i) = | |
| if i = j then coordinateLayer d j c else 1 := by | |
| by_cases hi : i = j | |
| Β· subst i; simp | |
| Β· simp [coordinateLayer_zero, hi] | |
| simp only [binarySweep, h] | |
| exact prod_reverse_ofFn_single d j _ | |
| def sweepReachable (d : β) : Submonoid (Equiv.Perm (Slot d)) where | |
| carrier := {g | β l : List (SweepCoins d), (l.map (binarySweep d)).prod = g} | |
| one_mem' := β¨[], rflβ© | |
| mul_mem' := by | |
| rintro g h β¨l, rflβ© β¨k, rflβ© | |
| exact β¨l ++ k, by simpβ© | |
| lemma coordinateLayer_mem_reachable (d : β) (j : Fin d) | |
| (c : ({i : Fin d // i β j} β Bool) β Bool) : | |
| coordinateLayer d j c β sweepReachable d := by | |
| refine β¨[Function.update ((fun _ _ => false) : SweepCoins d) j c], ?_β© | |
| simp [binarySweep_singleLayer] | |
| lemma fiber_boolSwitch_eq_swap {Y : Type*} [DecidableEq Y] (y : Y) (a : Bool) : | |
| Equiv.prodCongrLeft (fun z => boolSwitch (decide (z = y))) = | |
| Equiv.swap (a, y) (!a, y) := by | |
| ext β¨b, zβ© <;> cases a <;> cases b <;> by_cases h : z = y <;> | |
| simp [boolSwitch, Equiv.swap_apply_def, h] | |
| end BinaryCoordinateSweeps | |
| end | |
| end OAI | |