Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 98ece77

Browse files
urkudmergify[bot]
authored andcommitted
refactor(algebra/group): split into smaller files (#1121)
* rename `src/algebra/group.lean` → `src/algebra/group/default.lean` * Split algebra/group/default into smaller files No code changes, except for variables declaration and imports * Fix compile * fix compile error: import `anti_hom` in `algebra/group/default` * Drop unused imports
1 parent 8d0e719 commit 98ece77

File tree

12 files changed

+1175
-1068
lines changed

12 files changed

+1175
-1068
lines changed

src/algebra/group.lean

Lines changed: 0 additions & 1068 deletions
This file was deleted.

src/algebra/group/anti_hom.lean

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/-
2+
Copyright (c) 2018 Patrick Massot. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Patrick Massot, Mario Carneiro, Johan Commelin
5+
6+
Various multiplicative and additive structures.
7+
-/
8+
import algebra.group.basic
9+
10+
variables {α : Type*} {β : Type*} [group α] [group β]
11+
12+
/-- Predicate for group anti-homomorphism, or a homomorphism
13+
into the opposite group. -/
14+
class is_group_anti_hom (f : α → β) : Prop :=
15+
(map_mul : ∀ a b : α, f (a * b) = f b * f a)
16+
17+
namespace is_group_anti_hom
18+
variables (f : α → β) [w : is_group_anti_hom f]
19+
include w
20+
21+
theorem map_one : f 1 = 1 :=
22+
mul_self_iff_eq_one.1 $ by rw [← map_mul f, one_mul]
23+
24+
theorem map_inv (a : α) : f a⁻¹ = (f a)⁻¹ :=
25+
eq_inv_of_mul_eq_one $ by rw [← map_mul f, mul_inv_self, map_one f]
26+
27+
end is_group_anti_hom
28+
29+
theorem inv_is_group_anti_hom : is_group_anti_hom (λ x : α, x⁻¹) :=
30+
⟨mul_inv_rev⟩

src/algebra/group/basic.lean

Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
/-
2+
Copyright (c) 2014 Jeremy Avigad. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Jeremy Avigad, Simon Hudon, Mario Carneiro
5+
6+
Various multiplicative and additive structures.
7+
-/
8+
import algebra.group.to_additive
9+
10+
universe u
11+
variable {α : Type u}
12+
13+
instance monoid_to_is_left_id {α : Type*} [monoid α]
14+
: is_left_id α (*) 1 :=
15+
⟨ monoid.one_mul ⟩
16+
17+
instance monoid_to_is_right_id {α : Type*} [monoid α]
18+
: is_right_id α (*) 1 :=
19+
⟨ monoid.mul_one ⟩
20+
21+
instance add_monoid_to_is_left_id {α : Type*} [add_monoid α]
22+
: is_left_id α (+) 0 :=
23+
⟨ add_monoid.zero_add ⟩
24+
25+
instance add_monoid_to_is_right_id {α : Type*} [add_monoid α]
26+
: is_right_id α (+) 0 :=
27+
⟨ add_monoid.add_zero ⟩
28+
29+
@[simp, to_additive add_left_inj]
30+
theorem mul_left_inj [left_cancel_semigroup α] (a : α) {b c : α} : a * b = a * c ↔ b = c :=
31+
⟨mul_left_cancel, congr_arg _⟩
32+
33+
@[simp, to_additive add_right_inj]
34+
theorem mul_right_inj [right_cancel_semigroup α] (a : α) {b c : α} : b * a = c * a ↔ b = c :=
35+
⟨mul_right_cancel, congr_arg _⟩
36+
37+
section comm_semigroup
38+
variables [comm_semigroup α] {a b c d : α}
39+
40+
@[to_additive add_add_add_comm]
41+
theorem mul_mul_mul_comm : (a * b) * (c * d) = (a * c) * (b * d) :=
42+
by simp [mul_left_comm, mul_assoc]
43+
44+
end comm_semigroup
45+
46+
section group
47+
variables [group α] {a b c : α}
48+
49+
@[simp, to_additive neg_inj']
50+
theorem inv_inj' : a⁻¹ = b⁻¹ ↔ a = b :=
51+
⟨λ h, by rw [← inv_inv a, h, inv_inv], congr_arg _⟩
52+
53+
@[to_additive eq_of_neg_eq_neg]
54+
theorem eq_of_inv_eq_inv : a⁻¹ = b⁻¹ → a = b :=
55+
inv_inj'.1
56+
57+
@[simp, to_additive add_self_iff_eq_zero]
58+
theorem mul_self_iff_eq_one : a * a = a ↔ a = 1 :=
59+
by have := @mul_left_inj _ _ a a 1; rwa mul_one at this
60+
61+
@[simp, to_additive neg_eq_zero]
62+
theorem inv_eq_one : a⁻¹ = 1 ↔ a = 1 :=
63+
by rw [← @inv_inj' _ _ a 1, one_inv]
64+
65+
@[simp, to_additive neg_ne_zero]
66+
theorem inv_ne_one : a⁻¹ ≠ 1 ↔ a ≠ 1 :=
67+
not_congr inv_eq_one
68+
69+
@[to_additive left_inverse_neg]
70+
theorem left_inverse_inv (α) [group α] :
71+
function.left_inverse (λ a : α, a⁻¹) (λ a, a⁻¹) :=
72+
assume a, inv_inv a
73+
74+
attribute [simp] mul_inv_cancel_left add_neg_cancel_left
75+
mul_inv_cancel_right add_neg_cancel_right
76+
77+
@[to_additive eq_neg_iff_eq_neg]
78+
theorem eq_inv_iff_eq_inv : a = b⁻¹ ↔ b = a⁻¹ :=
79+
⟨eq_inv_of_eq_inv, eq_inv_of_eq_inv⟩
80+
81+
@[to_additive neg_eq_iff_neg_eq]
82+
theorem inv_eq_iff_inv_eq : a⁻¹ = b ↔ b⁻¹ = a :=
83+
by rw [eq_comm, @eq_comm _ _ a, eq_inv_iff_eq_inv]
84+
85+
@[to_additive add_eq_zero_iff_eq_neg]
86+
theorem mul_eq_one_iff_eq_inv : a * b = 1 ↔ a = b⁻¹ :=
87+
by simpa [mul_left_inv, -mul_right_inj] using @mul_right_inj _ _ b a (b⁻¹)
88+
89+
@[to_additive add_eq_zero_iff_neg_eq]
90+
theorem mul_eq_one_iff_inv_eq : a * b = 1 ↔ a⁻¹ = b :=
91+
by rw [mul_eq_one_iff_eq_inv, eq_inv_iff_eq_inv, eq_comm]
92+
93+
@[to_additive eq_neg_iff_add_eq_zero]
94+
theorem eq_inv_iff_mul_eq_one : a = b⁻¹ ↔ a * b = 1 :=
95+
mul_eq_one_iff_eq_inv.symm
96+
97+
@[to_additive neg_eq_iff_add_eq_zero]
98+
theorem inv_eq_iff_mul_eq_one : a⁻¹ = b ↔ a * b = 1 :=
99+
mul_eq_one_iff_inv_eq.symm
100+
101+
@[to_additive eq_add_neg_iff_add_eq]
102+
theorem eq_mul_inv_iff_mul_eq : a = b * c⁻¹ ↔ a * c = b :=
103+
⟨λ h, by rw [h, inv_mul_cancel_right], λ h, by rw [← h, mul_inv_cancel_right]⟩
104+
105+
@[to_additive eq_neg_add_iff_add_eq]
106+
theorem eq_inv_mul_iff_mul_eq : a = b⁻¹ * c ↔ b * a = c :=
107+
⟨λ h, by rw [h, mul_inv_cancel_left], λ h, by rw [← h, inv_mul_cancel_left]⟩
108+
109+
@[to_additive neg_add_eq_iff_eq_add]
110+
theorem inv_mul_eq_iff_eq_mul : a⁻¹ * b = c ↔ b = a * c :=
111+
⟨λ h, by rw [← h, mul_inv_cancel_left], λ h, by rw [h, inv_mul_cancel_left]⟩
112+
113+
@[to_additive add_neg_eq_iff_eq_add]
114+
theorem mul_inv_eq_iff_eq_mul : a * b⁻¹ = c ↔ a = c * b :=
115+
⟨λ h, by rw [← h, inv_mul_cancel_right], λ h, by rw [h, mul_inv_cancel_right]⟩
116+
117+
@[to_additive add_neg_eq_zero]
118+
theorem mul_inv_eq_one {a b : α} : a * b⁻¹ = 1 ↔ a = b :=
119+
by rw [mul_eq_one_iff_eq_inv, inv_inv]
120+
121+
@[to_additive neg_comm_of_comm]
122+
theorem inv_comm_of_comm {a b : α} (H : a * b = b * a) : a⁻¹ * b = b * a⁻¹ :=
123+
begin
124+
have : a⁻¹ * (b * a) * a⁻¹ = a⁻¹ * (a * b) * a⁻¹ :=
125+
congr_arg (λ x:α, a⁻¹ * x * a⁻¹) H.symm,
126+
rwa [inv_mul_cancel_left, mul_assoc, mul_inv_cancel_right] at this
127+
end
128+
129+
end group
130+
131+
132+
section add_group
133+
variables [add_group α] {a b c : α}
134+
135+
local attribute [simp] sub_eq_add_neg
136+
137+
def sub_sub_cancel := @sub_sub_self
138+
139+
@[simp] lemma sub_left_inj : a - b = a - c ↔ b = c :=
140+
(add_left_inj _).trans neg_inj'
141+
142+
@[simp] lemma sub_right_inj : b - a = c - a ↔ b = c :=
143+
add_right_inj _
144+
145+
lemma sub_add_sub_cancel (a b c : α) : (a - b) + (b - c) = a - c :=
146+
by rw [← add_sub_assoc, sub_add_cancel]
147+
148+
lemma sub_sub_sub_cancel_right (a b c : α) : (a - c) - (b - c) = a - b :=
149+
by rw [← neg_sub c b, sub_neg_eq_add, sub_add_sub_cancel]
150+
151+
theorem sub_eq_zero : a - b = 0 ↔ a = b :=
152+
⟨eq_of_sub_eq_zero, λ h, by rw [h, sub_self]⟩
153+
154+
theorem sub_ne_zero : a - b ≠ 0 ↔ a ≠ b :=
155+
not_congr sub_eq_zero
156+
157+
theorem eq_sub_iff_add_eq : a = b - c ↔ a + c = b :=
158+
eq_add_neg_iff_add_eq
159+
160+
theorem sub_eq_iff_eq_add : a - b = c ↔ a = c + b :=
161+
add_neg_eq_iff_eq_add
162+
163+
theorem eq_iff_eq_of_sub_eq_sub {a b c d : α} (H : a - b = c - d) : a = b ↔ c = d :=
164+
by rw [← sub_eq_zero, H, sub_eq_zero]
165+
166+
theorem left_inverse_sub_add_left (c : α) : function.left_inverse (λ x, x - c) (λ x, x + c) :=
167+
assume x, add_sub_cancel x c
168+
169+
theorem left_inverse_add_left_sub (c : α) : function.left_inverse (λ x, x + c) (λ x, x - c) :=
170+
assume x, sub_add_cancel x c
171+
172+
theorem left_inverse_add_right_neg_add (c : α) :
173+
function.left_inverse (λ x, c + x) (λ x, - c + x) :=
174+
assume x, add_neg_cancel_left c x
175+
176+
theorem left_inverse_neg_add_add_right (c : α) :
177+
function.left_inverse (λ x, - c + x) (λ x, c + x) :=
178+
assume x, neg_add_cancel_left c x
179+
end add_group
180+
181+
section add_comm_group
182+
variables [add_comm_group α] {a b c : α}
183+
184+
lemma sub_eq_neg_add (a b : α) : a - b = -b + a :=
185+
add_comm _ _
186+
187+
theorem neg_add' (a b : α) : -(a + b) = -a - b := neg_add a b
188+
189+
lemma neg_sub_neg (a b : α) : -a - -b = b - a := by simp
190+
191+
lemma eq_sub_iff_add_eq' : a = b - c ↔ c + a = b :=
192+
by rw [eq_sub_iff_add_eq, add_comm]
193+
194+
lemma sub_eq_iff_eq_add' : a - b = c ↔ a = b + c :=
195+
by rw [sub_eq_iff_eq_add, add_comm]
196+
197+
lemma add_sub_cancel' (a b : α) : a + b - a = b :=
198+
by rw [sub_eq_neg_add, neg_add_cancel_left]
199+
200+
lemma add_sub_cancel'_right (a b : α) : a + (b - a) = b :=
201+
by rw [← add_sub_assoc, add_sub_cancel']
202+
203+
lemma sub_right_comm (a b c : α) : a - b - c = a - c - b :=
204+
add_right_comm _ _ _
205+
206+
lemma add_add_sub_cancel (a b c : α) : (a + c) + (b - c) = a + b :=
207+
by rw [add_assoc, add_sub_cancel'_right]
208+
209+
lemma sub_add_add_cancel (a b c : α) : (a - c) + (b + c) = a + b :=
210+
by rw [add_left_comm, sub_add_cancel, add_comm]
211+
212+
lemma sub_add_sub_cancel' (a b c : α) : (a - b) + (c - a) = c - b :=
213+
by rw add_comm; apply sub_add_sub_cancel
214+
215+
lemma add_sub_sub_cancel (a b c : α) : (a + b) - (a - c) = b + c :=
216+
by rw [← sub_add, add_sub_cancel']
217+
218+
lemma sub_sub_sub_cancel_left (a b c : α) : (c - a) - (c - b) = b - a :=
219+
by rw [← neg_sub b c, sub_neg_eq_add, add_comm, sub_add_sub_cancel]
220+
221+
lemma sub_eq_sub_iff_sub_eq_sub {d : α} :
222+
a - b = c - d ↔ a - c = b - d :=
223+
⟨λ h, by rw eq_add_of_sub_eq h; simp, λ h, by rw eq_add_of_sub_eq h; simp⟩
224+
225+
end add_comm_group
226+
227+
section add_monoid
228+
variables [add_monoid α] {a b c : α}
229+
230+
@[simp] lemma bit0_zero : bit0 (0 : α) = 0 := add_zero _
231+
@[simp] lemma bit1_zero [has_one α] : bit1 (0 : α) = 1 :=
232+
show 0+0+1=(1:α), by rw [zero_add, zero_add]
233+
234+
end add_monoid

src/algebra/group/conj.lean

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/-
2+
Copyright (c) 2018 Patrick Massot. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Patrick Massot, Chris Hughes, Michael Howes
5+
6+
Conjugacy of group elements
7+
-/
8+
import tactic.basic algebra.group.hom
9+
10+
universes u v
11+
variables {α : Type u} {β : Type v}
12+
13+
variables [group α] [group β]
14+
15+
def is_conj (a b : α) := ∃ c : α, c * a * c⁻¹ = b
16+
17+
@[refl] lemma is_conj_refl (a : α) : is_conj a a :=
18+
1, by rw [one_mul, one_inv, mul_one]⟩
19+
20+
@[symm] lemma is_conj_symm {a b : α} : is_conj a b → is_conj b a
21+
| ⟨c, hc⟩ := ⟨c⁻¹, by rw [← hc, mul_assoc, mul_inv_cancel_right, inv_mul_cancel_left]⟩
22+
23+
@[trans] lemma is_conj_trans {a b c : α} : is_conj a b → is_conj b c → is_conj a c
24+
| ⟨c₁, hc₁⟩ ⟨c₂, hc₂⟩ := ⟨c₂ * c₁, by rw [← hc₂, ← hc₁, mul_inv_rev]; simp only [mul_assoc]⟩
25+
26+
@[simp] lemma is_conj_one_right {a : α} : is_conj 1 a ↔ a = 1 :=
27+
by simp [is_conj, is_conj_refl] {contextual := tt}, by simp [is_conj_refl] {contextual := tt}⟩
28+
29+
@[simp] lemma is_conj_one_left {a : α} : is_conj a 1 ↔ a = 1 :=
30+
calc is_conj a 1 ↔ is_conj 1 a : ⟨is_conj_symm, is_conj_symm⟩
31+
... ↔ a = 1 : is_conj_one_right
32+
33+
@[simp] lemma conj_inv {a b : α} : (b * a * b⁻¹)⁻¹ = b * a⁻¹ * b⁻¹ :=
34+
begin
35+
rw [mul_inv_rev _ b⁻¹, mul_inv_rev b _, inv_inv, mul_assoc],
36+
end
37+
38+
@[simp] lemma conj_mul {a b c : α} : (b * a * b⁻¹) * (b * c * b⁻¹) = b * (a * c) * b⁻¹ :=
39+
begin
40+
assoc_rw inv_mul_cancel_right,
41+
repeat {rw mul_assoc},
42+
end
43+
44+
@[simp] lemma is_conj_iff_eq {α : Type*} [comm_group α] {a b : α} : is_conj a b ↔ a = b :=
45+
⟨λ ⟨c, hc⟩, by rw [← hc, mul_right_comm, mul_inv_self, one_mul], λ h, by rw h⟩
46+
47+
protected lemma is_group_hom.is_conj (f : α → β) [is_group_hom f] {a b : α} : is_conj a b → is_conj (f a) (f b)
48+
| ⟨c, hc⟩ := ⟨f c, by rw [← is_group_hom.map_mul f, ← is_group_hom.map_inv f, ← is_group_hom.map_mul f, hc]⟩

src/algebra/group/default.lean

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/-
2+
Copyright (c) 2014 Jeremy Avigad. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Jeremy Avigad, Leonardo de Moura, Michael Howes
5+
6+
Various multiplicative and additive structures.
7+
-/
8+
9+
import algebra.group.to_additive
10+
import algebra.group.basic
11+
import algebra.group.units
12+
import algebra.group.hom
13+
import algebra.group.type_tags
14+
import algebra.group.free_monoid
15+
import algebra.group.conj
16+
import algebra.group.with_one
17+
import algebra.group.anti_hom
18+
import algebra.group.units_hom

src/algebra/group/free_monoid.lean

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/-
2+
Copyright (c) 2019 Simon Hudon. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Simon Hudon
5+
6+
Free monoid over a given alphabet
7+
-/
8+
def free_monoid (α) := list α
9+
10+
instance {α} : monoid (free_monoid α) :=
11+
{ one := [],
12+
mul := λ x y, (x ++ y : list α),
13+
mul_one := by intros; apply list.append_nil,
14+
one_mul := by intros; refl,
15+
mul_assoc := by intros; apply list.append_assoc }
16+
17+
@[simp] lemma free_monoid.one_def {α} : (1 : free_monoid α) = [] := rfl
18+
19+
@[simp] lemma free_monoid.mul_def {α} (xs ys : list α) : (xs * ys : free_monoid α) = (xs ++ ys : list α) := rfl
20+
21+
def free_add_monoid (α) := list α
22+
23+
instance {α} : add_monoid (free_add_monoid α) :=
24+
{ zero := [],
25+
add := λ x y, (x ++ y : list α),
26+
add_zero := by intros; apply list.append_nil,
27+
zero_add := by intros; refl,
28+
add_assoc := by intros; apply list.append_assoc }
29+
30+
@[simp] lemma free_add_monoid.zero_def {α} : (1 : free_monoid α) = [] := rfl
31+
32+
@[simp] lemma free_add_monoid.add_def {α} (xs ys : list α) : (xs * ys : free_monoid α) = (xs ++ ys : list α) := rfl

0 commit comments

Comments
 (0)