(* 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*{ extras :  Inter\_intersection.v }%*)
Set Implicit Arguments.
Unset Strict Implicit.
Require Export arb_intersections.
Require Export conshdtl.
From Algebra Require Export Inter.
(** - A nice lemma relating indexed intersections with binary ones. Remember that 'indexed_intersection' takes a map from some setoid I to the powerset of A, yielding the intersection of the range. As it happens, sequences can be such maps (with I=(fin n)). So suppose we have an n-length sequence of part_sets of A If n=0, its intersection is the full subset of A For n+1, take the binary intersection inter with the n-length intersection*)
Fixpoint repeated_inter (A : Setoid) (n : nat) {struct n} :
seq n (part_set A) -> part_set A :=
match n return (seq n (part_set A) -> part_set A) with
| O => fun v : seq 0 _ => full A
| S n' => fun v : seq (S n') _ => inter (head v) (repeated_inter (Seqtl v))
end.

(* Specifications: *)
Lemma indexed_intersection_as_repeated_inter :
forall (n : nat) (A : Setoid) (f : seq n (part_set A)),
indexed_intersection f =' repeated_inter f in _.