The Quipper System

Safe HaskellNone

Quipper.Libraries.ClassicalOptim.Circuit

Contents

Description

This module provides a simplified representation of classical circuits.

Synopsis

Simplified circuits

type Wire = Int Source #

The type of wires. A wire is determined by an integer ID.

data Gate Source #

The type of gates.

Constructors

NoOp

No operation.

Init Bool Wire

Initialization.

Cnot Wire [(Wire, Bool)]

Multi-controlled not.

Instances
Eq Gate # 
Instance details

Defined in Quipper.Libraries.ClassicalOptim.Circuit

Methods

(==) :: Gate -> Gate -> Bool #

(/=) :: Gate -> Gate -> Bool #

Show Gate # 
Instance details

Defined in Quipper.Libraries.ClassicalOptim.Circuit

Methods

showsPrec :: Int -> Gate -> ShowS #

show :: Gate -> String #

showList :: [Gate] -> ShowS #

NFData Gate 
Instance details

Defined in Quipper.Libraries.ClassicalOptim.Simplification

Methods

rnf :: Gate -> ()

wireOfGate :: Gate -> Maybe Wire Source #

Get the wire acted upon by a gate, if any.

ctlsOfGate :: Gate -> Maybe [(Wire, Bool)] Source #

Get the list of controls, if any.

evalCirc :: Map Wire Bool -> [Gate] -> Map Wire Bool Source #

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

data CircState Source #

A data structure to represent a "circuit under construction". This holds the data needed for circuit generation.

Constructors

CS 

Fields

emptyState :: CircState Source #

The empty state.

data Circ a Source #

A simplified Circ monad.

Constructors

Circ (CircState -> (CircState, a)) 
Instances
Monad Circ # 
Instance details

Defined in Quipper.Libraries.ClassicalOptim.Circuit

Methods

(>>=) :: Circ a -> (a -> Circ b) -> Circ b #

(>>) :: Circ a -> Circ b -> Circ b #

return :: a -> Circ a #

fail :: String -> Circ a #

Functor Circ # 
Instance details

Defined in Quipper.Libraries.ClassicalOptim.Circuit

Methods

fmap :: (a -> b) -> Circ a -> Circ b #

(<$) :: a -> Circ b -> Circ a #

Applicative Circ # 
Instance details

Defined in Quipper.Libraries.ClassicalOptim.Circuit

Methods

pure :: a -> Circ a #

(<*>) :: Circ (a -> b) -> Circ a -> Circ b #

liftA2 :: (a -> b -> c) -> Circ a -> Circ b -> Circ c #

(*>) :: Circ a -> Circ b -> Circ b #

(<*) :: Circ a -> Circ b -> Circ a #

Low-level access functions

getFresh :: Circ Wire Source #

Retrieve the next fresh wire.

incrementFresh :: Circ () Source #

Increment the value of the fresh wire.

addGate :: Gate -> Circ () Source #

Add a new gate to the circuit.

extractCircuit :: Circ a -> [Gate] Source #

Get the circuit out of the monad.

Higher-level access functions

init :: Bool -> Circ Wire Source #

Initialize a new wire.

cnot :: Wire -> [(Wire, Bool)] -> Circ () Source #

Add a multi-controlled not gate.

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.