-
Notifications
You must be signed in to change notification settings - Fork 297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Merged by Bors] - feat(linear_algebra/tensor_algebra): Tensor algebras #3531
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
pre.has_coe_module pre.has_coe_ring pre.has_mul pre.has_add pre.has_zero | ||
pre.has_one pre.has_scalar pre.has_neg | ||
|
||
instance : ring (tensor_algebra R M) := |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This proof and the following one really seem to call for a small tactic, something like the pi_instance
tactic.
Now that this is written in terms of |
This is a more general question: if you have semiring which is an algebra over a ring, then it is also a ring. But this proof probably doesn't belong in this PR. |
Also, changed function ccomp in theorems to a comp of lin maps.
My fear is that such a proof might require an entirely different construction, perhaps as bad as having two entirely separate |
I'm pretty confident this won't be the case. Given a semiring which is an algebra over a ring, it's straightforward to construct a ring instance. |
Besides some minor suggestions on doc-strings, let's hit merge! |
bors d+ |
✌️ adamtopaz can now approve this pull request. To approve and merge a pull request, simply reply with |
Oops, removing that, another maintainer suggested we look more at this one. bors d- |
begin | ||
refine ⟨λ hyp, _, λ hyp, by simp [hyp]⟩, | ||
ext, | ||
rcases quot.exists_rep x with ⟨x,rfl⟩, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rcases quot.exists_rep x with ⟨x,rfl⟩, | |
rcases x, |
theorem lift_unique {A : Type u₃} [semiring A] [algebra R A] (f : M →ₗ[R] A) | ||
(g : tensor_algebra R M →ₐ[R] A) : g.to_linear_map.comp (ι R M) = f ↔ g = lift R M f := | ||
begin | ||
refine ⟨λ hyp, _, λ hyp, by simp [hyp]⟩, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clearer without simp
, maybe?
refine ⟨λ hyp, _, λ hyp, by simp [hyp]⟩, | |
refine ⟨λ hyp, _, λ hyp, by {rw hyp, exact ι_comp_lift f}⟩, |
|
||
@[simp] | ||
theorem ι_comp_lift {A : Type u₃} [semiring A] [algebra R A] (f : M →ₗ[R] A) : | ||
(lift R M f).to_linear_map.comp (ι R M) = f := by {ext, refl} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this similar theorem also useful?
@[simp]
theorem lift_comp_ι {A : Type u₃} [semiring A] [algebra R A] (g : tensor_algebra R M →ₐ[R] A) :
lift R M (g.to_linear_map.comp (ι R M)) = g :=
begin
symmetry,
ext,
rcases x,
induction x,
case pre.of: x { refl },
case pre.of_scalar: x { exact alg_hom.commutes g x },
case pre.add: a b ha hb { change g (quot.mk _ _ + quot.mk _ _) = _,
rw alg_hom.map_add,
rw [ha, hb], refl },
case pre.mul: a b ha hb { change g (quot.mk _ _ * quot.mk _ _) = _,
rw alg_hom.map_mul,
rw [ha, hb], refl },
end
With it, you can implement lift_unique
as ⟨λ hyp, by simp [←hyp], λ hyp, by simp [hyp]⟩
Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
Here is a summary of the changes.
Thanks @eric-wieser and @semorrison for the suggestions! I want to reiterate that neither I nor @eric-wieser marked the conversations about the universe variables and I understand (and agree!) that this is a large project with a lot of moving pieces, and that style, formatting, and documentation is important. If there are some other issues, then please let me know what they are and I would be happy to change them. Other than that, I'll honestly say that I was a bit discouraged by the subtly hostile comments about "bad habits." |
I'm really sorry that you felt that my comment was "subtly hostile". This was not my intention at all. I don't understand why people marked these conversation as resolved, and I admit it didn't come to my mind that other maintainers could have done that. But all maintainers are under pressure from the huge flow of PRs. We are very happy to see all those contributions, but it's not always easy. I'm a bit worried that changing the universes annotations required changes to the proofs. I think it's a very bad omen. We really need to understand what happened. The first step is to have a look at all the universe levels inferred by Lean before and after this change. |
Thanks @PatrickMassot -- no harm, no foul. Concerning universes -- I just checked. The universe annotations work out to be the same. The three types Before: repeat { set G := lift_fun R M f,
change G _ + G _ = G _ + G _,
rw h_ih, },
repeat { set G := lift_fun R M f,
change G _ * G _ = G _ * G _,
rw h_ih, }, After: repeat { change lift_fun R M f _ + lift_fun R M f _ = _,
rw h_ih,
refl, },
repeat { change lift_fun R M f _ * lift_fun R M f _ = _,
rw h_ih,
refl, }, These seem to be equivalent to me! And certainly the second proof works even with complete universe annotations (I checked). |
Ok, thanks for checking this. I'll let Scott check whether he's happy and merge. |
This comment has been minimized.
This comment has been minimized.
You need a comm_ring instance for R. This is a restriction coming from the algebra typeclass |
I'm being stupid, I misread |
bors merge |
This PR constructs the tensor algebra of a module over a commutative ring. The main components are: 1. The construction of the tensor algebra: `tensor_algebra R M` for a module `M` over a commutative ring `R`. 2. The linear map `univ R M` from `M` to `tensor_algebra R M`. 3. Given a linear map `f`from `M`to an `R`-algebra `A`, the lift of `f` to `tensor_algebra R M` is denoted `lift R M f`. 4. A theorem `univ_comp_lift` asserting that the composition of `univ R M` with `lift R M f`is `f`. 5. A theorem `lift_unique` asserting the uniqueness of `lift R M f`with respect to property 4. Co-authored-by: Adam Topaz <adamtopaz@users.noreply.github.com> Co-authored-by: Patrick Massot <patrickmassot@free.fr>
Pull request successfully merged into master. Build succeeded: |
This PR constructs the tensor algebra of a module over a commutative ring.
The main components are:
tensor_algebra R M
for a moduleM
over a commutative ringR
.univ R M
fromM
totensor_algebra R M
.f
fromM
to anR
-algebraA
, the lift off
totensor_algebra R M
is denotedlift R M f
.univ_comp_lift
asserting that the composition ofuniv R M
withlift R M f
isf
.lift_unique
asserting the uniqueness oflift R M f
with respect to property 4.Note: This PR only does the bare minimum!