(* 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 :  omit\_facts.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.
Require Export seq_equality_facts.
Require Export sums.
Require Export mult_by_scalars.
destruct n.
simpl in |- *.
red in |- *; auto with algebra.
destruct n.
intros; (apply Trans with (empty_seq M); auto with algebra).
auto with algebra.
Qed.
Hint Resolve omit_head_is_seqtl: algebra.
simple induction n.
intros A v m.
case m.
intros.
apply Trans with (head v;; empty_seq A); auto with algebra.
intros.
inversion H.
inversion H1.
intros.
apply Trans with (head v;; omit (Seqtl v) (Build_finiteT (lt_S_n _ _ HS)));
auto with algebra.
change
(head v;; omit (Seqtl v) (Build_finiteT (lt_S_n m (S (S n0)) HS)) ='
head v;; omit (Seqtl v) (Build_finiteT H0) in seq (S (S n0)) A)
in |- *.
apply cons_comp; auto with algebra.
Qed.
Hint Resolve omit_tlelt: algebra.
(** - The above also holds for seqs of length (S n), but since the types become non-convertible then, we have to do a cast_seq or use seq_equal. *)
destruct n.
intros; inversion_clear Heq.
intros.
apply Trans with (head v;; omit (Seqtl v) (Build_finiteT H));
auto with algebra.
Qed.
Hint Resolve omit_tlelt': algebra.
intros.
apply
seq_equal_trans
with
(pred (S n))
(cast_seq (head v;; omit (Seqtl v) (Build_finiteT H)) Heq);
auto with algebra.
apply Map_eq_seq_equal; auto with algebra.
Qed.
Hint Resolve omit_tlelt'': algebra.
induction n.
intros.
destruct i as [| n].
2: inversion_clear Hi.
2: inversion_clear H.
apply Trans with (Seqtl (v ++ w)); auto with algebra.
apply Trans with (Seqtl v ++ w); auto with algebra.
intros.
destruct i as [| n0].
apply Trans with (Seqtl (v ++ w)); auto with algebra.
apply Trans with (Seqtl v ++ w); auto with algebra.
apply
Trans
with
(head (v ++ w);;
omit (Seqtl (v ++ w)) (Build_finiteT (lt_S_n _ (S (n + m)) Hi')));
auto with algebra.
apply
Trans with ((head v;; omit (Seqtl v) (Build_finiteT (lt_S_n _ _ Hi))) ++ w);
auto with algebra.
apply
Trans
with
(head v;;
omit (Seqtl (v ++ w)) (Build_finiteT (lt_S_n _ (S (n + m)) Hi')));
auto with algebra.
apply
Trans
with (head v;; omit (Seqtl v) (Build_finiteT (lt_S_n n0 (S n) Hi)) ++ w).
2: change
(head v;; omit (Seqtl v) (Build_finiteT (lt_S_n n0 (S n) Hi)) ++ w ='
(head v;; omit (Seqtl v) (Build_finiteT (lt_S_n n0 (S n) Hi))) ++ w
in seq (S (n + m)) A) in |- *.
2: apply cons_concat_special.
change
(head v;; omit (Seqtl (v ++ w)) (Build_finiteT (lt_S_n n0 (S (n + m)) Hi')) ='
head v;; omit (Seqtl v) (Build_finiteT (lt_S_n n0 (S n) Hi)) ++ w
in seq (S (n + m)) A) in |- *.
apply cons_comp; auto with algebra.
apply
Trans with (omit (Seqtl v ++ w) (Build_finiteT (lt_S_n n0 (S (n + m)) Hi'))).
change
(omit (Seqtl (v ++ w)) (Build_finiteT (lt_S_n n0 (S (n + m)) Hi')) ='
omit (Seqtl v ++ w) (Build_finiteT (lt_S_n n0 (S (n + m)) Hi'))
in seq (pred (S (n + m))) A) in |- *.
apply omit_comp; auto with algebra.
change
(omit (Seqtl v ++ w) (Build_finiteT (lt_S_n n0 (S (n + m)) Hi')) ='
omit (Seqtl v) (Build_finiteT (lt_S_n n0 (S n) Hi)) ++ w
in seq (pred (S n + m)) A) in |- *.
apply (IHn m A (Seqtl v) w).
Qed.
Hint Resolve omit_concat_first_part: algebra.
(** - The following also comes in two guises. It is again an equation between two sequences of equal but non-convertible length. The first formulation uses the external (not inherited from any setoid) equality seq_equal, the second does a cast_seq in the appropriate places *)

Lemma omit_concat_second_part' :
forall (n m : Nat) (A : Setoid) (v : seq n A) (w : seq m A)
(i : Nat) (Hi : i < m) (Hi' : n + i < n + m)
(H : n + pred m = pred (n + m)),
seq_equal (omit (v ++ w) (Build_finiteT Hi'))
(v ++ omit w (Build_finiteT Hi)).