File size: 1,897 Bytes
9425aed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
-- BOB Quantum Kernel Error Status (WORM-sealed)
-- Phase 2: Loop Invariant Formalization
-- Status: Observable error codes tied to WORM logs (bookkeeping only)

module Core.ErrorCode where

open import Data.Nat using (β„•)

-- Error status codes (copied from bob_errors.f90 enum)
data ErrorCode : Set where
  BOB_SUCCESS             : ErrorCode  -- 0 (no error)
  BOB_ERROR_ALLOCATION    : ErrorCode  -- Memory allocation failure
  BOB_ERROR_INVALID_STATE : ErrorCode  -- Invalid quantum state
  BOB_ERROR_INVALID_GATE  : ErrorCode  -- Invalid gate operation
  BOB_ERROR_NOT_UNITARY   : ErrorCode  -- Matrix is not unitary
  BOB_ERROR_INVALID_ARGUMENT : ErrorCode  -- Bad argument
  BOB_ERROR_DIMENSION_MISMATCH : ErrorCode  -- Dimension mismatch
  BOB_ERROR_OTHER         : ErrorCode  -- Other error

-- Decidable equality for error codes
_==β‚‘_ : ErrorCode β†’ ErrorCode β†’ Set
BOB_SUCCESS ==β‚‘ BOB_SUCCESS = Set
BOB_SUCCESS ==β‚‘ _           = βŠ₯
BOB_ERROR_ALLOCATION ==β‚‘ BOB_ERROR_ALLOCATION = Set
BOB_ERROR_ALLOCATION ==β‚‘ _                     = βŠ₯
BOB_ERROR_INVALID_STATE ==β‚‘ BOB_ERROR_INVALID_STATE = Set
BOB_ERROR_INVALID_STATE ==β‚‘ _                        = βŠ₯
BOB_ERROR_INVALID_GATE ==β‚‘ BOB_ERROR_INVALID_GATE = Set
BOB_ERROR_INVALID_GATE ==β‚‘ _                       = βŠ₯
BOB_ERROR_NOT_UNITARY ==β‚‘ BOB_ERROR_NOT_UNITARY = Set
BOB_ERROR_NOT_UNITARY ==β‚‘ _                      = βŠ₯
BOB_ERROR_INVALID_ARGUMENT ==β‚‘ BOB_ERROR_INVALID_ARGUMENT = Set
BOB_ERROR_INVALID_ARGUMENT ==β‚‘ _                           = βŠ₯
BOB_ERROR_DIMENSION_MISMATCH ==β‚‘ BOB_ERROR_DIMENSION_MISMATCH = Set
BOB_ERROR_DIMENSION_MISMATCH ==β‚‘ _                              = βŠ₯
BOB_ERROR_OTHER ==β‚‘ BOB_ERROR_OTHER = Set
BOB_ERROR_OTHER ==β‚‘ _               = βŠ₯

-- Predicate: no error occurred
isSuccess : ErrorCode β†’ Set
isSuccess BOB_SUCCESS = Set
isSuccess _           = βŠ₯