Zulip Chat Archive

Stream: Is there code for X?

Topic: le_pred_of_lt for WithBot ℕ


Daniel Weber (Jun 24 2024 at 04:23):

Is there a nicer way to prove this?

import Mathlib

example (a : WithBot ) (b : ) (h : a < b) : a  (b - 1 : ) := by
  cases a
  case bot => simp
  case coe a =>
    rw [ WithBot.coe_natCast, WithBot.coe_le_coe, Nat.cast_id]
    rw [ WithBot.coe_natCast, WithBot.coe_lt_coe, Nat.cast_id] at h
    omega

Kim Morrison (Jun 24 2024 at 05:27):

You should add the missing simp lemma that (a : WithBot Nat) <= (b : WithBot Nat) iff a <= b to Mathlib.

Daniel Weber (Jun 24 2024 at 05:31):

I think a better lemma to add might be (a : WithBot Nat) = some a, and then it's just coe_le_coe

Eric Wieser (Jun 24 2024 at 07:21):

That wouldn't help with WithBot Real

Eric Wieser (Jun 24 2024 at 07:24):

Kim Morrison said a less general version of:

You should add the missing simp lemma that (a : WithBot A) <= (b : WithBot A) iff a <= b, for a b : Nat, to Mathlib.

I guess there are quite a lot of these to add: Bot/Top, le/lt, special case where one or both of a and b are 0/1/ofNat, intCast versions of the same, lemmas with intCast on one side and natCast on the other, ...

Kim Morrison (Jun 24 2024 at 07:27):

(To clarify, Eric doesn't mean that you shouldn't add this simp lemma, but that it should be more general that for Nat.)

Eric Wieser (Jun 24 2024 at 07:33):

I actually misread your suggestion as being the general one, and meant that Daniel's lemma probably isn't useful in the presence of (my reading of) yours


Last updated: May 02 2025 at 03:31 UTC