The Quipper System

Safe HaskellNone

QuipperLib.Simulation.ClassicalSimulation

Contents

Description

This module provides functions for simulating certain classes of circuits, for testing and debugging purposes. At the moment, the only type of simulation we provide is boolean simulation.

This module provides the internal implementation of the library, and can be imported by other libraries. The public interface to simulation is QuipperLib.Simulation.

Synopsis

Simulation of classical circuits

controls :: [Signed (B_Endpoint Bool Bool)] -> Bool Source #

Auxiliary function: determine whether a "control" is true of false.

simulate_cgate :: String -> [Bool] -> Bool Source #

Auxiliary function: compute the boolean function corresponding to a CGate of the given name.

simulate_classical :: Transformer Id Bool Bool Source #

A Quipper.Transformer mapping each gate to the corresponding boolean function. This will fail with an error for gates that don't act within the computational basis, or if some assertion is not met. Some gates are not yet implemented.

run_classical :: BCircuit -> Bindings Bool Bool -> Bindings Bool Bool Source #

Boolean simulation of a circuit, for testing and debugging purposes. This function makes use of the concept of a valuation. A valuation is a partial map from circuit wires to booleans, represented by the type Bindings Bool. Given a circuit and a valuation for its inputs, the function run_classical produces a valuation for its outputs.

The simulation will fail with an error if the circuit contains a gate not acting within the computational basis, or if some assertion is not met. Not all gates are currently implemented. Subroutines are not currently implemented.

Generic simulation

run_classical_errmsg :: (QCData qa, QCData qb) => ErrMsg -> (qa -> Circ qb) -> BType qa -> BType qb Source #

Like run_classical_unary, but also takes a stub error message.

run_classical_unary :: (QCData qa, QCData qb) => (qa -> Circ qb) -> BType qa -> BType qb Source #

Boolean simulation of a circuit, for testing and debugging purposes. Input a classical circuit, and output the corresponding boolean function. This will fail with an error if the circuit contains a gate not acting within the computational basis, or if some assertion is not met.

run_classical_generic :: (QCData qa, QCData qb, QCurry qfun qa qb, Curry fun (BType qa) (BType qb)) => qfun -> fun Source #

Boolean simulation of a circuit, for testing and debugging purposes. Input a classical circuit, and output the corresponding boolean function. This will fail with an error if the circuit contains a gate not acting within the computational basis, or if some assertion is not met.

Unlike run_classical_unary, this can be applied to a circuit-generating function in curried form with n arguments, for any n ≥ 0. The resulting boolean function then will also have n arguments.

The type of this heavily overloaded function is difficult to read. In more readable form, it has all of the following types:

run_classical_generic :: (QCData qa) => Circ qa -> BType qa
run_classical_generic :: (QCData qa, QCData qb) => (qa -> Circ qb) -> BType qa -> BType qb
run_classical_generic :: (QCData qa, QCData qb, QCData qc) => (qa -> qb -> Circ qc) -> BType qa -> BType qb -> BType qc

and so forth.