Debian Codegraph @

src/Util/Structures/Orders/Unit.v

raw
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.Equalities.Unit.
5 Require Import Crypto.Util.Structures.Orders.
6 Require Import Crypto.Util.Unit.
7 Require Import Crypto.Util.Tactics.DestructHead.
8
9 Local Set Implicit Arguments.
10
11 Module UnitHasLeb.
12 Definition leb (x y : unit) := true.
13 End UnitHasLeb.
14
15 Module UnitHasLtb.
16 Definition ltb (x y : unit) := false.
17 End UnitHasLtb.
18
19 Module UnitHasLe.
20 Definition le : relation unit := fun _ _ => True.
21 End UnitHasLe.
22
23 Module UnitHasLt.
24 Definition lt : relation unit := fun _ _ => False.
25 End UnitHasLt.
26
27 Local Ltac t :=
28 repeat first [ intro
29 | progress cbv in *
30 | progress subst
31 | exfalso; assumption
32 | congruence
33 | progress destruct_head'_unit
34 | progress destruct_head'_or
35 | solve [ eauto ]
36 | exactly_once constructor ].
37
38 Module UnitIsStrOrder.
39 Global Instance lt_strorder : StrictOrder UnitHasLt.lt | 1.
40 Proof. t. Qed.
41 Global Instance lt_compat : Proper (eq==>eq==>iff) UnitHasLt.lt | 1.
42 Proof. t. Qed.
43 End UnitIsStrOrder.
44
45 Module UnitIsStrOrderOrig.
46 Lemma lt_trans : forall x y z, UnitHasLt.lt x y -> UnitHasLt.lt y z -> UnitHasLt.lt x z.
47 Proof. t. Qed.
48 Lemma lt_not_eq : forall x y, UnitHasLt.lt x y -> ~ eq x y.
49 Proof. t. Qed.
50 End UnitIsStrOrderOrig.
51
52 Module UnitHasCompareOrig.
53 Definition compare : forall x y, OrderedType.Compare UnitHasLt.lt eq x y.
54 Proof.
55 constructor; destruct_head'_unit; reflexivity.
56 Defined.
57 End UnitHasCompareOrig.
58
59 Module UnitLeIsLtEq.
60 Local Infix "<=" := UnitHasLe.le.
61 Local Infix "<" := UnitHasLt.lt.
62 Local Infix "==" := eq (at level 70).
63 Lemma le_lteq : forall x y, x <= y <-> x < y \/ x == y.
64 Proof. t. Qed.
65 End UnitLeIsLtEq.
66
67 Module UnitHasCmp.
68 Definition compare (x y : unit) : comparison := Eq.
69 End UnitHasCmp.
70
71 Module UnitCmpNotation := Nop <+ CmpNotation UnitTyp UnitHasCmp.
72
73 Module UnitCmpSpec.
74 Local Infix "<" := UnitHasLt.lt.
75 Local Infix "==" := eq (at level 70).
76 Lemma compare_spec : forall x y, CompareSpec (x == y) (x < y) (y < x) Eq.
77 Proof. t. Qed.
78 End UnitCmpSpec.
79
80 Module UnitLtIsTotal.
81 Local Infix "<" := UnitHasLt.lt.
82 Local Infix "==" := eq (at level 70).
83 Lemma lt_total : forall x y, x < y \/ x == y \/ y < x.
84 Proof. t. Qed.
85 End UnitLtIsTotal.
86
87 Module UnitLebNotation := Nop <+ LebNotation UnitTyp UnitHasLeb.
88 Module UnitLtbNotation := Nop <+ LtbNotation UnitTyp UnitHasLtb.
89
90 Module UnitLebSpec.
91 Lemma leb_le : forall x y, UnitHasLeb.leb x y = true <-> UnitHasLe.le x y.
92 Proof. t. Qed.
93 End UnitLebSpec.
94
95 Module UnitLtbSpec.
96 Lemma ltb_lt : forall x y, UnitHasLtb.ltb x y = true <-> UnitHasLt.lt x y.
97 Proof. t. Qed.
98 End UnitLtbSpec.
99
100 Module UnitLebIsTotal.
101 Local Infix "<=?" := UnitHasLeb.leb (at level 70).
102 Lemma leb_total : forall x y, (x <=? y) = true \/ (y <=? x) = true.
103 Proof. t. Qed.
104 End UnitLebIsTotal.
105
106 Module UnitLebIsTransitive.
107 Local Coercion is_true : bool >-> Sortclass.
108 Lemma leb_trans : Transitive UnitHasLeb.leb.
109 Proof. t. Qed.
110 End UnitLebIsTransitive.
111
112 Module UnitUsualIsStrOrder.
113 Global Instance lt_strorder : StrictOrder UnitHasLt.lt | 1 := _.
114 Global Instance lt_compat : Proper (eq==>eq==>iff) UnitHasLt.lt | 1 := _.
115 End UnitUsualIsStrOrder.
116
117 Module UnitUsualLeIsLtEq.
118 Local Infix "<=" := UnitHasLe.le.
119 Local Infix "<" := UnitHasLt.lt.
120 Lemma le_lteq : forall x y, x <= y <-> x < y \/ x = y.
121 Proof. t. Qed.
122 End UnitUsualLeIsLtEq.
123
124 Module UnitUsualCmpSpec.
125 Local Infix "<" := UnitHasLt.lt.
126 Lemma compare_spec : forall x y, CompareSpec (x = y) (x < y) (y < x) Eq.
127 Proof. t. Qed.
128 End UnitUsualCmpSpec.
129
130 Module UnitUsualLtIsTotal.
131 Local Infix "<" := UnitHasLt.lt.
132 Lemma lt_total : forall x y, x < y \/ x = y \/ y < x.
133 Proof. t. Qed.
134 End UnitUsualLtIsTotal.
135
136 Local Coercion is_true : bool >-> Sortclass.
137
138 Module UnitIsStrOrderBool.
139 Global Instance ltb_strorder : StrictOrder UnitHasLtb.ltb | 10.
140 Proof. t. Qed.
141 Global Instance ltb_compat : Proper (UnitHasEqb.eqb==>UnitHasEqb.eqb==>eq) UnitHasLtb.ltb | 10.
142 Proof. t. Qed.
143 End UnitIsStrOrderBool.
144
145 Module UnitLebIsLtbEqb.
146 Lemma leb_ltbeqb : forall x y, (UnitHasLeb.leb x y = (UnitHasLtb.ltb x y || UnitHasEqb.eqb x y))%bool.
147 Proof. t. Qed.
148 End UnitLebIsLtbEqb.
149
150 Module UnitEqLt <: EqLt := UnitEq <+ UnitHasLt.
151 Module UnitEqLe <: EqLe := UnitEq <+ UnitHasLe.
152 Module UnitEqLtLe <: EqLtLe := UnitEq <+ UnitHasLt <+ UnitHasLe.
153 Module UnitEqLt' <: EqLt' := UnitEq <+ UnitHasLt <+ EqLtNotation.
154 Module UnitEqLe' <: EqLe' := UnitEq <+ UnitHasLe <+ EqLeNotation.
155 Module UnitEqLtLe' <: EqLtLe' := UnitEq <+ UnitHasLt <+ UnitHasLe <+ EqLtLeNotation.
156 Module UnitStrOrder <: StrOrder := UnitEqualityType <+ UnitHasLt <+ UnitIsStrOrder.
157 Module UnitStrOrder' <: StrOrder' := UnitStrOrder <+ EqLtNotation.
158 Module UnitHasCompare := UnitHasCmp <+ UnitCmpSpec.
159 Module UnitDecStrOrder <: DecStrOrder := UnitStrOrder <+ UnitHasCompare.
160 Module UnitDecStrOrder' <: DecStrOrder' := UnitDecStrOrder <+ EqLtNotation <+ CmpNotation.
161 Module UnitOrderedType <: OrderedType := UnitDecStrOrder <+ UnitHasEqDec.
162 Module UnitOrderedType' <: OrderedType' := UnitOrderedType <+ EqLtNotation <+ CmpNotation.
163 Module UnitOrderedTypeFull <: OrderedTypeFull := UnitOrderedType <+ UnitHasLe <+ UnitLeIsLtEq.
164 Module UnitOrderedTypeFull' <: OrderedTypeFull' := UnitOrderedTypeFull <+ EqLtLeNotation <+ CmpNotation.
165
166 Module UnitUsualEqLt <: UsualEqLt := UnitUsualEq <+ UnitHasLt.
167 Module UnitUsualEqLe <: UsualEqLe := UnitUsualEq <+ UnitHasLe.
168 Module UnitUsualEqLtLe <: UsualEqLtLe := UnitUsualEq <+ UnitHasLt <+ UnitHasLe.
169
170 Module UnitUsualStrOrder <: UsualStrOrder := UnitUsualEqualityType <+ UnitHasLt <+ UnitUsualIsStrOrder.
171
172 Module UnitUsualHasCompare := UnitHasCmp <+ UnitUsualCmpSpec.
173
174 Module UnitUsualDecStrOrder <: UsualDecStrOrder := UnitUsualStrOrder <+ UnitUsualHasCompare.
175 Module UnitUsualOrderedType <: UsualOrderedType := UnitUsualDecStrOrder <+ UnitUsualHasEqDec.
176 Module UnitUsualOrderedTypeFull <: UsualOrderedTypeFull := UnitUsualOrderedType <+ UnitHasLe <+ UnitUsualLeIsLtEq.
177
178 Module UnitUsualStrOrder' <: UsualStrOrder' := UnitUsualStrOrder <+ LtNotation.
179 Module UnitUsualDecStrOrder' <: UsualDecStrOrder' := UnitUsualDecStrOrder <+ LtNotation.
180 Module UnitUsualOrderedType' <: UsualOrderedType' := UnitUsualOrderedType <+ LtNotation.
181 Module UnitUsualOrderedTypeFull' <: UsualOrderedTypeFull' := UnitUsualOrderedTypeFull <+ LtLeNotation.
182
183 Module UnitTotalOrder <: TotalOrder := UnitStrOrder <+ UnitHasLe <+ UnitLeIsLtEq <+ UnitLtIsTotal.
184 Module UnitUsualTotalOrder <: UsualTotalOrder
185 := UnitUsualStrOrder <+ UnitHasLe <+ UnitUsualLeIsLtEq <+ UnitUsualLtIsTotal.
186
187 Module UnitTotalOrder' <: TotalOrder' := UnitTotalOrder <+ EqLtLeNotation.
188 Module UnitUsualTotalOrder' <: UsualTotalOrder' := UnitUsualTotalOrder <+ LtLeNotation.
189
190 Module UnitOrderedTypeOrig <: OrderedTypeOrig := OT_of_New UnitOrderedType.
191 Module UnitMiniOrderedType <: MiniOrderedType := UnitOrderedTypeOrig.
192 Module UnitUsualOrderedTypeOrig <: UsualOrderedTypeOrig := UnitOrderedTypeOrig.
193 Module UnitUsualMiniOrderedType <: UsualMiniOrderedType := UnitOrderedTypeOrig.
194
195 Module UnitLeBool <: LeBool := UnitTyp <+ UnitHasLeb.
196 Module UnitLtBool <: LtBool := UnitTyp <+ UnitHasLtb.
197 Module UnitLeBool' <: LeBool' := UnitLeBool <+ LebNotation.
198 Module UnitLtBool' <: LtBool' := UnitLtBool <+ LtbNotation.
199 Module UnitEqLeBool <: EqLeBool := UnitTyp <+ UnitHasEqb <+ UnitHasLeb.
200 Module UnitEqLtBool <: EqLtBool := UnitTyp <+ UnitHasEqb <+ UnitHasLtb.
201 Module UnitEqLeBool' <: EqLeBool' := UnitEqLeBool <+ EqbNotation <+ LebNotation.
202 Module UnitEqLtBool' <: EqLtBool' := UnitEqLtBool <+ EqbNotation <+ LtbNotation.
203 Module UnitEqLtLeBool <: EqLtLeBool := UnitTyp <+ UnitHasEqb <+ UnitHasLtb <+ UnitHasLeb.
204 Module UnitEqLtLeBool' <: EqLtLeBool' := UnitEqLtLeBool <+ EqbNotation <+ LtbNotation <+ LebNotation.
205
206 Module UnitTotalLeBool <: TotalLeBool := UnitLeBool <+ UnitLebIsTotal.
207 Module UnitTotalLeBool' <: TotalLeBool' := UnitLeBool' <+ UnitLebIsTotal.
208 Module UnitTotalEqLeBool <: TotalEqLeBool := UnitEqLeBool <+ UnitLebIsTotal.
209 Module UnitTotalEqLeBool' <: TotalEqLeBool' := UnitEqLeBool' <+ UnitLebIsTotal.
210 Module UnitTotalEqLtLeBool <: TotalEqLtLeBool := UnitEqLtLeBool <+ UnitLebIsTotal.
211 Module UnitTotalEqLtLeBool' <: TotalEqLtLeBool' := UnitEqLtLeBool' <+ UnitLebIsTotal.
212
213 Module UnitTotalTransitiveLeBool <: TotalTransitiveLeBool := UnitTotalLeBool <+ UnitLebIsTransitive.
214 Module UnitTotalTransitiveLeBool' <: TotalTransitiveLeBool' := UnitTotalLeBool' <+ UnitLebIsTransitive.
215 Module UnitTotalTransitiveEqLeBool <: TotalTransitiveEqLeBool := UnitTotalEqLeBool <+ UnitLebIsTransitive.
216 Module UnitTotalTransitiveEqLeBool' <: TotalTransitiveEqLeBool' := UnitTotalEqLeBool' <+ UnitLebIsTransitive.
217 Module UnitTotalTransitiveEqLtLeBool <: TotalTransitiveEqLtLeBool := UnitTotalEqLtLeBool <+ UnitLebIsTransitive.
218 Module UnitTotalTransitiveEqLtLeBool' <: TotalTransitiveEqLtLeBool' := UnitTotalEqLtLeBool' <+ UnitLebIsTransitive.
219
220 Module UnitStrOrderBool <: StrOrderBool := UnitEqbType <+ UnitHasLtb <+ UnitIsStrOrderBool.
221 Module UnitStrOrderBool' <: StrOrderBool' := UnitStrOrderBool <+ EqLtBoolNotation.
222
223 Module UnitTotalOrderBool <: TotalOrderBool := UnitStrOrderBool <+ UnitHasLeb <+ UnitLebIsLtbEqb <+ UnitLebIsTotal.
224 Module UnitTotalOrderBool' <: TotalOrderBool' := UnitTotalOrderBool <+ EqLtLeBoolNotation.
225
226 Module UnitHasBoolOrdFuns := UnitHasEqb <+ UnitHasLtb <+ UnitHasLeb.
227
228 Module UnitHasBoolOrdFuns' := UnitHasBoolOrdFuns <+ UnitEqbNotation <+ UnitLtbNotation <+ UnitLebNotation.
229
230 Module UnitBoolOrdSpecs := UnitEqbSpec <+ UnitLtbSpec <+ UnitLebSpec.
231
232 Module UnitOrderFunctions := UnitHasCompare <+ UnitHasBoolOrdFuns <+ UnitBoolOrdSpecs.
233 Module UnitOrderFunctions' := UnitHasCompare <+ UnitCmpNotation <+ UnitHasBoolOrdFuns' <+ UnitBoolOrdSpecs.