Alphabeta Math
LemmaStatement: Literature-sourcedProof: AI-adaptedPipeline-generatedjudge pass (gpt-6-luna)
How statement and proof provenance work

The first chip identifies the source of the statement or construction; the second identifies the source of its local proof or verification.

  • Literature-sourced: the exact statement appears in a cited source; only wording and notation differ.
  • AI-adapted: a semantically identical restatement of literature-sourced material, modulo indexing, notation, and boundary cases adopted by the library.
  • AI-generated: a genuinely novel statement formulated by AI, with no source for the claim itself.

These labels describe origin, not correctness: citations and verification chips remain separate evidence.

Exact randomized modular square roots in expected polynomial time

Statement

Given a prime integer p and an integer a, there is an exact randomized algorithm that returns a square root of a modulo p or correctly reports that none exists. With ordinary binary integers, schoolbook arithmetic and independent unbiased random bits, its expected bit cost is polynomial in the input length; after reducing a modulo p, it is O((1+log⁡p)4). Every returned answer is correct, and the algorithm terminates with probability one. The input promise that p is prime is not a primality test.

Facts & Assumptions

Given: A prime p and an integer a in binary; random bits are independent and unbiased.

[F1]

Euler's criterion gives a(p−1)/2=(a/p) modulo an odd prime (Euler's criterion: (a/p)≡a(p−1)/2(modp)).

[F2]

Exactly half the nonzero classes modulo an odd prime are nonsquares (An odd prime has (p−1)/2 nonzero quadratic residues and as many nonresidues).

[F3]

The residue ring modulo a prime is a field (For every prime p, the two operations on Z/p make it a field).

Proof

1.1givenF1F2constructalgebra

Reduce a modulo p. If p=2, return its residue; if a=0, return zero. Otherwise [F1] rejects exactly the nonsquares by testing a(p−1)/2=−1. In the remaining case write p−1=2sq with q odd and s≥1. Repeatedly sample z uniformly from 1,…,p−1 until z(p−1)/2=−1. Uniform sampling is implemented by drawing ⌈log⁡2p⌉ bits and rejecting zero and integers at least p. Each draw is accepted with probability at least 1/4, and each accepted z is a nonsquare with probability 1/2 by [F2]; thus this search has bounded expected trials and terminates almost surely.

2.1F1F3step 1.1algebraconstruct

Set x=a(q+1)/2, t=aq, c=zq and M=s, all modulo p. Then x2=at, c has exact multiplicative order 2M, and t2M−1=1 by the tests in step 1.1. While t≠1, find the least m≥1 with t2m=1 by successive squaring; it satisfies m<M. Put b=c2M−m−1 and replace (x,t,c,M) by (xb,tb2,b2,m). The identity x2=at is preserved. The old t has order exactly 2m, so t2m−1=−1: in a field, the only roots of X2−1 are 1,−1 by factorization. Likewise b2 has order 2m and its 2m−1-st power is −1. Therefore the new t has order dividing 2m−1, while the new c has order 2m. The invariants are maintained and M strictly decreases. After at most s iterations, t=1 and x2=a. Return x.

3.1step 1.1step 2.1algebra∎

Put B=1+⌈log⁡2p⌉. Every modular integer has O(B) bits. Schoolbook multiplication and division use O(B2) bit operations; binary repeated squaring computes a power with O(B)-bit exponent in O(B) modular multiplications. These bounds follow directly by forming at most B shifted rows for multiplication and eliminating at most B quotient digits for division. Step 1.1 uses an expected bounded number of such powers. Each of the at most B iterations in step 2.1 uses at most O(B) modular multiplications to find m and compute b. Its total cost is O(B4). Initial reduction has cost polynomial in the original length of a and p. Thus the algorithm has the asserted expected bit bound; only the nonsquare search is randomized, and its outcome never changes the correctness of the final answer.

Depends on

Used by

Dependency tree · two levels

21 results within two dependency steps of this one, each drawn at its shortest distance from it. An arrow runs from a result to what uses it, so the chart reads left to right and ends at this result, which carries a heavier outline. Every node is a link to that result. Click elsewhere on the chart to enlarge it.

Sources