The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V12. Number theory

Mathlib.NumberTheory.PowModTotient

4 declarations. Mathlib docs · Source

Modular exponentiation with the totient function

This file contains lemmas about modular exponentiation. In particular, it contains lemmas showing that an exponent can be reduced modulo the totient function when the base is coprime to the modulus.

Main Results

  • pow_totient_mod: If x is coprime to n, then the modular exponentiation x ^ k % n can be reduced to x ^ (k % φ n) % n.

TODO

  • Extend to results in cases where the base is not coprime to the modulus.
  • Write a tactic or simproc that can automatically reduce exponents or towers of exponents using these results.

theorem Nat.pow_totient_mod_eq_one E1 #

∀ {x n : ℕ}, 1 < n → x.Coprime n → x ^ n.totient % n = 1

theorem Nat.pow_add_totient_mod_eq E0 #

∀ {x k n : ℕ}, 1 < n → x.Coprime n → x ^ (k + n.totient) % n = x ^ k % n

theorem Nat.pow_add_mul_totient_mod_eq E0 #

∀ {x k l n : ℕ}, 1 < n → x.Coprime n → x ^ (k + l * n.totient) % n = x ^ k % n

theorem Nat.pow_totient_mod E3 #

∀ {x k n : ℕ}, 1 < n → x.Coprime n → x ^ k % n = x ^ (k % n.totient) % n