Safe Haskell | None |
---|
QuipperLib.ClassicalOptim.Circuit
Contents
Description
This module provides a simplified representation of classical circuits.
- type Wire = Int
- data Gate
- wireOfGate :: Gate -> Maybe Wire
- ctlsOfGate :: Gate -> Maybe [(Wire, Bool)]
- evalCirc :: Map Wire Bool -> [Gate] -> Map Wire Bool
- data CircState = CS {}
- emptyState :: CircState
- data Circ a = Circ (CircState -> (CircState, a))
- getFresh :: Circ Wire
- incrementFresh :: Circ ()
- addGate :: Gate -> Circ ()
- extractCircuit :: Circ a -> [Gate]
- init :: Bool -> Circ Wire
- cnot :: Wire -> [(Wire, Bool)] -> Circ ()
- printCircuit :: Circ a -> IO ()
- print_quipperStyle :: Gate -> IO ()
Simplified circuits
The type of gates.
wireOfGate :: Gate -> Maybe WireSource
Get the wire acted upon by a gate, if any.
evalCirc :: Map Wire Bool -> [Gate] -> Map Wire BoolSource
Evaluate a circuit on a given initial state, and return the final state. A state is represented as a map from wires to booleans.
Simplified Circ monad
A data structure to represent a "circuit under construction". This holds the data needed for circuit generation.
The empty state.
A simplified Circ
monad.
Low-level access functions
incrementFresh :: Circ ()Source
Increment the value of the fresh wire.
extractCircuit :: Circ a -> [Gate]Source
Get the circuit out of the monad.
Higher-level access functions
Pretty-printing
These functions are only used for testing.
printCircuit :: Circ a -> IO ()Source
Pretty-print a circuit as a list of gates.
print_quipperStyle :: Gate -> IO ()Source
Print a gate as Quipper code.