Research-Stack/0-Core-Formalism/lean/Semantics/Semantics/AntiDiophantine.lean
allaun 77488ac0ae feat(lean): close gaussian_line_integral_unit_dir + consolidate infrastructure
Lean proof fixes:
- N3L_Energy.lean: fully close gaussian_line_integral_unit_dir (nlinarith+hab
  for unit-circle quadratic, sqrt_mul+neg_div for integral_gaussian_1d match,
  exp_sum_of_sq order fix, add_assoc for h_gauss_shift, sq_sqrt for field_simp,
  sq_abs for perpDistance hd)
- Add Adapters/AlphaProofNexus: 12 Erdos/graph adapter stubs (AlphaProof nexus)
- Add Adapters/ErgodicAdditive.lean, SidonMatroid.lean
- Add AntiDiophantine.lean, EffectiveBoundDQ.lean, PVGS_DQ_Bridge.lean
- Add FormalConjectures/Util/ProblemImports.lean
- Add RRC/EntropyCandidates/Candidates.lean
- Add OTOM external project (lakefile.toml, lake-manifest.json, lean-toolchain)

Infrastructure:
- Add 4-Infrastructure/shim/: 17 Python probes (RRC manifold, Sidon kernel,
  Wannier, arxiv harvest, math_symbols DB, coverage density, geometric entropy)
- Add 4-Infrastructure/NoDupeLabs/: Node server + package files
- Add 6-Documentation/docs/specs/DP_RRC_RECEIPT_ENCODING_SPEC.md
- Add fix_offloat.py

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-18 16:53:23 -05:00

154 lines
5.6 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import Mathlib.Data.Set.Basic
import Mathlib.Data.Finset.Basic
import Mathlib.Data.Finset.Sort
import Mathlib.Data.Int.Basic
import Mathlib.Tactic
import Semantics.SidonSets
import Semantics.FixedPoint
open Semantics
open FixedPoint
open Semantics.SidonSets
/-!
# Anti-Diophantine Constructions and the Sidon Intersection
A **Diophantine** equation `P(x) = 0` has finitely many integer solutions (Baker).
An **Anti-Diophantine** construction has infinitely many or dense solutions.
Sidon sets `aᵢ + aⱼ = aₖ + aₗ ⇒ {i,j} = {k,l}` live at the intersection:
- **Diophantine**: the sum equation has only trivial solutions (finiteness)
- **Anti-Diophantine**: maximal Sidon size `~√N` (positive density)
- **Slack σ** = M max(label): large σ → Anti-Diophantine, small σ → Diophantine
-/
/-! ## 1. Dual Predicates -/
/-- A family `F` is **Diophantine**: each instance has finitely many solutions. -/
def IsDiophantineFamily (F : → Set ) : Prop :=
∀ p, Set.Finite (F p)
/-- A family is **Anti-Diophantine**: each instance has infinitely many solutions. -/
def IsAntiDiophantineFamily (F : → Set ) : Prop :=
∀ p, Set.Infinite (F p)
/-- Agreement zone: both Diophantine finiteness AND Anti-Diophantine density hold. -/
structure Agreement (F : → Set ) where
diophantine : IsDiophantineFamily F
antiDiophantine : IsAntiDiophantineFamily F
/-- Disagreement zone: both fail. -/
structure Disagreement (F : → Set ) where
notDiophantine : ¬ IsDiophantineFamily F
notAntiDiophantine : ¬ IsAntiDiophantineFamily F
/-! ## 2. Sidon Slack -/
/--
The Sidon slack σ = M max(label) measures address headroom.
Large slack → Anti-Diophantine regime (many embeddings).
Small slack → Diophantine regime (tight constraints).
-/
def sidonSlack (labels : Finset ) (M : ) : :=
M - (if h : labels.Nonempty then labels.max' h else 0)
theorem sidonSlack_eq (labels : Finset ) (h : labels.Nonempty) (M : ) :
sidonSlack labels M = M - labels.max' h := by
unfold sidonSlack
simp [h]
/-- Slack ≥ 128 → Anti-Diophantine regime. -/
def isAntiDiophantineSlack (σ : ) : Prop :=
σ ≥ 128
/-- Slack < 8 → Diophantine regime. -/
def isDiophantineSlack (σ : ) : Prop :=
σ < 8
/-! ## 3. Canonical 8-strand Labels -/
/--
Canonical 8-strand Sidon labels (powers of 2): {1,2,4,8,16,32,64,128}.
These achieve σ = M 128 for address budget M.
-/
def canonicalSidonLabels : Finset :=
{1, 2, 4, 8, 16, 32, 64, 128}
theorem canonicalSidonLabels_nonempty : canonicalSidonLabels.Nonempty := by
refine ⟨1, ?_⟩
simp [canonicalSidonLabels]
theorem canonicalSidonLabels_max : canonicalSidonLabels.max' canonicalSidonLabels_nonempty = 128 := by
native_decide
theorem canonical_labels_sidon : Semantics.SidonSets.IsSidon (canonicalSidonLabels.image (λ (n : ) => (n : ))) := by
native_decide
theorem canonical_sidon_slack (M : ) (hM : M ≥ 128) :
sidonSlack canonicalSidonLabels M = M - 128 := by
rw [sidonSlack_eq canonicalSidonLabels canonicalSidonLabels_nonempty M]
rw [canonicalSidonLabels_max]
/-! ## 4. Intersection Bounds -/
/--
**Agreement upper bound** (Diophantine side): `h(N) ≤ √(2N) + 1` for `N ≥ 1`.
This is the sumset double-counting bound from SidonSets.lean.
-/
theorem sidon_agreement_upper (N : ) (hN : 1 ≤ N) :
Semantics.SidonSets.sidonMaximum N ≤ Nat.sqrt (2 * N) + 1 :=
Semantics.SidonSets.sidonMaximum_le_sqrt_two N hN
/--
**Agreement lower bound** (Anti-Diophantine side): `√N / 2 ≤ h(N)` for `N ≥ 5`.
This uses the Singer/Bose-Chowla construction (SidonSets.lean:2990).
-/
theorem sidon_agreement_lower (N : ) (hN : 5 ≤ N) :
Nat.sqrt N / 2 ≤ Semantics.SidonSets.sidonMaximum N := by
have h_strong : (Nat.sqrt N + 1) / 2 < Semantics.SidonSets.sidonMaximum N :=
Semantics.SidonSets.sidonMaximum_gt_sqrt_div_two N hN
have h_weak : Nat.sqrt N / 2 ≤ (Nat.sqrt N + 1) / 2 := by
omega
omega
/--
**Full agreement theorem**: for `N ≥ 5`,
`√N / 2 ≤ h(N) ≤ √(2N) + 1`.
Thus Sidon sets live in the agreement zone: Diophantine upper bound meets
Anti-Diophantine lower bound at `Θ(√N)`.
-/
theorem sidon_agreement_theorem (N : ) (hN : 5 ≤ N) :
Nat.sqrt N / 2 ≤ Semantics.SidonSets.sidonMaximum N ∧
Semantics.SidonSets.sidonMaximum N ≤ Nat.sqrt (2 * N) + 1 := by
have h_upper : Semantics.SidonSets.sidonMaximum N ≤ Nat.sqrt (2 * N) + 1 := by
have h1 : 1 ≤ N := by omega
exact sidon_agreement_upper N h1
exact ⟨sidon_agreement_lower N hN, h_upper⟩
/-! ## 5. Slack Regime Transition -/
theorem slack_regime_transition (M : ) (hM : M ≥ 256) :
sidonSlack canonicalSidonLabels M ≥ 128 := by
have hM128 : M ≥ 128 := by omega
rw [canonical_sidon_slack M hM128]
omega
/-! ## 6. Diophantine vs Anti-Diophantine Comparison -/
/--
The equation `a + b = c + d` over a Sidon set `A` has only trivial solutions.
This means the sumset `A + A` grows quadratically in `|A|`.
**Diophantine constraint**: `|A + A| ≥ |A|·(|A|1)/2` (all non-trivial sums distinct).
**Anti-Diophantine density**: `|A| ≥ √N/2` (Singer construction gives large sets).
The comparison: Diophantine says `|A|` is bounded by `√(2N)`, Anti-Diophantine says
`|A|` is at least `√N/2`. Together they pin `|A|` to `Θ(√N)`.
-/
theorem diophantine_antiDiophantine_comparison (N : ) (hN : 5 ≤ N) :
let diophantineBound := Nat.sqrt (2 * N) + 1; let antiDiophantineBound := Nat.sqrt N / 2;
antiDiophantineBound ≤ Semantics.SidonSets.sidonMaximum N ∧
Semantics.SidonSets.sidonMaximum N ≤ diophantineBound := by
intro diophantineBound antiDiophantineBound
exact sidon_agreement_theorem N hN