Skip to content

Commit d88e542

Browse files
committed
feat: port Algebra.NeZero (#557)
The lemmas `coe_trans` and `trans` were removed (see [zulip discussion](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/mathlib4.23557/near/308688583)).
1 parent 20f9b28 commit d88e542

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

Mathlib.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Mathlib.Algebra.GroupPower.Basic
99
import Mathlib.Algebra.GroupPower.Identities
1010
import Mathlib.Algebra.GroupPower.Lemmas
1111
import Mathlib.Algebra.GroupWithZero.Defs
12+
import Mathlib.Algebra.NeZero
1213
import Mathlib.Algebra.Order.Group
1314
import Mathlib.Algebra.Order.Monoid
1415
import Mathlib.Algebra.Order.MonoidLemmas

Mathlib/Algebra/NeZero.lean

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/-
2+
Copyright (c) 2021 Eric Rodriguez. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Eric Rodriguez
5+
-/
6+
7+
import Mathlib.Logic.Basic
8+
import Mathlib.Init.ZeroOne
9+
import Mathlib.Init.Algebra.Order
10+
11+
/-!
12+
# `NeZero` typeclass
13+
14+
We create a typeclass `NeZero n` which carries around the fact that `(n : R) ≠ 0`.
15+
16+
## Main declarations
17+
18+
* `NeZero`: `n ≠ 0` as a typeclass.
19+
-/
20+
21+
/-- A type-class version of `n ≠ 0`. -/
22+
class NeZero {R} [Zero R] (n : R) : Prop where
23+
/-- The proposition that `n` is not zero. -/
24+
out : n ≠ 0
25+
26+
theorem NeZero.ne {R} [Zero R] (n : R) [h : NeZero n] : n ≠ 0 :=
27+
h.out
28+
29+
theorem neZero_iff {R : Type _} [Zero R] {n : R} : NeZero n ↔ n ≠ 0 :=
30+
fun h => h.out, NeZero.mk⟩
31+
#align ne_zero_iff neZero_iff
32+
33+
theorem not_neZero {R : Type _} [Zero R] {n : R} : ¬NeZero n ↔ n = 0 := by simp [neZero_iff]
34+
#align not_ne_zero not_neZero
35+
36+
theorem eq_zero_or_neZero {α} [Zero α] (a : α) : a = 0 ∨ NeZero a :=
37+
(eq_or_ne a 0).imp_right NeZero.mk
38+
#align eq_zero_or_ne_zero eq_zero_or_neZero
39+
40+
namespace NeZero
41+
42+
variable {M : Type _} {x : M}
43+
44+
instance succ : NeZero (n + 1) := ⟨n.succ_ne_zero⟩
45+
46+
theorem of_pos [Preorder M] [Zero M] (h : 0 < x) : NeZero x := ⟨ne_of_gt h⟩
47+
48+
end NeZero

0 commit comments

Comments
 (0)