Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Quadratic residues satisfy a(p−1)/2≡1(modp)a^{(p-1)/2}\equiv 1 \pmod pa(p−1)/2≡1(modp)

Proved
AlfutovaUstinov.problem_4_125

by evgeth · Sep 28, 2026 · Mathlib 0df444a (Lean v4.33.1)

elementary-number-theoryfermat-little-theoremnumber-theoryquadratic-residues

This is Problem 4.125 of N. B. Alfutova and A. V. Ustinov, Algebra and Number Theory (MCCME, 2002), Chapter 4, §4 “Theorems of Fermat and Euler”.

Theorem. Let p>2p>2p>2 be a prime and let aaa be an integer not divisible by ppp. Suppose that aaa is a square modulo ppp, i.e. there is an integer xxx with

x2≡a(modp).x^{2}\equiv a \pmod p .x2≡a(modp).

Then

ap−12≡1(modp).a^{\frac{p-1}{2}} \equiv 1 \pmod p .a2p−1​≡1(modp).

This is one half of Euler's criterion for quadratic residues; the book uses it to study which primes divide numbers of the form x2+1x^2+1x2+1.

Formalization Note The exponent (p−1)/2(p-1)/2(p−1)/2 is natural-number division, which is exact because ppp is odd. Congruences are Int.ModEq on Z\mathbb ZZ.

Preamble
import Mathlib
Formal statement
namespace AlfutovaUstinov

theorem problem_4_125 (p : ℕ) (hp : p.Prime) (hp2 : 2 < p) (a x : ℤ) (ha : ¬ (p : ℤ) ∣ a)
    (hx : x ^ 2 ≡ a [ZMOD p]) : a ^ ((p - 1) / 2) ≡ 1 [ZMOD p] := by sorry

end AlfutovaUstinov
Source
N. B. Alfutova, A. V. Ustinov, «Алгебра и теория чисел. Сборник задач для математических школ» (Algebra and Number Theory: a problem book for mathematical schools), Moscow: MCCME, 2002, Chapter 4 «Арифметика остатков» (Arithmetic of residues), §4 «Теоремы Ферма и Эйлера» (Theorems of Fermat and Euler), Problem 4.125. Problem text and answer as catalogued on problems.ru, problem 60751: https://problems.ru/view_problem_details_new.php?id=60751

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