roseking's picture
Add lean source and binary files (part 6)
2c7d975 verified
Raw History Blame Contribute Delete
4.87 kB
12
@[ext] structure Triangular (R F : Type*) where
body · 3 lines
  top : R
  bottom : R
  off : F
21
def coordinates : Triangular R F ≃ (R × R) × F where
body · 4 lines
  toFun x := ((x.top, x.bottom), x.off)
  invFun x := ⟨x.1.1, x.1.2, x.2⟩
  left_inv _ := rfl
  right_inv _ := rfl
27
instance [AddCommGroup R] [AddCommGroup F] : AddCommGroup (Triangular R F) :=
body · 1 line
  coordinates.addCommGroup
30
def coordinateAddEquiv [AddCommGroup R] [AddCommGroup F] :
    Triangular R F ≃+ (R × R) × F where
body · 2 lines
  toEquiv := coordinates
  map_add' _ _ := rfl
38
instance : One (Triangular R F) := ⟨⟨1, 1, 0⟩⟩
40
instance : Mul (Triangular R F) :=
body · 2 lines
  ⟨fun x y => ⟨x.top * y.top, x.bottom * y.bottom,
    x.bottom • y.off + MulOpposite.op y.top • x.off⟩⟩
48
@[simp] theorem top_zero : (0 : Triangular R F).top = 0 := rfl
49
@[simp] theorem bottom_zero : (0 : Triangular R F).bottom = 0 := rfl
50
@[simp] theorem off_zero : (0 : Triangular R F).off = 0 := rfl
51
@[simp] theorem top_one : (1 : Triangular R F).top = 1 := rfl
52
@[simp] theorem bottom_one : (1 : Triangular R F).bottom = 1 := rfl
53
@[simp] theorem off_one : (1 : Triangular R F).off = 0 := rfl
54
@[simp] theorem top_add (x y : Triangular R F) : (x + y).top = x.top + y.top := rfl
55
@[simp] theorem bottom_add (x y : Triangular R F) :
    (x + y).bottom = x.bottom + y.bottom := rfl
57
@[simp] theorem off_add (x y : Triangular R F) : (x + y).off = x.off + y.off := rfl
60
@[simp] theorem top_mul (x y : Triangular R F) : (x * y).top = x.top * y.top := rfl
61
@[simp] theorem bottom_mul (x y : Triangular R F) :
    (x * y).bottom = x.bottom * y.bottom := rfl
63
@[simp] theorem off_mul (x y : Triangular R F) :
    (x * y).off = x.bottom • y.off + MulOpposite.op y.top • x.off := rfl
68
instance : Ring (Triangular R F) where
body · 14 lines
  __ := (inferInstance : AddCommGroup (Triangular R F))
  mul_assoc x y z := by
    ext
    · exact mul_assoc ..
    · exact mul_assoc ..
    · simp only [off_mul, bottom_mul, top_mul, mul_smul, smul_add, MulOpposite.op_mul]
      rw [← smul_comm x.bottom (MulOpposite.op z.top) y.off]
      exact (add_assoc ..).symm
  one_mul x := by ext <;> simp
  mul_one x := by ext <;> simp
  left_distrib x y z := by ext <;> simp [mul_add, smul_add, add_smul, add_add_add_comm]
  right_distrib x y z := by ext <;> simp [add_mul, smul_add, add_smul, add_add_add_comm]
  zero_mul x := by ext <;> simp
  mul_zero x := by ext <;> simp
84
def diagonal : Triangular R F →+* R × R where
body · 5 lines
  toFun x := (x.top, x.bottom)
  map_one' := rfl
  map_mul' _ _ := rfl
  map_zero' := rfl
  map_add' _ _ := rfl
91
theorem diagonal_surjective : Function.Surjective (diagonal (R := R) (F := F)) := by
proof · 2 lines
  intro x
  exact ⟨⟨x.1, x.2, 0⟩, rfl⟩
95
def offDiagonal (f : F) : Triangular R F := ⟨0, 0, f⟩
97
@[simp] theorem offDiagonal_mul_offDiagonal (f g : F) :
    offDiagonal (R := R) f * offDiagonal g = 0 := by
proof · 1 line
  ext <;> simp [offDiagonal]
105
instance : Module k (Triangular R F) := coordinateAddEquiv.module k
107
@[simp] theorem top_smul (c : k) (x : Triangular R F) : (c • x).top = c • x.top := rfl
108
@[simp] theorem bottom_smul (c : k) (x : Triangular R F) :
    (c • x).bottom = c • x.bottom := rfl
110
@[simp] theorem off_smul (c : k) (x : Triangular R F) : (c • x).off = c • x.off := rfl
115
instance : Algebra k (Triangular R F) := Algebra.ofModule
body · 15 lines
  (by
    intro c x y
    ext
    · exact smul_mul_assoc c x.top y.top
    · exact smul_mul_assoc c x.bottom y.bottom
    · simp only [off_mul, off_smul, bottom_smul, smul_assoc, smul_add]
      rw [← smul_comm c (MulOpposite.op y.top) x.off])
  (by
    intro c x y
    ext
    · exact mul_smul_comm c x.top y.top
    · exact mul_smul_comm c x.bottom y.bottom
    · simp only [off_mul, off_smul, top_smul, MulOpposite.op_smul,
        smul_assoc, smul_add]
      rw [← smul_comm c x.bottom y.off])
132
def coordinateLinearEquiv : Triangular R F ≃ₗ[k] (R × R) × F :=
body · 1 line
  (coordinateAddEquiv (R := R) (F := F)).linearEquiv k
135
instance [Module.Finite k R] [Module.Finite k F] : Module.Finite k (Triangular R F) :=
body · 1 line
  Module.Finite.equiv (coordinateLinearEquiv (R := R) (F := F) k).symm