The Quipper System

Safe HaskellNone




This module provides some automated tests for the algebraic optimization procedure. The main function are:

  • testArith5: runs the optimization on a reversible adder generated with Template Haskell and exhaustively tests all the values.
  • testCircSimpl and testCircSwap: using the Test.QuickCheck library, perform optimization on randomly generated circuits and test validity for some random input.


Testing an adder

myAdder :: ([Qubit], [Qubit]) -> Circ [Qubit] Source #

Wrapper around template_adder.

myArith :: ([Qubit], [Qubit]) -> Circ [Qubit] Source #

A synonym for myAdder.

myCircArith :: Int -> (CircState, [Wire]) Source #

The optimized version of myArith.

bCircArith :: Int -> BCircuit Source #

The BCircuit of the optimized version of myArith.

wire_of_endpoint :: B_Endpoint t t -> t Source #

Extract the underlying Wire from an Endpoint.

runArithDry :: Int -> Int -> Int -> Int Source #

Run the reversible adder, non-optimized.

runArith :: Int -> Int -> Int -> Int Source #

Run the reversible adder, optimized.

testArith5 :: Bool Source #

Exhaustively test all the inputs of the optimized adder.

Randomized tests

The following functions use the Test.QuickCheck library. They generate random circuits, and run them classically before and after optimization.

choose :: [b] -> Int -> [[b]] Source #

Return all sublists of the given size.

genCirc :: Int -> Int -> Gen ([Gate], [Wire]) Source #

Generate a random circuit with the given number of inputs and ancillas.

printSampleCirc :: Int -> Int -> IO () Source #

Print some sample circuits generated by genCirc.

restrict :: Ord k => [k] -> Map k a -> Map k a Source #

Restrict a map to the given domain.

testCircSimpl :: Property Source #

Test of simplRec.

testCircSwap :: Property Source #

Test of alg_swap.

myQuickTest :: Property -> IO () Source #

A wrapper function to easily run a test. Within the interpreter quipperi, use, e.g., as

myQuickTest testCircSimpl