Documentation

CslibFrontier.Foundations.NumberTheory.AKS.PerfectPower

Deciding perfect powers #

Step 1 of the AKS algorithm Agrawal, Kayal, Saxena, Section 4 asks whether n = a ^ b for some b > 1. For n ≥ 2 such an a is at least 2, so b ≤ log₂ n, and n is a b-th power exactly when it is the b-th power of its integer b-th root Nat.nthRoot b n. This makes Cslib.AKS.IsPerfectPower decidable by a bounded search.

Main results #

References #

theorem Cslib.AKS.isPerfectPower_iff_nthRoot {n : ℕ} (hn : 2 ≤ n) :
IsPerfectPower n ↔ ∃ b < Nat.log 2 n + 1, 2 ≤ b ∧ b.nthRoot n ^ b = n

For n ≥ 2, n is a perfect power exactly when it is the b-th power of its integer b-th root for some 2 ≤ b ≤ log₂ n.

0 and 1 are perfect powers: 0 = 0 ^ 2 and 1 = 1 ^ 2.

@[instance_reducible]

Perfect powers are decidable, by the bounded search of isPerfectPower_iff_nthRoot.