(* 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                                                     *)
(* Contribution to the Coq Library   V6.3 (July 1999)                    *)
(****************************************************************************)
(*                 The Calculus of Inductive Constructions                  *)
(*                                                                          *)
(*                                Projet Coq                                *)
(*                                                                          *)
(*                     INRIA                        ENS-CNRS                *)
(*              Rocquencourt                        Lyon                    *)
(*                                                                          *)
(*                                Coq V5.10                                 *)
(*                              Nov 25th 1994                               *)
(*                                                                          *)
(****************************************************************************)
(****************************************************************************)
(*                                  Cube.v                                  *)
(*                                                                          *)
(*                                Gerard Huet                               *)
(*                                                                          *)
(* Developed in V5.8  January 1993                                          *)
(* Ported    to V5.10 January 1995                                          *)
(****************************************************************************)
(*****************)
(* Prism Theorem *)
(*****************)
(* Auxiliary notion : compat Used to generate the right simultaneous induction on U, V and W *)
(* (compat U V W) iff U,V,W are compatible markings, and (sub V U) *)
Inductive compat : redexes -> redexes -> redexes -> Prop :=
| Compat_Var : forall n : nat, compat (Var n) (Var n) (Var n)
| Compat_Fun :
forall U V W : redexes, compat U V W -> compat (Fun U) (Fun V) (Fun W)
| Compat_Ap1 :
forall U1 V1 W1 : redexes,
compat U1 V1 W1 ->
forall U2 V2 W2 : redexes,
compat U2 V2 W2 ->
forall b : bool, compat (Ap false U1 U2) (Ap false V1 V2) (Ap b W1 W2)
| Compat_Ap2 :
forall U1 V1 W1 : redexes,
compat U1 V1 W1 ->
forall U2 V2 W2 : redexes,
compat U2 V2 W2 ->
forall b b' : bool,
compat (Ap true (Fun U1) U2) (Ap b (Fun V1) V2) (Ap b' (Fun W1) W2).
(* Remark - It should be possible to get rid of auxiliary compat and to combine prism0 with compat_intro in one lemma *)
(*****************************************************************)
(* Theorem prism : (U,V,W:redexes)(sub V U) ->                   *)
(*     (UV:redexes)(residuals U V UV) ->                         *)
(*     (WV:redexes)(residuals W V WV) ->                         *)
(*     (WU:redexes)(residuals W U WU) <-> (residuals WV UV WU).  *)
(*****************************************************************)

Theorem prism :
forall U V W : redexes,
sub V U ->
forall UV : redexes,
residuals U V UV ->
forall WV : redexes,
residuals W V WV ->
forall WU : redexes, residuals W U WU <-> regular U /\ residuals WV UV WU.