(* 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                                                     *)
(** Let (X, A, a) be a pointed graph.  The powerset of the set represented by this pointed graph is itself represented by the pointed graph  ((sum X X->Prop), (POWER X A a), (out X X->Prop))  whose edge relation (POWER X A a) : (Rel (sum X X->Prop)) is defined by the following 3 clauses:  1. Delocating A into the powerset:  if (A x' x), then (POWER X A a (inl X X->Prop x') (inl X X->Prop x))  2. Connecting each vertex x':X such that (A x' a) to all the predicates p : X->Prop such that (p x'):  if (A x' a) and (p x'), then (POWER X A a (inl X X->Prop x') (inr X X->Prop p))  3. Connecting all the predicates p : X->Prop to the new root:  (POWER X A a (inr X X->Prop p) (out X X->Prop)).  This relation is impredicatively encoded as follows: *)
Definition POWER (X : Typ1) (A : Rel X) (a : X) (z' z : sum X (X -> Prop)) :=
forall E : Prop,
(forall x x' : X,
eq (sum X (X -> Prop)) z' (inl X (X -> Prop) x') ->
eq (sum X (X -> Prop)) z (inl X (X -> Prop) x) -> A x' x -> E) ->
(forall (x' : X) (p : X -> Prop),
eq (sum X (X -> Prop)) z' (inl X (X -> Prop) x') ->
eq (sum X (X -> Prop)) z (inr X (X -> Prop) p) -> A x' a -> p x' -> E) ->
(forall p : X -> Prop,
eq (sum X (X -> Prop)) z' (inr X (X -> Prop) p) ->
eq (sum X (X -> Prop)) z (out X (X -> Prop)) -> E) -> E.
(** Introduction rules corresponding to the clauses: *)
Proof
fun X A a x x' H E e _ _ =>
e x x' (eq_refl (sum X (X -> Prop)) (inl X (X -> Prop) x'))
(eq_refl (sum X (X -> Prop)) (inl X (X -> Prop) x)) H.

Lemma POWER_in2 :
forall (X : Typ1) (A : Rel X) (a x' : X) (p : X -> Prop),
A x' a -> p x' -> POWER X A a (inl X (X -> Prop) x') (inr X (X -> Prop) p).