(* 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                                                     *)
(** * spans.v *)
Set Implicit Arguments.
Unset Strict Implicit.
(** - Spans can be defined in two ways: (1) the span of a subset $S\subset V$ is the subspace of all linear combinations of $S$ or (2) it is the set defined inductively by -- $0\in span(S)$ -- $v\in S\to v\in span(S)$ -- $v,v'\in S\to v+v'\in span(S)$ -- $v\in S, c\in F\to cv\in span(S)$  These definitions are proved equivalent. Notice how we must first define the formal expressions for these vectors and then inject them into the final set.  Also $span(S)$ is the smallest subspace containing $S$ and some other easy lemmas *)
Require Export lin_combinations.
Require Export subspaces.
Section spans.
Variable F : field.
Variable V : vectorspace F.
Definition span_set (S : part_set V) : part_set V := is_lin_comb_pred S.
(** %\tocdef{span}% *)
Definition span : part_set V -> subspace V.
intro S.
apply alt_Build_subspace with (span_set S).
red in |- *; split; try split.
simpl in |- *.
red in |- *.
exists 0.
exists (empty_seq F).
exists (empty_seq S).
simpl in |- *.
auto with algebra.
intros; simpl in H, H0; simpl in |- *; red in H, H0; red in |- *.
inversion_clear H; inversion_clear H0; inversion_clear H; inversion_clear H1;
inversion_clear H0; inversion_clear H.
exists (x0 + x1).
exists (x3 ++ x2).
exists (x5 ++ x4).
apply
Trans
with
(sum (mult_by_scalars x3 (Map_embed x5)) +'
sum (mult_by_scalars x2 (Map_embed x4))); auto with algebra.
apply
Trans
with
(sum
(mult_by_scalars x3 (Map_embed x5) ++
mult_by_scalars x2 (Map_embed x4))); auto with algebra.
apply
Trans with (sum (mult_by_scalars (x3 ++ x2) (Map_embed x5 ++ Map_embed x4)));
auto with algebra.
intros.
red in |- *; red in H.
simpl in |- *; simpl in H.
red in |- *; red in H.
inversion_clear H; inversion_clear H0; inversion_clear H.
exists x0;
exists (pointwise (uncurry (RING_comp (R:=F))) (const_seq x0 c) x1);
exists x2.
apply
Trans
with
(sum
(mult_by_scalars (const_seq x0 c) (mult_by_scalars x1 (Map_embed x2))));
auto with algebra.
apply Trans with (c mX sum (mult_by_scalars x1 (Map_embed x2)));
auto with algebra.
Defined.

(* Specifications: *)
Lemma span_comp :
forall S S' : part_set V, S =' S' in _ -> span S =' span S' in part_set V.