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

Failed attempt to replace ℤ with an extra type parameter. #6

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 23 additions & 18 deletions src/geometric_algebra/nursery/graded.lean
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ import algebra.group
import linear_algebra.tensor_product
import tactic.ring

universes u
universes u v

open_locale big_operators
open_locale classical
open finset

class graded_module_components
-- the indices of the grades, typically ℕ
{ι : Type u} [has_zero ι]
-- a type for each grade.
(A : → Type u)
(A : ι → Type u)
:=
-- (A 0) is the scalar type
[zc: comm_ring (A 0)]
Expand All @@ -25,21 +27,23 @@ attribute [instance] graded_module_components.b
attribute [instance] graded_module_components.c

namespace graded_module_components
variables {A : → Type u}
variables {ι : Type u} [has_zero ι] {A : ι → Type u}
/-- objects are coercible only if they have the same grade-/
instance has_coe (r s : ) (h: r = s) : has_coe (A r) (A s) := { coe := by {subst h, exact id}}
instance has_coe (r s : ι) (h: r = s) : has_coe (A r) (A s) := { coe := by {subst h, exact id}}
end graded_module_components

-- needed for the definition of `select`
attribute [instance] dfinsupp.to_semimodule

/-- Grade selection maps from objects in G to a finite set of components of substituent grades -/
class has_grade_select
(A : ℤ → Type u) (G: Type u)
{ι : Type u} [has_zero ι]
(A : ι → Type u) (G: Type u)
[graded_module_components A]
[add_comm_group G]
[ring (A 0)]
Copy link
Member Author

Choose a reason for hiding this comment

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

Without this line, module (A 0) G below would fail, even though this should be implied by graded_module_components.zc?

[module (A 0) G] :=
(select : G →ₗ[A 0] (Π₀ r, A r))
(select : linear_map (A 0) G (Π₀ r, A r))
Copy link
Member Author

@eric-wieser eric-wieser Jul 3, 2020

Choose a reason for hiding this comment

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

With or without this line change,

failed to synthesize type class instance for
ι : Type u,
_inst_1 : has_zero ι,
A : ι → Type u,
G : Type u,
_inst_2 : graded_module_components A,
_inst_3 : add_comm_group G,
_inst_4 : ring (A 0),
_inst_5 : module (A 0) G
⊢ semimodule (A 0) (Π₀ (r : ι), A r)


/- TODO: check precedence -/
notation `⟨`:0 g`⟩_`:0 r:100 := has_grade_select.select g r
Expand All @@ -51,7 +55,8 @@ notation `⟨`:0 g`⟩_`:0 r:100 := has_grade_select.select g r
/-- A module divisible into disjoint graded modules, where the grade selectio
operator is a complete and independent set of projections -/
class graded_module
(A : ℤ → Type u) (G: Type u)
{ι : Type v} [has_zero ι]
(A : ι → Type u) (G: Type u)
[graded_module_components A]
[add_comm_group G]
[module (A 0) G]
Expand All @@ -61,42 +66,42 @@ class graded_module


namespace graded_module
variables {A : → Type u} {G: Type u}
variables {ι : Type v} [has_zero ι] {A : ι → Type u} {G: Type u}
variables [graded_module_components A] [add_comm_group G] [module (A 0) G]
variables [graded_module A G]

/-- locally bind the notation above to our A and G-/
local notation `⟨`:0 g`⟩_`:0 r:100 := @has_grade_select.select A G _ _ _ _ g r
local notation `⟨`:0 g`⟩_`:0 r:100 := @has_grade_select.select ι A G _ _ _ _ g r

/-- convert from r-vectors to multi-vectors -/
instance has_coe (r : ) : has_coe (A r) G := { coe := to_fun }
instance has_coe (r : ι) : has_coe (A r) G := { coe := to_fun }

@[simp]
lemma coe_def {r : } (v : A r) : (v : G) = to_fun v := rfl
lemma coe_def {r : ι} (v : A r) : (v : G) = to_fun v := rfl

/-- An r-vector has only a single grade
Discussed at https://leanprover.zulipchat.com/#narrow/stream/113489-new-members/topic/Expressing.20a.20sum.20with.20finitely.20many.20nonzero.20terms/near/202657281-/
lemma select_coe_is_single {r : } (v : A r) : has_grade_select.select (v : G) = dfinsupp.single r v := begin
lemma select_coe_is_single {r : ι} (v : A r) : has_grade_select.select (v : G) = dfinsupp.single r v := begin
symmetry,
rw is_complete (v : G) (dfinsupp.single r v),
symmetry,
apply dfinsupp.sum_single_index,
exact linear_map.map_zero _,
end

def is_r_vector (r : ) (a : G) := (⟨a⟩_r : G) = a
def is_r_vector (r : ι) (a : G) := (⟨a⟩_r : G) = a

/-- Chisholm 6a, ish.
This says A = ⟨A}_r for r-vectors.
Chisholm aditionally wants proof that A != ⟨A}_r for non-rvectors -/
lemma r_grade_of_coe {r : } (v : A r) : ⟨v⟩_r = v := begin
lemma r_grade_of_coe {r : ι} (v : A r) : ⟨v⟩_r = v := begin
rw select_coe_is_single,
rw dfinsupp.single_apply,
simp,
end

/-- to_fun is injective -/
lemma to_fun_inj (r : ) : function.injective (to_fun : A r → G) := begin
lemma to_fun_inj (r : ι) : function.injective (to_fun : A r → G) := begin
intros a b h,
rw ← r_grade_of_coe a,
rw ← r_grade_of_coe b,
Expand All @@ -106,13 +111,13 @@ namespace graded_module
end

/-- Chisholm 6b -/
lemma grade_of_sum (r : ) (a b : G) : ⟨a + b⟩_r = ⟨a⟩_r + ⟨b⟩_r := by simp
lemma grade_of_sum (r : ι) (a b : G) : ⟨a + b⟩_r = ⟨a⟩_r + ⟨b⟩_r := by simp

/-- Chisholm 6c -/
lemma grade_smul (r : ) (k : A 0) (a : G) : ⟨k • a⟩_r = k • ⟨a⟩_r := by simp
lemma grade_smul (r : ι) (k : A 0) (a : G) : ⟨k • a⟩_r = k • ⟨a⟩_r := by simp

/-- chisholm 6d. Modifid to use `_s` instead of `_r` on the right, to keep the statement cast-free -/
lemma grade_grade (r s : ) (a : G) : ⟨⟨a⟩_r⟩_s = if r = s then ⟨a⟩_s else 0
lemma grade_grade (r s : ι) (a : G) : ⟨⟨a⟩_r⟩_s = if r = s then ⟨a⟩_s else 0
:= begin
rw select_coe_is_single,
rw dfinsupp.single_apply,
Expand Down