@@ -239,28 +239,50 @@ by simp [sub_eq_add_neg]
239
239
@[simp] lemma sub_apply (Q Q' : quadratic_form R M) (x : M) : (Q - Q') x = Q x - Q' x :=
240
240
by simp [sub_eq_add_neg]
241
241
242
- instance : has_scalar R₁ (quadratic_form R₁ M) :=
243
- ⟨ λ a Q,
244
- { to_fun := a • Q,
245
- to_fun_smul := λ b x, by simp only [pi.smul_apply, map_smul, smul_eq_mul, mul_left_comm],
246
- polar_add_left' := λ x x' y, by simp only [polar_smul, polar_add_left, mul_add],
247
- polar_smul_left' := λ b x y,
248
- by simp only [polar_smul, polar_smul_left, smul_eq_mul, mul_left_comm],
249
- polar_add_right' := λ x y y', by simp only [polar_smul, polar_add_right, mul_add],
250
- polar_smul_right' := λ b x y,
251
- by simp only [polar_smul, polar_smul_right, smul_eq_mul, mul_left_comm] } ⟩
252
-
253
- @[simp] lemma coe_fn_smul (a : R₁) (Q : quadratic_form R₁ M) : ⇑(a • Q) = a • Q := rfl
242
+ section has_scalar
243
+ variables {R₂ : Type u} [comm_semiring R₂]
254
244
255
- @[simp] lemma smul_apply (a : R₁) (Q : quadratic_form R₁ M) (x : M) : (a • Q) x = a * Q x := rfl
245
+ /-- ` quadratic_form R M` inherits the scalar action from any algebra over `R`.
256
246
257
- instance : module R₁ (quadratic_form R₁ M) :=
258
- { mul_smul := λ a b Q, ext (λ x, by simp only [smul_apply, mul_left_comm, mul_assoc]),
247
+ When `R` is commutative, this provides an `R`-action via `algebra.id`. -/
248
+ instance [algebra R₂ R] : has_scalar R₂ (quadratic_form R M) :=
249
+ ⟨ λ a Q,
250
+ { to_fun := a • Q,
251
+ to_fun_smul := λ b x, by rw [pi.smul_apply, map_smul, pi.smul_apply, algebra.mul_smul_comm],
252
+ polar_add_left' := λ x x' y, begin
253
+ rw [← one_smul R ⇑Q, ←smul_assoc],
254
+ simp only [polar_smul, polar_add_left, mul_add],
255
+ end ,
256
+ polar_smul_left' := λ b x y, begin
257
+ rw [← one_smul R ⇑Q, ←smul_assoc],
258
+ simp only [polar_smul, polar_smul_left, smul_eq_mul, algebra.smul_def, ←mul_assoc, mul_one,
259
+ one_mul, algebra.commutes],
260
+ end ,
261
+ polar_add_right' := λ x y y', begin
262
+ rw [← one_smul R ⇑Q, ←smul_assoc],
263
+ simp only [polar_smul, polar_add_right, mul_add],
264
+ end ,
265
+ polar_smul_right' := λ b x y, begin
266
+ rw [← one_smul R ⇑Q, ←smul_assoc],
267
+ simp only [polar_smul, polar_smul_right, smul_eq_mul, algebra.smul_def, ←mul_assoc, mul_one,
268
+ one_mul, algebra.commutes],
269
+ end } ⟩
270
+
271
+ @[simp] lemma coe_fn_smul [algebra R₂ R] (a : R₂) (Q : quadratic_form R M) : ⇑(a • Q) = a • Q := rfl
272
+
273
+ @[simp] lemma smul_apply [algebra R₂ R] (a : R₂) (Q : quadratic_form R M) (x : M) :
274
+ (a • Q) x = a • Q x := rfl
275
+
276
+ instance [algebra R₂ R] : semimodule R₂ (quadratic_form R M) :=
277
+ { mul_smul := λ a b Q, ext (λ x, by
278
+ simp only [smul_apply, mul_left_comm, ←smul_eq_mul, smul_assoc]),
259
279
one_smul := λ Q, ext (λ x, by simp),
260
- smul_add := λ a Q Q', by { ext, simp only [add_apply, smul_apply, mul_add] },
261
- smul_zero := λ a, by { ext, simp only [zero_apply, smul_apply, mul_zero] },
262
- zero_smul := λ Q, by { ext, simp only [zero_apply, smul_apply, zero_mul] },
263
- add_smul := λ a b Q, by { ext, simp only [add_apply, smul_apply, add_mul] } }
280
+ smul_add := λ a Q Q', by { ext, simp only [add_apply, smul_apply, smul_add] },
281
+ smul_zero := λ a, by { ext, simp only [zero_apply, smul_apply, smul_zero] },
282
+ zero_smul := λ Q, by { ext, simp only [zero_apply, smul_apply, zero_smul] },
283
+ add_smul := λ a b Q, by { ext, simp only [add_apply, smul_apply, add_smul] } }
284
+
285
+ end has_scalar
264
286
265
287
section comp
266
288
0 commit comments