Module SubType.
Section Zmodule.
Variables (V : zmodType) (S : predPredType V).
Variables (subS : zmodPred S) (kS : keyed_pred subS).
Variable U : subType (mem kS).
Let inU v Sv : U := Sub v Sv.
Let zeroU := inU (rpred0 kS).
Let oppU (u : U) := inU (rpredNr (valP u)).
Let addU (u1 u2 : U) := inU (rpredD (valP u1) (valP u2)).
Fact addA : associative addU.
Fact mulA : @associative T' mulT.
Definition ringMixin := RingMixin mulA mul1l mul1r mulDl mulDr nz1.
End Ring.
Section Lmodule.
Variables (R : ringType) (V : lmodType R) (S : predPredType V).
Variables (linS : submodPred S) (kS : keyed_pred linS).
Variables (W : subType (mem kS)) (Z : zmodType) (ZeqW : Z = W :> Type).
Let scaleW a (w : W) := (Sub _ : _ -> W) (rpredZ a (valP w)).
Let W' := cast_zmodType ZeqW.
Hypothesis valD : {morph (val : W' -> V) : x y / x + y}.
Fact scaleA a b (w : W') : scaleW a (scaleW b w) = scaleW (a * b) w.

Lemma comRingMixin (R : comRingType) (T : ringType) (f : T -> R) :
phant T -> injective f -> {morph f : x y / x * y} -> commutative (@mul T).