Ltac cgen  H := generalize H; clear H.Ltac celim H := elim H; clear H.(** A binary relation is a predicate over pairs of processes *)
Definition relation2(X Y: Type) := X -> Y -> Prop.Definition relation (X: Type) := relation2 X X.Definition set(X: Type) := X -> Prop.(** Inclusion *)
  Definition incl: relation (relation2 X Y) := fun R1 R2 => forall x y, R1 x y -> R2 x y.(** Extensional equality *)
  Definition eeq: relation (relation2 X Y) := fun R1 R2 => incl R1 R2 /\ incl R2 R1.Definition reflexive     := forall x, R x x.Definition transitive    := forall y x z, R x y -> R y z -> R x z.Definition symmetric     := forall x y, R x y -> R y x.Definition antisymmetric := forall x y, R x y -> R y x -> x=y.(* begin hide *)
    Definition eta2: relation2 X Y := fun x y => Rxy x y.(* end hide *)

    (** Transposition, composition, union, union `such that' *)
    Definition trans:  relation2 Y X := fun y x => Rxy x y.Definition comp:   relation2 X Z := fun x z => exists2 y, Rxy x y & Ryz y z.Definition union2: relation2 X Y := fun x y => Rxy x y \/ Rxy' x y.Definition union (I: Type) R: relation2 X Y := fun x y => exists i: I, R i x y.Definition union_st (P: set (relation2 X Y)) := fun x y => exists2 R, P R & R x y.(** Reflexive, transitive closure *) 
  Inductive star: relation X := 
    | star_refl: forall x, star x x
    | S_star: forall y x z, R x y -> star y z -> star x z.(** Reflexive, transitive closure *) 
  Inductive star: relation X := 
    | star_refl: forall x, star x x
    | S_star: forall y x z, R x y -> star y z -> star x z.(** Reflexive, transitive closure *) 
  Inductive star: relation X := 
    | star_refl: forall x, star x x
    | S_star: forall y x z, R x y -> star y z -> star x z.(** Transitive closure *) 
  Definition plus: relation X := comp R star.

(* Specifications: *)
Lemma trans_incl: incl R R' -> incl (trans R) (trans R').
Lemma trans_eeq: eeq R R' -> eeq (trans R) (trans R').
Lemma comp_incl: incl R R' -> incl S S' -> incl (comp R S) (comp R' S').
Lemma comp_eeq: eeq R R' -> eeq S S' -> eeq (comp R S) (comp R' S').
Lemma union_incl: (forall i, incl (F i) (F' i)) -> incl (union F) (union F').
Lemma union_eeq: (forall i, eeq (F i) (F' i)) -> eeq (union F) (union F').
Lemma union2_incl: incl R R' -> incl R1 R1' -> incl (union2 R R1) (union2 R' R1').
Lemma union2_eeq: eeq R R' -> eeq R1 R1' -> eeq (union2 R R1) (union2 R' R1').
Lemma star_incl: incl T T' -> incl (star T) (star T').
Lemma star_eeq: eeq T T' -> eeq (star T) (star T').
Lemma plus_incl: incl T T' -> incl (plus T) (plus T').
Lemma plus_eeq: eeq T T' -> eeq (plus T) (plus T').
Lemma incl_refl: incl R R.
Lemma incl_trans: incl R S -> incl S T -> incl R T.
Lemma eeq_refl: eeq R R.
Lemma eeq_trans: eeq R S -> eeq S T -> eeq R T.
Lemma eeq_sym: eeq R S -> eeq S R.
Lemma star1: forall x y, R x y -> star R x y.
Lemma star_S: forall x y z, star R x y -> R y z -> star R x z.
Lemma star_trans: forall x y z, star R x y -> star R y z -> star R x z.
Lemma plus_star: forall x y, plus R x y -> star R x y.
Lemma plus_star_plus: forall y x z, plus R x y -> star R y z -> plus R x z.
Lemma star_plus_plus: forall y x z, star R x y -> plus R y z -> plus R x z.
Lemma plus_trans: forall y x z, plus R x y -> plus R y z -> plus R x z.
Lemma plus1: forall x y, R x y -> plus R x y.
Lemma plus_S: forall y x z, star R x y -> R y z -> plus R x z.
Lemma S_plus: forall y x z, R x y -> star R y z -> plus R x z.