Skip to content

Commit 8057823

Browse files
committed
Updates
- Split things between files - Added a few new things
1 parent 321dd2c commit 8057823

20 files changed

+958
-608
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
/private
44
.lake
55
TODO.md
6-
.vscode
6+
.vscode
7+
**/*/private_*.lean

Mathematics.lean

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
-- TODO what goes here
1+
import Mathematics.Logic
2+
import Mathematics.Structures.Numbers.Natural
3+
import Mathematics.Structures.Set
4+
import Mathematics.Algebra.Group

Mathematics/Algebra/Group.lean

Lines changed: 17 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import Mathematics.Structures.Relation
22

3-
class Inv (T : Type) where
4-
inv : T → T
3+
class Inverse (T : Type) where
4+
inverse' : T → T
55

6-
postfix:max "⁻¹" => Inv.inverse
6+
postfix:max "⁻¹" => Inverse.inverse'
77

8-
-- TODO to_additive
9-
class Group (T: Type) extends Mul T, Inv T, OfNat T 1 :=
8+
class Group (T: Type) extends Mul T, Inverse T, OfNat T 1 :=
109
associativity : ∀ a b c: T, a * (b * c) = (a * b) * c
1110
identity : ∀ a: T, a * 1 = a ∧ 1 * a = a
1211
inverse : ∀ a: T, a⁻¹ * a = 1 ∧ a * a⁻¹ = 1
@@ -26,24 +25,24 @@ theorem one.multiply (a: T) : 1 * a = a := (Group.identity a).right
2625
theorem multiply.associative: ∀ a b c: T, a * (b * c) = (a * b) * c := Group.associativity
2726

2827
theorem inv.double : (a⁻¹)⁻¹ = a := by
29-
rw [←multiply.one (a⁻¹)⁻¹, ←(Group.inverseerse a).left, Group.associativity, (Group.inverseerse _).left, one.multiply]
28+
rw [←multiply.one (a⁻¹)⁻¹, ←(Group.inverse a).left, Group.associativity, (Group.inverse _).left, one.multiply]
3029

31-
theorem one.inverseerse : (1⁻¹) = (1: T) := by
32-
rw [←multiply.one 1⁻¹, (Group.inverseerse 1).1]
30+
theorem one.inverse : (1⁻¹) = (1: T) := by
31+
rw [←multiply.one 1⁻¹, (Group.inverse 1).1]
3332

3433
theorem multiply.eq_one_implies_eq (h : a * b = 1) : a⁻¹ = b := by
35-
rw [←multiply.one a⁻¹, ←h, Group.associativity, (Group.inverseerse a).left, one.multiply]
34+
rw [←multiply.one a⁻¹, ←h, Group.associativity, (Group.inverse a).left, one.multiply]
3635

3736
theorem inv.multiply : (a * b)⁻¹ = b⁻¹ * a⁻¹ := by
3837
apply multiply.eq_one_implies_eq
39-
rw [←Group.associativity, Group.associativity b, (Group.inverseerse _).right, one.multiply, (Group.inverseerse a).right]
38+
rw [←Group.associativity, Group.associativity b, (Group.inverse _).right, one.multiply, (Group.inverse a).right]
4039

4140
theorem multiply.left_cancel (h : a * b = a * c) : b = c := by
42-
rw [←one.multiply b, ←(Group.inverseerse a).left, ←Group.associativity, h, Group.associativity, (Group.inverseerse a).left, one.multiply c]
41+
rw [←one.multiply b, ←(Group.inverse a).left, ←Group.associativity, h, Group.associativity, (Group.inverse a).left, one.multiply c]
4342

4443
-- Note the symmetry with above
4544
theorem multiply.right_cancel (h : b * a = c * a) : b = c := by
46-
rw [←multiply.one b, ←(Group.inverseerse a).right, Group.associativity, h, ←Group.associativity, (Group.inverseerse a).right, multiply.one c]
45+
rw [←multiply.one b, ←(Group.inverse a).right, Group.associativity, h, ←Group.associativity, (Group.inverse a).right, multiply.one c]
4746

4847
theorem multiply.injective_inverse : a⁻¹ = b⁻¹ ↔ a = b := by
4948
apply Iff.intro
@@ -78,70 +77,6 @@ end groups
7877

7978
def conjugation { T: Type } [Group T] (c: T) := fun (x: T) => c * x * c⁻¹
8079

81-
class GroupHomomorphism (T U: Type) [Group T] [Group U] (f: T -> U) :=
82-
map_mul : ∀ a b: T, f (a * b) = f a * f b
83-
84-
namespace group_homomorphism
85-
86-
def in_kernel {T U: Type} [Group T] [Group U] (f: T -> U) (a: T): Prop := f a = 1
87-
def in_image {T U: Type} [Group T] [Group U] (f: T -> U) (b: U): Prop := ∃ a: T, f a = b
88-
89-
open groups
90-
91-
variable {T U: Type} [Group T] [Group U] (f: T -> U) [GroupHomomorphism T U f]
92-
93-
theorem map.multiply : ∀ a b: T, f (a * b) = f a * f b := GroupHomomorphism.map_mul
94-
95-
theorem map.one : f 1 = 1 := by
96-
apply groups.multiplytiply.left_cancel
97-
show f 1 * f 1 = f 1 * 1
98-
rw [←GroupHomomorphism.map_mul, multiply.one, multiply.one]
99-
100-
def id := fun (x: T) => x
101-
102-
theorem id.homomorphism : GroupHomomorphism T T id := {
103-
map_mul := by intros a b; exact rfl
104-
}
105-
106-
theorem conjugation.homomorphism (c: T) : GroupHomomorphism T T (conjugation c) := {
107-
map_mul := by
108-
intros a b
109-
unfold conjugation
110-
rw [
111-
←multiply.associative c b,
112-
multiply.associative _ c,
113-
←multiply.associative _ _ c,
114-
(Group.inverseerse c).left,
115-
multiply.one,
116-
multiply.associative,
117-
multiply.associative
118-
]
119-
}
120-
121-
theorem homomorphism.compose { V: Type } [Group V] (f: T -> U) (g: U -> V) [GroupHomomorphism _ _ f] [GroupHomomorphism _ _ g]
122-
: GroupHomomorphism T V (g ∘ f) := {
123-
map_mul := by
124-
intros a b
125-
unfold Function.comp
126-
rw [←map.multiply, ←map.multiply]
127-
}
128-
129-
theorem map.inverse (a : T) : f a⁻¹ = (f a)⁻¹ := by
130-
apply (multiply.left_cancel_iff (f a) (f a⁻¹) (f a)⁻¹).mp
131-
rw [←map.multiply, (Group.inverseerse a).right, (Group.inverseerse (f a)).right]
132-
exact @map.one T U _ _ f _
133-
134-
theorem map.multiplytiply.inverse (a b : T) : (f (a * b))⁻¹ = f b⁻¹ * f a⁻¹ := by
135-
rw [←map.multiply, ←inv.multiply, ←map.inverse]
136-
137-
-- TODO exponents
138-
-- theorem map_pow (a : T) (n : Natural) : f a ^ n = (f a) ^ n := by
139-
-- induction n with
140-
-- | zero => rw [power.zero]
141-
-- | successor n ih => rw [power.successor, ih]
142-
143-
end group_homomorphism
144-
14580
namespace random
14681

14782
variable {T: Type} [Group T]
@@ -153,24 +88,24 @@ instance : Relation T are_conjugate := {
15388
symmetric := by
15489
intro a b h1
15590
let ⟨g, h2⟩ := h1
156-
apply Exists.intro (Inv.inverse g)
91+
apply Exists.intro g⁻¹
15792
unfold conjugation at *
15893
rw [
15994
h2,
16095
inv.double,
16196
multiply.associative,
16297
←multiply.associative _ g⁻¹ g,
163-
(Group.inverseerse g).1,
98+
(Group.inverse g).1,
16499
multiply.one,
165100
multiply.associative,
166-
(Group.inverseerse g).1,
101+
(Group.inverse g).1,
167102
one.multiply
168103
]
169104
reflexivity := by
170105
intro a
171106
apply Exists.intro 1
172107
unfold conjugation at *
173-
rw [one.multiply, one.inverseerse, multiply.one]
108+
rw [one.multiply, one.inverse, multiply.one]
174109
transitivity := by
175110
intro a b c h1
176111
let ⟨⟨g1, h2⟩, ⟨g2, h3⟩⟩ := h1
@@ -186,7 +121,7 @@ namespace product
186121
def Group.Product (A B: Type) [Group A] [Group B] : Type := A × B
187122

188123
instance (A B: Type) [Group A] [Group B] : Mul (Group.Product A B) := ⟨fun (g1, g2) (h1, h2) => (g1 * h1, g2 * h2)⟩
189-
instance (A B: Type) [Group A] [Group B] : Inv (Group.Product A B) := ⟨fun (g1, g2) => (g1⁻¹, g2⁻¹)⟩
124+
instance (A B: Type) [Group A] [Group B] : Inverse (Group.Product A B) := ⟨fun (g1, g2) => (g1⁻¹, g2⁻¹)⟩
190125
instance (A B: Type) [Group A] [Group B] : OfNat (Group.Product A B) 1 := ⟨(1, 1)⟩
191126

192127
theorem mul_eq (A B: Type) [Group A] [Group B] (a b: Group.Product A B) : a * b = (a.1 * b.1, a.2 * b.2) := rfl
@@ -200,7 +135,7 @@ instance (A B: Type) {ga: Group A} {gb: Group B} : Group (Group.Product A B) :=
200135
rfl
201136
inverse := by
202137
intro a
203-
rw [mul_inv, mul_eq, (ga.inverseerse _).1, (gb.inverseerse _).1, mul_eq, (ga.inverseerse _).2, (gb.inverseerse _).2]
138+
rw [mul_inv, mul_eq, (ga.inverse _).1, (gb.inverse _).1, mul_eq, (ga.inverse _).2, (gb.inverse _).2]
204139
exact ⟨one_left _ _, one_left _ _⟩
205140
identity := by
206141
intro a
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import Mathematics.Algebra.Group
2+
3+
class GroupHomomorphism (T U: Type) [Group T] [Group U] (f: T -> U) :=
4+
map_mul : ∀ a b: T, f (a * b) = f a * f b
5+
6+
def in_kernel {T U: Type} [Group T] [Group U] (f: T -> U) (a: T): Prop := f a = 1
7+
def in_image {T U: Type} [Group T] [Group U] (f: T -> U) (b: U): Prop := ∃ a: T, f a = b
8+
9+
open groups
10+
11+
variable {T U: Type} [Group T] [Group U] (f: T -> U) [GroupHomomorphism T U f]
12+
13+
theorem map.multiply : ∀ a b: T, f (a * b) = f a * f b := GroupHomomorphism.map_mul
14+
15+
theorem map.one : f 1 = 1 := by
16+
apply groups.multiply.left_cancel
17+
show f 1 * f 1 = f 1 * 1
18+
rw [←GroupHomomorphism.map_mul, multiply.one, multiply.one]
19+
20+
-- def id := fun (x: T) => x
21+
22+
instance : GroupHomomorphism T T id := {
23+
map_mul := by intros a b; exact rfl
24+
}
25+
26+
instance (c: T) : GroupHomomorphism T T (conjugation c) := {
27+
map_mul := by
28+
intros a b
29+
unfold conjugation
30+
rw [
31+
←multiply.associative c b,
32+
multiply.associative _ c,
33+
←multiply.associative _ _ c,
34+
(Group.inverse c).left,
35+
multiply.one,
36+
multiply.associative,
37+
multiply.associative
38+
]
39+
}
40+
41+
instance homomorphism.compose { V: Type } [Group V] (f: T -> U) (g: U -> V) [GroupHomomorphism _ _ f] [GroupHomomorphism _ _ g]
42+
: GroupHomomorphism T V (g ∘ f) := {
43+
map_mul := by
44+
intros a b
45+
unfold Function.comp
46+
rw [←map.multiply, ←map.multiply]
47+
}
48+
49+
theorem map.inverse (a : T) : f a⁻¹ = (f a)⁻¹ := by
50+
apply (multiply.left_cancel_iff (f a) (f a⁻¹) (f a)⁻¹).mp
51+
rw [←map.multiply, (Group.inverse a).right, (Group.inverse (f a)).right]
52+
exact @map.one T U _ _ f _
53+
54+
theorem map.multiply.inverse (a b : T) : (f (a * b))⁻¹ = f b⁻¹ * f a⁻¹ := by
55+
rw [←map.multiply, ←inv.multiply, ←map.inverse]
56+
57+
-- TODO exponents
58+
-- theorem map_pow (a : T) (n : Natural) : f a ^ n = (f a) ^ n := by
59+
-- induction n with
60+
-- | zero => rw [power.zero]
61+
-- | successor n ih => rw [power.successor, ih]
62+
63+
def AutomorphismOf (T: Type) [Group T] := GroupHomomorphism T T

Mathematics/Algebra/Group/Order.lean

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import Mathematics.Algebra.Group
22
import Mathematics.Structures.Numbers.Natural
3+
import Mathematics.Structures.Numbers.Natural.Addition
4+
import Mathematics.Structures.Numbers.Natural.Multiplication
35

46
def Group.power {T: Type} [Group T] (a: T) (n: Natural) : T := match n with
57
| Natural.zero => 1
6-
| Natural.successor n => (pow a n) * a
8+
| Natural.successor n => (Group.power a n) * a
79

810
instance {T: Type} [Group T] : Pow T Natural where
911
pow := Group.power
@@ -21,44 +23,42 @@ theorem power.successor (n: Natural) : a ^ Natural.successor n = a ^ n * a := rf
2123
theorem power.successor' (n: Natural) : a ^ Natural.successor n = a * a ^ n := by
2224
rw [power.successor]
2325
induction n with
24-
| zero => rw [power.zero, one.multiply, multiply.one]
26+
| zero => rw [power.zero, groups.one.multiply, groups.multiply.one]
2527
| successor n ih => rw [power.successor, Group.associativity, multiply.right_cancel_iff, ih]
2628

2729
theorem power.one : a ^ (1: Natural) = a := by
28-
rw [←successor.zero_eq_one, power.successor, power.zero, one.multiply]
30+
rw [←successor.zero_eq_one, power.successor, power.zero, groups.one.multiply]
2931

3032
theorem one.power (n: Natural) : (1 : T) ^ n = 1 := by
3133
induction n with
3234
| zero => exact power.zero 1
33-
| successor n ih => rw [power.successor, ih, multiply.one]
35+
| successor n ih => rw [power.successor, ih, groups.multiply.one]
3436

35-
open addition in
3637
theorem power.add (m n : Natural) : a ^ (m + n) = a^m * a^n := by
3738
induction n with
38-
| zero => rw [zero.eq_zero, add.zero, ←zero.eq_zero, power.zero, multiply.one]
39-
| successor n ih => rw [add.successor, power.successor, power.successor, multiply.associative, multiply.right_cancel_iff, ih]
39+
| zero => rw [Natural.zero_def, Natural.add.zero, ←Natural.zero_def, power.zero, groups.multiply.one]
40+
| successor n ih => rw [add.successor, power.successor, power.successor, groups.multiply.associative, multiply.right_cancel_iff, ih]
4041

41-
open multiplication in
4242
theorem power.multiply (m n : Natural) : a ^ (m * n) = (a ^ m) ^ n := by
4343
induction n with
44-
| zero => rw [zero.eq_zero, multiply.zero, ←zero.eq_zero, power.zero, power.zero]
44+
| zero => rw [Natural.zero_def, multiply.zero, ←Natural.zero_def, power.zero, power.zero]
4545
| successor n ih => rw [power.successor, ←ih, ←power.add, multiply.successor]
4646

4747
theorem multiply.power {U : Type} [AbelianGroup U] (a b: U) (n : Natural) : (a * b) ^ n = a ^ n * b ^ n := by
4848
induction n with
49-
| zero => rw [power.zero, power.zero, power.zero, multiply.one]
49+
| zero => rw [power.zero, power.zero, power.zero, groups.multiply.one]
5050
| successor n ih => {
5151
rw [power.successor,
5252
power.successor,
5353
power.successor,
54-
←multiply.associative (a ^ n) a,
54+
groups.multiply.associative (a ^ n) a,
5555
AbelianGroup.commutativity a (b ^ n * b),
5656
ih,
5757
AbelianGroup.commutativity a b,
58-
←multiply.associative (b ^ n) b a,
59-
multiply.associative,
60-
multiply.associative,
61-
multiply.associative
58+
groups.multiply.associative (b ^ n) b a,
59+
groups.multiply.associative,
60+
groups.multiply.associative,
61+
groups.multiply.associative
6262
]
6363
}
6464

Mathematics/Algebra/PartialOrder.lean

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class PartialOrder (T: Type) (relation: T → T → Prop) :=
2+
reflexivity : ∀ a: T, relation a a
3+
antisymmetric : ∀ a b: T, (relation a b) ∧ (relation b a) → a = b
4+
transitivity : ∀ a b c: T, (relation a b) ∧ (relation b c) → (relation a c)

Mathematics/Random/README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

Mathematics/Structures/Function.lean

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ def repeated_apply { T: Type } (f: T → T) (n: Natural) (a: T) : T := match n w
99

1010
/- adding three four times to 2 results in 14 -/
1111
example : repeated_apply (. + 3) 4 2 = 14 := rfl
12+
13+
def function.point_free { T: Type } (f: T → T) : Prop := ∀t: T, f t ≠ t
14+
15+
def function.is_involution { T: Type } (f: T → T) : Prop := ∀t: T, f (f t) = t

0 commit comments

Comments
 (0)