-
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
-
95
-
96
-
97
-
98
-
99
-
100
-
101
-
102
-
103
-
104
-
105
-
106
-
107
-
108
-
109
-
110
-
111
-
112
-
113
-
114
-
115
-
116
-
117
-
118
-
119
-
120
-
121
-
122
-
123
-
124
-
125
-
126
-
127
-
128
-
129
-
130
-
131
-
132
-
133
-
134
-
135
-
136
-
137
-
138
-
139
-
140
-
141
-
142
-
143
-
144
-
145
-
146
-
147
-
148
-
149
-
150
-
151
-
152
-
153
-
154
import data.real.basic
structure group₁ (α : Type*) :=
(mul: α → α → α)
(one: α)
(inv: α → α)
(mul_assoc : ∀ x y z : α, mul (mul x y) z = mul x (mul y z))
(mul_one: ∀ x : α, mul x one = x)
(one_mul: ∀ x : α, mul x one = x)
(mul_left_inv : ∀ x : α, mul (inv x) x = one)
structure Group₁ :=
(α : Type*)
(str : group₁ α)
section
variables (α β γ : Type*)
variables (f : α ≃ β) (g : β ≃ γ)
#check equiv α β
#check (f.to_fun : α → β)
#check (f.inv_fun : β → α)
#check (f.right_inv: ∀ x : β, f (f.inv_fun x) = x)
#check (f.left_inv: ∀ x : α, f.inv_fun (f x) = x)
#check (equiv.refl α : α ≃ α)
#check (f.symm : β ≃ α)
#check (f.trans g : α ≃ γ)
example (x : α) : (f.trans g).to_fun x = g.to_fun (f.to_fun x) := rfl
example (x : α) : (f.trans g) x = g (f x) := rfl
example : (f.trans g : α → γ) = g ∘ f := rfl
end
example (α : Type*) : equiv.perm α = (α ≃ α) := rfl
def perm_group {α : Type*} : group₁ (equiv.perm α) :=
{ mul := λ f g, equiv.trans g f,
one := equiv.refl α,
inv := equiv.symm,
mul_assoc := λ f g h, (equiv.trans_assoc _ _ _).symm,
one_mul := equiv.trans_refl,
mul_one := equiv.refl_trans,
mul_left_inv := equiv.self_trans_symm }
structure add_group₁ (α : Type*) :=
(add : α → α → α)
-- fill in the rest
@[ext] structure point := (x : ℝ) (y : ℝ) (z : ℝ)
namespace point
def add (a b : point) : point := ⟨a.x + b.x, a.y + b.y, a.z + b.z⟩
def neg (a b : point) : point := sorry
def zero : point := sorry
def add_group_point : add_group point := sorry
end point
section
variables {α : Type*} (f g : equiv.perm α) (n : ℕ)
#check f * g
#check mul_assoc f g g⁻¹
-- group power, defined for any group
#check g^n
example : f * g * (g⁻¹) = f :=
by { rw [mul_assoc, mul_right_inv, mul_one] }
example : f * g * (g⁻¹) = f := mul_inv_cancel_right f g
example {α : Type*} (f g : equiv.perm α) : g.symm.trans (g.trans f) = f :=
mul_inv_cancel_right f g
end
class group₂ (α : Type*) :=
(mul: α → α → α)
(one: α)
(inv: α → α)
(mul_assoc : ∀ x y z : α, mul (mul x y) z = mul x (mul y z))
(mul_one: ∀ x : α, mul x one = x)
(one_mul: ∀ x : α, mul x one = x)
(mul_left_inv : ∀ x : α, mul (inv x) x = one)
instance {α : Type*} : group₂ (equiv.perm α) :=
{ mul := λ f g, equiv.trans g f,
one := equiv.refl α,
inv := equiv.symm,
mul_assoc := λ f g h, (equiv.trans_assoc _ _ _).symm,
one_mul := equiv.trans_refl,
mul_one := equiv.refl_trans,
mul_left_inv := equiv.self_trans_symm }
#check @group₂.mul
def my_square {α : Type*} [group₂ α] (x : α) := group₂.mul x x
#check @my_square
section
variables {β : Type*} (f g : equiv.perm β)
example : group₂.mul f g = g.trans f := rfl
example : my_square f = f.trans f := rfl
end
instance : inhabited point := { default := ⟨0, 0, 0⟩ }
#check (default : point)
example : ([] : list point).head = default := rfl
instance : has_add point := { add := point.add }
section
variables x y : point
#check x + y
example : x + y = point.add x y := rfl
end
instance has_mul_group₂ {α : Type*} [group₂ α] : has_mul α := ⟨group₂.mul⟩
instance has_one_group₂ {α : Type*} [group₂ α] : has_one α := ⟨group₂.one⟩
instance has_inv_group₂ {α : Type*} [group₂ α] : has_inv α := ⟨group₂.inv⟩
section
variables {α : Type*} (f g : equiv.perm α)
#check f * 1 * g⁻¹
def foo: f * 1 * g⁻¹ = g.symm.trans ((equiv.refl α).trans f) := rfl
end
class add_group₂ (α : Type*) :=
(add : α → α → α)
-- fill in the rest