-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathDefs.lean
More file actions
94 lines (71 loc) · 3.22 KB
/
Defs.lean
File metadata and controls
94 lines (71 loc) · 3.22 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/-
Copyright (c) 2016 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad
-/
module
public import Mathlib.Algebra.Group.Defs
/-!
# The integers form a group
This file contains the additive group and multiplicative monoid instances on the integers.
See note [foundational algebra order theory].
-/
@[expose] public section
assert_not_exists Ring DenselyOrdered
open Nat
namespace Int
/-! ### Instances -/
instance instCommMonoid : CommMonoid ℤ where
mul_comm := Int.mul_comm
mul_one := Int.mul_one
one_mul := Int.one_mul
npow n x := x ^ n
npow_zero _ := by simp [Int.pow_zero]
npow_succ _ _ := by simp [Int.pow_succ]
mul_assoc := Int.mul_assoc
instance instAddCommGroup : AddCommGroup ℤ where
add_comm := Int.add_comm
add_assoc := Int.add_assoc
add_zero := Int.add_zero
zero_add := Int.zero_add
neg_add_cancel := Int.add_left_neg
nsmul := (· * ·)
nsmul_zero := Int.zero_mul
nsmul_succ n x :=
show (n + 1 : ℤ) * x = n * x + x by rw [Int.add_mul, Int.one_mul]
zsmul := (· * ·)
zsmul_zero' := Int.zero_mul
zsmul_succ' m n := by
simp only [HSMul.hSMul, SMul.smul, natCast_succ, Int.add_mul, Int.add_comm, Int.one_mul]
zsmul_neg' m n := by simp only [HSMul.hSMul, SMul.smul, negSucc_eq, natCast_succ, Int.neg_mul]
sub_eq_add_neg _ _ := Int.sub_eq_add_neg
-- This instance can also be found from the `LinearOrderedCommMonoidWithZero ℤ` instance by
-- typeclass search, but it is better practice to not rely on algebraic order theory to prove
-- purely algebraic results on concrete types. Eg the results can be made available earlier.
instance instIsAddTorsionFree : IsAddTorsionFree ℤ where
nsmul_right_injective _n hn _x _y := Int.eq_of_mul_eq_mul_left (by lia)
/-!
### Extra instances to short-circuit type class resolution
These also prevent non-computable instances like `Int.instNormedCommRing` being used to construct
these instances non-computably.
-/
section
set_option linter.style.whitespace false -- manual alignment is not recognised
instance instAddCommMonoid : AddCommMonoid ℤ := by infer_instance
instance instAddMonoid : AddMonoid ℤ := by infer_instance
instance instMonoid : Monoid ℤ := by infer_instance
instance instCommSemigroup : CommSemigroup ℤ := by infer_instance
instance instSemigroup : Semigroup ℤ := by infer_instance
instance instAddGroup : AddGroup ℤ := by infer_instance
instance instAddCommSemigroup : AddCommSemigroup ℤ := by infer_instance
instance instAddSemigroup : AddSemigroup ℤ := by infer_instance
end
-- This lemma is higher priority than later `_root_.nsmul_eq_mul` so that the `simpNF` is happy
@[simp high] protected lemma nsmul_eq_mul (n : ℕ) (a : ℤ) : n • a = n * a := rfl
-- This lemma is higher priority than later `_root_.zsmul_eq_mul` so that the `simpNF` is happy
@[simp high] protected lemma zsmul_eq_mul (n a : ℤ) : n • a = n * a := rfl
end Int
@[deprecated "use `zsmul_eq_mul`" (since := "2026-01-05")]
lemma zsmul_int_int (a b : ℤ) : a • b = a * b := rfl
@[deprecated "use `zsmul_one`" (since := "2026-01-05")]
lemma zsmul_int_one (n : ℤ) : n • (1 : ℤ) = n := mul_one _