File: Mathlib/Algebra/DirectSum/Decomposition.lean

full_name: DirectSum.Decomposition
code: /-- A decomposition is an equivalence between an additive monoid `M` and a direct sum of additive
submonoids `ℳ i` of that `M`, such that the "recomposition" is canonical. This definition also
works for additive groups and modules.

This is a version of `DirectSum.IsInternal` which comes with a constructive inverse to the
canonical "recomposition" rather than just a proof that the "recomposition" is bijective.

Often it is easier to construct a term of this type via `Decomposition.ofAddHom` or
`Decomposition.ofLinearMap`. -/
class Decomposition where
  decompose' : M → ⨁ i, ℳ i
  left_inv : Function.LeftInverse (DirectSum.coeAddMonoidHom ℳ) decompose'
  right_inv : Function.RightInverse (DirectSum.coeAddMonoidHom ℳ) decompose'
goal: Type (max u_1 u_3)

full_name: DirectSum.Decomposition.decompose'
code: /-- A decomposition is an equivalence between an additive monoid `M` and a direct sum of additive
submonoids `ℳ i` of that `M`, such that the "recomposition" is canonical. This definition also
works for additive groups and modules.

This is a version of `DirectSum.IsInternal` which comes with a constructive inverse to the
canonical "recomposition" rather than just a proof that the "recomposition" is bijective.

Often it is easier to construct a term of this type via `Decomposition.ofAddHom` or
`Decomposition.ofLinearMap`. -/
class Decomposition where
  decompose' : M → ⨁ i, ℳ i
  left_inv : Function.LeftInverse (DirectSum.coeAddMonoidHom ℳ) decompose'
  right_inv : Function.RightInverse (DirectSum.coeAddMonoidHom ℳ) decompose'
goal: M → ⨁ (i : ι), ↥(ℳ i)

full_name: DirectSum.Decomposition.left_inv
code: /-- A decomposition is an equivalence between an additive monoid `M` and a direct sum of additive
submonoids `ℳ i` of that `M`, such that the "recomposition" is canonical. This definition also
works for additive groups and modules.

This is a version of `DirectSum.IsInternal` which comes with a constructive inverse to the
canonical "recomposition" rather than just a proof that the "recomposition" is bijective.

Often it is easier to construct a term of this type via `Decomposition.ofAddHom` or
`Decomposition.ofLinearMap`. -/
class Decomposition where
  decompose' : M → ⨁ i, ℳ i
  left_inv : Function.LeftInverse (DirectSum.coeAddMonoidHom ℳ) decompose'
  right_inv : Function.RightInverse (DirectSum.coeAddMonoidHom ℳ) decompose'
goal: Function.LeftInverse (⇑(DirectSum.coeAddMonoidHom ℳ)) DirectSum.Decomposition.decompose'

full_name: DirectSum.Decomposition.right_inv
code: /-- A decomposition is an equivalence between an additive monoid `M` and a direct sum of additive
submonoids `ℳ i` of that `M`, such that the "recomposition" is canonical. This definition also
works for additive groups and modules.

This is a version of `DirectSum.IsInternal` which comes with a constructive inverse to the
canonical "recomposition" rather than just a proof that the "recomposition" is bijective.

Often it is easier to construct a term of this type via `Decomposition.ofAddHom` or
`Decomposition.ofLinearMap`. -/
class Decomposition where
  decompose' : M → ⨁ i, ℳ i
  left_inv : Function.LeftInverse (DirectSum.coeAddMonoidHom ℳ) decompose'
  right_inv : Function.RightInverse (DirectSum.coeAddMonoidHom ℳ) decompose'
goal: Function.RightInverse (⇑(DirectSum.coeAddMonoidHom ℳ)) DirectSum.Decomposition.decompose'

full_name: DirectSum.instSubsingletonDecomposition
code: /-- `DirectSum.Decomposition` instances, while carrying data, are always equal. -/
instance : Subsingleton (Decomposition ℳ) 
goal: Subsingleton (DirectSum.Decomposition ℳ)

full_name: DirectSum.Decomposition.ofAddHom
code: /-- A convenience method to construct a decomposition from an `AddMonoidHom`, such that the proofs
of left and right inverse can be constructed via `ext`. -/
abbrev Decomposition.ofAddHom (decompose : M →+ ⨁ i, ℳ i)
    (h_left_inv : (DirectSum.coeAddMonoidHom ℳ).comp decompose = .id _)
    (h_right_inv : decompose.comp (DirectSum.coeAddMonoidHom ℳ) = .id _) : Decomposition ℳ 
goal: DirectSum.Decomposition ℳ

full_name: DirectSum.IsInternal.chooseDecomposition
code: /-- Noncomputably conjure a decomposition instance from a `DirectSum.IsInternal` proof. -/
noncomputable def IsInternal.chooseDecomposition (h : IsInternal ℳ) :
    DirectSum.Decomposition ℳ 
goal: DirectSum.Decomposition ℳ

full_name: DirectSum.Decomposition.isInternal
code: protected theorem Decomposition.isInternal : DirectSum.IsInternal ℳ 
goal: DirectSum.IsInternal ℳ

full_name: DirectSum.decompose
code: /-- If `M` is graded by `ι` with degree `i` component `ℳ i`, then it is isomorphic as
to a direct sum of components. This is the canonical spelling of the `decompose'` field. -/
def decompose : M ≃ ⨁ i, ℳ i 
goal: M ≃ ⨁ (i : ι), ↥(ℳ i)

full_name: DirectSum.Decomposition.inductionOn
code: protected theorem Decomposition.inductionOn {p : M → Prop} (h_zero : p 0)
    (h_homogeneous : ∀ {i} (m : ℳ i), p (m : M)) (h_add : ∀ m m' : M, p m → p m' → p (m + m')) :
    ∀ m, p m 
goal: p m

full_name: DirectSum.Decomposition.decompose'_eq
code: @[simp]
theorem Decomposition.decompose'_eq : Decomposition.decompose' = decompose ℳ 
goal: DirectSum.Decomposition.decompose' = ⇑(DirectSum.decompose ℳ)

full_name: DirectSum.decompose_symm_of
code: @[simp]
theorem decompose_symm_of {i : ι} (x : ℳ i) : (decompose ℳ).symm (DirectSum.of _ i x) = x 
goal: (DirectSum.decompose ℳ).symm ((DirectSum.of (fun i => ↥(ℳ i)) i) x) = ↑x

full_name: DirectSum.decompose_coe
code: @[simp]
theorem decompose_coe {i : ι} (x : ℳ i) : decompose ℳ (x : M) = DirectSum.of _ i x 
goal: (DirectSum.decompose ℳ) ↑x = (DirectSum.of (fun i => ↥(ℳ i)) i) x

full_name: DirectSum.decompose_of_mem
code: theorem decompose_of_mem {x : M} {i : ι} (hx : x ∈ ℳ i) :
    decompose ℳ x = DirectSum.of (fun i ↦ ℳ i) i ⟨x, hx⟩ 
goal: (DirectSum.decompose ℳ) x = (DirectSum.of (fun i => ↥(ℳ i)) i) ⟨x, hx⟩

full_name: DirectSum.decompose_of_mem_same
code: theorem decompose_of_mem_same {x : M} {i : ι} (hx : x ∈ ℳ i) : (decompose ℳ x i : M) = x 
goal: ↑(((DirectSum.decompose ℳ) x) i) = x

full_name: DirectSum.decompose_of_mem_ne
code: theorem decompose_of_mem_ne {x : M} {i j : ι} (hx : x ∈ ℳ i) (hij : i ≠ j) :
    (decompose ℳ x j : M) = 0 
goal: ↑(((DirectSum.decompose ℳ) x) j) = 0

full_name: DirectSum.degree_eq_of_mem_mem
code: theorem degree_eq_of_mem_mem {x : M} {i j : ι} (hxi : x ∈ ℳ i) (hxj : x ∈ ℳ j) (hx : x ≠ 0) :
    i = j 
goal: i = j

full_name: DirectSum.decomposeAddEquiv
code: /-- If `M` is graded by `ι` with degree `i` component `ℳ i`, then it is isomorphic as
an additive monoid to a direct sum of components. -/
-- Porting note: deleted [simps] and added the corresponding lemmas by hand
def decomposeAddEquiv : M ≃+ ⨁ i, ℳ i 
goal: M ≃+ ⨁ (i : ι), ↥(ℳ i)

full_name: DirectSum.decomposeAddEquiv_apply
code: @[simp]
lemma decomposeAddEquiv_apply (a : M) :
    decomposeAddEquiv ℳ a = decompose ℳ a 
goal: (DirectSum.decomposeAddEquiv ℳ) a = (DirectSum.decompose ℳ) a

full_name: DirectSum.decomposeAddEquiv_symm_apply
code: @[simp]
lemma decomposeAddEquiv_symm_apply (a : ⨁ i, ℳ i) :
    (decomposeAddEquiv ℳ).symm a = (decompose ℳ).symm a 
goal: (DirectSum.decomposeAddEquiv ℳ).symm a = (DirectSum.decompose ℳ).symm a

full_name: DirectSum.decompose_zero
code: @[simp]
theorem decompose_zero : decompose ℳ (0 : M) = 0 
goal: (DirectSum.decompose ℳ) 0 = 0

full_name: DirectSum.decompose_symm_zero
code: @[simp]
theorem decompose_symm_zero : (decompose ℳ).symm 0 = (0 : M) 
goal: (DirectSum.decompose ℳ).symm 0 = 0

full_name: DirectSum.decompose_add
code: @[simp]
theorem decompose_add (x y : M) : decompose ℳ (x + y) = decompose ℳ x + decompose ℳ y 
goal: (DirectSum.decompose ℳ) (x + y) = (DirectSum.decompose ℳ) x + (DirectSum.decompose ℳ) y

full_name: DirectSum.decompose_symm_add
code: @[simp]
theorem decompose_symm_add (x y : ⨁ i, ℳ i) :
    (decompose ℳ).symm (x + y) = (decompose ℳ).symm x + (decompose ℳ).symm y 
goal: (DirectSum.decompose ℳ).symm (x + y) = (DirectSum.decompose ℳ).symm x + (DirectSum.decompose ℳ).symm y

full_name: DirectSum.decompose_sum
code: @[simp]
theorem decompose_sum {ι'} (s : Finset ι') (f : ι' → M) :
    decompose ℳ (∑ i ∈ s, f i) = ∑ i ∈ s, decompose ℳ (f i) 
goal: (DirectSum.decompose ℳ) (∑ i ∈ s, f i) = ∑ i ∈ s, (DirectSum.decompose ℳ) (f i)

full_name: DirectSum.decompose_symm_sum
code: @[simp]
theorem decompose_symm_sum {ι'} (s : Finset ι') (f : ι' → ⨁ i, ℳ i) :
    (decompose ℳ).symm (∑ i ∈ s, f i) = ∑ i ∈ s, (decompose ℳ).symm (f i) 
goal: (DirectSum.decompose ℳ).symm (∑ i ∈ s, f i) = ∑ i ∈ s, (DirectSum.decompose ℳ).symm (f i)

full_name: DirectSum.sum_support_decompose
code: theorem sum_support_decompose [∀ (i) (x : ℳ i), Decidable (x ≠ 0)] (r : M) :
    (∑ i ∈ (decompose ℳ r).support, (decompose ℳ r i : M)) = r 
goal: ∑ i ∈ DFinsupp.support ((DirectSum.decompose ℳ) r), ↑(((DirectSum.decompose ℳ) r) i) = r

full_name: DirectSum.addCommGroupSetLike
code: /-- The `-` in the statements below doesn't resolve without this line.

This seems to be a problem of synthesized vs inferred typeclasses disagreeing. If we replace
the statement of `decompose_neg` with `@Eq (⨁ i, ℳ i) (decompose ℳ (-x)) (-decompose ℳ x)`
instead of `decompose ℳ (-x) = -decompose ℳ x`, which forces the typeclasses needed by `⨁ i, ℳ i`
to be found by unification rather than synthesis, then everything works fine without this
instance. -/
instance addCommGroupSetLike [AddCommGroup M] [SetLike σ M] [AddSubgroupClass σ M] (ℳ : ι → σ) :
    AddCommGroup (⨁ i, ℳ i) 
goal: AddCommGroup (⨁ (i : ι), ↥(ℳ i))

full_name: DirectSum.decompose_neg
code: @[simp]
theorem decompose_neg (x : M) : decompose ℳ (-x) = -decompose ℳ x 
goal: (DirectSum.decompose ℳ) (-x) = -(DirectSum.decompose ℳ) x

full_name: DirectSum.decompose_symm_neg
code: @[simp]
theorem decompose_symm_neg (x : ⨁ i, ℳ i) : (decompose ℳ).symm (-x) = -(decompose ℳ).symm x 
goal: (DirectSum.decompose ℳ).symm (-x) = -(DirectSum.decompose ℳ).symm x

full_name: DirectSum.decompose_sub
code: @[simp]
theorem decompose_sub (x y : M) : decompose ℳ (x - y) = decompose ℳ x - decompose ℳ y 
goal: (DirectSum.decompose ℳ) (x - y) = (DirectSum.decompose ℳ) x - (DirectSum.decompose ℳ) y

full_name: DirectSum.decompose_symm_sub
code: @[simp]
theorem decompose_symm_sub (x y : ⨁ i, ℳ i) :
    (decompose ℳ).symm (x - y) = (decompose ℳ).symm x - (decompose ℳ).symm y 
goal: (DirectSum.decompose ℳ).symm (x - y) = (DirectSum.decompose ℳ).symm x - (DirectSum.decompose ℳ).symm y

full_name: DirectSum.Decomposition.ofLinearMap
code: /-- A convenience method to construct a decomposition from an `LinearMap`, such that the proofs
of left and right inverse can be constructed via `ext`. -/
abbrev Decomposition.ofLinearMap (decompose : M →ₗ[R] ⨁ i, ℳ i)
    (h_left_inv : DirectSum.coeLinearMap ℳ ∘ₗ decompose = .id)
    (h_right_inv : decompose ∘ₗ DirectSum.coeLinearMap ℳ = .id) : Decomposition ℳ 
goal: DirectSum.Decomposition ℳ

full_name: DirectSum.decomposeLinearEquiv
code: /-- If `M` is graded by `ι` with degree `i` component `ℳ i`, then it is isomorphic as
a module to a direct sum of components. -/
def decomposeLinearEquiv : M ≃ₗ[R] ⨁ i, ℳ i 
goal: M ≃ₗ[R] ⨁ (i : ι), ↥(ℳ i)

full_name: DirectSum.decomposeLinearEquiv_apply
code: @[simp] theorem decomposeLinearEquiv_apply (m : M) :
    decomposeLinearEquiv ℳ m = decompose ℳ m 
goal: (DirectSum.decomposeLinearEquiv ℳ) m = (DirectSum.decompose ℳ) m

full_name: DirectSum.decomposeLinearEquiv_symm_apply
code: @[simp] theorem decomposeLinearEquiv_symm_apply (m : ⨁ i, ℳ i) :
    (decomposeLinearEquiv ℳ).symm m = (decompose ℳ).symm m 
goal: (DirectSum.decomposeLinearEquiv ℳ).symm m = (DirectSum.decompose ℳ).symm m

full_name: DirectSum.decompose_smul
code: @[simp]
theorem decompose_smul (r : R) (x : M) : decompose ℳ (r • x) = r • decompose ℳ x 
goal: (DirectSum.decompose ℳ) (r • x) = r • (DirectSum.decompose ℳ) x

full_name: DirectSum.decomposeLinearEquiv_symm_comp_lof
code: @[simp] theorem decomposeLinearEquiv_symm_comp_lof (i : ι) :
    (decomposeLinearEquiv ℳ).symm ∘ₗ lof R ι (ℳ ·) i = (ℳ i).subtype 
goal: ↑(DirectSum.decomposeLinearEquiv ℳ).symm ∘ₗ DirectSum.lof R ι (fun x => ↥(ℳ x)) i = (ℳ i).subtype

full_name: DirectSum.decompose_lhom_ext
code: /-- Two linear maps from a module with a decomposition agree if they agree on every piece.

Note this cannot be `@[ext]` as `ℳ` cannot be inferred. -/
theorem decompose_lhom_ext {N} [AddCommMonoid N] [Module R N] ⦃f g : M →ₗ[R] N⦄
    (h : ∀ i, f ∘ₗ (ℳ i).subtype = g ∘ₗ (ℳ i).subtype) : f = g 
goal: f = g