hex

3.4. The Mathlib correspondence🔗

The two predicates agree, and the companion registers a handler on the same syntax kind, so the tactic closes Mathlib-stated goals directly:

example : Nat.Prime 2147483647 := Nat.Prime 2147483647 All goals completed! 🐙
🔗theorem
Hex.Nat.prime_iff {n : } : Hex.Nat.Prime n Nat.Prime n
Hex.Nat.prime_iff {n : } : Hex.Nat.Prime n Nat.Prime n

The whole correspondence: the Mathlib-free predicate and Nat.Prime agree. Everything else transports along it.

An ordinary import leaves Mathlib's Nat.Prime norm_num behavior unchanged: its trial-division extension registered before Hex's and is therefore consulted first. A module that wants the supported Hex policy opts in explicitly. Numerals below 2^24 then use a guarded trial-division alias, while 25-bit and larger numerals use bounded certificate search:

use_hex_primality_norm_num example : Nat.Prime 2147483647 := Nat.Prime 2147483647 All goals completed! 🐙 example : ¬ Nat.Prime 2147483649 := ¬Nat.Prime 2147483649 All goals completed! 🐙 example : Nat.Prime 101 := Nat.Prime 101 All goals completed! 🐙

The choice is per-module and does not persist across imports. If bounded certificate or factor search exhausts above the threshold, the Hex policy fails rather than falling back to a large trial-division computation.