Solovay-Strassen test

Solovay-Strassen test

It is known that an

odd number

n

is prime if and only if for every

1

<

a

<

n

such that

(

a

,

n

)

=

1

we have

(

a

n

)

≡

a

n

-

1

2

(

mod

n

)

(1)

where

(

a

n

)

is the

Jacobi symbol

. (The only if part is obvious; the if part follows from

Theorem

1

.) From this we can derive the following

algorithm

.

1.

Choose a

random number

a

between

1

and

n

-

1

.

2.

Check if

(

a

,

n

)

=

1

(for example using the

Euclidean algorithm

). If it is not, then

n

is not prime and

(

a

,

n

)

is a

divisor

of

n

.

3.

Check if

Equation

(

1

) holds. If it does not, then

n

is not prime. Otherwise

n

is a candidate for

primality

.

By repeating this algorithm we can increase the chance that the result is correct. In order to estimate the probability of error, we make use of Theorem

1

, which says that every

independent

iteration

of the algorithm has a chance of at most

50

%

of being wrong. Hence, after

t

iterations there is at most a

2

-

t

chance of getting a wrong result.

Theorem 1

.

Let

n

≥

3

be an odd

composite

integer

. Then at least half of the
elements of

Z

n

*

do not

satisfy

Equation (

1

).

Proof.

It suffices to exhibit one

element

a

∈

ℤ

n

*

which does not satisfy Equation (

1

). Indeed, if there exists one such element, then the set of
all elements which do satisfy Equation (

1

) forms a

proper subgroup

of

ℤ

n

*

, from which we
conclude that the elements satisfying Equation (

1

) number no more than half of the elements
of

ℤ

n

*

.

We consider separately the cases where

n

is

squarefree

and not
squarefree. If

n

is squarefree, let

p

be a prime dividing

n

and
let

b

be a

quadratic non-residue

mod

n

. Using the

Chinese
Remainder Theorem

, choose an integer

a

∈

ℤ

n

*

such that:

a

≡

b

(

mod

p

)

,

a

≡

1

(

mod

n

p

)

.

The Jacobi symbol

(

a

n

)

is given by

(

a

n

)

=

(

a

p

)

⁢

(

a

n

/

p

)

=

(

b

p

)

⁢

(

1

n

/

p

)

=

(

-

1

)

⋅

1

=

-

1

.

We will assume that

a

n

-

1

2

≡

-

1

(

mod

n

)

and derive
a

contradiction

. The equation

a

n

-

1

2

≡

-

1

(

mod

n

)

implies that

a

n

-

1

2

≡

-

1

(

mod

n

p

)

.
However, since

a

≡

1

(

mod

n

p

)

, we must have

a

n

-

1

2

≡

1

(

mod

n

p

)

, so that

1

≡

-

1

(

mod

n

p

)

, which is a contradiction.

Now suppose that

n

is not squarefree. Let

p

be a prime such that

p

2

∣

n

, and set

a

=

1

+

n

p

. By the

binomial theorem

,
we have

a

p

=

(

1

+

n

p

)

p

=

1

+

(

p

1

)

⁢

(

n

/

p

)

+

(

p

2

)

⁢

(

n

/

p

)

2

+

⋯

+

(

p

p

)

⁢

(

n

/

p

)

p

≡

1

(

mod

n

)

,

so the

multiplicative order

of

a

mod

n

is equal to

p

, and hence
in particular

a

n

-

1

≠

1

(

mod

n

)

, since

p

∤

n

-

1

. On the
other hand,

(

a

n

)

=

(

1

+

n

p

n

)

=

(

1

+

n

p

p

)

⁢

(

1

+

n

p

n

/

p

)

=

(

1

p

)

⁢

(

1

n

/

p

)

=

1

,

so

a

does not satisfy Equation (

1

).
∎

Title

Solovay-Strassen test

Canonical name

SolovayStrassenTest

Date of creation

2013-03-22 14:27:33

Last modified on

2013-03-22 14:27:33

Owner

mathwizard (128)

Last modified by

mathwizard (128)

Numerical id

7

Author

mathwizard (128)

Entry type

Algorithm

Classification

msc 11Y11

Related topic

MillerRabinPrimeTest

Generated on Fri Feb 9 15:47:15 2018 by

LaTeXML