|
|
|
|
|
|
|
|
|
|
| module QuantumSpec where
|
|
|
| open import Data.Nat using (β; _<_; suc; zero; _+_)
|
| open import Data.Bool using (Bool; true; false)
|
| open import Data.Product using (_Γ_; _,_; β)
|
| open import Data.Sum using (_β_; injβ; injβ)
|
| open import Relation.Binary.PropositionalEquality using (_β‘_; refl)
|
| open import Data.Empty using (β₯; β₯-elim)
|
|
|
|
|
|
|
|
|
|
|
| data FSMState : Set where
|
| Init : FSMState
|
| Prepare : FSMState
|
| Entangle : FSMState
|
| Compute : FSMState
|
| Measure : FSMState
|
| Verify : FSMState
|
| Commit : FSMState
|
| Halted : FSMState
|
| CycleLimit : FSMState
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| data Transition : FSMState β FSMState β Set where
|
| T-Init-Prepare : Transition Init Prepare
|
| T-Prep-Entangle : Transition Prepare Entangle
|
| T-Ent-Compute : Transition Entangle Compute
|
| T-Comp-Measure : Transition Compute Measure
|
| T-Meas-Verify : Transition Measure Verify
|
| T-Veri-Commit : Transition Verify Commit
|
| T-Comm-Prepare : Transition Commit Prepare
|
| T-Comm-Commit : Transition Commit Commit
|
| T-Any-Halted : β {s} β Transition s Halted
|
|
|
|
|
|
|
|
|
|
|
| data Terminal : FSMState β Set where
|
| T-Halted : Terminal Halted
|
| T-Cycle : Terminal CycleLimit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| halted-absorbing : β {s'} β Transition Halted s' β s' β‘ Halted
|
| halted-absorbing T-Any-Halted = refl
|
| -- No other constructor has Halted as its first argument β proof is total.
|
|
|
| cyclelimit-absorbing : β {s'} β Transition CycleLimit s' β s' β‘ Halted
|
| cyclelimit-absorbing T-Any-Halted = refl
|
|
|
|
|
|
|
|
|
|
|
| record FSM : Set where
|
| field
|
| state : FSMState
|
| cycle : β
|
| maxCycle : β
|
| bounded : cycle < suc maxCycle
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| data StepResult : Set where
|
| Ok : FSM β StepResult
|
| Err : StepResult
|
|
|
| step : (fsm : FSM) β (s' : FSMState) β Transition (FSM.state fsm) s' β StepResult
|
| step fsm s' t with FSM.cycle fsm < FSM.maxCycle
|
| ... | false = Ok (record fsm { state = CycleLimit })
|
| ... | true = Ok (record fsm
|
| { state = s'
|
| ; cycle = suc (FSM.cycle fsm)
|
| ; bounded = {!!}
|
| })
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| postulate
|
| Amp : Set
|
| normSq : Amp β β
|
|
|
|
|
| StateVec : β β Set
|
| StateVec n = (i : β) β Amp
|
|
|
| postulate
|
| sumNormSq : β {n} β StateVec n β β
|
|
|
|
|
| Normalised : β {n} β StateVec n β Set
|
| Normalised {n} Ο = sumNormSq Ο β‘ 1
|
|
|
|
|
| IsUnitary : β {n} β (StateVec n β StateVec n) β Set
|
| IsUnitary {n} U = β Ο β Normalised Ο β Normalised (U Ο)
|
|
|
|
|
| inv1 : β {n} (Ο : StateVec n) (U : StateVec n β StateVec n)
|
| β IsUnitary U β Normalised Ο β Normalised (U Ο)
|
| inv1 Ο U hU hN = hU Ο hN
|
|
|
|
|
|
|
|
|
|
|
| postulate
|
| QubitSet : Set
|
| β
: QubitSet
|
| _β©_ : QubitSet β QubitSet β QubitSet
|
| emptyInter : β (a b : QubitSet) β Set
|
|
|
|
|
| OwnershipDisjoint : QubitSet β QubitSet β Set
|
| OwnershipDisjoint a b = emptyInter a b
|
|
|
|
|
| postulate
|
| inv7 : β (a b : QubitSet) β OwnershipDisjoint a b
|
| β β q β q β a β q β b
|
| where
|
| postulate
|
| _β_ : β β QubitSet β Set
|
| _β_ : β β QubitSet β Set
|
|
|