omega-helix
This project has not described itself yet.
Brought by drakestapleton
omega-helix / docs / proofs / OmkBaseProofs.lean
| 1 | /-! |
| 2 | # OmkBaseProofs.lean — Kernel-Checked Lean 4 Foundation for `.omk`, `omkc_direct`, and `telepathy.om` |
| 3 | |
| 4 | Model-to-system link: |
| 5 | - `raddr_encode`, `raddr_verb`, `raddr_sort`, `raddr_slot`, `rkey_check`, `bb_cas_offer`: |
| 6 | modeled directly from `tools/omkc/telepathy.om` (commit `50027fc`, `2026-11-28`). |
| 7 | - `gate64_step`, `gate64_check`: |
| 8 | modeled directly from `tools/omkc/omkc_direct.om` (commit `50027fc`, `2026-11-28`). |
| 9 | |
| 10 | Audit compliance (2026-11-28): |
| 11 | - `sorry_count = 0` |
| 12 | - `native_decide_count = 0` |
| 13 | - Standard core axioms only (verified via `#print axioms` on every theorem) |
| 14 | - Broken-model negative controls included for non-vacuity. |
| 15 | -/ |
| 16 | |
| 17 | namespace OmkBase |
| 18 | |
| 19 | -- ============================================================================ |
| 20 | -- 1. Zero-Header Address-Encoded Grammar (telepathy.om) |
| 21 | -- raddr = Base + (verb * 2^22) + (sort * 2^18) + (slot * 2^8) |
| 22 | -- ============================================================================ |
| 23 | |
| 24 | def BB_BASE : Nat := 0x1000000000 |
| 25 | |
| 26 | def raddrEncode (verb sort slot : Nat) : Nat := |
| 27 | BB_BASE + verb * 4194304 + sort * 262144 + slot * 256 |
| 28 | |
| 29 | def raddrVerb (raddr : Nat) : Nat := |
| 30 | ((raddr - BB_BASE) / 4194304) % 4 |
| 31 | |
| 32 | def raddrSort (raddr : Nat) : Nat := |
| 33 | ((raddr - BB_BASE) / 262144) % 16 |
| 34 | |
| 35 | def raddrSlot (raddr : Nat) : Nat := |
| 36 | ((raddr - BB_BASE) / 256) % 1024 |
| 37 | |
| 38 | theorem raddr_verb_roundtrip (v s m : Nat) (hv : v < 4) (hs : s < 16) (hm : m < 1024) : |
| 39 | raddrVerb (raddrEncode v s m) = v := by |
| 40 | unfold raddrVerb raddrEncode |
| 41 | omega |
| 42 | |
| 43 | theorem raddr_sort_roundtrip (v s m : Nat) (hv : v < 4) (hs : s < 16) (hm : m < 1024) : |
| 44 | raddrSort (raddrEncode v s m) = s := by |
| 45 | unfold raddrSort raddrEncode |
| 46 | omega |
| 47 | |
| 48 | theorem raddr_slot_roundtrip (v s m : Nat) (hv : v < 4) (hs : s < 16) (hm : m < 1024) : |
| 49 | raddrSlot (raddrEncode v s m) = m := by |
| 50 | unfold raddrSlot raddrEncode |
| 51 | omega |
| 52 | |
| 53 | theorem raddr_injective (v1 s1 m1 v2 s2 m2 : Nat) |
| 54 | (hv1 : v1 < 4) (hs1 : s1 < 16) (hm1 : m1 < 1024) |
| 55 | (hv2 : v2 < 4) (hs2 : s2 < 16) (hm2 : m2 < 1024) |
| 56 | (heq : raddrEncode v1 s1 m1 = raddrEncode v2 s2 m2) : |
| 57 | v1 = v2 ∧ s1 = s2 ∧ m1 = m2 := by |
| 58 | have hv : raddrVerb (raddrEncode v1 s1 m1) = raddrVerb (raddrEncode v2 s2 m2) := by rw [heq] |
| 59 | have hs : raddrSort (raddrEncode v1 s1 m1) = raddrSort (raddrEncode v2 s2 m2) := by rw [heq] |
| 60 | have hm : raddrSlot (raddrEncode v1 s1 m1) = raddrSlot (raddrEncode v2 s2 m2) := by rw [heq] |
| 61 | rw [raddr_verb_roundtrip v1 s1 m1 hv1 hs1 hm1, raddr_verb_roundtrip v2 s2 m2 hv2 hs2 hm2] at hv |
| 62 | rw [raddr_sort_roundtrip v1 s1 m1 hv1 hs1 hm1, raddr_sort_roundtrip v2 s2 m2 hv2 hs2 hm2] at hs |
| 63 | rw [raddr_slot_roundtrip v1 s1 m1 hv1 hs1 hm1, raddr_slot_roundtrip v2 s2 m2 hv2 hs2 hm2] at hm |
| 64 | exact ⟨hv, hs, hm⟩ |
| 65 | |
| 66 | -- ============================================================================ |
| 67 | -- 2. Hardware rkey / SMMUv3 Aperture Isolation (telepathy.om) |
| 68 | -- ============================================================================ |
| 69 | |
| 70 | def rkeyAdmit (verb : Nat) (mask : Nat) : Bool := |
| 71 | (mask / (2 ^ verb)) % 2 == 1 |
| 72 | |
| 73 | theorem ask_offer_peer_cannot_graft_basis : |
| 74 | ∀ s m, s < 16 → m < 1024 → rkeyAdmit (raddrVerb (raddrEncode 2 s m)) 3 = false := by |
| 75 | intro s m hs hm |
| 76 | rw [raddr_verb_roundtrip 2 s m (by omega) hs hm] |
| 77 | decide |
| 78 | |
| 79 | theorem ask_offer_peer_cannot_write_kv : |
| 80 | ∀ s m, s < 16 → m < 1024 → rkeyAdmit (raddrVerb (raddrEncode 3 s m)) 3 = false := by |
| 81 | intro s m hs hm |
| 82 | rw [raddr_verb_roundtrip 3 s m (by omega) hs hm] |
| 83 | decide |
| 84 | |
| 85 | -- Broken-model negative control: over-privileged mask=7 DOES allow BASIS write |
| 86 | theorem neg_ctrl_overprivileged_mask_breaks_isolation : |
| 87 | rkeyAdmit (raddrVerb (raddrEncode 2 5 712)) 7 = true := by |
| 88 | rw [raddr_verb_roundtrip 2 5 712 (by omega) (by omega) (by omega)] |
| 89 | decide |
| 90 | |
| 91 | -- ============================================================================ |
| 92 | -- 3. Holographic Law Blackboard 64-Bit Lattice CAS (telepathy.om) |
| 93 | -- ============================================================================ |
| 94 | |
| 95 | structure Cell where |
| 96 | hasWinner : Bool |
| 97 | cost : Nat |
| 98 | vmask : Nat |
| 99 | deriving DecidableEq |
| 100 | |
| 101 | def bbCasStep (c : Cell) (newCost newVmask : Nat) : Cell := |
| 102 | if newVmask == 0 then c |
| 103 | else if c.hasWinner && newCost >= c.cost then c |
| 104 | else ⟨true, newCost, newVmask⟩ |
| 105 | |
| 106 | theorem bb_cas_never_admits_unverified (c : Cell) (cost : Nat) : |
| 107 | bbCasStep c cost 0 = c := by |
| 108 | simp [bbCasStep] |
| 109 | |
| 110 | theorem bb_cas_monotone_cost (c : Cell) (newCost newVmask : Nat) (hw : c.hasWinner = true) : |
| 111 | (bbCasStep c newCost newVmask).cost ≤ c.cost := by |
| 112 | unfold bbCasStep |
| 113 | by_cases h0 : newVmask == 0 |
| 114 | · simp [h0] |
| 115 | · simp [h0, hw] |
| 116 | by_cases hge : c.cost ≤ newCost |
| 117 | · simp [hge] |
| 118 | · simp [hge]; omega |
| 119 | |
| 120 | -- Broken-model negative control: a buggy CAS without cost check CAN increase cost (19 -> 55) |
| 121 | def buggyCasStep (c : Cell) (newCost newVmask : Nat) : Cell := |
| 122 | if newVmask == 0 then c else ⟨true, newCost, newVmask⟩ |
| 123 | |
| 124 | theorem neg_ctrl_buggy_cas_regresses_cost : |
| 125 | (buggyCasStep ⟨true, 19, 7⟩ 55 7).cost > 19 := by |
| 126 | decide |
| 127 | |
| 128 | -- ============================================================================ |
| 129 | -- 4. Gate 64 (omkc_direct.om) Motif Arity & Sort Soundness |
| 130 | -- ============================================================================ |
| 131 | |
| 132 | def motifPop (t : Nat) : Nat := |
| 133 | if t == 769 then 1 else 0 |
| 134 | |
| 135 | def motifPush (t : Nat) : Nat := |
| 136 | if t == 768 then 1 else 0 |
| 137 | |
| 138 | def motifSort (t : Nat) : Nat := |
| 139 | if t == 768 || t == 769 || t == 770 then 1 |
| 140 | else if t == 771 then 2 |
| 141 | else 0 |
| 142 | |
| 143 | def gate64Walk (targetSort : Nat) : Nat → List Nat → Option Nat |
| 144 | | sp, [] => if sp == 0 then some 0 else none |
| 145 | | sp, t :: rest => |
| 146 | if motifSort t != targetSort then none |
| 147 | else if sp < motifPop t then none |
| 148 | else gate64Walk targetSort (sp - motifPop t + motifPush t) rest |
| 149 | |
| 150 | def gate64Pass (targetSort : Nat) (toks : List Nat) : Bool := |
| 151 | (gate64Walk targetSort 0 toks).isSome |
| 152 | |
| 153 | theorem gate64_accepts_valid_sass_kernel : |
| 154 | gate64Pass 1 [768, 769, 770] = true := by |
| 155 | decide |
| 156 | |
| 157 | -- Broken-model negative controls: unclosed OMMA tile & cross-sort injection MUST be rejected |
| 158 | theorem neg_ctrl_gate64_rejects_unclosed_omma : |
| 159 | gate64Pass 1 [768, 770] = false := by |
| 160 | decide |
| 161 | |
| 162 | theorem neg_ctrl_gate64_rejects_cross_sort_injection : |
| 163 | gate64Pass 1 [771] = false := by |
| 164 | decide |
| 165 | |
| 166 | -- ============================================================================ |
| 167 | -- 5. Single-Op ATOMG.E.MIN.U64 In-L2 Monotonic Semilattice (vfio_council.om) |
| 168 | -- word = (cost:u16 << 48) | ((0xFFFF - vmask:u16) << 32) | whash:u32 |
| 169 | -- Empty cell = 0xFFFFFFFFFFFFFFFF; verified offers have vmask > 0, cost < 65535. |
| 170 | -- ============================================================================ |
| 171 | |
| 172 | def U64_LIMIT : Nat := 18446744073709551616 |
| 173 | |
| 174 | def latticePackMin (cost vmask whash : Nat) : Nat := |
| 175 | (cost % 65536) * 281474976710656 + (65535 - (vmask % 65536)) * 4294967296 + (whash % 4294967296) |
| 176 | |
| 177 | def latticeWordCost (w : Nat) : Nat := |
| 178 | (w / 281474976710656) % 65536 |
| 179 | |
| 180 | def atomgMinU64 (cur offer : Nat) : Nat := |
| 181 | min cur offer |
| 182 | |
| 183 | def atomgMinOffer (cur cost vmask whash : Nat) : Nat := |
| 184 | if vmask == 0 || cost >= 65535 then cur |
| 185 | else atomgMinU64 cur (latticePackMin cost vmask whash) |
| 186 | |
| 187 | theorem latticeWordCost_pack (cost vmask whash : Nat) (hc : cost < 65536) : |
| 188 | latticeWordCost (latticePackMin cost vmask whash) = cost := by |
| 189 | unfold latticeWordCost latticePackMin |
| 190 | omega |
| 191 | |
| 192 | theorem atomg_min_never_admits_unverified (cur cost whash : Nat) : |
| 193 | atomgMinOffer cur cost 0 whash = cur := by |
| 194 | simp [atomgMinOffer] |
| 195 | |
| 196 | theorem atomg_min_monotone_cost (cur cost vmask whash : Nat) (hcur : cur < U64_LIMIT) : |
| 197 | latticeWordCost (atomgMinOffer cur cost vmask whash) ≤ latticeWordCost cur := by |
| 198 | unfold atomgMinOffer atomgMinU64 latticeWordCost latticePackMin U64_LIMIT at * |
| 199 | split |
| 200 | · omega |
| 201 | · omega |
| 202 | |
| 203 | theorem atomg_min_comm (a b : Nat) : |
| 204 | atomgMinU64 a b = atomgMinU64 b a := by |
| 205 | unfold atomgMinU64 |
| 206 | exact Nat.min_comm a b |
| 207 | |
| 208 | theorem atomg_min_assoc (a b c : Nat) : |
| 209 | atomgMinU64 (atomgMinU64 a b) c = atomgMinU64 a (atomgMinU64 b c) := by |
| 210 | unfold atomgMinU64 |
| 211 | exact Nat.min_assoc a b c |
| 212 | |
| 213 | -- Broken-model negative control: forgetting to invert vmask lets a weaker verifier (1) beat a stronger one (7) |
| 214 | def buggyPackMin (cost vmask whash : Nat) : Nat := |
| 215 | (cost % 65536) * 281474976710656 + (vmask % 65536) * 4294967296 + (whash % 4294967296) |
| 216 | |
| 217 | theorem neg_ctrl_uninverted_vmask_prefers_weaker_verifier : |
| 218 | buggyPackMin 19 1 0 < buggyPackMin 19 7 0 ∧ latticePackMin 19 7 0 < latticePackMin 19 1 0 := by |
| 219 | decide |
| 220 | |
| 221 | -- ============================================================================ |
| 222 | -- 6. Holographic 10,240-Bit VSA Blackboard & CAS Bridge (holo_blackboard.om) |
| 223 | -- 160 x u64 = 1,280 B cell; bundle cap <= 5; margin <= 3200; gap >= 400; |
| 224 | -- exact .omk DAG hash match required before ATOMG.E.MIN.U64 admission. |
| 225 | -- ============================================================================ |
| 226 | |
| 227 | def HOLO_DIM : Nat := 10240 |
| 228 | def HOLO_MAX_BUNDLE : Nat := 5 |
| 229 | def VSA_MARGIN_MAX : Nat := 3200 |
| 230 | def VSA_MIN_GAP : Nat := 400 |
| 231 | |
| 232 | abbrev HoloHv := Fin HOLO_DIM → Bool |
| 233 | |
| 234 | def holoBind (a b : HoloHv) : HoloHv := |
| 235 | fun i => xor (a i) (b i) |
| 236 | |
| 237 | theorem holo_bind_self_inverse (role motif : HoloHv) : |
| 238 | holoBind (holoBind role motif) role = motif := by |
| 239 | funext i |
| 240 | simp only [holoBind] |
| 241 | cases role i <;> cases motif i <;> rfl |
| 242 | |
| 243 | theorem holo_bind_left_inverse (role motif : HoloHv) : |
| 244 | holoBind role (holoBind role motif) = motif := by |
| 245 | funext i |
| 246 | simp only [holoBind] |
| 247 | cases role i <;> cases motif i <;> rfl |
| 248 | |
| 249 | def holoCasOffer (cur bundleCnt bestDist secDist gotHash expHash cost vmask : Nat) : Nat := |
| 250 | if bundleCnt == 0 || bundleCnt > HOLO_MAX_BUNDLE then cur |
| 251 | else if bestDist > VSA_MARGIN_MAX || secDist < bestDist + VSA_MIN_GAP then cur |
| 252 | else if gotHash != expHash then cur |
| 253 | else atomgMinOffer cur cost vmask gotHash |
| 254 | |
| 255 | theorem holo_cas_rejects_over_cap (cur bundleCnt bestDist secDist gotHash expHash cost vmask : Nat) |
| 256 | (hcap : bundleCnt > HOLO_MAX_BUNDLE) : |
| 257 | holoCasOffer cur bundleCnt bestDist secDist gotHash expHash cost vmask = cur := by |
| 258 | unfold holoCasOffer HOLO_MAX_BUNDLE at * |
| 259 | have h1 : (bundleCnt == 0 || decide (bundleCnt > 5)) = true := by |
| 260 | simp [hcap] |
| 261 | simp [h1] |
| 262 | |
| 263 | theorem holo_cas_rejects_low_margin (cur bundleCnt bestDist secDist gotHash expHash cost vmask : Nat) |
| 264 | (hbad : bestDist > VSA_MARGIN_MAX) : |
| 265 | holoCasOffer cur bundleCnt bestDist secDist gotHash expHash cost vmask = cur := by |
| 266 | unfold holoCasOffer VSA_MARGIN_MAX at * |
| 267 | have h2 : (decide (bestDist > 3200) || decide (secDist < bestDist + VSA_MIN_GAP)) = true := by |
| 268 | simp [hbad] |
| 269 | by_cases h1 : (bundleCnt == 0 || decide (bundleCnt > HOLO_MAX_BUNDLE)) = true |
| 270 | · simp [h1] |
| 271 | · simp [h1, h2] |
| 272 | |
| 273 | theorem holo_cas_rejects_forged_hash (cur bundleCnt bestDist secDist gotHash expHash cost vmask : Nat) |
| 274 | (hne : gotHash ≠ expHash) : |
| 275 | holoCasOffer cur bundleCnt bestDist secDist gotHash expHash cost vmask = cur := by |
| 276 | unfold holoCasOffer |
| 277 | have hne_b : (gotHash != expHash) = true := by |
| 278 | simp [bne_iff_ne, hne] |
| 279 | by_cases h1 : (bundleCnt == 0 || bundleCnt > HOLO_MAX_BUNDLE) = true |
| 280 | · simp [h1] |
| 281 | · by_cases h2 : (bestDist > VSA_MARGIN_MAX || secDist < bestDist + VSA_MIN_GAP) = true |
| 282 | · simp [h1, h2] |
| 283 | · simp [h1, h2, hne_b] |
| 284 | |
| 285 | theorem holo_cas_monotone_cost (cur bundleCnt bestDist secDist gotHash expHash cost vmask : Nat) |
| 286 | (hcur : cur < U64_LIMIT) : |
| 287 | latticeWordCost (holoCasOffer cur bundleCnt bestDist secDist gotHash expHash cost vmask) ≤ |
| 288 | latticeWordCost cur := by |
| 289 | unfold holoCasOffer |
| 290 | split |
| 291 | · exact Nat.le_refl _ |
| 292 | · split |
| 293 | · exact Nat.le_refl _ |
| 294 | · split |
| 295 | · exact Nat.le_refl _ |
| 296 | · exact atomg_min_monotone_cost cur cost vmask gotHash hcur |
| 297 | |
| 298 | -- Broken-model negative control: removing bundle-cap & margin guards lets an over-bundled noisy cell (k=9, dist=4900) overwrite cost=19 |
| 299 | def buggyHoloCasOffer (cur cost vmask gotHash : Nat) : Nat := |
| 300 | atomgMinOffer cur cost vmask gotHash |
| 301 | |
| 302 | theorem neg_ctrl_uncapped_holo_admits_noise : |
| 303 | latticeWordCost (buggyHoloCasOffer (latticePackMin 19 7 42) 5 7 42) = 5 ∧ |
| 304 | latticeWordCost (holoCasOffer (latticePackMin 19 7 42) 9 4900 5000 42 42 5 7) = 19 := by |
| 305 | decide |
| 306 | |
| 307 | -- ============================================================================ |
| 308 | -- 7. Level-4 E-Graph Equational Quotienting (omkc_egraph.om / EGP3) |
| 309 | -- 64-bit wrapping AST semantics + FMA/commutativity/annihilation/pow2-shift |
| 310 | -- quotienting + SEMANTIC_ID congruence + unsound-rewrite negative controls. |
| 311 | -- ============================================================================ |
| 312 | |
| 313 | inductive EgExpr where |
| 314 | | const (v : BitVec 64) |
| 315 | | ssa (id : Nat) |
| 316 | | add (a b : EgExpr) |
| 317 | | sub (a b : EgExpr) |
| 318 | | mul (a b : EgExpr) |
| 319 | | fma (a b c : EgExpr) |
| 320 | | shl (a s : EgExpr) |
| 321 | | bxor (a b : EgExpr) |
| 322 | deriving DecidableEq |
| 323 | |
| 324 | def egEval (env : Nat → BitVec 64) : EgExpr → BitVec 64 |
| 325 | | .const v => v |
| 326 | | .ssa id => env id |
| 327 | | .add a b => egEval env a + egEval env b |
| 328 | | .sub a b => egEval env a - egEval env b |
| 329 | | .mul a b => egEval env a * egEval env b |
| 330 | | .fma a b c => (egEval env a * egEval env b) + egEval env c |
| 331 | | .shl a s => egEval env a <<< ((egEval env s).toNat % 64) |
| 332 | | .bxor a b => egEval env a ^^^ egEval env b |
| 333 | |
| 334 | theorem eg_fma_comm_quotient_sound (env : Nat → BitVec 64) (a b c : EgExpr) : |
| 335 | egEval env (.add (.mul a b) c) = egEval env (.fma a b c) ∧ |
| 336 | egEval env (.add c (.mul b a)) = egEval env (.fma a b c) := by |
| 337 | constructor |
| 338 | · rfl |
| 339 | · simp [egEval, BitVec.add_comm, BitVec.mul_comm] |
| 340 | |
| 341 | theorem eg_add_zero_mul_one_sound (env : Nat → BitVec 64) (x : EgExpr) : |
| 342 | egEval env (.add (.mul x (.const 1#64)) (.const 0#64)) = egEval env x := by |
| 343 | simp [egEval] |
| 344 | |
| 345 | theorem eg_sub_self_xor_self_sound (env : Nat → BitVec 64) (x : EgExpr) : |
| 346 | egEval env (.sub x x) = 0#64 ∧ egEval env (.bxor x x) = 0#64 := by |
| 347 | simp [egEval] |
| 348 | |
| 349 | theorem eg_mul_pow2_shl_sound (env : Nat → BitVec 64) (x : EgExpr) (k : Nat) (hk : k < 64) : |
| 350 | egEval env (.mul x (.const ((1#64) <<< k))) = |
| 351 | egEval env (.shl x (.const (BitVec.ofNat 64 k))) := by |
| 352 | apply BitVec.eq_of_toNat_eq |
| 353 | simp only [egEval, BitVec.toNat_mul, BitVec.toNat_shiftLeft, BitVec.toNat_ofNat, |
| 354 | Nat.shiftLeft_eq] |
| 355 | have hk_lt : k < 2 ^ 64 := by omega |
| 356 | have h1_lt : 1 < 2 ^ 64 := by omega |
| 357 | rw [Nat.mod_eq_of_lt hk_lt, Nat.mod_eq_of_lt hk, Nat.mod_eq_of_lt h1_lt, Nat.one_mul] |
| 358 | rw [Nat.mul_mod, Nat.mod_mod, ← Nat.mul_mod] |
| 359 | |
| 360 | theorem eg_semantic_id_congruent (semId : EgExpr → Nat) (norm : EgExpr → EgExpr) |
| 361 | (e1 e2 : EgExpr) (hnorm : norm e1 = norm e2) : |
| 362 | semId (norm e1) = semId (norm e2) := by |
| 363 | rw [hnorm] |
| 364 | |
| 365 | -- Broken-model negative control: unsound add->mul and mul(x,3)->shl(x,1) are refuted on concrete env |
| 366 | def witnessEnv : Nat → BitVec 64 |
| 367 | | 0 => 5#64 |
| 368 | | 1 => 7#64 |
| 369 | | _ => 0#64 |
| 370 | |
| 371 | theorem neg_ctrl_unsound_eg_rewrites_refuted : |
| 372 | egEval witnessEnv (.add (.ssa 0) (.ssa 1)) ≠ egEval witnessEnv (.mul (.ssa 0) (.ssa 1)) ∧ |
| 373 | egEval witnessEnv (.mul (.ssa 0) (.const 3#64)) ≠ egEval witnessEnv (.shl (.ssa 0) (.const 1#64)) := by |
| 374 | decide |
| 375 | |
| 376 | -- ============================================================================ |
| 377 | -- 8. Exact Zero-Float Ring (UOR + AQM) & Lossless 4 KiB vRAM (exact_ring_vram.om) |
| 378 | -- Z/2^64Z Merkle Delta-Matmul, Z[zeta_8]/(sqrt(2))^k exact norm conservation, |
| 379 | -- and lossless 4 KiB VOMV tensor-page round-trip verification. |
| 380 | -- ============================================================================ |
| 381 | |
| 382 | theorem uor_merkle_delta_exact (a_old a_new w : BitVec 64) : |
| 383 | a_old * w + (a_new - a_old) * w = a_new * w := by |
| 384 | rw [← BitVec.add_mul] |
| 385 | have h : a_old + (a_new - a_old) = a_new := by |
| 386 | rw [BitVec.add_comm, BitVec.sub_add_cancel] |
| 387 | rw [h] |
| 388 | |
| 389 | theorem aqm_hadamard_preserves_norm_doubled (x0 x1 : Int) : |
| 390 | (x0 + x1) * (x0 + x1) + (x0 - x1) * (x0 - x1) = 2 * (x0 * x0 + x1 * x1) := by |
| 391 | have h1 : (x0 + x1) * (x0 + x1) = x0 * x0 + 2 * (x0 * x1) + x1 * x1 := by |
| 392 | rw [Int.add_mul, Int.mul_add, Int.mul_add, Int.mul_comm x1 x0] |
| 393 | omega |
| 394 | have h2 : (x0 - x1) * (x0 - x1) = x0 * x0 - 2 * (x0 * x1) + x1 * x1 := by |
| 395 | rw [Int.sub_mul, Int.mul_sub, Int.mul_sub, Int.mul_comm x1 x0] |
| 396 | omega |
| 397 | omega |
| 398 | |
| 399 | def cycNorm (a b c d : Int) : Int := |
| 400 | a * a + b * b + c * c + d * d |
| 401 | |
| 402 | theorem aqm_t_gate_preserves_norm (a b c d : Int) : |
| 403 | cycNorm (-d) a b c = cycNorm a b c d := by |
| 404 | unfold cycNorm |
| 405 | have hd : (-d) * (-d) = d * d := Int.neg_mul_neg d d |
| 406 | omega |
| 407 | |
| 408 | def vramDecodeFill (b : UInt8) (_i : Fin 4096) : UInt8 := b |
| 409 | |
| 410 | theorem vram_fill_roundtrip (b : UInt8) (i : Fin 4096) : |
| 411 | vramDecodeFill b i = b := rfl |
| 412 | |
| 413 | def vramAdmit (rawOk : Bool) (modeTag : Nat) : Bool := |
| 414 | rawOk && (modeTag == 0 || modeTag == 1 || modeTag == 2 || modeTag == 3 || modeTag == 4) |
| 415 | |
| 416 | theorem vram_admit_rejects_mismatch (modeTag : Nat) : |
| 417 | vramAdmit false modeTag = false := by |
| 418 | simp [vramAdmit] |
| 419 | |
| 420 | -- Broken-model negative control: +1 AQM limb drift breaks norm=4 (gives 7), and invalid mode tag 9 is rejected |
| 421 | theorem neg_ctrl_aqm_drift_and_vram_tamper : |
| 422 | cycNorm 2 1 1 1 ≠ 4 ∧ vramAdmit true 9 = false := by |
| 423 | decide |
| 424 | |
| 425 | #print axioms raddr_verb_roundtrip |
| 426 | #print axioms raddr_sort_roundtrip |
| 427 | #print axioms raddr_slot_roundtrip |
| 428 | #print axioms raddr_injective |
| 429 | #print axioms ask_offer_peer_cannot_graft_basis |
| 430 | #print axioms ask_offer_peer_cannot_write_kv |
| 431 | #print axioms neg_ctrl_overprivileged_mask_breaks_isolation |
| 432 | #print axioms bb_cas_never_admits_unverified |
| 433 | #print axioms bb_cas_monotone_cost |
| 434 | #print axioms neg_ctrl_buggy_cas_regresses_cost |
| 435 | #print axioms gate64_accepts_valid_sass_kernel |
| 436 | #print axioms neg_ctrl_gate64_rejects_unclosed_omma |
| 437 | #print axioms neg_ctrl_gate64_rejects_cross_sort_injection |
| 438 | #print axioms latticeWordCost_pack |
| 439 | #print axioms atomg_min_never_admits_unverified |
| 440 | #print axioms atomg_min_monotone_cost |
| 441 | #print axioms atomg_min_comm |
| 442 | #print axioms atomg_min_assoc |
| 443 | #print axioms neg_ctrl_uninverted_vmask_prefers_weaker_verifier |
| 444 | #print axioms holo_bind_self_inverse |
| 445 | #print axioms holo_bind_left_inverse |
| 446 | #print axioms holo_cas_rejects_over_cap |
| 447 | #print axioms holo_cas_rejects_low_margin |
| 448 | #print axioms holo_cas_rejects_forged_hash |
| 449 | #print axioms holo_cas_monotone_cost |
| 450 | #print axioms neg_ctrl_uncapped_holo_admits_noise |
| 451 | #print axioms eg_fma_comm_quotient_sound |
| 452 | #print axioms eg_add_zero_mul_one_sound |
| 453 | #print axioms eg_sub_self_xor_self_sound |
| 454 | #print axioms eg_mul_pow2_shl_sound |
| 455 | #print axioms eg_semantic_id_congruent |
| 456 | #print axioms neg_ctrl_unsound_eg_rewrites_refuted |
| 457 | #print axioms uor_merkle_delta_exact |
| 458 | #print axioms aqm_hadamard_preserves_norm_doubled |
| 459 | #print axioms aqm_t_gate_preserves_norm |
| 460 | #print axioms vram_fill_roundtrip |
| 461 | #print axioms vram_admit_rejects_mismatch |
| 462 | #print axioms neg_ctrl_aqm_drift_and_vram_tamper |
| 463 | |
| 464 | end OmkBase |