Download data/lean/OAI/LinearAlgebra/MatrixFields/Construction/JointAPFree.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 5.59 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/MatrixFields/Construction/JointAPFree.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/LinearAlgebra/MatrixFields/Construction/JointAPFree.lean
-
curl -L -o JointAPFree.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/MatrixFields/Construction/JointAPFree.lean
5.59 kB
| import Mathlib | |
| namespace OAI | |
| namespace MatrixAllFields | |
| open scoped BigOperators Topology Polynomial | |
| noncomputable section | |
| namespace MatrixMultiplication.JointAPFree | |
| def natSet (N : β) : Finset β := (rothNumberNat_spec N).choose | |
| theorem natSet_subset (N : β) : natSet N β Finset.range N := | |
| (rothNumberNat_spec N).choose_spec.1 | |
| theorem natSet_card (N : β) : (natSet N).card = rothNumberNat N := | |
| (rothNumberNat_spec N).choose_spec.2.1 | |
| theorem natSet_threeAPFree (N : β) : ThreeAPFree (natSet N : Set β) := | |
| (rothNumberNat_spec N).choose_spec.2.2 | |
| theorem mem_natSet_lt {N a : β} (ha : a β natSet N) : a < N := | |
| Finset.mem_range.mp (natSet_subset N ha) | |
| theorem natCast_injective_below {M a b : β} (ha : a < M) (hb : b < M) | |
| (hab : (a : ZMod M) = (b : ZMod M)) : a = b := by | |
| have h := congrArg ZMod.val hab | |
| simpa only [ZMod.val_natCast_of_lt ha, ZMod.val_natCast_of_lt hb] using h | |
| theorem add_lt_modulus {M a b : β} (ha : a < M / 2) (hb : b < M / 2) : | |
| a + b < M := by | |
| have h := Nat.div_mul_le_self M 2 | |
| omega | |
| def modularSet (M : β) : Finset (ZMod M) := | |
| (natSet (M / 2)).image (fun a : β => (a : ZMod M)) | |
| theorem modularSet_card (M : β) : | |
| (modularSet M).card = rothNumberNat (M / 2) := by | |
| rw [modularSet, Finset.card_image_iff.mpr, natSet_card] | |
| intro a ha b hb hab | |
| exact natCast_injective_below | |
| ((mem_natSet_lt ha).trans_le (Nat.div_le_self M 2)) | |
| ((mem_natSet_lt hb).trans_le (Nat.div_le_self M 2)) hab | |
| theorem modularSet_threeAPFree (M : β) : | |
| ThreeAPFree (modularSet M : Set (ZMod M)) := by | |
| intro a ha b hb c hc habc | |
| change a β (natSet (M / 2)).image (fun n : β => (n : ZMod M)) at ha | |
| change b β (natSet (M / 2)).image (fun n : β => (n : ZMod M)) at hb | |
| change c β (natSet (M / 2)).image (fun n : β => (n : ZMod M)) at hc | |
| obtain β¨a', ha', rflβ© := Finset.mem_image.mp ha | |
| obtain β¨b', hb', rflβ© := Finset.mem_image.mp hb | |
| obtain β¨c', hc', rflβ© := Finset.mem_image.mp hc | |
| have hac := add_lt_modulus (mem_natSet_lt ha') (mem_natSet_lt hc') | |
| have hbb := add_lt_modulus (mem_natSet_lt hb') (mem_natSet_lt hb') | |
| have hnat : a' + c' = b' + b' := natCast_injective_below hac hbb (by | |
| simpa only [Nat.cast_add] using habc) | |
| exact congrArg (fun n : β => (n : ZMod M)) (natSet_threeAPFree (M / 2) ha' hb' hc' hnat) | |
| theorem modularSet_hashAP (M : β) : | |
| β x β modularSet M, β y β modularSet M, β z β modularSet M, | |
| x + y = 2 * z β x = z β§ y = z := by | |
| intro x hx y hy z hz h | |
| have h' : x + y = z + z := by simpa only [two_mul] using h | |
| exact β¨modularSet_threeAPFree M hx hz hy h', | |
| ((modularSet_threeAPFree M).eq_right hx hz hy h').symmβ© | |
| theorem modularSet_card_lower (M : β) : | |
| ((M / 2 : β) : β) * Real.exp (-4 * Real.sqrt (Real.log ((M / 2 : β) : β))) β€ | |
| ((modularSet M).card : β) := by | |
| rw [modularSet_card] | |
| exact Behrend.roth_lower_bound | |
| theorem modularSet_card_le_half (M : β) : (modularSet M).card β€ M / 2 := by | |
| rw [modularSet_card] | |
| exact rothNumberNat_le _ | |
| theorem modularSet_card_pos {M : β} (hM : 2 β€ M) : 0 < (modularSet M).card := by | |
| have hhalf : 0 < M / 2 := Nat.div_pos hM (by decide) | |
| have hpos : (0 : β) < ((M / 2 : β) : β) * | |
| Real.exp (-4 * Real.sqrt (Real.log ((M / 2 : β) : β))) := by | |
| exact mul_pos (by exact_mod_cast hhalf) (Real.exp_pos _) | |
| exact_mod_cast hpos.trans_le (modularSet_card_lower M) | |
| theorem modularSet_nonempty {M : β} (hM : 2 β€ M) : (modularSet M).Nonempty := | |
| Finset.card_pos.mp (modularSet_card_pos hM) | |
| theorem modularSet_log_card_lower {M : β} (hM : 2 β€ M) : | |
| Real.log ((M / 2 : β) : β) - 4 * Real.sqrt (Real.log ((M / 2 : β) : β)) β€ | |
| Real.log ((modularSet M).card : β) := by | |
| have hhalf : (0 : β) < ((M / 2 : β) : β) := by | |
| exact_mod_cast (Nat.div_pos hM (by decide) : 0 < M / 2) | |
| have h := Real.log_le_log (mul_pos hhalf (Real.exp_pos _)) (modularSet_card_lower M) | |
| rw [Real.log_mul hhalf.ne' (Real.exp_pos _).ne', Real.log_exp] at h | |
| linarith | |
| theorem modularSet_log_card_le_half {M : β} (hM : 2 β€ M) : | |
| Real.log ((modularSet M).card : β) β€ Real.log ((M / 2 : β) : β) := by | |
| apply Real.log_le_log | |
| Β· exact_mod_cast modularSet_card_pos hM | |
| Β· exact_mod_cast modularSet_card_le_half M | |
| theorem modularSet_log_card_lower_modulus {M : β} (hM : 2 β€ M) : | |
| Real.log (M : β) - Real.log 3 - 4 * Real.sqrt (Real.log (M : β)) β€ | |
| Real.log ((modularSet M).card : β) := by | |
| have hMr : (0 : β) < M := by exact_mod_cast (by omega : 0 < M) | |
| have hhalf : (0 : β) < ((M / 2 : β) : β) := by | |
| exact_mod_cast (Nat.div_pos hM (by decide) : 0 < M / 2) | |
| have hround : (M : β) / 3 β€ ((M / 2 : β) : β) := by | |
| have hn : M β€ 3 * (M / 2) := by omega | |
| have hr : (M : β) β€ 3 * ((M / 2 : β) : β) := by exact_mod_cast hn | |
| linarith | |
| have hlog := Real.log_le_log (div_pos hMr (by norm_num)) hround | |
| rw [Real.log_div hMr.ne' (by norm_num)] at hlog | |
| have hlogUpper : Real.log ((M / 2 : β) : β) β€ Real.log (M : β) := by | |
| apply Real.log_le_log hhalf | |
| exact_mod_cast Nat.div_le_self M 2 | |
| have hsqrt := Real.sqrt_le_sqrt hlogUpper | |
| have hcard := modularSet_log_card_lower hM | |
| linarith | |
| theorem modularSet_log_card_le_modulus {M : β} (hM : 2 β€ M) : | |
| Real.log ((modularSet M).card : β) β€ Real.log (M : β) := by | |
| apply Real.log_le_log | |
| Β· exact_mod_cast modularSet_card_pos hM | |
| Β· exact_mod_cast (modularSet_card_le_half M).trans (Nat.div_le_self M 2) | |
| end MatrixMultiplication.JointAPFree | |
| end | |
| end MatrixAllFields | |
| end OAI | |