A bounded rounded ellipsoid search with answer-or-cut replies

Lax263307.RoundedOracleSearch · concepts/Lax263307/RoundedOracleSearch.lean · lax-263307

proven

Loading review…

Sign in with ORCID

Community review

Flags

Each flag is tied to a public ORCID identity and explains why this concept may be incorrect.

No flags have been submitted.

    Community review

    Flag this concept

    State precisely what appears incorrect. This explanation will be public under your ORCID name.

    No source line selected.

    Natural Language Statement

    Lemma

    An oracle returns an answer, a certified rejection, or a nonzero integer central-cut normal. The search stores a rational matrix and center, advances them once per cut, and stops after an explicit finite iteration budget. When rejection is impossible and every cut preserves a fixed dyadic cube around a scaled unit-cube point, the search must return an answer.

    Concept map
    10 concepts; 7 descendants hidden
    100%
    Proven claimDefinitionThis conceptRelated conceptA → B: B builds on A
    Evidence

    Lean source view on GitHub

    1import Lax263307.BufferedEllipsoid
    2import Lax109476.RationalEncoding
    3import Mathlib.Data.Rat.Floor
    4import Mathlib.Data.Nat.Sqrt
    5import Mathlib.Data.Nat.Size
    6
    7/-!
    8---
    9title: A bounded rounded ellipsoid search with answer-or-cut replies
    10type: lemma
    11---
    12An oracle returns an answer, a certified rejection, or a nonzero integer
    13central-cut normal. The search stores a rational matrix and center, advances
    14them once per cut, and stops after an explicit finite iteration budget.
    15When rejection is impossible and every cut preserves a fixed dyadic cube
    16around a scaled unit-cube point, the search must return an answer.
    17
    18# Formalization notes
    19
    20The computable rational update is the registered LP ellipsoid update,
    21written explicitly so that definitions and statement types do not import
    22a proof package. The proof identifies its trajectory with the registered
    23sequence and applies that sequence's determinant and containment theorems.
    24The main theorem supplies the oracle and verifies the corresponding
    25RAM implementation.
    26-/
    27
    28namespace Lax263307.RoundedOracleSearch
    29
    30open BufferedEllipsoid (scale)
    31open Lax109476.RationalEncoding (encodeRational)
    32open Lax759944.BinaryWordEncoding (bitSize)
    33open Matrix
    34
    35abbrev State (n : ℕ) := Matrix (Fin n) (Fin n) ℚ × (Fin n → ℚ)
    36
    37inductive Reply (n : ℕ) (Result : Type)
    38 | found (answer : Result)
    39 | reject
    40 | cut (normal : Fin n → ℤ)
    41
    42def rationalNormal {n : ℕ} (a : Fin n → ℤ) : Fin n → ℚ := fun i => a i
    43
    44def roundDown (q : ℚ) (D : ℕ) : ℚ := (Int.floor (q * D) : ℚ) / D
    45
    46def sqrtUpper (q : ℚ) (D : ℕ) : ℚ :=
    47 ((Nat.sqrt (Nat.ceil (q * (D : ℚ) ^ 2)) + 1 : ℕ) : ℚ) / D
    48
    49def cutShape {n : ℕ} (A : Matrix (Fin n) (Fin n) ℚ) (a : Fin n → ℚ) :
    50 Matrix (Fin n) (Fin n) ℚ :=
    51 ((n : ℚ) ^ 2 / ((n : ℚ) ^ 2 - 1)) •
    52 (A - (2 / (((n : ℚ) + 1) * (a ⬝ᵥ (A *ᵥ a)))) •
    53 Matrix.vecMulVec (A *ᵥ a) (A *ᵥ a))
    54
    55def grid (n k : ℕ) : ℕ := 2 ^ ((2 * k + 2) + (2 * n + 4) + n + 3)
    56
    57def cached {n : ℕ} (state : State n) : State n :=
    58 let rows : Vector (Vector ℚ n) n := Vector.ofFn (fun i => Vector.ofFn (state.1 i))
    59 let center : Vector ℚ n := Vector.ofFn state.2
    60 ((fun i j => (rows.get i).get j), fun i => center.get i)
    61
    62def update {n : ℕ} (k : ℕ) (state : State n) (a : Fin n → ℤ) : State n :=
    63 let a := rationalNormal a
    64 let D := grid n k
    65 let η : ℚ := 1 / (2 : ℚ) ^ (2 * n + 4)
    66 let shape := ((1 + η) ^ 2) •
    67 ((Matrix.of fun i j => roundDown (cutShape state.1 a i j) D) + ((n : ℚ) / D) • 1)
    68 let center := fun i => roundDown
    69 (state.2 i - (1 / (((n : ℚ) + 1) * sqrtUpper (a ⬝ᵥ (state.1 *ᵥ a)) D)) *
    70 (state.1 *ᵥ a) i) D
    71 cached (shape, center)
    72
    73def fallback {n : ℕ} : Fin n → ℤ := fun i => if i.val = 0 then 1 else 0
    74
    75def selectedNormal {n : ℕ} {Result : Type} : Reply n Result → Fin n → ℤ
    76 | .cut a => a
    77 | _ => fallback
    78
    79def trajectory {n : ℕ} {Result : Type} (oracle : ℕ → (Fin n → ℚ) → Reply n Result) :
    80 ℕ → State n
    81 | 0 => (1, 0)
    82 | k + 1 =>
    83 let old := trajectory oracle k
    84 update k old (selectedNormal (oracle k old.2))
    85
    86def normalSchedule {n : ℕ} {Result : Type}
    87 (oracle : ℕ → (Fin n → ℚ) → Reply n Result) (k : ℕ) : Fin n → ℤ :=
    88 selectedNormal (oracle k (trajectory oracle k).2)
    89
    90def scan {n : ℕ} {Result : Type} (oracle : ℕ → (Fin n → ℚ) → Reply n Result) :
    91 ℕ → ℕ → State n → Option Result
    92 | _, 0, _ => none
    93 | k, count + 1, state =>
    94 match oracle k state.2 with
    95 | .found answer => some answer
    96 | .reject => none
    97 | .cut a => scan oracle (k + 1) count (update k state a)
    98
    99def steps (n B : ℕ) : ℕ := 4 * (n + 1) * (B * n + 1)
    100
    101def search {n : ℕ} {Result : Type} (oracle : ℕ → (Fin n → ℚ) → Reply n Result)
    102 (B : ℕ) : Option Result := scan oracle 0 (steps n B) (1, 0)
    103
    104axiom search_sound {n : ℕ} {Result : Type}
    105 (oracle : ℕ → (Fin n → ℚ) → Reply n Result) (B : ℕ) (Good : Result → Prop)
    106 (answers : ∀ k center answer, oracle k center = .found answer → Good answer) :
    107 ∀ answer, search oracle B = some answer → Good answer
    108
    109axiom search_complete {n : ℕ} {Result : Type} (dimension : 2 ≤ n)
    110 (oracle : ℕ → (Fin n → ℚ) → Reply n Result) (B : ℕ) (precision : 2 ≤ B)
    111 (nonzero : ∀ k center a, oracle k center = .cut a → ∃ i, a i ≠ 0)
    112 (no_reject : ∀ k center, oracle k center ≠ .reject)
    113 (z : Fin n → ℝ) (cube : ∀ i, 0 ≤ z i ∧ z i ≤ 1)
    114 (retains : ∀ k center a, oracle k center = .cut a →
    115 ∀ e : Fin n → ℝ, (∀ i, |e i| ≤ ((2 : ℝ) ^ B)⁻¹) →
    116 (fun i => (a i : ℝ)) ⬝ᵥ
    117 (scale z + e - (fun i => (center i : ℝ))) ≤ 0) :
    118 ∃ answer, search oracle B = some answer
    119
    120axiom center_encoding_bound {n : ℕ} {Result : Type} (dimension : 2 ≤ n)
    121 (oracle : ℕ → (Fin n → ℚ) → Reply n Result)
    122 (nonzero : ∀ k center a, oracle k center = .cut a → ∃ i, a i ≠ 0) (k : ℕ) (i : Fin n) :
    123 bitSize
    124 (encodeRational ((trajectory oracle k).2 i)) ≤ 60 + 6 * k + 14 * n
    125
    126axiom shape_encoding_bound {n : ℕ} {Result : Type} (dimension : 2 ≤ n)
    127 (oracle : ℕ → (Fin n → ℚ) → Reply n Result)
    128 (nonzero : ∀ k center a, oracle k center = .cut a → ∃ i, a i ≠ 0)
    129 (k : ℕ) (i j : Fin n) :
    130 bitSize
    131 (encodeRational ((trajectory oracle k).1 i j)) ≤ 60 + 6 * k + 14 * n
    132
    133end Lax263307.RoundedOracleSearch
    134
    Show ProofShow ProofShow ProofShow Proof
    Formalization notes

    The computable rational update is the registered LP ellipsoid update, written explicitly so that definitions and statement types do not import a proof package. The proof identifies its trajectory with the registered sequence and applies that sequence's determinant and containment theorems. The main theorem supplies the oracle and verifies the corresponding RAM implementation.

    Discussion

    Ask a question or add context. Endorsements and structured flags are kept in the review panel above.

    Loading discussion…