(* 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 :  arb\_intersections.v }%*)
(** - This stuff could be put in the algebra contribution as well. We define indexed intersections $\bigcap_{i\in I} X_i$ whenever all $X_i\subset X$, and arbitrary intersections $\bigcap_{X\in P}X$ for $P\subset{\cal P}(A)$. - Suppose we have a collection of subsets $A_i$ of a setoid $A$, indexed by some index set $I$. Then we may define the intersection $\bigcap_{i\in I} A_i \subset A$ as $\{a\in A | \forall i\in I.a\in A_i\}$ *)
Set Implicit Arguments.
Unset Strict Implicit.
From Algebra Require Export Parts2.
Require Export Classical_Pred_Type.
Section MAIN.
Section indexed_int.
Variable A : Setoid.
Variable I : Setoid.
Variable f : MAP I (part_set A). (* Picks A_i for i\in I *)
(** - so, given an index set $I$ and an indexing function $f$ mapping this set to the part_set (powerset) of X,  (ie. $f(i) = A_i\ (\in (part\_set A))$,) then (indexed_intersection f) will be $\bigcap_{i\in I} A_i$. *)
Definition indexed_intersection : part_set A.
simpl in |- *.
apply
(Build_Predicate (Pred_fun:=fun a : A => forall i : I, in_part a (f i))).
red in |- *.
intros.
apply in_part_comp_l with x.
apply H.
assumption.
Defined.

(* Note that as we used "Variable"s, in this section we can write *)
(* "indexed_intersection" instead of (indexed_intersection f). *)
(* The following Lemma then states that \forall i \in I: intersection \subseteq A_i *)
Lemma indexed_intersection_included_in_subsets :
forall i : I, included indexed_intersection (f i).