(** * Definition of binary relations, auxiliary results *)
Set Implicit Arguments.
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.
Section Definitions.
Variables X Y Z: Type.
(** 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.
Variable R: relation X.
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.
End Definitions.
Hint Unfold incl.
Section Operators.
Section O.
Variables X Y Z: Type.
Variable Rxy:  relation2 X Y.
Variable Rxy': relation2 X Y.
Variable Ryz:  relation2 Y Z.
(* 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.
End O.
Variable X: Type.
Variable R: relation X.
(** 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.
End Operators.
Hint Unfold trans.
Hint Immediate star_refl.
Section Eeq1.
Variables I X Y Z: Type.
Variable R' R1': relation2 X Y.
Variable S': relation2 Y Z.
Variable R  R1: relation2 X Y.
Variable S : relation2 Y Z.
Variables T' T: relation X.
Variables F' F: I -> relation2 X Y.

Lemma star_eeq: eeq T T' -> eeq (star T) (star T').