On the Characteristic of a Ring
I was reading the section on the characteristic of a field in my textbook.
In the Textbook
Section titled “In the Textbook”The definition goes something like this:
Let be the natural homomorphism from to a field .
If , the characteristic is .
If is a prime number and , the characteristic is .
In mathlib
Section titled “In mathlib”I tried looking for it in mathlib (with some help from an LLM), and found this:
class _root_.CharP (R : Type*) [AddMonoidWithOne R] (p : outParam ℕ) : Prop where cast_eq_zero_iff (R p) : ∀ x : ℕ, (x : R) = 0 ↔ p ∣ xIt seems this is how it’s defined.
But… this looks quite different from the textbook definition.
Neither nor makes an appearance here.
Maybe this is just a “classic mathlib moment.”
Defining Characteristic Following the Textbook
Section titled “Defining Characteristic Following the Textbook”Just to see, I tried defining it myself while following the textbook as closely as possible (again, with some help from an LLM):
import Mathlib.RingTheory.Ideal.Maps
class CharP (K : Type) [Ring K] (p : ℕ) : Prop where kernel_eq_span : RingHom.ker (Int.castRingHom K) = Ideal.span { (p : ℤ) }And… it compiled without errors!
Though, I still feel like I might not fully grasp everything yet…
Notes on the Textbook-Style Definition
Section titled “Notes on the Textbook-Style Definition”It seems RingHom.ker (Int.castRingHom K) corresponds to .
As for the Ideal.span part:
Ideal.span {(p : ℤ)}is the set of all multiples of (i.e., ).Ideal.span {(0 : ℤ)}is the ideal generated by , which is .
It turns out you don’t actually need to write a separate case for “If it is …”. The single expression covers both!
That’s all for today!