diff --git a/.github/workflows/erdos625-sharp-deficit-product.yml b/.github/workflows/erdos625-sharp-deficit-product.yml new file mode 100644 index 00000000..d04aead0 --- /dev/null +++ b/.github/workflows/erdos625-sharp-deficit-product.yml @@ -0,0 +1,104 @@ +name: Erdős 625 sharp all-deficit product + +on: + pull_request: + paths: + - "625/formalization/Erdos625/Section8SharpDeficitProduct.lean" + - "625/formalization/Erdos625/Section8ThreeQuarterDeficitArithmetic.lean" + - "625/proofs/SECTION8_SHARP_DEFICIT_PRODUCT_AND_REWRITE.md" + - "625/arxiv/SECTION8_SHARP_DEFICIT_INSERT_V2.tex" + - "625/experiments/section8_sharp_deficit_product.py" + - ".github/workflows/erdos625-sharp-deficit-product.yml" + workflow_dispatch: + +concurrency: + group: erdos625-sharp-deficit-product-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + exact-regression: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5 + - name: Compile exact checker + run: python -m py_compile 625/experiments/section8_sharp_deficit_product.py + - name: Run exact checker + run: python 625/experiments/section8_sharp_deficit_product.py + - name: Run exact checker with optimization + run: python -O 625/experiments/section8_sharp_deficit_product.py + - name: Validate reader-facing TeX fragment + run: | + python - <<'PY' + from pathlib import Path + + path = Path("625/arxiv/SECTION8_SHARP_DEFICIT_INSERT_V2.tex") + text = path.read_text(encoding="utf-8") + required = ( + "Aggregate deficit comparison", + "Cellwise optional-deficit product", + "eq:aggregate-bare-weight-v2", + "eq:fixed-support-all-deficit-v2", + "eq:bare-skeleton-sharp-v2", + "Audit boundary", + ) + missing = [token for token in required if token not in text] + if missing: + raise SystemExit(f"missing TeX markers: {missing}") + if text.count("{") != text.count("}"): + raise SystemExit("unbalanced TeX braces") + if "\\tag{" in text: + raise SystemExit("manual equation tags are forbidden in the insert") + print("TeX marker and brace checks passed") + PY + + focused-lean-check: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5 + - name: Reject placeholders and project axioms + shell: bash + run: | + if grep -nE \ + '(^|[[:space:]])(sorry|admit|sorryAx)([[:space:][:punct:]]|$)|^[[:space:]]*(axiom|constant|unsafe)[[:space:]]' \ + 625/formalization/Erdos625/Section8SharpDeficitProduct.lean \ + 625/formalization/Erdos625/Section8ThreeQuarterDeficitArithmetic.lean; then + exit 1 + fi + - uses: leanprover/lean-action@38fbc41a8c28c4cbaec22d7f7de508ec2e7c0dd9 # v1 + with: + lake-package-directory: 625/formalization + auto-config: false + build: false + use-mathlib-cache: true + use-github-cache: false + nanoda: false + - name: Build the sharp all-deficit interfaces warning-fatally + working-directory: 625/formalization + shell: bash + run: | + : > /tmp/erdos625-sharp-deficit-product.log + for target in \ + Erdos625.Section8SharpDeficitProduct \ + Erdos625.Section8ThreeQuarterDeficitArithmetic; do + echo "=== $target ===" | tee -a /tmp/erdos625-sharp-deficit-product.log + set +e + lake build "$target" --wfail \ + >> /tmp/erdos625-sharp-deficit-product.log 2>&1 + status=$? + set -e + if [[ $status -ne 0 ]]; then + tail -n 700 /tmp/erdos625-sharp-deficit-product.log + exit $status + fi + done + tail -n 700 /tmp/erdos625-sharp-deficit-product.log + - name: Upload focused Lean log + if: always() + uses: actions/upload-artifact@v4 + with: + name: erdos625-sharp-deficit-product-log + path: /tmp/erdos625-sharp-deficit-product.log + if-no-files-found: ignore diff --git a/625/arxiv/SECTION8_SHARP_DEFICIT_INSERT_V2.tex b/625/arxiv/SECTION8_SHARP_DEFICIT_INSERT_V2.tex new file mode 100644 index 00000000..d4290bdd --- /dev/null +++ b/625/arxiv/SECTION8_SHARP_DEFICIT_INSERT_V2.tex @@ -0,0 +1,201 @@ +% Copy-ready Section VIII insert for the post-closure Version 2 manuscript. +% Do not include this file from main.tex until the attained-demand reindexing +% and pointwise aggregate weight identity have been checked. + +\subsection{The all-deficit partition function} +\label{subsec:all-deficit-partition-function} + +Fix a block-level matching support $P$. For every selected cell $e\in P$, let +$s_e,t_e$ be its endpoint block sizes and put +\[ + m_e:=\min\{s_e,t_e\}, + \qquad + d_e:=|s_e-t_e|. +\] +If the actual high multiplicity is $j_e$, write +\[ + j_e=m_e-h_e. +\] +The canonical high condition implies $2h_e None: + if not condition: + raise RuntimeError(message) + + +def falling(n: int, k: int) -> int: + require(0 <= k <= n, f"invalid falling factorial ({n})_{{{k}}}") + value = 1 + for offset in range(k): + value *= n - offset + return value + + +def local_ratio(m: int, d: int, h: int) -> Fraction: + """The aggregate local ratio R_{m,d}(h).""" + + rising = factorial(d + h) // factorial(d) + binary_exponent = h * m - h * (h + 1) // 2 + return Fraction(comb(m, h), rising * 2**binary_exponent) + + +def check_exact_local_ratio(max_m: int = 100) -> int: + checked = 0 + for m in range(3, max_m + 1): + for d in range(4): + for h in range((m - 1) // 2 + 1): + j = m - h + decorated = Fraction( + falling(m, j) * falling(m + d, j), factorial(j) + ) * Fraction(2 ** comb(j, 2), 2) + full = Fraction( + falling(m, m) * falling(m + d, m), factorial(m) + ) * Fraction(2 ** comb(m, 2), 2) + require( + decorated / full == local_ratio(m, d, h), + f"local ratio failed at m={m}, d={d}, h={h}", + ) + checked += 1 + return checked + + +def check_two_thirds_charge(max_m: int = 220) -> int: + """Verify n^h R <= (n m / 2^floor(2m/3))^h exactly.""" + + checked = 0 + sample_n = (1, 2, 3, 5, 10, 20, 50, 100) + for m in range(3, max_m + 1): + exponent = (2 * m) // 3 + for d in range(4): + for h in range(1, (m - 1) // 2 + 1): + require(2 * h < m, "loop admitted a non-high deficit") + exponent_budget = h * m - h * (h + 1) // 2 + require( + h * exponent <= exponent_budget, + f"two-thirds exponent budget failed at m={m}, h={h}", + ) + ratio = local_ratio(m, d, h) + for n in sample_n: + lhs = n**h * ratio + rho = Fraction(n * m, 2**exponent) + require( + lhs <= rho**h, + f"two-thirds charge failed at n={n}, m={m}, d={d}, h={h}", + ) + checked += 1 + return checked + + +def check_three_quarter_charge(max_m: int = 280) -> int: + """Verify the stronger floor((3m-1)/4) charged ratio exactly.""" + + checked = 0 + sample_n = (1, 2, 3, 5, 10, 20, 50, 100) + for m in range(3, max_m + 1): + two_thirds = (2 * m) // 3 + three_quarters = (3 * m - 1) // 4 + require( + two_thirds <= three_quarters, + f"three-quarter exponent is weaker at m={m}", + ) + for d in range(4): + for h in range(1, (m - 1) // 2 + 1): + require(2 * h < m, "loop admitted a non-high deficit") + exponent_budget = h * m - h * (h + 1) // 2 + require( + h * three_quarters <= exponent_budget, + f"three-quarter exponent budget failed at m={m}, h={h}", + ) + ratio = local_ratio(m, d, h) + for n in sample_n: + lhs = n**h * ratio + rho = Fraction(n * m, 2**three_quarters) + require( + lhs <= rho**h, + f"three-quarter charge failed at n={n}, m={m}, d={d}, h={h}", + ) + checked += 1 + return checked + + +def check_finite_geometric_bound() -> int: + """Check sum_{h=1}^H rho^h <= rho/(1-rho) <= 2 rho.""" + + checked = 0 + for denominator in range(2, 81): + for numerator in range(1, denominator // 2 + 1): + rho = Fraction(numerator, denominator) + require(rho <= Fraction(1, 2), "test construction exceeded one half") + power = Fraction(1, 1) + finite_sum = Fraction(0, 1) + for cutoff in range(0, 81): + if cutoff > 0: + power *= rho + finite_sum += power + require( + finite_sum <= rho / (1 - rho), + f"geometric majorant failed at rho={rho}, H={cutoff}", + ) + require( + finite_sum <= 2 * rho, + f"two-rho majorant failed at rho={rho}, H={cutoff}", + ) + checked += 1 + return checked + + +def check_head_tail_bound(max_m: int = 100) -> int: + """Check the optional first-term plus geometric-tail refinement.""" + + checked = 0 + for m in range(3, max_m + 1): + exponent = (3 * m - 1) // 4 + largest = (m - 1) // 2 + for d in range(4): + ratios = tuple(local_ratio(m, d, h) for h in range(largest + 1)) + for n in range(1, 21): + rho = Fraction(n * m, 2**exponent) + if rho > Fraction(1, 2): + continue + actual = sum( + (n**h * ratios[h] for h in range(1, largest + 1)), + Fraction(0, 1), + ) + first = n * ratios[1] + tail = rho**2 / (1 - rho) + require( + actual <= first + tail, + f"head-tail bound failed at n={n}, m={m}, d={d}", + ) + checked += 1 + return checked + + +def check_partition_function_factorization() -> int: + """Exhaust exact sums over small distinguishable deficit fibres.""" + + local_fibres = ( + (Fraction(1), Fraction(1, 7), Fraction(1, 49)), + (Fraction(1), Fraction(2, 9)), + (Fraction(1), Fraction(1, 11), Fraction(1, 121), Fraction(1, 1331)), + (Fraction(1),), + ) + checked = 0 + for number_of_cells in range(0, len(local_fibres) + 1): + fibres = local_fibres[:number_of_cells] + direct = Fraction(0, 1) + for choice in product(*fibres): + term = Fraction(1, 1) + for value in choice: + term *= value + direct += term + factorized = Fraction(1, 1) + for fibre in fibres: + factorized *= sum(fibre, Fraction(0, 1)) + require( + direct == factorized, + f"partition-function factorization failed for {number_of_cells} cells", + ) + checked += 1 + return checked + + +def check_cellwise_and_uniform_bounds() -> int: + """Compare cellwise 2 rho charges with the older U rho interface.""" + + checked = 0 + for U in range(2, 81): + for denominator in range(2, 61): + for numerator in range(1, denominator // 2 + 1): + rho = Fraction(numerator, denominator) + require(2 * rho <= U * rho, "sharp charge exceeded old charge") + require( + 1 + 2 * rho <= 1 + U * rho, + "additive charge comparison failed", + ) + checked += 1 + return checked + + +def check_endpoint_type_retention() -> int: + """Retaining cellwise charges is sharper than replacing them by max rho.""" + + checked = 0 + for alpha in range(12, 61): + endpoint_sizes = tuple(alpha - d for d in (2, 3, 4, 5)) + for n in (1, 2, 5, 10, 20): + charges = [ + Fraction( + n * min(s, t), + 2 ** ((3 * min(s, t) - 1) // 4), + ) + for s in endpoint_sizes + for t in endpoint_sizes + ] + require( + sum(charges, Fraction(0, 1)) <= len(charges) * max(charges), + "cellwise-to-uniform maximum comparison failed", + ) + checked += 1 + return checked + + +def asymptotic_diagnostics() -> list[ + tuple[int, Decimal, Decimal, Decimal, Decimal] +]: + """Logarithms of error-scale ratios after division by n/N^4. + + With N=log n: + + three-quarter: sqrt(n) N^(3/2) -> exp(-N/2) N^(11/2), + two-thirds: n^(2/3) N^(4/3) -> exp(-N/3) N^(16/3), + old U*rho: n^(2/3) N^(7/3) -> exp(-N/3) N^(19/3), + endpoint: sqrt(nN) -> exp(-N/2) N^(9/2). + """ + + getcontext().prec = 80 + rows: list[tuple[int, Decimal, Decimal, Decimal, Decimal]] = [] + previous: tuple[Decimal, Decimal, Decimal, Decimal] | None = None + for nlog in (120, 240, 480, 960, 1920): + N = Decimal(nlog) + three_quarter = -N / 2 + (Decimal(11) / 2) * N.ln() + two_thirds = -N / 3 + (Decimal(16) / 3) * N.ln() + old = -N / 3 + (Decimal(19) / 3) * N.ln() + endpoint = -N / 2 + (Decimal(9) / 2) * N.ln() + current = (three_quarter, two_thirds, old, endpoint) + if previous is not None: + labels = ("three-quarter", "two-thirds", "old", "endpoint") + for label, value, old_value in zip(labels, current, previous): + require(value < old_value, f"{label} scale diagnostic is not decreasing") + previous = current + rows.append((nlog, *current)) + for index, label in enumerate( + ("three-quarter", "two-thirds", "old", "endpoint"), start=1 + ): + require(rows[-1][index] < -100, f"{label} scale is not strongly subcritical") + return rows + + +def main() -> None: + local_cases = check_exact_local_ratio() + two_thirds_cases = check_two_thirds_charge() + three_quarter_cases = check_three_quarter_charge() + geometric_cases = check_finite_geometric_bound() + head_tail_cases = check_head_tail_bound() + factorization_cases = check_partition_function_factorization() + comparison_cases = check_cellwise_and_uniform_bounds() + endpoint_cases = check_endpoint_type_retention() + diagnostics = asymptotic_diagnostics() + + print("ERDOS 625 SHARP DEFICIT PRODUCT: PASS") + print(f" exact aggregate local ratios: {local_cases}") + print(f" exact two-thirds charged ratios: {two_thirds_cases}") + print(f" exact three-quarter charged ratios: {three_quarter_cases}") + print(f" finite geometric sums: {geometric_cases}") + print(f" first-term plus tail checks: {head_tail_cases}") + print(f" exact partition-function factorizations: {factorization_cases}") + print(f" sharp-vs-cardinality comparisons: {comparison_cases}") + print(f" cellwise endpoint-type comparisons: {endpoint_cases}") + print( + " asymptotic log-ratios " + "(N, three-quarter, two-thirds, old-cardinality, endpoint):" + ) + for row in diagnostics: + print(" ", row) + print(" scope: exact finite arithmetic and scale diagnostics only") + + +if __name__ == "__main__": + main() diff --git a/625/formalization/Erdos625/Section8SharpDeficitProduct.lean b/625/formalization/Erdos625/Section8SharpDeficitProduct.lean new file mode 100644 index 00000000..869a34c5 --- /dev/null +++ b/625/formalization/Erdos625/Section8SharpDeficitProduct.lean @@ -0,0 +1,123 @@ +import Erdos625.Section8AllHighDeficitProductBound +import Mathlib.Tactic + +/-! +# Section VIII: sharp cellwise product interface for all high deficits + +The generic all-high product theorem previously replaced every nonzero deficit +weight by one common bound and then multiplied by the number of admissible +deficits. That route is sufficient for the normalized second moment, but it +introduces an unnecessary factor of the phase size. + +This module isolates the sharper interface actually used by the concise +manuscript proof. First sum the complete positive-deficit fibre in each +selected physical cell; then multiply the resulting local partition functions. +The local bounds may vary from cell to cell. + +No geometric-series estimate, phase asymptotic, endpoint transportation bound, +or identification with attained canonical demands is asserted here. +-/ + +namespace Erdos625 + +open scoped BigOperators ENNReal + +noncomputable section + +set_option autoImplicit false + +/-- Exact optional-deficit expansion followed by arbitrary cellwise upper +bounds on the positive-deficit sums. -/ +theorem sum_nearSkeletonChoiceWeight_le_product_of_local_sums + {Cell Deficit : Type*} + [Fintype Cell] [Fintype Deficit] [DecidableEq Deficit] + (allowed : Cell → Finset Deficit) + (weight : Cell → Deficit → ENNReal) + (bound : Cell → ENNReal) + (hlocal : ∀ c, (∑ e ∈ allowed c, weight c e) ≤ bound c) : + (∑ choice : NearSkeletonChoice Cell Deficit allowed, + nearSkeletonChoiceWeight allowed weight choice) ≤ + ∏ c, (1 + bound c) := by + rw [sum_nearSkeletonChoiceWeight_eq_product] + apply Finset.prod_le_prod' + intro c _ + simpa [add_comm] using add_le_add_left (hlocal c) 1 + +/-- Uniform specialization of the cellwise local-sum interface. -/ +theorem sum_nearSkeletonChoiceWeight_le_uniform_local_sum + {Cell Deficit : Type*} + [Fintype Cell] [Fintype Deficit] [DecidableEq Deficit] + (allowed : Cell → Finset Deficit) + (weight : Cell → Deficit → ENNReal) + (sigma : ENNReal) + (hlocal : ∀ c, (∑ e ∈ allowed c, weight c e) ≤ sigma) : + (∑ choice : NearSkeletonChoice Cell Deficit allowed, + nearSkeletonChoiceWeight allowed weight choice) ≤ + (1 + sigma) ^ Fintype.card Cell := by + calc + (∑ choice : NearSkeletonChoice Cell Deficit allowed, + nearSkeletonChoiceWeight allowed weight choice) ≤ + ∏ _c : Cell, (1 + sigma) := by + apply sum_nearSkeletonChoiceWeight_le_product_of_local_sums + allowed weight (fun _ => sigma) + exact hlocal + _ = (1 + sigma) ^ Fintype.card Cell := by simp + +/-- If the complete positive-deficit fibre in cell `c` is at most `2*rho c`, +the global optional-deficit partition function retains the cellwise charges. -/ +theorem sum_nearSkeletonChoiceWeight_le_cellwise_two_rho + {Cell Deficit : Type*} + [Fintype Cell] [Fintype Deficit] [DecidableEq Deficit] + (allowed : Cell → Finset Deficit) + (weight : Cell → Deficit → ENNReal) + (rho : Cell → ENNReal) + (hlocal : ∀ c, (∑ e ∈ allowed c, weight c e) ≤ 2 * rho c) : + (∑ choice : NearSkeletonChoice Cell Deficit allowed, + nearSkeletonChoiceWeight allowed weight choice) ≤ + ∏ c, (1 + 2 * rho c) := by + apply sum_nearSkeletonChoiceWeight_le_product_of_local_sums + allowed weight (fun c => 2 * rho c) + exact hlocal + +/-- Uniform `2*rho` specialization. This is the formal endpoint needed after +a finite geometric-series estimate in every selected cell. -/ +theorem sum_nearSkeletonChoiceWeight_le_uniform_two_rho + {Cell Deficit : Type*} + [Fintype Cell] [Fintype Deficit] [DecidableEq Deficit] + (allowed : Cell → Finset Deficit) + (weight : Cell → Deficit → ENNReal) + (rho : ENNReal) + (hlocal : ∀ c, (∑ e ∈ allowed c, weight c e) ≤ 2 * rho) : + (∑ choice : NearSkeletonChoice Cell Deficit allowed, + nearSkeletonChoiceWeight allowed weight choice) ≤ + (1 + 2 * rho) ^ Fintype.card Cell := by + apply sum_nearSkeletonChoiceWeight_le_uniform_local_sum + allowed weight (2 * rho) + exact hlocal + +/-- The sharp `2*rho` local charge is never worse than the old cardinality +charge `U*rho` once every cell was allowed at least two candidate deficits. -/ +theorem two_mul_ennreal_le_natCast_mul + (U : Nat) (rho : ENNReal) (hU : 2 ≤ U) : + 2 * rho ≤ (U : ENNReal) * rho := by + have hU' : (2 : ENNReal) ≤ (U : ENNReal) := by + exact_mod_cast hU + simpa [mul_comm] using mul_le_mul_right hU' rho + +/-- Additive form of the comparison with the earlier uniform-cardinality +interface. -/ +theorem one_add_two_mul_ennreal_le_one_add_natCast_mul + (U : Nat) (rho : ENNReal) (hU : 2 ≤ U) : + 1 + 2 * rho ≤ 1 + (U : ENNReal) * rho := by + simpa [add_comm] using + add_le_add_left (two_mul_ennreal_le_natCast_mul U rho hU) 1 + +#print axioms sum_nearSkeletonChoiceWeight_le_product_of_local_sums +#print axioms sum_nearSkeletonChoiceWeight_le_uniform_local_sum +#print axioms sum_nearSkeletonChoiceWeight_le_cellwise_two_rho +#print axioms sum_nearSkeletonChoiceWeight_le_uniform_two_rho +#print axioms two_mul_ennreal_le_natCast_mul + +end + +end Erdos625 diff --git a/625/formalization/Erdos625/Section8ThreeQuarterDeficitArithmetic.lean b/625/formalization/Erdos625/Section8ThreeQuarterDeficitArithmetic.lean new file mode 100644 index 00000000..dc3842c0 --- /dev/null +++ b/625/formalization/Erdos625/Section8ThreeQuarterDeficitArithmetic.lean @@ -0,0 +1,75 @@ +import Erdos625.Section8AllHighDeficitArithmetic +import Mathlib.Tactic + +/-! +# Section VIII: a three-quarter exponent budget + +For a high multiplicity `j=m-h`, the condition `2h