AFTD Auto-Formalizing Theoretical Domains

discrete_log

def

For an element x and base g in a monoid M, discrete_log g x is the minimal natural number m such that g ^ m = x, or 0 if no such m exists.

Statement

noncomputable def discrete_log {M : Type*} [Monoid M] (g x : M) : ℕ
Defined in
arXiv:2611.22205 Section 3
Verified
20 Nov 2026
Axioms
none listed
Used by 1
  • power_residue_charFor natural numbers p and r and units g and x of (ZMod p)ˣ, power_residue_char p r g x is defined as the discrete logarithm discrete_log g…

Read back from the Lean

Given a type M with a Monoid structure and elements g, x : M, discrete_log g x is defined as a natural number: if there exists m : ℕ such that g ^ m = x, it returns the least such m (via Nat.find); otherwise, it returns 0.

Written by a model that saw only the Lean, never the English above. If the two disagree, that is worth a challenge.

Lean source view module on GitHub

/-- Discrete logarithm of an element x with respect to base g in a monoid M. -/
noncomputable def discrete_log {M : Type*} [Monoid M] (g x : M) : ℕ := by classical exact if h : ∃ m : ℕ, g ^ m = x then Nat.find h else 0
See it in the graphDiscuss this resultChallenge it