Alphabeta Math
AlgorithmAlgorithm: Literature-sourcedProof: Not applicablePipeline-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.

Reversible modular multiplication by a unit

Definition

Input. An integer N≥2, n=⌈log⁡2N⌉, a one-bit control c, an n-bit data register z, and integers a,a−1 with 0≤a,a−1<N and aa−1≡1(modN). The data encoding is valid when its unsigned value is less than N.

Residue addition and multiplication are in Z/N with the class operations of The congruence class [a]n and the quotient set Z/n, Addition and multiplication on Z/n by [a]n+[b]n=[a+b]n and [a]n[b]n=[ab]n, and For every natural n, (Z/n,+) is an abelian group, multiplication is a commutative monoid operation, and both distributive laws hold. The inverse condition says [a]N is a unit, equivalently gcd⁡(a,N)=1 by The unit group (Z/n)× and Euler's totient φ(n)=∣(Z/n)×∣ for n≥1 and For n≥1, [a]n is a unit if and only if gcd⁡(a,n)=1. Kets use Dirac Notation Conversion; c,z are ordered computational-basis registers with the unsigned encoding of Finite registers and their ordered computational bases and Big-endian encoding of ordered bit strings, tensor order as in Ordered tensor registers, their inner product, and wire permutations, and circuit denotation as in Denotational semantics of a finite layered circuit. “Clean work” means initialized and returned to zero under Clean and dirty ancillas.

Output. A reversible circuit on c,z and clean work registers which implements the controlled map z↦az mod N for c=1 and valid z, and is the identity on invalid encodings and when c=0.

Instructions. Define the total Boolean function on (c,z) by fa(c,z)={az mod N,c=1 and z<N,z,otherwise. Generate the following explicit NOT/AND/OR DAG for this function. Bit arrays in the instructions below are indexed from least significant bit 0; the input and output port lists retain the repository's most-significant-first register order. Begin with the distinct input identifiers c,zn−1,…,z0 and two constant nodes 0,1. Every gate emission appends a fresh identifier in consecutive order, referencing only existing identifiers. A named bit below is an alias of its node identifier, never an additional gate. Expand every macro call immediately in the stated loop order.

  1. Define XOR⁡(u,v) by emitting, in order, o=OR⁡(u,v), h=AND⁡(u,v), d=NOT⁡(h), and e=AND⁡(o,d), returning e. Define ADD⁡w(U,V,d0) by looping i=0,…,w−1: emit ei=XOR⁡(Ui,Vi), si=XOR⁡(ei,di), hi=AND⁡(Ui,Vi), ji=AND⁡(ei,di), and di+1=OR⁡(hi,ji). Return (s0,…,sw−1) and dw. Define SUB⁡w(U,V) by first emitting NOT⁡(Vi) in increasing i and then calling ADD⁡w(U,NOT⁡(V),1); return its difference bits and carry bit h (the no-borrow bit).
  2. Define SELECT⁡w(h,U,V) by emitting d=NOT⁡(h) and, for i=0,…,w−1, ui=AND⁡(h,Ui), vi=AND⁡(d,Vi), si=OR⁡(ui,vi). It returns the selected bit array S. Public constant arrays below refer to the shared 0,1 nodes and are zero-padded to the displayed width.
  3. Initialize a 2n-bit accumulator P with zero aliases. For i=0,…,n−1, form a 2n-bit row H: for j=0,…,n−1, emit Hi+j=AND⁡(ai,zj), where ai is the constant bit of a; all other row bits alias 0. Replace P by the sum output of ADD⁡2n(P,H,0), ignoring the carry output.
  4. Initialize R to n zero aliases. For ℓ=2n−1,…,0, form the (n+1)-bit array V by V0=Pℓ and Vi=Ri−1 for 1≤i≤n. Call SUB⁡n+1(V,N), obtaining difference D and carry h. Set R to the low n bits of SELECT⁡n+1(h,D,V).
  5. Pad z by a zero high bit, call SUB⁡n+1(z,N), and let h be its carry. Emit v=NOT⁡(h) and g=AND⁡(c,v). Set F=SELECT⁡n(g,R,z). The ordered output ports are Fn−1,…,F0. This completes the finite DAG and its topological order. Construct a second DAG by the identical recipe with constant a−1 in place of a.

Compile each DAG to the clean-target XOR oracle of Coherent XOR function oracle using Reversible embedding of a Boolean circuit, whose exact gate-emission rules apply also to repeated-source ports. Allocate an n-bit clean target, compute fa(c,z) into it, swap the data and target registers with three CNOT gates per bit, then apply the compiled XOR computation for fa−1 to the old-data target, using the new data as input. Each compiled XOR oracle is an involution by A total Boolean XOR oracle is unitary and involutive. Return the concatenated gate list with every compute-copy-uncompute stage included. Separate items thm-qa-modular-multiplication-circuit-correctness and thm-qa-modular-arithmetic-cost establish its basis action and gate/work bounds. No depth bound is part of this algorithm.

Depends on

Used by

Dependency tree · two levels

65 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