Add lean source and binary files (part 107)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/SumPeriodBlocks.lean +77 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/Support.lean +90 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/SupportEqUsed.lean +107 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/SupportIffExtraOrLabel.lean +107 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/Symbolic.lean +154 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TaggedEdgeProduct.lean +96 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TaggedShape.lean +106 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TaggedShapeMap.lean +111 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/Test.lean +163 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TestVacuous.lean +108 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TiltedListLocalMean.lean +99 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TokenSlot.lean +212 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/Topology.lean +135 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TopologyTreeSteps.lean +133 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TotalCodeMass.lean +54 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TotalUnlitCountEqSubtype.lean +58 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TreeBlocksWithEdges.lean +77 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TreeDestinationInjective.lean +112 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TreeEdge.lean +137 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TreeEdgeInjective.lean +95 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TreeOccurrences.lean +232 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TreeOccurrencesEmptyOfFree.lean +155 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TreePrimeSupport.lean +131 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TreeVertices.lean +134 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TwoBlockRerooting.lean +101 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TwoTermBinomial.lean +164 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/UncutTreeEdges.lean +163 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/UnlitPolynomialBound.lean +125 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/Unselected.lean +92 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/UnselectedCard.lean +24 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/UntaggedEdgeCode.lean +87 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/UntaggedReferenceWeight.lean +104 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/UsedPrimeReciprocal.lean +133 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/VertexAt.lean +89 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/VertexIndex.lean +128 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/VertexWeight.lean +62 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/VerticesInBlock.lean +90 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/WalkBetweenSupport.lean +36 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/WalkSupportConnected.lean +34 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/WalkVertices.lean +88 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/Witness.lean +110 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/WitnessBaseDoublePath.lean +124 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/WitnessConfiguration.lean +149 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/WitnessEntropyBase.lean +117 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/WitnessSlotCount.lean +100 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/WitnessTestDescriptor.lean +139 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/WitnessTestShape.lean +130 -0
- lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/ZeroExpression.lean +95 -0
- lean/OAI/NumberTheory/Ostmann/All.lean +152 -0
- lean/OAI/NumberTheory/Ostmann/Arithmetic/AccidentalDivisibility.lean +65 -0
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/SumPeriodBlocks.lean
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
noncomputable section
|
| 6 |
+
open scoped BigOperators
|
| 7 |
+
open Finset
|
| 8 |
+
open Finset Classical
|
| 9 |
+
open Filter
|
| 10 |
+
open Finset Classical Filter
|
| 11 |
+
open scoped Topology
|
| 12 |
+
|
| 13 |
+
namespace OrdinaryCorrelations.PeriodicOrigin
|
| 14 |
+
open Finset Classical Filter
|
| 15 |
+
|
| 16 |
+
lemma sum_period_blocks (M : ℕ) (f : ℕ → ℝ) (hp : Function.Periodic f M) (q : ℕ) :
|
| 17 |
+
(∑ n ∈ range (M*q), f n) = (q : ℝ) * ∑ n ∈ range M, f n := by
|
| 18 |
+
induction q with
|
| 19 |
+
| zero => simp
|
| 20 |
+
| succ q ih =>
|
| 21 |
+
rw [Nat.mul_succ,sum_range_add,ih]
|
| 22 |
+
have he : (∑ n ∈ range M, f (M*q+n)) = ∑ n ∈ range M, f n := by
|
| 23 |
+
apply sum_congr rfl
|
| 24 |
+
intro n hn
|
| 25 |
+
simpa only [Nat.nsmul_eq_mul,Nat.mul_comm,Nat.add_comm] using hp.nsmul q n
|
| 26 |
+
rw [he,Nat.cast_add,Nat.cast_one]
|
| 27 |
+
ring
|
| 28 |
+
|
| 29 |
+
lemma sum_period_quotient (M N : ℕ) (f : ℕ → ℝ) (hp : Function.Periodic f M) :
|
| 30 |
+
(∑ n ∈ range N, f n) = (N/M : ℕ) * (∑ n ∈ range M, f n) + ∑ n ∈ range (N%M), f n := by
|
| 31 |
+
have hN : N = M*(N/M)+N%M := (Nat.div_add_mod N M).symm
|
| 32 |
+
conv_lhs => rw [hN,sum_range_add,sum_period_blocks M f hp]
|
| 33 |
+
congr 1
|
| 34 |
+
apply sum_congr rfl
|
| 35 |
+
intro n hn
|
| 36 |
+
simpa only [Nat.nsmul_eq_mul,Nat.mul_comm,Nat.add_comm] using hp.nsmul (N/M) n
|
| 37 |
+
|
| 38 |
+
theorem discrepancy (M N : ℕ) (hM : 0 < M) (f : ℕ → ℝ) (hp : Function.Periodic f M) :
|
| 39 |
+
|(∑ n ∈ range N, f n) - (N : ℝ) * ((∑ n ∈ range M, f n)/(M : ℝ))| ≤
|
| 40 |
+
2 * ∑ n ∈ range M, |f n| := by
|
| 41 |
+
let A := ∑ n ∈ range M, f n
|
| 42 |
+
let K := ∑ n ∈ range M, |f n|
|
| 43 |
+
have hK : 0 ≤ K := sum_nonneg (fun _ _ => abs_nonneg _)
|
| 44 |
+
have hA : |A| ≤ K := abs_sum_le_sum_abs _ _
|
| 45 |
+
have hR : |∑ n ∈ range (N%M), f n| ≤ K := by
|
| 46 |
+
apply (abs_sum_le_sum_abs _ _).trans
|
| 47 |
+
apply sum_le_sum_of_subset_of_nonneg (range_mono (Nat.mod_lt N hM).le)
|
| 48 |
+
intro n hn ho
|
| 49 |
+
exact abs_nonneg _
|
| 50 |
+
have hq : (N : ℝ) = (M : ℝ)*(N/M : ℕ)+(N%M : ℕ) := by
|
| 51 |
+
exact_mod_cast (Nat.div_add_mod N M).symm
|
| 52 |
+
have hmR : (0 : ℝ) < M := by exact_mod_cast hM
|
| 53 |
+
have hrlo : (0 : ℝ) ≤ (N%M : ℕ) := Nat.cast_nonneg _
|
| 54 |
+
have hrhi : (N%M : ℕ) / (M : ℝ) ≤ 1 := (div_le_one hmR).mpr (by exact_mod_cast (Nat.mod_lt N hM).le)
|
| 55 |
+
have he : (N/M : ℕ)*A - (N : ℝ)*(A/(M : ℝ)) = -((N%M : ℕ)/(M : ℝ)*A) := by
|
| 56 |
+
rw [hq]
|
| 57 |
+
field_simp
|
| 58 |
+
ring
|
| 59 |
+
rw [sum_period_quotient M N f hp]
|
| 60 |
+
calc
|
| 61 |
+
_ = |(∑ n ∈ range (N%M), f n) - ((N%M : ℕ)/(M : ℝ)*A)| := by
|
| 62 |
+
congr 1
|
| 63 |
+
dsimp only [A] at he ⊢
|
| 64 |
+
linarith
|
| 65 |
+
_ ≤ |∑ n ∈ range (N%M), f n| + |((N%M : ℕ)/(M : ℝ)*A)| := abs_sub _ _
|
| 66 |
+
_ ≤ K+K := by
|
| 67 |
+
apply add_le_add hR
|
| 68 |
+
rw [abs_mul,abs_of_nonneg (div_nonneg hrlo hmR.le)]
|
| 69 |
+
exact (mul_le_mul_of_nonneg_left hA (div_nonneg hrlo hmR.le)).trans
|
| 70 |
+
((mul_le_mul_of_nonneg_right hrhi hK).trans_eq (one_mul K))
|
| 71 |
+
_ = _ := by dsimp only [K]; ring
|
| 72 |
+
|
| 73 |
+
end OrdinaryCorrelations.PeriodicOrigin
|
| 74 |
+
|
| 75 |
+
end
|
| 76 |
+
|
| 77 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/Support.lean
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
noncomputable section
|
| 6 |
+
open scoped BigOperators
|
| 7 |
+
open Finset
|
| 8 |
+
open Finset Classical
|
| 9 |
+
open Filter
|
| 10 |
+
open Finset Classical Filter
|
| 11 |
+
|
| 12 |
+
namespace OrdinaryCorrelations.TaggedPrimeGroups
|
| 13 |
+
variable {P : Type*} [Fintype P] [DecidableEq P]
|
| 14 |
+
|
| 15 |
+
def support {m : ℕ} (x : Fin m → P) : Finset P := univ.image x
|
| 16 |
+
|
| 17 |
+
def weight (W : P → ℝ) {m : ℕ} (x : Fin m → P) : ℝ := ∏ p ∈ support x, W p
|
| 18 |
+
|
| 19 |
+
omit [Fintype P] in
|
| 20 |
+
lemma weight_nonneg (W : P → ℝ) (hW : ∀ p, 0 ≤ W p) {m : ℕ} (x : Fin m → P) :
|
| 21 |
+
0 ≤ weight W x := prod_nonneg (fun p _ => hW p)
|
| 22 |
+
|
| 23 |
+
omit [Fintype P] in
|
| 24 |
+
lemma support_cons {m : ℕ} (p : P) (x : Fin m → P) :
|
| 25 |
+
support (Fin.cons p x) = insert p (support x) := by
|
| 26 |
+
ext q
|
| 27 |
+
simp only [support,mem_image,mem_univ,true_and,mem_insert]
|
| 28 |
+
constructor
|
| 29 |
+
· rintro ⟨i,hi⟩
|
| 30 |
+
revert hi
|
| 31 |
+
refine Fin.cases ?_ (fun j => ?_) i
|
| 32 |
+
· intro hi; exact Or.inl hi.symm
|
| 33 |
+
· intro hi; exact Or.inr ⟨j,hi⟩
|
| 34 |
+
· rintro (rfl | ⟨j,hj⟩)
|
| 35 |
+
· exact ⟨0,Fin.cons_zero _ _⟩
|
| 36 |
+
· exact ⟨j.succ,by simpa only [Fin.cons_succ] using hj⟩
|
| 37 |
+
|
| 38 |
+
omit [Fintype P] in
|
| 39 |
+
lemma weight_cons (W : P → ℝ) {m : ℕ} (p : P) (x : Fin m → P) :
|
| 40 |
+
weight W (Fin.cons p x) = (if p ∈ support x then 1 else W p) * weight W x := by
|
| 41 |
+
unfold weight
|
| 42 |
+
rw [support_cons]
|
| 43 |
+
by_cases hp : p ∈ support x
|
| 44 |
+
· rw [ite_eq_left hp,insert_eq_of_mem hp,one_mul]
|
| 45 |
+
· rw [ite_eq_right hp,prod_insert hp]
|
| 46 |
+
|
| 47 |
+
lemma repeat_or_new (W : P → ℝ) (hW : ∀ p, 0 ≤ W p) {m : ℕ} (x : Fin m → P) :
|
| 48 |
+
(∑ p : P, weight W (Fin.cons p x)) ≤
|
| 49 |
+
((m : ℝ) + ∑ p : P, W p) * weight W x := by
|
| 50 |
+
simp_rw [weight_cons]
|
| 51 |
+
rw [← sum_mul]
|
| 52 |
+
apply mul_le_mul_of_nonneg_right _ (weight_nonneg W hW x)
|
| 53 |
+
calc
|
| 54 |
+
_ ≤ ∑ p : P, ((if p ∈ support x then (1 : ℝ) else 0) + W p) := by
|
| 55 |
+
apply sum_le_sum
|
| 56 |
+
intro p hp
|
| 57 |
+
split_ifs <;> linarith [hW p]
|
| 58 |
+
_ = ((support x).card : ℝ) + ∑ p : P, W p := by
|
| 59 |
+
rw [sum_add_distrib]
|
| 60 |
+
congr 1
|
| 61 |
+
simp only [← sum_filter]
|
| 62 |
+
simp
|
| 63 |
+
_ ≤ _ := by
|
| 64 |
+
have hcard : (support x).card ≤ m := by
|
| 65 |
+
simpa only [support,card_univ,Fintype.card_fin] using card_image_le (s := univ) (f := x)
|
| 66 |
+
have hr : ((support x).card : ℝ) ≤ (m : ℝ) := by exact_mod_cast hcard
|
| 67 |
+
linarith
|
| 68 |
+
|
| 69 |
+
theorem grouped_prime_sum (W : P → ℝ) (hW : ∀ p, 0 ≤ W p) (m : ℕ) :
|
| 70 |
+
(∑ x : Fin m → P, weight W x) ≤ ∏ i ∈ range m, ((i : ℝ) + ∑ p : P, W p) := by
|
| 71 |
+
induction m with
|
| 72 |
+
| zero => simp [weight,support]
|
| 73 |
+
| succ m ih =>
|
| 74 |
+
rw [← (Fin.consEquiv (fun _ : Fin (m+1) => P)).sum_comp (weight W),
|
| 75 |
+
Fintype.sum_prod_type,prod_range_succ]
|
| 76 |
+
change (∑ p : P, ∑ x : Fin m → P, weight W (Fin.cons p x)) ≤ _
|
| 77 |
+
rw [sum_comm]
|
| 78 |
+
calc
|
| 79 |
+
_ ≤ ∑ x : Fin m → P, ((m : ℝ) + ∑ p : P, W p) * weight W x :=
|
| 80 |
+
sum_le_sum (fun x hx => repeat_or_new W hW x)
|
| 81 |
+
_ = ((m : ℝ) + ∑ p : P, W p) * ∑ x : Fin m → P, weight W x := mul_sum .. |>.symm
|
| 82 |
+
_ ≤ ((m : ℝ) + ∑ p : P, W p) * ∏ i ∈ range m, ((i : ℝ) + ∑ p : P, W p) :=
|
| 83 |
+
mul_le_mul_of_nonneg_left ih (add_nonneg (Nat.cast_nonneg _) (sum_nonneg (fun p _ => hW p)))
|
| 84 |
+
_ = _ := mul_comm _ _
|
| 85 |
+
|
| 86 |
+
end OrdinaryCorrelations.TaggedPrimeGroups
|
| 87 |
+
|
| 88 |
+
end
|
| 89 |
+
|
| 90 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/SupportEqUsed.lean
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.Ordered
|
| 2 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.WitnessTestDescriptor
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
noncomputable section
|
| 7 |
+
open scoped BigOperators
|
| 8 |
+
open Finset
|
| 9 |
+
open Finset Classical
|
| 10 |
+
open Filter
|
| 11 |
+
open Finset Classical Filter
|
| 12 |
+
open scoped Topology
|
| 13 |
+
|
| 14 |
+
namespace OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 15 |
+
open OrdinaryCorrelations.SignedTrace OrdinaryCorrelations.ArithmeticSaving
|
| 16 |
+
open OrdinaryCorrelations.SharedSlotPatterns
|
| 17 |
+
open Finset Classical
|
| 18 |
+
variable {S : PrimeSystem} {B τ C₀ : ℝ} {D : S.DivisorFamily B τ C₀} {h ℓ L t : ℕ}
|
| 19 |
+
namespace WitnessConfiguration
|
| 20 |
+
variable (x : WitnessConfiguration D h ℓ L t)
|
| 21 |
+
|
| 22 |
+
lemma support_eq_used : support x.primeCode=x.family.used x.primitives := by
|
| 23 |
+
ext p
|
| 24 |
+
exact (mem_support _ p).trans (x.primeCode_support p)
|
| 25 |
+
|
| 26 |
+
noncomputable def name (p : S.Index) (hp : p ∈ support x.primeCode) :
|
| 27 |
+
Fin (support x.primeCode).card := (FiniteSlotEncoding.enum (support x.primeCode)).symm ⟨p,hp⟩
|
| 28 |
+
|
| 29 |
+
lemma values_name (p : S.Index) (hp : p ∈ support x.primeCode) :
|
| 30 |
+
values x.primeCode (x.name p hp)=p := by
|
| 31 |
+
change ((FiniteSlotEncoding.enum (support x.primeCode))
|
| 32 |
+
((FiniteSlotEncoding.enum (support x.primeCode)).symm _)).val=p
|
| 33 |
+
rw [Equiv.apply_symm_apply]
|
| 34 |
+
|
| 35 |
+
lemma selected_mem_support {j : Fin t} (d : x.family.Test j) (hd : d.Valid) :
|
| 36 |
+
d.selected ∈ support x.primeCode := by
|
| 37 |
+
rw [x.support_eq_used]
|
| 38 |
+
exact x.family.test_support_used x.primitives d _ (d.selected_mem hd)
|
| 39 |
+
|
| 40 |
+
lemma modulus_mem_support {j : Fin t} (d : x.family.Test j) :
|
| 41 |
+
d.modulus ∈ support x.primeCode := by
|
| 42 |
+
rw [x.support_eq_used]
|
| 43 |
+
exact x.family.test_support_used x.primitives d _ d.modulus_mem
|
| 44 |
+
|
| 45 |
+
noncomputable def template (c : PrivateFamily.Case) (A : Finset (Fin t))
|
| 46 |
+
(d : ∀ j : A, x.family.Test j.val) (hd : ∀ j, (d j).Valid) :
|
| 47 |
+
WitnessTemplateCode ℓ L ⌈C₀*Real.log B⌉₊ t (support x.primeCode).card :=
|
| 48 |
+
(x.metadata,pattern x.primeCode,
|
| 49 |
+
⟨⟨A.card,Nat.lt_succ_of_le (by simpa using Finset.card_le_univ A)⟩,
|
| 50 |
+
fun i => (x.shape (d (c.ordered A i)),
|
| 51 |
+
x.name (d (c.ordered A i)).selected (x.selected_mem_support _ (hd _)),
|
| 52 |
+
x.name (d (c.ordered A i)).modulus (x.modulus_mem_support _),
|
| 53 |
+
decide (d (c.ordered A i)).Linear)⟩)
|
| 54 |
+
|
| 55 |
+
lemma template_selected (c : PrivateFamily.Case) (A : Finset (Fin t))
|
| 56 |
+
(d : ∀ j : A, x.family.Test j.val) (hd : ∀ j, (d j).Valid) (i : Fin A.card) :
|
| 57 |
+
values x.primeCode ((x.template c A d hd).selected i)=(d (c.ordered A i)).selected :=
|
| 58 |
+
x.values_name _ _
|
| 59 |
+
|
| 60 |
+
lemma template_modulus (c : PrivateFamily.Case) (A : Finset (Fin t))
|
| 61 |
+
(d : ∀ j : A, x.family.Test j.val) (hd : ∀ j, (d j).Valid) (i : Fin A.card) :
|
| 62 |
+
values x.primeCode ((x.template c A d hd).modulus i)=(d (c.ordered A i)).modulus :=
|
| 63 |
+
x.values_name _ _
|
| 64 |
+
|
| 65 |
+
lemma template_expression (c : PrivateFamily.Case) (A : Finset (Fin t))
|
| 66 |
+
(d : ∀ j : A, x.family.Test j.val) (hd : ∀ j, (d j).Valid) (i : Fin A.card) :
|
| 67 |
+
((x.template c A d hd).expression h i).relabel (values x.primeCode)=
|
| 68 |
+
(d (c.ordered A i)).symbolic x.labels :=
|
| 69 |
+
x.pattern_shape_expression _
|
| 70 |
+
|
| 71 |
+
lemma template_wellFormed (c : PrivateFamily.Case) (A : Finset (Fin t))
|
| 72 |
+
(d : ∀ j : A, x.family.Test j.val) (hd : ∀ j, (d j).Valid)
|
| 73 |
+
(hinj : Function.Injective (fun j => (d j).selected))
|
| 74 |
+
(hfuture : ∀ i j : A, c.Precedes i.val j.val → ((d j).selected:ℕ) ∉ (d i).support) :
|
| 75 |
+
(x.template c A d hd).WellFormed h := by
|
| 76 |
+
apply WitnessTemplateCode.wellFormed_of_relabel (x.template c A d hd) h (values x.primeCode)
|
| 77 |
+
(PrivateFamily.testEmbedding c A d hinj) (PrivateFamily.testSystem x.labels c A d hd hinj hfuture)
|
| 78 |
+
· exact x.template_selected c A d hd
|
| 79 |
+
· exact x.template_expression c A d hd
|
| 80 |
+
· exact x.template_modulus c A d hd
|
| 81 |
+
· intro i; rfl
|
| 82 |
+
|
| 83 |
+
lemma template_admissible (c : PrivateFamily.Case) (A : Finset (Fin t))
|
| 84 |
+
(d : ∀ j : A, x.family.Test j.val) (hd : ∀ j, (d j).Valid)
|
| 85 |
+
(hinj : Function.Injective (fun j => (d j).selected))
|
| 86 |
+
(hfuture : ∀ i j : A, c.Precedes i.val j.val → ((d j).selected:ℕ) ∉ (d i).support)
|
| 87 |
+
(hnd : ∀ j, if (d j).Linear then ¬(((d j).modulus:ℕ):ℤ) ∣ (d j).coefficient
|
| 88 |
+
else (d j).expression ≠ 0)
|
| 89 |
+
(hB : 0 ≤ B) (P : ℝ) (hP : ∀ p : S.Index, P ≤ (p:ℝ))
|
| 90 |
+
(hupper : ∀ p : S.Index, (p:ℝ) ≤ Real.exp B)
|
| 91 |
+
(r : S.Residues) (hq : ∀ i p, (x.family.witness i).spec.ResidueTest p
|
| 92 |
+
(x.family.witness i).vertex (r p)) :
|
| 93 |
+
((x.template c A d hd).system h (x.template_wellFormed c A d hd hinj hfuture)).Admissible
|
| 94 |
+
P (PrivateFamily.testSize B C₀ h ℓ L) (fun a => (values x.primeCode a:ℕ)) := by
|
| 95 |
+
apply WitnessTemplateCode.system_admissible_of_relabel (x.template c A d hd) h
|
| 96 |
+
(x.template_wellFormed c A d hd hinj hfuture) (values x.primeCode)
|
| 97 |
+
(PrivateFamily.testEmbedding c A d hinj) (PrivateFamily.testSystem x.labels c A d hd hinj hfuture)
|
| 98 |
+
(x.template_selected c A d hd) (x.template_expression c A d hd)
|
| 99 |
+
(x.template_modulus c A d hd) (fun _ => rfl)
|
| 100 |
+
exact PrivateFamily.testSystem_admissible x.labels c A d hd hinj hfuture hnd hB P hP hupper r hq
|
| 101 |
+
|
| 102 |
+
end WitnessConfiguration
|
| 103 |
+
end OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 104 |
+
|
| 105 |
+
end
|
| 106 |
+
|
| 107 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/SupportIffExtraOrLabel.lean
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.ListSupport
|
| 2 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.LastEdge
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
noncomputable section
|
| 7 |
+
open scoped BigOperators
|
| 8 |
+
open Finset
|
| 9 |
+
open Finset Classical
|
| 10 |
+
open Filter
|
| 11 |
+
open Finset Classical Filter
|
| 12 |
+
open scoped Topology
|
| 13 |
+
|
| 14 |
+
namespace OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 15 |
+
open OrdinaryCorrelations.SignedTrace
|
| 16 |
+
open Finset Classical
|
| 17 |
+
variable {S : PrimeSystem} {B τ C₀ : ℝ} {D : S.DivisorFamily B τ C₀} {h L ℓ : ℕ}
|
| 18 |
+
|
| 19 |
+
namespace Specification
|
| 20 |
+
lemma support_iff_extra_or_label (s : S.Specification D h L) (p : S.Index) :
|
| 21 |
+
(p:ℕ) ∈ s.primeSupport ↔ p=s.extra ∨ ∃ i : Fin s.length, (p:ℕ) ∣ s.label i := by
|
| 22 |
+
simp only [primeSupport,mem_insert,mem_biUnion,mem_univ,true_and]
|
| 23 |
+
constructor
|
| 24 |
+
· rintro (he|⟨i,hi⟩)
|
| 25 |
+
· exact Or.inl (Subtype.ext he)
|
| 26 |
+
· exact Or.inr ⟨i,(Nat.mem_primeFactors.mp hi).2.1⟩
|
| 27 |
+
· rintro (rfl|⟨i,hi⟩)
|
| 28 |
+
· exact Or.inl rfl
|
| 29 |
+
· exact Or.inr ⟨i,Nat.mem_primeFactors.mpr
|
| 30 |
+
⟨S.prime_mem p p.property,hi,(D.squarefree _ (s.label_mem i)).ne_zero⟩⟩
|
| 31 |
+
|
| 32 |
+
noncomputable def activity (s : S.Specification D h L) (p : S.Index)
|
| 33 |
+
(hp : (p:ℕ) ∈ s.primeSupport) : Fin (s.length+1) :=
|
| 34 |
+
if he : p=s.extra then 0 else
|
| 35 |
+
(Classical.choose ((s.support_iff_extra_or_label p).mp hp |>.resolve_left he)).castSucc
|
| 36 |
+
|
| 37 |
+
lemma activity_divides (s : S.Specification D h L) (p : S.Index)
|
| 38 |
+
(hp : (p:ℕ) ∈ s.primeSupport) (x : ℤ) (hx : s.QualifiesAt x) :
|
| 39 |
+
((p:ℕ):ℤ) ∣ x+s.offset (s.activity p hp) := by
|
| 40 |
+
unfold activity
|
| 41 |
+
split_ifs with he
|
| 42 |
+
· subst p
|
| 43 |
+
simpa only [s.offset_zero,add_zero] using hx.1
|
| 44 |
+
· exact dvd_trans (by exact_mod_cast (Classical.choose_spec
|
| 45 |
+
(((s.support_iff_extra_or_label p).mp hp).resolve_left he)))
|
| 46 |
+
(hx.2 (Classical.choose (((s.support_iff_extra_or_label p).mp hp).resolve_left he)))
|
| 47 |
+
|
| 48 |
+
lemma tail_support (s : S.Specification D h L) (r : S.Index)
|
| 49 |
+
(hr : (r:ℕ) ∣ s.label s.tailStart) : (r:ℕ) ∈ s.primeSupport :=
|
| 50 |
+
(s.support_iff_extra_or_label r).mpr (Or.inr ⟨s.tailStart,hr⟩)
|
| 51 |
+
|
| 52 |
+
lemma occurs_before_or_tail (s : S.Specification D h L) (q : S.Index)
|
| 53 |
+
(hq : (q:ℕ) ∈ s.primeSupport) :
|
| 54 |
+
q=s.extra ∨ (∃ i : Fin s.length, i < s.tailStart ∧ (q:ℕ) ∣ s.label i) ∨
|
| 55 |
+
((q:ℕ) ∣ s.label s.tailStart ∧
|
| 56 |
+
∀ i : Fin s.length, i < s.tailStart → ¬(q:ℕ) ∣ s.label i) := by
|
| 57 |
+
rcases (s.support_iff_extra_or_label q).mp hq with he|⟨i,hi⟩
|
| 58 |
+
· exact Or.inl he
|
| 59 |
+
· by_cases hpre : ∃ i : Fin s.length, i < s.tailStart ∧ (q:ℕ) ∣ s.label i
|
| 60 |
+
· exact Or.inr (Or.inl hpre)
|
| 61 |
+
· right; right
|
| 62 |
+
have hat : s.tailStart ≤ i := by
|
| 63 |
+
by_contra hn
|
| 64 |
+
exact hpre ⟨i,lt_of_not_ge hn,hi⟩
|
| 65 |
+
constructor
|
| 66 |
+
· rwa [s.tail_labels i hat] at hi
|
| 67 |
+
· intro j hj hd
|
| 68 |
+
exact hpre ⟨j,hj,hd⟩
|
| 69 |
+
end Specification
|
| 70 |
+
|
| 71 |
+
lemma free_prime_one_side (w : ClosedLine h ℓ) (p : S.Index) (hp : ¬S.IsFixed w p)
|
| 72 |
+
(k : Fin (ℓ+1)) :
|
| 73 |
+
(∀ i : Fin ℓ, i.val < k.val → ¬(p:ℕ) ∣ w.label i) ∨
|
| 74 |
+
(∀ i : Fin ℓ, k.val ≤ i.val → ¬(p:ℕ) ∣ w.label i) := by
|
| 75 |
+
by_cases ha : ∀ i : Fin ℓ, i.val < k.val → ¬(p:ℕ) ∣ w.label i
|
| 76 |
+
· exact Or.inl ha
|
| 77 |
+
· right
|
| 78 |
+
push Not at ha
|
| 79 |
+
obtain ⟨e,hek,he⟩ := ha
|
| 80 |
+
intro i hki hi
|
| 81 |
+
have hei := (unique_occurrence_of_free w p hp e he i).mp hi
|
| 82 |
+
subst i
|
| 83 |
+
omega
|
| 84 |
+
|
| 85 |
+
lemma attached_activity_comparison (w : ClosedLine h ℓ)
|
| 86 |
+
(a b : AttachedSpec w D L) (r : S.Index)
|
| 87 |
+
(hr : (r:ℕ) ∈ a.spec.primeSupport)
|
| 88 |
+
(hrt : (r:ℕ) ∣ b.spec.label b.spec.tailStart)
|
| 89 |
+
(x : ℤ) (ha : a.spec.QualifiesAt (x+a.vertex))
|
| 90 |
+
(hb : b.spec.QualifiesAt (x+b.vertex)) :
|
| 91 |
+
((r:ℕ):ℤ) ∣ b.vertex-a.vertex+b.spec.offset b.spec.tailStart.castSucc-
|
| 92 |
+
a.spec.offset (a.spec.activity r hr) := by
|
| 93 |
+
have hi := a.spec.activity_divides r hr (x+a.vertex) ha
|
| 94 |
+
have hj : ((r:ℕ):ℤ) ∣ x+b.vertex+b.spec.offset b.spec.tailStart.castSucc :=
|
| 95 |
+
dvd_trans (by exact_mod_cast hrt) (hb.2 b.spec.tailStart)
|
| 96 |
+
have he : b.vertex-a.vertex+b.spec.offset b.spec.tailStart.castSucc-
|
| 97 |
+
a.spec.offset (a.spec.activity r hr) =
|
| 98 |
+
(x+b.vertex+b.spec.offset b.spec.tailStart.castSucc)-
|
| 99 |
+
(x+a.vertex+a.spec.offset (a.spec.activity r hr)) := by ring
|
| 100 |
+
rw [he]
|
| 101 |
+
exact dvd_sub hj hi
|
| 102 |
+
|
| 103 |
+
end OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 104 |
+
|
| 105 |
+
end
|
| 106 |
+
|
| 107 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/Symbolic.lean
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.Test
|
| 2 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.ZeroExpression
|
| 3 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.EdgeAt
|
| 4 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.LinearCoeffZeroOfNot
|
| 5 |
+
|
| 6 |
+
namespace OAI
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
open scoped BigOperators
|
| 10 |
+
open Finset
|
| 11 |
+
open Finset Classical
|
| 12 |
+
open Filter
|
| 13 |
+
open Finset Classical Filter
|
| 14 |
+
open scoped Topology
|
| 15 |
+
|
| 16 |
+
namespace OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 17 |
+
open OrdinaryCorrelations.ArithmeticSaving OrdinaryCorrelations.SignedTrace
|
| 18 |
+
open Finset Classical
|
| 19 |
+
variable {S : PrimeSystem} {B τ C₀ : ℝ} {D : S.DivisorFamily B τ C₀} {h L ℓ n : ℕ}
|
| 20 |
+
namespace PrivateFamily.Test
|
| 21 |
+
variable {w : ClosedLine h ℓ} (hl : ∀ i, w.label i ∈ D.members)
|
| 22 |
+
{F : PrivateFamily w D L n} {j : Fin n}
|
| 23 |
+
|
| 24 |
+
noncomputable def symbolic : F.Test j → SquarefreeExpression S.Index ((ℓ+L)+L)
|
| 25 |
+
| .extra | .tail _ =>
|
| 26 |
+
((SquarefreeExpression.zeroExpression S.Index ℓ).append
|
| 27 |
+
((F.witness j).spec.segmentExpression (F.witness j).spec.suffix.val (F.witness j).spec.length)).append
|
| 28 |
+
(SquarefreeExpression.zeroExpression S.Index L)
|
| 29 |
+
| .compare i _ r hi =>
|
| 30 |
+
((LineExpression.segment w hl (F.witness i).index (F.witness j).index).append
|
| 31 |
+
((F.witness j).spec.segmentExpression 0 (F.witness j).spec.tailStart.val)).append
|
| 32 |
+
((F.witness i).spec.segmentExpression 0 ((F.witness i).spec.activity r hi).val).neg
|
| 33 |
+
|
| 34 |
+
lemma symbolic_eval (t : F.Test j) :
|
| 35 |
+
(t.symbolic hl).eval (fun p => ((p:ℕ):ℤ)) = t.expression := by
|
| 36 |
+
cases t with
|
| 37 |
+
| extra =>
|
| 38 |
+
simp only [symbolic,SquarefreeExpression.eval_append,SquarefreeExpression.eval_zero,
|
| 39 |
+
zero_add,add_zero,expression]
|
| 40 |
+
exact (F.witness j).spec.segmentExpression_eval _ _ (Fin.isLt _).le le_rfl
|
| 41 |
+
| tail q =>
|
| 42 |
+
simp only [symbolic,SquarefreeExpression.eval_append,SquarefreeExpression.eval_zero,
|
| 43 |
+
zero_add,add_zero,expression]
|
| 44 |
+
exact (F.witness j).spec.segmentExpression_eval _ _ (Fin.isLt _).le le_rfl
|
| 45 |
+
| compare i q r hi =>
|
| 46 |
+
simp only [symbolic,SquarefreeExpression.eval_append,SquarefreeExpression.eval_neg,
|
| 47 |
+
LineExpression.segment_eval]
|
| 48 |
+
rw [(F.witness j).spec.segmentExpression_eval 0 _ (Nat.zero_le _) (Fin.isLt _).le,
|
| 49 |
+
(F.witness i).spec.segmentExpression_eval 0 _ (Nat.zero_le _)
|
| 50 |
+
(Nat.lt_succ_iff.mp ((F.witness i).spec.activity r hi).isLt)]
|
| 51 |
+
change w.offset (F.witness j).index-w.offset (F.witness i).index+
|
| 52 |
+
((F.witness j).spec.offset (F.witness j).spec.tailStart.castSucc-(F.witness j).spec.offset 0)+
|
| 53 |
+
-((F.witness i).spec.offset ((F.witness i).spec.activity r hi)-(F.witness i).spec.offset 0) = _
|
| 54 |
+
rw [(F.witness j).spec.offset_zero,(F.witness i).spec.offset_zero]
|
| 55 |
+
simp only [expression,AttachedSpec.vertex,sub_eq_add_neg,neg_zero,add_zero]
|
| 56 |
+
|
| 57 |
+
lemma symbolic_coefficient (t : F.Test j) :
|
| 58 |
+
(t.symbolic hl).linearCoeff t.selected (fun p => ((p:ℕ):ℤ)) = t.coefficient := by
|
| 59 |
+
cases t with
|
| 60 |
+
| extra =>
|
| 61 |
+
simp only [symbolic,selected,SquarefreeExpression.coefficient_append,
|
| 62 |
+
SquarefreeExpression.coefficient_zero,zero_add,add_zero,coefficient]
|
| 63 |
+
exact SquarefreeExpression.linearCoeff_zero_of_not_support _ _
|
| 64 |
+
((F.witness j).spec.segmentExpression_extra_absent _ _) _
|
| 65 |
+
| tail q =>
|
| 66 |
+
simp only [symbolic,selected,SquarefreeExpression.coefficient_append,
|
| 67 |
+
SquarefreeExpression.coefficient_zero,zero_add,add_zero,coefficient]
|
| 68 |
+
exact (F.witness j).spec.segmentExpression_coefficient _ _ le_rfl _
|
| 69 |
+
| compare i q r hi =>
|
| 70 |
+
simp only [symbolic,selected,SquarefreeExpression.coefficient_append,
|
| 71 |
+
SquarefreeExpression.coefficient_neg,LineExpression.segment_coefficient]
|
| 72 |
+
rw [(F.witness j).spec.segmentExpression_coefficient 0 _ (Fin.isLt _).le,
|
| 73 |
+
(F.witness i).spec.segmentExpression_coefficient 0 _
|
| 74 |
+
(Nat.lt_succ_iff.mp ((F.witness i).spec.activity r hi).isLt)]
|
| 75 |
+
rfl
|
| 76 |
+
|
| 77 |
+
lemma symbolic_support (t : F.Test j) {p : S.Index}
|
| 78 |
+
(hp : p ∈ (t.symbolic hl).support) : (p:ℕ) ∈ t.support := by
|
| 79 |
+
cases t with
|
| 80 |
+
| extra =>
|
| 81 |
+
simp only [symbolic,SquarefreeExpression.support_append,SquarefreeExpression.support_zero,
|
| 82 |
+
empty_union,union_empty] at hp
|
| 83 |
+
exact (F.witness j).spec.segmentExpression_support _ _ hp
|
| 84 |
+
| tail q =>
|
| 85 |
+
simp only [symbolic,SquarefreeExpression.support_append,SquarefreeExpression.support_zero,
|
| 86 |
+
empty_union,union_empty] at hp
|
| 87 |
+
exact (F.witness j).spec.segmentExpression_support _ _ hp
|
| 88 |
+
| compare i q r hi =>
|
| 89 |
+
simp only [symbolic,SquarefreeExpression.support_append,SquarefreeExpression.support_neg,mem_union] at hp
|
| 90 |
+
rcases hp with (hp|hp)|hp
|
| 91 |
+
· exact mem_union_right _ (LineExpression.segment_support w hl _ _ hp)
|
| 92 |
+
· exact mem_union_left _ (mem_union_right _ ((F.witness j).spec.segmentExpression_support _ _ hp))
|
| 93 |
+
· exact mem_union_left _ (mem_union_left _ ((F.witness i).spec.segmentExpression_support _ _ hp))
|
| 94 |
+
|
| 95 |
+
lemma symbolic_own_absent (t : F.Test j) (ht : ¬t.Linear) : t.selected ∉ (t.symbolic hl).support := by
|
| 96 |
+
cases t with
|
| 97 |
+
| extra =>
|
| 98 |
+
simp only [symbolic,selected,SquarefreeExpression.support_append,SquarefreeExpression.support_zero,
|
| 99 |
+
empty_union,union_empty]
|
| 100 |
+
exact (F.witness j).spec.segmentExpression_extra_absent _ _
|
| 101 |
+
| tail q => exact (ht trivial).elim
|
| 102 |
+
| compare i q r hi => exact (ht trivial).elim
|
| 103 |
+
|
| 104 |
+
lemma symbolic_factor_card (t : F.Test j) (i : Fin ((ℓ+L)+L)) :
|
| 105 |
+
((t.symbolic hl).factors i).card ≤ ⌈C₀*Real.log B⌉₊ := by
|
| 106 |
+
cases t with
|
| 107 |
+
| extra | tail =>
|
| 108 |
+
apply SquarefreeExpression.factors_append_le _ _ _ _ _ i
|
| 109 |
+
· apply SquarefreeExpression.factors_append_le
|
| 110 |
+
· intro e; simp [SquarefreeExpression.zeroExpression]
|
| 111 |
+
· exact fun e => (F.witness j).spec.segmentExpression_factor_card _ _ e
|
| 112 |
+
· intro e; simp [SquarefreeExpression.zeroExpression]
|
| 113 |
+
| compare a q r ha =>
|
| 114 |
+
apply SquarefreeExpression.factors_append_le _ _ _ _ _ i
|
| 115 |
+
· apply SquarefreeExpression.factors_append_le
|
| 116 |
+
· exact fun e => LineExpression.segment_factor_card w hl _ _ e
|
| 117 |
+
· exact fun e => (F.witness j).spec.segmentExpression_factor_card _ _ e
|
| 118 |
+
· exact fun e => (F.witness a).spec.segmentExpression_factor_card 0 ((F.witness a).spec.activity r ha).val e
|
| 119 |
+
|
| 120 |
+
lemma symbolic_coeff_bound (t : F.Test j) (i : Fin ((ℓ+L)+L)) :
|
| 121 |
+
|((t.symbolic hl).coefficient i:ℝ)| ≤ (h:ℝ) := by
|
| 122 |
+
cases t with
|
| 123 |
+
| extra | tail =>
|
| 124 |
+
apply SquarefreeExpression.abs_coefficient_append_le _ _ _ _ _ i
|
| 125 |
+
· apply SquarefreeExpression.abs_coefficient_append_le
|
| 126 |
+
· intro e; simp [SquarefreeExpression.zeroExpression]
|
| 127 |
+
· exact fun e => (F.witness j).spec.segmentExpression_coeff_bound _ _ e
|
| 128 |
+
· intro e; simp [SquarefreeExpression.zeroExpression]
|
| 129 |
+
| compare a q r ha =>
|
| 130 |
+
apply SquarefreeExpression.abs_coefficient_append_le _ _ _ _ _ i
|
| 131 |
+
· apply SquarefreeExpression.abs_coefficient_append_le
|
| 132 |
+
· exact fun e => LineExpression.segment_coeff_bound w hl _ _ e
|
| 133 |
+
· exact fun e => (F.witness j).spec.segmentExpression_coeff_bound _ _ e
|
| 134 |
+
· intro e
|
| 135 |
+
simpa only [SquarefreeExpression.neg,Int.cast_neg,abs_neg] using
|
| 136 |
+
(F.witness a).spec.segmentExpression_coeff_bound 0 ((F.witness a).spec.activity r ha).val e
|
| 137 |
+
|
| 138 |
+
lemma symbolic_size (t : F.Test j) (hB : 0 ≤ B) (x : S.Index → ℕ)
|
| 139 |
+
(hx : ∀ p, (x p:ℝ) ≤ Real.exp B) :
|
| 140 |
+
|((t.symbolic hl).eval (fun p => (x p:ℤ)):ℝ)| ≤
|
| 141 |
+
((ℓ+L)+L)*h*Real.exp (B*⌈C₀*Real.log B⌉₊) := by
|
| 142 |
+
have hb := SquarefreeExpression.abs_eval_le (t.symbolic hl) ⌈C₀*Real.log B⌉₊ B (h:ℝ)
|
| 143 |
+
hB (Nat.cast_nonneg h) (t.symbolic_factor_card hl) (t.symbolic_coeff_bound hl)
|
| 144 |
+
(fun p => (x p:ℤ)) (by
|
| 145 |
+
intro p hp
|
| 146 |
+
simpa only [Int.cast_natCast,abs_of_nonneg (show (0:ℝ) ≤ (x p:ℝ) from Nat.cast_nonneg _)] using hx p)
|
| 147 |
+
simpa only [Nat.cast_add] using hb
|
| 148 |
+
|
| 149 |
+
end PrivateFamily.Test
|
| 150 |
+
end OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 151 |
+
|
| 152 |
+
end
|
| 153 |
+
|
| 154 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TaggedEdgeProduct.lean
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.TokenSlot
|
| 2 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.UntaggedEdgeCode
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
noncomputable section
|
| 7 |
+
open scoped BigOperators
|
| 8 |
+
open Finset
|
| 9 |
+
open Finset Classical
|
| 10 |
+
open Filter
|
| 11 |
+
open Finset Classical Filter
|
| 12 |
+
|
| 13 |
+
namespace OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 14 |
+
open OrdinaryCorrelations.SignedTrace OrdinaryCorrelations.NumericalSubtrees
|
| 15 |
+
open Finset Classical
|
| 16 |
+
variable {S : PrimeSystem} {B τ C₀ : ℝ} {D : S.DivisorFamily B τ C₀} {h ℓ L : ℕ}
|
| 17 |
+
|
| 18 |
+
noncomputable def taggedEdgeProduct (w : ClosedLine h ℓ) (hh : 0 < h)
|
| 19 |
+
(𝔏 : List (AttachedSpec w D L)) (a : S.FixedResidues w) (e : Fin ℓ) : ℝ :=
|
| 20 |
+
∏ p : S.Index, if e ∈ (taggedTokens w hh 𝔏 (recordAt w hh 𝔏 a) p).biUnion tokenEdges
|
| 21 |
+
then (p:ℝ) else 1
|
| 22 |
+
|
| 23 |
+
lemma taggedEdgeProduct_pos (w : ClosedLine h ℓ) (hh : 0 < h)
|
| 24 |
+
(𝔏 : List (AttachedSpec w D L)) (a : S.FixedResidues w) (e : Fin ℓ) :
|
| 25 |
+
0 < taggedEdgeProduct w hh 𝔏 a e := by
|
| 26 |
+
apply prod_pos
|
| 27 |
+
intro p _
|
| 28 |
+
split_ifs
|
| 29 |
+
· exact_mod_cast S.prime_mem _ p.property |>.pos
|
| 30 |
+
· norm_num
|
| 31 |
+
|
| 32 |
+
lemma unorderedEdgeProduct_fibers (w : ClosedLine h ℓ) (f : S.Index → Option (TokenType w))
|
| 33 |
+
(e : Fin ℓ) :
|
| 34 |
+
unorderedEdgeProduct (TypeFibers.multiplicity f) (TypeFibers.unordered f) e =
|
| 35 |
+
∏ p : S.Index, TypeFibers.factor f (fun t (p : S.Index) =>
|
| 36 |
+
if e ∈ t.2.edges.val then (p:ℝ) else 1) p := by
|
| 37 |
+
rw [← TypeFibers.fiber_product f]
|
| 38 |
+
apply prod_congr rfl
|
| 39 |
+
intro t _
|
| 40 |
+
by_cases he : e ∈ t.2.edges.val <;>
|
| 41 |
+
simp only [TypeFibers.unordered,he,ite_true,ite_false,prod_const_one]
|
| 42 |
+
|
| 43 |
+
lemma tagged_untagged_edge_split (w : ClosedLine h ℓ) (hh : 0 < h)
|
| 44 |
+
(𝔏 : List (AttachedSpec w D L)) (a : S.FixedResidues w) (e : Fin ℓ) (p : S.Index) :
|
| 45 |
+
(if e ∈ (taggedTokens w hh 𝔏 (recordAt w hh 𝔏 a) p).biUnion tokenEdges then (p:ℝ) else 1) *
|
| 46 |
+
TypeFibers.factor (untaggedType w hh 𝔏 a)
|
| 47 |
+
(fun t (p : S.Index) => if e ∈ t.2.edges.val then (p:ℝ) else 1) p =
|
| 48 |
+
if e ∈ (recordTokens w hh 𝔏 (recordAt w hh 𝔏 a) p).biUnion tokenEdges then (p:ℝ) else 1 := by
|
| 49 |
+
rcases he : untaggedType w hh 𝔏 a p with _ | t
|
| 50 |
+
· rw [taggedTokens_of_none w hh 𝔏 a p he]
|
| 51 |
+
simp only [TypeFibers.factor,he,mul_one]
|
| 52 |
+
· rw [taggedTokens_of_some w hh 𝔏 a p t he,
|
| 53 |
+
(untaggedType_some w hh 𝔏 a p t he).2]
|
| 54 |
+
simp only [biUnion_empty,notMem_empty,ite_false,TypeFibers.factor,he,one_mul,
|
| 55 |
+
singleton_biUnion,tokenEdges]
|
| 56 |
+
|
| 57 |
+
theorem record_edge_factorization (w : ClosedLine h ℓ) (hh : 0 < h)
|
| 58 |
+
(𝔏 : List (AttachedSpec w D L)) (a : S.FixedResidues w)
|
| 59 |
+
(hlabels : ∀ i, w.label i ∈ D.members) (e : Fin ℓ) (he : e ∈ w.treeSteps) :
|
| 60 |
+
taggedEdgeProduct w hh 𝔏 a e *
|
| 61 |
+
unorderedEdgeProduct (TypeFibers.multiplicity (untaggedType w hh 𝔏 a))
|
| 62 |
+
(TypeFibers.unordered (untaggedType w hh 𝔏 a)) e = (w.label e : ℝ) := by
|
| 63 |
+
rw [unorderedEdgeProduct_fibers,taggedEdgeProduct,← prod_mul_distrib]
|
| 64 |
+
simp_rw [tagged_untagged_edge_split]
|
| 65 |
+
have hr := recordTokens_recover_label w hh 𝔏 a hlabels e he
|
| 66 |
+
simp only [mem_biUnion]
|
| 67 |
+
exact_mod_cast hr
|
| 68 |
+
|
| 69 |
+
lemma unorderedEdgeProduct_reference {w v : ClosedLine h ℓ} (H : SameGeometry v w)
|
| 70 |
+
(hh : 0 < h) (𝔏 : List (AttachedSpec v D L)) (a : S.FixedResidues v) (e : Fin ℓ) :
|
| 71 |
+
unorderedEdgeProduct (TypeFibers.multiplicity (untaggedReference H hh 𝔏 a))
|
| 72 |
+
(TypeFibers.unordered (untaggedReference H hh 𝔏 a)) e =
|
| 73 |
+
unorderedEdgeProduct (TypeFibers.multiplicity (untaggedType v hh 𝔏 a))
|
| 74 |
+
(TypeFibers.unordered (untaggedType v hh 𝔏 a)) e := by
|
| 75 |
+
rw [unorderedEdgeProduct_fibers,unorderedEdgeProduct_fibers]
|
| 76 |
+
apply prod_congr rfl
|
| 77 |
+
intro p _
|
| 78 |
+
rcases he : untaggedType v hh 𝔏 a p with _ | t <;>
|
| 79 |
+
simp only [TypeFibers.factor,untaggedReference,he,Option.map_none,Option.map_some]
|
| 80 |
+
rfl
|
| 81 |
+
|
| 82 |
+
theorem record_unordered_bins {w v : ClosedLine h ℓ} (H : SameGeometry v w)
|
| 83 |
+
(hh : 0 < h) (𝔏 : List (AttachedSpec v D L)) (a : S.FixedResidues v)
|
| 84 |
+
(hlabels : ∀ i, v.label i ∈ D.members) :
|
| 85 |
+
unorderedBins (TypeFibers.multiplicity (untaggedReference H hh 𝔏 a))
|
| 86 |
+
(taggedEdgeProduct v hh 𝔏 a) D.H τ (TypeFibers.unordered (untaggedReference H hh 𝔏 a)) := by
|
| 87 |
+
intro e he
|
| 88 |
+
rw [unorderedEdgeProduct_reference,
|
| 89 |
+
record_edge_factorization v hh 𝔏 a hlabels e (H.trees.symm ▸ he)]
|
| 90 |
+
exact ⟨D.lower _ (hlabels e),D.upper _ (hlabels e)⟩
|
| 91 |
+
|
| 92 |
+
end OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 93 |
+
|
| 94 |
+
end
|
| 95 |
+
|
| 96 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TaggedShape.lean
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.ModifiedWeightSameBand
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
noncomputable section
|
| 6 |
+
open scoped BigOperators
|
| 7 |
+
open Finset
|
| 8 |
+
open Finset Classical
|
| 9 |
+
open Filter
|
| 10 |
+
open Finset Classical Filter
|
| 11 |
+
|
| 12 |
+
namespace OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 13 |
+
open OrdinaryCorrelations.SignedTrace OrdinaryCorrelations.NumericalSubtrees
|
| 14 |
+
open Finset Classical
|
| 15 |
+
variable {S : PrimeSystem} {B τ C₀ : ℝ} {D : S.DivisorFamily B τ C₀} {h ℓ L : ℕ}
|
| 16 |
+
|
| 17 |
+
abbrev TaggedShape (w : ClosedLine h ℓ) := Shape w ⊕ Fin ℓ
|
| 18 |
+
|
| 19 |
+
def taggedShapeCode (w : ClosedLine h ℓ) : TaggedShape w → LocalToken ℓ
|
| 20 |
+
| .inl Q => (true,false,Q.edges.val)
|
| 21 |
+
| .inr e => (true,true,{e})
|
| 22 |
+
|
| 23 |
+
lemma taggedShapeCode_injective (w : ClosedLine h ℓ) : Function.Injective (taggedShapeCode w) := by
|
| 24 |
+
intro s t he
|
| 25 |
+
rcases s with Q | e <;> rcases t with R | j
|
| 26 |
+
· exact congrArg Sum.inl (Shape.edges_injective w (congrArg (fun t : LocalToken ℓ => t.2.2) he))
|
| 27 |
+
· have := congrArg (fun t : LocalToken ℓ => t.2.1) he; contradiction
|
| 28 |
+
· have := congrArg (fun t : LocalToken ℓ => t.2.1) he; contradiction
|
| 29 |
+
· exact congrArg Sum.inr (singleton_injective (congrArg (fun t : LocalToken ℓ => t.2.2) he))
|
| 30 |
+
|
| 31 |
+
lemma taggedPieces_shape (w : ClosedLine h ℓ) (hh : 0 < h) (O E : Finset (Fin ℓ))
|
| 32 |
+
(hE : E ⊆ w.treeSteps) (t : LocalToken ℓ) (ht : t ∈ taggedPieces w hh O E) :
|
| 33 |
+
∃ s : TaggedShape w, taggedShapeCode w s=t := by
|
| 34 |
+
rcases mem_union.mp ht with ht | ht
|
| 35 |
+
· obtain ⟨c,hc,rfl⟩ := mem_image.mp ht
|
| 36 |
+
exact ⟨.inl (shapeFromGrows w _ _ (component_grows w hh hE c hc)
|
| 37 |
+
(componentEdges_nonempty w hh E c hc)),rfl⟩
|
| 38 |
+
· obtain ⟨e,he,rfl⟩ := mem_image.mp ht
|
| 39 |
+
exact ⟨.inr e,rfl⟩
|
| 40 |
+
|
| 41 |
+
theorem record_tagged_shape (w : ClosedLine h ℓ) (hh : 0 < h)
|
| 42 |
+
(𝔏 : List (AttachedSpec w D L)) (a : S.FixedResidues w) (p : S.Index)
|
| 43 |
+
(t : LocalToken ℓ) (ht : t ∈ taggedTokens w hh 𝔏 (recordAt w hh 𝔏 a) p) :
|
| 44 |
+
∃ s : TaggedShape w, taggedShapeCode w s=t := by
|
| 45 |
+
obtain ⟨ht,htag⟩ := mem_filter.mp ht
|
| 46 |
+
by_cases ho : (treeOccurrences w p).Nonempty
|
| 47 |
+
· rw [recordTokens,ite_eq_left ho] at ht
|
| 48 |
+
by_cases hf : S.IsFixed w p
|
| 49 |
+
· rw [ite_eq_left hf] at ht
|
| 50 |
+
by_cases hp : (recordAt w hh 𝔏 a).2 p=true
|
| 51 |
+
· rw [ite_eq_left hp] at ht
|
| 52 |
+
exact taggedPieces_shape w hh _ _ ((recordAt_compatible w hh 𝔏 a p).trans (filter_subset _ _)) t ht
|
| 53 |
+
· rw [ite_eq_right hp] at ht
|
| 54 |
+
have he := mem_singleton.mp ht
|
| 55 |
+
have hfalse : t.1=false := congrArg Prod.fst he
|
| 56 |
+
rw [hfalse] at htag
|
| 57 |
+
contradiction
|
| 58 |
+
· rw [ite_eq_right hf] at ht
|
| 59 |
+
obtain ⟨e,he,rfl⟩ := mem_image.mp ht
|
| 60 |
+
by_cases hp : singletonIsTagged w 𝔏 p e
|
| 61 |
+
· exact ⟨.inr e,by simp only [taggedShapeCode,freePiece,hp,ite_true]⟩
|
| 62 |
+
· simp only [freePiece,hp,ite_false] at htag
|
| 63 |
+
contradiction
|
| 64 |
+
· rw [recordTokens,ite_eq_right ho] at ht
|
| 65 |
+
exact False.elim (Finset.notMem_empty _ ht)
|
| 66 |
+
|
| 67 |
+
lemma subtree_shape_sum (w : ClosedLine h ℓ) (p : S.Index) :
|
| 68 |
+
(∑ Q : Shape w, subtreeUnionWeight w p Q.edges.val) ≤ bandDefect w (S.beta p) := by
|
| 69 |
+
have hA : 0 ≤ S.amplitude p := by
|
| 70 |
+
unfold amplitude
|
| 71 |
+
split_ifs
|
| 72 |
+
· exact A_pos.le
|
| 73 |
+
· norm_num
|
| 74 |
+
have hne : 1+S.amplitude p ≠ 0 := ne_of_gt (by linarith)
|
| 75 |
+
have hunit : S.beta p*(1+S.amplitude p)=1 := inv_mul_cancel₀ hne
|
| 76 |
+
rw [sum_shapes]
|
| 77 |
+
exact numerical_subtree_sum_le w (S.amplitude p) (S.beta p) hA (beta_nonneg p) hunit
|
| 78 |
+
|
| 79 |
+
lemma bandDefect_le_vertices (w : ClosedLine h ℓ) (p : S.Index) :
|
| 80 |
+
bandDefect w (S.beta p) ≤ (ℓ:ℝ)+1 := by
|
| 81 |
+
calc
|
| 82 |
+
_ ≤ ∑ _v ∈ treeVertices w, (1:ℝ) := by
|
| 83 |
+
apply sum_le_sum
|
| 84 |
+
intro v hv
|
| 85 |
+
have hn : 0 ≤ (S.beta p)^(w.children v) := pow_nonneg (beta_nonneg p) _
|
| 86 |
+
linarith
|
| 87 |
+
_ = ((treeVertices w).card : ℝ) := by simp
|
| 88 |
+
_ ≤ (ℓ:ℝ)+1 := by
|
| 89 |
+
have hc : (treeVertices w).card ≤ ℓ+1 := by
|
| 90 |
+
simpa only [treeVertices,card_univ,Fintype.card_fin] using card_image_le (s := (univ : Finset (Fin (ℓ+1)))) (f := w.offset)
|
| 91 |
+
exact_mod_cast hc
|
| 92 |
+
|
| 93 |
+
theorem tagged_shape_sum (w : ClosedLine h ℓ) (p : S.Index) :
|
| 94 |
+
(∑ s : TaggedShape w, localTokenWeight w p (taggedShapeCode w s)) ≤ 3*(ℓ:ℝ)+1 := by
|
| 95 |
+
rw [Fintype.sum_sum_type]
|
| 96 |
+
simp only [taggedShapeCode,localTokenWeight,ite_true,Bool.false_eq_true,ite_false,tokenEdges]
|
| 97 |
+
have h1 := subtree_shape_sum w p
|
| 98 |
+
have h2 := bandDefect_le_vertices w p
|
| 99 |
+
simp only [sum_const,card_univ,Fintype.card_fin,nsmul_eq_mul]
|
| 100 |
+
linarith
|
| 101 |
+
|
| 102 |
+
end OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 103 |
+
|
| 104 |
+
end
|
| 105 |
+
|
| 106 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TaggedShapeMap.lean
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.TopologyTreeSteps
|
| 2 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.SpecPrimeSlot
|
| 3 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.TaggedShape
|
| 4 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.Enum
|
| 5 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.VertexIndex
|
| 6 |
+
|
| 7 |
+
namespace OAI
|
| 8 |
+
|
| 9 |
+
noncomputable section
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
open Finset
|
| 12 |
+
open Finset Classical
|
| 13 |
+
open Filter
|
| 14 |
+
open Finset Classical Filter
|
| 15 |
+
|
| 16 |
+
namespace OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 17 |
+
open OrdinaryCorrelations.SignedTrace OrdinaryCorrelations.NumericalSubtrees
|
| 18 |
+
open Finset Classical
|
| 19 |
+
variable {S : PrimeSystem} {B τ C₀ : ℝ} {D : S.DivisorFamily B τ C₀} {h ℓ L : ℕ}
|
| 20 |
+
|
| 21 |
+
def taggedShapeMap {w v : ClosedLine h ℓ} (H : SameGeometry v w) : TaggedShape v → TaggedShape w
|
| 22 |
+
| .inl Q => .inl (H.shapeMap Q)
|
| 23 |
+
| .inr e => .inr e
|
| 24 |
+
|
| 25 |
+
lemma taggedShapeMap_code {w v : ClosedLine h ℓ} (H : SameGeometry v w) (s : TaggedShape v) :
|
| 26 |
+
taggedShapeCode w (taggedShapeMap H s)=taggedShapeCode v s := by
|
| 27 |
+
cases s <;> rfl
|
| 28 |
+
|
| 29 |
+
lemma taggedShapeMap_weight {w v : ClosedLine h ℓ} (H : SameGeometry v w) (p : S.Index)
|
| 30 |
+
(s : TaggedShape v) :
|
| 31 |
+
localTokenWeight w p (taggedShapeCode w (taggedShapeMap H s)) =
|
| 32 |
+
localTokenWeight v p (taggedShapeCode v s) := by
|
| 33 |
+
cases s with
|
| 34 |
+
| inl Q => exact (H.weight p Q.edges.val).symm
|
| 35 |
+
| inr e => rfl
|
| 36 |
+
|
| 37 |
+
lemma taggedShapeMap_surjective {w v : ClosedLine h ℓ} (H : SameGeometry v w) :
|
| 38 |
+
Function.Surjective (taggedShapeMap H) := by
|
| 39 |
+
intro t
|
| 40 |
+
cases t with
|
| 41 |
+
| inl Q =>
|
| 42 |
+
obtain ⟨R,hR⟩ := H.shapeEquiv.surjective Q
|
| 43 |
+
exact ⟨.inl R,congrArg Sum.inl hR⟩
|
| 44 |
+
| inr e => exact ⟨.inr e,rfl⟩
|
| 45 |
+
|
| 46 |
+
noncomputable def taggedPairSet {w v : ClosedLine h ℓ} (_H : SameGeometry v w) (hh : 0 < h)
|
| 47 |
+
(𝔏 : List (AttachedSpec v D L)) (a : S.FixedResidues v) : Finset (S.Index × TaggedShape w) :=
|
| 48 |
+
univ.filter (fun z => taggedShapeCode w z.2 ∈ taggedTokens v hh 𝔏 (recordAt v hh 𝔏 a) z.1)
|
| 49 |
+
|
| 50 |
+
lemma mem_taggedPairSet {w v : ClosedLine h ℓ} (H : SameGeometry v w) (hh : 0 < h)
|
| 51 |
+
(𝔏 : List (AttachedSpec v D L)) (a : S.FixedResidues v) (p : S.Index) (s : TaggedShape w) :
|
| 52 |
+
(p,s) ∈ taggedPairSet H hh 𝔏 a ↔
|
| 53 |
+
taggedShapeCode w s ∈ taggedTokens v hh 𝔏 (recordAt v hh 𝔏 a) p := by
|
| 54 |
+
simp only [taggedPairSet,mem_filter,mem_univ,true_and]
|
| 55 |
+
|
| 56 |
+
lemma taggedToken_iff_pair {w v : ClosedLine h ℓ} (H : SameGeometry v w) (hh : 0 < h)
|
| 57 |
+
(𝔏 : List (AttachedSpec v D L)) (a : S.FixedResidues v) (p : S.Index) (t : LocalToken ℓ) :
|
| 58 |
+
t ∈ taggedTokens v hh 𝔏 (recordAt v hh 𝔏 a) p ↔
|
| 59 |
+
∃ s : TaggedShape w, (p,s) ∈ taggedPairSet H hh 𝔏 a ∧ taggedShapeCode w s=t := by
|
| 60 |
+
constructor
|
| 61 |
+
· intro ht
|
| 62 |
+
obtain ⟨s,hs⟩ := record_tagged_shape v hh 𝔏 a p t ht
|
| 63 |
+
refine ⟨taggedShapeMap H s,?_,?_⟩
|
| 64 |
+
· rw [mem_taggedPairSet,taggedShapeMap_code,hs]
|
| 65 |
+
exact ht
|
| 66 |
+
· exact (taggedShapeMap_code H s).trans hs
|
| 67 |
+
· rintro ⟨s,hs,rfl⟩
|
| 68 |
+
exact (mem_taggedPairSet H hh 𝔏 a p s).mp hs
|
| 69 |
+
|
| 70 |
+
noncomputable def taggedRecordCode {w v : ClosedLine h ℓ} (H : SameGeometry v w) (hh : 0 < h)
|
| 71 |
+
(𝔏 : List (AttachedSpec v D L)) (a : S.FixedResidues v) (N : ℕ) :
|
| 72 |
+
Fin N → Option (S.Index × TaggedShape w) := FiniteSlotEncoding.code (taggedPairSet H hh 𝔏 a) N
|
| 73 |
+
|
| 74 |
+
theorem tag_tokens_eq_of_code {w v u : ClosedLine h ℓ}
|
| 75 |
+
(H : SameGeometry v w) (I : SameGeometry u w) (hh : 0 < h)
|
| 76 |
+
(𝔏 : List (AttachedSpec v D L)) (𝔐 : List (AttachedSpec u D L))
|
| 77 |
+
(a : S.FixedResidues v) (b : S.FixedResidues u) (N : ℕ)
|
| 78 |
+
(hN : (taggedPairSet H hh 𝔏 a).card ≤ N) (hM : (taggedPairSet I hh 𝔐 b).card ≤ N)
|
| 79 |
+
(hc : taggedRecordCode H hh 𝔏 a N=taggedRecordCode I hh 𝔐 b N) (p : S.Index) :
|
| 80 |
+
taggedTokens v hh 𝔏 (recordAt v hh 𝔏 a) p=taggedTokens u hh 𝔐 (recordAt u hh 𝔐 b) p := by
|
| 81 |
+
have hs := FiniteSlotEncoding.code_injective hN hM hc
|
| 82 |
+
ext t
|
| 83 |
+
rw [taggedToken_iff_pair H hh 𝔏 a p t,taggedToken_iff_pair I hh 𝔐 b p t,hs]
|
| 84 |
+
|
| 85 |
+
noncomputable def taggedPairEquiv {w v : ClosedLine h ℓ} (H : SameGeometry v w) (hh : 0 < h)
|
| 86 |
+
(𝔏 : List (AttachedSpec v D L)) (a : S.FixedResidues v) :
|
| 87 |
+
↥(taggedPairSet H hh 𝔏 a) ≃ TaggedSlot v hh 𝔏 a :=
|
| 88 |
+
Equiv.ofBijective
|
| 89 |
+
(fun z => ⟨z.val.1,⟨taggedShapeCode w z.val.2,(mem_taggedPairSet H hh 𝔏 a _ _).mp z.property⟩⟩)
|
| 90 |
+
⟨by
|
| 91 |
+
intro x y he
|
| 92 |
+
have hp : x.val.1=y.val.1 := congrArg Sigma.fst he
|
| 93 |
+
have hT : taggedShapeCode w x.val.2=taggedShapeCode w y.val.2 :=
|
| 94 |
+
congrArg (fun z : TaggedSlot v hh 𝔏 a => z.2.val) he
|
| 95 |
+
exact Subtype.ext (Prod.ext hp (taggedShapeCode_injective w hT)),
|
| 96 |
+
by
|
| 97 |
+
rintro ⟨p,t⟩
|
| 98 |
+
obtain ⟨s,hs,he⟩ := (taggedToken_iff_pair H hh 𝔏 a p t.val).mp t.property
|
| 99 |
+
refine ⟨⟨(p,s),hs⟩,?_⟩
|
| 100 |
+
exact congrArg (fun z => (Sigma.mk p z : TaggedSlot v hh 𝔏 a)) (Subtype.ext he)⟩
|
| 101 |
+
|
| 102 |
+
lemma taggedPairSet_card {w v : ClosedLine h ℓ} (H : SameGeometry v w) (hh : 0 < h)
|
| 103 |
+
(𝔏 : List (AttachedSpec v D L)) (a : S.FixedResidues v) :
|
| 104 |
+
(taggedPairSet H hh 𝔏 a).card=Fintype.card (TaggedSlot v hh 𝔏 a) := by
|
| 105 |
+
simpa only [Fintype.card_coe] using Fintype.card_congr (taggedPairEquiv H hh 𝔏 a)
|
| 106 |
+
|
| 107 |
+
end OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 108 |
+
|
| 109 |
+
end
|
| 110 |
+
|
| 111 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/Test.lean
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.IntegerResidues
|
| 2 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.PrivateFamily
|
| 3 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.CoefficientZeroOfNotSupport
|
| 4 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.PrefixCoefficientNondvd
|
| 5 |
+
|
| 6 |
+
namespace OAI
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
open scoped BigOperators
|
| 10 |
+
open Finset
|
| 11 |
+
open Finset Classical
|
| 12 |
+
open Filter
|
| 13 |
+
open Finset Classical Filter
|
| 14 |
+
open scoped Topology
|
| 15 |
+
|
| 16 |
+
namespace OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 17 |
+
open OrdinaryCorrelations.SignedTrace
|
| 18 |
+
open Finset Classical
|
| 19 |
+
variable {S : PrimeSystem} {B τ C₀ : ℝ} {D : S.DivisorFamily B τ C₀} {h L ℓ n : ℕ}
|
| 20 |
+
namespace PrivateFamily
|
| 21 |
+
variable {w : ClosedLine h ℓ} (F : PrivateFamily w D L n)
|
| 22 |
+
|
| 23 |
+
inductive Test (j : Fin n) where
|
| 24 |
+
| extra
|
| 25 |
+
| tail (q : S.Index)
|
| 26 |
+
| compare (i : Fin n) (q r : S.Index)
|
| 27 |
+
(hr : (r:ℕ) ∈ (F.witness i).spec.primeSupport)
|
| 28 |
+
|
| 29 |
+
namespace Test
|
| 30 |
+
variable {F} {j : Fin n}
|
| 31 |
+
|
| 32 |
+
def selected : F.Test j → S.Index
|
| 33 |
+
| .extra => (F.witness j).spec.extra
|
| 34 |
+
| .tail q => q
|
| 35 |
+
| .compare _ q _ _ => q
|
| 36 |
+
|
| 37 |
+
def modulus : F.Test j → S.Index
|
| 38 |
+
| .extra => (F.witness j).spec.extra
|
| 39 |
+
| .tail _ => (F.witness j).spec.extra
|
| 40 |
+
| .compare _ _ r _ => r
|
| 41 |
+
|
| 42 |
+
noncomputable def support : F.Test j → Finset ℕ
|
| 43 |
+
| .extra => (F.witness j).spec.primeSupport
|
| 44 |
+
| .tail _ => (F.witness j).spec.primeSupport
|
| 45 |
+
| .compare i _ _ _ => F.comparisonSupport i j
|
| 46 |
+
|
| 47 |
+
noncomputable def expression : F.Test j → ℤ
|
| 48 |
+
| .extra => (F.witness j).spec.offset (Fin.last (F.witness j).spec.length)-
|
| 49 |
+
(F.witness j).spec.offset (F.witness j).spec.suffix.castSucc
|
| 50 |
+
| .tail _ => (F.witness j).spec.offset (Fin.last (F.witness j).spec.length)-
|
| 51 |
+
(F.witness j).spec.offset (F.witness j).spec.suffix.castSucc
|
| 52 |
+
| .compare i _ r hi => (F.witness j).vertex-(F.witness i).vertex+
|
| 53 |
+
(F.witness j).spec.offset (F.witness j).spec.tailStart.castSucc-
|
| 54 |
+
(F.witness i).spec.offset ((F.witness i).spec.activity r hi)
|
| 55 |
+
|
| 56 |
+
noncomputable def coefficient : F.Test j → ℤ
|
| 57 |
+
| .extra => 0
|
| 58 |
+
| .tail q => (F.witness j).spec.coefficient q (F.witness j).spec.suffix.val
|
| 59 |
+
(F.witness j).spec.length
|
| 60 |
+
| .compare i q r hi =>
|
| 61 |
+
w.segmentCoefficient q (F.witness i).index (F.witness j).index+
|
| 62 |
+
(F.witness j).spec.coefficient q 0 (F.witness j).spec.tailStart.val-
|
| 63 |
+
(F.witness i).spec.coefficient q 0 ((F.witness i).spec.activity r hi).val
|
| 64 |
+
|
| 65 |
+
def Valid : F.Test j → Prop
|
| 66 |
+
| .extra => True
|
| 67 |
+
| .tail q => (q:ℕ) ∣ (F.witness j).spec.label (F.witness j).spec.tailStart ∧
|
| 68 |
+
∀ e : Fin (F.witness j).spec.length, e < (F.witness j).spec.tailStart →
|
| 69 |
+
¬(q:ℕ) ∣ (F.witness j).spec.label e
|
| 70 |
+
| .compare i q r _ =>
|
| 71 |
+
(r:ℕ) ∣ (F.witness j).spec.label (F.witness j).spec.tailStart ∧
|
| 72 |
+
(∀ e : Fin (F.witness j).spec.length, e < (F.witness j).spec.tailStart →
|
| 73 |
+
¬(r:ℕ) ∣ (F.witness j).spec.label e) ∧
|
| 74 |
+
(∃ e : Fin (F.witness j).spec.length, e < (F.witness j).spec.tailStart ∧
|
| 75 |
+
(q:ℕ) ∣ (F.witness j).spec.label e) ∧
|
| 76 |
+
(q:ℕ) ∉ (F.witness i).spec.primeSupport ∧
|
| 77 |
+
(q:ℕ) ∉ w.segmentSupport (F.witness i).index (F.witness j).index
|
| 78 |
+
|
| 79 |
+
def Linear : F.Test j → Prop
|
| 80 |
+
| .extra => False
|
| 81 |
+
| .tail _ => True
|
| 82 |
+
| .compare _ _ _ _ => True
|
| 83 |
+
|
| 84 |
+
lemma selected_mem (t : F.Test j) (ht : t.Valid) : (t.selected:ℕ) ∈ t.support := by
|
| 85 |
+
cases t with
|
| 86 |
+
| extra => exact ((F.witness j).spec.support_iff_extra_or_label _).mpr (Or.inl rfl)
|
| 87 |
+
| tail q =>
|
| 88 |
+
exact ((F.witness j).spec.support_iff_extra_or_label q).mpr
|
| 89 |
+
(Or.inr ⟨(F.witness j).spec.tailStart,ht.1⟩)
|
| 90 |
+
| compare i q r hi =>
|
| 91 |
+
obtain ⟨e,he,hqe⟩ := ht.2.2.1
|
| 92 |
+
exact mem_union_left _ (mem_union_right _
|
| 93 |
+
(((F.witness j).spec.support_iff_extra_or_label q).mpr (Or.inr ⟨e,hqe⟩)))
|
| 94 |
+
|
| 95 |
+
lemma comparison_coefficient (i : Fin n) (q r : S.Index)
|
| 96 |
+
(hi : (r:ℕ) ∈ (F.witness i).spec.primeSupport)
|
| 97 |
+
(ht : (Test.compare (F:=F) (j:=j) i q r hi).Valid) :
|
| 98 |
+
(Test.compare (F:=F) (j:=j) i q r hi).coefficient =
|
| 99 |
+
(F.witness j).spec.coefficient q 0 (F.witness j).spec.tailStart.val := by
|
| 100 |
+
change w.segmentCoefficient q (F.witness i).index (F.witness j).index+
|
| 101 |
+
(F.witness j).spec.coefficient q 0 (F.witness j).spec.tailStart.val-
|
| 102 |
+
(F.witness i).spec.coefficient q 0 ((F.witness i).spec.activity r hi).val = _
|
| 103 |
+
rw [w.segmentCoefficient_zero q (S.prime_mem q q.property) _ _ ht.2.2.2.2,
|
| 104 |
+
(F.witness i).spec.coefficient_zero_of_not_support q ht.2.2.2.1]
|
| 105 |
+
ring
|
| 106 |
+
|
| 107 |
+
lemma holds (t : F.Test j) (ht : t.Valid) (x : ℤ)
|
| 108 |
+
(hx : ∀ i, (F.witness i).spec.QualifiesAt (x+(F.witness i).vertex)) :
|
| 109 |
+
((t.modulus:ℕ):ℤ) ∣ t.expression := by
|
| 110 |
+
cases t with
|
| 111 |
+
| extra => exact (F.witness j).spec.extra_div_suffix
|
| 112 |
+
| tail q => exact (F.witness j).spec.extra_div_suffix
|
| 113 |
+
| compare i q r hi =>
|
| 114 |
+
exact attached_activity_comparison w (F.witness i) (F.witness j) r hi ht.1 x (hx i) (hx j)
|
| 115 |
+
|
| 116 |
+
lemma nondegenerate (t : F.Test j) (ht : t.Valid) (hh : 0 < h)
|
| 117 |
+
(hpp : h < ((F.witness j).spec.extra:ℕ))
|
| 118 |
+
(hpL : L < ((F.witness j).spec.extra:ℕ)) :
|
| 119 |
+
if t.Linear then ¬((t.modulus:ℕ):ℤ) ∣ t.coefficient else t.expression ≠ 0 := by
|
| 120 |
+
cases t with
|
| 121 |
+
| extra =>
|
| 122 |
+
simp only [Linear,ite_false,expression,ne_eq,sub_eq_zero]
|
| 123 |
+
intro he
|
| 124 |
+
have hi := (F.witness j).spec.offsets_distinct he
|
| 125 |
+
have hv := congrArg Fin.val hi
|
| 126 |
+
have hs := (F.witness j).spec.suffix.isLt
|
| 127 |
+
simp only [Fin.val_last,Fin.val_castSucc] at hv
|
| 128 |
+
omega
|
| 129 |
+
| tail q =>
|
| 130 |
+
rw [ite_eq_left (show (Test.tail (F:=F) (j:=j) q).Linear from trivial)]
|
| 131 |
+
exact (F.witness j).spec.suffix_coefficient_nondvd hh hpp hpL q ht.1 ht.2
|
| 132 |
+
| compare i q r hi =>
|
| 133 |
+
rw [ite_eq_left (show (Test.compare (F:=F) (j:=j) i q r hi).Linear from trivial)]
|
| 134 |
+
change ¬((r:ℕ):ℤ) ∣ _
|
| 135 |
+
rw [comparison_coefficient i q r hi ht]
|
| 136 |
+
exact (F.witness j).spec.prefix_coefficient_nondvd (F.witness j).primitive q r
|
| 137 |
+
ht.1 ht.2.1 ht.2.2.1
|
| 138 |
+
|
| 139 |
+
lemma modulus_ne_selected (t : F.Test j) (ht : t.Valid) (hl : t.Linear) :
|
| 140 |
+
t.modulus ≠ t.selected := by
|
| 141 |
+
cases t with
|
| 142 |
+
| extra => exact hl.elim
|
| 143 |
+
| tail q =>
|
| 144 |
+
intro he
|
| 145 |
+
change (F.witness j).spec.extra=q at he
|
| 146 |
+
apply (F.witness j).spec.extra_not_div (F.witness j).spec.tailStart
|
| 147 |
+
rw [he]
|
| 148 |
+
exact ht.1
|
| 149 |
+
| compare i q r hi =>
|
| 150 |
+
intro he
|
| 151 |
+
obtain ⟨e,he',hqe⟩ := ht.2.2.1
|
| 152 |
+
change r=q at he
|
| 153 |
+
apply ht.2.1 e he'
|
| 154 |
+
rw [he]
|
| 155 |
+
exact hqe
|
| 156 |
+
|
| 157 |
+
end Test
|
| 158 |
+
end PrivateFamily
|
| 159 |
+
end OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 160 |
+
|
| 161 |
+
end
|
| 162 |
+
|
| 163 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TestVacuous.lean
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.SpecPrimeSlot
|
| 2 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.AttachedMetadata
|
| 3 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.Cylinder
|
| 4 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.IntegerResidues
|
| 5 |
+
|
| 6 |
+
namespace OAI
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
open scoped BigOperators
|
| 10 |
+
open Finset
|
| 11 |
+
open Finset Classical
|
| 12 |
+
open Filter
|
| 13 |
+
open Finset Classical Filter
|
| 14 |
+
open scoped Topology
|
| 15 |
+
|
| 16 |
+
namespace OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 17 |
+
open OrdinaryCorrelations.SignedTrace OrdinaryCorrelations.SourceCylinder
|
| 18 |
+
open Finset Classical
|
| 19 |
+
variable {S : PrimeSystem} {B τ C₀ : ℝ} {D : S.DivisorFamily B τ C₀} {h ℓ L : ℕ}
|
| 20 |
+
|
| 21 |
+
instance (w : ClosedLine h ℓ) : Finite (AttachedSpec w D L) := by
|
| 22 |
+
apply Finite.of_injective
|
| 23 |
+
(fun s : AttachedSpec w D L => (attachedMetadata w s,specPrimeCode s.spec))
|
| 24 |
+
intro s t ht
|
| 25 |
+
exact attached_code_injective w s t (congrArg Prod.fst ht) (congrArg Prod.snd ht)
|
| 26 |
+
|
| 27 |
+
noncomputable instance (w : ClosedLine h ℓ) : Fintype (AttachedSpec w D L) := Fintype.ofFinite _
|
| 28 |
+
|
| 29 |
+
lemma Specification.test_vacuous (s : S.Specification D h L) (p : S.Index)
|
| 30 |
+
(hp : (p:ℕ) ∉ s.primeSupport) (b : ℤ) (a : ZMod (p:ℕ)) : s.ResidueTest p b a := by
|
| 31 |
+
constructor
|
| 32 |
+
· intro he
|
| 33 |
+
exact (hp (mem_insert.mpr (Or.inl he))).elim
|
| 34 |
+
· intro i hd
|
| 35 |
+
apply False.elim
|
| 36 |
+
apply hp
|
| 37 |
+
apply mem_insert_of_mem
|
| 38 |
+
apply mem_biUnion.mpr
|
| 39 |
+
refine ⟨i,mem_univ _,Nat.mem_primeFactors.mpr ⟨S.prime_mem p.val p.property,hd,?_⟩⟩
|
| 40 |
+
have := D.greater_one _ (s.label_mem i)
|
| 41 |
+
omega
|
| 42 |
+
|
| 43 |
+
lemma Specification.test_unique (s : S.Specification D h L) (p : S.Index)
|
| 44 |
+
(hp : (p:ℕ) ∈ s.primeSupport) (b : ℤ) (a a' : ZMod (p:ℕ))
|
| 45 |
+
(ha : s.ResidueTest p b a) (ha' : s.ResidueTest p b a') : a=a' := by
|
| 46 |
+
rcases mem_insert.mp hp with he | he
|
| 47 |
+
· exact add_right_cancel ((ha.1 he).trans (ha'.1 he).symm)
|
| 48 |
+
· obtain ⟨i,hi,hpi⟩ := mem_biUnion.mp he
|
| 49 |
+
have hd := (Nat.mem_primeFactors.mp hpi).2.1
|
| 50 |
+
exact add_right_cancel ((ha.2 i hd).trans (ha'.2 i hd).symm)
|
| 51 |
+
|
| 52 |
+
namespace AttachedSpec
|
| 53 |
+
variable {w : ClosedLine h ℓ}
|
| 54 |
+
|
| 55 |
+
noncomputable def origin (s : AttachedSpec w D L) : ℤ :=
|
| 56 |
+
Classical.choose s.primitive.1 - s.vertex
|
| 57 |
+
|
| 58 |
+
lemma origin_tests (s : AttachedSpec w D L) (p : S.Index) :
|
| 59 |
+
s.spec.ResidueTest p s.vertex (s.origin : ZMod (p:ℕ)) := by
|
| 60 |
+
apply (s.spec.qualifies_iff_residueTests s.origin s.vertex).mp
|
| 61 |
+
simpa only [origin,sub_add_cancel] using Classical.choose_spec s.primitive.1
|
| 62 |
+
|
| 63 |
+
noncomputable def fullCylinder (s : AttachedSpec w D L) :
|
| 64 |
+
Cylinder (fun p : S.Index => ZMod (p:ℕ)) :=
|
| 65 |
+
⟨fun p => if (p:ℕ) ∈ s.spec.primeSupport then some (s.origin : ZMod (p:ℕ)) else none⟩
|
| 66 |
+
|
| 67 |
+
lemma fullCylinder_holds (s : AttachedSpec w D L) (r : S.Residues) :
|
| 68 |
+
s.fullCylinder.Holds r ↔ ∀ p : S.Index, s.spec.ResidueTest p s.vertex (r p) := by
|
| 69 |
+
constructor
|
| 70 |
+
· intro hr p
|
| 71 |
+
by_cases hp : (p:ℕ) ∈ s.spec.primeSupport
|
| 72 |
+
· have he := hr p (s.origin : ZMod (p:ℕ)) (by simp only [fullCylinder,ite_eq_left hp])
|
| 73 |
+
rw [he]
|
| 74 |
+
exact s.origin_tests p
|
| 75 |
+
· exact s.spec.test_vacuous p hp s.vertex (r p)
|
| 76 |
+
· intro hr p a ha
|
| 77 |
+
by_cases hp : (p:ℕ) ∈ s.spec.primeSupport
|
| 78 |
+
· have he : (s.origin : ZMod (p:ℕ))=a := Option.some.inj (by
|
| 79 |
+
simpa only [fullCylinder,ite_eq_left hp] using ha)
|
| 80 |
+
exact (s.spec.test_unique p hp s.vertex (r p) _ (hr p) (s.origin_tests p)).trans he
|
| 81 |
+
· simp [fullCylinder,hp] at ha
|
| 82 |
+
|
| 83 |
+
@[simp] lemma mem_fullCylinder_support (s : AttachedSpec w D L) (p : S.Index) :
|
| 84 |
+
p ∈ s.fullCylinder.support ↔ (p:ℕ) ∈ s.spec.primeSupport := by
|
| 85 |
+
by_cases hp : (p:ℕ) ∈ s.spec.primeSupport <;>
|
| 86 |
+
simp [Cylinder.support,fullCylinder,hp]
|
| 87 |
+
|
| 88 |
+
lemma fullCylinder_width (s : AttachedSpec w D L) :
|
| 89 |
+
s.fullCylinder.support.card ≤ L*⌈C₀*Real.log B⌉₊+1 := by
|
| 90 |
+
have he : s.fullCylinder.support = univ.image (specSlotPrime s.spec) := by
|
| 91 |
+
ext p
|
| 92 |
+
simp only [mem_fullCylinder_support,mem_image,mem_univ,true_and]
|
| 93 |
+
exact specSupport_iff_slot s.spec p
|
| 94 |
+
rw [he]
|
| 95 |
+
exact card_image_le.trans (by simpa using specPrimeSlot_card s.spec)
|
| 96 |
+
|
| 97 |
+
lemma fullCylinder_integer (s : AttachedSpec w D L) (n : ℤ) :
|
| 98 |
+
s.fullCylinder.Holds (S.integerResidues n) ↔ s.spec.QualifiesAt (n+s.vertex) := by
|
| 99 |
+
rw [s.fullCylinder_holds]
|
| 100 |
+
exact (s.spec.qualifies_iff_residueTests n s.vertex).symm
|
| 101 |
+
|
| 102 |
+
end AttachedSpec
|
| 103 |
+
|
| 104 |
+
end OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 105 |
+
|
| 106 |
+
end
|
| 107 |
+
|
| 108 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TiltedListLocalMean.lean
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.AmplitudeGeOne
|
| 2 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.LocalUnlitCount
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
noncomputable section
|
| 7 |
+
open scoped BigOperators
|
| 8 |
+
open Finset
|
| 9 |
+
open Finset Classical
|
| 10 |
+
open Filter
|
| 11 |
+
open Finset Classical Filter
|
| 12 |
+
open scoped Topology
|
| 13 |
+
|
| 14 |
+
namespace OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 15 |
+
open OrdinaryCorrelations.SignedTrace OrdinaryCorrelations.FiniteIntegration
|
| 16 |
+
open Finset Classical
|
| 17 |
+
noncomputable section
|
| 18 |
+
variable {S : PrimeSystem} {B τ C₀ : ℝ} {D : S.DivisorFamily B τ C₀} {h ℓ L : ℕ}
|
| 19 |
+
|
| 20 |
+
lemma tilted_list_local_mean (w : ClosedLine h ℓ) (𝔏 : List (AttachedSpec w D L))
|
| 21 |
+
(p : S.Index) (z : ℝ) (hz : 1 ≤ z) (hzp : z^2 ≤ (p:ℝ)) :
|
| 22 |
+
avg (fun r => |localWithList w 𝔏 p r| * z^(repeatedUnlitLocal w p r)) ≤
|
| 23 |
+
S.amplitude p ^ S.occurrenceCount w p *
|
| 24 |
+
(if p ∈ fullUsedIndices w 𝔏 then ((ℓ:ℝ)+2)*(p:ℝ)⁻¹ else 1) := by
|
| 25 |
+
by_cases hr : ¬S.IsCore p ∧ 2 ≤ S.occurrenceCount w p
|
| 26 |
+
· have he : ∃ i, (p:ℕ) ∣ w.label i := by
|
| 27 |
+
have hm : (univ.filter (fun i : Fin ℓ => (p:ℕ) ∣ w.label i)).Nonempty := by
|
| 28 |
+
rw [←card_pos]; exact lt_of_lt_of_le (by norm_num) hr.2
|
| 29 |
+
obtain ⟨i,hi⟩ := hm
|
| 30 |
+
exact ⟨i,(mem_filter.mp hi).2⟩
|
| 31 |
+
have hp : p ∈ fullUsedIndices w 𝔏 := mem_filter.mpr ⟨mem_univ _,Or.inl he⟩
|
| 32 |
+
simp only [repeatedUnlitLocal,hr,amplitude,ite_false,one_pow,
|
| 33 |
+
one_mul,ite_eq_left hp]
|
| 34 |
+
calc
|
| 35 |
+
_ ≤ avg (fun r => |S.primeFactor w p r| *z^(localUnlitCount w p r)) := by
|
| 36 |
+
apply avg_mono
|
| 37 |
+
intro r
|
| 38 |
+
apply mul_le_mul_of_nonneg_right _ (pow_nonneg (zero_le_one.trans hz) _)
|
| 39 |
+
rw [localWithList,abs_mul,abs_of_nonneg (listLocal_nonneg w 𝔏 p r)]
|
| 40 |
+
exact mul_le_of_le_one_right (abs_nonneg _) (listLocal_le_one w 𝔏 p r)
|
| 41 |
+
_ ≤ ((ℓ:ℝ)+1)*(p:ℝ)⁻¹ := center_tilt_mean w p hr.1 hr.2 z hz hzp
|
| 42 |
+
_ ≤ _ := mul_le_mul_of_nonneg_right (by linarith) (by positivity)
|
| 43 |
+
· simp only [repeatedUnlitLocal,hr,ite_false,pow_zero,mul_one]
|
| 44 |
+
apply (crude_prime_mean w 𝔏 p).trans
|
| 45 |
+
apply mul_le_mul_of_nonneg_left _ (pow_nonneg (zero_le_one.trans (amplitude_ge_one p)) _)
|
| 46 |
+
split_ifs
|
| 47 |
+
· apply mul_le_mul_of_nonneg_right _ (by positivity)
|
| 48 |
+
linarith [(Nat.cast_nonneg ℓ : (0:ℝ) ≤ (ℓ:ℝ))]
|
| 49 |
+
· exact le_rfl
|
| 50 |
+
|
| 51 |
+
lemma repeated_unlit_tail_integral (w : ClosedLine h ℓ)
|
| 52 |
+
(hl : ∀ i, w.label i ∈ D.members) {T : ℝ} (cut : S.Cutoffs T)
|
| 53 |
+
(𝔏 : List (AttachedSpec w D L)) (z : ℝ) (hz : 1 ≤ z)
|
| 54 |
+
(hzp : ∀ p : S.Index, z^2 ≤ (p:ℝ)) (t : ℕ) :
|
| 55 |
+
(avg (fun r : S.Residues => if t ≤ repeatedUnlitTotal w r then
|
| 56 |
+
|S.kernel w cut r| *listIndicator w 𝔏 r else 0))*z^t ≤
|
| 57 |
+
A^(ℓ*⌈C₀*Real.log B⌉₊)*((ℓ:ℝ)+2)^(fullUsedIndices w 𝔏).card *
|
| 58 |
+
∏ p ∈ fullUsedIndices w 𝔏,(p:ℝ)⁻¹ := by
|
| 59 |
+
have hz0 : 0 ≤ z := zero_le_one.trans hz
|
| 60 |
+
have hpt (r : S.Residues) :
|
| 61 |
+
(if t ≤ repeatedUnlitTotal w r then |S.kernel w cut r| *listIndicator w 𝔏 r else 0)*z^t ≤
|
| 62 |
+
∏ p : S.Index, |localWithList w 𝔏 p (r p)| *z^(repeatedUnlitLocal w p (r p)) := by
|
| 63 |
+
rw [prod_mul_distrib,prod_pow_eq_pow_sum]
|
| 64 |
+
by_cases ht : t ≤ repeatedUnlitTotal w r
|
| 65 |
+
· rw [ite_eq_left ht,absolute_list_factorization]
|
| 66 |
+
apply mul_le_mul
|
| 67 |
+
· exact mul_le_of_le_one_left (prod_nonneg (fun p hp => abs_nonneg _)) (cutoffProduct_le_one w cut _)
|
| 68 |
+
· exact pow_le_pow_right₀ hz ht
|
| 69 |
+
· exact pow_nonneg hz0 _
|
| 70 |
+
· exact prod_nonneg (fun p hp => abs_nonneg _)
|
| 71 |
+
· rw [ite_eq_right ht,zero_mul]
|
| 72 |
+
exact mul_nonneg (prod_nonneg (fun p hp => abs_nonneg _)) (pow_nonneg hz0 _)
|
| 73 |
+
calc
|
| 74 |
+
_ = avg (fun r : S.Residues => (if t ≤ repeatedUnlitTotal w r then
|
| 75 |
+
|S.kernel w cut r| *listIndicator w 𝔏 r else 0)*z^t) := (avg_mul_right _ _).symm
|
| 76 |
+
_ ≤ avg (fun r : S.Residues => ∏ p : S.Index,
|
| 77 |
+
|localWithList w 𝔏 p (r p)| *z^(repeatedUnlitLocal w p (r p))) := avg_mono hpt
|
| 78 |
+
_ = ∏ p : S.Index, avg (fun r => |localWithList w 𝔏 p r| *z^(repeatedUnlitLocal w p r)) := by
|
| 79 |
+
convert avg_product (Ω := fun p : S.Index => ZMod (p:ℕ))
|
| 80 |
+
(fun p r => |localWithList w 𝔏 p r| *z^(repeatedUnlitLocal w p r)) using 1
|
| 81 |
+
congr 1
|
| 82 |
+
exact Subsingleton.elim _ _
|
| 83 |
+
_ ≤ ∏ p : S.Index, S.amplitude p ^ S.occurrenceCount w p *
|
| 84 |
+
(if p ∈ fullUsedIndices w 𝔏 then ((ℓ:ℝ)+2)*(p:ℝ)⁻¹ else 1) :=
|
| 85 |
+
prod_le_prod₀ (fun p hp => avg_nonneg (fun r => mul_nonneg (abs_nonneg _) (pow_nonneg hz0 _)))
|
| 86 |
+
(fun p hp => tilted_list_local_mean w 𝔏 p z hz (hzp p))
|
| 87 |
+
_ = (∏ p : S.Index, S.amplitude p ^ S.occurrenceCount w p)*
|
| 88 |
+
(((ℓ:ℝ)+2)^(fullUsedIndices w 𝔏).card * ∏ p ∈ fullUsedIndices w 𝔏,(p:ℝ)⁻¹) := by
|
| 89 |
+
rw [prod_mul_distrib,prod_ite_mem,univ_inter,prod_mul_distrib,prod_const]
|
| 90 |
+
_ ≤ _ := by
|
| 91 |
+
simpa only [mul_assoc] using mul_le_mul_of_nonneg_right (crude_amplitude_product w hl)
|
| 92 |
+
(by positivity : 0 ≤ ((ℓ:ℝ)+2)^(fullUsedIndices w 𝔏).card * ∏ p ∈ fullUsedIndices w 𝔏,(p:ℝ)⁻¹)
|
| 93 |
+
|
| 94 |
+
end
|
| 95 |
+
end OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 96 |
+
|
| 97 |
+
end
|
| 98 |
+
|
| 99 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TokenSlot.lean
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.AllSlotMasses
|
| 2 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.FlatSlot
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
noncomputable section
|
| 7 |
+
open scoped BigOperators
|
| 8 |
+
open Finset
|
| 9 |
+
open Finset Classical
|
| 10 |
+
open Filter
|
| 11 |
+
open Finset Classical Filter
|
| 12 |
+
|
| 13 |
+
namespace OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 14 |
+
open OrdinaryCorrelations.SignedTrace OrdinaryCorrelations.PivotSummation
|
| 15 |
+
open OrdinaryCorrelations.NumericalSubtrees
|
| 16 |
+
open Finset Classical Filter
|
| 17 |
+
variable {h ℓ : ℕ} {w : ClosedLine h ℓ} {S : PrimeSystem}
|
| 18 |
+
|
| 19 |
+
local instance tokenTypeDec (w : ClosedLine h ℓ) : DecidableEq (TokenType w) := Classical.decEq _
|
| 20 |
+
local instance primeIndexDec (S : PrimeSystem) : DecidableEq S.Index := Classical.decEq _
|
| 21 |
+
|
| 22 |
+
abbrev TokenSlot (j : TokenType w → ℕ) := FactorialAssignments.FlatSlot j
|
| 23 |
+
|
| 24 |
+
local instance tokenSlotDec (j : TokenType w → ℕ) : DecidableEq (TokenSlot j) := Classical.decEq _
|
| 25 |
+
|
| 26 |
+
def slotShape (j : TokenType w → ℕ) (s : TokenSlot j) : Shape w := s.1.2
|
| 27 |
+
|
| 28 |
+
def slotCore (j : TokenType w → ℕ) (s : TokenSlot j) : Prop := s.1.1 = true
|
| 29 |
+
|
| 30 |
+
def unorderedEdgeProduct (j : TokenType w → ℕ)
|
| 31 |
+
(U : FactorialAssignments.Unordered (P := S.Index) j) (e : Fin ℓ) : ℝ :=
|
| 32 |
+
∏ t : TokenType w, if e ∈ t.2.edges.val then ∏ p ∈ (U t).val, (p.val : ℝ) else 1
|
| 33 |
+
|
| 34 |
+
def unorderedBins (j : TokenType w → ℕ)
|
| 35 |
+
(C : Fin ℓ → ℝ) (H τ : ℝ) (U : FactorialAssignments.Unordered (P := S.Index) j) : Prop :=
|
| 36 |
+
∀ e ∈ w.treeSteps, H < C e * unorderedEdgeProduct j U e ∧
|
| 37 |
+
C e * unorderedEdgeProduct j U e ≤ τ*H
|
| 38 |
+
|
| 39 |
+
lemma slotEdgeProduct_named (j : TokenType w → ℕ)
|
| 40 |
+
(x : FactorialAssignments.Named (P := S.Index) j) (e : Fin ℓ) :
|
| 41 |
+
slotEdgeProduct (slotShape j) S (FactorialAssignments.namedFlat j x) e =
|
| 42 |
+
unorderedEdgeProduct j (FactorialAssignments.forget j x) e := by
|
| 43 |
+
let : DecidableEq S.Index := Classical.decEq _
|
| 44 |
+
unfold slotEdgeProduct unorderedEdgeProduct
|
| 45 |
+
rw [Fintype.prod_sigma]
|
| 46 |
+
apply prod_congr rfl
|
| 47 |
+
intro t ht
|
| 48 |
+
by_cases he : e ∈ t.2.edges.val
|
| 49 |
+
· simp only [slotShape,he,ite_true,FactorialAssignments.forget,
|
| 50 |
+
FactorialAssignments.forgetBlock]
|
| 51 |
+
rw [prod_image (fun i _ k _ hik => (x t).injective hik)]
|
| 52 |
+
apply prod_congr rfl
|
| 53 |
+
intro i hi
|
| 54 |
+
rfl
|
| 55 |
+
· simp only [slotShape,he,ite_false,prod_const_one]
|
| 56 |
+
|
| 57 |
+
lemma pivotBinIndicator_nonneg (j : TokenType w → ℕ)
|
| 58 |
+
(C : Fin ℓ → ℝ) (H τ : ℝ) (x : TokenSlot j → S.Index) :
|
| 59 |
+
0 ≤ pivotBinIndicator (slotShape j) (slotCore j) S C H τ x := by
|
| 60 |
+
unfold pivotBinIndicator
|
| 61 |
+
apply prod_nonneg
|
| 62 |
+
intro i hi
|
| 63 |
+
split_ifs <;> norm_num
|
| 64 |
+
|
| 65 |
+
lemma unorderedBins_gate (j : TokenType w → ℕ)
|
| 66 |
+
(C : Fin ℓ → ℝ) (H τ : ℝ) (x : FactorialAssignments.Named (P := S.Index) j)
|
| 67 |
+
(hx : unorderedBins j C H τ (FactorialAssignments.forget j x)) :
|
| 68 |
+
pivotBinIndicator (slotShape j) (slotCore j) S C H τ (FactorialAssignments.namedFlat j x) = 1 := by
|
| 69 |
+
unfold pivotBinIndicator
|
| 70 |
+
apply prod_eq_one
|
| 71 |
+
intro i hi
|
| 72 |
+
rw [slotEdgeProduct_named]
|
| 73 |
+
have he : (slotShape j (orderedPivot (slotShape j) (slotCore j) i)).topEdge ∈ w.treeSteps :=
|
| 74 |
+
Shape.grows _ |>.1 (Shape.topEdge_mem _)
|
| 75 |
+
exact ite_eq_left (hx _ he)
|
| 76 |
+
|
| 77 |
+
lemma token_constants_product (j : TokenType w → ℕ) (u : TokenType w → ℝ)
|
| 78 |
+
(x : TokenSlot j → S.Index) :
|
| 79 |
+
(∏ s : TokenSlot j, u s.1 * slotWeight S (slotCore j s) (x s)) =
|
| 80 |
+
(∏ t, u t ^ j t) * ∏ s : TokenSlot j, slotWeight S (slotCore j s) (x s) := by
|
| 81 |
+
rw [prod_mul_distrib]
|
| 82 |
+
congr 1
|
| 83 |
+
rw [Fintype.prod_sigma]
|
| 84 |
+
simp only [prod_const,card_univ,Fintype.card_fin]
|
| 85 |
+
|
| 86 |
+
lemma slot_mass_product (j : TokenType w → ℕ) (vC vZ : ℝ) :
|
| 87 |
+
(∏ s : TokenSlot j, if slotCore j s then vC else vZ) =
|
| 88 |
+
∏ t : TokenType w, tokenMass w vC vZ t ^ j t := by
|
| 89 |
+
rw [Fintype.prod_sigma]
|
| 90 |
+
apply prod_congr rfl
|
| 91 |
+
intro t ht
|
| 92 |
+
cases he : t.1 <;> simp [slotCore,tokenMass,he]
|
| 93 |
+
|
| 94 |
+
lemma token_gated_sum (j : TokenType w → ℕ) (u : TokenType w → ℝ)
|
| 95 |
+
(C : Fin ℓ → ℝ) (H τ : ℝ) :
|
| 96 |
+
(∑ x : TokenSlot j → S.Index,
|
| 97 |
+
pivotBinIndicator (slotShape j) (slotCore j) S C H τ x *
|
| 98 |
+
∏ s : TokenSlot j, u s.1 * slotWeight S (s.1.1=true) (x s)) =
|
| 99 |
+
(∏ t, u t ^ j t) *
|
| 100 |
+
(∑ x : TokenSlot j → S.Index,
|
| 101 |
+
pivotBinIndicator (slotShape j) (slotCore j) S C H τ x *
|
| 102 |
+
∏ s : TokenSlot j, slotWeight S (slotCore j s) (x s)) := by
|
| 103 |
+
rw [mul_sum]
|
| 104 |
+
apply sum_congr rfl
|
| 105 |
+
intro x hx
|
| 106 |
+
change _ * (∏ s : TokenSlot j, u s.1 * slotWeight S (slotCore j s) (x s)) = _
|
| 107 |
+
rw [token_constants_product]
|
| 108 |
+
ring
|
| 109 |
+
|
| 110 |
+
lemma token_mass_algebra (j : TokenType w → ℕ) (u : TokenType w → ℝ) (vC vZ K : ℝ) :
|
| 111 |
+
(∏ t, u t ^ j t) * (K * ∏ s : TokenSlot j, if slotCore j s then vC else vZ) =
|
| 112 |
+
K * ∏ t : TokenType w, (tokenMass w vC vZ t * u t) ^ j t := by
|
| 113 |
+
rw [slot_mass_product]
|
| 114 |
+
simp_rw [mul_pow]
|
| 115 |
+
rw [prod_mul_distrib]
|
| 116 |
+
ring
|
| 117 |
+
|
| 118 |
+
def tokenNamedSum (S : PrimeSystem) (j : TokenType w → ℕ)
|
| 119 |
+
(u : TokenType w → ℝ) (C : Fin ℓ → ℝ) (H τ : ℝ) : ℝ :=
|
| 120 |
+
∑ x : TokenSlot j → S.Index,
|
| 121 |
+
pivotBinIndicator (slotShape j) (slotCore j) S C H τ x *
|
| 122 |
+
∏ s : TokenSlot j, u s.1 * slotWeight S (s.1.1=true) (x s)
|
| 123 |
+
|
| 124 |
+
def tokenMassProduct (j : TokenType w → ℕ) (vC vZ : ℝ) (u : TokenType w → ℝ) : ℝ :=
|
| 125 |
+
∏ t : TokenType w, (tokenMass w vC vZ t * u t) ^ j t
|
| 126 |
+
|
| 127 |
+
def tokenFactorialProduct (j : TokenType w → ℕ) (vC vZ : ℝ) (u : TokenType w → ℝ) : ℝ :=
|
| 128 |
+
∏ t : TokenType w, (tokenMass w vC vZ t * u t) ^ j t / (j t).factorial
|
| 129 |
+
|
| 130 |
+
def unorderedTokenSum (S : PrimeSystem) (j : TokenType w → ℕ)
|
| 131 |
+
(u : TokenType w → ℝ) (C : Fin ℓ → ℝ) (H τ : ℝ)
|
| 132 |
+
(V : FactorialAssignments.Unordered (P := S.Index) j → Prop) : ℝ :=
|
| 133 |
+
∑ U : FactorialAssignments.Unordered (P := S.Index) j,
|
| 134 |
+
if V U ∧ unorderedBins j C H τ U then
|
| 135 |
+
FactorialAssignments.unorderedWeight j
|
| 136 |
+
(fun t p => u t * slotWeight S (t.1=true) p) U else 0
|
| 137 |
+
|
| 138 |
+
def NamedTokenBound (S : PrimeSystem) (K τ : ℝ) : Prop :=
|
| 139 |
+
∀ (h ℓ : ℕ) (w : ClosedLine h ℓ) (j : TokenType w → ℕ)
|
| 140 |
+
(C : Fin ℓ → ℝ), (∀ e, 0 < C e) → ∀ H : ℝ,
|
| 141 |
+
∀ (u : TokenType w → ℝ), (∀ t, 0 ≤ u t) →
|
| 142 |
+
tokenNamedSum S j u C H τ ≤
|
| 143 |
+
K^(pivotEdges (slotShape j) (slotCore j)).card *
|
| 144 |
+
tokenMassProduct j S.harmonicCore S.harmonicCenter u
|
| 145 |
+
|
| 146 |
+
def PrimeNamedBound (S : PrimeSystem) (K τ : ℝ) : Prop :=
|
| 147 |
+
∀ (h ℓ : ℕ) (w : ClosedLine h ℓ) (σ : Type) [Fintype σ],
|
| 148 |
+
∀ (q : σ → Shape w) (core : σ → Prop) (C : Fin ℓ → ℝ),
|
| 149 |
+
(∀ e, 0 < C e) → ∀ H : ℝ,
|
| 150 |
+
(∑ x : σ → S.Index, pivotBinIndicator q core S C H τ x *
|
| 151 |
+
∏ s, slotWeight S (core s) (x s)) ≤
|
| 152 |
+
K^(pivotEdges q core).card *
|
| 153 |
+
∏ s : σ, if core s then S.harmonicCore else S.harmonicCenter
|
| 154 |
+
|
| 155 |
+
lemma namedTokenBound_of_prime (S : PrimeSystem) (K τ : ℝ)
|
| 156 |
+
(hB : PrimeNamedBound S K τ) : NamedTokenBound S K τ := by
|
| 157 |
+
intro h ℓ w j C hC H u hu
|
| 158 |
+
unfold tokenNamedSum tokenMassProduct
|
| 159 |
+
rw [token_gated_sum]
|
| 160 |
+
have hp := hB h ℓ w (TokenSlot j) (slotShape j) (slotCore j) C hC H
|
| 161 |
+
have h0 : 0 ≤ ∏ t, u t ^ j t := prod_nonneg (fun t _ => pow_nonneg (hu t) _)
|
| 162 |
+
have he := mul_le_mul_of_nonneg_left hp h0
|
| 163 |
+
rw [token_mass_algebra] at he
|
| 164 |
+
exact he
|
| 165 |
+
|
| 166 |
+
lemma source_token_named_sum (τ : ℝ) (hτ : 0 < τ) :
|
| 167 |
+
∀ᶠ B : ℝ in atTop, NamedTokenBound (sourceSystem B)
|
| 168 |
+
(((Real.log 4+1)*τ)/B^(1-eta)) τ := by
|
| 169 |
+
filter_upwards [source_named_prime_sum τ hτ] with B hB
|
| 170 |
+
exact namedTokenBound_of_prime _ _ _ hB
|
| 171 |
+
|
| 172 |
+
def UnorderedTokenBound (S : PrimeSystem) (K τ : ℝ) : Prop :=
|
| 173 |
+
∀ (h ℓ : ℕ) (w : ClosedLine h ℓ) (j : TokenType w → ℕ)
|
| 174 |
+
(C : Fin ℓ → ℝ), (∀ e, 0 < C e) → ∀ H : ℝ,
|
| 175 |
+
∀ (V : FactorialAssignments.Unordered (P := S.Index) j → Prop)
|
| 176 |
+
(u : TokenType w → ℝ), (∀ t, 0 ≤ u t) →
|
| 177 |
+
unorderedTokenSum S j u C H τ V ≤
|
| 178 |
+
K^(pivotEdges (slotShape j) (slotCore j)).card *
|
| 179 |
+
tokenFactorialProduct j S.harmonicCore S.harmonicCenter u
|
| 180 |
+
|
| 181 |
+
lemma unorderedTokenBound_of_named (S : PrimeSystem) (K τ : ℝ)
|
| 182 |
+
(hB : NamedTokenBound S K τ) : UnorderedTokenBound S K τ := by
|
| 183 |
+
intro h ℓ w j C hC H V u hu
|
| 184 |
+
have hg := FactorialAssignments.unordered_gated_sum j
|
| 185 |
+
(fun U => V U ∧ unorderedBins j C H τ U)
|
| 186 |
+
(fun t p => u t * slotWeight S (t.1=true) p)
|
| 187 |
+
(fun t p => mul_nonneg (hu t) (slotWeight_nonneg _ _ _))
|
| 188 |
+
(pivotBinIndicator (slotShape j) (slotCore j) S C H τ)
|
| 189 |
+
(pivotBinIndicator_nonneg j C H τ)
|
| 190 |
+
(fun x hx => unorderedBins_gate j C H τ x hx.2)
|
| 191 |
+
have hp := hB h ℓ w j C hC H u hu
|
| 192 |
+
have hd : 0 ≤ ((∏ t : TokenType w, (j t).factorial : ℕ) : ℝ) := Nat.cast_nonneg _
|
| 193 |
+
have hc := hg.trans (div_le_div_of_nonneg_right hp hd)
|
| 194 |
+
unfold unorderedTokenSum
|
| 195 |
+
convert hc using 1
|
| 196 |
+
· apply Finset.sum_congr rfl
|
| 197 |
+
intro U hU
|
| 198 |
+
by_cases hv : V U ∧ unorderedBins j C H τ U <;> simp only [hv,ite_false]
|
| 199 |
+
· unfold tokenMassProduct tokenFactorialProduct
|
| 200 |
+
rw [prod_div_distrib,← Nat.cast_prod,mul_div_assoc]
|
| 201 |
+
|
| 202 |
+
theorem source_unordered_prime_sum (τ : ℝ) (hτ : 0 < τ) :
|
| 203 |
+
∀ᶠ B : ℝ in atTop, UnorderedTokenBound (sourceSystem B)
|
| 204 |
+
(((Real.log 4+1)*τ)/B^(1-eta)) τ := by
|
| 205 |
+
filter_upwards [source_token_named_sum τ hτ] with B hB
|
| 206 |
+
exact unorderedTokenBound_of_named _ _ _ hB
|
| 207 |
+
|
| 208 |
+
end OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 209 |
+
|
| 210 |
+
end
|
| 211 |
+
|
| 212 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/Topology.lean
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.TreeDestinationInjective
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
noncomputable section
|
| 6 |
+
open scoped BigOperators
|
| 7 |
+
open Finset
|
| 8 |
+
open Finset Classical
|
| 9 |
+
open Filter
|
| 10 |
+
|
| 11 |
+
namespace OrdinaryCorrelations.NumericalSubtrees
|
| 12 |
+
open OrdinaryCorrelations.SignedTrace OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 13 |
+
open Finset Classical
|
| 14 |
+
variable {h ℓ : ℕ}
|
| 15 |
+
|
| 16 |
+
@[reducible] def Topology (ℓ r : ℕ) :=
|
| 17 |
+
(R : {R : Finset (Fin ℓ) // R.card=r}) × ((Fin ℓ → Bool) × (↥R.val → Fin (ℓ+1)))
|
| 18 |
+
|
| 19 |
+
lemma topology_card (ℓ r : ℕ) : Fintype.card (Topology ℓ r) ≤ 4^ℓ*(ℓ+1)^r := by
|
| 20 |
+
rw [Fintype.card_sigma]
|
| 21 |
+
have he : ∀ R : {R : Finset (Fin ℓ) // R.card=r},
|
| 22 |
+
Fintype.card ((Fin ℓ → Bool) × (↥R.val → Fin (ℓ+1))) = 2^ℓ*(ℓ+1)^r := by
|
| 23 |
+
intro R
|
| 24 |
+
simp only [Fintype.card_prod,Fintype.card_fun,Fintype.card_bool,Fintype.card_fin,
|
| 25 |
+
Fintype.card_coe,R.property]
|
| 26 |
+
simp_rw [he]
|
| 27 |
+
rw [sum_const,nsmul_eq_mul,Nat.cast_id,card_univ]
|
| 28 |
+
have hc : Fintype.card {R : Finset (Fin ℓ) // R.card=r} ≤ 2^ℓ := by
|
| 29 |
+
simpa only [Fintype.card_finset,Fintype.card_fin] using
|
| 30 |
+
Fintype.card_subtype_le (fun R : Finset (Fin ℓ) => R.card=r)
|
| 31 |
+
calc
|
| 32 |
+
_ ≤ 2^ℓ*(2^ℓ*(ℓ+1)^r) := Nat.mul_le_mul_right _ hc
|
| 33 |
+
_ = _ := by rw [← mul_assoc,← mul_pow]; norm_num
|
| 34 |
+
|
| 35 |
+
lemma exists_return_target (w : ClosedLine h ℓ) (e : Fin ℓ) (he : e ∈ returnSteps w) :
|
| 36 |
+
∃ j : Fin (ℓ+1), j.val ≤ e.val ∧ w.offset j = w.offset e.succ := by
|
| 37 |
+
have hn : ¬∀ j : Fin (ℓ+1), j.val ≤ e.val → w.offset j ≠ w.offset e.succ := by
|
| 38 |
+
intro ht
|
| 39 |
+
exact (mem_sdiff.mp he).2 (mem_filter.mpr ⟨mem_univ _,ht⟩)
|
| 40 |
+
push Not at hn
|
| 41 |
+
exact hn
|
| 42 |
+
|
| 43 |
+
def returnTarget (w : ClosedLine h ℓ) (e : Fin ℓ) (he : e ∈ returnSteps w) : Fin (ℓ+1) :=
|
| 44 |
+
Classical.choose (exists_return_target w e he)
|
| 45 |
+
|
| 46 |
+
lemma returnTarget_spec (w : ClosedLine h ℓ) (e : Fin ℓ) (he : e ∈ returnSteps w) :
|
| 47 |
+
(returnTarget w e he).val ≤ e.val ∧ w.offset (returnTarget w e he) = w.offset e.succ :=
|
| 48 |
+
Classical.choose_spec (exists_return_target w e he)
|
| 49 |
+
|
| 50 |
+
def signBit (w : ClosedLine h ℓ) (e : Fin ℓ) : Bool := decide (w.sign e=1)
|
| 51 |
+
|
| 52 |
+
lemma signBit_decode (w : ClosedLine h ℓ) (e : Fin ℓ) :
|
| 53 |
+
w.sign e = if signBit w e then 1 else -1 := by
|
| 54 |
+
rcases w.sign_mem e with hs | hs <;> simp [signBit,hs]
|
| 55 |
+
|
| 56 |
+
def encodeTopology (w : ClosedLine h ℓ) (r : ℕ) (hr : (returnSteps w).card=r) : Topology ℓ r :=
|
| 57 |
+
⟨⟨returnSteps w,hr⟩, signBit w, fun e => returnTarget w e.val e.property⟩
|
| 58 |
+
|
| 59 |
+
def topologyTarget {r : ℕ} (t : Topology ℓ r) (e : Fin ℓ) : Fin (ℓ+1) :=
|
| 60 |
+
if he : e ∈ t.1.val then t.2.2 ⟨e,he⟩ else 0
|
| 61 |
+
|
| 62 |
+
lemma topologyTarget_encode (w : ClosedLine h ℓ) (r : ℕ) (hr : (returnSteps w).card=r)
|
| 63 |
+
(e : Fin ℓ) (he : e ∈ returnSteps w) :
|
| 64 |
+
topologyTarget (encodeTopology w r hr) e = returnTarget w e he := by
|
| 65 |
+
dsimp only [topologyTarget,encodeTopology]
|
| 66 |
+
rw [dite_eq_left he]
|
| 67 |
+
|
| 68 |
+
lemma ClosedLine.ext_values (w v : ClosedLine h ℓ)
|
| 69 |
+
(ho : w.offset=v.offset) (hl : w.label=v.label) (hs : w.sign=v.sign) : w=v := by
|
| 70 |
+
cases w
|
| 71 |
+
cases v
|
| 72 |
+
simp_all
|
| 73 |
+
|
| 74 |
+
theorem topology_tree_labels_injective (w v : ClosedLine h ℓ) (hh : 0 < h)
|
| 75 |
+
(r : ℕ) (hwr : (returnSteps w).card=r) (hvr : (returnSteps v).card=r)
|
| 76 |
+
(ht : encodeTopology w r hwr=encodeTopology v r hvr)
|
| 77 |
+
(hl : ∀ e ∈ w.treeSteps, w.label e=v.label e) : w=v := by
|
| 78 |
+
have hR : returnSteps w=returnSteps v := congrArg (fun t : Topology ℓ r => t.1.val) ht
|
| 79 |
+
have hs : ∀ e, w.sign e=v.sign e := by
|
| 80 |
+
intro e
|
| 81 |
+
have hb : signBit w e=signBit v e := congrArg (fun t : Topology ℓ r => t.2.1 e) ht
|
| 82 |
+
rw [signBit_decode w e,signBit_decode v e,hb]
|
| 83 |
+
have htar : ∀ e (he : e ∈ returnSteps w),
|
| 84 |
+
returnTarget w e he=returnTarget v e (hR ▸ he) := by
|
| 85 |
+
intro e he
|
| 86 |
+
have hte := congrArg (fun t : Topology ℓ r => topologyTarget t e) ht
|
| 87 |
+
simpa only [topologyTarget_encode w r hwr e he,
|
| 88 |
+
topologyTarget_encode v r hvr e (hR ▸ he)] using hte
|
| 89 |
+
have ho : ∀ j, w.offset j=v.offset j := by
|
| 90 |
+
have hd : ∀ n : ℕ, ∀ j : Fin (ℓ+1), j.val=n → w.offset j=v.offset j := by
|
| 91 |
+
intro n
|
| 92 |
+
induction n using Nat.strong_induction_on with
|
| 93 |
+
| h n ih =>
|
| 94 |
+
intro j hj
|
| 95 |
+
by_cases hj0 : j=0
|
| 96 |
+
· subst j
|
| 97 |
+
rw [w.start_zero,v.start_zero]
|
| 98 |
+
· obtain ⟨e,rfl⟩ := Fin.exists_succ_eq.mpr hj0
|
| 99 |
+
have heprev := ih e.val (by simpa only [← hj,Fin.val_succ] using Nat.lt_succ_self e.val)
|
| 100 |
+
e.castSucc rfl
|
| 101 |
+
by_cases het : e ∈ w.treeSteps
|
| 102 |
+
· have hw := w.step e
|
| 103 |
+
have hv := v.step e
|
| 104 |
+
rw [hl e het,hs e] at hw
|
| 105 |
+
linarith only [hw,hv,heprev]
|
| 106 |
+
· have her : e ∈ returnSteps w := mem_sdiff.mpr ⟨mem_univ _,het⟩
|
| 107 |
+
have hert : (returnTarget w e her).val<n := by
|
| 108 |
+
have hle := (returnTarget_spec w e her).1
|
| 109 |
+
simp only [Fin.val_succ] at hj
|
| 110 |
+
omega
|
| 111 |
+
have hi := ih _ hert (returnTarget w e her) rfl
|
| 112 |
+
rw [(returnTarget_spec w e her).2,htar e her,
|
| 113 |
+
(returnTarget_spec v e (hR ▸ her)).2] at hi
|
| 114 |
+
exact hi
|
| 115 |
+
intro j
|
| 116 |
+
exact hd j.val j rfl
|
| 117 |
+
have hall : ∀ e, w.label e=v.label e := by
|
| 118 |
+
intro e
|
| 119 |
+
have hw := w.step e
|
| 120 |
+
have hv := v.step e
|
| 121 |
+
rw [ho e.succ,ho e.castSucc,hs e] at hw
|
| 122 |
+
have hn : v.sign e*(h : ℤ) ≠ 0 := mul_ne_zero
|
| 123 |
+
(by rcases v.sign_mem e with hs | hs <;> rw [hs] <;> norm_num)
|
| 124 |
+
(by exact_mod_cast ne_of_gt hh)
|
| 125 |
+
have hm : (v.sign e*(h : ℤ))*(w.label e : ℤ) =
|
| 126 |
+
(v.sign e*(h : ℤ))*(v.label e : ℤ) := hw.symm.trans hv
|
| 127 |
+
have he := mul_left_cancel₀ hn hm
|
| 128 |
+
exact_mod_cast he
|
| 129 |
+
exact ClosedLine.ext_values w v (funext ho) (funext hall) (funext hs)
|
| 130 |
+
|
| 131 |
+
end OrdinaryCorrelations.NumericalSubtrees
|
| 132 |
+
|
| 133 |
+
end
|
| 134 |
+
|
| 135 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TopologyTreeSteps.lean
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.BitWeight
|
| 2 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.Topology
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
noncomputable section
|
| 7 |
+
open scoped BigOperators
|
| 8 |
+
open Finset
|
| 9 |
+
open Finset Classical
|
| 10 |
+
open Filter
|
| 11 |
+
open Finset Classical Filter
|
| 12 |
+
|
| 13 |
+
namespace OrdinaryCorrelations.NumericalSubtrees
|
| 14 |
+
open OrdinaryCorrelations.SignedTrace OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 15 |
+
open Finset Classical
|
| 16 |
+
variable {h ℓ r : ℕ} {w v : ClosedLine h ℓ}
|
| 17 |
+
|
| 18 |
+
lemma topology_treeSteps (hw : (returnSteps w).card=r) (hv : (returnSteps v).card=r)
|
| 19 |
+
(ht : encodeTopology w r hw=encodeTopology v r hv) : w.treeSteps=v.treeSteps := by
|
| 20 |
+
have hr : returnSteps w=returnSteps v := congrArg (fun t : Topology ℓ r => t.1.val) ht
|
| 21 |
+
ext e
|
| 22 |
+
have he := congrArg (fun E => e ∈ E) hr
|
| 23 |
+
simp only [returnSteps,Finset.mem_sdiff,mem_univ,true_and] at he
|
| 24 |
+
tauto
|
| 25 |
+
|
| 26 |
+
lemma topology_target_eq (hw : (returnSteps w).card=r) (hv : (returnSteps v).card=r)
|
| 27 |
+
(ht : encodeTopology w r hw=encodeTopology v r hv)
|
| 28 |
+
(e : Fin ℓ) (hew : e ∈ returnSteps w) (hev : e ∈ returnSteps v) :
|
| 29 |
+
returnTarget w e hew = returnTarget v e hev := by
|
| 30 |
+
have hte := congrArg (fun t : Topology ℓ r => topologyTarget t e) ht
|
| 31 |
+
simpa only [topologyTarget_encode w r hw e hew,
|
| 32 |
+
topologyTarget_encode v r hv e hev] using hte
|
| 33 |
+
|
| 34 |
+
theorem topology_offset_pattern (hw : (returnSteps w).card=r) (hv : (returnSteps v).card=r)
|
| 35 |
+
(ht : encodeTopology w r hw=encodeTopology v r hv) (i j : Fin (ℓ+1)) :
|
| 36 |
+
w.offset i=w.offset j ↔ v.offset i=v.offset j := by
|
| 37 |
+
have htree := topology_treeSteps hw hv ht
|
| 38 |
+
have H : ∀ k : ℕ, ∀ i j : Fin (ℓ+1), i.val≤k → j.val≤k →
|
| 39 |
+
(w.offset i=w.offset j ↔ v.offset i=v.offset j) := by
|
| 40 |
+
intro k
|
| 41 |
+
induction k with
|
| 42 |
+
| zero =>
|
| 43 |
+
intro i j hi hj
|
| 44 |
+
have hij : i=j := Fin.ext (by omega)
|
| 45 |
+
subst j
|
| 46 |
+
simp
|
| 47 |
+
| succ k ih =>
|
| 48 |
+
intro i j hi hj
|
| 49 |
+
by_cases hik : i.val≤k
|
| 50 |
+
· by_cases hjk : j.val≤k
|
| 51 |
+
· exact ih i j hik hjk
|
| 52 |
+
· have hjev : j.val=k+1 := by omega
|
| 53 |
+
let e : Fin ℓ := ⟨k,by omega⟩
|
| 54 |
+
have hje : j=e.succ := Fin.ext hjev
|
| 55 |
+
rw [hje]
|
| 56 |
+
by_cases het : e ∈ w.treeSteps
|
| 57 |
+
· have hevt : e ∈ v.treeSteps := htree ▸ het
|
| 58 |
+
have hwn : w.offset i≠w.offset e.succ := (mem_filter.mp het).2 i hik
|
| 59 |
+
have hvn : v.offset i≠v.offset e.succ := (mem_filter.mp hevt).2 i hik
|
| 60 |
+
simp [hwn,hvn]
|
| 61 |
+
· have hew : e ∈ returnSteps w := Finset.mem_sdiff.mpr ⟨mem_univ _,het⟩
|
| 62 |
+
have hev : e ∈ returnSteps v := by
|
| 63 |
+
apply Finset.mem_sdiff.mpr
|
| 64 |
+
exact ⟨mem_univ _,by simpa only [← htree] using het⟩
|
| 65 |
+
have hetar := topology_target_eq hw hv ht e hew hev
|
| 66 |
+
have hs := returnTarget_spec w e hew
|
| 67 |
+
have hs' := returnTarget_spec v e hev
|
| 68 |
+
rw [← hs.2,← hs'.2,← hetar]
|
| 69 |
+
exact ih i (returnTarget w e hew) hik hs.1
|
| 70 |
+
· by_cases hjk : j.val≤k
|
| 71 |
+
· have hie : i.val=k+1 := by omega
|
| 72 |
+
let e : Fin ℓ := ⟨k,by omega⟩
|
| 73 |
+
have hi' : i=e.succ := Fin.ext hie
|
| 74 |
+
rw [hi']
|
| 75 |
+
by_cases het : e ∈ w.treeSteps
|
| 76 |
+
· have hevt : e ∈ v.treeSteps := htree ▸ het
|
| 77 |
+
have hwn : w.offset e.succ≠w.offset j := Ne.symm ((mem_filter.mp het).2 j hjk)
|
| 78 |
+
have hvn : v.offset e.succ≠v.offset j := Ne.symm ((mem_filter.mp hevt).2 j hjk)
|
| 79 |
+
simp [hwn,hvn]
|
| 80 |
+
· have hew : e ∈ returnSteps w := Finset.mem_sdiff.mpr ⟨mem_univ _,het⟩
|
| 81 |
+
have hev : e ∈ returnSteps v := by
|
| 82 |
+
apply Finset.mem_sdiff.mpr
|
| 83 |
+
exact ⟨mem_univ _,by simpa only [← htree] using het⟩
|
| 84 |
+
have hetar := topology_target_eq hw hv ht e hew hev
|
| 85 |
+
have hs := returnTarget_spec w e hew
|
| 86 |
+
have hs' := returnTarget_spec v e hev
|
| 87 |
+
rw [← hs.2,← hs'.2,← hetar]
|
| 88 |
+
exact ih (returnTarget w e hew) j hs.1 hjk
|
| 89 |
+
· have hij : i=j := Fin.ext (by omega)
|
| 90 |
+
subst j
|
| 91 |
+
simp
|
| 92 |
+
exact H ℓ i j (by omega) (by omega)
|
| 93 |
+
|
| 94 |
+
structure SameGeometry (w v : ClosedLine h ℓ) : Prop where
|
| 95 |
+
trees : w.treeSteps=v.treeSteps
|
| 96 |
+
pattern : ∀ i j, w.offset i=w.offset j ↔ v.offset i=v.offset j
|
| 97 |
+
|
| 98 |
+
lemma sameGeometry_of_topology (hw : (returnSteps w).card=r) (hv : (returnSteps v).card=r)
|
| 99 |
+
(ht : encodeTopology w r hw=encodeTopology v r hv) : SameGeometry w v :=
|
| 100 |
+
⟨topology_treeSteps hw hv ht,topology_offset_pattern hw hv ht⟩
|
| 101 |
+
|
| 102 |
+
namespace SameGeometry
|
| 103 |
+
lemma symm (H : SameGeometry w v) : SameGeometry v w :=
|
| 104 |
+
⟨H.trees.symm,fun i j => (H.pattern i j).symm⟩
|
| 105 |
+
|
| 106 |
+
lemma children (H : SameGeometry w v) (i : Fin (ℓ+1)) :
|
| 107 |
+
w.children (w.offset i)=v.children (v.offset i) := by
|
| 108 |
+
unfold ClosedLine.children
|
| 109 |
+
apply congrArg Finset.card
|
| 110 |
+
ext e
|
| 111 |
+
simp only [mem_filter,H.trees,H.pattern]
|
| 112 |
+
|
| 113 |
+
lemma root (H : SameGeometry w v) (i : Fin (ℓ+1)) : w.offset i=0 ↔ v.offset i=0 := by
|
| 114 |
+
simpa only [w.start_zero,v.start_zero] using H.pattern i 0
|
| 115 |
+
|
| 116 |
+
lemma noReturn (H : SameGeometry w v) (i : Fin (ℓ+1)) :
|
| 117 |
+
w.NoReturnIncidence (w.offset i) ↔ v.NoReturnIncidence (v.offset i) := by
|
| 118 |
+
simp only [ClosedLine.NoReturnIncidence,ne_eq,H.trees,H.pattern]
|
| 119 |
+
|
| 120 |
+
lemma good (H : SameGeometry w v) (e : Fin ℓ) : w.Good e ↔ v.Good e := by
|
| 121 |
+
simp only [ClosedLine.Good,ne_eq,H.trees,H.children,H.root,H.noReturn]
|
| 122 |
+
|
| 123 |
+
lemma grows (H : SameGeometry w v) (i : Fin (ℓ+1)) (E : Finset (Fin ℓ)) :
|
| 124 |
+
Grows w (w.offset i) E ↔ Grows v (v.offset i) E := by
|
| 125 |
+
simp only [Grows,H.trees,H.pattern]
|
| 126 |
+
|
| 127 |
+
end SameGeometry
|
| 128 |
+
|
| 129 |
+
end OrdinaryCorrelations.NumericalSubtrees
|
| 130 |
+
|
| 131 |
+
end
|
| 132 |
+
|
| 133 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TotalCodeMass.lean
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.FirstSlot
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
noncomputable section
|
| 6 |
+
open scoped BigOperators
|
| 7 |
+
open Finset
|
| 8 |
+
open Finset Classical
|
| 9 |
+
open Filter
|
| 10 |
+
open Finset Classical Filter
|
| 11 |
+
open scoped Topology
|
| 12 |
+
|
| 13 |
+
namespace OrdinaryCorrelations.SharedSlotPatterns
|
| 14 |
+
open Finset Classical
|
| 15 |
+
variable {σ P : Type*} [Fintype σ] [Fintype P] [DecidableEq P]
|
| 16 |
+
|
| 17 |
+
lemma total_code_mass (W : P → ℝ) (hW : ∀ p, 0 ≤ W p) :
|
| 18 |
+
(∑ x : σ → Option P, ∏ p ∈ support x, W p) ≤
|
| 19 |
+
(Fintype.card σ+1:ℝ)*(Fintype.card σ+1:ℝ)^(Fintype.card σ)*
|
| 20 |
+
(max 1 (∑ p,W p))^(Fintype.card σ) := by
|
| 21 |
+
let N := Fintype.card σ
|
| 22 |
+
let H : ℝ := max 1 (∑ p,W p)
|
| 23 |
+
have hH : 1 ≤ H := le_max_left _ _
|
| 24 |
+
have he := weighted_code_sum (σ:=σ) (fun _ => 1) (by intro; norm_num) W hW
|
| 25 |
+
simp only [one_mul] at he
|
| 26 |
+
apply he.trans
|
| 27 |
+
change (∑ z : (m : Fin (N+1)) × (σ → Option (Fin m.val)) × (Fin m.val → P),
|
| 28 |
+
∏ i, W (z.2.2 i)) ≤ _
|
| 29 |
+
rw [Fintype.sum_sigma]
|
| 30 |
+
calc
|
| 31 |
+
_ ≤ ∑ m : Fin (N+1), ((N+1:ℝ)^N*H^N) := by
|
| 32 |
+
apply sum_le_sum
|
| 33 |
+
intro m hm
|
| 34 |
+
rw [Fintype.sum_prod_type]
|
| 35 |
+
have hrow : (∑ v : Fin m.val → P, ∏ i, W (v i)) ≤ H^N := by
|
| 36 |
+
rw [←Fintype.prod_sum]
|
| 37 |
+
simp only [prod_const,card_univ,Fintype.card_fin]
|
| 38 |
+
apply (pow_le_pow_left₀ (sum_nonneg (fun p hp => hW p)) (le_max_right (1:ℝ) _) _).trans
|
| 39 |
+
exact pow_le_pow_right₀ hH (Nat.lt_succ_iff.mp m.isLt)
|
| 40 |
+
calc
|
| 41 |
+
_ ≤ ∑ _d : σ → Option (Fin m.val), H^N := sum_le_sum (fun d hd => hrow)
|
| 42 |
+
_ = ((m.val+1:ℕ):ℝ)^N*H^N := by simp [N]
|
| 43 |
+
_ ≤ _ := by
|
| 44 |
+
apply mul_le_mul_of_nonneg_right _ (pow_nonneg (zero_le_one.trans hH) _)
|
| 45 |
+
apply pow_le_pow_left₀ (by positivity)
|
| 46 |
+
have hm' : m.val ≤ N := Nat.lt_succ_iff.mp m.isLt
|
| 47 |
+
exact_mod_cast Nat.add_le_add_right hm' 1
|
| 48 |
+
_ = _ := by simp [N,H]; ring
|
| 49 |
+
|
| 50 |
+
end OrdinaryCorrelations.SharedSlotPatterns
|
| 51 |
+
|
| 52 |
+
end
|
| 53 |
+
|
| 54 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TotalUnlitCountEqSubtype.lean
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.AllCoreLit
|
| 2 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.UncutTreeEdges
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
noncomputable section
|
| 7 |
+
open scoped BigOperators
|
| 8 |
+
open Finset
|
| 9 |
+
open Finset Classical
|
| 10 |
+
open Filter
|
| 11 |
+
open Finset Classical Filter
|
| 12 |
+
open scoped Topology
|
| 13 |
+
|
| 14 |
+
namespace OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 15 |
+
open OrdinaryCorrelations.SignedTrace Finset Classical
|
| 16 |
+
noncomputable section
|
| 17 |
+
variable {S : PrimeSystem} {h ℓ : ℕ}
|
| 18 |
+
|
| 19 |
+
lemma totalUnlitCount_eq_subtype (w : ClosedLine h ℓ) (a : S.FixedResidues w) :
|
| 20 |
+
totalUnlitCount w a = ∑ p : S.FixedIndex w, (unlitOccurrences w p.val (a p)).card := by
|
| 21 |
+
have he := Finset.sum_subtype (F:=inferInstance) (p:=S.IsFixed w)
|
| 22 |
+
(univ.filter (S.IsFixed w)) (by simp) (fixedUnlitCount w a)
|
| 23 |
+
rw [sum_filter] at he
|
| 24 |
+
have hf : (∑ p : S.Index, if S.IsFixed w p then fixedUnlitCount w a p else 0) =
|
| 25 |
+
totalUnlitCount w a := by
|
| 26 |
+
apply sum_congr rfl
|
| 27 |
+
intro p hp
|
| 28 |
+
by_cases hh : S.IsFixed w p <;> simp [hh,fixedUnlitCount]
|
| 29 |
+
rw [hf] at he
|
| 30 |
+
exact he.trans (sum_congr rfl (fun p hp => by simp [fixedUnlitCount,p.property]))
|
| 31 |
+
|
| 32 |
+
lemma cut_tree_edges_le_unlit (w : ClosedLine h ℓ) (a : S.FixedResidues w) :
|
| 33 |
+
(w.treeSteps \ uncutTreeEdges w a).card ≤ totalUnlitCount w a := by
|
| 34 |
+
have hs : w.treeSteps \ uncutTreeEdges w a ⊆
|
| 35 |
+
univ.biUnion (fun p : S.FixedIndex w => unlitOccurrences w p.val (a p)) := by
|
| 36 |
+
intro e he
|
| 37 |
+
have ht := (mem_sdiff.mp he).1
|
| 38 |
+
have hn : ¬ ∀ p : S.FixedIndex w, (p.val:ℕ) ∣ w.label e →
|
| 39 |
+
a p+(w.offset e.castSucc : ZMod (p.val:ℕ))=0 := by
|
| 40 |
+
intro ha
|
| 41 |
+
exact (mem_sdiff.mp he).2 (mem_filter.mpr ⟨ht,ha⟩)
|
| 42 |
+
push Not at hn
|
| 43 |
+
obtain ⟨p,hp,ha⟩ := hn
|
| 44 |
+
exact mem_biUnion.mpr ⟨p,mem_univ _,mem_filter.mpr ⟨mem_univ e,hp,ha⟩⟩
|
| 45 |
+
rw [totalUnlitCount_eq_subtype]
|
| 46 |
+
exact (card_le_card hs).trans (card_biUnion_le ..)
|
| 47 |
+
|
| 48 |
+
lemma cut_tree_edges_lt_of_core_lit (w : ClosedLine h ℓ) (a : S.FixedResidues w)
|
| 49 |
+
(hc : AllCoreLit w a) (t : ℕ) (hu : repeatedCenterUnlitCount w a<t) :
|
| 50 |
+
(w.treeSteps \ uncutTreeEdges w a).card < t := by
|
| 51 |
+
exact (cut_tree_edges_le_unlit w a).trans_lt ((totalUnlit_eq_center w a hc).symm ▸ hu)
|
| 52 |
+
|
| 53 |
+
end
|
| 54 |
+
end OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 55 |
+
|
| 56 |
+
end
|
| 57 |
+
|
| 58 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TreeBlocksWithEdges.lean
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.TreeEdgeInjective
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
noncomputable section
|
| 6 |
+
open scoped BigOperators
|
| 7 |
+
open Finset
|
| 8 |
+
open Finset Classical
|
| 9 |
+
open Filter
|
| 10 |
+
open Finset Classical Filter
|
| 11 |
+
open scoped Topology
|
| 12 |
+
|
| 13 |
+
namespace OrdinaryCorrelations.NumericalSubtrees
|
| 14 |
+
open OrdinaryCorrelations.SignedTrace OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 15 |
+
open OrdinaryCorrelations.ForestTraversal Finset Classical SimpleGraph
|
| 16 |
+
noncomputable section
|
| 17 |
+
variable {h ℓ : ℕ}
|
| 18 |
+
|
| 19 |
+
theorem tree_blocks_with_edges (w : ClosedLine h ℓ) (hh : 0<h) (H : Finset (Fin ℓ))
|
| 20 |
+
(L : ℕ) (hL : 0<L) :
|
| 21 |
+
∃ bs : List (Block (edgeGraph w hh (w.treeSteps \ H))),
|
| 22 |
+
bs.length ≤ (2*ℓ)/L+2*H.card+1 ∧
|
| 23 |
+
(∀ b ∈ bs,b.walk.length ≤ L) ∧
|
| 24 |
+
(∀ z ∈ treeVertices w,∃ b ∈ bs,z ∈ b.walk.support) ∧
|
| 25 |
+
(∀ e ∈ w.treeSteps \ H,∃ b ∈ bs,treeEdge w e ∈ b.walk.edges) := by
|
| 26 |
+
obtain ⟨p,hplen,hcover,hcount⟩ := grown_tour w hh 0 w.treeSteps (grows_full_tree w)
|
| 27 |
+
obtain ⟨bs,hbs,hbl,hbc⟩ := chunk_cut_cover (edgeGraph w hh (w.treeSteps \ H)) L hL p
|
| 28 |
+
refine ⟨bs,?_,hbl,?_,?_⟩
|
| 29 |
+
· have hcut := tour_cutCount w hh H p hcount
|
| 30 |
+
have hcard : w.treeSteps.card ≤ ℓ := by simpa using card_le_univ w.treeSteps
|
| 31 |
+
have hlen : p.length ≤ 2*ℓ := by rw [hplen]; omega
|
| 32 |
+
exact hbs.trans (Nat.add_le_add_right (Nat.add_le_add (Nat.div_le_div_right hlen) hcut) 1)
|
| 33 |
+
· intro z hz
|
| 34 |
+
exact hbc.1 z (hcover z (reached_full_tree w ▸ hz))
|
| 35 |
+
· intro e he
|
| 36 |
+
apply hbc.2
|
| 37 |
+
· apply List.count_pos_iff.mp
|
| 38 |
+
rw [hcount]
|
| 39 |
+
have hc : 0<(w.treeSteps.filter (fun f => treeEdge w f=treeEdge w e)).card :=
|
| 40 |
+
card_pos.mpr ⟨e,mem_filter.mpr ⟨(mem_sdiff.mp he).1,rfl⟩⟩
|
| 41 |
+
omega
|
| 42 |
+
· exact edgeGraph_adj w hh _ e he
|
| 43 |
+
|
| 44 |
+
theorem full_tree_blocks (w : ClosedLine h ℓ) (hh : 0<h) (L : ℕ) (hL : 0<L) :
|
| 45 |
+
∃ bs : List (Block (edgeGraph w hh w.treeSteps)),
|
| 46 |
+
bs.length ≤ (2*ℓ)/L+1 ∧ (∀ b ∈ bs,b.walk.length ≤ L) ∧
|
| 47 |
+
(∀ z ∈ treeVertices w,∃ b ∈ bs,z ∈ b.walk.support) ∧
|
| 48 |
+
(∀ e ∈ w.treeSteps,∃ b ∈ bs,treeEdge w e ∈ b.walk.edges) := by
|
| 49 |
+
obtain ⟨p,hplen,hcover,hcount⟩ := grown_tour w hh 0 w.treeSteps (grows_full_tree w)
|
| 50 |
+
obtain ⟨bs,hbs,hbl,hbc⟩ := chunk_cut_cover (edgeGraph w hh w.treeSteps) L hL p
|
| 51 |
+
have hcut : cutCount (edgeGraph w hh w.treeSteps) p=0 := by
|
| 52 |
+
apply List.countP_eq_zero.mpr
|
| 53 |
+
intro e he hn
|
| 54 |
+
have hnot : e ∉ (edgeGraph w hh w.treeSteps).edgeSet := of_decide_eq_true hn
|
| 55 |
+
exact hnot (p.edges_subset_edgeSet he)
|
| 56 |
+
refine ⟨bs,?_,hbl,?_,?_⟩
|
| 57 |
+
· have hcard : w.treeSteps.card ≤ ℓ := by simpa using card_le_univ w.treeSteps
|
| 58 |
+
have hlen : p.length ≤ 2*ℓ := by rw [hplen]; omega
|
| 59 |
+
rw [hcut,Nat.add_zero] at hbs
|
| 60 |
+
exact hbs.trans (Nat.add_le_add_right (Nat.div_le_div_right hlen) 1)
|
| 61 |
+
· intro z hz
|
| 62 |
+
exact hbc.1 z (hcover z (reached_full_tree w ▸ hz))
|
| 63 |
+
· intro e he
|
| 64 |
+
apply hbc.2
|
| 65 |
+
· apply List.count_pos_iff.mp
|
| 66 |
+
rw [hcount]
|
| 67 |
+
have hc : 0<(w.treeSteps.filter (fun f => treeEdge w f=treeEdge w e)).card :=
|
| 68 |
+
card_pos.mpr ⟨e,mem_filter.mpr ⟨he,rfl⟩⟩
|
| 69 |
+
omega
|
| 70 |
+
· exact edgeGraph_adj w hh _ e he
|
| 71 |
+
|
| 72 |
+
end
|
| 73 |
+
end OrdinaryCorrelations.NumericalSubtrees
|
| 74 |
+
|
| 75 |
+
end
|
| 76 |
+
|
| 77 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TreeDestinationInjective.lean
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.TreeVertices
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
noncomputable section
|
| 6 |
+
open scoped BigOperators
|
| 7 |
+
open Finset
|
| 8 |
+
open Finset Classical
|
| 9 |
+
|
| 10 |
+
namespace OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 11 |
+
open OrdinaryCorrelations.SignedTrace
|
| 12 |
+
open Finset Classical
|
| 13 |
+
variable {h ℓ : ℕ}
|
| 14 |
+
|
| 15 |
+
lemma tree_destination_injective (w : ClosedLine h ℓ) :
|
| 16 |
+
Set.InjOn (fun i : Fin ℓ => w.offset i.succ) w.treeSteps := by
|
| 17 |
+
intro i hi j hj heq
|
| 18 |
+
have hi' := (mem_filter.mp hi).2
|
| 19 |
+
have hj' := (mem_filter.mp hj).2
|
| 20 |
+
apply Fin.ext
|
| 21 |
+
by_contra hn
|
| 22 |
+
rcases lt_or_gt_of_ne hn with hij | hji
|
| 23 |
+
· exact hj' i.succ (by change i.val + 1 ≤ j.val; omega) heq
|
| 24 |
+
· exact hi' j.succ (by change j.val + 1 ≤ i.val; omega) heq.symm
|
| 25 |
+
|
| 26 |
+
lemma tree_destination_nonzero (w : ClosedLine h ℓ) (i : Fin ℓ) (hi : i ∈ w.treeSteps) :
|
| 27 |
+
w.offset i.succ ≠ 0 := by
|
| 28 |
+
have h := (mem_filter.mp hi).2 0 (Nat.zero_le _)
|
| 29 |
+
rwa [w.start_zero, ne_comm] at h
|
| 30 |
+
|
| 31 |
+
lemma has_incoming_edge (w : ClosedLine h ℓ) (v : ℤ)
|
| 32 |
+
(hv : v ∈ treeVertices w) (hv0 : v ≠ 0) :
|
| 33 |
+
∃ i ∈ w.treeSteps, w.offset i.succ = v := by
|
| 34 |
+
let visits : Finset (Fin (ℓ+1)) := univ.filter (fun j => w.offset j = v)
|
| 35 |
+
have hn : visits.Nonempty := by
|
| 36 |
+
obtain ⟨j,hj,hv⟩ := mem_image.mp hv
|
| 37 |
+
exact ⟨j,mem_filter.mpr ⟨hj,hv⟩⟩
|
| 38 |
+
let j := visits.min' hn
|
| 39 |
+
have hj : w.offset j = v := (mem_filter.mp (min'_mem visits hn)).2
|
| 40 |
+
have hj0 : j ≠ 0 := by
|
| 41 |
+
intro heq
|
| 42 |
+
rw [heq, w.start_zero] at hj
|
| 43 |
+
exact hv0 hj.symm
|
| 44 |
+
obtain ⟨i,hi⟩ := Fin.eq_succ_of_ne_zero hj0
|
| 45 |
+
refine ⟨i,mem_filter.mpr ⟨mem_univ _,?_⟩,?_⟩
|
| 46 |
+
· intro k hk hki
|
| 47 |
+
have hkv : w.offset k = v := by rw [hki, ← hi]; exact hj
|
| 48 |
+
have hkmin : j ≤ k := min'_le visits k (mem_filter.mpr ⟨mem_univ _,hkv⟩)
|
| 49 |
+
have hkmin' : j.val ≤ k.val := hkmin
|
| 50 |
+
rw [hi, Fin.val_succ] at hkmin'
|
| 51 |
+
omega
|
| 52 |
+
· rwa [← hi]
|
| 53 |
+
|
| 54 |
+
def goodOrigins (w : ClosedLine h ℓ) : Finset ℤ :=
|
| 55 |
+
(univ.filter w.Good).image (fun i => w.offset i.castSucc)
|
| 56 |
+
|
| 57 |
+
lemma good_origin_data (w : ClosedLine h ℓ) {v : ℤ} (hv : v ∈ goodOrigins w) :
|
| 58 |
+
v ∈ treeVertices w ∧ v ≠ 0 ∧ w.children v = 1 ∧ w.NoReturnIncidence v := by
|
| 59 |
+
obtain ⟨i, hi, rfl⟩ := mem_image.mp hv
|
| 60 |
+
have hg := (mem_filter.mp hi).2
|
| 61 |
+
exact ⟨departure_mem_vertices w i, hg.2.2.2.1, hg.2.1, hg.2.2.2.2.1⟩
|
| 62 |
+
|
| 63 |
+
def incomingCharges (w : ClosedLine h ℓ) (U : Finset ℤ) : Finset (Fin ℓ) :=
|
| 64 |
+
w.treeSteps.filter (fun i => w.offset i.succ ∈ U)
|
| 65 |
+
|
| 66 |
+
def returnSteps (w : ClosedLine h ℓ) : Finset (Fin ℓ) := univ \ w.treeSteps
|
| 67 |
+
|
| 68 |
+
lemma incomingCharges_image (w : ClosedLine h ℓ) (U : Finset ℤ)
|
| 69 |
+
(hU : U ⊆ goodOrigins w) :
|
| 70 |
+
(incomingCharges w U).image (fun i => w.offset i.succ) = U := by
|
| 71 |
+
ext v
|
| 72 |
+
constructor
|
| 73 |
+
· rintro hv
|
| 74 |
+
obtain ⟨i,hi,rfl⟩ := mem_image.mp hv
|
| 75 |
+
exact (mem_filter.mp hi).2
|
| 76 |
+
· intro hv
|
| 77 |
+
have hd := good_origin_data w (hU hv)
|
| 78 |
+
obtain ⟨i,hi,hiv⟩ := has_incoming_edge w v hd.1 hd.2.1
|
| 79 |
+
exact mem_image.mpr ⟨i,mem_filter.mpr ⟨hi,by rwa [hiv]⟩,hiv⟩
|
| 80 |
+
|
| 81 |
+
lemma incomingCharges_card (w : ClosedLine h ℓ) (U : Finset ℤ)
|
| 82 |
+
(hU : U ⊆ goodOrigins w) : (incomingCharges w U).card = U.card := by
|
| 83 |
+
calc
|
| 84 |
+
_ = ((incomingCharges w U).image (fun i => w.offset i.succ)).card :=
|
| 85 |
+
(card_image_iff.mpr ((tree_destination_injective w).mono (filter_subset _ _))).symm
|
| 86 |
+
_ = U.card := congrArg Finset.card (incomingCharges_image w U hU)
|
| 87 |
+
|
| 88 |
+
lemma incoming_return_disjoint (w : ClosedLine h ℓ) (U : Finset ℤ) :
|
| 89 |
+
Disjoint (incomingCharges w U) (returnSteps w) := by
|
| 90 |
+
apply disjoint_left.mpr
|
| 91 |
+
intro i hi hr
|
| 92 |
+
exact (mem_sdiff.mp hr).2 (mem_filter.mp hi).1
|
| 93 |
+
|
| 94 |
+
theorem source_cutoff_charges {S : PrimeSystem} (w : ClosedLine h ℓ) {T : ℝ}
|
| 95 |
+
(cut : S.Cutoffs T) (x : S.CoreResidues) (U : Finset ℤ)
|
| 96 |
+
(hU : U ⊆ goodOrigins w) :
|
| 97 |
+
S.cutoffProduct w cut x ≤
|
| 98 |
+
Real.exp (-kappa * (S.harmonicCore - T * Real.sqrt S.harmonicCore) *
|
| 99 |
+
(((returnSteps w).card : ℝ) + U.card)) *
|
| 100 |
+
Real.exp (kappa *
|
| 101 |
+
((∑ i ∈ returnSteps w, (S.cutoffCount (w.label i)
|
| 102 |
+
(S.shiftCore x (w.offset i.castSucc)) : ℝ)) +
|
| 103 |
+
∑ i ∈ incomingCharges w U, (S.cutoffCount (w.label i)
|
| 104 |
+
(S.shiftCore x (w.offset i.succ)) : ℝ))) := by
|
| 105 |
+
simpa only [incomingCharges_card w U hU] using
|
| 106 |
+
cutoffProduct_le_charges w cut x (returnSteps w) (incomingCharges w U)
|
| 107 |
+
|
| 108 |
+
end OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 109 |
+
|
| 110 |
+
end
|
| 111 |
+
|
| 112 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TreeEdge.lean
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.Directed
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
noncomputable section
|
| 6 |
+
open scoped BigOperators
|
| 7 |
+
open Finset
|
| 8 |
+
open Finset Classical
|
| 9 |
+
open Filter
|
| 10 |
+
open Finset Classical Filter
|
| 11 |
+
open scoped Topology
|
| 12 |
+
|
| 13 |
+
namespace OrdinaryCorrelations.NumericalSubtrees
|
| 14 |
+
open OrdinaryCorrelations.SignedTrace OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 15 |
+
open Finset Classical SimpleGraph
|
| 16 |
+
noncomputable section
|
| 17 |
+
variable {h ℓ : ℕ}
|
| 18 |
+
|
| 19 |
+
def treeEdge (w : ClosedLine h ℓ) (e : Fin ℓ) : Sym2 ℤ :=
|
| 20 |
+
s(w.offset e.castSucc,w.offset e.succ)
|
| 21 |
+
|
| 22 |
+
lemma grows_full_tree (w : ClosedLine h ℓ) : Grows w 0 w.treeSteps := by
|
| 23 |
+
refine ⟨Subset.rfl,?_⟩
|
| 24 |
+
intro e he
|
| 25 |
+
by_cases hz : w.offset e.castSucc=0
|
| 26 |
+
· exact Or.inl hz
|
| 27 |
+
· obtain ⟨j,hj,hjv⟩ := has_incoming_edge w (w.offset e.castSucc) (departure_mem_vertices w e) hz
|
| 28 |
+
exact Or.inr ⟨j,hj,incoming_earlier w hj hjv,hjv⟩
|
| 29 |
+
|
| 30 |
+
lemma reached_full_tree (w : ClosedLine h ℓ) : reached w 0 w.treeSteps=treeVertices w := by
|
| 31 |
+
apply Finset.ext
|
| 32 |
+
intro v
|
| 33 |
+
constructor
|
| 34 |
+
· intro hv
|
| 35 |
+
rcases mem_insert.mp hv with rfl | hv
|
| 36 |
+
· exact mem_image.mpr ⟨0,mem_univ _,w.start_zero⟩
|
| 37 |
+
· obtain ⟨e,he,rfl⟩ := mem_image.mp hv
|
| 38 |
+
exact endpoint_mem_vertices w e
|
| 39 |
+
· intro hv
|
| 40 |
+
by_cases hz : v=0
|
| 41 |
+
· rw [hz]; exact mem_insert_self _ _
|
| 42 |
+
· obtain ⟨e,he,hev⟩ := has_incoming_edge w v hv hz
|
| 43 |
+
exact mem_insert_of_mem (mem_image.mpr ⟨e,he,hev⟩)
|
| 44 |
+
|
| 45 |
+
theorem grown_tour (w : ClosedLine h ℓ) (hh : 0<h) (v : ℤ) (E : Finset (Fin ℓ))
|
| 46 |
+
(hg : Grows w v E) :
|
| 47 |
+
∃ p : (edgeGraph w hh w.treeSteps).Walk v v,
|
| 48 |
+
p.length=2*E.card ∧ (∀ z ∈ reached w v E,z ∈ p.support) ∧
|
| 49 |
+
∀ q : Sym2 ℤ,p.edges.count q=2*(E.filter (fun e => treeEdge w e=q)).card := by
|
| 50 |
+
suffices aux : ∀ n,∀ E : Finset (Fin ℓ),E.card=n → Grows w v E →
|
| 51 |
+
∃ p : (edgeGraph w hh w.treeSteps).Walk v v,
|
| 52 |
+
p.length=2*E.card ∧ (∀ z ∈ reached w v E,z ∈ p.support) ∧
|
| 53 |
+
∀ q : Sym2 ℤ,p.edges.count q=2*(E.filter (fun e => treeEdge w e=q)).card by
|
| 54 |
+
exact aux _ E rfl hg
|
| 55 |
+
intro n
|
| 56 |
+
induction n using Nat.strong_induction_on with
|
| 57 |
+
| h n ih =>
|
| 58 |
+
intro E hcard hg
|
| 59 |
+
by_cases hne : E.Nonempty
|
| 60 |
+
· let e := E.max' hne
|
| 61 |
+
have he : e ∈ E := max'_mem E hne
|
| 62 |
+
let F := E.erase e
|
| 63 |
+
have hF : F ⊆ E := erase_subset _ _
|
| 64 |
+
have heF : e ∉ F := notMem_erase _ _
|
| 65 |
+
have hinsert : insert e F=E := insert_erase he
|
| 66 |
+
have hFgrow : Grows w v F := by
|
| 67 |
+
refine ⟨hF.trans hg.1,?_⟩
|
| 68 |
+
intro f hf
|
| 69 |
+
rcases hg.2 f (hF hf) with hr | ⟨j,hj,hjf,hjv⟩
|
| 70 |
+
· exact Or.inl hr
|
| 71 |
+
· refine Or.inr ⟨j,mem_erase.mpr ⟨?_,hj⟩,hjf,hjv⟩
|
| 72 |
+
intro hje
|
| 73 |
+
subst j
|
| 74 |
+
exact (not_lt_of_ge (le_max' E f (hF hf))) hjf
|
| 75 |
+
have hlt : F.card<n := by rw [←hcard]; exact card_erase_lt_of_mem he
|
| 76 |
+
obtain ⟨p,hplen,hcover,hcount⟩ := ih F.card hlt F rfl hFgrow
|
| 77 |
+
have hsource : w.offset e.castSucc ∈ reached w v F := by
|
| 78 |
+
rcases hg.2 e he with hr | ⟨j,hj,hje,hjv⟩
|
| 79 |
+
· rw [hr]; exact mem_insert_self _ _
|
| 80 |
+
· exact mem_insert_of_mem (mem_image.mpr ⟨j,mem_erase.mpr ⟨ne_of_lt hje,hj⟩,hjv⟩)
|
| 81 |
+
obtain ⟨p₁,p₂,hp⟩ := SimpleGraph.Walk.mem_support_iff_exists_append.mp
|
| 82 |
+
(hcover _ hsource)
|
| 83 |
+
let ha := edgeGraph_adj w hh w.treeSteps e (hg.1 he)
|
| 84 |
+
let loop : (edgeGraph w hh w.treeSteps).Walk (w.offset e.castSucc) (w.offset e.castSucc) :=
|
| 85 |
+
.cons ha (.cons ha.symm .nil)
|
| 86 |
+
let q := p₁.append (loop.append p₂)
|
| 87 |
+
refine ⟨q,?_,?_,?_⟩
|
| 88 |
+
· have hcard' : E.card=F.card+1 := by rw [←hinsert,card_insert_of_notMem heF]
|
| 89 |
+
rw [hp,SimpleGraph.Walk.length_append] at hplen
|
| 90 |
+
simp only [q,loop,SimpleGraph.Walk.length_append,SimpleGraph.Walk.length_cons,
|
| 91 |
+
SimpleGraph.Walk.length_nil]
|
| 92 |
+
omega
|
| 93 |
+
· intro z hz
|
| 94 |
+
rcases mem_insert.mp hz with hroot | hz
|
| 95 |
+
· subst z; exact q.start_mem_support
|
| 96 |
+
· obtain ⟨f,hf,rfl⟩ := mem_image.mp hz
|
| 97 |
+
by_cases hfe : f=e
|
| 98 |
+
· subst f
|
| 99 |
+
exact (SimpleGraph.Walk.mem_support_append_iff p₁ (loop.append p₂)).mpr
|
| 100 |
+
(Or.inr ((SimpleGraph.Walk.mem_support_append_iff loop p₂).mpr
|
| 101 |
+
(Or.inl (by simp [loop]))))
|
| 102 |
+
· have hmem := hcover (w.offset f.succ) (mem_insert_of_mem (mem_image.mpr ⟨f,mem_erase.mpr ⟨hfe,hf⟩,rfl⟩))
|
| 103 |
+
rw [hp,SimpleGraph.Walk.mem_support_append_iff] at hmem
|
| 104 |
+
exact (SimpleGraph.Walk.mem_support_append_iff p₁ (loop.append p₂)).mpr
|
| 105 |
+
(hmem.imp_right (fun hh => (SimpleGraph.Walk.mem_support_append_iff loop p₂).mpr (Or.inr hh)))
|
| 106 |
+
· intro s
|
| 107 |
+
have hc := hcount s
|
| 108 |
+
rw [hp,SimpleGraph.Walk.edges_append,List.count_append] at hc
|
| 109 |
+
have hsame : s(w.offset e.castSucc,w.offset e.succ)=treeEdge w e := rfl
|
| 110 |
+
have hsym : s(w.offset e.succ,w.offset e.castSucc)=treeEdge w e := Sym2.eq_swap
|
| 111 |
+
have hef : e ∉ F.filter (fun e => treeEdge w e=s) := fun he => heF (mem_filter.mp he).1
|
| 112 |
+
have heqcard : (E.filter (fun e => treeEdge w e=s)).card =
|
| 113 |
+
(F.filter (fun e => treeEdge w e=s)).card + if treeEdge w e=s then 1 else 0 := by
|
| 114 |
+
rw [←hinsert,filter_insert]
|
| 115 |
+
split_ifs <;> simp [hef]
|
| 116 |
+
rw [heqcard]
|
| 117 |
+
simp only [q,loop,SimpleGraph.Walk.edges_append,SimpleGraph.Walk.edges_cons,
|
| 118 |
+
SimpleGraph.Walk.edges_nil,List.count_append,hsame,hsym]
|
| 119 |
+
by_cases hes : treeEdge w e=s
|
| 120 |
+
· subst s
|
| 121 |
+
simp only [List.count_cons_self,List.count_nil,ite_true]
|
| 122 |
+
omega
|
| 123 |
+
· have hse : s≠treeEdge w e := Ne.symm hes
|
| 124 |
+
simp only [List.count_cons_of_ne hes,List.count_nil,hes,ite_false]
|
| 125 |
+
omega
|
| 126 |
+
· have hE : E=∅ := not_nonempty_iff_eq_empty.mp hne
|
| 127 |
+
subst E
|
| 128 |
+
refine ⟨.nil,by simp,?_,by simp⟩
|
| 129 |
+
intro z hz
|
| 130 |
+
simpa [reached] using hz
|
| 131 |
+
|
| 132 |
+
end
|
| 133 |
+
end OrdinaryCorrelations.NumericalSubtrees
|
| 134 |
+
|
| 135 |
+
end
|
| 136 |
+
|
| 137 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TreeEdgeInjective.lean
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.TreeEdge
|
| 2 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.Append
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
noncomputable section
|
| 7 |
+
open scoped BigOperators
|
| 8 |
+
open Finset
|
| 9 |
+
open Finset Classical
|
| 10 |
+
open Filter
|
| 11 |
+
open Finset Classical Filter
|
| 12 |
+
open scoped Topology
|
| 13 |
+
|
| 14 |
+
namespace OrdinaryCorrelations.NumericalSubtrees
|
| 15 |
+
open OrdinaryCorrelations.SignedTrace OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 16 |
+
open OrdinaryCorrelations.ForestTraversal Finset Classical SimpleGraph
|
| 17 |
+
noncomputable section
|
| 18 |
+
variable {h ℓ : ℕ}
|
| 19 |
+
|
| 20 |
+
lemma treeEdge_injective (w : ClosedLine h ℓ) : Set.InjOn (treeEdge w) w.treeSteps := by
|
| 21 |
+
intro e he f hf hef
|
| 22 |
+
rcases Sym2.eq_iff.mp hef with hd | hs
|
| 23 |
+
· exact tree_destination_injective w he hf hd.2
|
| 24 |
+
· have hfe := incoming_earlier w hf hs.1.symm
|
| 25 |
+
have hef := incoming_earlier w he hs.2
|
| 26 |
+
exact (lt_asymm hfe hef).elim
|
| 27 |
+
|
| 28 |
+
lemma treeEdge_mem_edgeSet_iff (w : ClosedLine h ℓ) (hh : 0<h)
|
| 29 |
+
{e : Fin ℓ} (he : e ∈ w.treeSteps) {E : Finset (Fin ℓ)} (hE : E ⊆ w.treeSteps) :
|
| 30 |
+
treeEdge w e ∈ (edgeGraph w hh E).edgeSet ↔ e ∈ E := by
|
| 31 |
+
constructor
|
| 32 |
+
· rintro ⟨f,hf,hor | hrev⟩
|
| 33 |
+
· have hef : treeEdge w e=treeEdge w f := by dsimp only at hor; unfold treeEdge; rw [hor.1,hor.2]
|
| 34 |
+
exact treeEdge_injective w he (hE hf) hef ▸ hf
|
| 35 |
+
· have hef : treeEdge w e=treeEdge w f := by dsimp only at hrev; unfold treeEdge; rw [hrev.1,hrev.2]; exact Sym2.eq_swap
|
| 36 |
+
exact treeEdge_injective w he (hE hf) hef ▸ hf
|
| 37 |
+
· intro heE
|
| 38 |
+
exact edgeGraph_adj w hh E e heE
|
| 39 |
+
|
| 40 |
+
lemma tour_cutCount (w : ClosedLine h ℓ) (hh : 0<h) (H : Finset (Fin ℓ))
|
| 41 |
+
(p : (edgeGraph w hh w.treeSteps).Walk 0 0)
|
| 42 |
+
(hc : ∀ q : Sym2 ℤ,p.edges.count q=2*(w.treeSteps.filter (fun e => treeEdge w e=q)).card) :
|
| 43 |
+
cutCount (edgeGraph w hh (w.treeSteps \ H)) p ≤ 2*H.card := by
|
| 44 |
+
let F := p.edges.toFinset.filter (fun q => q ∉ (edgeGraph w hh (w.treeSteps \ H)).edgeSet)
|
| 45 |
+
have hF : F ⊆ H.image (treeEdge w) := by
|
| 46 |
+
intro q hq
|
| 47 |
+
obtain ⟨hql,hqn⟩ := mem_filter.mp hq
|
| 48 |
+
have ht := p.edges_subset_edgeSet (List.mem_toFinset.mp hql)
|
| 49 |
+
induction q using Sym2.ind with | _ u v =>
|
| 50 |
+
obtain ⟨e,he,hor | hrev⟩ := ht
|
| 51 |
+
· have hqe : s(u,v)=treeEdge w e := by dsimp only at hor; unfold treeEdge; rw [hor.1,hor.2]
|
| 52 |
+
refine mem_image.mpr ⟨e,?_,hqe.symm⟩
|
| 53 |
+
by_contra hn
|
| 54 |
+
exact hqn (hqe.symm ▸ (treeEdge_mem_edgeSet_iff w hh he sdiff_subset).mpr (mem_sdiff.mpr ⟨he,hn⟩))
|
| 55 |
+
· have hqe : s(u,v)=treeEdge w e := by dsimp only at hrev; unfold treeEdge; rw [hrev.1,hrev.2]; exact Sym2.eq_swap
|
| 56 |
+
refine mem_image.mpr ⟨e,?_,hqe.symm⟩
|
| 57 |
+
by_contra hn
|
| 58 |
+
exact hqn (hqe.symm ▸ (treeEdge_mem_edgeSet_iff w hh he sdiff_subset).mpr (mem_sdiff.mpr ⟨he,hn⟩))
|
| 59 |
+
have hcount (q : Sym2 ℤ) : p.edges.count q ≤ 2 := by
|
| 60 |
+
rw [hc]
|
| 61 |
+
have hf : (w.treeSteps.filter (fun e => treeEdge w e=q)).card ≤ 1 := by
|
| 62 |
+
apply card_le_one.mpr
|
| 63 |
+
intro e he f hf
|
| 64 |
+
exact treeEdge_injective w (mem_filter.mp he).1 (mem_filter.mp hf).1
|
| 65 |
+
((mem_filter.mp he).2.trans (mem_filter.mp hf).2.symm)
|
| 66 |
+
omega
|
| 67 |
+
calc
|
| 68 |
+
cutCount (edgeGraph w hh (w.treeSteps \ H)) p = ∑ q ∈ F,p.edges.count q :=
|
| 69 |
+
(sum_filter_count_eq_countP _ _).symm
|
| 70 |
+
_ ≤ ∑ _q ∈ F,2 := sum_le_sum (fun q _ => hcount q)
|
| 71 |
+
_ = 2*F.card := by simp [Nat.mul_comm]
|
| 72 |
+
_ ≤ 2*H.card := Nat.mul_le_mul_left 2 ((card_le_card hF).trans card_image_le)
|
| 73 |
+
|
| 74 |
+
theorem tree_blocks (w : ClosedLine h ℓ) (hh : 0<h) (H : Finset (Fin ℓ))
|
| 75 |
+
(L : ℕ) (hL : 0<L) :
|
| 76 |
+
∃ bs : List (Block (edgeGraph w hh (w.treeSteps \ H))),
|
| 77 |
+
bs.length ≤ (2*ℓ)/L+2*H.card+1 ∧
|
| 78 |
+
(∀ b ∈ bs,b.walk.length ≤ L) ∧
|
| 79 |
+
(∀ z ∈ treeVertices w,∃ b ∈ bs,z ∈ b.walk.support) := by
|
| 80 |
+
obtain ⟨p,hplen,hcover,hcount⟩ := grown_tour w hh 0 w.treeSteps (grows_full_tree w)
|
| 81 |
+
obtain ⟨bs,hbs,hbl,hbc⟩ := chunk_cut_cover (edgeGraph w hh (w.treeSteps \ H)) L hL p
|
| 82 |
+
refine ⟨bs,?_,hbl,?_⟩
|
| 83 |
+
· have hcut := tour_cutCount w hh H p hcount
|
| 84 |
+
have hcard : w.treeSteps.card ≤ ℓ := by simpa using card_le_univ w.treeSteps
|
| 85 |
+
have hlen : p.length ≤ 2*ℓ := by rw [hplen]; omega
|
| 86 |
+
exact hbs.trans (Nat.add_le_add_right (Nat.add_le_add (Nat.div_le_div_right hlen) hcut) 1)
|
| 87 |
+
· intro z hz
|
| 88 |
+
exact hbc.1 z (hcover z (reached_full_tree w ▸ hz))
|
| 89 |
+
|
| 90 |
+
end
|
| 91 |
+
end OrdinaryCorrelations.NumericalSubtrees
|
| 92 |
+
|
| 93 |
+
end
|
| 94 |
+
|
| 95 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TreeOccurrences.lean
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.PrimeChargeProduct
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
noncomputable section
|
| 6 |
+
open scoped BigOperators
|
| 7 |
+
open Finset
|
| 8 |
+
open Finset Classical
|
| 9 |
+
|
| 10 |
+
namespace OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 11 |
+
open OrdinaryCorrelations.SignedTrace OrdinaryCorrelations.FiniteIntegration
|
| 12 |
+
open Finset Classical
|
| 13 |
+
variable {S : PrimeSystem} {h ℓ : ℕ}
|
| 14 |
+
|
| 15 |
+
def treeOccurrences (w : ClosedLine h ℓ) (p : S.Index) : Finset (Fin ℓ) :=
|
| 16 |
+
w.treeSteps.filter (fun i => (p : ℕ) ∣ w.label i)
|
| 17 |
+
|
| 18 |
+
def litEdges (w : ClosedLine h ℓ) (p : S.Index) (a : ZMod (p : ℕ)) : Finset (Fin ℓ) :=
|
| 19 |
+
(treeOccurrences w p).filter (fun i => a + (w.offset i.castSucc : ZMod (p : ℕ)) = 0)
|
| 20 |
+
|
| 21 |
+
def edgeVertices (w : ClosedLine h ℓ) (E : Finset (Fin ℓ)) : Finset ℤ :=
|
| 22 |
+
E.image (fun i => w.offset i.castSucc) ∪ E.image (fun i => w.offset i.succ)
|
| 23 |
+
|
| 24 |
+
lemma edgeVertices_subset (w : ClosedLine h ℓ) (E : Finset (Fin ℓ)) :
|
| 25 |
+
edgeVertices w E ⊆ treeVertices w := by
|
| 26 |
+
intro v hv
|
| 27 |
+
rcases mem_union.mp hv with hv | hv
|
| 28 |
+
· obtain ⟨i,hi,rfl⟩ := mem_image.mp hv
|
| 29 |
+
exact departure_mem_vertices w i
|
| 30 |
+
· obtain ⟨i,hi,rfl⟩ := mem_image.mp hv
|
| 31 |
+
exact endpoint_mem_vertices w i
|
| 32 |
+
|
| 33 |
+
lemma lit_vertex_active (w : ClosedLine h ℓ) (p : S.Index) (a : ZMod (p : ℕ))
|
| 34 |
+
{v : ℤ} (hv : v ∈ edgeVertices w (litEdges w p a)) : a + (v : ZMod (p : ℕ)) = 0 := by
|
| 35 |
+
rcases mem_union.mp hv with hv | hv
|
| 36 |
+
· obtain ⟨i,hi,rfl⟩ := mem_image.mp hv
|
| 37 |
+
exact (mem_filter.mp hi).2
|
| 38 |
+
· obtain ⟨i,hi,rfl⟩ := mem_image.mp hv
|
| 39 |
+
rw [w.label_residue_eq i (mem_filter.mp (mem_filter.mp hi).1).2]
|
| 40 |
+
exact (mem_filter.mp hi).2
|
| 41 |
+
|
| 42 |
+
def NoComponentTop (w : ClosedLine h ℓ) (U : Finset ℤ) (p : S.Index)
|
| 43 |
+
(E : Finset (Fin ℓ)) : Prop :=
|
| 44 |
+
S.IsCore p → ∀ i ∈ incomingCharges w U,
|
| 45 |
+
w.offset i.succ ∈ edgeVertices w E → (p : ℕ) ∣ w.label i
|
| 46 |
+
|
| 47 |
+
def isolatedCharge (w : ClosedLine h ℓ) (U : Finset ℤ) (p : S.Index)
|
| 48 |
+
(E : Finset (Fin ℓ)) (a : ZMod (p : ℕ)) (v : ℤ) : ℝ :=
|
| 49 |
+
if S.IsCore p ∧ v ∈ U ∧ a + (v : ZMod (p : ℕ)) = 0 ∧ v ∉ edgeVertices w E
|
| 50 |
+
then Real.exp kappa else 1
|
| 51 |
+
|
| 52 |
+
lemma isolatedCharge_nonneg (w : ClosedLine h ℓ) (U : Finset ℤ) (p : S.Index)
|
| 53 |
+
(E : Finset (Fin ℓ)) (a : ZMod (p : ℕ)) (v : ℤ) :
|
| 54 |
+
0 ≤ isolatedCharge w U p E a v := by
|
| 55 |
+
unfold isolatedCharge; split_ifs <;> positivity
|
| 56 |
+
|
| 57 |
+
lemma incoming_charge_le_isolated (w : ClosedLine h ℓ) (U : Finset ℤ) (p : S.Index)
|
| 58 |
+
(E : Finset (Fin ℓ)) (htop : NoComponentTop w U p E)
|
| 59 |
+
(a : ZMod (p : ℕ)) (i : Fin ℓ) (hi : i ∈ incomingCharges w U) :
|
| 60 |
+
S.primeCharge p (w.label i) (w.offset i.succ) a ≤
|
| 61 |
+
isolatedCharge w U p E a (w.offset i.succ) := by
|
| 62 |
+
have hiU := (mem_filter.mp hi).2
|
| 63 |
+
by_cases hc : S.IsCore p
|
| 64 |
+
· by_cases he : w.offset i.succ ∈ edgeVertices w E
|
| 65 |
+
· have hd := htop hc i hi he
|
| 66 |
+
simp [primeCharge, isolatedCharge, hc, hd, he]
|
| 67 |
+
· by_cases ha : a + (w.offset i.succ : ZMod (p : ℕ)) = 0
|
| 68 |
+
· simp only [isolatedCharge, hc, hiU, ha, he, not_false_eq_true, and_self, ite_true]
|
| 69 |
+
unfold primeCharge
|
| 70 |
+
split_ifs
|
| 71 |
+
· exact le_rfl
|
| 72 |
+
· exact Real.one_le_exp (by unfold kappa eta epsilon; positivity)
|
| 73 |
+
· simp [primeCharge, isolatedCharge, ha]
|
| 74 |
+
· simp [primeCharge, isolatedCharge, hc]
|
| 75 |
+
|
| 76 |
+
lemma incoming_charges_le_vertices (w : ClosedLine h ℓ) (U : Finset ℤ)
|
| 77 |
+
(hU : U ⊆ goodOrigins w) (p : S.Index) (E : Finset (Fin ℓ))
|
| 78 |
+
(htop : NoComponentTop w U p E) (a : ZMod (p : ℕ)) :
|
| 79 |
+
(∏ i ∈ incomingCharges w U, S.primeCharge p (w.label i) (w.offset i.succ) a) ≤
|
| 80 |
+
∏ v ∈ treeVertices w, isolatedCharge w U p E a v := by
|
| 81 |
+
calc
|
| 82 |
+
_ ≤ ∏ i ∈ incomingCharges w U, isolatedCharge w U p E a (w.offset i.succ) :=
|
| 83 |
+
prod_le_prod₀ (fun _ _ => primeCharge_nonneg _ _ _ _)
|
| 84 |
+
(fun i hi => incoming_charge_le_isolated w U p E htop a i hi)
|
| 85 |
+
_ = ∏ v ∈ U, isolatedCharge w U p E a v := by
|
| 86 |
+
calc
|
| 87 |
+
_ = ∏ v ∈ (incomingCharges w U).image (fun i => w.offset i.succ),
|
| 88 |
+
isolatedCharge w U p E a v := by
|
| 89 |
+
symm
|
| 90 |
+
apply prod_image
|
| 91 |
+
intro i hi j hj hij
|
| 92 |
+
exact tree_destination_injective w (mem_filter.mp hi).1 (mem_filter.mp hj).1 hij
|
| 93 |
+
_ = _ := congrArg (fun V => ∏ v ∈ V, isolatedCharge w U p E a v)
|
| 94 |
+
(incomingCharges_image w U hU)
|
| 95 |
+
_ = ∏ v ∈ treeVertices w, isolatedCharge w U p E a v := by
|
| 96 |
+
apply prod_subset (fun v hv => (good_origin_data w (hU hv)).1)
|
| 97 |
+
intro v hv hn
|
| 98 |
+
simp [isolatedCharge, hn]
|
| 99 |
+
|
| 100 |
+
def subtreeUnionWeight (w : ClosedLine h ℓ) (p : S.Index) (E : Finset (Fin ℓ)) : ℝ :=
|
| 101 |
+
S.amplitude p ^ E.card * ∏ v ∈ edgeVertices w E, S.beta p ^ w.children v
|
| 102 |
+
|
| 103 |
+
lemma tree_norm_charges_le (w : ClosedLine h ℓ) (U : Finset ℤ)
|
| 104 |
+
(hU : U ⊆ goodOrigins w) (p : S.Index) (a : ZMod (p : ℕ))
|
| 105 |
+
(htop : NoComponentTop w U p (litEdges w p a)) :
|
| 106 |
+
(∏ i ∈ w.treeSteps, S.beta p ^
|
| 107 |
+
(if a + (w.offset i.castSucc : ZMod (p : ℕ)) = 0 then (1 : ℕ) else 0)) *
|
| 108 |
+
(∏ i ∈ incomingCharges w U, S.primeCharge p (w.label i) (w.offset i.succ) a) ≤
|
| 109 |
+
∏ v ∈ edgeVertices w (litEdges w p a), S.beta p ^ w.children v := by
|
| 110 |
+
let E := litEdges w p a
|
| 111 |
+
have hn : ∀ v : ℤ, (0 : ℝ) ≤ (if a + (v : ZMod (p : ℕ)) = 0 then
|
| 112 |
+
S.beta p ^ w.children v else 1) := by
|
| 113 |
+
intro v
|
| 114 |
+
have hb := beta_nonneg p
|
| 115 |
+
split_ifs <;> positivity
|
| 116 |
+
rw [tree_normalization]
|
| 117 |
+
calc
|
| 118 |
+
_ ≤ (∏ v ∈ treeVertices w, if a + (v : ZMod (p : ℕ)) = 0 then
|
| 119 |
+
S.beta p ^ w.children v else 1) *
|
| 120 |
+
∏ v ∈ treeVertices w, isolatedCharge w U p E a v :=
|
| 121 |
+
mul_le_mul_of_nonneg_left (incoming_charges_le_vertices w U hU p E htop a)
|
| 122 |
+
(prod_nonneg (fun v _ => hn v))
|
| 123 |
+
_ = ∏ v ∈ treeVertices w, (if a + (v : ZMod (p : ℕ)) = 0 then
|
| 124 |
+
S.beta p ^ w.children v else 1) * isolatedCharge w U p E a v := by
|
| 125 |
+
rw [prod_mul_distrib]
|
| 126 |
+
_ ≤ ∏ v ∈ treeVertices w, if v ∈ edgeVertices w E then S.beta p ^ w.children v else 1 := by
|
| 127 |
+
apply Finset.prod_le_prod₀
|
| 128 |
+
· intro v hv
|
| 129 |
+
exact mul_nonneg (hn v) (isolatedCharge_nonneg w U p E a v)
|
| 130 |
+
· intro v hv
|
| 131 |
+
by_cases he : v ∈ edgeVertices w E
|
| 132 |
+
· rw [ite_eq_left he, ite_eq_left (lit_vertex_active w p a he)]
|
| 133 |
+
simp [isolatedCharge, he]
|
| 134 |
+
· rw [ite_eq_right he]
|
| 135 |
+
by_cases ha : a + (v : ZMod (p : ℕ)) = 0
|
| 136 |
+
· rw [ite_eq_left ha]
|
| 137 |
+
by_cases hu : S.IsCore p ∧ v ∈ U
|
| 138 |
+
· have hv1 := (good_origin_data w (hU hu.2)).2.2.1
|
| 139 |
+
simp only [isolatedCharge, hu.1, hu.2, ha, he, not_false_eq_true, and_self,
|
| 140 |
+
ite_true, hv1, pow_one, beta_eq_core p hu.1]
|
| 141 |
+
exact betaC_mul_exp_le_one
|
| 142 |
+
· have hc : ¬(S.IsCore p ∧ v ∈ U ∧ a + (v : ZMod (p : ℕ)) = 0 ∧ v ∉ edgeVertices w E) :=
|
| 143 |
+
fun hh => hu ⟨hh.1,hh.2.1⟩
|
| 144 |
+
rw [isolatedCharge, ite_eq_right hc, mul_one]
|
| 145 |
+
exact pow_le_one₀ (beta_nonneg p) (beta_le_one p)
|
| 146 |
+
· simp [isolatedCharge, ha]
|
| 147 |
+
_ = ∏ v ∈ edgeVertices w E, S.beta p ^ w.children v := by
|
| 148 |
+
rw [← prod_filter]
|
| 149 |
+
congr 1
|
| 150 |
+
rw [filter_mem_eq_inter, inter_eq_right.mpr (edgeVertices_subset w E)]
|
| 151 |
+
|
| 152 |
+
lemma charged_prime_le_tree (w : ClosedLine h ℓ) (U : Finset ℤ)
|
| 153 |
+
(p : S.Index) (a : ZMod (p : ℕ)) :
|
| 154 |
+
|S.primeFactor w p a| * allPrimeCharges w U p a ≤
|
| 155 |
+
(∏ i ∈ w.treeSteps, |S.occurrenceFactor w p i a|) *
|
| 156 |
+
((∏ i ∈ w.treeSteps, S.beta p ^
|
| 157 |
+
(if a + (w.offset i.castSucc : ZMod (p : ℕ)) = 0 then (1 : ℕ) else 0)) *
|
| 158 |
+
∏ i ∈ incomingCharges w U, S.primeCharge p (w.label i) (w.offset i.succ) a) := by
|
| 159 |
+
have hret : |∏ i ∈ returnSteps w, S.stepFactor w p i a| *
|
| 160 |
+
(∏ i ∈ returnSteps w, S.primeCharge p (w.label i) (w.offset i.castSucc) a) ≤ 1 := by
|
| 161 |
+
rw [abs_prod, ← prod_mul_distrib]
|
| 162 |
+
exact prod_le_one₀ (fun i _ => mul_nonneg (abs_nonneg _) (primeCharge_nonneg _ _ _ _))
|
| 163 |
+
(fun i _ => charged_return_le_one w p i a)
|
| 164 |
+
have hi0 : 0 ≤ ∏ i ∈ incomingCharges w U,
|
| 165 |
+
S.primeCharge p (w.label i) (w.offset i.succ) a :=
|
| 166 |
+
prod_nonneg (fun i _ => primeCharge_nonneg _ _ _ _)
|
| 167 |
+
rw [primeFactor_split_steps, abs_mul, allPrimeCharges]
|
| 168 |
+
calc
|
| 169 |
+
_ = (|∏ i ∈ w.treeSteps, S.stepFactor w p i a| *
|
| 170 |
+
∏ i ∈ incomingCharges w U, S.primeCharge p (w.label i) (w.offset i.succ) a) *
|
| 171 |
+
(|∏ i ∈ returnSteps w, S.stepFactor w p i a| *
|
| 172 |
+
∏ i ∈ returnSteps w, S.primeCharge p (w.label i) (w.offset i.castSucc) a) := by
|
| 173 |
+
unfold returnSteps
|
| 174 |
+
ring
|
| 175 |
+
_ ≤ (|∏ i ∈ w.treeSteps, S.stepFactor w p i a| *
|
| 176 |
+
∏ i ∈ incomingCharges w U, S.primeCharge p (w.label i) (w.offset i.succ) a) * 1 :=
|
| 177 |
+
mul_le_mul_of_nonneg_left hret (mul_nonneg (abs_nonneg _) hi0)
|
| 178 |
+
_ = _ := by
|
| 179 |
+
simp only [mul_one, abs_prod, stepFactor, abs_mul,
|
| 180 |
+
abs_of_nonneg (pow_nonneg (beta_nonneg p) _), prod_mul_distrib]
|
| 181 |
+
ring
|
| 182 |
+
|
| 183 |
+
lemma occurrence_abs_le_lit_amplitude (w : ClosedLine h ℓ) (p : S.Index)
|
| 184 |
+
(a : ZMod (p : ℕ)) (i : Fin ℓ) (hi : i ∈ w.treeSteps) :
|
| 185 |
+
|S.occurrenceFactor w p i a| ≤
|
| 186 |
+
if i ∈ litEdges w p a then S.amplitude p else 1 := by
|
| 187 |
+
have ht := theta_div_bounds p
|
| 188 |
+
by_cases hd : (p : ℕ) ∣ w.label i <;>
|
| 189 |
+
by_cases ha : a + (w.offset i.castSucc : ZMod (p : ℕ)) = 0 <;>
|
| 190 |
+
by_cases hc : S.IsCore p
|
| 191 |
+
all_goals simp only [occurrenceFactor, activity, hd, ha, hc, ite_true, ite_false,
|
| 192 |
+
amplitude, litEdges, treeOccurrences, mem_filter, hi, and_true,
|
| 193 |
+
and_false, mul_zero, mul_one, abs_zero, zero_sub, abs_neg]
|
| 194 |
+
· exact le_of_eq (abs_of_pos A_pos)
|
| 195 |
+
· rw [abs_of_nonneg (sub_nonneg.mpr ht.2)]; linarith [ht.1]
|
| 196 |
+
· norm_num
|
| 197 |
+
· exact (abs_of_nonneg ht.1).le.trans ht.2
|
| 198 |
+
all_goals norm_num
|
| 199 |
+
|
| 200 |
+
lemma occurrence_product_le (w : ClosedLine h ℓ) (p : S.Index) (a : ZMod (p : ℕ)) :
|
| 201 |
+
(∏ i ∈ w.treeSteps, |S.occurrenceFactor w p i a|) ≤
|
| 202 |
+
S.amplitude p ^ (litEdges w p a).card := by
|
| 203 |
+
calc
|
| 204 |
+
_ ≤ ∏ i ∈ w.treeSteps, if i ∈ litEdges w p a then S.amplitude p else 1 :=
|
| 205 |
+
prod_le_prod₀ (fun _ _ => abs_nonneg _) (fun i hi => occurrence_abs_le_lit_amplitude w p a i hi)
|
| 206 |
+
_ = _ := by
|
| 207 |
+
rw [prod_ite_mem, inter_eq_right.mpr]
|
| 208 |
+
· simp only [prod_const]
|
| 209 |
+
· exact (filter_subset _ _).trans (filter_subset _ _)
|
| 210 |
+
|
| 211 |
+
theorem charged_prime_le_weight (w : ClosedLine h ℓ) (U : Finset ℤ)
|
| 212 |
+
(hU : U ⊆ goodOrigins w) (p : S.Index) (a : ZMod (p : ℕ))
|
| 213 |
+
(htop : NoComponentTop w U p (litEdges w p a)) :
|
| 214 |
+
|S.primeFactor w p a| * allPrimeCharges w U p a ≤
|
| 215 |
+
subtreeUnionWeight w p (litEdges w p a) := by
|
| 216 |
+
apply (charged_prime_le_tree w U p a).trans
|
| 217 |
+
unfold subtreeUnionWeight
|
| 218 |
+
apply mul_le_mul (occurrence_product_le w p a) (tree_norm_charges_le w U hU p a htop)
|
| 219 |
+
· exact mul_nonneg (prod_nonneg (fun _ _ => pow_nonneg (beta_nonneg p) _))
|
| 220 |
+
(prod_nonneg (fun _ _ => primeCharge_nonneg _ _ _ _))
|
| 221 |
+
· have hp : 0 ≤ S.amplitude p := by
|
| 222 |
+
unfold amplitude
|
| 223 |
+
split_ifs
|
| 224 |
+
· exact A_pos.le
|
| 225 |
+
· exact zero_le_one
|
| 226 |
+
exact pow_nonneg hp _
|
| 227 |
+
|
| 228 |
+
end OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 229 |
+
|
| 230 |
+
end
|
| 231 |
+
|
| 232 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TreeOccurrencesEmptyOfFree.lean
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.FixedCharges
|
| 2 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.RecordedTops
|
| 3 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.SingleEdgeWeight
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
open scoped BigOperators
|
| 9 |
+
open Finset
|
| 10 |
+
open Finset Classical
|
| 11 |
+
|
| 12 |
+
namespace OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 13 |
+
open OrdinaryCorrelations.SignedTrace OrdinaryCorrelations.FiniteIntegration
|
| 14 |
+
open Finset Classical
|
| 15 |
+
variable {S : PrimeSystem} {B τ C₀ : ℝ} {D : S.DivisorFamily B τ C₀} {h ℓ L : ℕ}
|
| 16 |
+
|
| 17 |
+
lemma treeOccurrences_empty_of_free_core (w : ClosedLine h ℓ) (p : S.FreeCoreIndex w) :
|
| 18 |
+
treeOccurrences w p.val.val = ∅ := by
|
| 19 |
+
apply eq_empty_iff_forall_notMem.mpr
|
| 20 |
+
intro i hi
|
| 21 |
+
exact p.val.property ⟨⟨i,(mem_filter.mp hi).2⟩, Or.inl p.property⟩
|
| 22 |
+
|
| 23 |
+
lemma treeOccurrences_singleton_of_free (w : ClosedLine h ℓ) (p : S.FreeIndex w)
|
| 24 |
+
(e : Fin ℓ) (he : e ∈ treeOccurrences w p.val) :
|
| 25 |
+
treeOccurrences w p.val = {e} := by
|
| 26 |
+
ext i
|
| 27 |
+
constructor
|
| 28 |
+
· intro hi
|
| 29 |
+
exact mem_singleton.mpr ((unique_occurrence_of_free w p.val p.property e
|
| 30 |
+
(mem_filter.mp he).2 i).mp (mem_filter.mp hi).2)
|
| 31 |
+
· intro hi
|
| 32 |
+
simpa only [mem_singleton.mp hi] using he
|
| 33 |
+
|
| 34 |
+
def freeTreeWeight (w : ClosedLine h ℓ) (𝔏 : List (AttachedSpec w D L)) (p : S.Index) : ℝ :=
|
| 35 |
+
∏ e ∈ treeOccurrences w p, singletonTokenWeight w 𝔏 p e
|
| 36 |
+
|
| 37 |
+
lemma freeTreeWeight_nonneg (w : ClosedLine h ℓ) (𝔏 : List (AttachedSpec w D L))
|
| 38 |
+
(p : S.Index) : 0 ≤ freeTreeWeight w 𝔏 p :=
|
| 39 |
+
prod_nonneg (fun _ _ => singletonTokenWeight_nonneg w 𝔏 p _)
|
| 40 |
+
|
| 41 |
+
def primeBound (w : ClosedLine h ℓ) (𝔏 : List (AttachedSpec w D L)) (U : Finset ℤ)
|
| 42 |
+
(E : S.Index → Finset (Fin ℓ)) (p : S.Index) : ℝ :=
|
| 43 |
+
if (treeOccurrences w p).Nonempty then
|
| 44 |
+
(if S.IsFixed w p then fixedTreeWeight w p (E p) else freeTreeWeight w 𝔏 p) / (p : ℝ)
|
| 45 |
+
else outsideTreeBound w 𝔏 U p
|
| 46 |
+
|
| 47 |
+
lemma primeBound_nonneg (w : ClosedLine h ℓ) (𝔏 : List (AttachedSpec w D L))
|
| 48 |
+
(U : Finset ℤ) (E : S.Index → Finset (Fin ℓ)) (p : S.Index) :
|
| 49 |
+
0 ≤ primeBound w 𝔏 U E p := by
|
| 50 |
+
unfold primeBound
|
| 51 |
+
split_ifs
|
| 52 |
+
· exact div_nonneg (fixedTreeWeight_nonneg w p _) (Nat.cast_nonneg _)
|
| 53 |
+
· exact div_nonneg (freeTreeWeight_nonneg w 𝔏 p) (Nat.cast_nonneg _)
|
| 54 |
+
· exact outsideTreeBound_nonneg w 𝔏 U p
|
| 55 |
+
|
| 56 |
+
lemma no_tree_of_not_nonempty (w : ClosedLine h ℓ) (p : S.Index)
|
| 57 |
+
(hn : ¬(treeOccurrences w p).Nonempty) :
|
| 58 |
+
∀ i ∈ w.treeSteps, ¬(p : ℕ) ∣ w.label i := by
|
| 59 |
+
intro i hi hd
|
| 60 |
+
exact hn ⟨i, mem_filter.mpr ⟨hi,hd⟩⟩
|
| 61 |
+
|
| 62 |
+
lemma fixed_mean_le_primeBound (w : ClosedLine h ℓ) (𝔏 : List (AttachedSpec w D L))
|
| 63 |
+
(U : Finset ℤ) (hU : U ⊆ goodOrigins w) (E : S.Index → Finset (Fin ℓ))
|
| 64 |
+
(p : S.FixedIndex w) (htop : NoComponentTop w U p.val (E p.val)) :
|
| 65 |
+
avg (recordPrime w 𝔏 U p.val (E p.val)) ≤ primeBound w 𝔏 U E p.val := by
|
| 66 |
+
by_cases ho : (treeOccurrences w p.val).Nonempty
|
| 67 |
+
· rw [primeBound, ite_eq_left ho, ite_eq_left p.property]
|
| 68 |
+
exact fixed_tree_mean w 𝔏 U hU p.val (E p.val) htop ho
|
| 69 |
+
· rw [primeBound, ite_eq_right ho]
|
| 70 |
+
exact (avg_mono (recordPrime_le_charged_local w 𝔏 U p.val (E p.val))).trans
|
| 71 |
+
(outside_tree_mean w 𝔏 U hU p.val (no_tree_of_not_nonempty w p.val ho))
|
| 72 |
+
|
| 73 |
+
lemma free_core_mean_le_primeBound (w : ClosedLine h ℓ)
|
| 74 |
+
(𝔏 : List (AttachedSpec w D L)) (U : Finset ℤ) (hU : U ⊆ goodOrigins w)
|
| 75 |
+
(E : S.Index → Finset (Fin ℓ)) (p : S.FreeCoreIndex w) :
|
| 76 |
+
avg (fun a => |localWithList w 𝔏 p.val.val a| * allPrimeCharges w U p.val.val a) ≤
|
| 77 |
+
primeBound w 𝔏 U E p.val.val := by
|
| 78 |
+
have ho : ¬(treeOccurrences w p.val.val).Nonempty := by
|
| 79 |
+
rw [treeOccurrences_empty_of_free_core w p]
|
| 80 |
+
exact not_nonempty_empty
|
| 81 |
+
rw [primeBound, ite_eq_right ho]
|
| 82 |
+
exact outside_tree_mean w 𝔏 U hU p.val.val (no_tree_of_not_nonempty w p.val.val ho)
|
| 83 |
+
|
| 84 |
+
lemma free_center_mean_le_primeBound (w : ClosedLine h ℓ) (hh : 0 < h)
|
| 85 |
+
(𝔏 : List (AttachedSpec w D L)) (U : Finset ℤ) (hU : U ⊆ goodOrigins w)
|
| 86 |
+
(E : S.Index → Finset (Fin ℓ)) (p : S.FreeCenterIndex w)
|
| 87 |
+
(hlarge : 2 * (ℓ+1) ≤ (p.val.val : ℕ)) :
|
| 88 |
+
|avg (localWithList w 𝔏 p.val.val)| ≤ primeBound w 𝔏 U E p.val.val := by
|
| 89 |
+
by_cases ho : (treeOccurrences w p.val.val).Nonempty
|
| 90 |
+
· rw [primeBound, ite_eq_left ho, ite_eq_right p.val.property]
|
| 91 |
+
obtain ⟨e,he⟩ := ho
|
| 92 |
+
rw [freeTreeWeight, treeOccurrences_singleton_of_free w p.val e he, prod_singleton]
|
| 93 |
+
exact free_center_tree_mean w hh 𝔏 p e (mem_filter.mp he).2 hlarge
|
| 94 |
+
· rw [primeBound, ite_eq_right ho]
|
| 95 |
+
have hc := outside_tree_mean w 𝔏 U hU p.val.val
|
| 96 |
+
(no_tree_of_not_nonempty w p.val.val ho)
|
| 97 |
+
simp only [allPrimeCharges_center w U p.val.val p.property, mul_one] at hc
|
| 98 |
+
exact (abs_avg_le _).trans hc
|
| 99 |
+
|
| 100 |
+
lemma product_index_split (w : ClosedLine h ℓ) (f : S.Index → ℝ) :
|
| 101 |
+
(∏ p : S.FixedIndex w, f p.val) *
|
| 102 |
+
((∏ p : S.FreeCoreIndex w, f p.val.val) *
|
| 103 |
+
(∏ p : S.FreeCenterIndex w, f p.val.val)) = ∏ p : S.Index, f p := by
|
| 104 |
+
rw [Fintype.prod_subtype_mul_prod_subtype (fun p : S.FreeIndex w => S.IsCore p.val)
|
| 105 |
+
(fun p : S.FreeIndex w => f p.val)]
|
| 106 |
+
exact Fintype.prod_subtype_mul_prod_subtype (S.IsFixed w) f
|
| 107 |
+
|
| 108 |
+
theorem assignedKernelIntegral_le_all_prime_bounds (w : ClosedLine h ℓ) (hh : 0 < h)
|
| 109 |
+
{T : ℝ} (cut : S.Cutoffs T) (𝔏 : List (AttachedSpec w D L))
|
| 110 |
+
(E : S.Index → Finset (Fin ℓ)) (hE : ∀ p, E p ⊆ treeOccurrences w p)
|
| 111 |
+
(group : S.FixedResidues w → Prop)
|
| 112 |
+
(hgroup : ∀ a, group a → ∀ p : S.FixedIndex w, litEdges w p.val (a p) = E p.val)
|
| 113 |
+
(hlarge : ∀ p : S.Index, 2 * (ℓ+1) ≤ (p : ℕ)) :
|
| 114 |
+
assignedKernelIntegral w cut 𝔏 group ≤
|
| 115 |
+
chargeConstant (S := S) w T (recordU w E) *
|
| 116 |
+
∏ p : S.Index, primeBound w 𝔏 (recordU w E) E p := by
|
| 117 |
+
let U := recordU w E
|
| 118 |
+
have hU := recordU_subset w E
|
| 119 |
+
have hh' := assignedKernelIntegral_le_prime_means w cut 𝔏 U hU group
|
| 120 |
+
(fun p => E p.val) hgroup
|
| 121 |
+
apply hh'.trans
|
| 122 |
+
calc
|
| 123 |
+
_ ≤ chargeConstant (S := S) w T U *
|
| 124 |
+
(∏ p : S.FreeCenterIndex w, primeBound w 𝔏 U E p.val.val) *
|
| 125 |
+
(∏ p : S.FixedIndex w, primeBound w 𝔏 U E p.val) *
|
| 126 |
+
∏ p : S.FreeCoreIndex w, primeBound w 𝔏 U E p.val.val := by
|
| 127 |
+
have hZ := prod_le_prod₀ (s := univ) (fun (p : S.FreeCenterIndex w) _ => abs_nonneg
|
| 128 |
+
(avg (localWithList w 𝔏 p.val.val)))
|
| 129 |
+
(fun p _ => free_center_mean_le_primeBound w hh 𝔏 U hU E p (hlarge _))
|
| 130 |
+
have hF := prod_le_prod₀ (s := univ) (fun (p : S.FixedIndex w) _ =>
|
| 131 |
+
avg_nonneg (recordPrime_nonneg w 𝔏 U p.val (E p.val)))
|
| 132 |
+
(fun p _ => fixed_mean_le_primeBound w 𝔏 U hU E p
|
| 133 |
+
(recordU_noComponentTop w E hE _))
|
| 134 |
+
have hC := prod_le_prod₀ (s := univ) (fun (p : S.FreeCoreIndex w) _ => avg_nonneg (fun a =>
|
| 135 |
+
mul_nonneg (abs_nonneg _) (allPrimeCharges_nonneg w U p.val.val a)))
|
| 136 |
+
(fun p _ => free_core_mean_le_primeBound w 𝔏 U hU E p)
|
| 137 |
+
have hZF := mul_le_mul hZ hF
|
| 138 |
+
(prod_nonneg (fun p _ => avg_nonneg (recordPrime_nonneg w 𝔏 U p.val _)))
|
| 139 |
+
(prod_nonneg (fun p _ => primeBound_nonneg w 𝔏 U E p.val.val))
|
| 140 |
+
have hZFC := mul_le_mul hZF hC
|
| 141 |
+
(prod_nonneg (fun p _ => avg_nonneg (fun a =>
|
| 142 |
+
mul_nonneg (abs_nonneg _) (allPrimeCharges_nonneg w U p.val.val a))))
|
| 143 |
+
(mul_nonneg (prod_nonneg (fun p _ => primeBound_nonneg w 𝔏 U E p.val.val))
|
| 144 |
+
(prod_nonneg (fun p _ => primeBound_nonneg w 𝔏 U E p.val)))
|
| 145 |
+
simpa only [chargeConstant, mul_assoc] using mul_le_mul_of_nonneg_left hZFC
|
| 146 |
+
((Real.exp_pos _).le : 0 ≤ chargeConstant (S := S) w T U)
|
| 147 |
+
_ = _ := by
|
| 148 |
+
rw [← product_index_split w]
|
| 149 |
+
ring
|
| 150 |
+
|
| 151 |
+
end OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 152 |
+
|
| 153 |
+
end
|
| 154 |
+
|
| 155 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TreePrimeSupport.lean
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.CardTreeVerticesLe
|
| 2 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.PrimeFactorsCardLeLog
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
noncomputable section
|
| 7 |
+
open scoped BigOperators
|
| 8 |
+
open Finset
|
| 9 |
+
open Finset Classical
|
| 10 |
+
|
| 11 |
+
namespace OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 12 |
+
open OrdinaryCorrelations.SignedTrace OrdinaryCorrelations.FiniteIntegration
|
| 13 |
+
open Finset Classical
|
| 14 |
+
variable {S : PrimeSystem} {B τ C₀ : ℝ} {D : S.DivisorFamily B τ C₀} {h ℓ L : ℕ}
|
| 15 |
+
|
| 16 |
+
def treePrimeSupport (w : ClosedLine h ℓ) : Finset ℕ :=
|
| 17 |
+
w.treeSteps.biUnion (fun i => (w.label i).primeFactors)
|
| 18 |
+
|
| 19 |
+
lemma treePrimeSupport_card_le (w : ClosedLine h ℓ) (hlabels : ∀ i, w.label i ∈ D.members) :
|
| 20 |
+
(treePrimeSupport w).card ≤ ℓ * ⌈C₀ * Real.log B⌉₊ := by
|
| 21 |
+
have hcard : w.treeSteps.card ≤ ℓ := by
|
| 22 |
+
exact (card_le_card (filter_subset _ _)).trans_eq (by simp)
|
| 23 |
+
exact (card_biUnion_le_card_mul w.treeSteps _ _
|
| 24 |
+
(fun i _ => D.omega _ (hlabels i))).trans (Nat.mul_le_mul_right _ hcard)
|
| 25 |
+
|
| 26 |
+
lemma Specification.primeSupport_card_le (s : S.Specification D h L) :
|
| 27 |
+
s.primeSupport.card ≤ L * ⌈C₀ * Real.log B⌉₊ + 1 := by
|
| 28 |
+
calc
|
| 29 |
+
_ ≤ (univ.biUnion (fun i : Fin s.length => (s.label i).primeFactors)).card + 1 :=
|
| 30 |
+
card_insert_le _ _
|
| 31 |
+
_ ≤ s.length * ⌈C₀ * Real.log B⌉₊ + 1 := by
|
| 32 |
+
gcongr
|
| 33 |
+
simpa only [card_univ, Fintype.card_fin] using card_biUnion_le_card_mul
|
| 34 |
+
(univ : Finset (Fin s.length)) (fun i => (s.label i).primeFactors) _
|
| 35 |
+
(fun i _ => D.omega _ (s.label_mem i))
|
| 36 |
+
_ ≤ _ := Nat.add_le_add_right (Nat.mul_le_mul_right _ s.length_le) _
|
| 37 |
+
|
| 38 |
+
lemma listSupport_card_le (w : ClosedLine h ℓ) (𝔏 : List (AttachedSpec w D L)) :
|
| 39 |
+
(listSupport w 𝔏).card ≤ 𝔏.length * (L * ⌈C₀ * Real.log B⌉₊ + 1) := by
|
| 40 |
+
exact (card_biUnion_le_card_mul 𝔏.toFinset _ _
|
| 41 |
+
(fun s _ => s.spec.primeSupport_card_le)).trans
|
| 42 |
+
(Nat.mul_le_mul_right _ (List.toFinset_card_le _))
|
| 43 |
+
|
| 44 |
+
lemma usedPrime_mem_support (w : ClosedLine h ℓ) (𝔏 : List (AttachedSpec w D L))
|
| 45 |
+
(p : S.Index) : UsedPrime w 𝔏 p ↔ (p : ℕ) ∈ treePrimeSupport w ∪ listSupport w 𝔏 := by
|
| 46 |
+
unfold UsedPrime
|
| 47 |
+
rw [mem_union]
|
| 48 |
+
refine or_congr ?_ Iff.rfl
|
| 49 |
+
unfold treePrimeSupport
|
| 50 |
+
constructor
|
| 51 |
+
· rintro ⟨e,he⟩
|
| 52 |
+
obtain ⟨het,hep⟩ := mem_filter.mp he
|
| 53 |
+
exact mem_biUnion.mpr ⟨e,het, Nat.mem_primeFactors.mpr
|
| 54 |
+
⟨S.prime_mem p p.property,hep,(w.label_pos e).ne'⟩⟩
|
| 55 |
+
· intro hm
|
| 56 |
+
obtain ⟨e,he,hep⟩ := mem_biUnion.mp hm
|
| 57 |
+
exact ⟨e,mem_filter.mpr ⟨he,(Nat.mem_primeFactors.mp hep).2.1⟩⟩
|
| 58 |
+
|
| 59 |
+
def usedIndices (w : ClosedLine h ℓ) (𝔏 : List (AttachedSpec w D L)) : Finset S.Index :=
|
| 60 |
+
univ.filter (UsedPrime w 𝔏)
|
| 61 |
+
|
| 62 |
+
def lineListSlots (w : ClosedLine h ℓ) (𝔏 : List (AttachedSpec w D L)) : ℕ :=
|
| 63 |
+
ℓ * ⌈C₀ * Real.log B⌉₊ + 𝔏.length * (L * ⌈C₀ * Real.log B⌉₊ + 1)
|
| 64 |
+
|
| 65 |
+
lemma usedIndices_card_le (w : ClosedLine h ℓ) (𝔏 : List (AttachedSpec w D L))
|
| 66 |
+
(hlabels : ∀ i, w.label i ∈ D.members) :
|
| 67 |
+
(usedIndices w 𝔏).card ≤ lineListSlots w 𝔏 := by
|
| 68 |
+
have hsub : (usedIndices w 𝔏).image Subtype.val ⊆ treePrimeSupport w ∪ listSupport w 𝔏 := by
|
| 69 |
+
intro p hp
|
| 70 |
+
obtain ⟨q,hq,hqp⟩ := mem_image.mp hp
|
| 71 |
+
rw [← hqp]
|
| 72 |
+
exact (usedPrime_mem_support w 𝔏 q).mp (mem_filter.mp hq).2
|
| 73 |
+
calc
|
| 74 |
+
_ = ((usedIndices w 𝔏).image Subtype.val).card :=
|
| 75 |
+
(card_image_of_injective _ Subtype.val_injective).symm
|
| 76 |
+
_ ≤ (treePrimeSupport w ∪ listSupport w 𝔏).card := card_le_card hsub
|
| 77 |
+
_ ≤ (treePrimeSupport w).card + (listSupport w 𝔏).card := card_union_le _ _
|
| 78 |
+
_ ≤ _ := Nat.add_le_add (treePrimeSupport_card_le w hlabels) (listSupport_card_le w 𝔏)
|
| 79 |
+
|
| 80 |
+
lemma restorationError_le_masses (w : ClosedLine h ℓ) (𝔏 : List (AttachedSpec w D L)) :
|
| 81 |
+
restorationError w 𝔏 ≤ ((ℓ : ℝ)+1) *
|
| 82 |
+
((∑ p ∈ usedIndices w 𝔏, (p : ℝ)⁻¹) +
|
| 83 |
+
∑ p ∈ collisionIndices (S := S) w, (p : ℝ)⁻¹) := by
|
| 84 |
+
apply mul_le_mul_of_nonneg_left _ (by positivity)
|
| 85 |
+
rw [usedIndices, collisionIndices, sum_filter, sum_filter, ← sum_add_distrib]
|
| 86 |
+
apply sum_le_sum
|
| 87 |
+
intro p hp
|
| 88 |
+
unfold OmittedPrime
|
| 89 |
+
by_cases hu : UsedPrime w 𝔏 p <;> by_cases hc : IsCollision w p <;>
|
| 90 |
+
simp [hu,hc, inv_nonneg.mpr (show 0 ≤ (p : ℝ) from Nat.cast_nonneg _)]
|
| 91 |
+
|
| 92 |
+
lemma card_tree_offDiag_le (w : ClosedLine h ℓ) :
|
| 93 |
+
(treeVertices w).offDiag.card ≤ (ℓ+1)^2 := by
|
| 94 |
+
have hsub : (treeVertices w).offDiag ⊆ (treeVertices w) ×ˢ (treeVertices w) := by
|
| 95 |
+
intro vu hvu
|
| 96 |
+
obtain ⟨hv,hu,_⟩ := mem_offDiag.mp hvu
|
| 97 |
+
exact mem_product.mpr ⟨hv,hu⟩
|
| 98 |
+
calc
|
| 99 |
+
_ ≤ ((treeVertices w) ×ˢ (treeVertices w)).card := card_le_card hsub
|
| 100 |
+
_ = (treeVertices w).card * (treeVertices w).card := card_product _ _
|
| 101 |
+
_ ≤ (ℓ+1) * (ℓ+1) := Nat.mul_le_mul (card_treeVertices_le w) (card_treeVertices_le w)
|
| 102 |
+
_ = _ := (pow_two _).symm
|
| 103 |
+
|
| 104 |
+
theorem restorationError_le (w : ClosedLine h ℓ) (𝔏 : List (AttachedSpec w D L))
|
| 105 |
+
(hlabels : ∀ i, w.label i ∈ D.members) (M P₀ : ℝ) (hM₀ : 0 ≤ M) (hP₀ : 0 < P₀)
|
| 106 |
+
(hp : ∀ p : S.Index, P₀ ≤ (p : ℝ))
|
| 107 |
+
(hM : ∀ v ∈ treeVertices w, ∀ u ∈ treeVertices w,
|
| 108 |
+
v ≠ u → ((u-v).natAbs : ℝ) ≤ Real.exp M) :
|
| 109 |
+
restorationError w 𝔏 ≤ ((ℓ : ℝ)+1) *
|
| 110 |
+
((lineListSlots w 𝔏 : ℝ) + ((ℓ : ℝ)+1)^2 * (M / Real.log 2)) / P₀ := by
|
| 111 |
+
have huCard : ((usedIndices w 𝔏).card : ℝ) ≤ (lineListSlots w 𝔏 : ℝ) := by
|
| 112 |
+
exact_mod_cast usedIndices_card_le w 𝔏 hlabels
|
| 113 |
+
have hused := (sum_inv_le_card_div (usedIndices w 𝔏) P₀ hP₀ (fun p _ => hp p)).trans
|
| 114 |
+
(div_le_div_of_nonneg_right huCard hP₀.le)
|
| 115 |
+
have hcoll := collision_reciprocal_mass w M P₀ hP₀ hp hM
|
| 116 |
+
have hcoll' : (∑ p ∈ collisionIndices (S := S) w, (p : ℝ)⁻¹) ≤
|
| 117 |
+
((ℓ : ℝ)+1)^2 * (M / Real.log 2) / P₀ := by
|
| 118 |
+
apply hcoll.trans
|
| 119 |
+
apply div_le_div_of_nonneg_right _ hP₀.le
|
| 120 |
+
exact mul_le_mul_of_nonneg_right (by exact_mod_cast card_tree_offDiag_le w)
|
| 121 |
+
(div_nonneg hM₀ (Real.log_nonneg (by norm_num)))
|
| 122 |
+
apply (restorationError_le_masses w 𝔏).trans
|
| 123 |
+
have hm := mul_le_mul_of_nonneg_left (add_le_add hused hcoll') (by positivity : 0 ≤ (ℓ : ℝ)+1)
|
| 124 |
+
convert hm using 1
|
| 125 |
+
ring
|
| 126 |
+
|
| 127 |
+
end OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 128 |
+
|
| 129 |
+
end
|
| 130 |
+
|
| 131 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TreeVertices.lean
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.KappaPos
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
noncomputable section
|
| 6 |
+
open scoped BigOperators
|
| 7 |
+
open Finset
|
| 8 |
+
open Finset Classical
|
| 9 |
+
|
| 10 |
+
namespace OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 11 |
+
open OrdinaryCorrelations.FiniteIntegration OrdinaryCorrelations.SignedTrace
|
| 12 |
+
open Finset Classical
|
| 13 |
+
variable {S : PrimeSystem} {h ℓ : ℕ}
|
| 14 |
+
|
| 15 |
+
def treeVertices (w : ClosedLine h ℓ) : Finset ℤ := univ.image w.offset
|
| 16 |
+
|
| 17 |
+
lemma departure_mem_vertices (w : ClosedLine h ℓ) (i : Fin ℓ) :
|
| 18 |
+
w.offset i.castSucc ∈ treeVertices w := mem_image.mpr ⟨i.castSucc, mem_univ _, rfl⟩
|
| 19 |
+
|
| 20 |
+
lemma endpoint_mem_vertices (w : ClosedLine h ℓ) (i : Fin ℓ) :
|
| 21 |
+
w.offset i.succ ∈ treeVertices w := mem_image.mpr ⟨i.succ, mem_univ _, rfl⟩
|
| 22 |
+
|
| 23 |
+
lemma tree_normalization (w : ClosedLine h ℓ) (p : S.Index) (x : ZMod (p : ℕ)) :
|
| 24 |
+
(∏ i ∈ w.treeSteps, S.beta p ^
|
| 25 |
+
(if x + (w.offset i.castSucc : ZMod (p : ℕ)) = 0 then (1 : ℕ) else 0)) =
|
| 26 |
+
∏ v ∈ treeVertices w, if x + (v : ZMod (p : ℕ)) = 0 then
|
| 27 |
+
S.beta p ^ w.children v else 1 := by
|
| 28 |
+
rw [← prod_fiberwise_of_maps_to (fun i (_ : i ∈ w.treeSteps) => departure_mem_vertices w i)]
|
| 29 |
+
apply prod_congr rfl
|
| 30 |
+
intro v hv
|
| 31 |
+
by_cases ha : x + (v : ZMod (p : ℕ)) = 0
|
| 32 |
+
· simp only [ha, ite_true, ClosedLine.children]
|
| 33 |
+
trans ∏ i ∈ w.treeSteps.filter (fun i => w.offset i.castSucc = v), S.beta p
|
| 34 |
+
· apply prod_congr rfl
|
| 35 |
+
intro i hi
|
| 36 |
+
rw [(mem_filter.mp hi).2, ite_eq_left ha, pow_one]
|
| 37 |
+
· rw [prod_const]
|
| 38 |
+
· rw [ite_eq_right ha]
|
| 39 |
+
apply prod_eq_one
|
| 40 |
+
intro i hi
|
| 41 |
+
rw [(mem_filter.mp hi).2, ite_eq_right ha, pow_zero]
|
| 42 |
+
|
| 43 |
+
lemma residue_product_mean {ι : Type*} {p : ℕ} [NeZero p]
|
| 44 |
+
(V : Finset ι) (r : ι → ZMod p) (g : ι → ℝ)
|
| 45 |
+
(hinj : Set.InjOn r V) :
|
| 46 |
+
avg (fun a : ZMod p => ∏ v ∈ V, if a = r v then g v else 1) =
|
| 47 |
+
1 - (∑ v ∈ V, (1 - g v)) / p := by
|
| 48 |
+
have hpoint (a : ZMod p) :
|
| 49 |
+
(∏ v ∈ V, if a = r v then g v else 1) =
|
| 50 |
+
1 + ∑ v ∈ V, if a = r v then g v - 1 else 0 := by
|
| 51 |
+
by_cases ha : ∃ v ∈ V, a = r v
|
| 52 |
+
· obtain ⟨v,hv,ha⟩ := ha
|
| 53 |
+
have hne (q : ι) (hq : q ∈ V) (hqv : q ≠ v) : a ≠ r q := by
|
| 54 |
+
intro h
|
| 55 |
+
exact hqv (hinj hq hv (h.symm.trans ha))
|
| 56 |
+
rw [prod_eq_single_of_mem v hv (fun q hq hqv => ite_eq_right (hne q hq hqv)),
|
| 57 |
+
sum_eq_single_of_mem v hv (fun q hq hqv => ite_eq_right (hne q hq hqv))]
|
| 58 |
+
simp only [ite_eq_left ha]
|
| 59 |
+
ring
|
| 60 |
+
· have hne (v : ι) (hv : v ∈ V) : a ≠ r v := fun h => ha ⟨v,hv,h⟩
|
| 61 |
+
rw [prod_eq_one (fun v hv => ite_eq_right (hne v hv)),
|
| 62 |
+
sum_eq_zero (fun v hv => ite_eq_right (hne v hv))]
|
| 63 |
+
ring
|
| 64 |
+
simp_rw [hpoint]
|
| 65 |
+
simp only [avg, sum_add_distrib, sum_const, card_univ, ZMod.card, nsmul_eq_mul]
|
| 66 |
+
rw [sum_comm]
|
| 67 |
+
simp only [sum_ite_eq', mem_univ, ite_true]
|
| 68 |
+
have hp : (p : ℝ) ≠ 0 := by exact_mod_cast NeZero.ne p
|
| 69 |
+
rw [sum_sub_distrib, sum_const, nsmul_eq_mul]
|
| 70 |
+
simp only [sum_sub_distrib, sum_const, nsmul_eq_mul]
|
| 71 |
+
field_simp
|
| 72 |
+
ring
|
| 73 |
+
|
| 74 |
+
def backgroundMultiplier (w : ClosedLine h ℓ) (U : Finset ℤ) (p : S.Index)
|
| 75 |
+
(a : ZMod (p : ℕ)) : ℝ :=
|
| 76 |
+
∏ v ∈ treeVertices w, if a + (v : ZMod (p : ℕ)) = 0 then
|
| 77 |
+
S.beta p ^ w.children v * (if S.IsCore p ∧ v ∈ U then Real.exp kappa else 1) else 1
|
| 78 |
+
|
| 79 |
+
def treeDefect (w : ClosedLine h ℓ) (p : S.Index) : ℝ :=
|
| 80 |
+
∑ v ∈ treeVertices w, (1 - S.beta p ^ w.children v)
|
| 81 |
+
|
| 82 |
+
lemma beta_nonneg (p : S.Index) : 0 ≤ S.beta p := by
|
| 83 |
+
have ha := A_pos
|
| 84 |
+
unfold beta amplitude
|
| 85 |
+
split_ifs <;> positivity
|
| 86 |
+
|
| 87 |
+
lemma beta_le_one (p : S.Index) : S.beta p ≤ 1 := by
|
| 88 |
+
unfold beta amplitude
|
| 89 |
+
split_ifs
|
| 90 |
+
· exact betaC_le_one
|
| 91 |
+
· norm_num
|
| 92 |
+
|
| 93 |
+
lemma background_vertex_le_one (w : ClosedLine h ℓ) (U : Finset ℤ)
|
| 94 |
+
(hU : ∀ v ∈ U, w.children v = 1) (p : S.Index) (v : ℤ) :
|
| 95 |
+
S.beta p ^ w.children v * (if S.IsCore p ∧ v ∈ U then Real.exp kappa else 1) ≤ 1 := by
|
| 96 |
+
by_cases hu : S.IsCore p ∧ v ∈ U
|
| 97 |
+
· rw [ite_eq_left hu, hU v hu.2, pow_one]
|
| 98 |
+
simpa only [beta, amplitude, hu.1, ite_true, betaC] using betaC_mul_exp_le_one
|
| 99 |
+
· rw [ite_eq_right hu, mul_one]
|
| 100 |
+
exact pow_le_one₀ (beta_nonneg p) (beta_le_one p)
|
| 101 |
+
|
| 102 |
+
lemma backgroundMultiplier_bounds (w : ClosedLine h ℓ) (U : Finset ℤ)
|
| 103 |
+
(hU : ∀ v ∈ U, w.children v = 1) (p : S.Index) (a : ZMod (p : ℕ)) :
|
| 104 |
+
0 ≤ backgroundMultiplier w U p a ∧ backgroundMultiplier w U p a ≤ 1 := by
|
| 105 |
+
have hnon (v : ℤ) : 0 ≤ (if a + (v : ZMod (p : ℕ)) = 0 then
|
| 106 |
+
S.beta p ^ w.children v * (if S.IsCore p ∧ v ∈ U then Real.exp kappa else 1) else 1) := by
|
| 107 |
+
have hb := beta_nonneg p
|
| 108 |
+
split_ifs <;> positivity
|
| 109 |
+
constructor
|
| 110 |
+
· exact prod_nonneg (fun v _ => hnon v)
|
| 111 |
+
· apply prod_le_one₀ (fun v _ => hnon v)
|
| 112 |
+
intro v hv
|
| 113 |
+
by_cases ha : a + (v : ZMod (p : ℕ)) = 0
|
| 114 |
+
· rw [ite_eq_left ha]
|
| 115 |
+
exact background_vertex_le_one w U hU p v
|
| 116 |
+
· rw [ite_eq_right ha]
|
| 117 |
+
|
| 118 |
+
lemma background_mean_exact (w : ClosedLine h ℓ) (U : Finset ℤ)
|
| 119 |
+
(p : S.Index) (hinj : Set.InjOn (fun v : ℤ => (v : ZMod (p : ℕ))) (treeVertices w)) :
|
| 120 |
+
avg (backgroundMultiplier w U p) = 1 -
|
| 121 |
+
(∑ v ∈ treeVertices w,
|
| 122 |
+
(1 - S.beta p ^ w.children v *
|
| 123 |
+
(if S.IsCore p ∧ v ∈ U then Real.exp kappa else 1))) / (p : ℝ) := by
|
| 124 |
+
change avg (fun a => ∏ v ∈ treeVertices w, if a + (v : ZMod (p : ℕ)) = 0 then _ else _) = _
|
| 125 |
+
simp only [add_eq_zero_iff_eq_neg]
|
| 126 |
+
apply residue_product_mean
|
| 127 |
+
intro v hv u hu hneg
|
| 128 |
+
exact hinj hv hu (neg_injective hneg)
|
| 129 |
+
|
| 130 |
+
end OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 131 |
+
|
| 132 |
+
end
|
| 133 |
+
|
| 134 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TwoBlockRerooting.lean
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.GateAncestor
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
noncomputable section
|
| 6 |
+
open scoped BigOperators
|
| 7 |
+
open Finset
|
| 8 |
+
open Finset Classical
|
| 9 |
+
open Filter
|
| 10 |
+
open Finset Classical Filter
|
| 11 |
+
open scoped Topology
|
| 12 |
+
|
| 13 |
+
namespace OrdinaryCorrelations.Rerooting
|
| 14 |
+
open Classical Finset SimpleGraph
|
| 15 |
+
noncomputable section
|
| 16 |
+
variable {V α : Type*} [DecidableEq V] [Fintype α] [DecidableEq α]
|
| 17 |
+
variable {G₁ G₂ : SimpleGraph V} {root₁ root₂ : V} {A₁ A₂ : α→Finset V}
|
| 18 |
+
|
| 19 |
+
theorem two_block_rerooting (hG₁ : G₁.IsAcyclic) (hG₂ : G₂.IsAcyclic)
|
| 20 |
+
(g₁ : ∀ p,Gate G₁ root₁ (A₁ p)) (g₂ : ∀ p,Gate G₂ root₂ (A₂ p))
|
| 21 |
+
(hA₂ : ∀ p,ConnectedSet G₂ (A₂ p))
|
| 22 |
+
(J n : ℕ) (hn : n^8 ≤ Fintype.card α)
|
| 23 |
+
(hcap : ∀ x y,G₂.Adj x y → (univ.filter (fun p => x ∈ A₂ p ∧ y ∈ A₂ p)).card ≤ J) :
|
| 24 |
+
∃ (t : Finset α) (root : V) (g : ∀ p : t,Gate G₂ root (A₂ p.val)) (key : t→ℕ),
|
| 25 |
+
n ≤ (2*J+1)*t.card ∧ (root=root₂ ∨ ∃ p,root=(g₂ p).vertex) ∧
|
| 26 |
+
∀ p q : t,gateAncestor (fun p : t => g₁ p.val) p q ∨ gateAncestor g p q → key p<key q := by
|
| 27 |
+
by_cases hn0 : n=0
|
| 28 |
+
· refine ⟨∅,root₂,(fun p => g₂ p.val),(fun p => (g₁ p.val).path.length),by simp [hn0],Or.inl rfl,?_⟩
|
| 29 |
+
intro p _ _
|
| 30 |
+
exact (notMem_empty p.val p.property).elim
|
| 31 |
+
have hr₁ := ancestor_trans hG₁ root₁ (fun p => (g₁ p).vertex) (fun p => (g₁ p).path) (fun p => (g₁ p).simple)
|
| 32 |
+
have hr₂ := ancestor_trans hG₂ root₂ (fun p => (g₂ p).vertex) (fun p => (g₂ p).path) (fun p => (g₂ p).simple)
|
| 33 |
+
obtain ⟨c,hcu,hc,hcases⟩ := two_order_extraction (gateAncestor g₁) (gateAncestor g₂)
|
| 34 |
+
hr₁ (ancestor_irrefl root₁ (fun p => (g₁ p).vertex) (fun p => (g₁ p).path))
|
| 35 |
+
hr₂ (ancestor_irrefl root₂ (fun p => (g₂ p).vertex) (fun p => (g₂ p).path)) univ n (by simpa using hn)
|
| 36 |
+
have hcne : c.Nonempty := card_pos.mp (by omega)
|
| 37 |
+
have hcs : n ≤ (2*J+1)*c.card := hc.trans (by nlinarith)
|
| 38 |
+
rcases hcases with ha₁|ha₂|hag|hre
|
| 39 |
+
· refine ⟨c,root₂,(fun p => g₂ p.val),(fun p => (g₂ p.val).path.length),hcs,Or.inl rfl,?_⟩
|
| 40 |
+
intro p q h
|
| 41 |
+
rcases h with h|h
|
| 42 |
+
· exact ((ha₁ p.property q.property (fun he => h.2 (congrArg (fun p => (g₁ p).vertex) he))).1 h).elim
|
| 43 |
+
· exact ancestor_length_lt hG₂ root₂ _ _ (fun p : c => (g₂ p.val).simple) h
|
| 44 |
+
· refine ⟨c,root₂,(fun p => g₂ p.val),(fun p => (g₁ p.val).path.length),hcs,Or.inl rfl,?_⟩
|
| 45 |
+
intro p q h
|
| 46 |
+
rcases h with h|h
|
| 47 |
+
· exact ancestor_length_lt hG₁ root₁ _ _ (fun p : c => (g₁ p.val).simple) h
|
| 48 |
+
· exact ((ha₂ p.property q.property (fun he => h.2 (congrArg (fun p => (g₂ p).vertex) he))).1 h).elim
|
| 49 |
+
· refine ⟨c,root₂,(fun p => g₂ p.val),(fun p => (g₁ p.val).path.length),hcs,Or.inl rfl,?_⟩
|
| 50 |
+
intro p q h
|
| 51 |
+
rcases h with h|h
|
| 52 |
+
· exact ancestor_length_lt hG₁ root₁ _ _ (fun p : c => (g₁ p.val).simple) h
|
| 53 |
+
· have hpq : p.val≠q.val := fun he => h.2 (congrArg (fun p => (g₂ p).vertex) he)
|
| 54 |
+
rcases hag p.property q.property hpq with ha|ha
|
| 55 |
+
· exact ancestor_length_lt hG₁ root₁ _ _ (fun p => (g₁ p).simple) ha.1
|
| 56 |
+
· have hlt := ancestor_length_lt hG₂ root₂ _ _ (fun p : c => (g₂ p.val).simple) h
|
| 57 |
+
have hgt := ancestor_length_lt hG₂ root₂ _ _ (fun p => (g₂ p).simple) ha.2
|
| 58 |
+
omega
|
| 59 |
+
· let : Nonempty c := ⟨⟨hcne.choose,hcne.choose_spec⟩⟩
|
| 60 |
+
have hre' : Chain (Reverse (gateAncestor (fun p : c => g₁ p.val))
|
| 61 |
+
(gateAncestor (fun p : c => g₂ p.val))) univ := by
|
| 62 |
+
intro p _ q _ hpq
|
| 63 |
+
exact hre p.property q.property (fun he => hpq (Subtype.ext he))
|
| 64 |
+
have hcap' (x y : V) (hxy : G₂.Adj x y) :
|
| 65 |
+
(univ.filter (fun p : c => x ∈ A₂ p.val ∧ y ∈ A₂ p.val)).card ≤ J := by
|
| 66 |
+
let u := univ.filter (fun p : c => x ∈ A₂ p.val ∧ y ∈ A₂ p.val)
|
| 67 |
+
calc
|
| 68 |
+
u.card=(u.image Subtype.val).card := (card_image_of_injective _ Subtype.val_injective).symm
|
| 69 |
+
_ ≤ (univ.filter (fun p => x ∈ A₂ p ∧ y ∈ A₂ p)).card := by
|
| 70 |
+
apply card_le_card
|
| 71 |
+
intro p hp
|
| 72 |
+
obtain ⟨q,hq,rfl⟩ := mem_image.mp hp
|
| 73 |
+
exact mem_filter.mpr ⟨mem_univ _,(mem_filter.mp hq).2⟩
|
| 74 |
+
_ ≤ J := hcap x y hxy
|
| 75 |
+
obtain ⟨root,g,u,hcard,hroot,horder⟩ := reroot_reverse hG₁ hG₂
|
| 76 |
+
(fun p : c => g₁ p.val) (fun p : c => g₂ p.val) (fun p => hA₂ p.val) hre' J hcap'
|
| 77 |
+
let t := u.image Subtype.val
|
| 78 |
+
have htc : t ⊆ c := image_subset_iff.mpr (fun p _ => p.property)
|
| 79 |
+
let e : t→c := fun p => ⟨p.val,htc p.property⟩
|
| 80 |
+
have heu (p : t) : e p ∈ u := by
|
| 81 |
+
obtain ⟨q,hq,he⟩ := mem_image.mp p.property
|
| 82 |
+
have heq : e p=q := Subtype.ext he.symm
|
| 83 |
+
simpa only [heq] using hq
|
| 84 |
+
have htcard : t.card=u.card := card_image_of_injective _ Subtype.val_injective
|
| 85 |
+
refine ⟨t,root,(fun p => g (e p)),(fun p => (g₁ p.val).path.length),?_,?_,?_⟩
|
| 86 |
+
· rw [htcard]
|
| 87 |
+
exact hc.trans (by simpa using hcard)
|
| 88 |
+
· right
|
| 89 |
+
obtain ⟨p,hp⟩ := hroot
|
| 90 |
+
exact ⟨p.val,hp⟩
|
| 91 |
+
· intro p q h
|
| 92 |
+
rcases h with h|h
|
| 93 |
+
· exact ancestor_length_lt hG₁ root₁ _ _ (fun p : t => (g₁ p.val).simple) h
|
| 94 |
+
· exact horder (e p) (heu p) (e q) (heu q) h
|
| 95 |
+
|
| 96 |
+
end
|
| 97 |
+
end OrdinaryCorrelations.Rerooting
|
| 98 |
+
|
| 99 |
+
end
|
| 100 |
+
|
| 101 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/TwoTermBinomial.lean
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.MemSupport
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
noncomputable section
|
| 6 |
+
open scoped BigOperators
|
| 7 |
+
open Finset
|
| 8 |
+
open Finset Classical
|
| 9 |
+
open Filter
|
| 10 |
+
open Finset Classical Filter
|
| 11 |
+
open scoped Topology
|
| 12 |
+
|
| 13 |
+
namespace OrdinaryCorrelations.SourceCylinder
|
| 14 |
+
variable {ι : Type*} [Fintype ι] {Ω : ι → Type*} [∀ p, Fintype (Ω p)]
|
| 15 |
+
local instance twoTermBinomialDecidableEqIndex : DecidableEq ι := Classical.decEq _
|
| 16 |
+
local instance twoTermBinomialDecidableEqIntersection (E : Finset (Cylinder Ω)) :
|
| 17 |
+
DecidableEq (Intersection E) := Classical.decEq _
|
| 18 |
+
local instance twoTermBinomialDecidableLEIntersection (E : Finset (Cylinder Ω)) :
|
| 19 |
+
DecidableLE (Intersection E) := Classical.decRel _
|
| 20 |
+
local instance twoTermBinomialDecidableLTIntersection (E : Finset (Cylinder Ω)) :
|
| 21 |
+
DecidableLT (Intersection E) := Classical.decRel _
|
| 22 |
+
local instance twoTermBinomialLocallyFiniteOrderIntersection (E : Finset (Cylinder Ω)) :
|
| 23 |
+
LocallyFiniteOrder (Intersection E) :=
|
| 24 |
+
Fintype.toLocallyFiniteOrder
|
| 25 |
+
|
| 26 |
+
lemma two_term_binomial (a k : ℕ) :
|
| 27 |
+
a ^ (k + 1) + (k + 1) * a ^ k ≤ (a + 1) ^ (k + 1) := by
|
| 28 |
+
induction k with
|
| 29 |
+
| zero => simp
|
| 30 |
+
| succ k ih =>
|
| 31 |
+
have h := Nat.mul_le_mul_right (a + 1) ih
|
| 32 |
+
simp only [pow_succ] at h ⊢
|
| 33 |
+
calc
|
| 34 |
+
a ^ k * a * a + (k+1+1) * (a^k*a)
|
| 35 |
+
≤ a ^ k * a * a + (k+1+1) * (a^k*a) + (k+1)*a^k := Nat.le_add_right _ _
|
| 36 |
+
_ = (a^k*a + (k+1)*a^k)*(a+1) := by ring
|
| 37 |
+
_ ≤ (a+1)^k*(a+1)*(a+1) := h
|
| 38 |
+
|
| 39 |
+
lemma double_power_le (n : ℕ) : 2 * n ^ (n+1) ≤ (n+1) ^ (n+1) := by
|
| 40 |
+
have h := two_term_binomial n n
|
| 41 |
+
have h' : 2 * n ^ (n+1) ≤ n ^ (n+1) + (n+1) * n ^ n := by
|
| 42 |
+
rw [pow_succ]
|
| 43 |
+
calc
|
| 44 |
+
2*(n^n*n) ≤ 2*(n^n*n)+n^n := Nat.le_add_right _ _
|
| 45 |
+
_ = n^n*n+(n+1)*n^n := by ring
|
| 46 |
+
exact h'.trans h
|
| 47 |
+
|
| 48 |
+
lemma factorial_power_bound (m : ℕ) (hm : 2 ≤ m) :
|
| 49 |
+
2 ^ m * m.factorial ≤ m ^ (m+1) := by
|
| 50 |
+
induction m with
|
| 51 |
+
| zero => omega
|
| 52 |
+
| succ n ih =>
|
| 53 |
+
by_cases hn : 2 ≤ n
|
| 54 |
+
· calc
|
| 55 |
+
2 ^ (n+1) * (n+1).factorial = (n+1) * (2 * (2^n * n.factorial)) := by
|
| 56 |
+
rw [pow_succ, Nat.factorial_succ]; ring
|
| 57 |
+
_ ≤ (n+1) * (2 * n ^ (n+1)) := Nat.mul_le_mul_left _ (Nat.mul_le_mul_left _ (ih hn))
|
| 58 |
+
_ ≤ (n+1) * (n+1) ^ (n+1) := Nat.mul_le_mul_left _ (double_power_le n)
|
| 59 |
+
_ = (n+1) ^ (n+1+1) := by rw [pow_succ]; ring
|
| 60 |
+
· have : n = 1 := by omega
|
| 61 |
+
subst n
|
| 62 |
+
decide
|
| 63 |
+
|
| 64 |
+
lemma geometric_two_bound (m : ℕ) : (∑ k ∈ Finset.range m, 2^k) ≤ 2^m := by
|
| 65 |
+
induction m with
|
| 66 |
+
| zero => simp
|
| 67 |
+
| succ m ih => rw [Finset.sum_range_succ, pow_succ]; omega
|
| 68 |
+
|
| 69 |
+
lemma choose_factorial_le {m k : ℕ} (hk : k ≤ m) :
|
| 70 |
+
m.choose k * k.factorial ≤ m.factorial := by
|
| 71 |
+
have h := Nat.choose_mul_factorial_mul_factorial hk
|
| 72 |
+
calc
|
| 73 |
+
m.choose k * k.factorial ≤ (m.choose k * k.factorial) * (m-k).factorial := by
|
| 74 |
+
exact Nat.le_mul_of_pos_right _ (Nat.factorial_pos _)
|
| 75 |
+
_ = m.factorial := h
|
| 76 |
+
|
| 77 |
+
omit [Fintype ι] in
|
| 78 |
+
lemma proper_subset_factorial_sum (U : Finset ι) :
|
| 79 |
+
(∑ S ∈ U.powerset with S.card < U.card, 2 ^ S.card * S.card.factorial) ≤
|
| 80 |
+
2 ^ U.card * U.card.factorial := by
|
| 81 |
+
classical
|
| 82 |
+
rw [Finset.sum_filter]
|
| 83 |
+
rw [Finset.sum_powerset]
|
| 84 |
+
have hlevel (k : ℕ) :
|
| 85 |
+
(∑ S ∈ U.powersetCard k,
|
| 86 |
+
if S.card < U.card then 2 ^ S.card * S.card.factorial else 0) =
|
| 87 |
+
U.card.choose k * (if k < U.card then 2 ^ k * k.factorial else 0) := by
|
| 88 |
+
simpa [nsmul_eq_mul] using
|
| 89 |
+
(Finset.sum_powersetCard k U (fun k => if k < U.card then 2 ^ k * k.factorial else 0))
|
| 90 |
+
simp_rw [hlevel]
|
| 91 |
+
rw [Finset.sum_range_succ]
|
| 92 |
+
simp only [lt_self_iff_false, ↓reduceIte, mul_zero, add_zero]
|
| 93 |
+
calc
|
| 94 |
+
(∑ k ∈ Finset.range U.card,
|
| 95 |
+
U.card.choose k * (if k < U.card then 2 ^ k * k.factorial else 0))
|
| 96 |
+
≤ ∑ k ∈ Finset.range U.card, 2 ^ k * U.card.factorial := by
|
| 97 |
+
apply Finset.sum_le_sum
|
| 98 |
+
intro k hk
|
| 99 |
+
have hk' := Finset.mem_range.mp hk
|
| 100 |
+
simp only [hk', ↓reduceIte]
|
| 101 |
+
calc
|
| 102 |
+
U.card.choose k * (2 ^ k * k.factorial) = 2 ^ k * (U.card.choose k * k.factorial) := by ring
|
| 103 |
+
_ ≤ 2 ^ k * U.card.factorial := Nat.mul_le_mul_left _ (choose_factorial_le hk'.le)
|
| 104 |
+
_ = (∑ k ∈ Finset.range U.card, 2 ^ k) * U.card.factorial := by rw [Finset.sum_mul]
|
| 105 |
+
_ ≤ 2 ^ U.card * U.card.factorial := Nat.mul_le_mul_right _ (geometric_two_bound _)
|
| 106 |
+
|
| 107 |
+
omit [∀ p, Fintype (Ω p)] in
|
| 108 |
+
lemma intersection_support_inj (E : Finset (Cylinder Ω)) (I : Intersection E) :
|
| 109 |
+
Set.InjOn (fun J : Intersection E => J.val.support) {J | J ≤ I} := by
|
| 110 |
+
intro J hJ K hK heq
|
| 111 |
+
exact Subtype.ext (Cylinder.eq_of_support_eq hJ hK heq)
|
| 112 |
+
|
| 113 |
+
lemma coefficient_crude (E : Finset (Cylinder Ω)) (I : Intersection E) :
|
| 114 |
+
(coefficient E I).natAbs ≤ 2 ^ I.val.support.card * I.val.support.card.factorial := by
|
| 115 |
+
classical
|
| 116 |
+
have aux : ∀ m, ∀ I : Intersection E, I.val.support.card = m →
|
| 117 |
+
(coefficient E I).natAbs ≤ 2 ^ m * m.factorial := by
|
| 118 |
+
intro m
|
| 119 |
+
induction m using Nat.strong_induction_on with
|
| 120 |
+
| h m ih =>
|
| 121 |
+
intro I hcard
|
| 122 |
+
by_cases hI : I = ⊥
|
| 123 |
+
· subst I
|
| 124 |
+
simp [coefficient, IncidenceAlgebra.mu_self, show (⊥ : Intersection E).val = ⊥ from rfl] at hcard ⊢
|
| 125 |
+
subst m
|
| 126 |
+
simp
|
| 127 |
+
· have hmu : coefficient E I = -∑ J ∈ Finset.Ico ⊥ I, coefficient E J := by
|
| 128 |
+
exact IncidenceAlgebra.mu_eq_neg_sum_Ico_of_ne (Ne.symm hI)
|
| 129 |
+
rw [hmu, Int.natAbs_neg]
|
| 130 |
+
calc
|
| 131 |
+
(∑ J ∈ Finset.Ico ⊥ I, coefficient E J).natAbs
|
| 132 |
+
≤ ∑ J ∈ Finset.Ico ⊥ I, (coefficient E J).natAbs := Int.natAbs_sum_le _ _
|
| 133 |
+
_ ≤ ∑ J ∈ Finset.Ico ⊥ I, 2 ^ J.val.support.card * J.val.support.card.factorial := by
|
| 134 |
+
apply Finset.sum_le_sum
|
| 135 |
+
intro J hJ
|
| 136 |
+
have hjlt : J.val.support.card < m := by
|
| 137 |
+
rw [← hcard]
|
| 138 |
+
exact Finset.card_lt_card (Cylinder.support_ssubset (Finset.mem_Ico.mp hJ).2)
|
| 139 |
+
exact ih _ hjlt J rfl
|
| 140 |
+
_ = ∑ S ∈ (Finset.Ico ⊥ I).image (fun J : Intersection E => J.val.support),
|
| 141 |
+
2 ^ S.card * S.card.factorial := by
|
| 142 |
+
symm
|
| 143 |
+
apply Finset.sum_image
|
| 144 |
+
intro J hJ K hK hJK
|
| 145 |
+
exact intersection_support_inj E I (Finset.mem_Ico.mp hJ).2.le
|
| 146 |
+
(Finset.mem_Ico.mp hK).2.le hJK
|
| 147 |
+
_ ≤ ∑ S ∈ I.val.support.powerset with S.card < I.val.support.card,
|
| 148 |
+
2 ^ S.card * S.card.factorial := by
|
| 149 |
+
apply Finset.sum_le_sum_of_subset_of_nonneg
|
| 150 |
+
· intro S hS
|
| 151 |
+
obtain ⟨J,hJ,rfl⟩ := Finset.mem_image.mp hS
|
| 152 |
+
have hlt := (Finset.mem_Ico.mp hJ).2
|
| 153 |
+
exact Finset.mem_filter.mpr ⟨Finset.mem_powerset.mpr (Cylinder.support_mono hlt.le),
|
| 154 |
+
Finset.card_lt_card (Cylinder.support_ssubset hlt)⟩
|
| 155 |
+
· intros; omega
|
| 156 |
+
_ ≤ 2 ^ I.val.support.card * I.val.support.card.factorial := proper_subset_factorial_sum _
|
| 157 |
+
_ = 2 ^ m * m.factorial := by rw [hcard]
|
| 158 |
+
exact aux _ I rfl
|
| 159 |
+
|
| 160 |
+
end OrdinaryCorrelations.SourceCylinder
|
| 161 |
+
|
| 162 |
+
end
|
| 163 |
+
|
| 164 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/UncutTreeEdges.lean
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.NumericalLine
|
| 2 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.NoFixedQualifyingPath
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
noncomputable section
|
| 7 |
+
open scoped BigOperators
|
| 8 |
+
open Finset
|
| 9 |
+
open Finset Classical
|
| 10 |
+
open Filter
|
| 11 |
+
open Finset Classical Filter
|
| 12 |
+
open scoped Topology
|
| 13 |
+
|
| 14 |
+
namespace OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 15 |
+
open OrdinaryCorrelations.SignedTrace Finset Classical
|
| 16 |
+
noncomputable section
|
| 17 |
+
variable {S : PrimeSystem} {B τ C₀ : ℝ} {D : S.DivisorFamily B τ C₀} {h ℓ L : ℕ}
|
| 18 |
+
|
| 19 |
+
def uncutTreeEdges (w : ClosedLine h ℓ) (a : S.FixedResidues w) : Finset (Fin ℓ) :=
|
| 20 |
+
w.treeSteps.filter (fun e => ∀ p : S.FixedIndex w, (p.val:ℕ) ∣ w.label e →
|
| 21 |
+
a p+(w.offset e.castSucc : ZMod (p.val:ℕ))=0)
|
| 22 |
+
|
| 23 |
+
structure TreePath (w : NumericalLine D h ℓ) (L : ℕ) where
|
| 24 |
+
length : ℕ
|
| 25 |
+
length_pos : 0 < length
|
| 26 |
+
length_le : length ≤ L
|
| 27 |
+
vertex : Fin (length+1) → ℤ
|
| 28 |
+
distinct : Function.Injective vertex
|
| 29 |
+
vertex_mem : ∀ i, ∃ j, vertex i=w.line.offset j
|
| 30 |
+
edge : Fin length → Fin ℓ
|
| 31 |
+
tree : ∀ i, edge i ∈ w.line.treeSteps
|
| 32 |
+
forward : Fin length → Bool
|
| 33 |
+
endpoints : ∀ i, if forward i then
|
| 34 |
+
vertex i.castSucc=w.line.offset (edge i).castSucc ∧ vertex i.succ=w.line.offset (edge i).succ
|
| 35 |
+
else vertex i.castSucc=w.line.offset (edge i).succ ∧ vertex i.succ=w.line.offset (edge i).castSucc
|
| 36 |
+
|
| 37 |
+
namespace TreePath
|
| 38 |
+
variable {w : NumericalLine D h ℓ}
|
| 39 |
+
|
| 40 |
+
def pathSign (P : TreePath w L) (i : Fin P.length) : ℤ :=
|
| 41 |
+
if P.forward i then w.line.sign (P.edge i) else -w.line.sign (P.edge i)
|
| 42 |
+
|
| 43 |
+
lemma pathSign_mem (P : TreePath w L) (i : Fin P.length) :
|
| 44 |
+
P.pathSign i = -1 ∨ P.pathSign i = 1 := by
|
| 45 |
+
rcases w.line.sign_mem (P.edge i) with hs | hs <;>
|
| 46 |
+
cases hf : P.forward i <;> simp [pathSign,hf,hs]
|
| 47 |
+
|
| 48 |
+
lemma path_step (P : TreePath w L) (i : Fin P.length) :
|
| 49 |
+
P.vertex i.succ-P.vertex i.castSucc = P.pathSign i*h*w.line.label (P.edge i) := by
|
| 50 |
+
have he := P.endpoints i
|
| 51 |
+
have hs := w.line.step (P.edge i)
|
| 52 |
+
cases hf : P.forward i <;> simp only [hf,Bool.false_eq_true,ite_false,ite_true] at he
|
| 53 |
+
· rw [he.1,he.2]
|
| 54 |
+
simp only [pathSign,hf,Bool.false_eq_true,ite_false]
|
| 55 |
+
linear_combination -hs
|
| 56 |
+
· rw [he.1,he.2]
|
| 57 |
+
simpa only [pathSign,hf,ite_true] using hs
|
| 58 |
+
|
| 59 |
+
lemma vertex_residue_eq (P : TreePath w L) (p : S.Index) (i : Fin P.length)
|
| 60 |
+
(hd : (p:ℕ) ∣ w.line.label (P.edge i)) :
|
| 61 |
+
(P.vertex i.succ : ZMod (p:ℕ))=(P.vertex i.castSucc : ZMod (p:ℕ)) := by
|
| 62 |
+
have he := P.endpoints i
|
| 63 |
+
have hs := w.line.label_residue_eq (P.edge i) hd
|
| 64 |
+
cases hf : P.forward i <;> simp only [hf,Bool.false_eq_true,ite_false,ite_true] at he
|
| 65 |
+
· rw [he.1,he.2]; exact hs.symm
|
| 66 |
+
· rw [he.1,he.2]; exact hs
|
| 67 |
+
|
| 68 |
+
lemma departure_lit (P : TreePath w L) (a : S.FixedResidues w.line)
|
| 69 |
+
(hu : ∀ i, P.edge i ∈ uncutTreeEdges w.line a) (p : S.FixedIndex w.line)
|
| 70 |
+
(i : Fin P.length) (hd : (p.val:ℕ) ∣ w.line.label (P.edge i)) :
|
| 71 |
+
a p+(P.vertex i.castSucc : ZMod (p.val:ℕ))=0 := by
|
| 72 |
+
have hl := (mem_filter.mp (hu i)).2 p hd
|
| 73 |
+
have he := P.endpoints i
|
| 74 |
+
cases hf : P.forward i <;> simp only [hf,Bool.false_eq_true,ite_false,ite_true] at he
|
| 75 |
+
· rw [he.1,w.line.label_residue_eq (P.edge i) hd]; exact hl
|
| 76 |
+
· rw [he.1]; exact hl
|
| 77 |
+
|
| 78 |
+
def IsGap (P : TreePath w L) (a : S.FixedResidues w.line) (p : S.FixedIndex w.line) : Prop :=
|
| 79 |
+
1<P.length ∧ a p+(P.vertex 0 : ZMod (p.val:ℕ))=0 ∧
|
| 80 |
+
a p+(P.vertex (Fin.last P.length) : ZMod (p.val:ℕ))=0 ∧
|
| 81 |
+
∀ j : Fin (P.length+1), 0<j.val → j.val<P.length →
|
| 82 |
+
a p+(P.vertex j : ZMod (p.val:ℕ))≠0
|
| 83 |
+
|
| 84 |
+
lemma gap_prime_free (P : TreePath w L) (a : S.FixedResidues w.line)
|
| 85 |
+
(hu : ∀ i, P.edge i ∈ uncutTreeEdges w.line a) (p : S.FixedIndex w.line)
|
| 86 |
+
(hg : P.IsGap a p) : ∀ i, ¬(p.val:ℕ) ∣ w.line.label (P.edge i) := by
|
| 87 |
+
intro i hi
|
| 88 |
+
have hlen := hg.1
|
| 89 |
+
have hd := P.departure_lit a hu p i hi
|
| 90 |
+
by_cases hz : i.val=0
|
| 91 |
+
· have ha : a p+(P.vertex i.succ : ZMod (p.val:ℕ))=0 := by
|
| 92 |
+
rwa [P.vertex_residue_eq p.val i hi]
|
| 93 |
+
exact hg.2.2.2 i.succ (by simp) (by simp; omega) ha
|
| 94 |
+
· exact hg.2.2.2 i.castSucc (by dsimp; omega) (by exact i.isLt) hd
|
| 95 |
+
|
| 96 |
+
lemma gap_div_displacement (P : TreePath w L) (a : S.FixedResidues w.line)
|
| 97 |
+
(p : S.FixedIndex w.line) (hg : P.IsGap a p) :
|
| 98 |
+
((p.val:ℕ):ℤ) ∣ P.vertex (Fin.last P.length)-P.vertex 0 := by
|
| 99 |
+
apply (ZMod.intCast_zmod_eq_zero_iff_dvd _ p.val).mp
|
| 100 |
+
rw [Int.cast_sub]
|
| 101 |
+
exact sub_eq_zero.mpr (add_left_cancel (hg.2.2.1.trans hg.2.1.symm))
|
| 102 |
+
|
| 103 |
+
def specification (P : TreePath w L) (p : S.Index)
|
| 104 |
+
(hfree : ∀ i, ¬(p:ℕ) ∣ w.line.label (P.edge i))
|
| 105 |
+
(hd : ((p:ℕ):ℤ) ∣ P.vertex (Fin.last P.length)-P.vertex 0) :
|
| 106 |
+
S.Specification D h L where
|
| 107 |
+
length := P.length
|
| 108 |
+
length_pos := P.length_pos
|
| 109 |
+
length_le := P.length_le
|
| 110 |
+
offset j := P.vertex j-P.vertex 0
|
| 111 |
+
offset_zero := sub_self _
|
| 112 |
+
offsets_distinct := by
|
| 113 |
+
intro i j he
|
| 114 |
+
apply P.distinct
|
| 115 |
+
linarith
|
| 116 |
+
label i := w.line.label (P.edge i)
|
| 117 |
+
label_mem i := w.labels (P.edge i)
|
| 118 |
+
sign := P.pathSign
|
| 119 |
+
sign_mem := P.pathSign_mem
|
| 120 |
+
step i := by simpa only [sub_sub_sub_cancel_right] using P.path_step i
|
| 121 |
+
extra := p
|
| 122 |
+
extra_not_div := hfree
|
| 123 |
+
suffix := ⟨0,P.length_pos⟩
|
| 124 |
+
extra_div_suffix := by simpa using hd
|
| 125 |
+
|
| 126 |
+
theorem gap_has_nonfixed (P : TreePath w L) (a : S.FixedResidues w.line)
|
| 127 |
+
(hu : ∀ i, P.edge i ∈ uncutTreeEdges w.line a) (hf : NoFixedForbidden w.line D L a)
|
| 128 |
+
(p : S.FixedIndex w.line) (hg : P.IsGap a p) :
|
| 129 |
+
∃ (i : Fin P.length) (q : S.Index), (q:ℕ) ∣ w.line.label (P.edge i) ∧ ¬S.IsFixed w.line q := by
|
| 130 |
+
by_contra hn
|
| 131 |
+
have ha : ∀ (i : Fin P.length) (q : S.Index), (q:ℕ) ∣ w.line.label (P.edge i) → S.IsFixed w.line q := by
|
| 132 |
+
intro i q hq
|
| 133 |
+
by_contra hnf
|
| 134 |
+
exact hn ⟨i,q,hq,hnf⟩
|
| 135 |
+
let s := P.specification p.val (P.gap_prime_free a hu p hg) (P.gap_div_displacement a p hg)
|
| 136 |
+
apply no_fixed_qualifying_path w.line a hf s (P.vertex 0)
|
| 137 |
+
· intro j
|
| 138 |
+
simpa only [s,specification,add_sub_cancel] using P.vertex_mem j
|
| 139 |
+
· intro q hq
|
| 140 |
+
rcases mem_insert.mp hq with he | he
|
| 141 |
+
· have he' : q=p.val := Subtype.ext he
|
| 142 |
+
exact he' ▸ p.property
|
| 143 |
+
· obtain ⟨i,_,hqi⟩ := mem_biUnion.mp he
|
| 144 |
+
exact ha i q (Nat.mem_primeFactors.mp hqi).2.1
|
| 145 |
+
· intro q
|
| 146 |
+
constructor
|
| 147 |
+
· intro hqp
|
| 148 |
+
have he : q=p := Subtype.ext (Subtype.ext hqp)
|
| 149 |
+
subst q
|
| 150 |
+
exact hg.2.1
|
| 151 |
+
· intro i hqi
|
| 152 |
+
have hl := P.departure_lit a hu q i hqi
|
| 153 |
+
change a q+((P.vertex 0+(P.vertex i.castSucc-P.vertex 0):ℤ):ZMod (q.val:ℕ))=0
|
| 154 |
+
rw [show P.vertex 0+(P.vertex i.castSucc-P.vertex 0)=P.vertex i.castSucc by ring]
|
| 155 |
+
exact hl
|
| 156 |
+
|
| 157 |
+
end TreePath
|
| 158 |
+
end
|
| 159 |
+
end OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 160 |
+
|
| 161 |
+
end
|
| 162 |
+
|
| 163 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/UnlitPolynomialBound.lean
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.SourceWitnessBasicScales
|
| 2 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.RepeatedUnlitTotalEqFixed
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
noncomputable section
|
| 7 |
+
open scoped BigOperators
|
| 8 |
+
open Finset
|
| 9 |
+
open Finset Classical
|
| 10 |
+
open Filter
|
| 11 |
+
open Finset Classical Filter
|
| 12 |
+
open scoped Topology
|
| 13 |
+
|
| 14 |
+
namespace OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 15 |
+
open OrdinaryCorrelations.SignedTrace OrdinaryCorrelations.FiniteIntegration OrdinaryCorrelations.NumericalSubtrees
|
| 16 |
+
open Finset Classical Filter
|
| 17 |
+
namespace NumericalLine
|
| 18 |
+
|
| 19 |
+
lemma unlit_polynomial_bound (S : PrimeSystem) (M ℓ L J t : ℕ) :
|
| 20 |
+
unlitPrefactor S ℓ J ≤ witnessEntropyBase S M ℓ L J t ^ witnessEntropyDegree M ℓ L J t := by
|
| 21 |
+
let Q := witnessEntropyBase S M ℓ L J t
|
| 22 |
+
let N := ℓ*J
|
| 23 |
+
let H : ℝ := max 1 (∑ p ∈ S.primes,(p:ℝ)⁻¹)
|
| 24 |
+
have hH : 1 ≤ H := le_max_left _ _
|
| 25 |
+
have hA := A_pos
|
| 26 |
+
have hM := Nat.cast_nonneg (α:=ℝ) M
|
| 27 |
+
have hℓ := Nat.cast_nonneg (α:=ℝ) ℓ
|
| 28 |
+
have hL := Nat.cast_nonneg (α:=ℝ) L
|
| 29 |
+
have ht := Nat.cast_nonneg (α:=ℝ) t
|
| 30 |
+
have hN : N ≤ witnessSlotCount ℓ L J t := by
|
| 31 |
+
simp only [N,witnessSlotCount,WitnessConfiguration.codeSlot_card]
|
| 32 |
+
omega
|
| 33 |
+
have hNcast : (N:ℝ) ≤ (witnessSlotCount ℓ L J t:ℝ) := by exact_mod_cast hN
|
| 34 |
+
have hN0 : (0:ℝ) ≤ N := by positivity
|
| 35 |
+
have hslot := Nat.cast_nonneg (α:=ℝ) (witnessSlotCount ℓ L J t)
|
| 36 |
+
have hQ : 2 ≤ Q := by dsimp [Q,witnessEntropyBase]; dsimp only [H] at *; linarith
|
| 37 |
+
have hQA : A ≤ Q := by dsimp [Q,witnessEntropyBase]; dsimp only [H] at *; linarith
|
| 38 |
+
have hQℓ : (ℓ:ℝ)+2 ≤ Q := by dsimp [Q,witnessEntropyBase]; dsimp only [H] at *; linarith
|
| 39 |
+
have hQN : (N:ℝ)+1 ≤ Q := by dsimp [Q,witnessEntropyBase]; dsimp only [H] at *; linarith
|
| 40 |
+
have hQH : H ≤ Q := by dsimp [Q,witnessEntropyBase]; dsimp only [H] at *; linarith
|
| 41 |
+
have hQ0 : 0 ≤ Q := by linarith
|
| 42 |
+
have hHid : max 1 (∑ p : S.Index,(p:ℝ)⁻¹)=H := by
|
| 43 |
+
exact congrArg (max (1:ℝ)) (sum_coe_sort S.primes (fun p : ℕ => (p:ℝ)⁻¹))
|
| 44 |
+
unfold unlitPrefactor lineMassBound
|
| 45 |
+
rw [hHid,←Nat.cast_mul]
|
| 46 |
+
change A^N*((ℓ:ℝ)+2)^N*(2^ℓ*((N:ℝ)+1)*((N:ℝ)+1)^N*H^N) ≤ _
|
| 47 |
+
calc
|
| 48 |
+
_ ≤ Q^N*Q^N*(Q^ℓ*Q*Q^N*Q^N) := by gcongr
|
| 49 |
+
_ = Q^(4*N+ℓ+1) := by simp only [pow_add,pow_mul,pow_one]; ring
|
| 50 |
+
_ ≤ _ := pow_le_pow_right₀ (by linarith)
|
| 51 |
+
(by unfold witnessEntropyDegree; omega)
|
| 52 |
+
|
| 53 |
+
lemma source_unlit_prefactor_small (C₀ : ℝ) (hC₀ : 0 ≤ C₀) :
|
| 54 |
+
∀ᶠ B : ℝ in atTop,
|
| 55 |
+
unlitPrefactor (sourceSystem B) (sourceLength B) ⌈C₀*Real.log B⌉₊ ≤
|
| 56 |
+
Real.exp (B^(1+epsilon/2)) := by
|
| 57 |
+
have hlim := (isLittleO_log_rpow_atTop (by norm_num [epsilon] : 0 < epsilon/4)).tendsto_div_nhds_zero
|
| 58 |
+
filter_upwards [source_witness_entropy_scales C₀ hC₀,
|
| 59 |
+
hlim.eventually (eventually_le_nhds (by norm_num : (0:ℝ)<1/2)),
|
| 60 |
+
eventually_ge_atTop (1:ℝ)] with B hs hlog hB
|
| 61 |
+
have hB0 : 0 < B := zero_lt_one.trans_le hB
|
| 62 |
+
have hbase0 : 0 ≤ witnessEntropyBase (sourceSystem B) (sourceListSlotBudget C₀ B)
|
| 63 |
+
(sourceLength B) (pathLength B) ⌈C₀*Real.log B⌉₊ (listCutoff B) := by
|
| 64 |
+
unfold witnessEntropyBase
|
| 65 |
+
have := A_pos
|
| 66 |
+
positivity
|
| 67 |
+
apply (unlit_polynomial_bound (sourceSystem B) (sourceListSlotBudget C₀ B)
|
| 68 |
+
(sourceLength B) (pathLength B) ⌈C₀*Real.log B⌉₊ (listCutoff B)).trans
|
| 69 |
+
apply (pow_le_pow_left₀ hbase0 hs.2 _).trans
|
| 70 |
+
rw [←Real.rpow_natCast,Real.rpow_def_of_pos (sq_pos_of_pos hB0),Real.log_pow]
|
| 71 |
+
apply Real.exp_le_exp.mpr
|
| 72 |
+
have hlog0 := Real.log_nonneg hB
|
| 73 |
+
have hl := (div_le_iff₀ (Real.rpow_pos_of_pos hB0 (epsilon/4))).mp hlog
|
| 74 |
+
have hd := mul_le_mul hs.1 hl hlog0 (Real.rpow_nonneg hB0.le _)
|
| 75 |
+
have hid : B^(1+epsilon/4)*((1/2)*B^(epsilon/4)) = (1/2)*B^(1+epsilon/2) := by
|
| 76 |
+
rw [mul_left_comm,←Real.rpow_add hB0]
|
| 77 |
+
congr 2
|
| 78 |
+
ring
|
| 79 |
+
rw [hid] at hd
|
| 80 |
+
norm_num only [Nat.cast_ofNat] at *
|
| 81 |
+
nlinarith
|
| 82 |
+
|
| 83 |
+
theorem source_unlit_tail_small (h : ℕ) (τ T C₀ : ℝ) (hC₀ : 0 ≤ C₀) :
|
| 84 |
+
∀ᶠ B : ℝ in atTop, ∀ (D : (sourceSystem B).DivisorFamily B τ C₀)
|
| 85 |
+
(cut : (sourceSystem B).Cutoffs T),
|
| 86 |
+
unlitTailSum D h (sourceLength B) (pathLength B) cut (listCutoff B) ≤
|
| 87 |
+
Real.exp (-B^(1+epsilon/2)) := by
|
| 88 |
+
filter_upwards [source_unlit_prefactor_small C₀ hC₀,
|
| 89 |
+
eventually_const_mul_rpow_le (1+epsilon/2) (1+3*epsilon) 4 (by norm_num [epsilon]),
|
| 90 |
+
eventually_ge_atTop (1:ℝ)] with B hpref hdom hB
|
| 91 |
+
intro D cut
|
| 92 |
+
have hB0 : 0 < B := zero_lt_one.trans_le hB
|
| 93 |
+
let z := Real.exp ((1/2)*B^(1-epsilon))
|
| 94 |
+
have hz : 1 ≤ z := Real.one_le_exp (by positivity)
|
| 95 |
+
have hzp : ∀ p : (sourceSystem B).Index, z^2 ≤ (p:ℝ) := by
|
| 96 |
+
intro p
|
| 97 |
+
have he : z^2=sourceMinPrime B := by
|
| 98 |
+
dsimp [z,sourceMinPrime]
|
| 99 |
+
rw [←Real.exp_nat_mul]
|
| 100 |
+
congr 1
|
| 101 |
+
ring
|
| 102 |
+
rw [he]
|
| 103 |
+
exact (source_prime_lower B hB p).le
|
| 104 |
+
have hh := unlit_tail_sum_bound (h:=h) (ℓ:=sourceLength B) (L:=pathLength B) D cut z hz hzp (listCutoff B)
|
| 105 |
+
have hzt : 0 < z^(listCutoff B) := pow_pos (Real.exp_pos _) _
|
| 106 |
+
have ht : B^(4*epsilon) ≤ (listCutoff B:ℝ) := Nat.le_ceil _
|
| 107 |
+
have hs : (1/2)*B^(1+3*epsilon) ≤ (listCutoff B:ℝ)*((1/2)*B^(1-epsilon)) := by
|
| 108 |
+
have hm := mul_le_mul_of_nonneg_right ht (show 0 ≤ (1/2)*B^(1-epsilon) by positivity)
|
| 109 |
+
have he : B^(4*epsilon)*((1/2)*B^(1-epsilon))=(1/2)*B^(1+3*epsilon) := by
|
| 110 |
+
rw [mul_left_comm,←Real.rpow_add hB0]
|
| 111 |
+
congr 2
|
| 112 |
+
ring
|
| 113 |
+
rwa [he] at hm
|
| 114 |
+
apply (le_div_iff₀ hzt).mpr (hh.trans hpref) |>.trans
|
| 115 |
+
change Real.exp (B^(1+epsilon/2))/(Real.exp ((1/2)*B^(1-epsilon)))^(listCutoff B) ≤ _
|
| 116 |
+
rw [←Real.exp_nat_mul,←Real.exp_sub]
|
| 117 |
+
apply Real.exp_le_exp.mpr
|
| 118 |
+
nlinarith
|
| 119 |
+
|
| 120 |
+
end NumericalLine
|
| 121 |
+
end OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 122 |
+
|
| 123 |
+
end
|
| 124 |
+
|
| 125 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/Unselected.lean
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
noncomputable section
|
| 6 |
+
open scoped BigOperators
|
| 7 |
+
open Finset
|
| 8 |
+
open Finset Classical
|
| 9 |
+
open Filter
|
| 10 |
+
open Finset Classical Filter
|
| 11 |
+
|
| 12 |
+
namespace OrdinaryCorrelations.PivotSummation
|
| 13 |
+
open Finset Classical
|
| 14 |
+
variable {σ P : Type*} {n : ℕ}
|
| 15 |
+
|
| 16 |
+
abbrev Unselected (sel : Fin n → σ) := {s : σ // s ∉ Set.range sel}
|
| 17 |
+
|
| 18 |
+
def splitSlots (sel : Fin n → σ) (hinj : Function.Injective sel) :
|
| 19 |
+
(σ → P) ≃ (Fin n → P) × (Unselected sel → P) :=
|
| 20 |
+
(Equiv.piEquivPiSubtypeProd (fun s => s ∈ Set.range sel) (fun _ => P)).trans
|
| 21 |
+
(Equiv.prodCongr (Equiv.arrowCongr (Equiv.ofInjective sel hinj).symm (Equiv.refl P)) (Equiv.refl _))
|
| 22 |
+
|
| 23 |
+
lemma splitSlots_first (sel : Fin n → σ) (hinj : Function.Injective sel) (x : σ → P) (i : Fin n) :
|
| 24 |
+
(splitSlots sel hinj x).1 i = x (sel i) := rfl
|
| 25 |
+
|
| 26 |
+
lemma splitSlots_second (sel : Fin n → σ) (hinj : Function.Injective sel) (x : σ → P) (s : Unselected sel) :
|
| 27 |
+
(splitSlots sel hinj x).2 s = x s.val := rfl
|
| 28 |
+
|
| 29 |
+
def mergeSlots (sel : Fin n → σ) (hinj : Function.Injective sel)
|
| 30 |
+
(y : Fin n → P) (z : Unselected sel → P) : σ → P := (splitSlots sel hinj).symm (y,z)
|
| 31 |
+
|
| 32 |
+
lemma mergeSlots_selected (sel : Fin n → σ) (hinj : Function.Injective sel)
|
| 33 |
+
(y : Fin n → P) (z : Unselected sel → P) (i : Fin n) :
|
| 34 |
+
mergeSlots sel hinj y z (sel i)=y i := by
|
| 35 |
+
have he := congrArg (fun x : (Fin n → P) × (Unselected sel → P) => x.1 i)
|
| 36 |
+
((splitSlots sel hinj).apply_symm_apply (y,z))
|
| 37 |
+
exact he
|
| 38 |
+
|
| 39 |
+
lemma mergeSlots_unselected (sel : Fin n → σ) (hinj : Function.Injective sel)
|
| 40 |
+
(y : Fin n → P) (z : Unselected sel → P) (s : Unselected sel) :
|
| 41 |
+
mergeSlots sel hinj y z s.val=z s := by
|
| 42 |
+
have he := congrArg (fun x : (Fin n → P) × (Unselected sel → P) => x.2 s)
|
| 43 |
+
((splitSlots sel hinj).apply_symm_apply (y,z))
|
| 44 |
+
exact he
|
| 45 |
+
|
| 46 |
+
variable [Fintype σ] [Fintype P]
|
| 47 |
+
|
| 48 |
+
lemma prod_slots (sel : Fin n → σ) (hinj : Function.Injective sel) (f : σ → ℝ) :
|
| 49 |
+
(∏ s, f s) = (∏ i, f (sel i)) * ∏ s : Unselected sel, f s.val := by
|
| 50 |
+
rw [← Fintype.prod_subtype_mul_prod_subtype (fun s => s ∈ Set.range sel) f]
|
| 51 |
+
congr 1
|
| 52 |
+
convert (Equiv.prod_comp (Equiv.ofInjective sel hinj) (fun s => f s.val)).symm using 1
|
| 53 |
+
· congr 1
|
| 54 |
+
ext x
|
| 55 |
+
simp
|
| 56 |
+
· rfl
|
| 57 |
+
|
| 58 |
+
lemma sum_slots (sel : Fin n → σ) (hinj : Function.Injective sel) (F : (σ → P) → ℝ) :
|
| 59 |
+
(∑ x, F x) = ∑ z : Unselected sel → P, ∑ y : Fin n → P, F (mergeSlots sel hinj y z) := by
|
| 60 |
+
rw [← Equiv.sum_comp (splitSlots sel hinj).symm F,Fintype.sum_prod_type,sum_comm]
|
| 61 |
+
rfl
|
| 62 |
+
|
| 63 |
+
theorem slots_weighted_bound (sel : Fin n → σ) (hinj : Function.Injective sel)
|
| 64 |
+
(W : σ → P → ℝ) (hW : ∀ s p, 0 ≤ W s p) (A : (σ → P) → ℝ)
|
| 65 |
+
(K : ℝ) (hinner : ∀ z : Unselected sel → P,
|
| 66 |
+
(∑ y : Fin n → P, A (mergeSlots sel hinj y z) * ∏ i, W (sel i) (y i)) ≤ K) :
|
| 67 |
+
(∑ x : σ → P, A x * ∏ s, W s (x s)) ≤
|
| 68 |
+
K * ∏ s : Unselected sel, ∑ p : P, W s.val p := by
|
| 69 |
+
rw [sum_slots sel hinj]
|
| 70 |
+
have he : ∀ z : Unselected sel → P,
|
| 71 |
+
(∑ y : Fin n → P, A (mergeSlots sel hinj y z) * ∏ s, W s (mergeSlots sel hinj y z s)) =
|
| 72 |
+
(∑ y : Fin n → P, A (mergeSlots sel hinj y z) * ∏ i, W (sel i) (y i)) *
|
| 73 |
+
∏ s : Unselected sel, W s.val (z s) := by
|
| 74 |
+
intro z
|
| 75 |
+
rw [sum_mul]
|
| 76 |
+
apply sum_congr rfl
|
| 77 |
+
intro y hy
|
| 78 |
+
rw [prod_slots sel hinj]
|
| 79 |
+
simp only [mergeSlots_selected,mergeSlots_unselected,mul_assoc]
|
| 80 |
+
simp_rw [he]
|
| 81 |
+
calc
|
| 82 |
+
_ ≤ ∑ z : Unselected sel → P, K * ∏ s : Unselected sel, W s.val (z s) := by
|
| 83 |
+
apply sum_le_sum
|
| 84 |
+
intro z hz
|
| 85 |
+
exact mul_le_mul_of_nonneg_right (hinner z) (prod_nonneg (fun s _ => hW _ _))
|
| 86 |
+
_ = _ := by rw [← mul_sum,← Fintype.prod_sum (fun s : Unselected sel => W s.val)]
|
| 87 |
+
|
| 88 |
+
end OrdinaryCorrelations.PivotSummation
|
| 89 |
+
|
| 90 |
+
end
|
| 91 |
+
|
| 92 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/UnselectedCard.lean
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.CoordinateEquiv
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
noncomputable section
|
| 6 |
+
open scoped BigOperators
|
| 7 |
+
open Finset
|
| 8 |
+
open Finset Classical
|
| 9 |
+
open Filter
|
| 10 |
+
open Finset Classical Filter
|
| 11 |
+
open scoped Topology
|
| 12 |
+
|
| 13 |
+
namespace OrdinaryCorrelations.ArithmeticSaving
|
| 14 |
+
open Finset Classical
|
| 15 |
+
lemma unselected_card {ι : Type*} [Fintype ι] [DecidableEq ι] {k : ℕ} (e : Fin k ↪ ι) :
|
| 16 |
+
Fintype.card (Unselected e) = Fintype.card ι-k := by
|
| 17 |
+
have he := Fintype.card_congr (coordinateEquiv e)
|
| 18 |
+
simp only [Fintype.card_sum,Fintype.card_fin] at he
|
| 19 |
+
omega
|
| 20 |
+
end OrdinaryCorrelations.ArithmeticSaving
|
| 21 |
+
|
| 22 |
+
end
|
| 23 |
+
|
| 24 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/UntaggedEdgeCode.lean
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.ModifiedWeightSameBand
|
| 2 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.TopologyTreeSteps
|
| 3 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.VertexIndex
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
open scoped BigOperators
|
| 9 |
+
open Finset
|
| 10 |
+
open Finset Classical
|
| 11 |
+
open Filter
|
| 12 |
+
open Finset Classical Filter
|
| 13 |
+
|
| 14 |
+
namespace OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 15 |
+
open OrdinaryCorrelations.SignedTrace OrdinaryCorrelations.NumericalSubtrees
|
| 16 |
+
open Finset Classical
|
| 17 |
+
variable {S : PrimeSystem} {B τ C₀ : ℝ} {D : S.DivisorFamily B τ C₀} {h ℓ L : ℕ}
|
| 18 |
+
|
| 19 |
+
def untaggedEdgeCode (w : ClosedLine h ℓ) (hh : 0 < h)
|
| 20 |
+
(𝔏 : List (AttachedSpec w D L)) (a : S.FixedResidues w) (p : S.Index) :
|
| 21 |
+
Option (Bool × Finset (Fin ℓ)) :=
|
| 22 |
+
(untaggedType w hh 𝔏 a p).map (fun t => (t.1,t.2.edges.val))
|
| 23 |
+
|
| 24 |
+
lemma tokens_eq_of_codes (w v : ClosedLine h ℓ) (hh : 0 < h)
|
| 25 |
+
(𝔏 : List (AttachedSpec w D L)) (𝔐 : List (AttachedSpec v D L))
|
| 26 |
+
(a : S.FixedResidues w) (b : S.FixedResidues v) (p : S.Index)
|
| 27 |
+
(hT : taggedTokens w hh 𝔏 (recordAt w hh 𝔏 a) p = taggedTokens v hh 𝔐 (recordAt v hh 𝔐 b) p)
|
| 28 |
+
(hU : untaggedEdgeCode w hh 𝔏 a p = untaggedEdgeCode v hh 𝔐 b p) :
|
| 29 |
+
recordTokens w hh 𝔏 (recordAt w hh 𝔏 a) p = recordTokens v hh 𝔐 (recordAt v hh 𝔐 b) p := by
|
| 30 |
+
rcases he : untaggedType w hh 𝔏 a p with _ | t <;>
|
| 31 |
+
rcases hf : untaggedType v hh 𝔐 b p with _ | u
|
| 32 |
+
· rw [← taggedTokens_of_none w hh 𝔏 a p he,← taggedTokens_of_none v hh 𝔐 b p hf]
|
| 33 |
+
exact hT
|
| 34 |
+
· simp only [untaggedEdgeCode,he,hf,Option.map_none,Option.map_some] at hU
|
| 35 |
+
contradiction
|
| 36 |
+
· simp only [untaggedEdgeCode,he,hf,Option.map_none,Option.map_some] at hU
|
| 37 |
+
contradiction
|
| 38 |
+
· simp only [untaggedEdgeCode,he,hf,Option.map_some] at hU
|
| 39 |
+
have hE : t.2.edges.val = u.2.edges.val := congrArg Prod.snd (Option.some.inj hU)
|
| 40 |
+
rw [(untaggedType_some w hh 𝔏 a p t he).2,(untaggedType_some v hh 𝔐 b p u hf).2,hE]
|
| 41 |
+
|
| 42 |
+
theorem line_eq_of_record_codes (w v : ClosedLine h ℓ) (hh : 0 < h)
|
| 43 |
+
(hw : ∀ i, w.label i ∈ D.members) (hv : ∀ i, v.label i ∈ D.members)
|
| 44 |
+
(r : ℕ) (hwr : (returnSteps w).card=r) (hvr : (returnSteps v).card=r)
|
| 45 |
+
(ht : encodeTopology w r hwr=encodeTopology v r hvr)
|
| 46 |
+
(𝔏 : List (AttachedSpec w D L)) (𝔐 : List (AttachedSpec v D L))
|
| 47 |
+
(a : S.FixedResidues w) (b : S.FixedResidues v)
|
| 48 |
+
(hT : ∀ p, taggedTokens w hh 𝔏 (recordAt w hh 𝔏 a) p = taggedTokens v hh 𝔐 (recordAt v hh 𝔐 b) p)
|
| 49 |
+
(hU : untaggedEdgeCode w hh 𝔏 a = untaggedEdgeCode v hh 𝔐 b) : w=v := by
|
| 50 |
+
apply topology_tree_labels_injective w v hh r hwr hvr ht
|
| 51 |
+
intro e he
|
| 52 |
+
have hev : e ∈ v.treeSteps := topology_treeSteps hwr hvr ht ▸ he
|
| 53 |
+
rw [← recordTokens_recover_label w hh 𝔏 a hw e he,
|
| 54 |
+
← recordTokens_recover_label v hh 𝔐 b hv e hev]
|
| 55 |
+
apply Finset.prod_congr rfl
|
| 56 |
+
intro p hp
|
| 57 |
+
rw [tokens_eq_of_codes w v hh 𝔏 𝔐 a b p (hT p) (congrFun hU p)]
|
| 58 |
+
|
| 59 |
+
def untaggedReference {w v : ClosedLine h ℓ} (H : SameGeometry v w) (hh : 0 < h)
|
| 60 |
+
(𝔏 : List (AttachedSpec v D L)) (a : S.FixedResidues v) : S.Index → Option (TokenType w) :=
|
| 61 |
+
fun p => (untaggedType v hh 𝔏 a p).map (fun t => (t.1,H.shapeMap t.2))
|
| 62 |
+
|
| 63 |
+
lemma untaggedReference_edges {w v : ClosedLine h ℓ} (H : SameGeometry v w) (hh : 0 < h)
|
| 64 |
+
(𝔏 : List (AttachedSpec v D L)) (a : S.FixedResidues v) (p : S.Index) :
|
| 65 |
+
(untaggedReference H hh 𝔏 a p).map (fun t => (t.1,t.2.edges.val)) =
|
| 66 |
+
untaggedEdgeCode v hh 𝔏 a p := by
|
| 67 |
+
simp only [untaggedReference,untaggedEdgeCode,Option.map_map]
|
| 68 |
+
rfl
|
| 69 |
+
|
| 70 |
+
lemma tokenWeight_reference {w v : ClosedLine h ℓ} (H : SameGeometry v w)
|
| 71 |
+
(pC pZ : S.Index) (t : TokenType v) :
|
| 72 |
+
tokenWeight v pC pZ t = tokenWeight w pC pZ (t.1,H.shapeMap t.2) := by
|
| 73 |
+
unfold tokenWeight
|
| 74 |
+
exact H.modifiedWeight _ _
|
| 75 |
+
|
| 76 |
+
lemma untaggedReference_injective {w v : ClosedLine h ℓ} (H : SameGeometry v w) :
|
| 77 |
+
Function.Injective (fun t : TokenType v => (t.1,H.shapeMap t.2)) := by
|
| 78 |
+
intro t u he
|
| 79 |
+
apply Prod.ext
|
| 80 |
+
· exact congrArg (fun z : TokenType w => z.1) he
|
| 81 |
+
· exact H.shapeEquiv.injective (congrArg Prod.snd he)
|
| 82 |
+
|
| 83 |
+
end OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 84 |
+
|
| 85 |
+
end
|
| 86 |
+
|
| 87 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/UntaggedReferenceWeight.lean
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.SlotWeight
|
| 2 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.RecordPacket
|
| 3 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.ExceptionalCodeSlot
|
| 4 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.FlatCode
|
| 5 |
+
|
| 6 |
+
namespace OAI
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
open scoped BigOperators
|
| 10 |
+
open Finset
|
| 11 |
+
open Finset Classical
|
| 12 |
+
open Filter
|
| 13 |
+
open Finset Classical Filter
|
| 14 |
+
|
| 15 |
+
namespace OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 16 |
+
open OrdinaryCorrelations.SignedTrace OrdinaryCorrelations.NumericalSubtrees
|
| 17 |
+
open OrdinaryCorrelations.TaggedPrimeGroups
|
| 18 |
+
open Finset Classical
|
| 19 |
+
variable {S : PrimeSystem} {B τ C₀ : ℝ} {D : S.DivisorFamily B τ C₀} {h ℓ L : ℕ}
|
| 20 |
+
|
| 21 |
+
lemma untagged_reference_weight {v w : ClosedLine h ℓ} (H : SameGeometry v w)
|
| 22 |
+
(hh : 0 < h) (𝔏 : List (AttachedSpec v D L)) (a : S.FixedResidues v)
|
| 23 |
+
(pC pZ : S.Index) (_hpC : S.IsCore pC) (_hpZ : ¬S.IsCore pZ) :
|
| 24 |
+
(∏ p : S.Index, TypeFibers.factor (untaggedReference H hh 𝔏 a)
|
| 25 |
+
(fun t p => tokenWeight w pC pZ t * slotWeight S (t.1=true) p) p) =
|
| 26 |
+
FactorialAssignments.unorderedWeight (TypeFibers.multiplicity (untaggedType v hh 𝔏 a))
|
| 27 |
+
(fun t (p : S.Index) => tokenWeight v pC pZ t * (p:ℝ)⁻¹)
|
| 28 |
+
(TypeFibers.unordered (untaggedType v hh 𝔏 a)) := by
|
| 29 |
+
rw [TypeFibers.unorderedWeight_eq]
|
| 30 |
+
apply prod_congr rfl
|
| 31 |
+
intro p hp
|
| 32 |
+
rcases he : untaggedType v hh 𝔏 a p with _ | t
|
| 33 |
+
· simp only [TypeFibers.factor,untaggedReference,he,Option.map_none]
|
| 34 |
+
· have ht := (untaggedType_some v hh 𝔏 a p t he).1
|
| 35 |
+
simp only [TypeFibers.factor,untaggedReference,he,Option.map_some,slotWeight,ht,ite_true]
|
| 36 |
+
rw [← tokenWeight_reference H]
|
| 37 |
+
|
| 38 |
+
namespace RecordPacket
|
| 39 |
+
variable {w₀ : ClosedLine h ℓ} {hh : 0 < h} {r : ℕ}
|
| 40 |
+
variable {hr₀ : (returnSteps w₀).card=r} {n N : ℕ}
|
| 41 |
+
|
| 42 |
+
noncomputable instance fintype : Fintype (RecordPacket D L w₀ hh r hr₀ n N) := Fintype.ofFinite _
|
| 43 |
+
|
| 44 |
+
noncomputable def exceptionalWeight (c : FlatCode S w₀ C₀ B L n N) : ℝ :=
|
| 45 |
+
weight (paddedGroupWeight (fun p : S.Index => (p:ℝ)⁻¹)) c.2.1 *
|
| 46 |
+
∏ i : Fin N, paddedShapeWeight (fun p s => localTokenWeight w₀ p (taggedShapeCode w₀ s))
|
| 47 |
+
(c.2.1 (exceptionalPick L ⌈C₀*Real.log B⌉₊ n N i)) (c.2.2.1 i)
|
| 48 |
+
|
| 49 |
+
noncomputable def flatWeight (pC pZ : S.Index) (c : FlatCode S w₀ C₀ B L n N) : ℝ :=
|
| 50 |
+
exceptionalWeight c * ∏ p : S.Index, TypeFibers.factor c.2.2.2
|
| 51 |
+
(fun t p => tokenWeight w₀ pC pZ t * slotWeight S (t.1=true) p) p
|
| 52 |
+
|
| 53 |
+
noncomputable def nativeWeight (x : RecordPacket D L w₀ hh r hr₀ n N) : ℝ :=
|
| 54 |
+
∏ p : S.Index, (if UsedPrime x.line x.primitives p then (p:ℝ)⁻¹ else 1) *
|
| 55 |
+
recordTreeWeight x.line hh x.primitives x.record p
|
| 56 |
+
|
| 57 |
+
lemma flatWeight_code (pC pZ : S.Index) (hpC : S.IsCore pC) (hpZ : ¬S.IsCore pZ)
|
| 58 |
+
(x : RecordPacket D L w₀ hh r hr₀ n N) : flatWeight pC pZ x.flatCode=x.nativeWeight := by
|
| 59 |
+
unfold nativeWeight flatWeight exceptionalWeight
|
| 60 |
+
rw [← x.realized_residues,record_weight_factorization x.line hh x.primitives x.residues pC pZ hpC hpZ]
|
| 61 |
+
rw [exceptionalCode_weight x.geometry hh x.primitives x.residues n N x.length_le x.tagCount]
|
| 62 |
+
congr 1
|
| 63 |
+
exact untagged_reference_weight x.geometry hh x.primitives x.residues pC pZ hpC hpZ
|
| 64 |
+
|
| 65 |
+
lemma factor_nonneg {P T : Type*} (f : P → Option T) (W : T → P → ℝ)
|
| 66 |
+
(hW : ∀ t p, 0 ≤ W t p) (p : P) : 0 ≤ TypeFibers.factor f W p := by
|
| 67 |
+
unfold TypeFibers.factor
|
| 68 |
+
cases he : f p with
|
| 69 |
+
| none => exact zero_le_one
|
| 70 |
+
| some t => exact hW t p
|
| 71 |
+
|
| 72 |
+
lemma exceptionalWeight_nonneg (c : FlatCode S w₀ C₀ B L n N) : 0 ≤ exceptionalWeight c := by
|
| 73 |
+
unfold exceptionalWeight
|
| 74 |
+
apply mul_nonneg
|
| 75 |
+
· exact weight_nonneg _ (paddedGroupWeight_nonneg _ (fun p => by positivity)) _
|
| 76 |
+
· exact prod_nonneg (fun i _ => paddedShapeWeight_nonneg _ (fun p s => localTokenWeight_nonneg w₀ p _) _ _)
|
| 77 |
+
|
| 78 |
+
lemma flatWeight_nonneg (pC pZ : S.Index) (c : FlatCode S w₀ C₀ B L n N) :
|
| 79 |
+
0 ≤ flatWeight pC pZ c := by
|
| 80 |
+
exact mul_nonneg (exceptionalWeight_nonneg c) (prod_nonneg (fun p _ =>
|
| 81 |
+
factor_nonneg _ _ (fun t p => mul_nonneg (tokenWeight_nonneg _ _ _ _) (slotWeight_nonneg _ _ _)) p))
|
| 82 |
+
|
| 83 |
+
theorem native_sum_le_gated_code (pC pZ : S.Index) (hpC : S.IsCore pC) (hpZ : ¬S.IsCore pZ) :
|
| 84 |
+
(∑ x : RecordPacket D L w₀ hh r hr₀ n N, x.nativeWeight) ≤
|
| 85 |
+
∑ c : FlatCode S w₀ C₀ B L n N, if flatGate D.H τ c then flatWeight pC pZ c else 0 := by
|
| 86 |
+
let W := fun c : FlatCode S w₀ C₀ B L n N => if flatGate D.H τ c then flatWeight pC pZ c else 0
|
| 87 |
+
have hx (x : RecordPacket D L w₀ hh r hr₀ n N) : W x.flatCode=x.nativeWeight := by
|
| 88 |
+
rw [show W x.flatCode=flatWeight pC pZ x.flatCode from ite_eq_left x.flatCode_gate,
|
| 89 |
+
flatWeight_code pC pZ hpC hpZ]
|
| 90 |
+
simp_rw [← hx]
|
| 91 |
+
calc
|
| 92 |
+
_ = ∑ c ∈ univ.image flatCode, W c := (sum_image (fun x _ y _ he => flatCode_injective he)).symm
|
| 93 |
+
_ ≤ _ := sum_le_sum_of_subset_of_nonneg (subset_univ _) (fun c _ _ => by
|
| 94 |
+
unfold W
|
| 95 |
+
split_ifs
|
| 96 |
+
· exact flatWeight_nonneg pC pZ c
|
| 97 |
+
· exact le_rfl)
|
| 98 |
+
|
| 99 |
+
end RecordPacket
|
| 100 |
+
end OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 101 |
+
|
| 102 |
+
end
|
| 103 |
+
|
| 104 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/UsedPrimeReciprocal.lean
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.SourcePolyDivTendsto
|
| 2 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.FixedIsTagged
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
noncomputable section
|
| 7 |
+
open scoped BigOperators
|
| 8 |
+
open Finset
|
| 9 |
+
open Finset Classical
|
| 10 |
+
open Filter
|
| 11 |
+
|
| 12 |
+
namespace OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 13 |
+
open OrdinaryCorrelations.SignedTrace OrdinaryCorrelations.FiniteIntegration
|
| 14 |
+
open Finset Classical Filter
|
| 15 |
+
variable {S : PrimeSystem} {B τ C₀ : ℝ} {D : S.DivisorFamily B τ C₀} {h ℓ L : ℕ}
|
| 16 |
+
|
| 17 |
+
def usedPrimeReciprocal (w : ClosedLine h ℓ) (𝔏 : List (AttachedSpec w D L)) : ℝ :=
|
| 18 |
+
∏ p : S.Index, if UsedPrime w 𝔏 p then (p : ℝ)⁻¹ else 1
|
| 19 |
+
|
| 20 |
+
lemma usedPrimeReciprocal_nonneg (w : ClosedLine h ℓ) (𝔏 : List (AttachedSpec w D L)) :
|
| 21 |
+
0 ≤ usedPrimeReciprocal w 𝔏 := by
|
| 22 |
+
unfold usedPrimeReciprocal
|
| 23 |
+
positivity
|
| 24 |
+
|
| 25 |
+
def traceIntegrationMajorant (w : ClosedLine h ℓ) (hh : 0 < h)
|
| 26 |
+
(𝔏 : List (AttachedSpec w D L)) (R : AssignedRecord S ℓ) (T err : ℝ) : ℝ :=
|
| 27 |
+
chargeConstant (S := S) w T (recordU w R.1) *
|
| 28 |
+
Real.exp (-S.harmonicCore * bandDefect w betaC - S.harmonicCenter * bandDefect w betaZ +
|
| 29 |
+
S.harmonicCore * betaC * (Real.exp kappa - 1) * (recordU w R.1).card + err) *
|
| 30 |
+
usedPrimeReciprocal w 𝔏 * ∏ p : S.Index, recordTreeWeight w hh 𝔏 R p
|
| 31 |
+
|
| 32 |
+
lemma traceIntegrationMajorant_nonneg (w : ClosedLine h ℓ) (hh : 0 < h)
|
| 33 |
+
(𝔏 : List (AttachedSpec w D L)) (R : AssignedRecord S ℓ) (T err : ℝ) :
|
| 34 |
+
0 ≤ traceIntegrationMajorant w hh 𝔏 R T err := by
|
| 35 |
+
unfold traceIntegrationMajorant chargeConstant
|
| 36 |
+
exact mul_nonneg (mul_nonneg (mul_nonneg (Real.exp_pos _).le (Real.exp_pos _).le)
|
| 37 |
+
(usedPrimeReciprocal_nonneg w 𝔏)) (prod_nonneg (fun p _ => recordTreeWeight_nonneg w hh 𝔏 R p))
|
| 38 |
+
|
| 39 |
+
lemma traceIntegrationMajorant_mono (w : ClosedLine h ℓ) (hh : 0 < h)
|
| 40 |
+
(𝔏 : List (AttachedSpec w D L)) (R : AssignedRecord S ℓ) (T : ℝ) {e₁ e₂ : ℝ}
|
| 41 |
+
(he : e₁ ≤ e₂) :
|
| 42 |
+
traceIntegrationMajorant w hh 𝔏 R T e₁ ≤ traceIntegrationMajorant w hh 𝔏 R T e₂ := by
|
| 43 |
+
unfold traceIntegrationMajorant
|
| 44 |
+
apply mul_le_mul_of_nonneg_right _ (prod_nonneg (fun p _ => recordTreeWeight_nonneg w hh 𝔏 R p))
|
| 45 |
+
apply mul_le_mul_of_nonneg_right _ (usedPrimeReciprocal_nonneg w 𝔏)
|
| 46 |
+
apply mul_le_mul_of_nonneg_left _ (Real.exp_pos _).le
|
| 47 |
+
apply Real.exp_le_exp.mpr
|
| 48 |
+
linarith
|
| 49 |
+
|
| 50 |
+
theorem trace_integration_finite (w : ClosedLine h ℓ) (hh : 0 < h)
|
| 51 |
+
{T : ℝ} (cut : S.Cutoffs T) (𝔏 : List (AttachedSpec w D L))
|
| 52 |
+
(R : AssignedRecord S ℓ) (hlarge : ∀ p : S.Index, 2 * (ℓ+1) ≤ (p : ℕ)) :
|
| 53 |
+
assignedKernelIntegral w cut 𝔏 (recordGroup w hh 𝔏 R) ≤
|
| 54 |
+
traceIntegrationMajorant w hh 𝔏 R T (restorationError w 𝔏) := by
|
| 55 |
+
by_cases hex : ∃ a, recordGroup w hh 𝔏 R a
|
| 56 |
+
· obtain ⟨a,ha⟩ := hex
|
| 57 |
+
change recordAt w hh 𝔏 a = R at ha
|
| 58 |
+
subst R
|
| 59 |
+
have hb := assignedKernelIntegral_restored w hh cut 𝔏 (recordAt w hh 𝔏 a).1
|
| 60 |
+
(recordAt_compatible w hh 𝔏 a) (recordGroup w hh 𝔏 (recordAt w hh 𝔏 a))
|
| 61 |
+
(fun b hb p => recordGroup_edges w hh 𝔏 (recordAt w hh 𝔏 a) b hb p) hlarge
|
| 62 |
+
apply hb.trans
|
| 63 |
+
have hp : (∏ p : S.Index, tokenPrimeFactor w 𝔏 (recordAt w hh 𝔏 a).1 p) ≤
|
| 64 |
+
usedPrimeReciprocal w 𝔏 * ∏ p : S.Index, recordTreeWeight w hh 𝔏 (recordAt w hh 𝔏 a) p := by
|
| 65 |
+
rw [usedPrimeReciprocal, ← prod_mul_distrib]
|
| 66 |
+
exact prod_le_prod₀ (fun p _ => tokenPrimeFactor_nonneg w 𝔏 _ p)
|
| 67 |
+
(fun p _ => record_tokenPrimeFactor_le w hh 𝔏 a p)
|
| 68 |
+
simpa only [traceIntegrationMajorant,chargeConstant,mul_assoc] using
|
| 69 |
+
mul_le_mul_of_nonneg_left hp (mul_nonneg (Real.exp_pos _).le (Real.exp_pos _).le)
|
| 70 |
+
· have hfalse : ∀ a, ¬recordGroup w hh 𝔏 R a := not_exists.mp hex
|
| 71 |
+
have hz : assignedKernelIntegral w cut 𝔏 (recordGroup w hh 𝔏 R) = 0 := by
|
| 72 |
+
simp [assignedKernelIntegral,hfalse,avg]
|
| 73 |
+
rw [hz]
|
| 74 |
+
exact traceIntegrationMajorant_nonneg w hh 𝔏 R T _
|
| 75 |
+
|
| 76 |
+
theorem trace_integration_source (h : ℕ) (hh : 0 < h) (τ C₀ : ℝ)
|
| 77 |
+
(hτ : 0 ≤ τ) (hC₀ : 0 ≤ C₀) :
|
| 78 |
+
∀ᶠ B : ℝ in atTop,
|
| 79 |
+
∀ (D : (sourceSystem B).DivisorFamily B τ C₀)
|
| 80 |
+
(w : ClosedLine h (sourceLength B)),
|
| 81 |
+
(∀ i, w.label i ∈ D.members) →
|
| 82 |
+
∀ {T : ℝ} (cut : (sourceSystem B).Cutoffs T)
|
| 83 |
+
(𝔏 : List (AttachedSpec w D (pathLength B))),
|
| 84 |
+
𝔏.length < listCutoff B →
|
| 85 |
+
∀ R : AssignedRecord (sourceSystem B) (sourceLength B),
|
| 86 |
+
assignedKernelIntegral w cut 𝔏 (recordGroup w hh 𝔏 R) ≤
|
| 87 |
+
traceIntegrationMajorant w hh 𝔏 R T (sourceErrorBound h τ C₀ B) := by
|
| 88 |
+
filter_upwards [source_eventually_large h] with B hB
|
| 89 |
+
intro D w hlabels T cut 𝔏 ht R
|
| 90 |
+
have he := restorationError_source_bound w 𝔏 hlabels hB.1 hC₀ hτ
|
| 91 |
+
(sourceLength_le B (by linarith [hB.1])) (pathLength_le B hB.1)
|
| 92 |
+
((by exact_mod_cast ht.le : (𝔏.length : ℝ) ≤ (listCutoff B : ℝ)).trans (listCutoff_le B hB.1))
|
| 93 |
+
(fun p => (source_prime_lower B hB.1 p).le)
|
| 94 |
+
exact (trace_integration_finite w hh cut 𝔏 R (fun p => (hB.2 p).1)).trans
|
| 95 |
+
(traceIntegrationMajorant_mono w hh 𝔏 R T he)
|
| 96 |
+
|
| 97 |
+
lemma assignedKernelIntegral_mono (w : ClosedLine h ℓ) {T : ℝ} (cut : S.Cutoffs T)
|
| 98 |
+
(𝔏 : List (AttachedSpec w D L)) (G H : S.FixedResidues w → Prop)
|
| 99 |
+
(hGH : ∀ a, G a → H a) :
|
| 100 |
+
assignedKernelIntegral w cut 𝔏 G ≤ assignedKernelIntegral w cut 𝔏 H := by
|
| 101 |
+
apply avg_mono
|
| 102 |
+
intro a
|
| 103 |
+
by_cases hg : G a
|
| 104 |
+
· simp only [hg,hGH a hg,ite_true,le_refl]
|
| 105 |
+
· simp only [hg,ite_false]
|
| 106 |
+
split_ifs
|
| 107 |
+
· exact abs_nonneg _
|
| 108 |
+
· exact le_refl _
|
| 109 |
+
|
| 110 |
+
theorem trace_integration_retained (w : ClosedLine h ℓ) (hh : 0 < h)
|
| 111 |
+
{T : ℝ} (cut : S.Cutoffs T) (𝔏 : List (AttachedSpec w D L))
|
| 112 |
+
(R : AssignedRecord S ℓ) (retained : S.FixedResidues w → Prop)
|
| 113 |
+
(hlarge : ∀ p : S.Index, 2 * (ℓ+1) ≤ (p : ℕ)) :
|
| 114 |
+
assignedKernelIntegral w cut 𝔏 (fun a => retained a ∧ recordGroup w hh 𝔏 R a) ≤
|
| 115 |
+
traceIntegrationMajorant w hh 𝔏 R T (restorationError w 𝔏) :=
|
| 116 |
+
(assignedKernelIntegral_mono w cut 𝔏 _ _ (fun _ ha => ha.2)).trans
|
| 117 |
+
(trace_integration_finite w hh cut 𝔏 R hlarge)
|
| 118 |
+
|
| 119 |
+
theorem source_active_graph_eventually (h : ℕ) (hh : 0 < h) :
|
| 120 |
+
∀ᶠ B : ℝ in atTop, ∀ (w : ClosedLine h (sourceLength B))
|
| 121 |
+
(p : (sourceSystem B).Index) (a : ZMod (p : ℕ)) (u v : ℤ),
|
| 122 |
+
(edgeGraph w hh (litEdges w p a)).Adj u v ↔
|
| 123 |
+
(edgeGraph w hh w.treeSteps).Adj u v ∧
|
| 124 |
+
a + (u : ZMod (p : ℕ)) = 0 ∧ a + (v : ZMod (p : ℕ)) = 0 := by
|
| 125 |
+
filter_upwards [source_eventually_large h] with B hB
|
| 126 |
+
intro w p a u v
|
| 127 |
+
exact active_graph_exact w hh p (Nat.not_dvd_of_pos_of_lt hh (hB.2 p).2) a u v
|
| 128 |
+
|
| 129 |
+
end OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 130 |
+
|
| 131 |
+
end
|
| 132 |
+
|
| 133 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/VertexAt.lean
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.DivisorFamily
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
noncomputable section
|
| 6 |
+
open scoped BigOperators
|
| 7 |
+
open Finset
|
| 8 |
+
open Finset Classical
|
| 9 |
+
open Filter
|
| 10 |
+
open Finset Classical Filter
|
| 11 |
+
open scoped Topology
|
| 12 |
+
|
| 13 |
+
namespace OrdinaryCorrelations.GraphKernel.PrimeSystem.Specification
|
| 14 |
+
open OrdinaryCorrelations.SignedTrace
|
| 15 |
+
open Finset Classical
|
| 16 |
+
variable {S : PrimeSystem} {B τ C₀ : ℝ} {D : S.DivisorFamily B τ C₀} {h L : ℕ}
|
| 17 |
+
|
| 18 |
+
def vertexAt (s : S.Specification D h L) (n : ℕ) : ℤ :=
|
| 19 |
+
if hn : n ≤ s.length then s.offset ⟨n,by omega⟩ else 0
|
| 20 |
+
|
| 21 |
+
def edgeAt (s : S.Specification D h L) (n : ℕ) : ℤ :=
|
| 22 |
+
if hn : n<s.length then s.sign ⟨n,hn⟩*(h:ℤ)*s.label ⟨n,hn⟩ else 0
|
| 23 |
+
|
| 24 |
+
def coefficientAt (s : S.Specification D h L) (q n : ℕ) : ℤ :=
|
| 25 |
+
if hn : n<s.length then
|
| 26 |
+
if q ∣ s.label ⟨n,hn⟩ then s.sign ⟨n,hn⟩*(h:ℤ)*(s.label ⟨n,hn⟩/q : ℕ) else 0
|
| 27 |
+
else 0
|
| 28 |
+
|
| 29 |
+
def coefficient (s : S.Specification D h L) (q a b : ℕ) : ℤ :=
|
| 30 |
+
∑ n ∈ Ico a b, s.coefficientAt q n
|
| 31 |
+
|
| 32 |
+
lemma edgeAt_eq (s : S.Specification D h L) (n : ℕ) (hn : n<s.length) :
|
| 33 |
+
s.edgeAt n = s.vertexAt (n+1)-s.vertexAt n := by
|
| 34 |
+
simp only [edgeAt,vertexAt,dite_eq_left hn,dite_eq_left (show n+1 ≤ s.length by omega),
|
| 35 |
+
dite_eq_left (show n ≤ s.length by omega)]
|
| 36 |
+
exact (s.step ⟨n,hn⟩).symm
|
| 37 |
+
|
| 38 |
+
lemma displacement_eq_sum (s : S.Specification D h L) (a b : ℕ)
|
| 39 |
+
(hab : a ≤ b) (hb : b ≤ s.length) :
|
| 40 |
+
s.offset ⟨b,by omega⟩-s.offset ⟨a,by omega⟩ = ∑ n ∈ Ico a b, s.edgeAt n := by
|
| 41 |
+
calc
|
| 42 |
+
_ = s.vertexAt b-s.vertexAt a := by
|
| 43 |
+
simp only [vertexAt,dite_eq_left hb,dite_eq_left (hab.trans hb)]
|
| 44 |
+
_ = ∑ n ∈ Ico a b, (s.vertexAt (n+1)-s.vertexAt n) := (sum_Ico_sub _ hab).symm
|
| 45 |
+
_ = _ := sum_congr rfl (fun n hn => (s.edgeAt_eq n (by have := mem_Ico.mp hn; omega)).symm)
|
| 46 |
+
|
| 47 |
+
lemma mul_coefficient_interval (s : S.Specification D h L) (q a b : ℕ)
|
| 48 |
+
(hab : a ≤ b) (hb : b ≤ s.length)
|
| 49 |
+
(hq : ∀ n : Fin s.length, a ≤ n.val → n.val<b → q ∣ s.label n) :
|
| 50 |
+
(q:ℤ)*s.coefficient q a b = s.offset ⟨b,by omega⟩-s.offset ⟨a,by omega⟩ := by
|
| 51 |
+
rw [s.displacement_eq_sum a b hab hb,coefficient,mul_sum]
|
| 52 |
+
apply sum_congr rfl
|
| 53 |
+
intro n hn
|
| 54 |
+
have hi := mem_Ico.mp hn
|
| 55 |
+
have hn' : n<s.length := by omega
|
| 56 |
+
have hqn := hq ⟨n,hn'⟩ hi.1 hi.2
|
| 57 |
+
simp only [coefficientAt,edgeAt,dite_eq_left hn',ite_eq_left hqn]
|
| 58 |
+
have he : (q:ℤ)*(s.label ⟨n,hn'⟩/q : ℕ) = (s.label ⟨n,hn'⟩:ℤ) := by
|
| 59 |
+
exact_mod_cast Nat.mul_div_cancel' hqn
|
| 60 |
+
calc
|
| 61 |
+
_ = s.sign ⟨n,hn'⟩*(h:ℤ)*((q:ℤ)*(s.label ⟨n,hn'⟩/q : ℕ)) := by ring
|
| 62 |
+
_ = _ := by rw [he]
|
| 63 |
+
|
| 64 |
+
lemma coefficient_restrict (s : S.Specification D h L) (q a b c d : ℕ)
|
| 65 |
+
(hca : c ≤ a) (hbd : b ≤ d) (hd : d ≤ s.length)
|
| 66 |
+
(hzero : ∀ i : Fin s.length, c ≤ i.val → i.val<d →
|
| 67 |
+
(i.val<a ∨ b ≤ i.val) → ¬q ∣ s.label i) :
|
| 68 |
+
s.coefficient q c d = s.coefficient q a b := by
|
| 69 |
+
unfold coefficient
|
| 70 |
+
symm
|
| 71 |
+
apply sum_subset
|
| 72 |
+
· intro n hn
|
| 73 |
+
have hi := mem_Ico.mp hn
|
| 74 |
+
exact mem_Ico.mpr ⟨hca.trans hi.1,lt_of_lt_of_le hi.2 hbd⟩
|
| 75 |
+
· intro n hn hout
|
| 76 |
+
have hi := mem_Ico.mp hn
|
| 77 |
+
have hn' : n<s.length := by omega
|
| 78 |
+
have hsplit : n<a ∨ b ≤ n := by
|
| 79 |
+
by_contra he
|
| 80 |
+
push Not at he
|
| 81 |
+
exact hout (mem_Ico.mpr ⟨by omega,by omega⟩)
|
| 82 |
+
have hq := hzero ⟨n,hn'⟩ hi.1 hi.2 hsplit
|
| 83 |
+
simp only [coefficientAt,dite_eq_left hn',ite_eq_right hq]
|
| 84 |
+
|
| 85 |
+
end OrdinaryCorrelations.GraphKernel.PrimeSystem.Specification
|
| 86 |
+
|
| 87 |
+
end
|
| 88 |
+
|
| 89 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/VertexIndex.lean
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.Nonempty
|
| 2 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.TopologyTreeSteps
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
noncomputable section
|
| 7 |
+
open scoped BigOperators
|
| 8 |
+
open Finset
|
| 9 |
+
open Finset Classical
|
| 10 |
+
open Filter
|
| 11 |
+
open Finset Classical Filter
|
| 12 |
+
|
| 13 |
+
namespace OrdinaryCorrelations.NumericalSubtrees
|
| 14 |
+
open OrdinaryCorrelations.SignedTrace OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 15 |
+
open Finset Classical
|
| 16 |
+
variable {h ℓ : ℕ} {w v : ClosedLine h ℓ}
|
| 17 |
+
|
| 18 |
+
def vertexIndex (w : ClosedLine h ℓ) (x : ℤ) : Fin (ℓ+1) :=
|
| 19 |
+
if hx : x ∈ treeVertices w then Classical.choose (mem_image.mp hx) else 0
|
| 20 |
+
|
| 21 |
+
lemma vertexIndex_spec (w : ClosedLine h ℓ) (x : ℤ) (hx : x ∈ treeVertices w) :
|
| 22 |
+
w.offset (vertexIndex w x)=x := by
|
| 23 |
+
simpa only [vertexIndex,dite_eq_left hx] using (Classical.choose_spec (mem_image.mp hx)).2
|
| 24 |
+
|
| 25 |
+
lemma offset_mem_vertices (w : ClosedLine h ℓ) (i : Fin (ℓ+1)) :
|
| 26 |
+
w.offset i ∈ treeVertices w := mem_image.mpr ⟨i,mem_univ _,rfl⟩
|
| 27 |
+
|
| 28 |
+
lemma edgeVertices_subset_vertices (w : ClosedLine h ℓ) (E : Finset (Fin ℓ)) :
|
| 29 |
+
edgeVertices w E ⊆ treeVertices w := by
|
| 30 |
+
intro x hx
|
| 31 |
+
rcases mem_union.mp hx with hx | hx
|
| 32 |
+
· obtain ⟨e,he,rfl⟩ := mem_image.mp hx
|
| 33 |
+
exact offset_mem_vertices w _
|
| 34 |
+
· obtain ⟨e,he,rfl⟩ := mem_image.mp hx
|
| 35 |
+
exact offset_mem_vertices w _
|
| 36 |
+
|
| 37 |
+
namespace SameGeometry
|
| 38 |
+
|
| 39 |
+
def vertexImage (_ : SameGeometry w v) (x : ℤ) : ℤ := v.offset (vertexIndex w x)
|
| 40 |
+
|
| 41 |
+
lemma vertexImage_offset (H : SameGeometry w v) (i : Fin (ℓ+1)) :
|
| 42 |
+
H.vertexImage (w.offset i) = v.offset i :=
|
| 43 |
+
(H.pattern _ _).mp (vertexIndex_spec w (w.offset i) (offset_mem_vertices w i))
|
| 44 |
+
|
| 45 |
+
lemma vertexImage_injective (H : SameGeometry w v) :
|
| 46 |
+
Set.InjOn H.vertexImage (treeVertices w) := by
|
| 47 |
+
intro x hx y hy he
|
| 48 |
+
have hh := (H.pattern (vertexIndex w x) (vertexIndex w y)).mpr he
|
| 49 |
+
simpa only [vertexIndex_spec w x hx,vertexIndex_spec w y hy] using hh
|
| 50 |
+
|
| 51 |
+
lemma vertices_image (H : SameGeometry w v) : (treeVertices w).image H.vertexImage = treeVertices v := by
|
| 52 |
+
simp only [treeVertices,image_image,Function.comp_def,H.vertexImage_offset]
|
| 53 |
+
|
| 54 |
+
lemma edgeVertices_image (H : SameGeometry w v) (E : Finset (Fin ℓ)) :
|
| 55 |
+
(edgeVertices w E).image H.vertexImage = edgeVertices v E := by
|
| 56 |
+
simp only [edgeVertices,image_union,image_image,Function.comp_def,H.vertexImage_offset]
|
| 57 |
+
|
| 58 |
+
lemma children_image (H : SameGeometry w v) (x : ℤ) (hx : x ∈ treeVertices w) :
|
| 59 |
+
v.children (H.vertexImage x) = w.children x := by
|
| 60 |
+
have he := H.children (vertexIndex w x)
|
| 61 |
+
simpa only [vertexIndex_spec w x hx,vertexImage] using he.symm
|
| 62 |
+
|
| 63 |
+
lemma weight (H : SameGeometry w v) {S : OrdinaryCorrelations.GraphKernel.PrimeSystem}
|
| 64 |
+
(p : S.Index) (E : Finset (Fin ℓ)) :
|
| 65 |
+
subtreeUnionWeight w p E = subtreeUnionWeight v p E := by
|
| 66 |
+
unfold subtreeUnionWeight
|
| 67 |
+
congr 1
|
| 68 |
+
rw [← H.edgeVertices_image E,prod_image (H.vertexImage_injective.mono (edgeVertices_subset_vertices w E))]
|
| 69 |
+
apply prod_congr rfl
|
| 70 |
+
intro x hx
|
| 71 |
+
rw [H.children_image x (edgeVertices_subset_vertices w E hx)]
|
| 72 |
+
|
| 73 |
+
lemma modifiedWeight (H : SameGeometry w v) {S : OrdinaryCorrelations.GraphKernel.PrimeSystem}
|
| 74 |
+
(p : S.Index) (E : Finset (Fin ℓ)) :
|
| 75 |
+
OrdinaryCorrelations.GraphKernel.PrimeSystem.modifiedWeight w p E =
|
| 76 |
+
OrdinaryCorrelations.GraphKernel.PrimeSystem.modifiedWeight v p E := by
|
| 77 |
+
simp only [OrdinaryCorrelations.GraphKernel.PrimeSystem.modifiedWeight,H.weight,H.good]
|
| 78 |
+
|
| 79 |
+
lemma bandDefect (H : SameGeometry w v) (β : ℝ) :
|
| 80 |
+
OrdinaryCorrelations.GraphKernel.PrimeSystem.bandDefect w β =
|
| 81 |
+
OrdinaryCorrelations.GraphKernel.PrimeSystem.bandDefect v β := by
|
| 82 |
+
unfold OrdinaryCorrelations.GraphKernel.PrimeSystem.bandDefect
|
| 83 |
+
rw [← H.vertices_image,sum_image H.vertexImage_injective]
|
| 84 |
+
apply sum_congr rfl
|
| 85 |
+
intro x hx
|
| 86 |
+
rw [H.children_image x hx]
|
| 87 |
+
|
| 88 |
+
def shapeMap (H : SameGeometry w v) (Q : Shape w) : Shape v where
|
| 89 |
+
top := ⟨v.offset Q.topEdge.castSucc,offset_mem_vertices v _⟩
|
| 90 |
+
edges := ⟨Q.edges.val,mem_erase.mpr ⟨Q.nonempty.ne_empty, (mem_shapes ..).mpr (by
|
| 91 |
+
apply (H.grows Q.topEdge.castSucc Q.edges.val).mp
|
| 92 |
+
simpa only [Q.topEdge_origin] using Q.grows)⟩⟩
|
| 93 |
+
|
| 94 |
+
lemma shapeMap_edges (H : SameGeometry w v) (Q : Shape w) : (H.shapeMap Q).edges.val=Q.edges.val := rfl
|
| 95 |
+
|
| 96 |
+
lemma Shape.ext_edges {w : ClosedLine h ℓ} (Q R : Shape w) (hE : Q.edges.val=R.edges.val) : Q=R := by
|
| 97 |
+
have htop : Q.top=R.top := by
|
| 98 |
+
apply Subtype.ext
|
| 99 |
+
rw [← Q.topEdge_origin,← R.topEdge_origin]
|
| 100 |
+
congr 2
|
| 101 |
+
simp only [Shape.topEdge,hE]
|
| 102 |
+
cases Q
|
| 103 |
+
cases R
|
| 104 |
+
cases htop
|
| 105 |
+
congr
|
| 106 |
+
exact Subtype.ext hE
|
| 107 |
+
|
| 108 |
+
lemma shapeMap_inverse (H : SameGeometry w v) (Q : Shape w) : H.symm.shapeMap (H.shapeMap Q)=Q :=
|
| 109 |
+
Shape.ext_edges _ _ rfl
|
| 110 |
+
|
| 111 |
+
def shapeEquiv (H : SameGeometry w v) : Shape w ≃ Shape v where
|
| 112 |
+
toFun := H.shapeMap
|
| 113 |
+
invFun := H.symm.shapeMap
|
| 114 |
+
left_inv := H.shapeMap_inverse
|
| 115 |
+
right_inv := H.symm.shapeMap_inverse
|
| 116 |
+
|
| 117 |
+
lemma goodEdges (H : SameGeometry w v) : OrdinaryCorrelations.NumericalSubtrees.goodEdges w =
|
| 118 |
+
OrdinaryCorrelations.NumericalSubtrees.goodEdges v := by
|
| 119 |
+
ext e
|
| 120 |
+
simp only [OrdinaryCorrelations.NumericalSubtrees.goodEdges,mem_filter,H.trees,H.good]
|
| 121 |
+
|
| 122 |
+
end SameGeometry
|
| 123 |
+
|
| 124 |
+
end OrdinaryCorrelations.NumericalSubtrees
|
| 125 |
+
|
| 126 |
+
end
|
| 127 |
+
|
| 128 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/VertexWeight.lean
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.PrimeSystem
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
noncomputable section
|
| 6 |
+
open scoped BigOperators
|
| 7 |
+
open Finset
|
| 8 |
+
open Finset Classical
|
| 9 |
+
|
| 10 |
+
namespace OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 11 |
+
open OrdinaryCorrelations.FiniteIntegration OrdinaryCorrelations.SignedTrace
|
| 12 |
+
open Finset Classical
|
| 13 |
+
variable {S : PrimeSystem} {h ℓ : ℕ}
|
| 14 |
+
|
| 15 |
+
def vertexWeight (S : PrimeSystem) (r : S.Residues) (b : ℤ) : ℝ :=
|
| 16 |
+
∏ p : S.Index, (S.beta p)⁻¹ ^
|
| 17 |
+
(if r p + (b : ZMod (p : ℕ)) = 0 then (1 : ℕ) else 0)
|
| 18 |
+
|
| 19 |
+
lemma vertexWeight_inv (S : PrimeSystem) (r : S.Residues) (b : ℤ) :
|
| 20 |
+
(S.vertexWeight r b)⁻¹ = ∏ p : S.Index, S.beta p ^
|
| 21 |
+
(if r p + (b : ZMod (p : ℕ)) = 0 then (1 : ℕ) else 0) := by
|
| 22 |
+
simp only [vertexWeight, prod_inv_distrib, inv_pow, inv_inv]
|
| 23 |
+
|
| 24 |
+
def edgeWeight (S : PrimeSystem) (w : ClosedLine h ℓ) {T : ℝ}
|
| 25 |
+
(cut : S.Cutoffs T) (r : S.Residues) (i : Fin ℓ) : ℝ :=
|
| 26 |
+
(cut.value (w.label i) (S.shiftCore (S.restrictCore r) (w.offset i.castSucc)) *
|
| 27 |
+
cut.value (w.label i) (S.shiftCore (S.restrictCore r) (w.offset i.succ))) *
|
| 28 |
+
∏ p, S.occurrenceFactor w p i (r p)
|
| 29 |
+
|
| 30 |
+
def chronologicalKernel (S : PrimeSystem) (w : ClosedLine h ℓ) {T : ℝ}
|
| 31 |
+
(cut : S.Cutoffs T) (r : S.Residues) : ℝ :=
|
| 32 |
+
∏ i : Fin ℓ, S.edgeWeight w cut r i / S.vertexWeight r (w.offset i.castSucc)
|
| 33 |
+
|
| 34 |
+
lemma chronologicalKernel_eq (S : PrimeSystem) (w : ClosedLine h ℓ) {T : ℝ}
|
| 35 |
+
(cut : S.Cutoffs T) (r : S.Residues) :
|
| 36 |
+
S.chronologicalKernel w cut r = S.kernel w cut r := by
|
| 37 |
+
simp only [chronologicalKernel, edgeWeight, div_eq_mul_inv, vertexWeight_inv,
|
| 38 |
+
kernel, cutoffProduct, primeFactor]
|
| 39 |
+
trans (∏ i : Fin ℓ,
|
| 40 |
+
(cut.value (w.label i) (S.shiftCore (S.restrictCore r) (w.offset i.castSucc)) *
|
| 41 |
+
cut.value (w.label i) (S.shiftCore (S.restrictCore r) (w.offset i.succ))) *
|
| 42 |
+
(∏ p : S.Index, S.occurrenceFactor w p i (r p) *
|
| 43 |
+
S.beta p ^ (if r p + (w.offset i.castSucc : ZMod (p : ℕ)) = 0 then 1 else 0)))
|
| 44 |
+
· apply prod_congr rfl
|
| 45 |
+
intro i _
|
| 46 |
+
rw [prod_mul_distrib]
|
| 47 |
+
ring
|
| 48 |
+
· rw [prod_mul_distrib, prod_comm]
|
| 49 |
+
|
| 50 |
+
lemma center_primeFactor_eq (S : PrimeSystem) (w : ClosedLine h ℓ) (p : S.Index)
|
| 51 |
+
(hp : ¬S.IsCore p) (r : ZMod (p : ℕ)) :
|
| 52 |
+
S.primeFactor w p r = centerPrimeFactor w.departures w.label r := by
|
| 53 |
+
simp only [primeFactor, occurrenceFactor, hp, ite_false, beta, amplitude,
|
| 54 |
+
add_eq_zero_iff_eq_neg, centerPrimeFactor, activeResidue, ClosedLine.departures,
|
| 55 |
+
activity, betaZ]
|
| 56 |
+
rfl
|
| 57 |
+
|
| 58 |
+
end OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 59 |
+
|
| 60 |
+
end
|
| 61 |
+
|
| 62 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/VerticesInBlock.lean
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.WalkBetweenSupport
|
| 2 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.WalkVertices
|
| 3 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.BlockEdges
|
| 4 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.AllForward
|
| 5 |
+
|
| 6 |
+
namespace OAI
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
open scoped BigOperators
|
| 10 |
+
open Finset
|
| 11 |
+
open Finset Classical
|
| 12 |
+
open Filter
|
| 13 |
+
open Finset Classical Filter
|
| 14 |
+
open scoped Topology
|
| 15 |
+
|
| 16 |
+
namespace OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 17 |
+
open OrdinaryCorrelations.SignedTrace OrdinaryCorrelations.NumericalSubtrees
|
| 18 |
+
open OrdinaryCorrelations.ForestTraversal Finset Classical SimpleGraph
|
| 19 |
+
noncomputable section
|
| 20 |
+
variable {S : PrimeSystem} {B τ C₀ : ℝ} {D : S.DivisorFamily B τ C₀} {h ℓ K : ℕ}
|
| 21 |
+
variable {w : NumericalLine D h ℓ} {hh : 0<h}
|
| 22 |
+
|
| 23 |
+
lemma TreePath.vertices_in_block (P : TreePath w K) (b : Block (edgeGraph w.line hh w.line.treeSteps))
|
| 24 |
+
(hPE : ∀ i,P.edge i ∈ blockEdges b) : ∀ j,P.vertex j ∈ b.walk.support := by
|
| 25 |
+
intro j
|
| 26 |
+
cases j using Fin.cases with
|
| 27 |
+
| zero =>
|
| 28 |
+
let i : Fin P.length := ⟨0,P.length_pos⟩
|
| 29 |
+
have hp := block_edge_endpoints b (P.edge i) (hPE i)
|
| 30 |
+
have he := P.endpoints i
|
| 31 |
+
have hi : i.castSucc=(0:Fin (P.length+1)) := rfl
|
| 32 |
+
cases hf : P.forward i <;> simp only [hf,Bool.false_eq_true,ite_false,ite_true] at he
|
| 33 |
+
· exact by simpa only [hi] using (he.1.symm ▸ hp.2)
|
| 34 |
+
· exact by simpa only [hi] using (he.1.symm ▸ hp.1)
|
| 35 |
+
| succ i =>
|
| 36 |
+
have hp := block_edge_endpoints b (P.edge i) (hPE i)
|
| 37 |
+
have he := P.endpoints i
|
| 38 |
+
cases hf : P.forward i <;> simp only [hf,Bool.false_eq_true,ite_false,ite_true] at he
|
| 39 |
+
· exact he.2.symm ▸ hp.1
|
| 40 |
+
· exact he.2.symm ▸ hp.2
|
| 41 |
+
|
| 42 |
+
lemma block_root_paths (b : Block (edgeGraph w.line hh w.line.treeSteps))
|
| 43 |
+
(hsmall : b.walk.length ≤ K) (hne : (blockEdges b).Nonempty) :
|
| 44 |
+
∃ c : Fin (ℓ+1),w.line.offset c ∈ b.walk.support ∧
|
| 45 |
+
∀ e ∈ blockEdges b,w.line.offset c=w.line.offset e.castSucc ∨
|
| 46 |
+
∃ P : TreePath w K,P.vertex 0=w.line.offset c ∧
|
| 47 |
+
P.vertex (Fin.last P.length)=w.line.offset e.castSucc ∧
|
| 48 |
+
(∀ i,P.edge i<e) := by
|
| 49 |
+
let e₀ := (blockEdges b).min' hne
|
| 50 |
+
let c := e₀.castSucc
|
| 51 |
+
have hc : w.line.offset c ∈ b.walk.support :=
|
| 52 |
+
(block_edge_endpoints b e₀ (min'_mem _ _)).1
|
| 53 |
+
refine ⟨c,hc,?_⟩
|
| 54 |
+
intro e he
|
| 55 |
+
by_cases hv : w.line.offset c=w.line.offset e.castSucc
|
| 56 |
+
· exact Or.inl hv
|
| 57 |
+
· right
|
| 58 |
+
have ht : w.line.offset e.castSucc ∈ b.walk.support := (block_edge_endpoints b e he).1
|
| 59 |
+
obtain ⟨q,hq⟩ := walk_between_support (u := w.line.offset c) (v := w.line.offset e.castSucc) (localBlockWalk b)
|
| 60 |
+
(by rwa [localBlockWalk_support]) (by rwa [localBlockWalk_support])
|
| 61 |
+
have hlen : q.length ≤ K := by rw [localBlockWalk_length] at hq; exact hq.trans hsmall
|
| 62 |
+
obtain ⟨P,hP0,hPL,hPE⟩ := exists_treePath w hh (blockEdges_subset b) q hlen
|
| 63 |
+
(mem_image.mpr ⟨c,mem_univ _,rfl⟩) hv
|
| 64 |
+
have hf : ∀ i,P.forward i=true := P.all_forward hPE (by
|
| 65 |
+
rw [hP0]
|
| 66 |
+
exact min_origin_not_destination w.line (blockEdges_subset b) hne)
|
| 67 |
+
exact ⟨P,hP0,hPL,P.edges_before_endpoint hf e hPL⟩
|
| 68 |
+
|
| 69 |
+
lemma block_local_paths (b : Block (edgeGraph w.line hh w.line.treeSteps))
|
| 70 |
+
(hsmall : b.walk.length ≤ K) (c v : Fin (ℓ+1))
|
| 71 |
+
(hc : w.line.offset c ∈ b.walk.support) (hv : w.line.offset v ∈ b.walk.support) :
|
| 72 |
+
w.line.offset c=w.line.offset v ∨ ∃ P : TreePath w K,
|
| 73 |
+
P.vertex 0=w.line.offset c ∧ P.vertex (Fin.last P.length)=w.line.offset v ∧
|
| 74 |
+
∀ i,P.vertex i ∈ b.walk.support := by
|
| 75 |
+
by_cases he : w.line.offset c=w.line.offset v
|
| 76 |
+
· exact Or.inl he
|
| 77 |
+
· right
|
| 78 |
+
obtain ⟨q,hq⟩ := walk_between_support (u := w.line.offset c) (v := w.line.offset v) (localBlockWalk b)
|
| 79 |
+
(by rwa [localBlockWalk_support]) (by rwa [localBlockWalk_support])
|
| 80 |
+
have hlen : q.length ≤ K := by rw [localBlockWalk_length] at hq; exact hq.trans hsmall
|
| 81 |
+
obtain ⟨P,hP0,hPL,hPE⟩ := exists_treePath w hh (blockEdges_subset b) q hlen
|
| 82 |
+
(mem_image.mpr ⟨c,mem_univ _,rfl⟩) he
|
| 83 |
+
exact ⟨P,hP0,hPL,P.vertices_in_block b hPE⟩
|
| 84 |
+
|
| 85 |
+
end
|
| 86 |
+
end OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 87 |
+
|
| 88 |
+
end
|
| 89 |
+
|
| 90 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/WalkBetweenSupport.lean
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
noncomputable section
|
| 6 |
+
open scoped BigOperators
|
| 7 |
+
open Finset
|
| 8 |
+
open Finset Classical
|
| 9 |
+
open Filter
|
| 10 |
+
open Finset Classical Filter
|
| 11 |
+
open scoped Topology
|
| 12 |
+
|
| 13 |
+
namespace OrdinaryCorrelations.ForestTraversal
|
| 14 |
+
open Classical SimpleGraph
|
| 15 |
+
noncomputable section
|
| 16 |
+
variable {V : Type*} {G : SimpleGraph V}
|
| 17 |
+
|
| 18 |
+
lemma walk_between_support {s t u v : V} (p : G.Walk s t)
|
| 19 |
+
(hu : u ∈ p.support) (hv : v ∈ p.support) :
|
| 20 |
+
∃ q : G.Walk u v,q.length ≤ p.length := by
|
| 21 |
+
obtain ⟨p₁,p₂,hp⟩ := Walk.mem_support_iff_exists_append.mp hu
|
| 22 |
+
have hlen : p₁.length+p₂.length=p.length := by rw [hp,Walk.length_append]
|
| 23 |
+
rw [hp,Walk.mem_support_append_iff] at hv
|
| 24 |
+
rcases hv with hv | hv
|
| 25 |
+
· refine ⟨(p₁.dropUntil v hv).reverse,?_⟩
|
| 26 |
+
rw [Walk.length_reverse,Walk.length_dropUntil]
|
| 27 |
+
omega
|
| 28 |
+
· refine ⟨p₂.takeUntil v hv,?_⟩
|
| 29 |
+
exact (Walk.length_le_of_isSubwalk (p₂.isSubwalk_takeUntil hv)).trans (by omega)
|
| 30 |
+
|
| 31 |
+
end
|
| 32 |
+
end OrdinaryCorrelations.ForestTraversal
|
| 33 |
+
|
| 34 |
+
end
|
| 35 |
+
|
| 36 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/WalkSupportConnected.lean
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.ConnectedSet
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
noncomputable section
|
| 6 |
+
open scoped BigOperators
|
| 7 |
+
open Finset
|
| 8 |
+
open Finset Classical
|
| 9 |
+
open Filter
|
| 10 |
+
open Finset Classical Filter
|
| 11 |
+
open scoped Topology
|
| 12 |
+
|
| 13 |
+
namespace OrdinaryCorrelations.Rerooting
|
| 14 |
+
open Classical Finset SimpleGraph
|
| 15 |
+
noncomputable section
|
| 16 |
+
variable {V : Type*} [DecidableEq V] {G : SimpleGraph V}
|
| 17 |
+
|
| 18 |
+
lemma walk_support_connected {x y : V} (p : G.Walk x y) : ConnectedSet G p.support.toFinset := by
|
| 19 |
+
intro u hu v hv
|
| 20 |
+
have hu' := List.mem_toFinset.mp hu
|
| 21 |
+
have hv' := List.mem_toFinset.mp hv
|
| 22 |
+
refine ⟨(p.takeUntil u hu').reverse.append (p.takeUntil v hv'),?_⟩
|
| 23 |
+
intro z hz
|
| 24 |
+
apply List.mem_toFinset.mpr
|
| 25 |
+
rw [Walk.mem_support_append_iff] at hz
|
| 26 |
+
rcases hz with hz|hz
|
| 27 |
+
· exact p.support_takeUntil_subset_support hu' (by simpa using hz)
|
| 28 |
+
· exact p.support_takeUntil_subset_support hv' hz
|
| 29 |
+
end
|
| 30 |
+
end OrdinaryCorrelations.Rerooting
|
| 31 |
+
|
| 32 |
+
end
|
| 33 |
+
|
| 34 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/WalkVertices.lean
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.UncutTreeEdges
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
noncomputable section
|
| 6 |
+
open scoped BigOperators
|
| 7 |
+
open Finset
|
| 8 |
+
open Finset Classical
|
| 9 |
+
open Filter
|
| 10 |
+
open Finset Classical Filter
|
| 11 |
+
open scoped Topology
|
| 12 |
+
|
| 13 |
+
namespace OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 14 |
+
open OrdinaryCorrelations.SignedTrace OrdinaryCorrelations.NumericalSubtrees
|
| 15 |
+
open Finset Classical SimpleGraph
|
| 16 |
+
noncomputable section
|
| 17 |
+
variable {S : PrimeSystem} {B τ C₀ : ℝ} {D : S.DivisorFamily B τ C₀} {h ℓ L : ℕ}
|
| 18 |
+
|
| 19 |
+
lemma walk_vertices (w : ClosedLine h ℓ) (hh : 0<h) {E : Finset (Fin ℓ)}
|
| 20 |
+
{u v : ℤ} (p : (edgeGraph w hh E).Walk u v) (hu : u ∈ treeVertices w) :
|
| 21 |
+
∀ z ∈ p.support,z ∈ treeVertices w := by
|
| 22 |
+
induction p with
|
| 23 |
+
| nil => simpa using hu
|
| 24 |
+
| @cons u v z ha p ih =>
|
| 25 |
+
have hv : v ∈ treeVertices w := by
|
| 26 |
+
obtain ⟨e,he,hor | hrev⟩ := ha
|
| 27 |
+
· rw [hor.2]; exact endpoint_mem_vertices w e
|
| 28 |
+
· rw [hrev.1]; exact departure_mem_vertices w e
|
| 29 |
+
intro x hx
|
| 30 |
+
rcases List.mem_cons.mp hx with rfl | hx
|
| 31 |
+
· exact hu
|
| 32 |
+
· exact ih hv x hx
|
| 33 |
+
|
| 34 |
+
lemma exists_treePath (w : NumericalLine D h ℓ) (hh : 0<h) {E : Finset (Fin ℓ)}
|
| 35 |
+
(hE : E ⊆ w.line.treeSteps) {u v : ℤ} (q : (edgeGraph w.line hh E).Walk u v)
|
| 36 |
+
(hlen : q.length ≤ L) (hu : u ∈ treeVertices w.line) (hne : u≠v) :
|
| 37 |
+
∃ P : TreePath w L,P.vertex 0=u ∧ P.vertex (Fin.last P.length)=v ∧ ∀ i,P.edge i ∈ E := by
|
| 38 |
+
let p := q.bypass
|
| 39 |
+
have hp : p.IsPath := q.bypass_isPath
|
| 40 |
+
have hpL : p.length ≤ L := q.length_bypass_le_length.trans hlen
|
| 41 |
+
have hp0 : 0<p.length := by
|
| 42 |
+
by_contra hn
|
| 43 |
+
exact hne (Walk.eq_of_length_eq_zero (Nat.eq_zero_of_not_pos hn))
|
| 44 |
+
have hedge : ∀ i : Fin p.length,∃ e ∈ E,
|
| 45 |
+
(p.getVert i.val=w.line.offset e.castSucc ∧ p.getVert (i.val+1)=w.line.offset e.succ) ∨
|
| 46 |
+
(p.getVert (i.val+1)=w.line.offset e.castSucc ∧ p.getVert i.val=w.line.offset e.succ) :=
|
| 47 |
+
fun i => p.adj_getVert_succ i.isLt
|
| 48 |
+
choose edge he hor using hedge
|
| 49 |
+
let vf : Fin (p.length+1) → ℤ := fun i => p.getVert i.val
|
| 50 |
+
let forward : Fin p.length → Bool := fun i => decide (p.getVert i.val=w.line.offset (edge i).castSucc)
|
| 51 |
+
have endpoints (i : Fin p.length) : if forward i then
|
| 52 |
+
vf i.castSucc=w.line.offset (edge i).castSucc ∧ vf i.succ=w.line.offset (edge i).succ
|
| 53 |
+
else vf i.castSucc=w.line.offset (edge i).succ ∧ vf i.succ=w.line.offset (edge i).castSucc := by
|
| 54 |
+
dsimp [forward,vf]
|
| 55 |
+
split_ifs with hi
|
| 56 |
+
· have hi' : p.getVert i.val=w.line.offset (edge i).castSucc := of_decide_eq_true hi
|
| 57 |
+
rcases hor i with hor | hrev
|
| 58 |
+
· exact hor
|
| 59 |
+
· exact (w.line.endpoints_ne hh (edge i) (hi'.symm.trans hrev.2)).elim
|
| 60 |
+
· rcases hor i with hor | hrev
|
| 61 |
+
· exact (hi (decide_eq_true hor.1)).elim
|
| 62 |
+
· exact ⟨hrev.2,hrev.1⟩
|
| 63 |
+
let P : TreePath w L := {
|
| 64 |
+
length := p.length
|
| 65 |
+
length_pos := hp0
|
| 66 |
+
length_le := hpL
|
| 67 |
+
vertex := vf
|
| 68 |
+
distinct := by
|
| 69 |
+
intro i j hij
|
| 70 |
+
apply Fin.ext
|
| 71 |
+
exact hp.getVert_injOn (Nat.le_of_lt_succ i.isLt) (Nat.le_of_lt_succ j.isLt) hij
|
| 72 |
+
vertex_mem := by
|
| 73 |
+
intro i
|
| 74 |
+
have hi := walk_vertices w.line hh p hu _ (p.getVert_mem_support i.val)
|
| 75 |
+
obtain ⟨j,hj,hjv⟩ := mem_image.mp hi
|
| 76 |
+
exact ⟨j,hjv.symm⟩
|
| 77 |
+
edge := edge
|
| 78 |
+
tree := fun i => hE (he i)
|
| 79 |
+
forward := forward
|
| 80 |
+
endpoints := endpoints }
|
| 81 |
+
exact ⟨P,by simp [P,vf],by simp [P,vf],he⟩
|
| 82 |
+
|
| 83 |
+
end
|
| 84 |
+
end OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 85 |
+
|
| 86 |
+
end
|
| 87 |
+
|
| 88 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/Witness.lean
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.BoundedLists
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
noncomputable section
|
| 6 |
+
open scoped BigOperators
|
| 7 |
+
open Finset
|
| 8 |
+
open Finset Classical
|
| 9 |
+
open Filter
|
| 10 |
+
open Finset Classical Filter
|
| 11 |
+
open scoped Topology
|
| 12 |
+
|
| 13 |
+
namespace OrdinaryCorrelations.SourceCylinder
|
| 14 |
+
open Finset Classical
|
| 15 |
+
variable {α ι : Type*} [Fintype α] [Fintype ι] {Ω : ι → Type*} [∀ p, Fintype (Ω p)]
|
| 16 |
+
|
| 17 |
+
abbrev Witness (V : Finset α) (f : α → Cylinder Ω) (t : ℕ) :=
|
| 18 |
+
{I : Intersection (V.image f) // I ∈ witnesses (V.image f) t}
|
| 19 |
+
|
| 20 |
+
omit [Fintype α] in
|
| 21 |
+
lemma exists_witnessGenerator (V : Finset α) (f : α → Cylinder Ω) (t : ℕ)
|
| 22 |
+
(I : Witness V f t) : ∃ l : List α, l.length ≤ t ∧
|
| 23 |
+
(∀ a ∈ l, a ∈ V) ∧ Cylinder.Generates (l.toFinset.image f) I.val.val := by
|
| 24 |
+
obtain ⟨A,hA,hcard,hgen⟩ := (mem_filter.mp I.property).2.2
|
| 25 |
+
let rep : A → α := fun e => Classical.choose (mem_image.mp (hA e.property))
|
| 26 |
+
have hv (e : A) : rep e ∈ V := (Classical.choose_spec (mem_image.mp (hA e.property))).1
|
| 27 |
+
have hf (e : A) : f (rep e)=e.val := (Classical.choose_spec (mem_image.mp (hA e.property))).2
|
| 28 |
+
let l : List α := A.attach.toList.map rep
|
| 29 |
+
have hlen : l.length = A.card := by simp [l]
|
| 30 |
+
have hmem (a : α) (ha : a ∈ l) : a ∈ V := by
|
| 31 |
+
obtain ⟨e,he,rfl⟩ := List.mem_map.mp ha
|
| 32 |
+
exact hv e
|
| 33 |
+
have he : l.toFinset.image f = A := by
|
| 34 |
+
ext c
|
| 35 |
+
constructor
|
| 36 |
+
· intro hc
|
| 37 |
+
obtain ⟨a,ha,rfl⟩ := mem_image.mp hc
|
| 38 |
+
obtain ⟨e,he,rfl⟩ := List.mem_map.mp (List.mem_toFinset.mp ha)
|
| 39 |
+
rw [hf e]
|
| 40 |
+
exact e.property
|
| 41 |
+
· intro hc
|
| 42 |
+
let e : A := ⟨c,hc⟩
|
| 43 |
+
exact mem_image.mpr ⟨rep e,List.mem_toFinset.mpr
|
| 44 |
+
(List.mem_map.mpr ⟨e,mem_toList.mpr (mem_attach A e),rfl⟩),hf e⟩
|
| 45 |
+
exact ⟨l,hlen ▸ hcard,hmem,he.symm ▸ hgen⟩
|
| 46 |
+
|
| 47 |
+
noncomputable def witnessGenerator (V : Finset α) (f : α → Cylinder Ω) (t : ℕ)
|
| 48 |
+
(I : Witness V f t) : List α := Classical.choose (exists_witnessGenerator V f t I)
|
| 49 |
+
|
| 50 |
+
omit [Fintype α] in
|
| 51 |
+
lemma witnessGenerator_spec (V : Finset α) (f : α → Cylinder Ω) (t : ℕ)
|
| 52 |
+
(I : Witness V f t) : (witnessGenerator V f t I).length ≤ t ∧
|
| 53 |
+
(∀ a ∈ witnessGenerator V f t I, a ∈ V) ∧
|
| 54 |
+
Cylinder.Generates ((witnessGenerator V f t I).toFinset.image f) I.val.val :=
|
| 55 |
+
Classical.choose_spec (exists_witnessGenerator V f t I)
|
| 56 |
+
|
| 57 |
+
omit [Fintype α] in
|
| 58 |
+
lemma witnessGenerator_injective (V : Finset α) (f : α → Cylinder Ω) (t : ℕ) :
|
| 59 |
+
Function.Injective (witnessGenerator V f t) := by
|
| 60 |
+
intro I J he
|
| 61 |
+
apply Subtype.ext
|
| 62 |
+
apply Subtype.ext
|
| 63 |
+
exact Cylinder.generates_unique (witnessGenerator_spec V f t I).2.2
|
| 64 |
+
(by simpa only [he] using (witnessGenerator_spec V f t J).2.2)
|
| 65 |
+
|
| 66 |
+
omit [Fintype α] in
|
| 67 |
+
lemma witnessGenerator_holds (V : Finset α) (f : α → Cylinder Ω) (t : ℕ)
|
| 68 |
+
(I : Witness V f t) (x : ∀ p, Ω p) (hx : I.val.val.Holds x) :
|
| 69 |
+
∀ a ∈ witnessGenerator V f t I, a ∈ V ∧ (f a).Holds x := by
|
| 70 |
+
intro a ha
|
| 71 |
+
refine ⟨(witnessGenerator_spec V f t I).2.1 a ha,?_⟩
|
| 72 |
+
apply Cylinder.holds_mono _ hx
|
| 73 |
+
exact (witnessGenerator_spec V f t I).2.2.1 (f a)
|
| 74 |
+
(mem_image.mpr ⟨a,List.mem_toFinset.mpr ha,rfl⟩)
|
| 75 |
+
|
| 76 |
+
omit [Fintype α] in
|
| 77 |
+
lemma witnessCount_eq_sum (V : Finset α) (f : α → Cylinder Ω) (t : ℕ) (x : ∀ p, Ω p) :
|
| 78 |
+
(witnessCount (V.image f) t x : ℝ) =
|
| 79 |
+
∑ I : Witness V f t, if I.val.val.Holds x then (1:ℝ) else 0 := by
|
| 80 |
+
rw [witnessCount,card_eq_sum_ones,Nat.cast_sum]
|
| 81 |
+
simp only [Nat.cast_one,sum_filter]
|
| 82 |
+
exact sum_subtype (witnesses (V.image f) t) (fun _ => Iff.rfl)
|
| 83 |
+
(fun I : Intersection (V.image f) => if I.val.Holds x then (1:ℝ) else 0)
|
| 84 |
+
|
| 85 |
+
theorem witnessCount_le_list_sum (V : Finset α) (f : α → Cylinder Ω) (t : ℕ)
|
| 86 |
+
(x : ∀ p, Ω p) (F : List α → ℝ) (hF : ∀ l, 0 ≤ F l)
|
| 87 |
+
(hI : ∀ I : Witness V f t, I.val.val.Holds x → 1 ≤ F (witnessGenerator V f t I)) :
|
| 88 |
+
(witnessCount (V.image f) t x : ℝ) ≤ ∑ l ∈ boundedLists α t, F l := by
|
| 89 |
+
rw [witnessCount_eq_sum V f]
|
| 90 |
+
calc
|
| 91 |
+
_ ≤ ∑ I : Witness V f t, F (witnessGenerator V f t I) := by
|
| 92 |
+
apply sum_le_sum
|
| 93 |
+
intro I hmem
|
| 94 |
+
split_ifs with hx
|
| 95 |
+
· exact hI I hx
|
| 96 |
+
· exact hF _
|
| 97 |
+
_ ≤ _ := by
|
| 98 |
+
rw [← sum_image (fun x _ y _ he => witnessGenerator_injective V f t he)]
|
| 99 |
+
apply sum_le_sum_of_subset_of_nonneg
|
| 100 |
+
· intro l hl
|
| 101 |
+
obtain ⟨I,hI,rfl⟩ := mem_image.mp hl
|
| 102 |
+
exact (mem_boundedLists _ _).mpr (witnessGenerator_spec V f t I).1
|
| 103 |
+
· intro l hl hnot
|
| 104 |
+
exact hF l
|
| 105 |
+
|
| 106 |
+
end OrdinaryCorrelations.SourceCylinder
|
| 107 |
+
|
| 108 |
+
end
|
| 109 |
+
|
| 110 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/WitnessBaseDoublePath.lean
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.SourceWitnessBasicScales
|
| 2 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.PackedGapPrefactor
|
| 3 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.ComponentBoundAfterGap
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
open scoped BigOperators
|
| 9 |
+
open Finset
|
| 10 |
+
open Finset Classical
|
| 11 |
+
open Filter
|
| 12 |
+
open Finset Classical Filter
|
| 13 |
+
open scoped Topology
|
| 14 |
+
|
| 15 |
+
namespace OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 16 |
+
open OrdinaryCorrelations.SignedTrace OrdinaryCorrelations.FiniteIntegration
|
| 17 |
+
open OrdinaryCorrelations.NumericalSubtrees Finset Classical Filter
|
| 18 |
+
noncomputable section
|
| 19 |
+
|
| 20 |
+
lemma witness_base_double_path (S : PrimeSystem) (M ℓ L J t : ℕ) :
|
| 21 |
+
witnessEntropyBase S M ℓ (L+L) J t ≤ 2*witnessEntropyBase S M ℓ L J t := by
|
| 22 |
+
unfold witnessEntropyBase witnessSlotCount
|
| 23 |
+
rw [WitnessConfiguration.codeSlot_card,WitnessConfiguration.codeSlot_card]
|
| 24 |
+
push_cast
|
| 25 |
+
have hH : 0 ≤ max 1 (∑ p ∈ S.primes,(p:ℝ)⁻¹) := le_trans (by norm_num) (le_max_left _ _)
|
| 26 |
+
have hA := A_pos
|
| 27 |
+
have hM := Nat.cast_nonneg (α:=ℝ) M
|
| 28 |
+
have hℓ := Nat.cast_nonneg (α:=ℝ) ℓ
|
| 29 |
+
have hL := Nat.cast_nonneg (α:=ℝ) L
|
| 30 |
+
have hJ := Nat.cast_nonneg (α:=ℝ) J
|
| 31 |
+
have ht := Nat.cast_nonneg (α:=ℝ) t
|
| 32 |
+
nlinarith
|
| 33 |
+
lemma witness_degree_double_path (M ℓ L J t : ℕ) :
|
| 34 |
+
witnessEntropyDegree M ℓ (L+L) J t ≤ 2*witnessEntropyDegree M ℓ L J t := by
|
| 35 |
+
unfold witnessEntropyDegree witnessSlotCount
|
| 36 |
+
rw [WitnessConfiguration.codeSlot_card,WitnessConfiguration.codeSlot_card]
|
| 37 |
+
nlinarith
|
| 38 |
+
|
| 39 |
+
namespace NumericalLine
|
| 40 |
+
lemma source_double_path_prefactor (C₀ : ℝ) (hC₀ : 0≤C₀) :
|
| 41 |
+
∀ᶠ B : ℝ in atTop,
|
| 42 |
+
packedGapPrefactor (sourceSystem B) (sourceLength B) (pathLength B+pathLength B)
|
| 43 |
+
⌈C₀*Real.log B⌉₊ (listCutoff B) ≤ Real.exp (B^(1+epsilon/2)) := by
|
| 44 |
+
have hlim := (isLittleO_log_rpow_atTop (by norm_num [epsilon] : 0<epsilon/4)).tendsto_div_nhds_zero
|
| 45 |
+
filter_upwards [source_witness_entropy_scales C₀ hC₀,
|
| 46 |
+
hlim.eventually (eventually_le_nhds (by norm_num : (0:ℝ)<1/6)),
|
| 47 |
+
eventually_ge_atTop (2:ℝ)] with B hs hlog hB
|
| 48 |
+
have hB1 : 1≤B := by linarith
|
| 49 |
+
have hB0 : 0<B := by linarith
|
| 50 |
+
let M := sourceListSlotBudget C₀ B
|
| 51 |
+
let ℓ := sourceLength B
|
| 52 |
+
let L := pathLength B
|
| 53 |
+
let J := ⌈C₀*Real.log B⌉₊
|
| 54 |
+
let t := listCutoff B
|
| 55 |
+
have hbase0 : 0≤witnessEntropyBase (sourceSystem B) M ℓ (L+L) J t := by
|
| 56 |
+
unfold witnessEntropyBase
|
| 57 |
+
have := A_pos
|
| 58 |
+
positivity
|
| 59 |
+
have hbase : witnessEntropyBase (sourceSystem B) M ℓ (L+L) J t ≤ B^3 := by
|
| 60 |
+
calc
|
| 61 |
+
_ ≤ 2*witnessEntropyBase (sourceSystem B) M ℓ L J t := witness_base_double_path ..
|
| 62 |
+
_ ≤ 2*(B^2) := mul_le_mul_of_nonneg_left hs.2 (by norm_num)
|
| 63 |
+
_ ≤ B^3 := by nlinarith [sq_nonneg B]
|
| 64 |
+
have hdegree : (witnessEntropyDegree M ℓ (L+L) J t:ℝ) ≤ 2*B^(1+epsilon/4) := by
|
| 65 |
+
calc
|
| 66 |
+
_ ≤ ((2*witnessEntropyDegree M ℓ L J t:ℕ):ℝ) := Nat.cast_le.mpr (witness_degree_double_path ..)
|
| 67 |
+
_ ≤ _ := by push_cast; exact mul_le_mul_of_nonneg_left hs.1 (by norm_num)
|
| 68 |
+
apply (packed_gap_polynomial_bound (sourceSystem B) M ℓ (L+L) J t).trans
|
| 69 |
+
apply (pow_le_pow_left₀ hbase0 hbase _).trans
|
| 70 |
+
rw [←Real.rpow_natCast,Real.rpow_def_of_pos (pow_pos hB0 3),Real.log_pow]
|
| 71 |
+
apply Real.exp_le_exp.mpr
|
| 72 |
+
have hlog0 := Real.log_nonneg hB1
|
| 73 |
+
have hl := (div_le_iff₀ (Real.rpow_pos_of_pos hB0 (epsilon/4))).mp hlog
|
| 74 |
+
have hd := mul_le_mul hdegree hl hlog0 (by positivity : 0≤2*B^(1+epsilon/4))
|
| 75 |
+
|
| 76 |
+
have hid' : (2*B^(1+epsilon/4))*((1/6)*B^(epsilon/4))=(1/3)*B^(1+epsilon/2) := by
|
| 77 |
+
calc
|
| 78 |
+
_ = (1/3)*(B^(1+epsilon/4)*B^(epsilon/4)) := by ring
|
| 79 |
+
_ = _ := by rw [←Real.rpow_add hB0]; congr 2; ring
|
| 80 |
+
rw [hid'] at hd
|
| 81 |
+
norm_num only [Nat.cast_ofNat] at *
|
| 82 |
+
nlinarith
|
| 83 |
+
|
| 84 |
+
lemma source_disconnected_threshold (C₀ : ℝ) (hC₀ : 0≤C₀) :
|
| 85 |
+
∀ᶠ B : ℝ in atTop,
|
| 86 |
+
(((((2*sourceLength B)/pathLength B+6*listCutoff B+1)^2)*
|
| 87 |
+
((2*⌈C₀*Real.log B⌉₊+1)*listCutoff B)^8:ℕ):ℝ) ≤ B^(1-2*rho) := by
|
| 88 |
+
filter_upwards [source_component_budget,source_witness_basic_scales C₀ hC₀,
|
| 89 |
+
eventually_const_mul_rpow_le (2*rho+8*(epsilon/8+4*epsilon)) (1-2*rho)
|
| 90 |
+
(32^2*6^8) (by norm_num [rho,epsilon])] with B hcomp hs hdom
|
| 91 |
+
obtain ⟨hB,hM,htL,ht,hJ,hH⟩ := hs
|
| 92 |
+
have hB0 : 0<B := zero_lt_one.trans_le hB
|
| 93 |
+
have ht' := ceil_rpow_le_two B (4*epsilon) hB (by norm_num [epsilon])
|
| 94 |
+
have hJ1 : 1≤B^(epsilon/8) := Real.one_le_rpow hB (by norm_num [epsilon])
|
| 95 |
+
have hn : (((2*⌈C₀*Real.log B⌉₊+1)*listCutoff B:ℕ):ℝ) ≤ 6*B^(epsilon/8+4*epsilon) := by
|
| 96 |
+
push_cast
|
| 97 |
+
calc
|
| 98 |
+
_ ≤ (3*B^(epsilon/8))*(2*B^(4*epsilon)) := mul_le_mul (by linarith) ht' (Nat.cast_nonneg _) (by positivity)
|
| 99 |
+
_ = _ := by rw [Real.rpow_add hB0]; ring
|
| 100 |
+
have hq := pow_le_pow_left₀ (Nat.cast_nonneg (α:=ℝ) _) hcomp.2 2
|
| 101 |
+
have hn8 := pow_le_pow_left₀ (Nat.cast_nonneg (α:=ℝ) _) hn 8
|
| 102 |
+
have hmul := mul_le_mul hq hn8 (by positivity) (by positivity)
|
| 103 |
+
have he : (32*B^rho)^2*(6*B^(epsilon/8+4*epsilon))^8 =
|
| 104 |
+
(32^2*6^8)*B^(2*rho+8*(epsilon/8+4*epsilon)) := by
|
| 105 |
+
have hp2 : (B^rho)^2 = B^(rho*2) := by
|
| 106 |
+
rw [Real.rpow_mul hB0.le]
|
| 107 |
+
norm_num
|
| 108 |
+
have hp8 : (B^(epsilon/8+4*epsilon))^8 = B^((epsilon/8+4*epsilon)*8) := by
|
| 109 |
+
rw [Real.rpow_mul hB0.le]
|
| 110 |
+
norm_num
|
| 111 |
+
rw [mul_pow,mul_pow,hp2,hp8]
|
| 112 |
+
calc
|
| 113 |
+
_ = (32^2*6^8)*(B^(rho*2)*B^((epsilon/8+4*epsilon)*8)) := by ring
|
| 114 |
+
_ = _ := by rw [←Real.rpow_add hB0]; congr 2; ring
|
| 115 |
+
rw [he] at hmul
|
| 116 |
+
exact le_trans (by simpa only [Nat.cast_mul,Nat.cast_pow] using hmul) hdom
|
| 117 |
+
|
| 118 |
+
end NumericalLine
|
| 119 |
+
end
|
| 120 |
+
end OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 121 |
+
|
| 122 |
+
end
|
| 123 |
+
|
| 124 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/WitnessConfiguration.lean
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.GlobalRecord
|
| 2 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.DataInjective
|
| 3 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.LinePrimeMemFullUsed
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
open scoped BigOperators
|
| 9 |
+
open Finset
|
| 10 |
+
open Finset Classical
|
| 11 |
+
open Filter
|
| 12 |
+
open Finset Classical Filter
|
| 13 |
+
open scoped Topology
|
| 14 |
+
|
| 15 |
+
namespace OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 16 |
+
open OrdinaryCorrelations.SignedTrace OrdinaryCorrelations.NumericalSubtrees
|
| 17 |
+
open Finset Classical
|
| 18 |
+
variable {S : PrimeSystem} {B τ C₀ : ℝ} {D : S.DivisorFamily B τ C₀} {h ℓ L t : ℕ}
|
| 19 |
+
|
| 20 |
+
structure WitnessConfiguration (D : S.DivisorFamily B τ C₀) (h ℓ L t : ℕ) where
|
| 21 |
+
line : ClosedLine h ℓ
|
| 22 |
+
labels : ∀ i, line.label i ∈ D.members
|
| 23 |
+
primitives : List (AttachedSpec line D L)
|
| 24 |
+
length_le : primitives.length ≤ t
|
| 25 |
+
family : PrivateFamily line D L t
|
| 26 |
+
|
| 27 |
+
abbrev WitnessCodeSlot (ℓ L J t : ℕ) :=
|
| 28 |
+
(Fin ℓ × Fin J) ⊕ (ListCodeSlot L J t ⊕ ((Fin t × SpecCodeSlot L J) ⊕ Fin t))
|
| 29 |
+
|
| 30 |
+
abbrev WitnessMetadata (ℓ L t : ℕ) :=
|
| 31 |
+
(Fin ℓ → Bool) × ListMetadata ℓ L t × (Fin t → AttachedMetadata ℓ L)
|
| 32 |
+
|
| 33 |
+
namespace WitnessConfiguration
|
| 34 |
+
variable (x : WitnessConfiguration D h ℓ L t)
|
| 35 |
+
|
| 36 |
+
noncomputable def metadata : WitnessMetadata ℓ L t :=
|
| 37 |
+
(signBit x.line,listMetadata x.line x.primitives t x.length_le,
|
| 38 |
+
fun j => attachedMetadata x.line (x.family.witness j))
|
| 39 |
+
|
| 40 |
+
noncomputable def primeCode : WitnessCodeSlot ℓ L ⌈C₀*Real.log B⌉₊ t → Option S.Index
|
| 41 |
+
| .inl (i,j) => FiniteSlotEncoding.code (labelPrimeSet (x.line.label i) (x.labels i)) ⌈C₀*Real.log B⌉₊ j
|
| 42 |
+
| .inr (.inl k) => listPrimeCode x.line x.primitives t k
|
| 43 |
+
| .inr (.inr (.inl (j,k))) => specPrimeCode (x.family.witness j).spec k
|
| 44 |
+
| .inr (.inr (.inr j)) => some (x.family.key j)
|
| 45 |
+
|
| 46 |
+
noncomputable def rawCode := (x.metadata,x.primeCode)
|
| 47 |
+
|
| 48 |
+
lemma rawCode_injective : Function.Injective
|
| 49 |
+
(rawCode : WitnessConfiguration D h ℓ L t → _) := by
|
| 50 |
+
intro x y he
|
| 51 |
+
have hm := congrArg Prod.fst he
|
| 52 |
+
have hp := congrArg Prod.snd he
|
| 53 |
+
have hline : x.line=y.line := by
|
| 54 |
+
apply GlobalRecord.line_eq_of_labels_signs
|
| 55 |
+
· funext i
|
| 56 |
+
have hsets : labelPrimeSet (x.line.label i) (x.labels i)=
|
| 57 |
+
labelPrimeSet (y.line.label i) (y.labels i) := by
|
| 58 |
+
apply FiniteSlotEncoding.code_injective (m:=⌈C₀*Real.log B⌉₊)
|
| 59 |
+
· rw [labelPrimeSet_card]; exact D.omega _ (x.labels i)
|
| 60 |
+
· rw [labelPrimeSet_card]; exact D.omega _ (y.labels i)
|
| 61 |
+
· funext j
|
| 62 |
+
exact congrFun hp (.inl (i,j))
|
| 63 |
+
rw [←labelPrimeSet_product (x.line.label i) (x.labels i),
|
| 64 |
+
←labelPrimeSet_product (y.line.label i) (y.labels i),hsets]
|
| 65 |
+
· funext i
|
| 66 |
+
have hs : signBit x.line i=signBit y.line i :=
|
| 67 |
+
congrArg (fun z : WitnessMetadata ℓ L t => z.1 i) hm
|
| 68 |
+
rw [signBit_decode x.line i,signBit_decode y.line i,hs]
|
| 69 |
+
cases x with
|
| 70 |
+
| mk w hw l hl F =>
|
| 71 |
+
cases y with
|
| 72 |
+
| mk v hv m hm' G =>
|
| 73 |
+
dsimp only at hline
|
| 74 |
+
subst v
|
| 75 |
+
have hlist : l=m := list_code_injective w l m t hl hm'
|
| 76 |
+
(congrArg (fun z : WitnessMetadata ℓ L t => z.2.1) hm)
|
| 77 |
+
(funext (fun k => congrFun hp (.inr (.inl k))))
|
| 78 |
+
subst m
|
| 79 |
+
have hfamily : F=G := by
|
| 80 |
+
apply PrivateFamily.data_injective
|
| 81 |
+
apply Prod.ext
|
| 82 |
+
· funext j
|
| 83 |
+
apply attached_code_injective w
|
| 84 |
+
· exact congrArg (fun z : WitnessMetadata ℓ L t => z.2.2 j) hm
|
| 85 |
+
· funext k
|
| 86 |
+
exact congrFun hp (.inr (.inr (.inl (j,k))))
|
| 87 |
+
· funext j
|
| 88 |
+
exact Option.some.inj (congrFun hp (.inr (.inr (.inr j))))
|
| 89 |
+
subst G
|
| 90 |
+
rfl
|
| 91 |
+
|
| 92 |
+
instance : Finite (WitnessConfiguration D h ℓ L t) :=
|
| 93 |
+
Finite.of_injective _ rawCode_injective
|
| 94 |
+
|
| 95 |
+
noncomputable instance : Fintype (WitnessConfiguration D h ℓ L t) := Fintype.ofFinite _
|
| 96 |
+
|
| 97 |
+
lemma primeCode_support (p : S.Index) :
|
| 98 |
+
(∃ k, x.primeCode k=some p) ↔ p ∈ fullUsedIndices x.line (x.primitives++List.ofFn x.family.witness) := by
|
| 99 |
+
constructor
|
| 100 |
+
· rintro ⟨(⟨i,j⟩ | (k | (⟨j,k⟩ | j))),hp⟩
|
| 101 |
+
· have hm := FiniteSlotEncoding.code_mem _ _ j p hp
|
| 102 |
+
exact line_prime_mem_fullUsed x.line _ p ((mem_labelPrimeSet _ _ _).mp hm)
|
| 103 |
+
· have hm := (listPrimeCode_support x.line x.primitives t x.length_le p).mpr ⟨k,hp⟩
|
| 104 |
+
obtain ⟨s,hs,hm⟩ := mem_biUnion.mp hm
|
| 105 |
+
exact list_prime_mem_fullUsed x.line _ s
|
| 106 |
+
(List.mem_append_left _ (List.mem_toFinset.mp hs)) p hm
|
| 107 |
+
· exact list_prime_mem_fullUsed x.line _ (x.family.witness j)
|
| 108 |
+
(List.mem_append_right _ (List.mem_ofFn.mpr ⟨j,rfl⟩)) p
|
| 109 |
+
((specPrimeCode_support (x.family.witness j).spec p).mpr ⟨k,hp⟩)
|
| 110 |
+
· have he : x.family.key j=p := Option.some.inj hp
|
| 111 |
+
exact he ▸ list_prime_mem_fullUsed x.line _ (x.family.witness j)
|
| 112 |
+
(List.mem_append_right _ (List.mem_ofFn.mpr ⟨j,rfl⟩)) (x.family.key j) (x.family.key_mem j)
|
| 113 |
+
· intro hp
|
| 114 |
+
rcases (mem_filter.mp hp).2 with ⟨i,hi⟩|hp
|
| 115 |
+
· have hc : (labelPrimeSet (x.line.label i) (x.labels i)).card ≤ ⌈C₀*Real.log B⌉₊ := by
|
| 116 |
+
rw [labelPrimeSet_card]; exact D.omega _ (x.labels i)
|
| 117 |
+
have hm : p ∈ labelPrimeSet (x.line.label i) (x.labels i) :=
|
| 118 |
+
(mem_labelPrimeSet _ _ _).mpr
|
| 119 |
+
(Nat.mem_primeFactors.mpr ⟨S.prime_mem p p.property,hi,(x.line.label_pos i).ne'⟩)
|
| 120 |
+
obtain ⟨j,hj⟩ := (FiniteSlotEncoding.mem_iff_code _ _ hc p).mp hm
|
| 121 |
+
exact ⟨.inl (i,j),hj⟩
|
| 122 |
+
· obtain ⟨s,hs,hp⟩ := mem_biUnion.mp hp
|
| 123 |
+
rcases List.mem_append.mp (List.mem_toFinset.mp hs) with hs|hs
|
| 124 |
+
· obtain ⟨k,hk⟩ := (listPrimeCode_support x.line x.primitives t x.length_le p).mp
|
| 125 |
+
(mem_biUnion.mpr ⟨s,List.mem_toFinset.mpr hs,hp⟩)
|
| 126 |
+
exact ⟨.inr (.inl k),hk⟩
|
| 127 |
+
· obtain ⟨j,rfl⟩ := List.mem_ofFn.mp hs
|
| 128 |
+
obtain ⟨k,hk⟩ := (specPrimeCode_support (x.family.witness j).spec p).mp hp
|
| 129 |
+
exact ⟨.inr (.inr (.inl (j,k))),hk⟩
|
| 130 |
+
|
| 131 |
+
lemma codeSlot_card (ℓ L J t : ℕ) :
|
| 132 |
+
Fintype.card (WitnessCodeSlot ℓ L J t)=ℓ*J+2*t*(L*J+1)+t := by
|
| 133 |
+
simp only [WitnessCodeSlot,ListCodeSlot,SpecCodeSlot,Fintype.card_sum,Fintype.card_prod,
|
| 134 |
+
Fintype.card_option,Fintype.card_fin]
|
| 135 |
+
ring
|
| 136 |
+
|
| 137 |
+
lemma metadata_card (ℓ L t : ℕ) :
|
| 138 |
+
Fintype.card (WitnessMetadata ℓ L t)=
|
| 139 |
+
2^ℓ*((t+1)*(1+(ℓ+1)*((L+1)^2*2^L))^t)*((ℓ+1)*((L+1)^2*2^L))^t := by
|
| 140 |
+
simp only [WitnessMetadata,Fintype.card_prod,Fintype.card_fun,Fintype.card_fin,Fintype.card_bool,
|
| 141 |
+
ListMetadata,AttachedMetadata,SpecMetadata,Fintype.card_option]
|
| 142 |
+
ring
|
| 143 |
+
|
| 144 |
+
end WitnessConfiguration
|
| 145 |
+
end OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 146 |
+
|
| 147 |
+
end
|
| 148 |
+
|
| 149 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/WitnessEntropyBase.lean
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.CylinderBudget
|
| 2 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.WitnessSlotCount
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
noncomputable section
|
| 7 |
+
open scoped BigOperators
|
| 8 |
+
open Finset
|
| 9 |
+
open Finset Classical
|
| 10 |
+
open Filter
|
| 11 |
+
open Finset Classical Filter
|
| 12 |
+
open scoped Topology
|
| 13 |
+
|
| 14 |
+
namespace OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 15 |
+
open OrdinaryCorrelations.SignedTrace
|
| 16 |
+
open Finset Classical
|
| 17 |
+
|
| 18 |
+
noncomputable def witnessEntropyBase (S : PrimeSystem) (M ℓ L J t : ℕ) : ℝ :=
|
| 19 |
+
2+A+M+ℓ+L+t+witnessSlotCount ℓ L J t + max 1 (∑ p ∈ S.primes,(p:ℝ)⁻¹)
|
| 20 |
+
|
| 21 |
+
noncomputable def witnessEntropyDegree (M ℓ L J t : ℕ) : ℕ :=
|
| 22 |
+
2*M+ℓ*J+3*witnessSlotCount ℓ L J t+ℓ+2*t*(L+10)+4
|
| 23 |
+
|
| 24 |
+
lemma add_one_le_pow_succ {Q x : ℝ} {n : ℕ} (hQ : 2 ≤ Q) (hx : x ≤ Q^n) :
|
| 25 |
+
x+1 ≤ Q^(n+1) := by
|
| 26 |
+
have hpow : 1 ≤ Q^n := one_le_pow₀ (by linarith)
|
| 27 |
+
rw [pow_succ]
|
| 28 |
+
nlinarith
|
| 29 |
+
|
| 30 |
+
lemma witness_polynomial_bound (S : PrimeSystem) (M ℓ L J t : ℕ) :
|
| 31 |
+
cylinderBudget M * (A^(ℓ*J)*2^(witnessSlotCount ℓ L J t)) *
|
| 32 |
+
(witnessTemplateBudget ℓ L J t:ℝ) *
|
| 33 |
+
(max 1 (∑ p ∈ S.primes,(p:ℝ)⁻¹))^(witnessSlotCount ℓ L J t) ≤
|
| 34 |
+
witnessEntropyBase S M ℓ L J t ^ witnessEntropyDegree M ℓ L J t := by
|
| 35 |
+
let N := witnessSlotCount ℓ L J t
|
| 36 |
+
let H : ℝ := max 1 (∑ p ∈ S.primes,(p:ℝ)⁻¹)
|
| 37 |
+
let Q := witnessEntropyBase S M ℓ L J t
|
| 38 |
+
have hH : 1 ≤ H := le_max_left _ _
|
| 39 |
+
have hA := A_pos
|
| 40 |
+
have hM := Nat.cast_nonneg (α:=ℝ) M
|
| 41 |
+
have hℓ := Nat.cast_nonneg (α:=ℝ) ℓ
|
| 42 |
+
have hL := Nat.cast_nonneg (α:=ℝ) L
|
| 43 |
+
have ht := Nat.cast_nonneg (α:=ℝ) t
|
| 44 |
+
have hN := Nat.cast_nonneg (α:=ℝ) N
|
| 45 |
+
have hQ : 2 ≤ Q := by dsimp [Q,witnessEntropyBase]; dsimp only [H,N] at *; linarith
|
| 46 |
+
have hQA : A ≤ Q := by dsimp [Q,witnessEntropyBase]; dsimp only [H,N] at *; linarith
|
| 47 |
+
have hQM : (M:ℝ) ≤ Q := by dsimp [Q,witnessEntropyBase]; dsimp only [H,N] at *; linarith
|
| 48 |
+
have hQℓ : (ℓ:ℝ)+1 ≤ Q := by dsimp [Q,witnessEntropyBase]; dsimp only [H,N] at *; linarith
|
| 49 |
+
have hQL : (L:ℝ)+1 ≤ Q := by dsimp [Q,witnessEntropyBase]; dsimp only [H,N] at *; linarith
|
| 50 |
+
have hQt : (t:ℝ)+1 ≤ Q := by dsimp [Q,witnessEntropyBase]; dsimp only [H,N] at *; linarith
|
| 51 |
+
have hQN : (N:ℝ)+1 ≤ Q := by dsimp [Q,witnessEntropyBase]; dsimp only [H,N] at *; linarith
|
| 52 |
+
have hQH : H ≤ Q := by dsimp [Q,witnessEntropyBase]; dsimp only [H,N] at *; linarith
|
| 53 |
+
have hQ0 : 0 ≤ Q := by linarith
|
| 54 |
+
have hcyl : cylinderBudget M ≤ Q^(2*M+1) := by
|
| 55 |
+
unfold cylinderBudget
|
| 56 |
+
push_cast
|
| 57 |
+
calc
|
| 58 |
+
_ ≤ Q^M * Q^(M+1) := by
|
| 59 |
+
apply mul_le_mul (pow_le_pow_left₀ (by norm_num) hQ _) _ (by positivity) (pow_nonneg hQ0 _)
|
| 60 |
+
apply max_le
|
| 61 |
+
· exact one_le_pow₀ (by linarith)
|
| 62 |
+
· exact pow_le_pow_left₀ hM hQM _
|
| 63 |
+
_ = _ := by rw [←pow_add]; congr 1; omega
|
| 64 |
+
have hcore : ((ℓ:ℝ)+1)*(((L:ℝ)+1)^2*2^L) ≤ Q^(L+3) := by
|
| 65 |
+
calc
|
| 66 |
+
_ ≤ Q*(Q^2*Q^L) := by gcongr
|
| 67 |
+
_ = _ := by rw [show L+3=L+2+1 by omega,pow_succ,pow_add]; ring
|
| 68 |
+
have hcore1 : 1+((ℓ:ℝ)+1)*(((L:ℝ)+1)^2*2^L) ≤ Q^(L+4) := by
|
| 69 |
+
simpa only [show L+4=(L+3)+1 by omega,add_comm (1:ℝ)] using add_one_le_pow_succ hQ hcore
|
| 70 |
+
have hmeta : (Fintype.card (WitnessMetadata ℓ L t):ℝ) ≤ Q^(ℓ+1+2*t*(L+4)) := by
|
| 71 |
+
rw [WitnessConfiguration.metadata_card]
|
| 72 |
+
push_cast
|
| 73 |
+
calc
|
| 74 |
+
_ ≤ Q^ℓ*(Q*(Q^(L+4))^t)*(Q^(L+4))^t := by
|
| 75 |
+
apply mul_le_mul
|
| 76 |
+
· apply mul_le_mul (pow_le_pow_left₀ (by norm_num) hQ _) _ (by positivity) (pow_nonneg hQ0 _)
|
| 77 |
+
exact mul_le_mul hQt (pow_le_pow_left₀ (by positivity) hcore1 _) (by positivity) hQ0
|
| 78 |
+
· exact pow_le_pow_left₀ (by positivity) (hcore.trans (pow_le_pow_right₀ (by linarith) (by omega))) _
|
| 79 |
+
· positivity
|
| 80 |
+
· positivity
|
| 81 |
+
_ = _ := by ring
|
| 82 |
+
have hdesc : (Fintype.card (WitnessTestDescriptor ℓ L t N):ℝ) ≤ Q^11 := by
|
| 83 |
+
rw [WitnessTemplateCode.descriptor_card]
|
| 84 |
+
push_cast
|
| 85 |
+
calc
|
| 86 |
+
_ ≤ (Q^2*Q*Q^3*Q^2)*Q^2*Q := by
|
| 87 |
+
gcongr <;> linarith
|
| 88 |
+
_ = _ := by ring
|
| 89 |
+
have hdesc1 : (Fintype.card (WitnessTestDescriptor ℓ L t N):ℝ)+1 ≤ Q^12 :=
|
| 90 |
+
add_one_le_pow_succ hQ hdesc
|
| 91 |
+
have hbudget : (witnessTemplateBudget ℓ L J t:ℝ) ≤
|
| 92 |
+
Q^(N+ℓ+2*t*(L+10)+3) := by
|
| 93 |
+
unfold witnessTemplateBudget
|
| 94 |
+
change (((N+1)*Fintype.card (WitnessMetadata ℓ L t)*(N+1)^N*
|
| 95 |
+
((t+1)*(Fintype.card (WitnessTestDescriptor ℓ L t N)+1)^t):ℕ):ℝ) ≤ _
|
| 96 |
+
push_cast
|
| 97 |
+
calc
|
| 98 |
+
_ ≤ Q*Q^(ℓ+1+2*t*(L+4))*Q^N*(Q*(Q^12)^t) := by
|
| 99 |
+
gcongr
|
| 100 |
+
_ = _ := by ring
|
| 101 |
+
apply (mul_le_mul (mul_le_mul (mul_le_mul hcyl
|
| 102 |
+
(mul_le_mul (pow_le_pow_left₀ hA.le hQA _) (pow_le_pow_left₀ (by norm_num) hQ _)
|
| 103 |
+
(by positivity) (pow_nonneg hQ0 _)) (by positivity) (pow_nonneg hQ0 _))
|
| 104 |
+
hbudget (Nat.cast_nonneg _) (by positivity))
|
| 105 |
+
(pow_le_pow_left₀ (zero_le_one.trans hH) hQH _) (by positivity) (by positivity)).trans_eq
|
| 106 |
+
unfold witnessEntropyDegree
|
| 107 |
+
change Q^(2*M+1)*(Q^(ℓ*J)*Q^N)*Q^(N+��+2*t*(L+10)+3)*Q^N = _
|
| 108 |
+
simp only [←pow_add]
|
| 109 |
+
congr 1
|
| 110 |
+
dsimp only [N]
|
| 111 |
+
omega
|
| 112 |
+
|
| 113 |
+
end OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 114 |
+
|
| 115 |
+
end
|
| 116 |
+
|
| 117 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/WitnessSlotCount.lean
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.UnselectedCard
|
| 2 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.WitnessTestDescriptor
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
noncomputable section
|
| 7 |
+
open scoped BigOperators
|
| 8 |
+
open Finset
|
| 9 |
+
open Finset Classical
|
| 10 |
+
open Filter
|
| 11 |
+
open Finset Classical Filter
|
| 12 |
+
open scoped Topology
|
| 13 |
+
|
| 14 |
+
namespace OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 15 |
+
open OrdinaryCorrelations.ArithmeticSaving OrdinaryCorrelations.SharedSlotPatterns
|
| 16 |
+
open Finset Classical
|
| 17 |
+
|
| 18 |
+
noncomputable def witnessSlotCount (ℓ L J t : ℕ) : ℕ := Fintype.card (WitnessCodeSlot ℓ L J t)
|
| 19 |
+
noncomputable def witnessTemplateBudget (ℓ L J t : ℕ) : ℕ :=
|
| 20 |
+
let N := witnessSlotCount ℓ L J t
|
| 21 |
+
(N+1)*Fintype.card (WitnessMetadata ℓ L t)*(N+1)^N *
|
| 22 |
+
((t+1)*(Fintype.card (WitnessTestDescriptor ℓ L t N)+1)^t)
|
| 23 |
+
|
| 24 |
+
lemma witnessTemplate_card_uniform (ℓ L J t m : ℕ) (hm : m ≤ witnessSlotCount ℓ L J t) :
|
| 25 |
+
Fintype.card (WitnessTemplateCode ℓ L J t m) ≤
|
| 26 |
+
Fintype.card (WitnessMetadata ℓ L t)*(witnessSlotCount ℓ L J t+1)^(witnessSlotCount ℓ L J t)*
|
| 27 |
+
((t+1)*(Fintype.card (WitnessTestDescriptor ℓ L t (witnessSlotCount ℓ L J t))+1)^t) := by
|
| 28 |
+
apply (WitnessTemplateCode.card_le ℓ L J t m).trans
|
| 29 |
+
have hc : Fintype.card (WitnessTestDescriptor ℓ L t m) ≤
|
| 30 |
+
Fintype.card (WitnessTestDescriptor ℓ L t (witnessSlotCount ℓ L J t)) := by
|
| 31 |
+
rw [WitnessTemplateCode.descriptor_card,WitnessTemplateCode.descriptor_card]
|
| 32 |
+
gcongr
|
| 33 |
+
change _ ≤ Fintype.card (WitnessMetadata ℓ L t)*
|
| 34 |
+
(witnessSlotCount ℓ L J t+1)^(Fintype.card (WitnessCodeSlot ℓ L J t))*_
|
| 35 |
+
gcongr
|
| 36 |
+
|
| 37 |
+
abbrev GoodWitnessTemplate (h ℓ L J t m r : ℕ) :=
|
| 38 |
+
{d : WitnessTemplateCode ℓ L J t m // d.WellFormed h ∧ r ≤ d.rank}
|
| 39 |
+
|
| 40 |
+
noncomputable def witnessTemplateMass (S : PrimeSystem) (P K : ℝ) (h ℓ L J t r : ℕ) : ℝ :=
|
| 41 |
+
∑ m : Fin (witnessSlotCount ℓ L J t+1),
|
| 42 |
+
∑ d : GoodWitnessTemplate h ℓ L J t m.val r,
|
| 43 |
+
∑ v : Fin m.val → S.Index,
|
| 44 |
+
(d.val.system h d.property.1).fiberWeight P K (fun a => (v a:ℕ))
|
| 45 |
+
|
| 46 |
+
lemma witnessTemplateMass_le (S : PrimeSystem) (P B K : ℝ) (h ℓ L J t r : ℕ)
|
| 47 |
+
(hP : 0 < P) (hB : 0 ≤ B) (hK : 0 ≤ K)
|
| 48 |
+
(hS : ∀ p : S.Index, P ≤ (p:ℝ) ∧ (p:ℝ) ≤ Real.exp B)
|
| 49 |
+
(hδ : max (K/(P*Real.log 2)) ((2+B)/P) ≤ 1) :
|
| 50 |
+
witnessTemplateMass S P K h ℓ L J t r ≤
|
| 51 |
+
(witnessTemplateBudget ℓ L J t:ℝ) *
|
| 52 |
+
(max 1 (∑ p ∈ S.primes, (p:ℝ)⁻¹))^(witnessSlotCount ℓ L J t) *
|
| 53 |
+
(max (K/(P*Real.log 2)) ((2+B)/P))^r := by
|
| 54 |
+
let N := witnessSlotCount ℓ L J t
|
| 55 |
+
let H : ℝ := max 1 (∑ p ∈ S.primes, (p:ℝ)⁻¹)
|
| 56 |
+
let δ : ℝ := max (K/(P*Real.log 2)) ((2+B)/P)
|
| 57 |
+
let C : ℕ := Fintype.card (WitnessMetadata ℓ L t)*(N+1)^N *
|
| 58 |
+
((t+1)*(Fintype.card (WitnessTestDescriptor ℓ L t N)+1)^t)
|
| 59 |
+
have h0δ : 0 ≤ δ := le_trans (by positivity : 0 ≤ (2+B)/P) (le_max_right _ _)
|
| 60 |
+
have hH : 1 ≤ H := le_max_left _ _
|
| 61 |
+
have h0H : 0 ≤ H := le_trans zero_le_one hH
|
| 62 |
+
have hrow (m : Fin (N+1)) (d : GoodWitnessTemplate h ℓ L J t m.val r) :
|
| 63 |
+
(∑ v : Fin m.val → S.Index,
|
| 64 |
+
(d.val.system h d.property.1).fiberWeight P K (fun a => (v a:ℕ))) ≤ H^N*δ^r := by
|
| 65 |
+
apply ((d.val.system h d.property.1).fiber_sum_le S.primes P B K hP hB hK
|
| 66 |
+
(fun p hp => ⟨S.prime_mem p hp,(hS ⟨p,hp⟩).1,(hS ⟨p,hp⟩).2⟩)).trans
|
| 67 |
+
apply mul_le_mul
|
| 68 |
+
· apply (pow_le_pow_left₀ (by positivity) (le_max_right (1:ℝ) _) _).trans
|
| 69 |
+
apply pow_le_pow_right₀ hH
|
| 70 |
+
rw [unselected_card,Fintype.card_fin]
|
| 71 |
+
omega
|
| 72 |
+
· exact pow_le_pow_of_le_one h0δ hδ d.property.2
|
| 73 |
+
· positivity
|
| 74 |
+
· positivity
|
| 75 |
+
have hcodes (m : Fin (N+1)) :
|
| 76 |
+
(∑ d : GoodWitnessTemplate h ℓ L J t m.val r,
|
| 77 |
+
∑ v : Fin m.val → S.Index,
|
| 78 |
+
(d.val.system h d.property.1).fiberWeight P K (fun a => (v a:ℕ))) ≤
|
| 79 |
+
(C:ℝ)*(H^N*δ^r) := by
|
| 80 |
+
calc
|
| 81 |
+
_ ≤ ∑ _ : GoodWitnessTemplate h ℓ L J t m.val r, H^N*δ^r :=
|
| 82 |
+
sum_le_sum (fun d _ => hrow m d)
|
| 83 |
+
_ = (Fintype.card (GoodWitnessTemplate h ℓ L J t m.val r):ℝ)*(H^N*δ^r) := by simp
|
| 84 |
+
_ ≤ _ := by
|
| 85 |
+
apply mul_le_mul_of_nonneg_right _ (mul_nonneg (pow_nonneg h0H _) (pow_nonneg h0δ _))
|
| 86 |
+
exact_mod_cast (Fintype.card_subtype_le _).trans
|
| 87 |
+
(witnessTemplate_card_uniform ℓ L J t m.val (Nat.lt_succ_iff.mp m.isLt))
|
| 88 |
+
calc
|
| 89 |
+
_ ≤ ∑ _ : Fin (N+1), (C:ℝ)*(H^N*δ^r) := sum_le_sum (fun m _ => hcodes m)
|
| 90 |
+
_ = ((N+1:ℕ):ℝ)*(C:ℝ)*(H^N*δ^r) := by simp [mul_assoc]
|
| 91 |
+
_ = _ := by
|
| 92 |
+
dsimp only [witnessTemplateBudget,C,N,H,δ]
|
| 93 |
+
push_cast
|
| 94 |
+
ring
|
| 95 |
+
|
| 96 |
+
end OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 97 |
+
|
| 98 |
+
end
|
| 99 |
+
|
| 100 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/WitnessTestDescriptor.lean
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.WitnessTestShape
|
| 2 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.OfRelabel
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
noncomputable section
|
| 7 |
+
open scoped BigOperators
|
| 8 |
+
open Finset
|
| 9 |
+
open Finset Classical
|
| 10 |
+
open Filter
|
| 11 |
+
open Finset Classical Filter
|
| 12 |
+
open scoped Topology
|
| 13 |
+
|
| 14 |
+
namespace OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 15 |
+
open OrdinaryCorrelations.ArithmeticSaving OrdinaryCorrelations.SharedSlotPatterns
|
| 16 |
+
open Finset Classical
|
| 17 |
+
|
| 18 |
+
abbrev WitnessTestDescriptor (ℓ L t m : ℕ) := WitnessTestShape ℓ L t × Fin m × Fin m × Bool
|
| 19 |
+
abbrev WitnessTemplateCode (ℓ L J t m : ℕ) :=
|
| 20 |
+
WitnessMetadata ℓ L t × (WitnessCodeSlot ℓ L J t → Option (Fin m)) ×
|
| 21 |
+
((k : Fin (t+1)) × (Fin k.val → WitnessTestDescriptor ℓ L t m))
|
| 22 |
+
|
| 23 |
+
noncomputable instance (ℓ L J t m : ℕ) : Fintype (WitnessTemplateCode ℓ L J t m) := by
|
| 24 |
+
haveI : Fintype (WitnessMetadata ℓ L t) := inferInstance
|
| 25 |
+
haveI : Fintype (WitnessCodeSlot ℓ L J t → Option (Fin m)) := inferInstance
|
| 26 |
+
haveI : Fintype (WitnessTestDescriptor ℓ L t m) := inferInstance
|
| 27 |
+
haveI : ∀ k : Fin (t+1), Fintype (Fin k.val → WitnessTestDescriptor ℓ L t m) :=
|
| 28 |
+
fun k => inferInstance
|
| 29 |
+
haveI : Fintype ((k : Fin (t+1)) × (Fin k.val → WitnessTestDescriptor ℓ L t m)) := inferInstance
|
| 30 |
+
unfold WitnessTemplateCode
|
| 31 |
+
infer_instance
|
| 32 |
+
|
| 33 |
+
namespace WitnessTemplateCode
|
| 34 |
+
variable {ℓ L J t m : ℕ}
|
| 35 |
+
noncomputable def rank (d : WitnessTemplateCode ℓ L J t m) : ℕ := d.2.2.1.val
|
| 36 |
+
noncomputable def selected (d : WitnessTemplateCode ℓ L J t m) (i : Fin d.rank) : Fin m :=
|
| 37 |
+
(d.2.2.2 i).2.1
|
| 38 |
+
noncomputable def modulus (d : WitnessTemplateCode ℓ L J t m) (i : Fin d.rank) : Fin m :=
|
| 39 |
+
(d.2.2.2 i).2.2.1
|
| 40 |
+
noncomputable def linear (d : WitnessTemplateCode ℓ L J t m) (i : Fin d.rank) : Bool :=
|
| 41 |
+
(d.2.2.2 i).2.2.2
|
| 42 |
+
noncomputable def expression (d : WitnessTemplateCode ℓ L J t m) (h : ℕ) (i : Fin d.rank) :
|
| 43 |
+
SquarefreeExpression (Fin m) ((ℓ+L)+L) := (d.2.2.2 i).1.expression h d.1 d.2.1
|
| 44 |
+
|
| 45 |
+
def WellFormed (d : WitnessTemplateCode ℓ L J t m) (h : ℕ) : Prop :=
|
| 46 |
+
Function.Injective d.selected ∧
|
| 47 |
+
(∀ i, d.linear i=false → d.modulus i=d.selected i) ∧
|
| 48 |
+
(∀ i, d.linear i=false → d.selected i ∉ (d.expression h i).support) ∧
|
| 49 |
+
(∀ i, d.linear i=true → d.modulus i≠d.selected i) ∧
|
| 50 |
+
(∀ i j, i<j → d.selected j ∉ insert (d.modulus i) (d.expression h i).support)
|
| 51 |
+
|
| 52 |
+
noncomputable def embedding (d : WitnessTemplateCode ℓ L J t m) (h : ℕ) (hd : d.WellFormed h) :
|
| 53 |
+
Fin d.rank ↪ Fin m := ⟨d.selected,hd.1⟩
|
| 54 |
+
noncomputable def system (d : WitnessTemplateCode ℓ L J t m) (h : ℕ) (hd : d.WellFormed h) :
|
| 55 |
+
TriangularExpressions (d.embedding h hd) ((ℓ+L)+L) where
|
| 56 |
+
expression := d.expression h
|
| 57 |
+
modulus := d.modulus
|
| 58 |
+
linear := d.linear
|
| 59 |
+
divisor_modulus := hd.2.1
|
| 60 |
+
divisor_own_absent := hd.2.2.1
|
| 61 |
+
linear_modulus_ne := hd.2.2.2.1
|
| 62 |
+
future_absent := hd.2.2.2.2
|
| 63 |
+
|
| 64 |
+
lemma wellFormed_of_relabel (d : WitnessTemplateCode ℓ L J t m) (h : ℕ)
|
| 65 |
+
{α : Type*} [DecidableEq α] (v : Fin m ↪ α) (e : Fin d.rank ↪ α)
|
| 66 |
+
(q : TriangularExpressions e ((ℓ+L)+L))
|
| 67 |
+
(hs : ∀ i, v (d.selected i)=e i)
|
| 68 |
+
(he : ∀ i, (d.expression h i).relabel v=q.expression i)
|
| 69 |
+
(hm : ∀ i, v (d.modulus i)=q.modulus i)
|
| 70 |
+
(hl : ∀ i, d.linear i=q.linear i) : d.WellFormed h := by
|
| 71 |
+
have hinj : Function.Injective d.selected := by
|
| 72 |
+
intro i j hij
|
| 73 |
+
apply e.injective
|
| 74 |
+
rw [←hs i,←hs j,hij]
|
| 75 |
+
let e' : Fin d.rank ↪ Fin m := ⟨d.selected,hinj⟩
|
| 76 |
+
let c := q.ofRelabel v e' hs (d.expression h) d.modulus he hm
|
| 77 |
+
refine ⟨hinj,?_,?_,?_,?_⟩
|
| 78 |
+
· intro i hi
|
| 79 |
+
exact c.divisor_modulus i (by simpa only [c,TriangularExpressions.ofRelabel,←hl] using hi)
|
| 80 |
+
· intro i hi
|
| 81 |
+
exact c.divisor_own_absent i (by simpa only [c,TriangularExpressions.ofRelabel,←hl] using hi)
|
| 82 |
+
· intro i hi
|
| 83 |
+
exact c.linear_modulus_ne i (by simpa only [c,TriangularExpressions.ofRelabel,←hl] using hi)
|
| 84 |
+
· exact c.future_absent
|
| 85 |
+
|
| 86 |
+
lemma system_admissible_of_relabel (d : WitnessTemplateCode ℓ L J t m) (h : ℕ)
|
| 87 |
+
(hd : d.WellFormed h) {α : Type*} [DecidableEq α]
|
| 88 |
+
(v : Fin m ↪ α) (e : Fin d.rank ↪ α) (q : TriangularExpressions e ((ℓ+L)+L))
|
| 89 |
+
(hs : ∀ i, v (d.selected i)=e i)
|
| 90 |
+
(he : ∀ i, (d.expression h i).relabel v=q.expression i)
|
| 91 |
+
(hm : ∀ i, v (d.modulus i)=q.modulus i)
|
| 92 |
+
(hl : ∀ i, d.linear i=q.linear i)
|
| 93 |
+
(P K : ℝ) (x : α → ℕ) (hx : q.Admissible P K x) :
|
| 94 |
+
(d.system h hd).Admissible P K (fun a => x (v a)) := by
|
| 95 |
+
intro i
|
| 96 |
+
have hi := hx i
|
| 97 |
+
change (if d.linear i then
|
| 98 |
+
ArithmeticClause.linear ((d.expression h i).linearCoeff (d.selected i) (fun a => (x (v a):ℤ)))
|
| 99 |
+
((d.expression h i).constantTerm (d.selected i) (fun a => (x (v a):ℤ))) (x (v (d.modulus i)))
|
| 100 |
+
else ArithmeticClause.divisor ((d.expression h i).eval (fun a => (x (v a):ℤ)))).Holds P K (x (v (d.selected i)))
|
| 101 |
+
rw [←SquarefreeExpression.linearCoeff_relabel (d.expression h i) v (fun a => (x a:ℤ)) (d.selected i),
|
| 102 |
+
←SquarefreeExpression.constant_relabel (d.expression h i) v (fun a => (x a:ℤ)) (d.selected i),
|
| 103 |
+
←SquarefreeExpression.eval_relabel (d.expression h i) v (fun a => (x a:ℤ)),hs i,hm i,he i,hl i]
|
| 104 |
+
exact hi
|
| 105 |
+
|
| 106 |
+
lemma descriptor_card (ℓ L t m : ℕ) :
|
| 107 |
+
Fintype.card (WitnessTestDescriptor ℓ L t m)=
|
| 108 |
+
(t^2*2*(L+1)^3*(ℓ+1)^2)*m^2*2 := by
|
| 109 |
+
simp only [WitnessTestDescriptor,Fintype.card_prod,Fintype.card_bool,Fintype.card_fin,
|
| 110 |
+
WitnessTestShape.card]
|
| 111 |
+
ring
|
| 112 |
+
|
| 113 |
+
lemma card_le (ℓ L J t m : ℕ) :
|
| 114 |
+
Fintype.card (WitnessTemplateCode ℓ L J t m) ≤
|
| 115 |
+
Fintype.card (WitnessMetadata ℓ L t)*(m+1)^(Fintype.card (WitnessCodeSlot ℓ L J t)) *
|
| 116 |
+
((t+1)*(Fintype.card (WitnessTestDescriptor ℓ L t m)+1)^t) := by
|
| 117 |
+
have hc : Fintype.card (WitnessTemplateCode ℓ L J t m) =
|
| 118 |
+
Fintype.card (WitnessMetadata ℓ L t)*(m+1)^(Fintype.card (WitnessCodeSlot ℓ L J t)) *
|
| 119 |
+
(∑ k : Fin (t+1), (Fintype.card (WitnessTestDescriptor ℓ L t m))^k.val) := by
|
| 120 |
+
simp only [WitnessTemplateCode,Fintype.card_prod,Fintype.card_fun,Fintype.card_option,
|
| 121 |
+
Fintype.card_fin,Fintype.card_sigma]
|
| 122 |
+
ring
|
| 123 |
+
rw [hc]
|
| 124 |
+
apply Nat.mul_le_mul_left
|
| 125 |
+
calc
|
| 126 |
+
_ ≤ ∑ k : Fin (t+1), (Fintype.card (WitnessTestDescriptor ℓ L t m)+1)^t := by
|
| 127 |
+
apply sum_le_sum
|
| 128 |
+
intro k hk
|
| 129 |
+
exact (Nat.pow_le_pow_left (Nat.le_succ _) k.val).trans
|
| 130 |
+
(Nat.pow_le_pow_right (n:=Fintype.card (WitnessTestDescriptor ℓ L t m)+1)
|
| 131 |
+
(Nat.succ_pos _) (Nat.lt_succ_iff.mp k.isLt))
|
| 132 |
+
_ = _ := by simp
|
| 133 |
+
|
| 134 |
+
end WitnessTemplateCode
|
| 135 |
+
end OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 136 |
+
|
| 137 |
+
end
|
| 138 |
+
|
| 139 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/WitnessTestShape.lean
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.Symbolic
|
| 2 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.WitnessConfiguration
|
| 3 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.SpecSegment
|
| 4 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.RelabelAppend
|
| 5 |
+
|
| 6 |
+
namespace OAI
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
open scoped BigOperators
|
| 10 |
+
open Finset
|
| 11 |
+
open Finset Classical
|
| 12 |
+
open Filter
|
| 13 |
+
open Finset Classical Filter
|
| 14 |
+
open scoped Topology
|
| 15 |
+
|
| 16 |
+
namespace OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 17 |
+
open OrdinaryCorrelations.SignedTrace OrdinaryCorrelations.NumericalSubtrees
|
| 18 |
+
open OrdinaryCorrelations.ArithmeticSaving OrdinaryCorrelations.SharedSlotPatterns
|
| 19 |
+
open Finset Classical
|
| 20 |
+
|
| 21 |
+
structure WitnessTestShape (ℓ L t : ℕ) where
|
| 22 |
+
witness : Fin t
|
| 23 |
+
other : Fin t
|
| 24 |
+
compare : Bool
|
| 25 |
+
a : Fin (L+1)
|
| 26 |
+
b : Fin (L+1)
|
| 27 |
+
c : Fin (L+1)
|
| 28 |
+
lineA : Fin (ℓ+1)
|
| 29 |
+
lineB : Fin (ℓ+1)
|
| 30 |
+
deriving DecidableEq
|
| 31 |
+
|
| 32 |
+
namespace WitnessTestShape
|
| 33 |
+
noncomputable def equiv (ℓ L t : ℕ) : WitnessTestShape ℓ L t ≃
|
| 34 |
+
Fin t × Fin t × Bool × Fin (L+1) × Fin (L+1) × Fin (L+1) × Fin (ℓ+1) × Fin (ℓ+1) :=
|
| 35 |
+
{ toFun d := (d.witness,d.other,d.compare,d.a,d.b,d.c,d.lineA,d.lineB)
|
| 36 |
+
invFun z := ⟨z.1,z.2.1,z.2.2.1,z.2.2.2.1,z.2.2.2.2.1,z.2.2.2.2.2.1,
|
| 37 |
+
z.2.2.2.2.2.2.1,z.2.2.2.2.2.2.2⟩
|
| 38 |
+
left_inv _ := rfl
|
| 39 |
+
right_inv _ := rfl }
|
| 40 |
+
noncomputable instance (ℓ L t : ℕ) : Fintype (WitnessTestShape ℓ L t) :=
|
| 41 |
+
Fintype.ofEquiv _ (equiv ℓ L t).symm
|
| 42 |
+
|
| 43 |
+
variable {α β : Type*} [DecidableEq α] [DecidableEq β] {ℓ L J t : ℕ}
|
| 44 |
+
|
| 45 |
+
noncomputable def expression (d : WitnessTestShape ℓ L t) (h : ℕ)
|
| 46 |
+
(m : WitnessMetadata ℓ L t) (p : WitnessCodeSlot ℓ L J t → Option α) :
|
| 47 |
+
SquarefreeExpression α ((ℓ+L)+L) :=
|
| 48 |
+
if d.compare then
|
| 49 |
+
((PatternExpression.lineSegment h m.1 (fun k => p (.inl k)) d.lineA d.lineB).append
|
| 50 |
+
(PatternExpression.specSegment h (m.2.2 d.witness).2
|
| 51 |
+
(fun k => p (.inr (.inr (.inl (d.witness,k))))) d.a.val d.b.val)).append
|
| 52 |
+
(PatternExpression.specSegment h (m.2.2 d.other).2
|
| 53 |
+
(fun k => p (.inr (.inr (.inl (d.other,k))))) 0 d.c.val).neg
|
| 54 |
+
else ((SquarefreeExpression.zeroExpression α ℓ).append
|
| 55 |
+
(PatternExpression.specSegment h (m.2.2 d.witness).2
|
| 56 |
+
(fun k => p (.inr (.inr (.inl (d.witness,k))))) d.a.val d.b.val)).append
|
| 57 |
+
(SquarefreeExpression.zeroExpression α L)
|
| 58 |
+
|
| 59 |
+
lemma expression_relabel (d : WitnessTestShape ℓ L t) (h : ℕ)
|
| 60 |
+
(m : WitnessMetadata ℓ L t) (p : WitnessCodeSlot ℓ L J t → Option α) (e : α ↪ β) :
|
| 61 |
+
(d.expression h m p).relabel e=d.expression h m (fun s => (p s).map e) := by
|
| 62 |
+
unfold expression
|
| 63 |
+
split_ifs <;> simp only [SquarefreeExpression.relabel_append,
|
| 64 |
+
SquarefreeExpression.relabel_neg,SquarefreeExpression.relabel_zero,
|
| 65 |
+
PatternExpression.specSegment_relabel,PatternExpression.lineSegment_relabel]
|
| 66 |
+
|
| 67 |
+
lemma card (ℓ L t : ℕ) :
|
| 68 |
+
Fintype.card (WitnessTestShape ℓ L t)=t^2*2*(L+1)^3*(ℓ+1)^2 := by
|
| 69 |
+
rw [Fintype.card_congr (equiv ℓ L t)]
|
| 70 |
+
simp only [Fintype.card_prod,Fintype.card_bool,Fintype.card_fin]
|
| 71 |
+
ring
|
| 72 |
+
end WitnessTestShape
|
| 73 |
+
|
| 74 |
+
variable {S : PrimeSystem} {B τ C₀ : ℝ} {D : S.DivisorFamily B τ C₀} {h ℓ L t : ℕ}
|
| 75 |
+
namespace WitnessConfiguration
|
| 76 |
+
variable (x : WitnessConfiguration D h ℓ L t)
|
| 77 |
+
|
| 78 |
+
noncomputable def shape {j : Fin t} : x.family.Test j → WitnessTestShape ℓ L t
|
| 79 |
+
| .extra | .tail _ =>
|
| 80 |
+
{ witness := j, other := j, compare := false
|
| 81 |
+
a := ⟨(x.family.witness j).spec.suffix.val,by
|
| 82 |
+
have := (x.family.witness j).spec.suffix.isLt
|
| 83 |
+
have := (x.family.witness j).spec.length_le
|
| 84 |
+
omega⟩
|
| 85 |
+
b := ⟨(x.family.witness j).spec.length,Nat.lt_succ_of_le (x.family.witness j).spec.length_le⟩
|
| 86 |
+
c := 0, lineA := 0, lineB := 0 }
|
| 87 |
+
| .compare i _ r hi =>
|
| 88 |
+
{ witness := j, other := i, compare := true
|
| 89 |
+
a := 0
|
| 90 |
+
b := ⟨(x.family.witness j).spec.tailStart.val,by
|
| 91 |
+
have := (x.family.witness j).spec.tailStart.isLt
|
| 92 |
+
have := (x.family.witness j).spec.length_le
|
| 93 |
+
omega⟩
|
| 94 |
+
c := ⟨((x.family.witness i).spec.activity r hi).val,by
|
| 95 |
+
have := ((x.family.witness i).spec.activity r hi).isLt
|
| 96 |
+
have := (x.family.witness i).spec.length_le
|
| 97 |
+
omega⟩
|
| 98 |
+
lineA := (x.family.witness i).index
|
| 99 |
+
lineB := (x.family.witness j).index }
|
| 100 |
+
|
| 101 |
+
lemma shape_expression {j : Fin t} (d : x.family.Test j) :
|
| 102 |
+
(x.shape d).expression h x.metadata x.primeCode=d.symbolic x.labels := by
|
| 103 |
+
have hs (j : Fin t) (a b : ℕ) :
|
| 104 |
+
PatternExpression.specSegment h (x.metadata.2.2 j).2
|
| 105 |
+
(fun k => x.primeCode (.inr (.inr (.inl (j,k))))) a b =
|
| 106 |
+
(x.family.witness j).spec.segmentExpression a b :=
|
| 107 |
+
PatternExpression.specSegment_source _ a b
|
| 108 |
+
have hl (a b : Fin (ℓ+1)) :
|
| 109 |
+
PatternExpression.lineSegment h x.metadata.1 (fun k => x.primeCode (.inl k)) a b=
|
| 110 |
+
LineExpression.segment x.line x.labels a b :=
|
| 111 |
+
PatternExpression.lineSegment_source x.line x.labels a b
|
| 112 |
+
cases d with
|
| 113 |
+
| extra | tail => simp only [shape,WitnessTestShape.expression,Bool.false_eq_true,ite_false,
|
| 114 |
+
hs,PrivateFamily.Test.symbolic]
|
| 115 |
+
| compare i q r hi => simp only [shape,WitnessTestShape.expression,ite_true,Fin.val_zero,
|
| 116 |
+
hs,hl,PrivateFamily.Test.symbolic]
|
| 117 |
+
|
| 118 |
+
lemma pattern_shape_expression {j : Fin t} (d : x.family.Test j) :
|
| 119 |
+
((x.shape d).expression h x.metadata (pattern x.primeCode)).relabel (values x.primeCode)=
|
| 120 |
+
d.symbolic x.labels := by
|
| 121 |
+
rw [WitnessTestShape.expression_relabel]
|
| 122 |
+
simp only [decode_pattern]
|
| 123 |
+
exact x.shape_expression d
|
| 124 |
+
|
| 125 |
+
end WitnessConfiguration
|
| 126 |
+
end OrdinaryCorrelations.GraphKernel.PrimeSystem
|
| 127 |
+
|
| 128 |
+
end
|
| 129 |
+
|
| 130 |
+
end OAI
|
lean/OAI/NumberTheory/OrdinaryCorrelations/HighTrace/ZeroExpression.lean
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.OrdinaryCorrelations.HighTrace.SquarefreeExpression
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
noncomputable section
|
| 6 |
+
open scoped BigOperators
|
| 7 |
+
open Finset
|
| 8 |
+
open Finset Classical
|
| 9 |
+
open Filter
|
| 10 |
+
open Finset Classical Filter
|
| 11 |
+
open scoped Topology
|
| 12 |
+
|
| 13 |
+
namespace OrdinaryCorrelations.ArithmeticSaving.SquarefreeExpression
|
| 14 |
+
open Finset Classical
|
| 15 |
+
variable {ι : Type*} [DecidableEq ι] {E F : ℕ}
|
| 16 |
+
|
| 17 |
+
noncomputable def zeroExpression (ι : Type*) [DecidableEq ι] (E : ℕ) : SquarefreeExpression ι E where
|
| 18 |
+
factors _ := ∅
|
| 19 |
+
coefficient _ := 0
|
| 20 |
+
|
| 21 |
+
noncomputable def append (d : SquarefreeExpression ι E) (e : SquarefreeExpression ι F) :
|
| 22 |
+
SquarefreeExpression ι (E+F) where
|
| 23 |
+
factors := Fin.addCases d.factors e.factors
|
| 24 |
+
coefficient := Fin.addCases d.coefficient e.coefficient
|
| 25 |
+
|
| 26 |
+
noncomputable def neg (d : SquarefreeExpression ι E) : SquarefreeExpression ι E where
|
| 27 |
+
factors := d.factors
|
| 28 |
+
coefficient i := -d.coefficient i
|
| 29 |
+
|
| 30 |
+
@[simp] lemma eval_zero (x : ι → ℤ) : (zeroExpression ι E).eval x=0 := by simp [eval,zeroExpression]
|
| 31 |
+
@[simp] lemma coefficient_zero (q : ι) (x : ι → ℤ) : (zeroExpression ι E).linearCoeff q x=0 := by
|
| 32 |
+
simp [linearCoeff,zeroExpression]
|
| 33 |
+
@[simp] lemma support_zero : (zeroExpression ι E).support=∅ := by ext v; simp [support,zeroExpression]
|
| 34 |
+
|
| 35 |
+
@[simp] lemma eval_append (d : SquarefreeExpression ι E) (e : SquarefreeExpression ι F) (x : ι → ℤ) :
|
| 36 |
+
(d.append e).eval x=d.eval x+e.eval x := by
|
| 37 |
+
unfold eval
|
| 38 |
+
rw [Fin.sum_univ_add]
|
| 39 |
+
simp only [append,Fin.addCases_left,Fin.addCases_right]
|
| 40 |
+
|
| 41 |
+
@[simp] lemma coefficient_append (d : SquarefreeExpression ι E) (e : SquarefreeExpression ι F)
|
| 42 |
+
(q : ι) (x : ι → ℤ) : (d.append e).linearCoeff q x=d.linearCoeff q x+e.linearCoeff q x := by
|
| 43 |
+
unfold linearCoeff
|
| 44 |
+
rw [Fin.sum_univ_add]
|
| 45 |
+
simp only [append,Fin.addCases_left,Fin.addCases_right]
|
| 46 |
+
|
| 47 |
+
@[simp] lemma eval_neg (d : SquarefreeExpression ι E) (x : ι → ℤ) : d.neg.eval x= -d.eval x := by
|
| 48 |
+
simp only [eval,neg,neg_mul,sum_neg_distrib]
|
| 49 |
+
|
| 50 |
+
@[simp] lemma coefficient_neg (d : SquarefreeExpression ι E) (q : ι) (x : ι → ℤ) :
|
| 51 |
+
d.neg.linearCoeff q x= -d.linearCoeff q x := by
|
| 52 |
+
unfold linearCoeff
|
| 53 |
+
rw [←sum_neg_distrib]
|
| 54 |
+
apply sum_congr rfl
|
| 55 |
+
intro i hi
|
| 56 |
+
simp only [neg,neg_mul]
|
| 57 |
+
split_ifs <;> simp
|
| 58 |
+
|
| 59 |
+
@[simp] lemma support_neg (d : SquarefreeExpression ι E) : d.neg.support=d.support := by
|
| 60 |
+
simp only [support,neg,neg_eq_zero]
|
| 61 |
+
|
| 62 |
+
@[simp] lemma support_append (d : SquarefreeExpression ι E) (e : SquarefreeExpression ι F) :
|
| 63 |
+
(d.append e).support=d.support ∪ e.support := by
|
| 64 |
+
ext v
|
| 65 |
+
simp only [support,mem_biUnion,mem_univ,true_and,mem_union]
|
| 66 |
+
constructor
|
| 67 |
+
· rintro ⟨i,hi⟩
|
| 68 |
+
refine Fin.addCases ?_ ?_ i hi
|
| 69 |
+
· intro j hj; exact Or.inl ⟨j,by simpa only [append,Fin.addCases_left] using hj⟩
|
| 70 |
+
· intro j hj; exact Or.inr ⟨j,by simpa only [append,Fin.addCases_right] using hj⟩
|
| 71 |
+
· rintro (⟨i,hi⟩|⟨i,hi⟩)
|
| 72 |
+
· exact ⟨i.castAdd F,by simpa only [append,Fin.addCases_left] using hi⟩
|
| 73 |
+
· exact ⟨i.natAdd E,by simpa only [append,Fin.addCases_right] using hi⟩
|
| 74 |
+
|
| 75 |
+
lemma factors_append_le (d : SquarefreeExpression ι E) (e : SquarefreeExpression ι F) (J : ℕ)
|
| 76 |
+
(hd : ∀ i, (d.factors i).card ≤ J) (he : ∀ i, (e.factors i).card ≤ J) :
|
| 77 |
+
∀ i, ((d.append e).factors i).card ≤ J := by
|
| 78 |
+
intro i
|
| 79 |
+
refine Fin.addCases ?_ ?_ i
|
| 80 |
+
· intro j; simpa only [append,Fin.addCases_left] using hd j
|
| 81 |
+
· intro j; simpa only [append,Fin.addCases_right] using he j
|
| 82 |
+
|
| 83 |
+
lemma abs_coefficient_append_le (d : SquarefreeExpression ι E) (e : SquarefreeExpression ι F) (H : ℝ)
|
| 84 |
+
(hd : ∀ i, |(d.coefficient i:ℝ)| ≤ H) (he : ∀ i, |(e.coefficient i:ℝ)| ≤ H) :
|
| 85 |
+
∀ i, |((d.append e).coefficient i:ℝ)| ≤ H := by
|
| 86 |
+
intro i
|
| 87 |
+
refine Fin.addCases ?_ ?_ i
|
| 88 |
+
· intro j; simpa only [append,Fin.addCases_left] using hd j
|
| 89 |
+
· intro j; simpa only [append,Fin.addCases_right] using he j
|
| 90 |
+
|
| 91 |
+
end OrdinaryCorrelations.ArithmeticSaving.SquarefreeExpression
|
| 92 |
+
|
| 93 |
+
end
|
| 94 |
+
|
| 95 |
+
end OAI
|
lean/OAI/NumberTheory/Ostmann/All.lean
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.ArithmeticPatternNormRate
|
| 2 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.ArithmeticSlotProducts
|
| 3 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.BulkKernelCellError
|
| 4 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.BulkLogPairComparison
|
| 5 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.BulkLogWeightedCellComparison
|
| 6 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.BulkPageProjection
|
| 7 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.BulkStatisticBound
|
| 8 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.CRTInternalLines
|
| 9 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.CRTLineProbabilities
|
| 10 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.CompensatedHistoryRate
|
| 11 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.ForwardHistoryRate
|
| 12 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.GlobalHistoryPairDecay
|
| 13 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.HarmonicGraphCancellation
|
| 14 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.IdealSmoothHistoryNorm
|
| 15 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.JointLineComparison
|
| 16 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.LeafFrequencySupport
|
| 17 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.LeafModulusRanges
|
| 18 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeFullHarmonicCost
|
| 19 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeStep
|
| 20 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingArithmeticPageDeletion
|
| 21 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingArithmeticScale
|
| 22 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingBulkLogVariation
|
| 23 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingBulkSupport
|
| 24 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingCompleteIntegerCells
|
| 25 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingConstructedProductStep
|
| 26 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingEarlyTemplateCaps
|
| 27 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingFieldBulkComparison
|
| 28 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingFirstNodeWindows
|
| 29 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingFrequencyEnergy
|
| 30 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingFullPair
|
| 31 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingJointSquareLoss
|
| 32 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingMixedResidueRate
|
| 33 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingNormalizedEnergyBound
|
| 34 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalEnergyBound
|
| 35 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalGiantComparison
|
| 36 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalLogGiantWeight
|
| 37 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalPair
|
| 38 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingPairAdaptiveSupport
|
| 39 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternGoodMaskedPriors
|
| 40 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternHalfLogTwoPrimeIntegratedRate
|
| 41 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLines
|
| 42 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogLeafBridge
|
| 43 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogTwoPrimeIntegratedRate
|
| 44 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMainGain
|
| 45 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternSameNormArithmetic
|
| 46 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternSignedArithmetic
|
| 47 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternSignedMajorant
|
| 48 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternWholeShellArithmetic
|
| 49 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternWindowWeightedWholeShell
|
| 50 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternWindowWholeShellArithmetic
|
| 51 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternWordArithmetic
|
| 52 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimeInternalNorm
|
| 53 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimeResidueRate
|
| 54 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingRealWeight
|
| 55 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingRegularOuterComparison
|
| 56 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingSampleDiagonalRate
|
| 57 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingSelectedDiagonalDecay
|
| 58 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingSelectedEarlyDiagonalDecay
|
| 59 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingSelectedPhaseStatistic
|
| 60 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingSelectedPrimeEnergy
|
| 61 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingSelectedPrimeStatistic
|
| 62 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingSelectedStatistic
|
| 63 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingSeparatedOuterComparison
|
| 64 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingSmoothPrimeComparison
|
| 65 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingSpectatorRangeUnits
|
| 66 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingSupportedOuterComparison
|
| 67 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingTaggedPrimeCore
|
| 68 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateMatchedBound
|
| 69 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateNormalizer
|
| 70 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.NaturalScheduleEnergy
|
| 71 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.PeriodicGraphCancellation
|
| 72 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.PrimeIntegerTransfer
|
| 73 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.RangedPairAdmissibility
|
| 74 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.RecursiveArchimedeanCutoff
|
| 75 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.ReducedCoefficientLift
|
| 76 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.ResidueProductSupport
|
| 77 |
+
import OAI.NumberTheory.Ostmann.Arithmetic.SmoothCellRate
|
| 78 |
+
import OAI.NumberTheory.Ostmann.Characters.AnchorDiagonalTotal
|
| 79 |
+
import OAI.NumberTheory.Ostmann.Characters.CharacterCompletedOrderOne
|
| 80 |
+
import OAI.NumberTheory.Ostmann.Characters.CharacterFinalTop
|
| 81 |
+
import OAI.NumberTheory.Ostmann.Characters.MixedGiantIdealization
|
| 82 |
+
import OAI.NumberTheory.Ostmann.Characters.PrimeCorrelationBounds
|
| 83 |
+
import OAI.NumberTheory.Ostmann.Characters.QuartetAllMajorants
|
| 84 |
+
import OAI.NumberTheory.Ostmann.Characters.QuartetFriendlyBound
|
| 85 |
+
import OAI.NumberTheory.Ostmann.Construction.BalancedHalfInitialAmplitude
|
| 86 |
+
import OAI.NumberTheory.Ostmann.Construction.ConstituentFinalComparison
|
| 87 |
+
import OAI.NumberTheory.Ostmann.Construction.ConstituentFourierBridge
|
| 88 |
+
import OAI.NumberTheory.Ostmann.Construction.ConstituentMatchingRate
|
| 89 |
+
import OAI.NumberTheory.Ostmann.Construction.ConstituentOriginalPair
|
| 90 |
+
import OAI.NumberTheory.Ostmann.Construction.ConstituentSelectedProducts
|
| 91 |
+
import OAI.NumberTheory.Ostmann.Construction.DiagonalRegularLift
|
| 92 |
+
import OAI.NumberTheory.Ostmann.Construction.DyadicGraphHistory
|
| 93 |
+
import OAI.NumberTheory.Ostmann.Construction.FinalArithmeticContradiction
|
| 94 |
+
import OAI.NumberTheory.Ostmann.Construction.FinalAsymptoticComparison
|
| 95 |
+
import OAI.NumberTheory.Ostmann.Construction.FinalEnergyCutoff
|
| 96 |
+
import OAI.NumberTheory.Ostmann.Construction.FinalOneSidedFactor
|
| 97 |
+
import OAI.NumberTheory.Ostmann.Construction.FiniteMatchedFubini
|
| 98 |
+
import OAI.NumberTheory.Ostmann.Construction.FiniteScheduledTemplate
|
| 99 |
+
import OAI.NumberTheory.Ostmann.Construction.FormulaHistoryGraphBound
|
| 100 |
+
import OAI.NumberTheory.Ostmann.Construction.FrozenOriginalBulk
|
| 101 |
+
import OAI.NumberTheory.Ostmann.Construction.FullPrimeRatioPair
|
| 102 |
+
import OAI.NumberTheory.Ostmann.Construction.HarmonicMatchedEnergy
|
| 103 |
+
import OAI.NumberTheory.Ostmann.Construction.HistoryLineComparison
|
| 104 |
+
import OAI.NumberTheory.Ostmann.Construction.HistoryResidueData
|
| 105 |
+
import OAI.NumberTheory.Ostmann.Construction.InitialOutsideTransform
|
| 106 |
+
import OAI.NumberTheory.Ostmann.Construction.InitialProductSize
|
| 107 |
+
import OAI.NumberTheory.Ostmann.Construction.InitialWordSupport
|
| 108 |
+
import OAI.NumberTheory.Ostmann.Construction.IntegerGridSupport
|
| 109 |
+
import OAI.NumberTheory.Ostmann.Construction.NaturalBadDiagonal
|
| 110 |
+
import OAI.NumberTheory.Ostmann.Construction.OriginalKernelComparison
|
| 111 |
+
import OAI.NumberTheory.Ostmann.Construction.OriginalPrimeRestoration
|
| 112 |
+
import OAI.NumberTheory.Ostmann.Construction.PhaseGiantInitialStatistic
|
| 113 |
+
import OAI.NumberTheory.Ostmann.Construction.PrimeCutoffFactors
|
| 114 |
+
import OAI.NumberTheory.Ostmann.Construction.PrimeTupleDiagonal
|
| 115 |
+
import OAI.NumberTheory.Ostmann.Construction.RepeatedPivotPhase
|
| 116 |
+
import OAI.NumberTheory.Ostmann.Construction.ScheduledAnchorDiagonalSplit
|
| 117 |
+
import OAI.NumberTheory.Ostmann.Construction.ScheduledAnchorEnergyBound
|
| 118 |
+
import OAI.NumberTheory.Ostmann.Construction.ScheduledDistinctSources
|
| 119 |
+
import OAI.NumberTheory.Ostmann.Construction.ScheduledFinalBound
|
| 120 |
+
import OAI.NumberTheory.Ostmann.Construction.ScheduledFinalPrimeComparison
|
| 121 |
+
import OAI.NumberTheory.Ostmann.Construction.ScheduledIntervalStep
|
| 122 |
+
import OAI.NumberTheory.Ostmann.Construction.ScheduledNonanchorDecay
|
| 123 |
+
import OAI.NumberTheory.Ostmann.Construction.ScheduledSpectatorComparison
|
| 124 |
+
import OAI.NumberTheory.Ostmann.Construction.ScheduledSpectatorProducts
|
| 125 |
+
import OAI.NumberTheory.Ostmann.Construction.SelectedAnchorEnergyBound
|
| 126 |
+
import OAI.NumberTheory.Ostmann.Construction.SelectedAnchorSupportedEnergy
|
| 127 |
+
import OAI.NumberTheory.Ostmann.Construction.SelectedCutoffData
|
| 128 |
+
import OAI.NumberTheory.Ostmann.Construction.SelectedFinalNaturalPrimeComparison
|
| 129 |
+
import OAI.NumberTheory.Ostmann.Construction.SelectedFinalPrimeComparison
|
| 130 |
+
import OAI.NumberTheory.Ostmann.Construction.SelectedNodeSources
|
| 131 |
+
import OAI.NumberTheory.Ostmann.Construction.SelectedNonanchorDecay
|
| 132 |
+
import OAI.NumberTheory.Ostmann.Construction.SmoothGiantLossBudget
|
| 133 |
+
import OAI.NumberTheory.Ostmann.Construction.SmoothMatchedPrior
|
| 134 |
+
import OAI.NumberTheory.Ostmann.Construction.UniformInitialAmplitude
|
| 135 |
+
import OAI.NumberTheory.Ostmann.Construction.WeightedRegularNorm
|
| 136 |
+
import OAI.NumberTheory.Ostmann.PaperMain
|
| 137 |
+
import OAI.NumberTheory.Ostmann.Preliminaries.Reduction
|
| 138 |
+
import OAI.NumberTheory.Ostmann.Quadratic.CommonCenterFromApproximation
|
| 139 |
+
import OAI.NumberTheory.Ostmann.Quadratic.KernelPopulationDiscard
|
| 140 |
+
import OAI.NumberTheory.Ostmann.Quadratic.QuadraticIntervalInverse
|
| 141 |
+
import OAI.NumberTheory.Ostmann.Quadratic.QuadraticNegligibleError
|
| 142 |
+
import OAI.NumberTheory.Ostmann.Quadratic.QuadraticSecondCorrections
|
| 143 |
+
import OAI.NumberTheory.Ostmann.Quadratic.QuadraticVaryingSmooth
|
| 144 |
+
import OAI.NumberTheory.Ostmann.Quadratic.QuadraticWholeDivisorBound
|
| 145 |
+
import OAI.NumberTheory.Ostmann.QuadraticCenter.RootSeparation
|
| 146 |
+
import OAI.NumberTheory.Ostmann.Tree.PairMoment
|
| 147 |
+
import OAI.NumberTheory.Ostmann.ZeroDensity.ActualPrincipalPNT
|
| 148 |
+
import OAI.NumberTheory.Ostmann.ZeroDensity.ArithmeticProgressionRows
|
| 149 |
+
import OAI.NumberTheory.Ostmann.ZeroDensity.BulkAbsoluteDensity
|
| 150 |
+
import OAI.NumberTheory.Ostmann.ZeroDensity.CharacterContourHeights
|
| 151 |
+
import OAI.NumberTheory.Ostmann.ZeroDensity.DensityFiniteIntegralEnergy
|
| 152 |
+
import OAI.NumberTheory.Ostmann.ZeroDensity.NonexceptionalRieszDecay
|
lean/OAI/NumberTheory/Ostmann/Arithmetic/AccidentalDivisibility.lean
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
noncomputable section
|
| 6 |
+
namespace Ostmann.Arithmetic.AccidentalDivisibility
|
| 7 |
+
open scoped BigOperators
|
| 8 |
+
|
| 9 |
+
theorem primeFactors_card_log_bound (N : ℕ) (hN : N ≠ 0) :
|
| 10 |
+
(N.primeFactors.card : ℝ) * Real.log 2 ≤ Real.log N := by
|
| 11 |
+
have hpow : 2 ^ N.primeFactors.card ≤ N := by
|
| 12 |
+
calc
|
| 13 |
+
_ = ∏ _p ∈ N.primeFactors, 2 := by simp
|
| 14 |
+
_ ≤ ∏ p ∈ N.primeFactors, p := Finset.prod_le_prod fun p hp =>
|
| 15 |
+
(Nat.prime_of_mem_primeFactors hp).two_le
|
| 16 |
+
_ ≤ N := Nat.le_of_dvd (Nat.pos_of_ne_zero hN) (Nat.prod_primeFactors_dvd N)
|
| 17 |
+
have hreal : (2:ℝ)^N.primeFactors.card ≤ (N:ℝ) := by exact_mod_cast hpow
|
| 18 |
+
have hlog := Real.log_le_log (by positivity : 0 < (2:ℝ)^N.primeFactors.card) hreal
|
| 19 |
+
simpa only [Real.log_pow] using hlog
|
| 20 |
+
|
| 21 |
+
theorem weighted_prime_divisors (N : ℕ) (hN : N ≠ 0) (S : Finset ℕ)
|
| 22 |
+
(μ : ℕ → ℝ) {α : ℝ} (hα : 0 ≤ α)
|
| 23 |
+
(hbound : ∀ p ∈ S, μ p ≤ α) :
|
| 24 |
+
(∑ p ∈ S with p.Prime ∧ p ∣ N, μ p) ≤
|
| 25 |
+
α * (Real.log N / Real.log 2) := by
|
| 26 |
+
have hcard : (S.filter fun p => p.Prime ∧ p ∣ N).card ≤ N.primeFactors.card := by
|
| 27 |
+
apply Finset.card_le_card
|
| 28 |
+
intro p hp
|
| 29 |
+
exact Nat.mem_primeFactors.mpr ⟨(Finset.mem_filter.mp hp).2.1,
|
| 30 |
+
(Finset.mem_filter.mp hp).2.2,hN⟩
|
| 31 |
+
have hlog2 : 0 < Real.log 2 := Real.log_pos (by norm_num)
|
| 32 |
+
calc
|
| 33 |
+
_ ≤ ∑ _p ∈ S with _p.Prime ∧ _p ∣ N, α :=
|
| 34 |
+
Finset.sum_le_sum fun p hp => hbound p (Finset.mem_filter.mp hp).1
|
| 35 |
+
_ = ((S.filter fun p => p.Prime ∧ p ∣ N).card : ℝ) * α := by simp
|
| 36 |
+
_ ≤ (N.primeFactors.card:ℝ)*α :=
|
| 37 |
+
mul_le_mul_of_nonneg_right (by exact_mod_cast hcard) hα
|
| 38 |
+
_ ≤ (Real.log N / Real.log 2)*α := by
|
| 39 |
+
apply mul_le_mul_of_nonneg_right _ hα
|
| 40 |
+
exact (le_div_iff₀ hlog2).2 (primeFactors_card_log_bound N hN)
|
| 41 |
+
_ = _ := mul_comm _ _
|
| 42 |
+
|
| 43 |
+
theorem weighted_polynomial_roots {K : Type*} [CommRing K] [IsDomain K]
|
| 44 |
+
[DecidableEq K] (P : Polynomial K) (hP : P ≠ 0) (S : Finset K)
|
| 45 |
+
(μ : K → ℝ) {α : ℝ} (hα : 0 ≤ α) (hbound : ∀ x ∈ S, μ x ≤ α) :
|
| 46 |
+
(∑ x ∈ S with P.eval x = 0, μ x) ≤ (P.natDegree:ℝ)*α := by
|
| 47 |
+
have hcard : (S.filter fun x => P.eval x=0).card ≤ P.natDegree := by
|
| 48 |
+
calc
|
| 49 |
+
_ ≤ P.roots.toFinset.card := Finset.card_le_card fun x hx => by
|
| 50 |
+
simpa [Polynomial.mem_roots hP, Polynomial.IsRoot] using
|
| 51 |
+
(Finset.mem_filter.mp hx).2
|
| 52 |
+
_ ≤ P.roots.card := Multiset.toFinset_card_le _
|
| 53 |
+
_ ≤ P.natDegree := P.card_roots'
|
| 54 |
+
calc
|
| 55 |
+
_ ≤ ∑ _x ∈ S with P.eval _x=0, α :=
|
| 56 |
+
Finset.sum_le_sum fun x hx => hbound x (Finset.mem_filter.mp hx).1
|
| 57 |
+
_ = ((S.filter fun x => P.eval x=0).card:ℝ)*α := by simp
|
| 58 |
+
_ ≤ (P.natDegree:ℝ)*α :=
|
| 59 |
+
mul_le_mul_of_nonneg_right (by exact_mod_cast hcard) hα
|
| 60 |
+
|
| 61 |
+
end Ostmann.Arithmetic.AccidentalDivisibility
|
| 62 |
+
|
| 63 |
+
end
|
| 64 |
+
|
| 65 |
+
end OAI
|