(* 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.
intros.
unfold mult_by_scalars in |- *.
auto with algebra.
Qed.
Hint Resolve mult_by_scalars_concat: algebra.

Lemma mult_by_scalars_modify_seq :
forall (F : field) (V : vectorspace F) (n : Nat) (p : seq n F)
(k : seq n V) (i : fin n) (q : F),
mult_by_scalars (modify_seq p i q) k ='
modify_seq (mult_by_scalars p k) i (q mX k i) in seq _ _.