Zulip Chat Archive
Stream: Is there code for X?
Topic: OrderedAddCommGroup has CharZero
Violeta Hernández (Mar 18 2025 at 00:59):
If an ordered group satisfies 0 < 1
, then NatCast
should be injective, right? Do we have something like this?
Aaron Liu (Mar 18 2025 at 01:02):
We have docs#StrictOrderedSemiring.toCharZero
Violeta Hernández (Mar 18 2025 at 01:03):
That's stronger than what I have, unfortunately, since my structure has no multiplication.
Kevin Buzzard (Mar 18 2025 at 01:03):
Whatever you mean by "group" it won't have both a 0 and a 1
Kevin Buzzard (Mar 18 2025 at 01:04):
Can you formalise the question?
Aaron Liu (Mar 18 2025 at 01:04):
Its proof doesn't need multiplication, so we could generalize this?
Kevin Buzzard (Mar 18 2025 at 01:05):
Do we have some kind of docs#AddMonoidWithOne
Violeta Hernández (Mar 18 2025 at 01:05):
docs#AddCommGroupWithOne is my relevant structure
Violeta Hernández (Mar 18 2025 at 01:05):
Though it might even work for non-commutative groups or monoids, I'm not sure
Kevin Buzzard (Mar 18 2025 at 01:05):
You'll need the order to be compatible with the addition so it's not over yet
Violeta Hernández (Mar 18 2025 at 01:06):
AddMonoidWithOne
does seem too weak since the order doesn't interact with the structure
Violeta Hernández (Mar 18 2025 at 01:07):
But perhaps AddMonoidWithOne
+ AddRightStrictMono
+ 0 < 1
is enough?
Aaron Liu (Mar 18 2025 at 01:07):
import Mathlib
example {α : Type*} [AddMonoidWithOne α] [PartialOrder α] [ZeroLEOneClass α]
[NeZero (1 : α)] [AddLeftStrictMono α] : CharZero α where
cast_injective :=
(strictMono_nat_of_lt_succ fun n ↦ by rw [Nat.cast_succ]; apply lt_add_one).injective
Violeta Hernández (Mar 18 2025 at 01:08):
That works for me!
Violeta Hernández (Mar 18 2025 at 01:11):
Does this generalize docs#StrictOrderedSemiring.toCharZero, or is it an incomparable set of assumptions?
Aaron Liu (Mar 18 2025 at 01:14):
95% sure its strictly more general but I'll check
Violeta Hernández (Mar 18 2025 at 01:14):
It generalizes!
import Mathlib
variable {α : Type*}
theorem foo [AddMonoidWithOne α] [PartialOrder α] [ZeroLEOneClass α] [NeZero (1 : α)] [AddLeftStrictMono α] : CharZero α where
cast_injective :=
(strictMono_nat_of_lt_succ fun n ↦ by rw [Nat.cast_succ]; apply lt_add_one).injective
example [StrictOrderedSemiring α] : CharZero α := foo
Violeta Hernández (Mar 18 2025 at 01:15):
Would you like to go ahead and PR this?
Aaron Liu (Mar 18 2025 at 01:15):
Sure
Aaron Liu (Mar 18 2025 at 01:22):
Should I keep the name?
Violeta Hernández (Mar 18 2025 at 01:22):
I think the deprecation policy generally doesn't apply to instance names
Violeta Hernández (Mar 18 2025 at 01:23):
You could call the new instance something like AddMonoidWithOne.toCharZero
and just remove the old one
Aaron Liu (Mar 18 2025 at 01:25):
It feels weird having an AddMonoidWithOne
class in the middle of all the StrictOrderedSemiring
classes
Aaron Liu (Mar 18 2025 at 01:32):
Violeta Hernández (Mar 18 2025 at 01:34):
Can that instance perhaps be moved to some earlier file?
Violeta Hernández (Mar 18 2025 at 01:35):
What does #find_home AddMonoidWithOne.toCharZero
give you?
Aaron Liu (Mar 18 2025 at 01:37):
It gave me Mathlib/Algebra/Order/Ring/Defs
(the same file)
Jireh Loreaux (Mar 18 2025 at 02:00):
I'm fairly sure I already made this generalization somewhere, but I think I scoped the instance for performance reasons. I'll try to find it tomorrow.
Aaron Liu (Mar 18 2025 at 02:15):
MathlibTest.linarith
failed with timeout at whnf
Aaron Liu (Apr 14 2025 at 18:08):
@Violeta Hernández Do you still need this?
Last updated: May 02 2025 at 03:31 UTC