Skip to content

Commit 804fe9b

Browse files
pecherskyYaelDillies
authored andcommitted
feat(GroupWithZero/WithZero): injectivity and monotonicity of WithZero.map' (leanprover-community#25660)
factored out of leanprover-community#22420 Co-authored-by: Yaël Dillies <yael.dillies@gmail.com>
1 parent 547e60b commit 804fe9b

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

Mathlib/Algebra/Group/WithOne/Defs.lean

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ def coe : α → WithOne α :=
8989
instance instCoeTC : CoeTC α (WithOne α) :=
9090
⟨coe⟩
9191

92+
@[to_additive]
93+
lemma «forall» {p : WithZero α → Prop} : (∀ x, p x) ↔ p 0 ∧ ∀ a : α, p a := Option.forall
94+
95+
@[to_additive]
96+
lemma «exists» {p : WithZero α → Prop} : (∃ x, p x) ↔ p 0 ∨ ∃ a : α, p a := Option.exists
97+
9298
/-- Recursor for `WithZero` using the preferred forms `0` and `↑a`. -/
9399
@[elab_as_elim, induction_eliminator, cases_eliminator]
94100
def _root_.WithZero.recZeroCoe {motive : WithZero α → Sort*} (zero : motive 0)

Mathlib/Algebra/GroupWithZero/WithZero.lean

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ This file proves that one can adjoin a new zero element to a group and get a gro
2222
a monoid homomorphism `f : α →* β`.
2323
-/
2424

25+
open Function
26+
2527
assert_not_exists DenselyOrdered Ring
2628

2729
namespace WithZero
@@ -139,6 +141,11 @@ lemma map'_map' (f : α →* β) (g : β →* γ) (x) : map' g (map' f x) = map
139141
lemma map'_comp (f : α →* β) (g : β →* γ) : map' (g.comp f) = (map' g).comp (map' f) :=
140142
MonoidWithZeroHom.ext fun x => (map'_map' f g x).symm
141143

144+
lemma map'_injective_iff {f : α →* β} : Injective (map' f) ↔ Injective f := by
145+
simp [Injective, WithZero.forall]
146+
147+
alias ⟨_, map'_injective⟩ := map'_injective_iff
148+
142149
end MulOneClass
143150

144151
section Pow

Mathlib/Algebra/Order/GroupWithZero/Canonical.lean

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ whereas it is a very common target for valuations.
2626
The solutions is to use a typeclass, and that is exactly what we do in this file.
2727
-/
2828

29-
variable {α : Type*}
29+
variableβ : Type*}
3030

3131
/-- A linearly ordered commutative monoid with a zero element. -/
3232
class LinearOrderedCommMonoidWithZero (α : Type*) extends CommMonoidWithZero α, LinearOrder α,
@@ -250,14 +250,16 @@ instance [LinearOrderedAddCommGroupWithTop α] :
250250

251251
namespace WithZero
252252
section Preorder
253-
variable [Preorder α] {a b : α}
253+
variable [Preorder α] [Preorder β] {x : WithZero α} {a b : α}
254254

255255
instance instPreorder : Preorder (WithZero α) := WithBot.preorder
256256
instance instOrderBot : OrderBot (WithZero α) := WithBot.orderBot
257257

258-
lemma zero_le (a : WithZero α) : 0 ≤ a := bot_le
258+
@[simp] lemma zero_le (a : WithZero α) : 0 ≤ a := bot_le
259259

260-
lemma zero_lt_coe (a : α) : (0 : WithZero α) < a := WithBot.bot_lt_coe a
260+
@[simp] lemma zero_lt_coe (a : α) : (0 : WithZero α) < a := WithBot.bot_lt_coe a
261+
@[simp] lemma not_coe_le_zero : ¬ a ≤ (0 : WithZero α) := WithBot.not_coe_le_bot a
262+
@[simp] lemma not_lt_zero : ¬ x < (0 : WithZero α) := WithBot.not_lt_bot _
261263

262264
lemma zero_eq_bot : (0 : WithZero α) = ⊥ := rfl
263265

@@ -318,6 +320,12 @@ instance instExistsAddOfLE [Add α] [ExistsAddOfLE α] : ExistsAddOfLE (WithZero
318320
obtain ⟨c, rfl⟩ := exists_add_of_le (WithZero.coe_le_coe.1 h)
319321
exact ⟨c, rfl⟩⟩
320322

323+
lemma map'_mono [MulOneClass α] [MulOneClass β] {f : α →* β} (hf : Monotone f) :
324+
Monotone (map' f) := by simpa [Monotone, WithZero.forall]
325+
326+
lemma map'_strictMono [MulOneClass α] [MulOneClass β] {f : α →* β} (hf : StrictMono f) :
327+
StrictMono (map' f) := by simpa [StrictMono, WithZero.forall]
328+
321329
end Preorder
322330

323331
section PartialOrder

0 commit comments

Comments
 (0)