The Quipper System

Safe HaskellNone

Algorithms.CL.CL

Contents

Description

An implementation of the quantum algorithms, based on the works of Hallgren, to compute the class number of a real quadratic number field.

Synopsis

Stage 1 (quantum): Approximate regulator to nearest integer

approximateRegulatorCircuit :: CLIntP -> Int -> CLIntP -> Circ CIntSource

Quantum part of the procedure to approximate the regulator R.

A version of the Hidden Subgroup Problem (HSP) Algorithm is used, to estimate the (irrational) period of the function f N (fN, q_fN); this is the function h of [Jozsa, Section 9], discretized with precision N = 2 n, and so has weak period S = NR.

Inputs: Δ; i, an assumed bound such that S ≤ 2i; and a random “jitter” parameter.

tryApproximateRegulator :: CLIntP -> Int -> IO (Maybe CLReal)Source

Attempt to approximate the regulator R, given an assumed bound i such that S ≤ 2i, using the probabilistic quantum computation approximateRegulatorCircuit twice as described in [Jozsa, Section 10].

Check the result for success; if it fails, return Nothing.

(The IO monad is slight overkill here: it is just to make a source of randomness available. A tighter approach could use a monad transformer such as RandT, applied to the Circ monad.)

verifyPeriodMultiple :: CLIntP -> Int -> CLInt -> BoolSource

verifyPeriodMultiple Δ n m: check whether m is within 1 of a multiple of the period S of fN

Since for any ideal I, ρ(ρ(I)) is distance > ln 2 from I, it suffices to check whether the unit ideal is within 4 steps either way of fN(m).

approximateRegulator :: CLIntP -> IO CLRealSource

Approximate the regulator for a given Δ (bigD).

Repeatedly run tryApproximateRegulator enough times, with increasing i, that it eventually succeeds with high probability.

Stage 2 (classical): Compute the regulator more accurately.

improveAccuracy :: CLReal -> Integer -> CLRealSource

Improve the accuracy of the initial estimate of the regulator R, for a quadratic discriminant Δ.

The implementation is mainly based on the proof for Theorem 5 appearing on Pages 270-271 in Jozsa's paper (Annals of Physics, 2003)

Stage 3 (classical): Find generators of the class group.

computeGenerators :: CLIntP -> [IdealRed]Source

A set of ideal classes generating CL(K).

Implementation: assuming the Generalized Riemann Hypothesis, it is enough to enumerate the non-principal prime ideals arising as factors of (p), for primes p ≤ 12(ln Δ)2. ([Haase and Maier 2006], Prop. 4.4.) For each p, there are at most two such prime ideals, and they are easily described.

Stage 4 (quantum): Find relations between generators.

Notation is as in [Hallgren 2006, Section 5]. Note: Some components are currently missing here, and are marked "incomplete" in the code below.

hI :: IdDist -> CLInt -> CLInt -> CLInt -> CLIntP -> CLIntP -> (IdDist, CLInt)Source

Compute the generators of CL(K), function hI.

computeGHat :: Integral int => [IdDist] -> [int] -> IdDistSource

Compute the ideals from the generators (ĝ function).

compute_i_N_at :: QDInt -> QDInt -> Circ ()Source

Compute i/N. Incomplete.

registerSizes :: CLIntP -> CLReal -> (Int, Int, Int, Int, Int, Int, Int)Source

Compute register sizes for structureCircuit, given Δ and a precise estimate of R. Return a 7-tuple (q,1,2,3,4,5,6) where q is the size of the first k registers, and 1…6 are the sizes of registers k+1…k+6.

structureCircuit :: CLIntP -> CLReal -> [IdealRed] -> Circ [CInt]Source

The quantum circuit used in computing the structure of CL(K), given Δ, a precise estimate of R, and a generating set for CL(K).

computeRelations :: CLIntP -> CLReal -> [IdealRed] -> IO [CLInt]Source

Compute the relations between a given set of reduced generators.

Section 5 (classical): compute class number.

classNumber :: CLIntP -> Int -> IO CLIntSource

The full implementation of Hallgren’s algorithm.

classNumber dd t: computes the class number |CL(K)| for Δ = dd, with success probability at least (1 - 1/2t).