Download data/lean/OAI/Combinatorics/FiniteCircle/BinaryDistortion.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 9.67 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/FiniteCircle/BinaryDistortion.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/FiniteCircle/BinaryDistortion.lean
-
curl -L -o BinaryDistortion.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/FiniteCircle/BinaryDistortion.lean
9.67 kB
| import OAI.Combinatorics.FiniteCircle.Parameters | |
| namespace OAI | |
| namespace FiniteCircle | |
| open scoped BigOperators List | |
| open scoped ComplexConjugate | |
| open RCLike Module | |
| theorem coded_range_lower {I Ξ± : Type*} [Fintype I] [DecidableEq I] [Fintype Ξ±] | |
| {n k M : β} [NeZero M] (hn : 1000000β€n) (hk : n^4=4*k) | |
| (hJ : Nat.log 2 M+1β€n^13) | |
| (H : AddSubgroup (I β ZMod M)) [Fintype H] (ΞΈ : I β ZMod M) | |
| (hb : β Ο : AddChar (I β ZMod M) β, Ο.compAddMonoidHom H.subtype=0 β Ο ΞΈβ 1 β | |
| (((n^4:β):β)/2)^(n^4) β€ β i, ((coordinateFrequency Ο i).valMinAbs.natAbs:β)) | |
| (W : (I β ZMod M) β List Ξ±) (L copies : β) (hL : 0<L) | |
| (hcL : L=M*Fintype.card I*copies) (hLen : β v, (W v).length=L) | |
| (hcheap : β v (c : H), (n^4)^(2*n^4)*editDistance (W v) (W (v+c)) β€ 2*n^4*L) | |
| (hsingle : β v i (j : Fin (Nat.log 2 M+1)), | |
| editDistance (W v) (W (v+Pi.single i ((2^j.val:β):ZMod M))) β€ 2*copies*2^j.val) | |
| (hlong : β v, (L:β)/(n:β)^(3*n^4) β€ (deficit (W v) (W (v+ΞΈ)):β)) | |
| {w : β} (c : Ξ± β Fin w β Bool) (hc : SubstitutionBounds (1/268435456) 67108928 c) : | |
| (n:β)^k β€ optimalDistortion (fun x : Set.range (fun v => encode c (W v)) => x.val) := by | |
| classical | |
| have hn0 : 0<n := by omega | |
| have hR : (0:β)<((n^4)^(2*n^4):β) := by positivity | |
| apply range_distortion_lower H ΞΈ ((((n^4:β):β)/2)^(n^4)) (by positivity) hb | |
| (fun v => encode c (W v)) (n^4) ((n^4)^(2*n^4):β) L copies w | |
| ((1/268435456)*w/(n:β)^(3*n^4)) ((n:β)^k) (by positivity) (by have := hc.1; positivity) | |
| (by exact_mod_cast hcL) | |
| Β· intro v z | |
| apply (le_div_iffβ hR).mpr | |
| have he := hc.2.2.2 (W v) (W (v+z)) | |
| have ht := Nat.mul_le_mul_left ((n^4)^(2*n^4)) he | |
| have hh := Nat.mul_le_mul_left w (hcheap v z) | |
| have hn : editDistance (encode c (W v)) (encode c (W (v+z)))*((n^4)^(2*n^4)) β€ w*2*n^4*L := by | |
| nlinarith | |
| exact_mod_cast hn | |
| Β· intro v i j | |
| have he := (hc.2.2.2 (W v) (W (v+Pi.single i ((2^j.val:β):ZMod M)))).trans | |
| (Nat.mul_le_mul_left w (hsingle v i j)) | |
| have hn : editDistance (encode c (W v)) (encode c (W (v+Pi.single i ((2^j.val:β):ZMod M)))) β€ | |
| w*2*copies*2^j.val := by nlinarith | |
| exact_mod_cast hn | |
| Β· intro v | |
| have hd := (hc.2.2.1 L (W v) (W (v+ΞΈ)) (hLen v) (hLen (v+ΞΈ))).1 | |
| have he := deficit_le_editDistance (x:=encode c (W v)) (y:=encode c (W (v+ΞΈ))) (by simp only [length_encode,hLen]) | |
| calc | |
| _ = (1/268435456)*w*((L:β)/(n:β)^(3*n^4)) := by ring | |
| _ β€ (1/268435456)*w*(deficit (W v) (W (v+ΞΈ)):β) := | |
| mul_le_mul_of_nonneg_left (hlong v) (by positivity) | |
| _ β€ (deficit (encode c (W v)) (encode c (W (v+ΞΈ))):β) := hd | |
| _ β€ _ := by exact_mod_cast he | |
| Β· intro t _ ht | |
| apply lower_numeric hn hk hJ hc.1 t | |
| simpa only [Nat.cast_pow] using ht | |
| theorem flatMaskState_surjective (h : β) (p : β β β β β) (M l : β) : | |
| Function.Surjective (flatMaskState h p M l) := by | |
| classical | |
| induction l with | |
| | zero => intro v; exact β¨fun _ => v,rflβ© | |
| | succ l ih => | |
| intro v | |
| choose f hf using fun j => ih (v j) | |
| refine β¨fun i => f i.1 i.2, ?_β© | |
| funext j | |
| exact hf j | |
| theorem flatExcludedState_surjective (h M l : β) : | |
| Function.Surjective (flatExcludedState h M l) := by | |
| classical | |
| induction l with | |
| | zero => intro v; exact β¨fun _ => v,rflβ© | |
| | succ l ih => | |
| intro v | |
| choose f hf using fun j => ih (v j) | |
| refine β¨fun i => f i.1 i.2, ?_β© | |
| funext j | |
| exact hf j | |
| theorem range_comp_surjective {X Y Z : Type*} (f : X β Y) (g : Y β Z) (hf : Function.Surjective f) : | |
| Set.range (fun x => g (f x)) = Set.range g := by | |
| ext z | |
| constructor | |
| Β· rintro β¨x,rflβ©; exact β¨f x,rflβ© | |
| Β· rintro β¨y,rflβ©; obtain β¨x,rflβ© := hf y; exact β¨x,rflβ© | |
| theorem mask_length_factor (h : β) (p : β β β β β) (R M l : β) : | |
| maskLength h p R M l = M*Fintype.card (TreeLeaf (MaskChildren h p) l)*treeCopies R (period h p) l := by | |
| apply tree_length_eq (MaskChildren h p) M R (period h p) (maskLength h p R M) rfl | |
| intro l | |
| simp only [maskLength, length_maskTags] | |
| congr 2 | |
| simp only [MaskChildren, Fintype.card_sigma, Fintype.card_fin] | |
| theorem excluded_length_factor (h : β) (p : β β β β β) (R M l : β) : | |
| excludedLength h p R M l = M*Fintype.card (TreeLeaf (fun _ => Fin h) l)*treeCopies R (period h p) l := by | |
| apply tree_length_eq (fun _ => Fin h) M R (period h p) (excludedLength h p R M) rfl | |
| intro l | |
| simp only [excludedLength,length_excludedTags,Fintype.card_fin] | |
| theorem mask_binary_distortion {n k : β} (hn : 1000000β€n) (hk : n^4=4*k) | |
| {p : β β β β β} (hp : StandingPrimes (n^4) p) {w : β} | |
| (c : MaskAlphabet (n^4) p (n^4) β Fin w β Bool) | |
| (hc : SubstitutionBounds (1/268435456) 67108928 c) : | |
| (n:β)^k β€ setDistortion (Set.range fun v : MaskState (n^4) p (circleSize (n^4) p) (n^4) => | |
| encode c (maskWord (n^4) p ((n^4)^(2*n^4)) (circleSize (n^4) p) (n^4) v)) := by | |
| classical | |
| let h := n^4 | |
| let M := circleSize h p | |
| let R := h^(2*h) | |
| let : NeZero M := β¨hp.circle_pos.ne'β© | |
| have hh : 2β€h := (show 2β€n by omega).trans (le_self_powβ (by omega) (by norm_num)) | |
| have hR : 0<R := pow_pos (by omega) _ | |
| let H := maskCheap h p M hp.divides_circle h | |
| let : Fintype H := Fintype.ofFinite H | |
| have hhb (Ο : AddChar (TreeLeaf (MaskChildren h p) h β ZMod M) β) | |
| (ha : Ο.compAddMonoidHom H.subtype=0) (hw : Ο (fun _ => ((M/2:β):ZMod M))β 1) : | |
| ((h:β)/2)^h β€ β i, ((coordinateFrequency Ο i).valMinAbs.natAbs:β) := by | |
| apply mask_character_branching hh hp.divides_circle hp.positive | |
| (fun l k hl hlh => (hp.atLevel l hl hlh k).1) | |
| hp.level_injective (fun l k hl hlh => (hp.atLevel l hl hlh k).2.1.le) Ο ha _ hw | |
| have hlong (v : TreeLeaf (MaskChildren h p) h β ZMod M) : | |
| (maskLength h p R M h:β)/(n:β)^(3*n^4) β€ | |
| (deficit (flatMaskWord h p R M h v) (flatMaskWord h p R M h (v+(fun _ => ((M/2:β):ZMod M)))):β) := by | |
| have he : n^4=2*(n^4/2) := by omega | |
| have ht := mask_long_deficit hn he hp hR (flatMaskState h p M h v) | |
| have hf := flatMaskState_shift h p M h v ((M/2:β):ZMod M) | |
| change flatMaskState h p M h (v+(fun _ => ((M/2:β):ZMod M))) = _ at hf | |
| simpa only [flatMaskWord,hf] using ht | |
| have ht := coded_range_lower hn hk (hp.log_circle_fourth hn) H (fun _ => ((M/2:β):ZMod M)) hhb | |
| (flatMaskWord h p R M h) (maskLength h p R M h) (treeCopies R (period h p) h) | |
| (hp.mask_length_pos (by omega) hR h) (mask_length_factor h p R M h) | |
| (fun v => length_maskWord h p R M h (flatMaskState h p M h v)) | |
| (fun v z => mask_cheap_ed hR hp.divides_circle hp.positive hp.coprime h v z z.property) | |
| (fun v i j => mask_single_ed (StandingPrimes.circle_even (h:=h) (p:=p)) h v i (2^j.val)) hlong c hc | |
| have he := range_comp_surjective (flatMaskState h p M h) | |
| (fun v => encode c (maskWord h p R M h v)) (flatMaskState_surjective h p M h) | |
| unfold flatMaskWord at ht | |
| rw [he] at ht | |
| exact ht | |
| theorem excluded_binary_distortion {n k : β} (hn : 1000000β€n) (hk : n^4=4*k) | |
| {p : β β β β β} (hp : StandingPrimes (n^4) p) {w : β} | |
| (c : ExcludedAlphabet (n^4) (circleSize (n^4) p) (n^4) β Fin w β Bool) | |
| (hc : SubstitutionBounds (1/268435456) 67108928 c) : | |
| (n:β)^k β€ setDistortion (Set.range fun v : ExcludedState (n^4) (circleSize (n^4) p) (n^4) => | |
| encode c (excludedWord (n^4) p ((n^4)^(2*n^4)) (circleSize (n^4) p) (n^4) v)) := by | |
| classical | |
| let h := n^4 | |
| let M := circleSize h p | |
| let R := h^(2*h) | |
| let : NeZero M := β¨hp.circle_pos.ne'β© | |
| have hh : 2β€h := (show 2β€n by omega).trans (le_self_powβ (by omega) (by norm_num)) | |
| have hR : 0<R := pow_pos (by omega) _ | |
| let H := excludedCheap h p M hp.divides_circle h | |
| let : Fintype H := Fintype.ofFinite H | |
| have hhb (Ο : AddChar (TreeLeaf (fun _ => Fin h) h β ZMod M) β) | |
| (ha : Ο.compAddMonoidHom H.subtype=0) (hw : Ο (fun _ => ((M/2:β):ZMod M))β 1) : | |
| ((h:β)/2)^h β€ β i, ((coordinateFrequency Ο i).valMinAbs.natAbs:β) := by | |
| apply excluded_character_branching hh hp.divides_circle hp.positive | |
| (fun l k hl hlh => (hp.atLevel l hl hlh k).1) | |
| hp.level_injective (fun l k hl hlh => (hp.atLevel l hl hlh k).2.1.le) Ο ha _ hw | |
| have hlong (v : TreeLeaf (fun _ => Fin h) h β ZMod M) : | |
| (excludedLength h p R M h:β)/(n:β)^(3*n^4) β€ | |
| (deficit (flatExcludedWord h p R M h v) (flatExcludedWord h p R M h (v+(fun _ => ((M/2:β):ZMod M)))):β) := by | |
| have he : n^4=2*(n^4/2) := by omega | |
| have ht := excluded_long_deficit hn he hp hR (flatExcludedState h M h v) | |
| have hf := flatExcludedState_shift h M h v ((M/2:β):ZMod M) | |
| change flatExcludedState h M h (v+(fun _ => ((M/2:β):ZMod M))) = _ at hf | |
| simpa only [flatExcludedWord,hf] using ht | |
| have ht := coded_range_lower hn hk (hp.log_circle_fourth hn) H (fun _ => ((M/2:β):ZMod M)) hhb | |
| (flatExcludedWord h p R M h) (excludedLength h p R M h) (treeCopies R (period h p) h) | |
| (hp.excluded_length_pos (by omega) hR h) (excluded_length_factor h p R M h) | |
| (fun v => length_excludedWord h p R M h (flatExcludedState h M h v)) | |
| (fun v z => excluded_cheap_ed hR hp.divides_circle hp.positive hp.coprime h v z z.property) | |
| (fun v i j => excluded_single_ed (StandingPrimes.circle_even (h:=h) (p:=p)) h v i (2^j.val)) hlong c hc | |
| have he := range_comp_surjective (flatExcludedState h M h) | |
| (fun v => encode c (excludedWord h p R M h v)) (flatExcludedState_surjective h M h) | |
| unfold flatExcludedWord at ht | |
| rw [he] at ht | |
| exact ht | |
| end FiniteCircle | |
| end OAI | |