Zulip Chat Archive
Stream: mathlib4
Topic: Decidability of the equality of real numbers(DecidableEq)
Sehun Kim (May 12 2025 at 15:40):
The equality of real numbers is well known to be undecidable
But in the mathlib, there is an instance Real.decidableEq.
As far as I know, if it is not based on the axiom, existence of this instance means that there is a function taking 2 real numbers and computing whether they are same or not.
How could this instance be defined in mathlib?
Following the definition of the Real.decidableEq, it is defined as
noncomputable instance decidableEq (a b : ℝ) : Decidable (a = b) := by infer_instance
And it seems to be defined by
@LinearOrder.decidableEq ℝ Real.linearOrder a b : Decidable (a = b)
And Real.linearOrder is defined by
noncomputable instance linearOrder : LinearOrder ℝ := Lattice.toLinearOrder ℝ
However the function toLinearOrder is defined by
abbrev Lattice.toLinearOrder (α : Type u) [Lattice α] [DecidableEq α]
[DecidableLE α] [DecidableLT α] [IsTotal α (· ≤ ·)] : LinearOrder α where
toDecidableLE := ‹_›
toDecidableEq := ‹_›
toDecidableLT := ‹_›
le_total := total_of (· ≤ ·)
max_def := by exact congr_fun₂ sup_eq_maxDefault
min_def := by exact congr_fun₂ inf_eq_minDefault
Which requires the DecidableEq α as an instance.
Can someone explain how could Lean accept this definition?
Aaron Liu (May 12 2025 at 15:43):
It uses docs#Classical.propDecidable
Eric Wieser (May 12 2025 at 15:44):
Probably we should reorder those instances to be a bit clearer
Edward van de Meent (May 12 2025 at 15:44):
in particular, it uses it at the definition of Real.toLinearOrder
Edward van de Meent (May 12 2025 at 15:45):
(see here)
Sehun Kim (May 12 2025 at 15:52):
Aha, it uses Classical.propDecidable in somewhere, and it seems to be based on the axiom of excluded middle, if I understood correctly.
Last updated: Dec 20 2025 at 21:32 UTC