(* 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                                                     *)
Section General_Order.
Variable S : Set.
Variable O : S -> S -> Prop.
Variable E : S -> S -> Prop.
(** 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.
End General_Order.
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}.
Section Negation_Order.
Variable S : well_ordering.
Let O := order S.

(* Specifications: *)
Lemma order_lt_le_weak : forall n m : S, O m n -> ~ O n m.