Built with Alectryon, running Coq+SerAPI v8.10.0+0.7.0. Coq sources are in this panel; goals and messages will appear in the other. Bubbles () indicate interactive fragments: hover for details, tap to reveal contents. Use Ctrl+↑ Ctrl+↓ to navigate, Ctrl+🖱️ to focus.
(************************************************************************) (* * The Coq Proof Assistant / The Coq Development Team *) (* v * INRIA, CNRS and contributors - Copyright 1999-2018 *) (* <O___,, * (see CREDITS file for the list of authors) *) (* \VV/ **************************************************************) (* // * This file is distributed under the terms of the *) (* * GNU Lesser General Public License Version 2.1 *) (* * (see LICENSE file for the text of the license) *) (************************************************************************) Require Import Rbase Equalities Orders OrdersTac. Local Open Scope R_scope.
forall r1 r2 : R, {r1 = r2} + {r1 <> r2}intros; generalize (total_order_T r1 r2) Rlt_dichotomy_converse; intuition eauto. Qed. Definition Reqb r1 r2 := if Req_dec r1 r2 then true else false.forall r1 r2 : R, {r1 = r2} + {r1 <> r2}forall r1 r2 : R, Reqb r1 r2 = true <-> r1 = r2forall r1 r2 : R, Reqb r1 r2 = true <-> r1 = r2r1, r2:RNEQ:r1 <> r2false = true <-> r1 = r2intro EQ; elim NEQ; auto. Qed. Module R_as_UBE <: UsualBoolEq. Definition t := R. Definition eq := @eq R. Definition eqb := Reqb. Definition eqb_eq := Reqb_eq. End R_as_UBE. Module R_as_DT <: UsualDecidableTypeFull := Make_UDTF R_as_UBE.r1, r2:RNEQ:r1 <> r2r1 = r2 -> false = true
Note that the last module fulfills by subtyping many other
interfaces, such as DecidableType or EqualityType.
Note that R_as_DT can also be seen as a DecidableType
and a DecidableTypeOrig.
Definition Rcompare x y := match total_order_T x y with | inleft (left _) => Lt | inleft (right _) => Eq | inright _ => Gt end.forall x y : R, CompareSpec (x = y) (x < y) (y < x) (Rcompare x y)forall x y : R, CompareSpec (x = y) (x < y) (y < x) (Rcompare x y)x, y:RCompareSpec (x = y) (x < y) (y < x) (Rcompare x y)destruct total_order_T as [[H|H]|H]; auto. Qed. Module R_as_OT <: OrderedTypeFull. Include R_as_DT. Definition lt := Rlt. Definition le := Rle. Definition compare := Rcompare.x, y:RCompareSpec (x = y) (x < y) (y < x) match total_order_T x y with | inleft (left _) => Lt | inleft (right _) => Eq | inright _ => Gt endStrictOrder Rltsplit; [ exact Rlt_irrefl | exact Rlt_trans ]. Qed.StrictOrder RltProper (Logic.eq ==> Logic.eq ==> iff) Rltrepeat red; intros; subst; auto. Qed.Proper (Logic.eq ==> Logic.eq ==> iff) Rltforall x y : R, x <= y <-> x < y \/ x = yunfold Rle; auto with *. Qed. Definition compare_spec := Rcompare_spec. End R_as_OT.forall x y : R, x <= y <-> x < y \/ x = y
Note that R_as_OT can also be seen as a UsualOrderedType
and a OrderedType (and also as a DecidableType).
Module ROrder := OTF_to_OrderTac R_as_OT. Ltac r_order := ROrder.order.
Note that r_order is domain-agnostic: it will not prove
1<=2 or x≤x+x, but rather things like x≤y → y≤x → x=y.