|
| 1 | +/- |
| 2 | +Copyright (c) 2015 Nathaniel Thomas. All rights reserved. |
| 3 | +Released under Apache 2.0 license as described in the file LICENSE. |
| 4 | +Authors: Nathaniel Thomas, Jeremy Avigad |
| 5 | +
|
| 6 | +Modules and vector spaces over a ring. |
| 7 | +-/ |
| 8 | +import algebra.field |
| 9 | + |
| 10 | +universes u v |
| 11 | + |
| 12 | +class has_scalar (α : inout Type u) (γ : Type v) := (smul : α → γ → γ) |
| 13 | + |
| 14 | +infixl ` • `:73 := has_scalar.smul |
| 15 | + |
| 16 | +/- modules over a ring -/ |
| 17 | + |
| 18 | +class module (α : inout Type u) (β : Type v) [ring α] extends has_scalar α β, add_comm_group β := |
| 19 | +(smul_left_distrib : ∀r (x y : β), r • (x + y) = r • x + r • y) |
| 20 | +(smul_right_distrib : ∀r s (x : β), (r + s) • x = r • x + s • x) |
| 21 | +(mul_smul : ∀r s (x : β), (r * s) • x = r • (s • x)) |
| 22 | +(one_smul : ∀x : β, (1 : α) • x = x) |
| 23 | + |
| 24 | +section module |
| 25 | +variables {α : Type u} {β : Type v} [ring α] [module α β] |
| 26 | +variables {a b c : α} {u v w : β} |
| 27 | + |
| 28 | +theorem smul_left_distrib : a • (u + v) = a • u + a • v := module.smul_left_distrib _ a u v |
| 29 | +theorem smul_right_distrib : (a + b) • u = a • u + b • u := module.smul_right_distrib _ a b u |
| 30 | +theorem mul_smul : (a * b) • u = a • (b • u) := module.mul_smul _ a b u |
| 31 | +@[simp] theorem one_smul : (1 : α) • u = u := module.one_smul _ u |
| 32 | + |
| 33 | +@[simp] theorem zero_smul : (0 : α) • u = 0 := |
| 34 | +have (0 : α) • u + 0 • u = 0 • u + 0, by rewrite [←smul_right_distrib]; simp, |
| 35 | +add_left_cancel this |
| 36 | + |
| 37 | +@[simp] theorem smul_zero : a • (0 : β) = 0 := |
| 38 | +have a • (0:β) + a • 0 = a • 0 + 0, by rewrite [←smul_left_distrib]; simp, |
| 39 | +add_left_cancel this |
| 40 | + |
| 41 | +@[simp] theorem neg_smul : (-a) • u = - (a • u) := |
| 42 | +eq_neg_of_add_eq_zero (by rewrite [←smul_right_distrib, add_left_neg, zero_smul]) |
| 43 | + |
| 44 | +@[simp] theorem smul_neg : a • (-u) = -(a • u) := |
| 45 | +calc a • (-u) = a • (-(1 • u)) : by simp |
| 46 | + ... = (a * -1) • u : by rw [←neg_smul, mul_smul]; simp |
| 47 | + ... = -(a • u) : by rw [mul_neg_eq_neg_mul_symm]; simp |
| 48 | + |
| 49 | +theorem smul_sub_left_distrib (a : α) (u v : β) : a • (u - v) = a • u - a • v := |
| 50 | +by simp [smul_left_distrib] |
| 51 | + |
| 52 | +theorem sub_smul_right_distrib (a b : α) (v : β) : (a - b) • v = a • v - b • v := |
| 53 | +by simp [smul_right_distrib] |
| 54 | + |
| 55 | +end module |
| 56 | + |
| 57 | +def ring.to_module {α : Type u} [r : ring α] : module α α := |
| 58 | +{ r with |
| 59 | + smul := λa b, a * b, |
| 60 | + smul_left_distrib := assume a b c, mul_add _ _ _, |
| 61 | + smul_right_distrib := assume a b c, add_mul _ _ _, |
| 62 | + mul_smul := assume a b c, mul_assoc _ _ _, |
| 63 | + one_smul := assume a, one_mul _ } |
| 64 | + |
| 65 | +/- vector spaces -/ |
| 66 | + |
| 67 | +class vector_space (α : inout Type u) (β : Type v) [field α] extends module α β |
0 commit comments