(****************************************************************************)
(*                 The Calculus of Inductive Constructions                  *)
(*                                                                          *)
(*                                Projet Coq                                *)
(*                                                                          *)
(*                     INRIA        LRI-CNRS        ENS-CNRS                *)
(*              Rocquencourt         Orsay          Lyon                    *)
(*                                                                          *)
(*                                 Coq V6.2                                 *)
(*                               May 1st 1998                               *)
(*                                                                          *)
(****************************************************************************)
(*                              Union.v                                     *)
(****************************************************************************)
(*                            Bruno Barras                                  *)
(****************************************************************************)

Require Relation_Operators.
Require Relation_Definitions.
Require Transitive_Closure.

Section WfUnion.
  Variable A: Set.
  Variable R1,R2: (relation A).
  
 Syntactic Definition Union := (union A R1 R2).

 Hint Acc_clos_trans wf_clos_trans.

Remark strip_commut: 
      (commut A R1 R2)->(x,y:A)(clos_trans A R1 y x)->(z:A)(R2 z y)
            ->(EX y':A | (R2 y' x) & (clos_trans A R1 z y')).
Proof.
 Induction 2;Intros.
 (Elim H with y0 x0 z ;Auto;Intros).
 (Exists x1;Auto).

 (Elim H2 with z0 ;Auto;Intros).
 (Elim H4 with x1 ;Auto;Intros).
 (Exists x2;Auto).
 (Apply t_trans with x1 ;Auto).
Save.


  Lemma Acc_union:  (commut A R1 R2)->((x:A)(Acc A R2 x)->(Acc A R1 x))
                         ->(a:A)(Acc A R2 a)->(Acc A Union a).
Proof.
 Induction 3.
 Intros.
 (Apply Acc_intro;Intros).
 (Elim H4;Intros;Auto).
 (Cut (clos_trans A  R1 y x);Auto).
 ElimType (Acc A (clos_trans A R1) y);Intros.
 Apply Acc_intro;Intros.
 Elim H9;Intros.
 (Apply H7;Auto).
 (Apply t_trans with x0 ;Auto).

 (Elim strip_commut with x x0 y0 ;Auto;Intros).
 (Apply Acc_inv_trans with x1 ;Auto).
 Unfold union .
 (Elim H12;Auto;Intros).
 (Apply t_trans with y1 ;Auto).

 Apply (Acc_clos_trans A).
 Apply Acc_inv with x ;Auto.
 Apply H0.
 (Apply Acc_intro;Auto).
Save.


  Theorem wf_union:  (commut A R1 R2)->(well_founded A R1)->(well_founded A R2)
                  ->(well_founded A Union).
Proof.
 Unfold well_founded .
 Intros.
 (Apply Acc_union;Auto).
Save.

End WfUnion.


(* $Id: Union.v,v 1.7 1998/04/30 16:45:55 mohring Exp $ *)
