(* 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                                                     *)
(** * lin_comb_facts.v *)
Set Implicit Arguments.
Unset Strict Implicit.
Require Export algebraic_span_facts.
Require Export seq_set_seq.
(** - Miscellaneous facts about linear combinations:  - Suppose $x$ is a linear combination of $W$, and all $w\in W$ are linear combinations of $W'$, then $x$ is a linear combination of $W'$ *)
intros.
change (in_part x (span W')) in |- *.
elim (span_idempotent W' x).
intros.
apply H2; auto with algebra; clear H1 H2.
simpl in |- *.
assert (forall w : W, in_part (subtype_elt w) (span_set W')).
auto.
clear H0.
inversion_clear H.
inversion_clear H0.
inversion_clear H.
red in |- *.
exists x0.
exists x1.
assert (forall i : fin x0, in_part (Map_embed x2 i) (span_set W')).
intro i.
change (in_part (subtype_elt (x2 i)) (span_set W')) in |- *.
auto.
exists (cast_map_to_subset H).
apply Trans with (sum (mult_by_scalars x1 (Map_embed x2))); auto with algebra.
Qed.
(** - If all $w\in W$ are linear combinations of $W'$ then $span(W)\subset span(W')$ *)

Lemma span_casting :
forall (F : field) (V : vectorspace F) (W W' : part_set V),
(forall w : W, is_lin_comb (subtype_elt w) W') ->
included (span W) (span W').