File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import Mathlib.Algebra.GroupPower.Basic
9
9
import Mathlib.Algebra.GroupPower.Identities
10
10
import Mathlib.Algebra.GroupPower.Lemmas
11
11
import Mathlib.Algebra.GroupWithZero.Defs
12
+ import Mathlib.Algebra.NeZero
12
13
import Mathlib.Algebra.Order.Group
13
14
import Mathlib.Algebra.Order.Monoid
14
15
import Mathlib.Algebra.Order.MonoidLemmas
Original file line number Diff line number Diff line change
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
You can’t perform that action at this time.
0 commit comments