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

[Merged by Bors] - chore(ring_theory/tensor_product): replace is_scalar_tower by smul_comm_class in left_algebra#19118

Closed
ADedecker wants to merge 5 commits intomasterfrom
AD_tensor_left_algebra
Closed

[Merged by Bors] - chore(ring_theory/tensor_product): replace is_scalar_tower by smul_comm_class in left_algebra#19118
ADedecker wants to merge 5 commits intomasterfrom
AD_tensor_left_algebra

Conversation

@ADedecker
Copy link
Copy Markdown
Member

@ADedecker ADedecker commented May 28, 2023

With this change, this instance works for both restriction (e.g tensor product over of complex algebras is a real algebra) and extension (e.g tensor product over of complex algebras is a complex algebra) of scalars.
Zulip

I also removes algebra.tensor_product.tensor_product.is_scalar_tower since it is automatically inferred from tensor_product.is_scalar_tower


Open in Gitpod

@ADedecker ADedecker added awaiting-review The author would like community review of the PR t-algebra Algebra (groups, rings, fields etc) labels May 28, 2023
@github-actions github-actions bot added the modifies-synchronized-file This PR touches a files that has already been ported to mathlib4, and may need a synchronization PR. label May 28, 2023
lemma algebra_map_apply [smul_comm_class R S A] (r : S) :
(algebra_map S (A ⊗[R] B)) r = ((algebra_map S A) r) ⊗ₜ 1 := rfl

instance : is_scalar_tower R S (A ⊗[R] B) := ⟨λ a b c, by simp⟩
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where did this instance go? Is it true by apply_instance? If so, please mention that in the PR description!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, both of the following work:

instance [algebra R S] [is_scalar_tower R S A] : is_scalar_tower R S (A ⊗[R] B) := infer_instance
instance [algebra S R] [is_scalar_tower S R A] : is_scalar_tower S R (A ⊗[R] B) := infer_instance

I added it to the PR description.

Copy link
Copy Markdown
Member

@eric-wieser eric-wieser May 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this creates a forward-porting obligation anyway, should we add the missing results:

  • is_scalar_tower S (A ⊗[R] B) (A ⊗[R] B)
  • smul_comm_class S (A ⊗[R] B) (A ⊗[R] B)

for when A is a non-unital algebra? (they're inferred from left_algebra when the algebra is unital)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the two instances I was thinking of:

instance [monoid S] [distrib_mul_action S A] [is_scalar_tower S A A] [smul_comm_class R S A] :
  is_scalar_tower S (A ⊗[R] B) (A ⊗[R] B) :=
{ smul_assoc := λ r x y, begin
    change (r • x) * y = r • (x * y),
    apply tensor_product.induction_on y,
    { simp [smul_zero], },
    { apply tensor_product.induction_on x,
      { simp [smul_zero] },
      { intros a b a' b',
        dsimp,
        rw [tensor_product.smul_tmul', tensor_product.smul_tmul', tmul_mul_tmul, smul_mul_assoc], },
      { intros, simp [smul_add, add_mul, *], } },
    { intros, simp [smul_add, mul_add, *], },
  end }

instance [monoid S] [distrib_mul_action S A] [smul_comm_class S A A] [smul_comm_class R S A] :
  smul_comm_class S (A ⊗[R] B) (A ⊗[R] B) :=
{ smul_comm := λ r x y, begin
    change r • (x * y) = x * r • y,
    apply tensor_product.induction_on y,
    { simp [smul_zero], },
    { apply tensor_product.induction_on x,
      { simp [smul_zero] },
      { intros a b a' b',
        dsimp,
        rw [tensor_product.smul_tmul', tensor_product.smul_tmul', tmul_mul_tmul, mul_smul_comm], },
      { intros, simp [smul_add, add_mul, *], } },
    { intros, simp [smul_add, mul_add, *], },
  end }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(#19143)

Copy link
Copy Markdown
Member

@eric-wieser eric-wieser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bors d+

Thanks!

Please wait for the out-of-sync queue to drop below 20 items before merging

@bors
Copy link
Copy Markdown

bors bot commented May 28, 2023

✌️ ADedecker can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@leanprover-community-bot-assistant leanprover-community-bot-assistant added delegated The PR author may merge after reviewing final suggestions. and removed awaiting-review The author would like community review of the PR labels May 28, 2023
@eric-wieser eric-wieser added the blocked-by-out-of-sync-queue The #outofsync queue must have at most 20 items label May 29, 2023
@AntoineChambert-Loir
Copy link
Copy Markdown
Collaborator

It is also interesting to add S-linearity instances on the right. Around line 430 :

variables [algebra S B] [tensor_product.compatible_smul R S A B]
/-- The algebra morphism `B →ₐ[S] A ⊗[R] B` sending `b` to `1 ⊗ₜ b`. -/
def include_right : B →ₐ[S] A ⊗[R] B :=
{ to_fun := λ b, 1 ⊗ₜ b,
  map_zero' := by simp,
  map_add' := by simp [tmul_add],
  map_one' := rfl,
  map_mul' := by simp,
  commutes' := λ r,
  begin
    simp only [algebra_map_apply],
    transitivity r • ((1 : A) ⊗ₜ[R] (1 : B)),
    { rw [←tmul_smul, algebra.smul_def], simp, },
    { simp [algebra.smul_def], },
  end, }

@[simp]
lemma include_right_apply (b : B) : (include_right : B →ₐ[S] A ⊗[R] B) b = 1 ⊗ₜ b := rfl

lemma include_left_comp_algebra_map [tensor_product.compatible_smul R S A B] :
-- {R A B : Type*} [comm_ring R] [comm_ring S] [comm_ring T]
--  [algebra R S] [algebra R T] :
    ((include_left : A →ₐ[S] A ⊗[R] B).to_ring_hom.comp (algebra_map R A) : R →+* A ⊗[R] B) =
      (include_right : B →ₐ[S] A ⊗[R] B).to_ring_hom.comp (algebra_map R B) :=
by { ext, simp [algebra.algebra_map_eq_smul_one, smul_tmul] }

I tried to make further adjustement to the right_algebra structure but did not succeed. Maybe this is not necessary.

@AntoineChambert-Loir
Copy link
Copy Markdown
Collaborator

One additional question: there are semiring, ring and comm_ring instances, but no comm_semiring. Is this normal? (Maybe this is just to prevent a diamond, but maybe comm_semiring should be proved anyway.)

/-- The `R`-algebra morphism `A →ₐ[R] A ⊗[R] B` sending `a` to `a ⊗ₜ 1`. -/
def include_left : A →ₐ[R] A ⊗[R] B :=
/-- The `R`-algebra morphism `A →ₐ[S] A ⊗[R] B` sending `a` to `a ⊗ₜ 1`. -/
def include_left [smul_comm_class R S A] : A →ₐ[S] A ⊗[R] B :=
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S should be explicit here

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, and it's often painful otherwise (hence a few include_left : _ \to\_a[S] _ later in the file). However, I wonder whether one could have a variant include_left where S and R are equal, and include_left' for the more general one (with one explicit argument).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do use that pattern elsewhere; though it means you end up duplicating lots of api

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what you mean with “duplicating lots of api”: no new lemma is created.
In the commutative case, the application suggested by @ADedecker requires less than what is done here, namely just A \to\_a A \otimes[R] B. But if A is not commutative, that does not work and one needs all intermediate linearity properties A \to\_a [S] A\otimes[R] B, for adequate S.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have both include_left and include_left', then every time you write a lemma about the primed one you have to duplicate it for the unprimed one. So I think we should just have only the fully-general one; I don't think making people write a single R is much of a burden.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I see. I had imagined having include_left := include_left' R, but that would require many simp only [include_left] to access the API of include_left', or duplicating it as you say.

Copy link
Copy Markdown
Collaborator

@AntoineChambert-Loir AntoineChambert-Loir May 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I'll have to check, but it seems that one needs to do similar modifications in linear_map.tensor_product.lean)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest making this generalization in a separate PR; the typeclass change by itelf is pretty self-contained

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand you correctly, this PR would just change the few instances that are invoked, and adding linearity is given in a separate PR ?

This reverts commit 8d0673e.

I suggested modifications but it seems that the better
for this PR is to have just the change in the instance and
that further results be delegated to a later PR.
@eric-wieser
Copy link
Copy Markdown
Member

bors merge

@github-actions github-actions bot added the ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) label Jun 2, 2023
bors bot pushed a commit that referenced this pull request Jun 2, 2023
…_comm_class` in `left_algebra` (#19118)

With this change, this instance works for both restriction (e.g tensor product over `ℂ` of complex algebras is a real algebra) and extension (e.g tensor product over `ℝ` of complex algebras is a complex algebra) of scalars. 
[Zulip](https://leanprover.zulipchat.com/#narrow/stream/217875-Is-there-code-for-X.3F/topic/Tensor.20products)

I also removes [algebra.tensor_product.tensor_product.is_scalar_tower](https://leanprover-community.github.io/mathlib_docs/ring_theory/tensor_product.html#algebra.tensor_product.tensor_product.is_scalar_tower) since it is automatically inferred from [tensor_product.is_scalar_tower](https://leanprover-community.github.io/mathlib_docs/linear_algebra/tensor_product.html#tensor_product.is_scalar_tower)



Co-authored-by: Antoine Chambert-Loir <antoine.chambert-loir@math.univ-paris-diderot.fr>
@bors
Copy link
Copy Markdown

bors bot commented Jun 2, 2023

Pull request successfully merged into master.

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@bors bors bot changed the title chore(ring_theory/tensor_product): replace is_scalar_tower by smul_comm_class in left_algebra [Merged by Bors] - chore(ring_theory/tensor_product): replace is_scalar_tower by smul_comm_class in left_algebra Jun 2, 2023
@bors bors bot closed this Jun 2, 2023
@bors bors bot deleted the AD_tensor_left_algebra branch June 2, 2023 10:28
bors bot pushed a commit to leanprover-community/mathlib4 that referenced this pull request Jun 8, 2023
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
bors bot pushed a commit to leanprover-community/mathlib4 that referenced this pull request Jun 8, 2023
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
bors bot pushed a commit to leanprover-community/mathlib4 that referenced this pull request Jun 12, 2023
This also removes a stray `import Mathlib.Tactic`, which causes a downstream file to break.



Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
kim-em pushed a commit to leanprover-community/mathlib4 that referenced this pull request Jun 25, 2023
This also removes a stray `import Mathlib.Tactic`, which causes a downstream file to break.



Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

blocked-by-out-of-sync-queue The #outofsync queue must have at most 20 items delegated The PR author may merge after reviewing final suggestions. modifies-synchronized-file This PR touches a files that has already been ported to mathlib4, and may need a synchronization PR. ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) t-algebra Algebra (groups, rings, fields etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants