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

Commit 657df43

Browse files
committed
refactor(linear_algebra/tensor_product): make lift f (x ⊗ₜ y) = f x y true by rfl (#18121)
Since this is essentially the "primitive" recursor, it is very convenient for it to expand definitionally. With this change, the following lemmas are now rfl: * `algebra.mul'_apply` * `free_monoid.lift_comp_of` * `free_monoid.lift_eval_of` * `tensor_product.lie_module.lift_apply` * `alternating_map.dom_coprod'_apply` * `contract_left_apply` * `contract_right_apply` * `dual_tensor_hom_apply` * `derivation.tensor_product_to_tmul` * `poly_equiv_tensor.to_fun_linear_tmul_apply` * `tensor_product.lift.tmul` * `tensor_product.lift.tmul'` * `algebra.tensor_product.lift_tmul` * `algebra.tensor_product.lmul'_apply_tmul` * `tensor_product.algebra.smul_def` And one lemma is no longer rfl * `free_monoid.lift_apply`
1 parent 914cb17 commit 657df43

File tree

11 files changed

+52
-50
lines changed

11 files changed

+52
-50
lines changed

src/algebra/algebra/bilinear.lean

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ variables {R}
5959
@[simp] lemma mul_right_apply (a b : A) : mul_right R a b = b * a := rfl
6060
@[simp] lemma mul_left_right_apply (a b x : A) : mul_left_right R (a, b) x = a * x * b := rfl
6161

62-
@[simp] lemma mul'_apply {a b : A} : mul' R A (a ⊗ₜ b) = a * b :=
63-
by simp only [linear_map.mul', tensor_product.lift.tmul, mul_apply']
62+
@[simp] lemma mul'_apply {a b : A} : mul' R A (a ⊗ₜ b) = a * b := rfl
6463

6564
@[simp] lemma mul_left_zero_eq_zero :
6665
mul_left R (0 : A) = 0 :=

src/algebra/free_monoid/basic.lean

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,27 +136,41 @@ lemma hom_eq ⦃f g : free_monoid α →* M⦄ (h : ∀ x, f (of x) = g (of x))
136136
monoid_hom.ext $ λ l, rec_on l (f.map_one.trans g.map_one.symm) $
137137
λ x xs hxs, by simp only [h, hxs, monoid_hom.map_mul]
138138

139+
/-- A variant of `list.prod` that has `[x].prod = x` true definitionally.
140+
141+
The purpose is to make `free_monoid.lift_eval_of` true by `rfl`. -/
142+
@[to_additive "A variant of `list.sum` that has `[x].sum = x` true definitionally.
143+
144+
The purpose is to make `free_add_monoid.lift_eval_of` true by `rfl`."]
145+
def prod_aux {M} [monoid M] (l : list M) : M :=
146+
l.rec_on 1 (λ x xs (_ : M), list.foldl (*) x xs)
147+
148+
@[to_additive]
149+
lemma prod_aux_eq : ∀ l : list M, free_monoid.prod_aux l = l.prod
150+
| [] := rfl
151+
| (x :: xs) := congr_arg (λ x, list.foldl (*) x xs) (one_mul _).symm
152+
139153
/-- Equivalence between maps `α → M` and monoid homomorphisms `free_monoid α →* M`. -/
140154
@[to_additive "Equivalence between maps `α → A` and additive monoid homomorphisms
141155
`free_add_monoid α →+ A`."]
142156
def lift : (α → M) ≃ (free_monoid α →* M) :=
143-
{ to_fun := λ f, ⟨λ l, (l.to_list.map f).prod, rfl,
144-
λ l₁ l₂, by simp only [to_list_mul, list.map_append, list.prod_append]⟩,
157+
{ to_fun := λ f, ⟨λ l, free_monoid.prod_aux (l.to_list.map f), rfl,
158+
λ l₁ l₂, by simp only [prod_aux_eq, to_list_mul, list.map_append, list.prod_append]⟩,
145159
inv_fun := λ f x, f (of x),
146-
left_inv := λ f, funext $ λ x, one_mul (f x),
147-
right_inv := λ f, hom_eq $ λ x, one_mul (f (of x)) }
160+
left_inv := λ f, rfl,
161+
right_inv := λ f, hom_eq $ λ x, rfl }
148162

149163
@[simp, to_additive]
150164
lemma lift_symm_apply (f : free_monoid α →* M) : lift.symm f = f ∘ of := rfl
151165

152166
@[to_additive]
153-
lemma lift_apply (f : α → M) (l : free_monoid α) : lift f l = (l.to_list.map f).prod := rfl
167+
lemma lift_apply (f : α → M) (l : free_monoid α) : lift f l = (l.to_list.map f).prod :=
168+
prod_aux_eq _
154169

155-
@[to_additive] lemma lift_comp_of (f : α → M) : lift f ∘ of = f := lift.symm_apply_apply f
170+
@[to_additive] lemma lift_comp_of (f : α → M) : lift f ∘ of = f := rfl
156171

157172
@[simp, to_additive]
158-
lemma lift_eval_of (f : α → M) (x : α) : lift f (of x) = f x :=
159-
congr_fun (lift_comp_of f) x
173+
lemma lift_eval_of (f : α → M) (x : α) : lift f (of x) = f x := rfl
160174

161175
@[simp, to_additive]
162176
lemma lift_restrict (f : free_monoid α →* M) : lift (f ∘ of) = f :=

src/algebra/lie/tensor_product.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def lift : (M →ₗ[R] N →ₗ[R] P) ≃ₗ⁅R,L⁆ (M ⊗[R] N →ₗ[R] P)
8787

8888
@[simp] lemma lift_apply (f : M →ₗ[R] N →ₗ[R] P) (m : M) (n : N) :
8989
lift R L M N P f (m ⊗ₜ n) = f m n :=
90-
lift.equiv_apply R M N P f m n
90+
rfl
9191

9292
/-- A weaker form of the universal property for tensor product of modules of a Lie algebra.
9393

src/category_theory/monoidal/internal/Module.lean

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ instance (A : Mon_ (Module.{u} R)) : algebra R A.X :=
6666
have h₂ := linear_map.congr_fun A.mul_one (a ⊗ₜ r),
6767
exact h₁.trans h₂.symm,
6868
end,
69-
smul_def' := λ r a, by { convert (linear_map.congr_fun A.one_mul (r ⊗ₜ a)).symm, simp, },
69+
smul_def' := λ r a, (linear_map.congr_fun A.one_mul (r ⊗ₜ a)).symm,
7070
..A.one }
7171

7272
@[simp] lemma algebra_map (A : Mon_ (Module.{u} R)) (r : R) : algebra_map R A.X r = A.one r := rfl
@@ -127,10 +127,8 @@ def inverse : Algebra.{u} R ⥤ Mon_ (Module.{u} R) :=
127127
{ obj := inverse_obj,
128128
map := λ A B f,
129129
{ hom := f.to_linear_map,
130-
one_hom' :=
131-
by { ext, dsimp, simp only [ring_hom.map_one, alg_hom.map_one] },
132-
mul_hom' :=
133-
by { ext, dsimp, simp only [linear_map.mul'_apply, ring_hom.map_mul, alg_hom.map_mul] } } }.
130+
one_hom' := linear_map.ext f.commutes,
131+
mul_hom' := tensor_product.ext $ linear_map.ext₂ $ map_mul f, } }
134132

135133
end Mon_Module_equivalence_Algebra
136134

@@ -146,19 +144,17 @@ def Mon_Module_equivalence_Algebra : Mon_ (Module.{u} R) ≌ Algebra R :=
146144
unit_iso := nat_iso.of_components
147145
(λ A,
148146
{ hom := { hom := { to_fun := id, map_add' := λ x y, rfl, map_smul' := λ r a, rfl, },
149-
mul_hom' := by { ext, dsimp at *,
150-
simp only [linear_map.mul'_apply, Mon_.X.ring_mul] } },
147+
mul_hom' := by { ext, dsimp at *, refl } },
151148
inv := { hom := { to_fun := id, map_add' := λ x y, rfl, map_smul' := λ r a, rfl, },
152-
mul_hom' := by { ext, dsimp at *,
153-
simp only [linear_map.mul'_apply, Mon_.X.ring_mul]} } })
149+
mul_hom' := by { ext, dsimp at *, refl } } })
154150
(by tidy),
155151
counit_iso := nat_iso.of_components (λ A,
156152
{ hom :=
157153
{ to_fun := id,
158154
map_zero' := rfl,
159155
map_add' := λ x y, rfl,
160156
map_one' := (algebra_map R A).map_one,
161-
map_mul' := λ x y, linear_map.mul'_apply,
157+
map_mul' := λ x y, (@linear_map.mul'_apply R _ _ _ _ _ _ x y),
162158
commutes' := λ r, rfl, },
163159
inv :=
164160
{ to_fun := id,

src/group_theory/submonoid/membership.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,8 @@ by rw [free_monoid.mrange_lift, subtype.range_coe]
291291
@[to_additive] lemma closure_eq_image_prod (s : set M) :
292292
(closure s : set M) = list.prod '' {l : list M | ∀ x ∈ l, x ∈ s} :=
293293
begin
294-
rw [closure_eq_mrange, coe_mrange, ← list.range_map_coe, ← set.range_comp],
295-
refl
294+
rw [closure_eq_mrange, coe_mrange, ← list.range_map_coe, ← set.range_comp, function.comp],
295+
exact congr_arg _ (funext $ free_monoid.lift_apply _),
296296
end
297297

298298
@[to_additive]

src/linear_algebra/alternating.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ tensor_product.lift $ by
862862
lemma dom_coprod'_apply
863863
(a : alternating_map R' Mᵢ N₁ ιa) (b : alternating_map R' Mᵢ N₂ ιb) :
864864
dom_coprod' (a ⊗ₜ[R'] b) = dom_coprod a b :=
865-
by simp only [dom_coprod', tensor_product.lift.tmul, linear_map.mk₂_apply]
865+
rfl
866866

867867
end alternating_map
868868

src/linear_algebra/contraction.lean

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ def dual_tensor_hom : (module.dual R M) ⊗ N →ₗ[R] M →ₗ[R] N :=
4848
variables {R M N P Q}
4949

5050
@[simp] lemma contract_left_apply (f : module.dual R M) (m : M) :
51-
contract_left R M (f ⊗ₜ m) = f m := by apply uncurry_apply
51+
contract_left R M (f ⊗ₜ m) = f m := rfl
5252

5353
@[simp] lemma contract_right_apply (f : module.dual R M) (m : M) :
54-
contract_right R M (m ⊗ₜ f) = f m := by apply uncurry_apply
54+
contract_right R M (m ⊗ₜ f) = f m := rfl
5555

5656
@[simp] lemma dual_tensor_hom_apply (f : module.dual R M) (m : M) (n : N) :
5757
dual_tensor_hom R M N (f ⊗ₜ n) m = (f m) • n :=
58-
by { dunfold dual_tensor_hom, rw uncurry_apply, refl, }
58+
rfl
5959

6060
@[simp] lemma transpose_dual_tensor_hom (f : module.dual R M) (m : M) :
6161
dual.transpose (dual_tensor_hom R M M (f ⊗ₜ m)) = dual_tensor_hom R _ _ (dual.eval R M m ⊗ₜ f) :=
@@ -199,6 +199,7 @@ begin
199199
have h : function.surjective e.to_linear_map := e.surjective,
200200
refine (cancel_right h).1 _,
201201
ext p f q m,
202+
dsimp [ltensor_hom_equiv_hom_ltensor],
202203
simp only [ltensor_hom_equiv_hom_ltensor, dual_tensor_hom_equiv, compr₂_apply, mk_apply, coe_comp,
203204
linear_equiv.coe_to_linear_map, function.comp_app, map_tmul, linear_equiv.coe_coe,
204205
dual_tensor_hom_equiv_of_basis_apply, linear_equiv.trans_apply, congr_tmul,

src/linear_algebra/tensor_product.lean

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,7 @@ add_con.add_con_gen_le $ λ x y hxy, match x, y, hxy with
403403
by simp_rw [add_monoid_hom.map_add, add_comm]
404404
end
405405

406-
lemma lift_aux_tmul (m n) : lift_aux f (m ⊗ₜ n) = f m n :=
407-
zero_add _
406+
lemma lift_aux_tmul (m n) : lift_aux f (m ⊗ₜ n) = f m n := rfl
408407

409408
variable {f}
410409

@@ -422,11 +421,8 @@ def lift : M ⊗ N →ₗ[R] P :=
422421
.. lift_aux f }
423422
variable {f}
424423

425-
@[simp] lemma lift.tmul (x y) : lift f (x ⊗ₜ y) = f x y :=
426-
zero_add _
427-
428-
@[simp] lemma lift.tmul' (x y) : (lift f).1 (x ⊗ₜ y) = f x y :=
429-
lift.tmul _ _
424+
@[simp] lemma lift.tmul (x y) : lift f (x ⊗ₜ y) = f x y := rfl
425+
@[simp] lemma lift.tmul' (x y) : (lift f).1 (x ⊗ₜ y) = f x y := rfl
430426

431427
theorem ext' {g h : (M ⊗[R] N) →ₗ[R] P}
432428
(H : ∀ x y, g (x ⊗ₜ y) = h (x ⊗ₜ y)) : g = h :=
@@ -653,11 +649,11 @@ variables [add_comm_monoid Q'] [module R Q']
653649

654650
lemma map_comp (f₂ : P →ₗ[R] P') (f₁ : M →ₗ[R] P) (g₂ : Q →ₗ[R] Q') (g₁ : N →ₗ[R] Q) :
655651
map (f₂.comp f₁) (g₂.comp g₁) = (map f₂ g₂).comp (map f₁ g₁) :=
656-
ext' $ λ _ _, by simp only [linear_map.comp_apply, map_tmul]
652+
ext' $ λ _ _, rfl
657653

658654
lemma lift_comp_map (i : P →ₗ[R] Q →ₗ[R] Q') (f : M →ₗ[R] P) (g : N →ₗ[R] Q) :
659655
(lift i).comp (map f g) = lift ((i.comp f).compl₂ g) :=
660-
ext' $ λ _ _, by simp only [lift.tmul, map_tmul, linear_map.compl₂_apply, linear_map.comp_apply]
656+
ext' $ λ _ _, rfl
661657

662658
local attribute [ext] ext
663659

src/ring_theory/derivation.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ tensor_product.algebra_tensor_module.lift ((linear_map.lsmul S (S →ₗ[R] M)).
520520

521521
lemma derivation.tensor_product_to_tmul (D : derivation R S M) (s t : S) :
522522
D.tensor_product_to (s ⊗ₜ t) = s • D t :=
523-
tensor_product.lift.tmul s t
523+
rfl
524524

525525
lemma derivation.tensor_product_to_mul (D : derivation R S M) (x y : S ⊗[R] S) :
526526
D.tensor_product_to (x * y) = tensor_product.lmul' R x • D.tensor_product_to y +
@@ -815,7 +815,7 @@ begin
815815
{ generalize : f x = y, obtain ⟨y, rfl⟩ := ideal.quotient.mk_surjective y, refl },
816816
have e₂ : x = kaehler_differential.quotient_cotangent_ideal_ring_equiv
817817
R S (is_scalar_tower.to_alg_hom R S _ x),
818-
{ exact ((tensor_product.lmul'_apply_tmul x 1).trans (mul_one x)).symm },
818+
{ exact (mul_one x).symm },
819819
split,
820820
{ intro e,
821821
exact (e₁.trans (@ring_equiv.congr_arg _ _ _ _ _ _

src/ring_theory/polynomial_algebra.lean

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ tensor_product.lift (to_fun_bilinear R A)
7272

7373
@[simp]
7474
lemma to_fun_linear_tmul_apply (a : A) (p : R[X]) :
75-
to_fun_linear R A (a ⊗ₜ[R] p) = to_fun_bilinear R A a p := lift.tmul _ _
75+
to_fun_linear R A (a ⊗ₜ[R] p) = to_fun_bilinear R A a p := rfl
7676

7777
-- We apparently need to provide the decidable instance here
7878
-- in order to successfully rewrite by this lemma.
@@ -125,10 +125,7 @@ alg_hom_of_linear_map_tensor_product
125125

126126
@[simp] lemma to_fun_alg_hom_apply_tmul (a : A) (p : R[X]) :
127127
to_fun_alg_hom R A (a ⊗ₜ[R] p) = p.sum (λ n r, monomial n (a * (algebra_map R A) r)) :=
128-
begin
129-
dsimp [to_fun_alg_hom],
130-
rw [to_fun_linear_tmul_apply, to_fun_bilinear_apply_eq_sum],
131-
end
128+
to_fun_bilinear_apply_eq_sum R A _ _
132129

133130
/--
134131
(Implementation detail.)

0 commit comments

Comments
 (0)