Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Discrete logarithm as a hidden subgroup problem: f(a,b)=gax−bf(a,b) = g^a x^{-b}f(a,b)=gax−b is a homomorphism with kernel the multiples of (r,1)(r,1)(r,1)

Proved
ShorWiki.discreteLog_hiddenSubgroup

by Lucas · Oct 13, 2026 · Mathlib 0df444a (Lean v4.33.1)

quantum-computingshor-algorithm

Let GGG be a finite group of order ppp generated by ggg, let rrr be an integer, and let x=grx = g^rx=gr. Define

f:Zp×Zp→G,f(a,b)=gax−b.f : \mathbb Z_p \times \mathbb Z_p \to G, \qquad f(a, b) = g^a x^{-b}.f:Zp​×Zp​→G,f(a,b)=gax−b.

Then

  1. fff is a group homomorphism: f(a+a′,b+b′)=f(a,b) f(a′,b′)f(a + a', b + b') = f(a,b)\,f(a',b')f(a+a′,b+b′)=f(a,b)f(a′,b′) for all a,b,a′,b′∈Zpa, b, a', b' \in \mathbb Z_pa,b,a′,b′∈Zp​;
  2. the kernel of fff consists exactly of the multiples of (r,1)(r, 1)(r,1): f(a,b)=1f(a,b) = 1f(a,b)=1 if and only if (a,b)=t (r,1)(a,b) = t\,(r,1)(a,b)=t(r,1) for some t∈Zpt \in \mathbb Z_pt∈Zp​.

Hence finding the hidden subgroup ker⁡f\ker fkerf determines the discrete logarithm r=log⁡gxr = \log_g xr=logg​x modulo ppp.

Formalization Note Elements of Zp\mathbb Z_pZp​ are ZMod p with ppp the cardinality of GGG, and gag^aga means ggg raised to the least nonnegative representative of aaa. The group is not assumed commutative; it is cyclic because ggg generates it.

Preamble
import Mathlib
import Definitions.Def_ShorWiki_Defs

open Matrix Kronecker
Formal statement
namespace ShorWiki

theorem discreteLog_hiddenSubgroup {G : Type*} [Group G] [Fintype G] (g : G)
    (hg : ∀ h : G, h ∈ Subgroup.zpowers g) (r : ℕ) :
    (∀ a b a' b' : ZMod (Fintype.card G),
        g ^ (a + a').val * ((g ^ r) ^ (b + b').val)⁻¹
          = (g ^ a.val * ((g ^ r) ^ b.val)⁻¹) * (g ^ a'.val * ((g ^ r) ^ b'.val)⁻¹)) ∧
    ∀ a b : ZMod (Fintype.card G),
      g ^ a.val * ((g ^ r) ^ b.val)⁻¹ = 1 ↔
        ∃ t : ZMod (Fintype.card G), a = t * (r : ZMod (Fintype.card G)) ∧ b = t := by sorry

end ShorWiki
Source
Wikipedia, "Shor's algorithm", revision oldid=1378862216, https://en.wikipedia.org/w/index.php?title=Shor%27s_algorithm&oldid=1378862216, section "Shor's algorithm for discrete logarithms" (PDF p. 7)
Human review
  • Endorsed by Shuze Chen · Oct 13, 2026

    Confirmed by the moderator at approval.

  • Endorsed by Lucas · Oct 13, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me