leanprover-community / leanprover-community/mathlib4

norm_num introduces Classical.choice on order goals over Nat/Int where decide does not

Open
#42,565 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Lean
Stars
4.1k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

norm_num closes numeric order goals over and with a proof depending on Classical.choice. decide and simp close the same goals without it. Equality and disequality goals are unaffected.

import Mathlib

theorem a : (2 : ℤ) ≤ 4 := by norm_num
theorem b : (2 : ℤ) ≤ 4 := by decide
theorem c : (2 : ℤ) ≤ 4 := by simp
theorem d : (2 : ℤ) + 2 = 4 := by norm_num

#print axioms a -- propext, Classical.choice, Quot.sound
#print axioms b -- propext
#print axioms c -- propext
#print axioms d -- propext

Same for <, ≥, > and over ℕ.

The route:

a -> Mathlib.Meta.NormNum.isNat_le_true -> Nat.mono_cast -> monotone_nat_of_le_succ -> Nat.rel_of_forall_rel_succ_of_le -> LE.le.eq_or_lt -> eq_or_lt_of_le -> lt_or_eq_of_le -> Classical.propDecidable -> Classical.choice

lt_or_eq_of_le is stated for a general PartialOrder, where equality is not decidable, so its use of Classical.propDecidable is correct. The issue is that the norm_num order extension only ever runs on types that do have DecidableEq, and inherits the general lemma's classical dependence anyway.

A constructive route exists on ℤ:

theorem e (a b : ℤ) (h : a ≤ b) : a < b ∨ a = b := by
by_cases hab : a = b
· exact Or.inr hab
· exact Or.inl (Int.lt_iff_le_and_ne.mpr ⟨h, hab⟩)

#print axioms e -- propext

Lean 4.32.1.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at Mathlib.Meta.NormNum.isNat_le_true and trace the order-proof route through Nat.mono_cast, monotone_nat_of_le_succ, and the related order lemmas. Run the supplied Lean examples with #print axioms; done means numeric order goals over Nat and Int no longer depend on Classical.choice while equality and disequality behavior remains unchanged.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.