-
Notifications
You must be signed in to change notification settings - Fork 307
/
NeZero.lean
60 lines (48 loc) · 1.91 KB
/
NeZero.lean
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/-
Copyright (c) 2020 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin
-/
import Mathlib.Algebra.GroupWithZero.Defs
import Mathlib.Algebra.NeZero
#align_import algebra.group_with_zero.defs from "leanprover-community/mathlib"@"2f3994e1b117b1e1da49bcfb67334f33460c3ce4"
/-!
# `NeZero 1` in a nontrivial `MulZeroOneClass`.
This file exists to minimize the dependencies of `Mathlib.Algebra.GroupWithZero.Defs`,
which is a part of the algebraic hierarchy used by basic tactics.
-/
universe u
variable {M₀ M₀' : Type*} [MulZeroOneClass M₀] [Nontrivial M₀]
/-- In a nontrivial monoid with zero, zero and one are different. -/
instance NeZero.one : NeZero (1 : M₀) := ⟨by
intro h
rcases exists_pair_ne M₀ with ⟨x, y, hx⟩
apply hx
calc
x = 1 * x := by rw [one_mul]
_ = 0 := by rw [h, zero_mul]
_ = 1 * y := by rw [h, zero_mul]
_ = y := by rw [one_mul]⟩
#align ne_zero.one NeZero.one
/-- Pullback a `Nontrivial` instance along a function sending `0` to `0` and `1` to `1`. -/
theorem pullback_nonzero [Zero M₀'] [One M₀'] (f : M₀' → M₀) (zero : f 0 = 0) (one : f 1 = 1) :
Nontrivial M₀' :=
⟨⟨0, 1, mt (congr_arg f) <| by
rw [zero, one]
exact zero_ne_one⟩⟩
#align pullback_nonzero pullback_nonzero
section GroupWithZero
variable {G₀ : Type*} [GroupWithZero G₀] {a : G₀}
-- Porting note: used `simpa` to prove `False` in lean3
theorem inv_ne_zero (h : a ≠ 0) : a⁻¹ ≠ 0 := fun a_eq_0 => by
have := mul_inv_cancel h
simp only [a_eq_0, mul_zero, zero_ne_one] at this
#align inv_ne_zero inv_ne_zero
@[simp]
theorem inv_mul_cancel (h : a ≠ 0) : a⁻¹ * a = 1 :=
calc
a⁻¹ * a = a⁻¹ * a * a⁻¹ * a⁻¹⁻¹ := by simp [inv_ne_zero h]
_ = a⁻¹ * a⁻¹⁻¹ := by simp [h]
_ = 1 := by simp [inv_ne_zero h]
#align inv_mul_cancel inv_mul_cancel
end GroupWithZero