The Quipper System

Algorithms.BF.Testing

Description

This module provides some testing facilities for the Boolean Formula algorithm, as well as some auxiliary function definitions. See Algorithms.BF.Main for an overview of the boolean formula algorithm.

Synopsis

# Auxiliary definitions

Convert list of moves, into a HexBoard.

moves_to_pos :: BooleanFormulaOracle -> [Int] -> [[Bool]] Source #

Convert a list of moves, into a list of positions.

set_bool :: [Bool] -> [Bool] -> Bool -> [Bool] Source #

Set the position in board, at the given address, to the given boolean.

fromPos :: BooleanFormulaOracle -> [[Bool]] -> HexBoard Source #

Create the description of a Hex board, from the given classical state of a position register from the Boolean Formula algorithm.

# Testing various circuits

A dummy value of type Double, to feed the type in the simulator.

Construct the oracle circuit, initialized with the given boolean inputs.

Simulate the oracle circuit with the given boolean inputs, to give boolean outputs.

Return the diffuse circuit, initialized with the given boolean inputs.

Simulate the diffuse circuit with the given boolean inputs, to give boolean outputs.

Return the walk circuit, initialized with the given boolean inputs.

Simulate the walk circuit with the given boolean inputs, to give boolean outputs.

Return the undo_oracle circuit, initialized with the given boolean inputs.

Simulate the undo_oracle circuit with the given boolean inputs, to give boolean outputs.

# Oracle, diffuse, walk, and undo_oracle

Create a register from the given boolean inputs, and then run the oracle circuit, followed by the diffusion step, followed by the walk step, and finally the undo_oracle circuit.

This is really a test of all four parts. The return values when running this step can be fed forward into the next iteration, and the undo_oracle step should have returned the eight work qubits back to the initial False states.

We break the simulation into the four separate steps, so that we are not trying to simulate the walk/undo_oracle steps over a quantum state, as this gives us an overhead.

Simulate the odwu circuit, running it n times and passing the output of each iteration as inputs to the next iteration. The overall return value is a representation of the HexBoard at each step of the simulation.

Simulate the odwu circuit, running it repeatedly and passing the output of each iteration as inputs to the next iteration. Outputs an ASCII representation of the position register/board after each step.

tidy :: (Bool, Bool) -> [[Bool]] -> [[Bool]] Source #

Trim any leading zeroes from a pos register, and a single leading 1, if we're not at a paraleaf, and a 3, if we're at the root.

Return the Hex circuit, initialized for the given oracle, with the given boolean inputs.

Simulate the running of the Hex circuit, initialized for the given oracle, with the given boolean inputs.

Simulate the running of the checkwin_red subroutine for the given oracle, and keep track of the state of certain "traced" qubits within that subroutine, which represent the Hex board at each iteration of the while loop in the flood_fill algorithm.