| 1 |
From Coq Require Import Morphisms Setoid. |
| 2 |
From Coq Require Import Equalities. |
| 3 |
From Coq Require Import Orders. |
| 4 |
Require Import Crypto.Util.Structures.Orders. |
| 5 |
Require Import Crypto.Util.Structures.Equalities.Iso. |
| 6 |
Require Import Crypto.Util.GlobalSettings. |
| 7 |
Require Import Crypto.Util.FixCoqMistakes. |
| 8 |
|
| 9 |
Local Set Implicit Arguments. |
| 10 |
|
| 11 |
Module Type IsSectLt (E : EqLt) (Import T:EqLt) (Import I : HasIso E T). |
| 12 |
Axiom Proper_to_lt : Proper (lt ==> E.lt) to_. |
| 13 |
End IsSectLt. |
| 14 |
|
| 15 |
Module Type IsRetrLt (E : EqLt) (Import T:EqLt) (Import I : HasIso E T). |
| 16 |
Axiom Proper_of_lt : Proper (E.lt ==> lt) of_. |
| 17 |
End IsRetrLt. |
| 18 |
|
| 19 |
Module Type IsIsoLt (E : EqLt) (T:EqLt) (I : HasIso E T) := Nop <+ IsSectLt E T I <+ IsRetrLt E T I. |
| 20 |
|
| 21 |
Module Type IsSectLe (E : EqLe) (Import T:EqLe) (Import I : HasIso E T). |
| 22 |
Axiom Proper_to_le : Proper (le ==> E.le) to_. |
| 23 |
End IsSectLe. |
| 24 |
|
| 25 |
Module Type IsRetrLe (E : EqLe) (Import T:EqLe) (Import I : HasIso E T). |
| 26 |
Axiom Proper_of_le : Proper (E.le ==> le) of_. |
| 27 |
End IsRetrLe. |
| 28 |
|
| 29 |
Module Type IsIsoLe (E : EqLe) (T:EqLe) (I : HasIso E T) := Nop <+ IsSectLe E T I <+ IsRetrLe E T I. |
| 30 |
|
| 31 |
Module Type IsoEqLt (E : EqLt) := EqLt <+ HasIso E <+ IsIso E <+ IsIsoLt E. |
| 32 |
Module Type IsoEqLe (E : EqLe) := EqLe <+ HasIso E <+ IsIso E <+ IsIsoLe E. |
| 33 |
Module Type IsoEqLtLe (E : EqLtLe) := EqLtLe <+ HasIso E <+ IsIso E <+ IsIsoLt E <+ IsIsoLe E. |
| 34 |
Module Type IsoEqLt' (E : EqLt) := EqLt' <+ HasIso E <+ IsIso E <+ IsIsoLt E. |
| 35 |
Module Type IsoEqLe' (E : EqLe) := EqLe' <+ HasIso E <+ IsIso E <+ IsIsoLe E. |
| 36 |
Module Type IsoEqLtLe' (E : EqLtLe) := EqLtLe' <+ HasIso E <+ IsIso E <+ IsIsoLt E <+ IsIsoLe E. |
| 37 |
Module Type IsoStrOrder (E : EqLt) := StrOrder <+ HasIso E <+ IsIso E <+ IsIsoLt E. |
| 38 |
Module Type IsoStrOrder' (E : EqLt) := StrOrder' <+ HasIso E <+ IsIso E <+ IsIsoLt E. |
| 39 |
Module Type IsoDecStrOrder (E : EqLt) := DecStrOrder <+ HasIso E <+ IsIso E <+ IsIsoLt E. |
| 40 |
Module Type IsoDecStrOrder' (E : EqLt) := DecStrOrder' <+ HasIso E <+ IsIso E <+ IsIsoLt E. |
| 41 |
Module Type IsoOrderedType (E : EqLt) := Orders.OrderedType <+ HasIso E <+ IsIso E <+ IsIsoLt E. |
| 42 |
Module Type IsoOrderedType' (E : EqLt) := OrderedType' <+ HasIso E <+ IsIso E <+ IsIsoLt E. |
| 43 |
Module Type IsoOrderedTypeFull (E : EqLt) := OrderedTypeFull <+ HasIso E <+ IsIso E <+ IsIsoLt E. |
| 44 |
Module Type IsoOrderedTypeFull' (E : EqLt) := OrderedTypeFull' <+ HasIso E <+ IsIso E <+ IsIsoLt E. |
| 45 |
|
| 46 |
Module Type IsoMiniOrderedType (E : EqLt) := MiniOrderedType <+ HasIso E <+ IsIso E <+ IsIsoLt E. |
| 47 |
Module Type IsoOrderedTypeOrig (E : EqLt) := OrderedTypeOrig <+ HasIso E <+ IsIso E <+ IsIsoLt E. |
| 48 |
Module Type IsoUsualMiniOrderedType (E : UsualEqLt) := UsualMiniOrderedType <+ HasIso E <+ IsIso E <+ IsIsoLt E. |
| 49 |
Module Type IsoUsualOrderedTypeOrig (E : UsualEqLt) := UsualOrderedTypeOrig <+ HasIso E <+ IsIso E <+ IsIsoLt E. |
| 50 |
|
| 51 |
Module LiftIsoHasLt (E : EqLt) (Import I : Iso.Iso E) <: HasLt I. |
| 52 |
Definition lt : relation t := fun x y => E.lt (to_ x) (to_ y). |
| 53 |
End LiftIsoHasLt. |
| 54 |
|
| 55 |
Module LiftIsoHasLe (E : EqLe) (Import I : Iso.Iso E) <: HasLe I. |
| 56 |
Definition le : relation t := fun x y => E.le (to_ x) (to_ y). |
| 57 |
End LiftIsoHasLe. |
| 58 |
|
| 59 |
Module LiftSectIsLt (E : EqLt) (Import I : Iso.Iso E). |
| 60 |
Module Import _LiftSectIsLt. |
| 61 |
Module Import I' := LiftIsoHasLt E I. |
| 62 |
End _LiftSectIsLt. |
| 63 |
Global Instance Proper_to_lt : Proper (I'.lt ==> E.lt) I.to_ | 5. |
| 64 |
Proof. cbv; intros *; exact id. Qed. |
| 65 |
End LiftSectIsLt. |
| 66 |
|
| 67 |
Module LiftRetrIsLt (E : StrOrder) (Import I : IsoEqualityType E). |
| 68 |
Module Import _LiftRetrIsLt. |
| 69 |
Module Import I' := LiftIsoHasLt E I. |
| 70 |
End _LiftRetrIsLt. |
| 71 |
Global Instance Proper_of_lt : Proper (E.lt ==> I'.lt) I.of_ | 5. |
| 72 |
Proof. cbv; intros *. rewrite !I.to_of. exact id. Qed. |
| 73 |
End LiftRetrIsLt. |
| 74 |
|
| 75 |
Module LiftUsualRetrIsLt (E : UsualEqLt) (Import I : IsoEqualityType E). |
| 76 |
Module Import _LiftRetrIsLt. |
| 77 |
Module Import I' := LiftIsoHasLt E I. |
| 78 |
End _LiftRetrIsLt. |
| 79 |
Global Instance Proper_of_lt : Proper (E.lt ==> I'.lt) I.of_ | 5. |
| 80 |
Proof. cbv; intros *. rewrite !I.to_of. exact id. Qed. |
| 81 |
End LiftUsualRetrIsLt. |
| 82 |
|
| 83 |
Module LiftIsoLtTrans (E : MiniOrderedType) (Import I : Iso.Iso E). |
| 84 |
Module Import _LiftSectLtTrans. |
| 85 |
Module Import I' := LiftIsoHasLt E I. |
| 86 |
End _LiftSectLtTrans. |
| 87 |
Lemma lt_trans : forall x y z : I.t, I'.lt x y -> I'.lt y z -> I'.lt x z. |
| 88 |
Proof. cbv; intros *; apply E.lt_trans. Qed. |
| 89 |
End LiftIsoLtTrans. |
| 90 |
|
| 91 |
Module LiftIsoLtNotEq (E : MiniOrderedType) (Import I : SectEqualityType E). |
| 92 |
Module Import _LiftSectLtNotEq. |
| 93 |
Module Import I' := LiftIsoHasLt E I. |
| 94 |
End _LiftSectLtNotEq. |
| 95 |
Lemma lt_not_eq : forall x y : t, I'.lt x y -> ~ I.eq x y. |
| 96 |
Proof. cbv; intros * H H'; apply E.lt_not_eq in H; apply H. f_equiv; assumption. Qed. |
| 97 |
End LiftIsoLtNotEq. |
| 98 |
|
| 99 |
Module LiftSectCompareOrig (E : MiniOrderedType) (Import I : SectEqualityType E). |
| 100 |
Module Import _LiftSectCompareOrig. |
| 101 |
Module Import I' := LiftIsoHasLt E I. |
| 102 |
End _LiftSectCompareOrig. |
| 103 |
Definition compare : forall x y : t, OrderedType.Compare I'.lt I.eq x y. |
| 104 |
Proof. |
| 105 |
intros x y. |
| 106 |
destruct (E.compare (to_ x) (to_ y)) as [H|H|H]; try (constructor; assumption). |
| 107 |
apply Proper_of_ in H. |
| 108 |
rewrite !of_to in H. |
| 109 |
constructor; assumption. |
| 110 |
Defined. |
| 111 |
End LiftSectCompareOrig. |
| 112 |
|
| 113 |
Module LiftSectHasMiniOrderedType (E : MiniOrderedType) (I : SectEqualityType E) := LiftIsoLtTrans E I <+ LiftIsoLtNotEq E I <+ LiftSectCompareOrig E I. |
| 114 |
|
| 115 |
Module Type SectEqLt (E : EqLt) := EqLt <+ HasIso E <+ IsSect E <+ IsSectLt E. |
| 116 |
Module Type SectEqLe (E : EqLe) := EqLe <+ HasIso E <+ IsSect E <+ IsSectLe E. |
| 117 |
Module Type SectEqLtLe (E : EqLtLe) := EqLtLe <+ HasIso E <+ IsSect E <+ IsSectLt E <+ IsSectLe E. |
| 118 |
Module Type SectEqLt' (E : EqLt) := EqLt' <+ HasIso E <+ IsSect E <+ IsSectLt E. |
| 119 |
Module Type SectEqLe' (E : EqLe) := EqLe' <+ HasIso E <+ IsSect E <+ IsSectLe E. |
| 120 |
Module Type SectEqLtLe' (E : EqLtLe) := EqLtLe' <+ HasIso E <+ IsSect E <+ IsSectLt E <+ IsSectLe E. |
| 121 |
Module Type SectStrOrder (E : EqLt) := StrOrder <+ HasIso E <+ IsSect E <+ IsSectLt E. |
| 122 |
Module Type SectStrOrder' (E : EqLt) := StrOrder' <+ HasIso E <+ IsSect E <+ IsSectLt E. |
| 123 |
Module Type SectDecStrOrder (E : EqLt) := DecStrOrder <+ HasIso E <+ IsSect E <+ IsSectLt E. |
| 124 |
Module Type SectDecStrOrder' (E : EqLt) := DecStrOrder' <+ HasIso E <+ IsSect E <+ IsSectLt E. |
| 125 |
Module Type SectOrderedType (E : EqLt) := Orders.OrderedType <+ HasIso E <+ IsSect E <+ IsSectLt E. |
| 126 |
Module Type SectOrderedType' (E : EqLt) := OrderedType' <+ HasIso E <+ IsSect E <+ IsSectLt E. |
| 127 |
Module Type SectOrderedTypeFull (E : EqLt) := OrderedTypeFull <+ HasIso E <+ IsSect E <+ IsSectLt E. |
| 128 |
Module Type SectOrderedTypeFull' (E : EqLt) := OrderedTypeFull' <+ HasIso E <+ IsSect E <+ IsSectLt E. |
| 129 |
|
| 130 |
Module Type SectMiniOrderedType (E : EqLt) := MiniOrderedType <+ HasIso E <+ IsSect E <+ IsSectLt E. |
| 131 |
Module Type SectOrderedTypeOrig (E : EqLt) := OrderedTypeOrig <+ HasIso E <+ IsSect E <+ IsSectLt E. |
| 132 |
Module Type SectUsualMiniOrderedType (E : UsualEqLt) := UsualMiniOrderedType <+ HasIso E <+ IsSect E <+ IsSectLt E. |
| 133 |
Module Type SectUsualOrderedTypeOrig (E : UsualEqLt) := UsualOrderedTypeOrig <+ HasIso E <+ IsSect E <+ IsSectLt E. |
| 134 |
|
| 135 |
Module Type RetrEqLt (E : EqLt) := EqLt <+ HasIso E <+ IsRetr E <+ IsRetrLt E. |
| 136 |
Module Type RetrEqLe (E : EqLe) := EqLe <+ HasIso E <+ IsRetr E <+ IsRetrLe E. |
| 137 |
Module Type RetrEqLtLe (E : EqLtLe) := EqLtLe <+ HasIso E <+ IsRetr E <+ IsRetrLt E <+ IsRetrLe E. |
| 138 |
Module Type RetrEqLt' (E : EqLt) := EqLt' <+ HasIso E <+ IsRetr E <+ IsRetrLt E. |
| 139 |
Module Type RetrEqLe' (E : EqLe) := EqLe' <+ HasIso E <+ IsRetr E <+ IsRetrLe E. |
| 140 |
Module Type RetrEqLtLe' (E : EqLtLe) := EqLtLe' <+ HasIso E <+ IsRetr E <+ IsRetrLt E <+ IsRetrLe E. |
| 141 |
Module Type RetrStrOrder (E : EqLt) := StrOrder <+ HasIso E <+ IsRetr E <+ IsRetrLt E. |
| 142 |
Module Type RetrStrOrder' (E : EqLt) := StrOrder' <+ HasIso E <+ IsRetr E <+ IsRetrLt E. |
| 143 |
Module Type RetrDecStrOrder (E : EqLt) := DecStrOrder <+ HasIso E <+ IsRetr E <+ IsRetrLt E. |
| 144 |
Module Type RetrDecStrOrder' (E : EqLt) := DecStrOrder' <+ HasIso E <+ IsRetr E <+ IsRetrLt E. |
| 145 |
Module Type RetrOrderedType (E : EqLt) := Orders.OrderedType <+ HasIso E <+ IsRetr E <+ IsRetrLt E. |
| 146 |
Module Type RetrOrderedType' (E : EqLt) := OrderedType' <+ HasIso E <+ IsRetr E <+ IsRetrLt E. |
| 147 |
Module Type RetrOrderedTypeFull (E : EqLt) := OrderedTypeFull <+ HasIso E <+ IsRetr E <+ IsRetrLt E. |
| 148 |
Module Type RetrOrderedTypeFull' (E : EqLt) := OrderedTypeFull' <+ HasIso E <+ IsRetr E <+ IsRetrLt E. |
| 149 |
|
| 150 |
Module Type RetrMiniOrderedType (E : EqLt) := MiniOrderedType <+ HasIso E <+ IsRetr E <+ IsRetrLt E. |
| 151 |
Module Type RetrOrderedTypeOrig (E : EqLt) := OrderedTypeOrig <+ HasIso E <+ IsRetr E <+ IsRetrLt E. |
| 152 |
Module Type RetrUsualMiniOrderedType (E : UsualEqLt) := UsualMiniOrderedType <+ HasIso E <+ IsRetr E <+ IsRetrLt E. |
| 153 |
Module Type RetrUsualOrderedTypeOrig (E : UsualEqLt) := UsualOrderedTypeOrig <+ HasIso E <+ IsRetr E <+ IsRetrLt E. |