-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathDefs.lean
More file actions
73 lines (56 loc) · 2.23 KB
/
Defs.lean
File metadata and controls
73 lines (56 loc) · 2.23 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
/-
Copyright (c) 2014 Floris van Doorn (c) 2016 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Floris van Doorn, Leonardo de Moura, Jeremy Avigad, Mario Carneiro
-/
import Mathlib.Algebra.Group.Defs
/-!
# The natural numbers form a monoid
This file contains the additive and multiplicative monoid instances on the natural numbers.
See note [foundational algebra order theory].
-/
assert_not_exists MonoidWithZero DenselyOrdered
namespace Nat
/-! ### Instances -/
instance instMulOneClass : MulOneClass ℕ where
one_mul := Nat.one_mul
mul_one := Nat.mul_one
instance instAddCancelCommMonoid : AddCancelCommMonoid ℕ where
add := Nat.add
add_assoc := Nat.add_assoc
zero := Nat.zero
zero_add := Nat.zero_add
add_zero := Nat.add_zero
add_comm := Nat.add_comm
nsmul m n := m * n
nsmul_zero := Nat.zero_mul
nsmul_succ := succ_mul
add_left_cancel _ _ _ := Nat.add_left_cancel
instance instCommMonoid : CommMonoid ℕ where
mul := Nat.mul
mul_assoc := Nat.mul_assoc
one := Nat.succ Nat.zero
one_mul := Nat.one_mul
mul_one := Nat.mul_one
mul_comm := Nat.mul_comm
npow m n := n ^ m
npow_zero := Nat.pow_zero
npow_succ _ _ := rfl
/-!
### Extra instances to short-circuit type class resolution
These also prevent non-computable instances being used to construct these instances non-computably.
-/
set_option linter.style.commandStart false
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 instAddCommSemigroup : AddCommSemigroup ℕ := by infer_instance
instance instAddSemigroup : AddSemigroup ℕ := by infer_instance
instance instOne : One ℕ := inferInstance
set_option linter.style.commandStart true
/-! ### Miscellaneous lemmas -/
-- We set the simp priority slightly lower than default; later more general lemmas will replace it.
@[simp 900] protected lemma nsmul_eq_mul (m n : ℕ) : m • n = m * n := rfl
end Nat