/- Released under Apache-2.0; see adjacent LICENSE. Exact actual reserved-prime completion and elementary short-floor budget. The visible completion constructor adapts the original pinned Reserved.lean; all needed original proof modules are rebuilt unchanged by the wrapper. No smooth-number or prime-supply estimate is assumed or discharged. -/ import EarlyCover import Gaps namespace ReserveBudget noncomputable section open KKFiniteCoreDraft EarlyCover ManuscriptResidues /-- The actual original full real cutoff is a prime family. -/ theorem fullPrimeFamily (y : ℝ) : PrimeFamily (primeCutoff y) := by intro p hp exact (Finset.mem_filter.mp hp).2 /-- The finite injection uses the literal early-uncovered interval and actual reserved primes. -/ theorem actual_reserved_injection (m : ℕ) (y z0 z1 : ℝ) (hcard : R m y z0 z1 ≤ (reservedPrimes y).card) : ∃ f : {i : ℕ // i ∈ uncoveredSet m y z0 z1} → {p : ℕ // p ∈ reservedPrimes y}, Function.Injective f := by rw [uncovered_eq_core] exact KKFiniteCoreProof.reserved_injection (earlyPrimes y) (reservedPrimes y) (choice z0 z1) m (by simpa only [R, uncovered_eq_core] using hcard) /-- Distinct assigned primes are explicit: b(f(i))=i, while every early residue is preserved. -/ theorem actual_reserved_completion (m : ℕ) (y z0 z1 : ℝ) (hcard : R m y z0 z1 ≤ (reservedPrimes y).card) : ∃ (f : {i : ℕ // i ∈ uncoveredSet m y z0 z1} → {p : ℕ // p ∈ reservedPrimes y}) (b : ℕ → ℕ), Function.Injective f ∧ (∀ i, b (f i).val = i.val) ∧ (∀ p, p ∉ reservedPrimes y → b p = choice z0 z1 p) ∧ (∀ p ∈ earlyPrimes y, b p = choice z0 z1 p) ∧ Cover (primeCutoff y) b m := by classical obtain ⟨f, hf⟩ := actual_reserved_injection m y z0 z1 hcard let b : ℕ → ℕ := fun p => if h : ∃ i, (f i).val = p then (Classical.choose h).val else choice z0 z1 p have outside : ∀ p, p ∉ reservedPrimes y → b p = choice z0 z1 p := by intro p hp dsimp [b] rw [dite_eq_right] rintro ⟨i, hi⟩ exact hp (hi ▸ (f i).property) have old : ∀ p ∈ earlyPrimes y, b p = choice z0 z1 p := by intro p hp apply outside exact Finset.disjoint_left.mp (prime_partition y).2 hp have assigned : ∀ i, b (f i).val = i.val := by intro i have he : ∃ j, (f j).val = (f i).val := ⟨i, rfl⟩ dsimp [b] rw [dite_eq_left he] have hx : Classical.choose he = i := hf (Subtype.ext (Classical.choose_spec he)) exact congrArg Subtype.val hx refine ⟨f, b, hf, assigned, outside, old, ?_⟩ rw [← (prime_partition y).1] intro i hi by_cases hc : CoveredAt (earlyPrimes y) (choice z0 z1) i · obtain ⟨p, hp, hpi⟩ := hc exact ⟨p, Finset.mem_union_left _ hp, by simpa only [old p hp] using hpi⟩ · have hui : i ∈ uncoveredSet m y z0 z1 := by rw [uncovered_eq_core] exact Finset.mem_filter.mpr ⟨hi, hc⟩ let u : {i : ℕ // i ∈ uncoveredSet m y z0 z1} := ⟨i, hui⟩ exact ⟨(f u).val, Finset.mem_union_right _ (f u).property, Or.inl (by rw [assigned u])⟩ /-- Conditional finite endpoint on the original full p≤y family, not an analytic theorem. -/ theorem actual_completion_gap (m : ℕ) (y z0 z1 : ℝ) (hcard : R m y z0 z1 ≤ (reservedPrimes y).card) : m + 1 ≤ G2 (primeCutoff y) := by obtain ⟨f, b, hf, ha, ho, he, hc⟩ := actual_reserved_completion m y z0 z1 hcard exact (KKFiniteCoreProof.cover_iff_gap_bound (primeCutoff y) m (fullPrimeFamily y)).mp ⟨b, hc⟩ /-- Existing positive-y threshold already makes sqrt(y)≥48log(y). -/ theorem sqrt_ge_log (y : ℝ) (hy : SieveParameters.threshold ≤ y) : 48 * Real.log y ≤ Real.sqrt y := by have hf := SieveParameters.large_y_facts y hy have ht : 0 < Real.log y := by linarith [hf.2.2.1] have hs : 0 < Real.sqrt y := Real.sqrt_pos.mpr hf.1 have he : Real.exp (Real.log y / 2) = Real.sqrt y := by rw [← Real.log_sqrt hf.1.le, Real.exp_log hs] have hq := Real.quadratic_le_exp_of_nonneg (show 0 ≤ Real.log y / 2 by positivity) rw [he] at hq have hm := mul_nonneg (show 0 ≤ Real.log y - 384 by linarith [hf.2.2.1]) ht.le nlinarith /-- Exact floor(sqrt(y)+2) budget: the original additive2 is not removed. -/ theorem short_floor_budget (y : ℝ) (hy : SieveParameters.threshold ≤ y) : (⌊Real.sqrt y + 2⌋₊ : ℝ) ≤ y / (24 * Real.log y) := by have hf := SieveParameters.large_y_facts y hy have ht : 0 < Real.log y := by linarith [hf.2.2.1] have hs : 0 ≤ Real.sqrt y := Real.sqrt_nonneg y have hs2 : 2 ≤ Real.sqrt y := by nlinarith [Real.sq_sqrt hf.1.le, hf.2.2.2] have h48 := sqrt_ge_log y hy have hdiv : Real.sqrt y + 2 ≤ y / (24 * Real.log y) := by apply (le_div_iff₀ (by positivity : 0 < 24 * Real.log y)).mpr calc _ ≤ (2 * Real.sqrt y) * (24 * Real.log y) := mul_le_mul_of_nonneg_right (by linarith) (by positivity) _ ≤ (Real.sqrt y) ^ 2 := by nlinarith [mul_nonneg hs (sub_nonneg.mpr h48)] _ = y := Real.sq_sqrt hf.1.le exact (Nat.floor_le (show 0 ≤ Real.sqrt y + 2 by positivity)).trans hdiv /-- A literal eventual bound with an exhibited positive threshold, no growth premise. -/ theorem eventual_short_floor_budget : ∃ y0 : ℝ, 0 < y0 ∧ ∀ y : ℝ, y0 ≤ y → (⌊Real.sqrt y + 2⌋₊ : ℝ) ≤ y / (24 * Real.log y) := by refine ⟨SieveParameters.threshold, ?_, short_floor_budget⟩ unfold SieveParameters.threshold exact Real.exp_pos _ /-- The chosen equation13 parameters have the S quarter-budget and the exact short budget. -/ theorem parameter_uncovered_budget (y A : ℝ) (hA : 4 ≤ A) (hy : ManuscriptParameters.threshold A ≤ y) : (R (ManuscriptParameters.m y (ManuscriptParameters.chooseB A)) y (ManuscriptParameters.z0 y A) (ManuscriptParameters.z1 y A) : ℝ) ≤ y / (4 * Real.log y) + y / (24 * Real.log y) + 2 * (Psi (ManuscriptParameters.m y (ManuscriptParameters.chooseB A) + 2) (ManuscriptParameters.z1 y A) : ℝ) := by have hr := parameter_uncovered_count y A hA hy have hrR := (show (R (ManuscriptParameters.m y (ManuscriptParameters.chooseB A)) y (ManuscriptParameters.z0 y A) (ManuscriptParameters.z1 y A) : ℝ) ≤ (SieveInterface.survivorCount (ManuscriptParameters.m y (ManuscriptParameters.chooseB A)) y (ManuscriptParameters.z0 y A) (ManuscriptParameters.z1 y A) : ℝ) + (⌊Real.sqrt y + 2⌋₊ : ℝ) + 2 * (Psi (ManuscriptParameters.m y (ManuscriptParameters.chooseB A) + 2) (ManuscriptParameters.z1 y A) : ℝ) from by exact_mod_cast hr) have hS := (ManuscriptParameters.chosen_B_budget y A hA hy).2 have hbase : SieveParameters.threshold ≤ y := (le_max_left _ _).trans hy have hshort := short_floor_budget y hbase change _ ≤ y / (4 * Real.log y) at hS linarith /-- Conditional remaining budgets compose exactly to the original full-family gap endpoint. -/ theorem parameter_gap_of_budgets (y A : ℝ) (hA : 4 ≤ A) (hy : ManuscriptParameters.threshold A ≤ y) (hH : 2 * (Psi (ManuscriptParameters.m y (ManuscriptParameters.chooseB A) + 2) (ManuscriptParameters.z1 y A) : ℝ) ≤ y / (24 * Real.log y)) (hP : y / (3 * Real.log y) ≤ ((reservedPrimes y).card : ℝ)) : ManuscriptParameters.m y (ManuscriptParameters.chooseB A) + 1 ≤ G2 (primeCutoff y) := by have hr := parameter_uncovered_budget y A hA hy have hb : y / (4 * Real.log y) + y / (24 * Real.log y) + y / (24 * Real.log y) = y / (3 * Real.log y) := by ring apply actual_completion_gap have hc : (R (ManuscriptParameters.m y (ManuscriptParameters.chooseB A)) y (ManuscriptParameters.z0 y A) (ManuscriptParameters.z1 y A) : ℝ) ≤ (reservedPrimes y).card := by linarith exact_mod_cast hc end end ReserveBudget #print axioms KKFiniteCoreProof.survivor_congr #print axioms KKFiniteCoreProof.neg_phase #print axioms KKFiniteCoreProof.phase_dvd_iff #print axioms KKFiniteCoreProof.int_survivor_congr #print axioms KKFiniteCoreProof.int_survivor_nat #print axioms KKFiniteCoreProof.canonical_int_congr #print axioms KKFiniteCoreProof.next_survivor #print axioms KKFiniteCoreProof.consecutive_mod #print axioms ReserveBudget.fullPrimeFamily #print axioms ReserveBudget.actual_reserved_injection #print axioms ReserveBudget.actual_reserved_completion #print axioms ReserveBudget.actual_completion_gap #print axioms ReserveBudget.sqrt_ge_log #print axioms ReserveBudget.short_floor_budget #print axioms ReserveBudget.eventual_short_floor_budget #print axioms ReserveBudget.parameter_uncovered_budget #print axioms ReserveBudget.parameter_gap_of_budgets