The Quipper System

Safe HaskellNone

QuipperLib.ClassicalOptim.QuickCheck

Contents

Description

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.

Synopsis

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 -> BCircuitSource

The BCircuit of the optimized version of myArith.

wire_of_endpoint :: B_Endpoint t t -> tSource

Extract the underlying Wire from an Endpoint.

runArithDry :: Int -> Int -> Int -> IntSource

Run the reversible adder, non-optimized.

runArith :: Int -> Int -> Int -> IntSource

Run the reversible adder, optimized.

testArith5 :: BoolSource

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 aSource

Restrict a map to the given domain.

testCircSimpl :: PropertySource

Test of simplRec.

testCircSwap :: PropertySource

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