Skip to content
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

feat(algebra/free_algebra): Define a grading #4321

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
957b483
feat(algebra/free_algebra): Add an inductive principle
eric-wieser Sep 30, 2020
e789702
chore(algebra/free_algebra): Use a subtype instead of a struct
eric-wieser Oct 3, 2020
87d31ff
chore(algebra/free_algebra): Disable false positive linter
eric-wieser Oct 3, 2020
778e9db
chore(algebra/free_algebra): Tidy up coercions
eric-wieser Oct 3, 2020
67e8211
refactor(algebra/free_algebra): Replace most of the code with subalgebra
eric-wieser Oct 6, 2020
28b1893
fix(*): remove squeeze_simp
eric-wieser Oct 6, 2020
ed419ec
Merge remote-tracking branch 'origin/master' into eric-wieser/free_al…
eric-wieser Oct 7, 2020
d816bfa
chore(*): Tidy the proof
eric-wieser Oct 7, 2020
aff1486
Add induction for the exterior algebra too
eric-wieser Oct 7, 2020
9f22aa6
feat(data/monoid_algebra): Add missing has_coe_to_fun instance
eric-wieser Sep 29, 2020
e75b7ef
feat(algebra/free_algebra): Attempt to define a grading
eric-wieser Sep 29, 2020
21ca265
Death throes of a failed attempt
eric-wieser Sep 29, 2020
62a77f0
feat(algebra/free_algebra): A few lemmas about grades of free algebras
eric-wieser Sep 29, 2020
fd54b8d
chore(*): Remove duplication between `sum_id` and `lift`
eric-wieser Oct 3, 2020
234ff72
fix(*): Solve merge mistake
eric-wieser Oct 12, 2020
eec3c2b
wip
eric-wieser Oct 12, 2020
81aa68b
chore(algebra/monoid_algebra): Replace `algebra_map'` with `single_(z…
eric-wieser Oct 12, 2020
f999d1a
Merge branch 'eric-wieser/single-hom' into eric-wieser/free_algebra-g…
eric-wieser Oct 12, 2020
abaa760
wip
eric-wieser Oct 12, 2020
b63b36c
wip
eric-wieser Oct 12, 2020
e5b725e
Merge branch 'eric-wieser/free_algebra-induction' into eric-wieser/fr…
eric-wieser Oct 12, 2020
b702aab
Revert unrelated changes
eric-wieser Oct 12, 2020
51900f9
Merge branch 'master' of github.com:leanprover-community/mathlib into…
eric-wieser Oct 12, 2020
5489c46
Fix bad merge
eric-wieser Oct 12, 2020
3ce401d
Merge remote-tracking branch 'origin/master' into eric-wieser/free_al…
eric-wieser Oct 13, 2020
38d3e48
wip
eric-wieser Oct 13, 2020
082ca79
feat(algebra/algebra/basic): Add `map_finsupp_(sum|prod)` to `alg_(ho…
eric-wieser Oct 13, 2020
99b4ac1
Merge branch 'eric-wieser/alg_hom.map_finsupp_sum' into eric-wieser/f…
eric-wieser Oct 13, 2020
303117d
Cleanup some more
eric-wieser Oct 13, 2020
40b1eb8
feat(algebra/algebra/basic): Add `map_finsupp_(sum|prod)` to `alg_(ho…
eric-wieser Oct 13, 2020
1a5eaa9
Merge branch 'eric-wieser/alg_hom.map_finsupp_sum' into eric-wieser/f…
eric-wieser Oct 13, 2020
06e16f5
Fix the proof
eric-wieser Oct 13, 2020
9c41969
Merge remote-tracking branch 'origin/master' into eric-wieser/free_al…
eric-wieser Oct 19, 2020
2d979c3
Cleanup the proofs
eric-wieser Oct 19, 2020
bee9b3c
Merge remote-tracking branch 'origin/master' into eric-wieser/free_al…
eric-wieser Oct 20, 2020
caaa54d
Update src/algebra/monoid_algebra.lean
eric-wieser Oct 20, 2020
33f38c7
Merge remote-tracking branch 'origin/master' into eric-wieser/free_al…
eric-wieser Oct 26, 2020
db82059
wip
eric-wieser Oct 26, 2020
986ed3c
Merge branch 'master' of github.com:leanprover-community/mathlib into…
eric-wieser Oct 28, 2020
1d0b9c9
fix(*): adjust for changed lemmas
eric-wieser Oct 28, 2020
7c58060
Merge branch 'master' into eric-wieser/free_algebra-grading
eric-wieser Dec 4, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
87 changes: 86 additions & 1 deletion src/algebra/free_algebra.lean
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Given a commutative semiring `R`, and a type `X`, we construct the free `R`-alge
of the composition of an algebra morphism with `ι` is the algebra morphism itself.
5. `equiv_monoid_algebra_free_monoid : free_algebra R X ≃ₐ[R] monoid_algebra R (free_monoid X)`
6. An inductive principle `induction`.
7. Statements about the natural grading of the free algebra `grades x i`: `grades.map_algebra_map`,
`grades.map_algebra_ι`, and `grades.map_grades`.

## Implementation details

Expand Down Expand Up @@ -371,6 +373,90 @@ begin
exact of_id a,
end

variables {R X}

/--
Separate an element of the free algebra into its ℕ-graded components.

This is defined as an `alg_hom` to `add_monoid_algebra` so that algebra operators can be moved
before and after the mapping.
-/
noncomputable
def grades : (free_algebra R X) →ₐ[R] add_monoid_algebra (free_algebra R X) ℕ :=
lift R $ finsupp.single 1 ∘ ι R
Copy link
Member

Choose a reason for hiding this comment

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

We have some algebra A (the free algebra), and the question is how to usefully state that A is actually an infinite internal direct sum of submodules A_i. This grades map here seems to be a map which does the following: if a is in A, let a_i be its i'th "piece". Then a_i is in A_i and all but finitely many a_i are zero. We can regard the a_i as elements of A. Now the a_i is a finite sequence of elements of A. So we can make them into a polynomial a_i X^i. grades sends a to this polynomial. I am surprised that this is a useful concept! But one cool thing about it is that it does seem to be a ring homomorphism, rather than just an R-module homomorphism. The next lemma says that if you evaluate the polynomial at 1 then you get back the element you started with. I've been out of the loop for over a month -- sorry if all this conversation has been had already. Is this the way to do grading of an algebra? It still seems a bit weird to me.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think my choice not to use polynomial was deliberate, since I wasn't really trying to invoke the mental model of one (although admittedly I had not spotted that polynomial A is defeq to add_monoid_algebra A ℕ).

I am surprised that this is a useful concept!

It seemed to me like the only (and obvious) way to induce a grading from the universal property alone. I have no idea if this is "how it's done", it's just the way I stumbled upon. I suppose though there's no need for it to be the public interface to the grading, it was just simplest to leave it that way, and the fact it was a ring homomorphism seemed cute, even though there's zero reason to need grades x * grades y as an alternate spelling of grades (x * y).

Is this the way to do grading of an algebra?

I assume you mean for a general algebra?

Copy link
Member Author

Choose a reason for hiding this comment

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

the question is how to usefully state that A is actually an infinite internal direct sum of submodules A_i

I attempted to do this in #4812. The proofs were really quite painful, and I don't think we want to use an API like that until dfinsupp is easier to use.


/-- Recombining the grades recovers the original element-/
lemma sum_id_grades :
(add_monoid_algebra.sum_id R).comp grades = alg_hom.id R (free_algebra R X) :=
begin
ext,
simp [grades, add_monoid_algebra.sum_id_apply, finsupp.sum_single_index],
end

noncomputable
instance : has_coe (add_monoid_algebra (free_algebra R X) ℕ) (free_algebra R X) := ⟨
(add_monoid_algebra.sum_id R : add_monoid_algebra (free_algebra R X) ℕ →ₐ[R] (free_algebra R X))
Copy link
Member

Choose a reason for hiding this comment

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

Should this really be an instance? Do we know for sure that this is the coercion that everyone will want? "evaluate the polynomial at 1"?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm reading this as "evaluate my direct sum over A_i back into A" - I hadn't thought of the "evaluate the polynomial" interpretation, and I think it hurts rather than hinders


@[simp, norm_cast]
lemma coe_def (x : add_monoid_algebra (free_algebra R X) ℕ) : (x : free_algebra R X) = add_monoid_algebra.sum_id R x := rfl
Comment on lines +396 to +402
Copy link
Member Author

Choose a reason for hiding this comment

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

This seemed harmless, and it makes the mouthful that is add_monoid_algebra.sum_id not really matter

Copy link
Member

Choose a reason for hiding this comment

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

You mean the instance? Why not make it a local instance?



/-- An element of `R` lifted with `algebra_map` has a single grade 0 element -/
lemma grades.map_algebra_map (r : R) :
grades (algebra_map R (free_algebra R X) r) = finsupp.single 0 (algebra_map R _ r) :=
by simp

/-- An element of `X` lifted with the canonical `ι R` function has a single grade 1 element -/
lemma grades.map_ι (x : X) :
grades (ι R x) = finsupp.single 1 (ι R x) :=
by simp [grades]

-- note this is true for any `zero_hom`, not just `grades`. Of course, then we need to repeat this
-- for `add_monoid_hom`, `add_equiv`, `linear_map`, `ring_hom`, `ring_equiv`, `alg_hom`, ...
private lemma map_single_apply (x : free_algebra R X) (i j : ℕ) :
grades (finsupp.single i x j) = finsupp.single i (grades x) j :=
by rw [finsupp.single_apply, finsupp.single_apply, apply_ite grades, grades.map_zero]

/-- The grade-`i` part consists only of itself -/
@[simp]
lemma grades.map_grades (x : free_algebra R X) (i : ℕ) :
grades (grades x i) = finsupp.single i (grades x i) :=
begin
induction x using free_algebra.induction generalizing i,
case h_grade0 : {
rw [grades.map_algebra_map, map_single_apply, grades.map_algebra_map,
finsupp.single_of_single_apply],
},
case h_grade1 : {
rw [grades.map_ι, map_single_apply, grades.map_ι,
finsupp.single_of_single_apply],
},
case h_add : x y hx hy {
rw [grades.map_add, finsupp.add_apply, grades.map_add, finsupp.single_add, hx, hy],
},
case h_mul : f g hx hy {
rw grades.map_mul,
rw add_monoid_algebra.mul_def,
simp_rw [finsupp.sum_apply],

-- pull the sums to the outside
have : finsupp.single i = finsupp.single_add_hom i := rfl,
rw this,
simp_rw alg_hom.map_finsupp_sum,
simp_rw add_monoid_hom.map_finsupp_sum,
simp_rw finsupp.sum,
congr, ext1 fi,
congr, ext1 gi,
rw ←this,

-- this proof now resembles the other three
rw [map_single_apply, grades.map_mul,
finsupp.single_of_single_apply],
rw [hx, hy, add_monoid_algebra.single_mul_single],
},
end

/-- The star ring formed by reversing the elements of products -/
instance : star_ring (free_algebra R X) :=
{ star := opposite.unop ∘ lift R (opposite.op ∘ ι R),
Expand All @@ -393,5 +479,4 @@ by simp [star, has_star.star]
def star_hom : free_algebra R X ≃ₐ[R] (free_algebra R X)ᵒᵖ :=
{ commutes' := λ r, by simp [star_algebra_map],
..star_ring_equiv }

end free_algebra
31 changes: 30 additions & 1 deletion src/algebra/monoid_algebra.lean
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,8 @@ alg_hom.to_linear_map_inj $ finsupp.lhom_ext' $ λ a, linear_map.ext_ring (h a)
(φ₂ : monoid_algebra k G →* A).comp (of k G)) : φ₁ = φ₂ :=
alg_hom_ext $ monoid_hom.congr_fun h

variables (k G A)
variables (k G A B)


/-- Any monoid homomorphism `G →* A` can be lifted to an algebra homomorphism
`monoid_algebra k G →ₐ[k] A`. -/
Expand Down Expand Up @@ -446,6 +447,19 @@ by conv_lhs { rw lift_unique' F, simp [lift_apply] }

end lift

variables (k)

/--
The `alg_hom` which maps from a grading of an algebra `A` back to that algebra.
-/
def sum_id {A : Type*} [comm_semiring k] [semiring A] [algebra k A] [monoid G] :
monoid_algebra A G →ₐ[k] A :=
lift_nc_alg_hom (alg_hom.id k A) ⟨λ g, 1, by simp, λ a b, by simp⟩ (by simp)

lemma sum_id_apply {A : Type*} [comm_semiring k] [semiring A] [algebra k A] [monoid G] (g : monoid_algebra A G) :
sum_id k g = g.sum (λ _ gi, gi) :=
by simp [sum_id, lift_nc_alg_hom, lift_nc_ring_hom, lift_nc, alg_hom.id, ring_hom.id]

section
local attribute [reducible] monoid_algebra

Expand Down Expand Up @@ -877,6 +891,9 @@ def lift : (multiplicative G →* A) ≃ (add_monoid_algebra k G →ₐ[k] A) :=

variables {k G A}

variables {k G}


lemma lift_apply' (F : multiplicative G →* A) (f : monoid_algebra k G) :
lift k G A F f = f.sum (λ a b, (algebra_map k A b) * F (multiplicative.of_add a)) := rfl

Expand Down Expand Up @@ -915,6 +932,18 @@ lemma alg_hom_ext_iff {φ₁ φ₂ : add_monoid_algebra k G →ₐ[k] A} :

end lift

variables (k)
/--
The `alg_hom` which maps from a grading of an algebra `A` back to that algebra.
-/
def sum_id {A : Type*} [comm_semiring k] [semiring A] [algebra k A] [add_monoid G] :
add_monoid_algebra A G →ₐ[k] A :=
lift_nc_alg_hom (alg_hom.id k A) ⟨λ g, 1, by simp, λ a b, by simp⟩ (by simp)

lemma sum_id_apply {A : Type*} [comm_semiring k] [semiring A] [algebra k A] [add_monoid G] (g : add_monoid_algebra A G) :
sum_id k g = g.sum (λ _ gi, gi) :=
by simp [sum_id, lift_nc_alg_hom, lift_nc_ring_hom, lift_nc, alg_hom.id, ring_hom.id]

section
local attribute [reducible] add_monoid_algebra

Expand Down
10 changes: 10 additions & 0 deletions src/data/finsupp/basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,16 @@ begin
{ rw [single_eq_of_ne h, zero_apply] }
end

lemma single_of_single_apply (a a' : α) (b : M) :
Copy link
Member Author

Choose a reason for hiding this comment

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

Split to #5219

single a ((single a' b) a) = single a' (single a' b) a :=
begin
rw [single_apply, single_apply],
ext,
split_ifs,
{ rw h, },
Vierkantor marked this conversation as resolved.
Show resolved Hide resolved
{ rw [zero_apply, single_apply, if_t_t], },
end

lemma support_single_ne_zero (hb : b ≠ 0) : (single a b).support = {a} :=
if_neg hb

Expand Down