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
Theorem
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: theorem |
| 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 | This is a functional search; its oracle and RAM refinements are separate |
| 25 | implementation obligations. |
| 26 | -/ |
| 27 | |
| 28 | namespace Lax263307.RoundedOracleSearch |
| 29 | |
| 30 | open Matrix |
| 31 | |
| 32 | abbrev State (n : ℕ) := Matrix (Fin n) (Fin n) ℚ × (Fin n → ℚ) |
| 33 | |
| 34 | inductive Reply (n : ℕ) (Result : Type) |
| 35 | | found (answer : Result) |
| 36 | | reject |
| 37 | | cut (normal : Fin n → ℤ) |
| 38 | |
| 39 | def rationalNormal {n : ℕ} (a : Fin n → ℤ) : Fin n → ℚ := fun i => a i |
| 40 | |
| 41 | def roundDown (q : ℚ) (D : ℕ) : ℚ := (Int.floor (q * D) : ℚ) / D |
| 42 | |
| 43 | def sqrtUpper (q : ℚ) (D : ℕ) : ℚ := |
| 44 | ((Nat.sqrt (Nat.ceil (q * (D : ℚ) ^ 2)) + 1 : ℕ) : ℚ) / D |
| 45 | |
| 46 | def cutShape {n : ℕ} (A : Matrix (Fin n) (Fin n) ℚ) (a : Fin n → ℚ) : |
| 47 | Matrix (Fin n) (Fin n) ℚ := |
| 48 | ((n : ℚ) ^ 2 / ((n : ℚ) ^ 2 - 1)) • |
| 49 | (A - (2 / (((n : ℚ) + 1) * (a ⬝ᵥ (A *ᵥ a)))) • |
| 50 | Matrix.vecMulVec (A *ᵥ a) (A *ᵥ a)) |
| 51 | |
| 52 | def grid (n k : ℕ) : ℕ := 2 ^ ((2 * k + 2) + (2 * n + 4) + n + 3) |
| 53 | |
| 54 | def cached {n : ℕ} (state : State n) : State n := |
| 55 | let rows : Vector (Vector ℚ n) n := Vector.ofFn (fun i => Vector.ofFn (state.1 i)) |
| 56 | let center : Vector ℚ n := Vector.ofFn state.2 |
| 57 | ((fun i j => (rows.get i).get j), fun i => center.get i) |
| 58 | |
| 59 | def update {n : ℕ} (k : ℕ) (state : State n) (a : Fin n → ℤ) : State n := |
| 60 | let a := rationalNormal a |
| 61 | let D := grid n k |
| 62 | let η : ℚ := 1 / (2 : ℚ) ^ (2 * n + 4) |
| 63 | let shape := ((1 + η) ^ 2) • |
| 64 | ((Matrix.of fun i j => roundDown (cutShape state.1 a i j) D) + ((n : ℚ) / D) • 1) |
| 65 | let center := fun i => roundDown |
| 66 | (state.2 i - (1 / (((n : ℚ) + 1) * sqrtUpper (a ⬝ᵥ (state.1 *ᵥ a)) D)) * |
| 67 | (state.1 *ᵥ a) i) D |
| 68 | cached (shape, center) |
| 69 | |
| 70 | def fallback {n : ℕ} : Fin n → ℤ := fun i => if i.val = 0 then 1 else 0 |
| 71 | |
| 72 | def selectedNormal {n : ℕ} {Result : Type} : Reply n Result → Fin n → ℤ |
| 73 | | .cut a => a |
| 74 | | _ => fallback |
| 75 | |
| 76 | def trajectory {n : ℕ} {Result : Type} (oracle : ℕ → (Fin n → ℚ) → Reply n Result) : |
| 77 | ℕ → State n |
| 78 | | 0 => (1, 0) |
| 79 | | k + 1 => |
| 80 | let old := trajectory oracle k |
| 81 | update k old (selectedNormal (oracle k old.2)) |
| 82 | |
| 83 | def normalSchedule {n : ℕ} {Result : Type} |
| 84 | (oracle : ℕ → (Fin n → ℚ) → Reply n Result) (k : ℕ) : Fin n → ℤ := |
| 85 | selectedNormal (oracle k (trajectory oracle k).2) |
| 86 | |
| 87 | def scan {n : ℕ} {Result : Type} (oracle : ℕ → (Fin n → ℚ) → Reply n Result) : |
| 88 | ℕ → ℕ → State n → Option Result |
| 89 | | _, 0, _ => none |
| 90 | | k, count + 1, state => |
| 91 | match oracle k state.2 with |
| 92 | | .found answer => some answer |
| 93 | | .reject => none |
| 94 | | .cut a => scan oracle (k + 1) count (update k state a) |
| 95 | |
| 96 | def steps (n B : ℕ) : ℕ := 4 * (n + 1) * (B * n + 1) |
| 97 | |
| 98 | def search {n : ℕ} {Result : Type} (oracle : ℕ → (Fin n → ℚ) → Reply n Result) |
| 99 | (B : ℕ) : Option Result := scan oracle 0 (steps n B) (1, 0) |
| 100 | |
| 101 | axiom search_sound {n : ℕ} {Result : Type} |
| 102 | (oracle : ℕ → (Fin n → ℚ) → Reply n Result) (B : ℕ) (Good : Result → Prop) |
| 103 | (answers : ∀ k center answer, oracle k center = .found answer → Good answer) : |
| 104 | ∀ answer, search oracle B = some answer → Good answer |
| 105 | |
| 106 | axiom search_complete {n : ℕ} {Result : Type} (dimension : 2 ≤ n) |
| 107 | (oracle : ℕ → (Fin n → ℚ) → Reply n Result) (B : ℕ) (precision : 2 ≤ B) |
| 108 | (nonzero : ∀ k center a, oracle k center = .cut a → ∃ i, a i ≠ 0) |
| 109 | (no_reject : ∀ k center, oracle k center ≠ .reject) |
| 110 | (z : Fin n → ℝ) (cube : ∀ i, 0 ≤ z i ∧ z i ≤ 1) |
| 111 | (retains : ∀ k center a, oracle k center = .cut a → |
| 112 | ∀ e : Fin n → ℝ, (∀ i, |e i| ≤ ((2 : ℝ) ^ B)⁻¹) → |
| 113 | (fun i => (a i : ℝ)) ⬝ᵥ |
| 114 | (Lax263307.BufferedEllipsoid.scale z + e - (fun i => (center i : ℝ))) ≤ 0) : |
| 115 | ∃ answer, search oracle B = some answer |
| 116 | |
| 117 | axiom center_encoding_bound {n : ℕ} {Result : Type} (dimension : 2 ≤ n) |
| 118 | (oracle : ℕ → (Fin n → ℚ) → Reply n Result) |
| 119 | (nonzero : ∀ k center a, oracle k center = .cut a → ∃ i, a i ≠ 0) (k : ℕ) (i : Fin n) : |
| 120 | Lax759944.BinaryWordEncoding.bitSize |
| 121 | (Lax109476.RationalEncoding.encodeRational ((trajectory oracle k).2 i)) ≤ 60 + 6 * k + 14 * n |
| 122 | |
| 123 | axiom shape_encoding_bound {n : ℕ} {Result : Type} (dimension : 2 ≤ n) |
| 124 | (oracle : ℕ → (Fin n → ℚ) → Reply n Result) |
| 125 | (nonzero : ∀ k center a, oracle k center = .cut a → ∃ i, a i ≠ 0) |
| 126 | (k : ℕ) (i j : Fin n) : |
| 127 | Lax759944.BinaryWordEncoding.bitSize |
| 128 | (Lax109476.RationalEncoding.encodeRational ((trajectory oracle k).1 i j)) ≤ 60 + 6 * k + 14 * n |
| 129 | |
| 130 | end Lax263307.RoundedOracleSearch |
| 131 |
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. This is a functional search; its oracle and RAM refinements are separate implementation obligations.
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments