(* 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.
intros.
intro.
unfold pointwise in |- *.
simpl in |- *.
apply Ap_comp; auto with algebra.
Qed.
intros.
apply (pointwise_comp_general H H0 H1).
Qed.
Hint Resolve pointwise_comp: algebra.
intros.
unfold pointwise in |- *.
simpl in |- *.
apply Refl.
Qed.
Hint Resolve pointwise_hd: algebra.
intros.
apply split_hd_tl_equality; auto with algebra.
Qed.
Hint Resolve pointwise_cons: algebra.
intros.
apply split_hd_tl_equality; auto with algebra.
unfold pointwise in |- *; intro; simpl in |- *.
destruct x; (apply Ap_comp; auto with algebra).
Qed.
Hint Resolve pointwise_hd_tl: algebra.

Lemma pointwise_Seqtl :
forall (A B C : Setoid) (n : Nat) (v : seq n A) (w : seq n B)
(op : Map (cart A B) C),
pointwise op (Seqtl v) (Seqtl w) =' Seqtl (pointwise op v w) in seq _ _.