(* 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                                                     *)
Definition PRED := forall X : Typ1, Rel X -> X -> Prop.
Definition Compat (P : PRED) : Prop :=
forall (X : Typ1) (A : Rel X) (a : X) (Y : Typ1) (B : Rel Y) (b : Y),
EQV X A a Y B b -> P X A a -> P Y B b.
Definition SELECT (X : Typ1) (A : Rel X) (a : X) (P : PRED) :
Rel (opt X) :=
fun z' z : opt X =>
forall E : Prop,
(forall x x' : X,
eq (opt X) z (some X x) -> eq (opt X) z' (some X x') -> A x' x -> E) ->
(forall x' : X,
eq (opt X) z' (some X x') ->
eq (opt X) z (none X) -> A x' a -> P X A x' -> E) -> E.

Lemma SELECT_in :
forall (X : Typ1) (A : Rel X) (a : X) (P : PRED) (x x' : X),
A x' x -> SELECT X A a P (some X x') (some X x).