A bounded rounded ellipsoid search with answer-or-cut replies
Lax263307.RoundedOracleSearch · concepts/Lax263307/RoundedOracleSearch.lean · lax-263307
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural 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
Evidence
Lean source view on GitHub
| 1 | import Lax263307.BufferedEllipsoid |
| 2 | import Lax109476.RationalEncoding |
| 3 | import Mathlib.Data.Rat.Floor |
| 4 | import Mathlib.Data.Nat.Sqrt |
| 5 | import Mathlib.Data.Nat.Size |
| 6 | |
| 7 | /-! |
| 8 | --- |
| 9 | title: A bounded rounded ellipsoid search with answer-or-cut replies |
| 10 | type: lemma |
| 11 | --- |
| 12 | An oracle returns an answer, a certified rejection, or a nonzero integer |
| 13 | central-cut normal. The search stores a rational matrix and center, advances |
| 14 | them once per cut, and stops after an explicit finite iteration budget. |
| 15 | When rejection is impossible and every cut preserves a fixed dyadic cube |
| 16 | around a scaled unit-cube point, the search must return an answer. |
| 17 | |
| 18 | # Formalization notes |
| 19 | |
| 20 | The computable rational update is the registered LP ellipsoid update, |
| 21 | written explicitly so that definitions and statement types do not import |
| 22 | a proof package. The proof identifies its trajectory with the registered |
| 23 | sequence and applies that sequence's determinant and containment theorems. |
| 24 | The main theorem supplies the oracle and verifies the corresponding |
| 25 | RAM implementation. |
| 26 | -/ |
| 27 | |
| 28 | namespace Lax263307.RoundedOracleSearch |
| 29 | |
| 30 | open BufferedEllipsoid (scale) |
| 31 | open Lax109476.RationalEncoding (encodeRational) |
| 32 | open Lax759944.BinaryWordEncoding (bitSize) |
| 33 | open Matrix |
| 34 | |
| 35 | abbrev State (n : ℕ) := Matrix (Fin n) (Fin n) ℚ × (Fin n → ℚ) |
| 36 | |
| 37 | inductive Reply (n : ℕ) (Result : Type) |
| 38 | | found (answer : Result) |
| 39 | | reject |
| 40 | | cut (normal : Fin n → ℤ) |
| 41 | |
| 42 | def rationalNormal {n : ℕ} (a : Fin n → ℤ) : Fin n → ℚ := fun i => a i |
| 43 | |
| 44 | def roundDown (q : ℚ) (D : ℕ) : ℚ := (Int.floor (q * D) : ℚ) / D |
| 45 | |
| 46 | def sqrtUpper (q : ℚ) (D : ℕ) : ℚ := |
| 47 | ((Nat.sqrt (Nat.ceil (q * (D : ℚ) ^ 2)) + 1 : ℕ) : ℚ) / D |
| 48 | |
| 49 | def 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 | |
| 55 | def grid (n k : ℕ) : ℕ := 2 ^ ((2 * k + 2) + (2 * n + 4) + n + 3) |
| 56 | |
| 57 | def 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 | |
| 62 | def 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 | |
| 73 | def fallback {n : ℕ} : Fin n → ℤ := fun i => if i.val = 0 then 1 else 0 |
| 74 | |
| 75 | def selectedNormal {n : ℕ} {Result : Type} : Reply n Result → Fin n → ℤ |
| 76 | | .cut a => a |
| 77 | | _ => fallback |
| 78 | |
| 79 | def 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 | |
| 86 | def normalSchedule {n : ℕ} {Result : Type} |
| 87 | (oracle : ℕ → (Fin n → ℚ) → Reply n Result) (k : ℕ) : Fin n → ℤ := |
| 88 | selectedNormal (oracle k (trajectory oracle k).2) |
| 89 | |
| 90 | def 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 | |
| 99 | def steps (n B : ℕ) : ℕ := 4 * (n + 1) * (B * n + 1) |
| 100 | |
| 101 | def search {n : ℕ} {Result : Type} (oracle : ℕ → (Fin n → ℚ) → Reply n Result) |
| 102 | (B : ℕ) : Option Result := scan oracle 0 (steps n B) (1, 0) |
| 103 | |
| 104 | axiom 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 | |
| 109 | axiom 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 | |
| 120 | axiom 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 | |
| 126 | axiom 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 | |
| 133 | end Lax263307.RoundedOracleSearch |
| 134 |
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.
0 comments