(** merge_order is the order which is the disjuction of two other orders. *)

Definition is_order :=
  (forall x : S, ~ O x x) /\ (forall x y z : S, O x y -> O y z -> O x z).Definition wf_ind :=
  forall P : S -> Prop,
  (forall q : S, (forall r : S, O r q -> P r) -> P q) -> forall q : S, P q.Definition is_equality :=
  (forall x : S, E x x) /\
  (forall x y : S, E x y -> E y x) /\
  (forall x y z : S, E x y -> E y z -> E x z).(* The well_definedness proof (of the merged order) does not seem to need the totality of the order with respect to the Leibniz equlqity, but rather with respect to an equality which is rewriteable in the order predicates, hence we consign to the following property *)

Definition is_well_def_rht :=
  forall x y : S, O x y -> forall z : S, E y z -> O x z.Definition is_well_def_lft :=
  forall x y : S, O x y -> forall z : S, E x z -> O z y.Record well_ordering : Type := 
  {wfcrr :> Set;
   order : wfcrr -> wfcrr -> Prop;
   equality : wfcrr -> wfcrr -> Prop;
   is_ord : is_order wfcrr order;
   is_eq : is_equality wfcrr equality;
   ord_is_wf : wf_ind wfcrr order;
   ord_wd_rht : is_well_def_rht wfcrr order equality}.Record well_ordering : Type := 
  {wfcrr :> Set;
   order : wfcrr -> wfcrr -> Prop;
   equality : wfcrr -> wfcrr -> Prop;
   is_ord : is_order wfcrr order;
   is_eq : is_equality wfcrr equality;
   ord_is_wf : wf_ind wfcrr order;
   ord_wd_rht : is_well_def_rht wfcrr order equality}.Record well_ordering : Type := 
  {wfcrr :> Set;
   order : wfcrr -> wfcrr -> Prop;
   equality : wfcrr -> wfcrr -> Prop;
   is_ord : is_order wfcrr order;
   is_eq : is_equality wfcrr equality;
   ord_is_wf : wf_ind wfcrr order;
   ord_wd_rht : is_well_def_rht wfcrr order equality}.Record well_ordering : Type := 
  {wfcrr :> Set;
   order : wfcrr -> wfcrr -> Prop;
   equality : wfcrr -> wfcrr -> Prop;
   is_ord : is_order wfcrr order;
   is_eq : is_equality wfcrr equality;
   ord_is_wf : wf_ind wfcrr order;
   ord_wd_rht : is_well_def_rht wfcrr order equality}.Record well_ordering : Type := 
  {wfcrr :> Set;
   order : wfcrr -> wfcrr -> Prop;
   equality : wfcrr -> wfcrr -> Prop;
   is_ord : is_order wfcrr order;
   is_eq : is_equality wfcrr equality;
   ord_is_wf : wf_ind wfcrr order;
   ord_wd_rht : is_well_def_rht wfcrr order equality}.Record well_ordering : Type := 
  {wfcrr :> Set;
   order : wfcrr -> wfcrr -> Prop;
   equality : wfcrr -> wfcrr -> Prop;
   is_ord : is_order wfcrr order;
   is_eq : is_equality wfcrr equality;
   ord_is_wf : wf_ind wfcrr order;
   ord_wd_rht : is_well_def_rht wfcrr order equality}.Record well_ordering : Type := 
  {wfcrr :> Set;
   order : wfcrr -> wfcrr -> Prop;
   equality : wfcrr -> wfcrr -> Prop;
   is_ord : is_order wfcrr order;
   is_eq : is_equality wfcrr equality;
   ord_is_wf : wf_ind wfcrr order;
   ord_wd_rht : is_well_def_rht wfcrr order equality}.Record well_ordering : Type := 
  {wfcrr :> Set;
   order : wfcrr -> wfcrr -> Prop;
   equality : wfcrr -> wfcrr -> Prop;
   is_ord : is_order wfcrr order;
   is_eq : is_equality wfcrr equality;
   ord_is_wf : wf_ind wfcrr order;
   ord_wd_rht : is_well_def_rht wfcrr order equality}.

Lemma order_lt_le_weak : forall n m : S, O m n -> ~ O n m.