(* 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 :  pointwise.v }%*)
Set Implicit Arguments.
Unset Strict Implicit.
Require Export concat.
From Algebra Require Export Cartesian.
(** - The pointwise operation of a binary operator: suppose $f:A\to B, g:A\to C, \circ:B\times C\to D$, then (pointwise $\circ$ f g) = $a\mapsto f(a)\circ g(a): A\to D$. This is used almost solely to define linear combinations: we have a sequence $\vec a$ of scalars and a sequence $\vec v$ of vectors, then (sum (pointwise (mX) a v)) = $\sum_{i=0}^{n-1} a_i v_i$.  %\label{pointwise}% *)
Definition pointwise :
forall (A B C D : Setoid) (op : Map (cart B C) D)
(f : Map A B) (g : Map A C), MAP A D.
intros.
apply (Build_Map (Ap:=fun a : A => op (couple (f a) (g a)))).
red in |- *.
intros.
apply Ap_comp; auto with algebra.
Defined.

(* Specifications: *)
Lemma pointwise_comp_general :
forall (A B C D : Setoid) (op op' : Map (cart B C) D)
(f f' : Map A B) (g g' : Map A C),
op =' op' in MAP _ _ ->
f =' f' in MAP _ _ ->
g =' g' in MAP _ _ -> pointwise op f g =' pointwise op' f' g' in _.