(* This program is free software; you can redistribute it and/or      *)
(* modify it under the terms of the GNU Lesser General Public License *)
(* as published by the Free Software Foundation; either version 2.1   *)
(* of the License, or (at your option) any later version.             *)
(*                                                                    *)
(* This program is distributed in the hope that it will be useful,    *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of     *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      *)
(* GNU General Public License for more details.                       *)
(*                                                                    *)
(* You should have received a copy of the GNU Lesser General Public   *)
(* License along with this program; if not, write to the Free         *)
(* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *)
(* 02110-1301 USA                                                     *)
(** %\subsection*{ support :  mult\_by\_scalars.v }%*)
Set Implicit Arguments.
Unset Strict Implicit.
From Algebra Require Field_facts.
Export Sets Categories Parts Sgroup_cat Monoid_cat Group_cat Abelian_group_cat Ring_cat.
Export Field_facts.
From Algebra Require Ring_facts.
Export Ring_facts.
From Algebra Require Export Field_cat.
(** - mult_by_scalars is just an abbreviation for the special case of pointwise, where the operation is scalar multiplication. *)
(* That is to say: it takes two sequences of length N: one sequence v1...vN of *)
(* vectors and one sequence a1...aN of scalars. It returns the sequence of each vector *)
(* multiplied by its respective scalar; ie. a1*v1...aN*vN *)
Require Export pointwise.
Require Export modify_seq.
Require Export vecspaces_verybasic.
(** %\label{multbyscalars}% *)
Definition mult_by_scalars (R : ring) (V : module R)
(N : Nat) (a : Map (fin N) R) (v : Map (fin N) V) :
MAP (fin N) V := pointwise (uncurry (MODULE_comp (Mod:=V))) a v.
intros.
unfold mult_by_scalars in |- *.
apply (pointwise_comp_general (A:=fin N) (B:=R) (C:=V) (D:=V));
auto with algebra.
Qed.
exact mult_by_scalars_comp.
Qed.
Hint Resolve mult_by_scalars_fun2_compatible mult_by_scalars_comp: algebra.
intros.
unfold mult_by_scalars in |- *.
apply Sym; auto with algebra.
Qed.
Hint Resolve mult_by_scalars_Seqtl: algebra.

Lemma mult_by_scalars_concat :
forall (R : ring) (V : module R) (N M : Nat) (a : Map (fin N) R)
(b : Map (fin M) R) (v : Map (fin N) V) (w : Map (fin M) V),
mult_by_scalars (a ++ b) (v ++ w) ='
mult_by_scalars a v ++ mult_by_scalars b w in _.