/
Ring.lean
395 lines (316 loc) · 16.6 KB
/
Ring.lean
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
/-
Copyright (c) 2021 Floris van Doorn. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Floris van Doorn
-/
import Mathlib.Data.Nat.Cast.Order
import Mathlib.Algebra.GroupPower.CovariantClass
import Mathlib.Algebra.Order.Ring.Defs
import Mathlib.Algebra.Order.Ring.InjSurj
import Mathlib.Order.CompleteLatticeIntervals
import Mathlib.Order.LatticeIntervals
#align_import algebra.order.nonneg.ring from "leanprover-community/mathlib"@"422e70f7ce183d2900c586a8cda8381e788a0c62"
/-!
# The type of nonnegative elements
This file defines instances and prove some properties about the nonnegative elements
`{x : α // 0 ≤ x}` of an arbitrary type `α`.
Currently we only state instances and states some `simp`/`norm_cast` lemmas.
When `α` is `ℝ`, this will give us some properties about `ℝ≥0`.
## Main declarations
* `{x : α // 0 ≤ x}` is a `CanonicallyLinearOrderedAddCommMonoid` if `α` is a `LinearOrderedRing`.
## Implementation Notes
Instead of `{x : α // 0 ≤ x}` we could also use `Set.Ici (0 : α)`, which is definitionally equal.
However, using the explicit subtype has a big advantage: when writing an element explicitly
with a proof of nonnegativity as `⟨x, hx⟩`, the `hx` is expected to have type `0 ≤ x`. If we would
use `Ici 0`, then the type is expected to be `x ∈ Ici 0`. Although these types are definitionally
equal, this often confuses the elaborator. Similar problems arise when doing cases on an element.
The disadvantage is that we have to duplicate some instances about `Set.Ici` to this subtype.
-/
open Set
variable {α : Type*}
namespace Nonneg
/-- This instance uses data fields from `Subtype.partialOrder` to help type-class inference.
The `Set.Ici` data fields are definitionally equal, but that requires unfolding semireducible
definitions, so type-class inference won't see this. -/
instance orderBot [Preorder α] {a : α} : OrderBot { x : α // a ≤ x } :=
{ Set.Ici.orderBot with }
#align nonneg.order_bot Nonneg.orderBot
theorem bot_eq [Preorder α] {a : α} : (⊥ : { x : α // a ≤ x }) = ⟨a, le_rfl⟩ :=
rfl
#align nonneg.bot_eq Nonneg.bot_eq
instance noMaxOrder [PartialOrder α] [NoMaxOrder α] {a : α} : NoMaxOrder { x : α // a ≤ x } :=
show NoMaxOrder (Ici a) by infer_instance
#align nonneg.no_max_order Nonneg.noMaxOrder
instance semilatticeSup [SemilatticeSup α] {a : α} : SemilatticeSup { x : α // a ≤ x } :=
Set.Ici.semilatticeSup
#align nonneg.semilattice_sup Nonneg.semilatticeSup
instance semilatticeInf [SemilatticeInf α] {a : α} : SemilatticeInf { x : α // a ≤ x } :=
Set.Ici.semilatticeInf
#align nonneg.semilattice_inf Nonneg.semilatticeInf
instance distribLattice [DistribLattice α] {a : α} : DistribLattice { x : α // a ≤ x } :=
Set.Ici.distribLattice
#align nonneg.distrib_lattice Nonneg.distribLattice
instance instDenselyOrdered [Preorder α] [DenselyOrdered α] {a : α} :
DenselyOrdered { x : α // a ≤ x } :=
show DenselyOrdered (Ici a) from Set.instDenselyOrdered
#align nonneg.densely_ordered Nonneg.instDenselyOrdered
/-- If `sSup ∅ ≤ a` then `{x : α // a ≤ x}` is a `ConditionallyCompleteLinearOrder`. -/
protected noncomputable abbrev conditionallyCompleteLinearOrder [ConditionallyCompleteLinearOrder α]
{a : α} : ConditionallyCompleteLinearOrder { x : α // a ≤ x } :=
{ @ordConnectedSubsetConditionallyCompleteLinearOrder α (Set.Ici a) _ ⟨⟨a, le_rfl⟩⟩ _ with }
#align nonneg.conditionally_complete_linear_order Nonneg.conditionallyCompleteLinearOrder
/-- If `sSup ∅ ≤ a` then `{x : α // a ≤ x}` is a `ConditionallyCompleteLinearOrderBot`.
This instance uses data fields from `Subtype.linearOrder` to help type-class inference.
The `Set.Ici` data fields are definitionally equal, but that requires unfolding semireducible
definitions, so type-class inference won't see this. -/
protected noncomputable abbrev conditionallyCompleteLinearOrderBot
[ConditionallyCompleteLinearOrder α] (a : α) :
ConditionallyCompleteLinearOrderBot { x : α // a ≤ x } :=
{ Nonneg.orderBot, Nonneg.conditionallyCompleteLinearOrder with
csSup_empty := by
rw [@subset_sSup_def α (Set.Ici a) _ _ ⟨⟨a, le_rfl⟩⟩]; simp [bot_eq] }
#align nonneg.conditionally_complete_linear_order_bot Nonneg.conditionallyCompleteLinearOrderBot
instance inhabited [Preorder α] {a : α} : Inhabited { x : α // a ≤ x } :=
⟨⟨a, le_rfl⟩⟩
#align nonneg.inhabited Nonneg.inhabited
instance zero [Zero α] [Preorder α] : Zero { x : α // 0 ≤ x } :=
⟨⟨0, le_rfl⟩⟩
#align nonneg.has_zero Nonneg.zero
@[simp, norm_cast]
protected theorem coe_zero [Zero α] [Preorder α] : ((0 : { x : α // 0 ≤ x }) : α) = 0 :=
rfl
#align nonneg.coe_zero Nonneg.coe_zero
@[simp]
theorem mk_eq_zero [Zero α] [Preorder α] {x : α} (hx : 0 ≤ x) :
(⟨x, hx⟩ : { x : α // 0 ≤ x }) = 0 ↔ x = 0 :=
Subtype.ext_iff
#align nonneg.mk_eq_zero Nonneg.mk_eq_zero
instance add [AddZeroClass α] [Preorder α] [CovariantClass α α (· + ·) (· ≤ ·)] :
Add { x : α // 0 ≤ x } :=
⟨fun x y => ⟨x + y, add_nonneg x.2 y.2⟩⟩
#align nonneg.has_add Nonneg.add
@[simp]
theorem mk_add_mk [AddZeroClass α] [Preorder α] [CovariantClass α α (· + ·) (· ≤ ·)] {x y : α}
(hx : 0 ≤ x) (hy : 0 ≤ y) :
(⟨x, hx⟩ : { x : α // 0 ≤ x }) + ⟨y, hy⟩ = ⟨x + y, add_nonneg hx hy⟩ :=
rfl
#align nonneg.mk_add_mk Nonneg.mk_add_mk
@[simp, norm_cast]
protected theorem coe_add [AddZeroClass α] [Preorder α] [CovariantClass α α (· + ·) (· ≤ ·)]
(a b : { x : α // 0 ≤ x }) : ((a + b : { x : α // 0 ≤ x }) : α) = a + b :=
rfl
#align nonneg.coe_add Nonneg.coe_add
instance nsmul [AddMonoid α] [Preorder α] [CovariantClass α α (· + ·) (· ≤ ·)] :
SMul ℕ { x : α // 0 ≤ x } :=
⟨fun n x => ⟨n • (x : α), nsmul_nonneg x.prop n⟩⟩
#align nonneg.has_nsmul Nonneg.nsmul
@[simp]
theorem nsmul_mk [AddMonoid α] [Preorder α] [CovariantClass α α (· + ·) (· ≤ ·)] (n : ℕ) {x : α}
(hx : 0 ≤ x) : (n • (⟨x, hx⟩ : { x : α // 0 ≤ x })) = ⟨n • x, nsmul_nonneg hx n⟩ :=
rfl
#align nonneg.nsmul_mk Nonneg.nsmul_mk
@[simp, norm_cast]
protected theorem coe_nsmul [AddMonoid α] [Preorder α] [CovariantClass α α (· + ·) (· ≤ ·)]
(n : ℕ) (a : { x : α // 0 ≤ x }) : ((n • a : { x : α // 0 ≤ x }) : α) = n • (a : α) :=
rfl
#align nonneg.coe_nsmul Nonneg.coe_nsmul
instance orderedAddCommMonoid [OrderedAddCommMonoid α] : OrderedAddCommMonoid { x : α // 0 ≤ x } :=
Subtype.coe_injective.orderedAddCommMonoid _ Nonneg.coe_zero (fun _ _ => rfl) fun _ _ => rfl
#align nonneg.ordered_add_comm_monoid Nonneg.orderedAddCommMonoid
instance linearOrderedAddCommMonoid [LinearOrderedAddCommMonoid α] :
LinearOrderedAddCommMonoid { x : α // 0 ≤ x } :=
Subtype.coe_injective.linearOrderedAddCommMonoid _ Nonneg.coe_zero
(fun _ _ => rfl) (fun _ _ => rfl)
(fun _ _ => rfl) fun _ _ => rfl
#align nonneg.linear_ordered_add_comm_monoid Nonneg.linearOrderedAddCommMonoid
instance orderedCancelAddCommMonoid [OrderedCancelAddCommMonoid α] :
OrderedCancelAddCommMonoid { x : α // 0 ≤ x } :=
Subtype.coe_injective.orderedCancelAddCommMonoid _ Nonneg.coe_zero (fun _ _ => rfl) fun _ _ => rfl
#align nonneg.ordered_cancel_add_comm_monoid Nonneg.orderedCancelAddCommMonoid
instance linearOrderedCancelAddCommMonoid [LinearOrderedCancelAddCommMonoid α] :
LinearOrderedCancelAddCommMonoid { x : α // 0 ≤ x } :=
Subtype.coe_injective.linearOrderedCancelAddCommMonoid _ Nonneg.coe_zero
(fun _ _ => rfl) (fun _ _ => rfl)
(fun _ _ => rfl) fun _ _ => rfl
#align nonneg.linear_ordered_cancel_add_comm_monoid Nonneg.linearOrderedCancelAddCommMonoid
/-- Coercion `{x : α // 0 ≤ x} → α` as an `AddMonoidHom`. -/
def coeAddMonoidHom [OrderedAddCommMonoid α] : { x : α // 0 ≤ x } →+ α :=
{ toFun := ((↑) : { x : α // 0 ≤ x } → α)
map_zero' := Nonneg.coe_zero
map_add' := Nonneg.coe_add }
#align nonneg.coe_add_monoid_hom Nonneg.coeAddMonoidHom
@[norm_cast]
theorem nsmul_coe [OrderedAddCommMonoid α] (n : ℕ) (r : { x : α // 0 ≤ x }) :
↑(n • r) = n • (r : α) :=
Nonneg.coeAddMonoidHom.map_nsmul _ _
#align nonneg.nsmul_coe Nonneg.nsmul_coe
instance one [OrderedSemiring α] : One { x : α // 0 ≤ x } where one := ⟨1, zero_le_one⟩
#align nonneg.has_one Nonneg.one
@[simp, norm_cast]
protected theorem coe_one [OrderedSemiring α] : ((1 : { x : α // 0 ≤ x }) : α) = 1 :=
rfl
#align nonneg.coe_one Nonneg.coe_one
@[simp]
theorem mk_eq_one [OrderedSemiring α] {x : α} (hx : 0 ≤ x) :
(⟨x, hx⟩ : { x : α // 0 ≤ x }) = 1 ↔ x = 1 :=
Subtype.ext_iff
#align nonneg.mk_eq_one Nonneg.mk_eq_one
instance mul [OrderedSemiring α] : Mul { x : α // 0 ≤ x } where
mul x y := ⟨x * y, mul_nonneg x.2 y.2⟩
#align nonneg.has_mul Nonneg.mul
@[simp, norm_cast]
protected theorem coe_mul [OrderedSemiring α] (a b : { x : α // 0 ≤ x }) :
((a * b : { x : α // 0 ≤ x }) : α) = a * b :=
rfl
#align nonneg.coe_mul Nonneg.coe_mul
@[simp]
theorem mk_mul_mk [OrderedSemiring α] {x y : α} (hx : 0 ≤ x) (hy : 0 ≤ y) :
(⟨x, hx⟩ : { x : α // 0 ≤ x }) * ⟨y, hy⟩ = ⟨x * y, mul_nonneg hx hy⟩ :=
rfl
#align nonneg.mk_mul_mk Nonneg.mk_mul_mk
instance addMonoidWithOne [OrderedSemiring α] : AddMonoidWithOne { x : α // 0 ≤ x } :=
{ Nonneg.one,
Nonneg.orderedAddCommMonoid with
natCast := fun n => ⟨n, Nat.cast_nonneg n⟩
natCast_zero := by simp
natCast_succ := fun _ => by ext; simp }
#align nonneg.add_monoid_with_one Nonneg.addMonoidWithOne
@[simp, norm_cast]
protected theorem coe_natCast [OrderedSemiring α] (n : ℕ) : ((↑n : { x : α // 0 ≤ x }) : α) = n :=
rfl
#align nonneg.coe_nat_cast Nonneg.coe_natCast
@[simp]
theorem mk_natCast [OrderedSemiring α] (n : ℕ) : (⟨n, n.cast_nonneg⟩ : { x : α // 0 ≤ x }) = n :=
rfl
#align nonneg.mk_nat_cast Nonneg.mk_natCast
instance pow [OrderedSemiring α] : Pow { x : α // 0 ≤ x } ℕ where
pow x n := ⟨(x : α) ^ n, pow_nonneg x.2 n⟩
#align nonneg.has_pow Nonneg.pow
@[simp, norm_cast]
protected theorem coe_pow [OrderedSemiring α] (a : { x : α // 0 ≤ x }) (n : ℕ) :
(↑(a ^ n) : α) = (a : α) ^ n :=
rfl
#align nonneg.coe_pow Nonneg.coe_pow
@[simp]
theorem mk_pow [OrderedSemiring α] {x : α} (hx : 0 ≤ x) (n : ℕ) :
(⟨x, hx⟩ : { x : α // 0 ≤ x }) ^ n = ⟨x ^ n, pow_nonneg hx n⟩ :=
rfl
#align nonneg.mk_pow Nonneg.mk_pow
instance orderedSemiring [OrderedSemiring α] : OrderedSemiring { x : α // 0 ≤ x } :=
Subtype.coe_injective.orderedSemiring _ Nonneg.coe_zero Nonneg.coe_one
(fun _ _ => rfl) (fun _ _=> rfl) (fun _ _ => rfl)
(fun _ _ => rfl) fun _ => rfl
#align nonneg.ordered_semiring Nonneg.orderedSemiring
instance strictOrderedSemiring [StrictOrderedSemiring α] :
StrictOrderedSemiring { x : α // 0 ≤ x } :=
Subtype.coe_injective.strictOrderedSemiring _ Nonneg.coe_zero Nonneg.coe_one
(fun _ _ => rfl) (fun _ _ => rfl)
(fun _ _ => rfl) (fun _ _ => rfl) fun _ => rfl
#align nonneg.strict_ordered_semiring Nonneg.strictOrderedSemiring
instance orderedCommSemiring [OrderedCommSemiring α] : OrderedCommSemiring { x : α // 0 ≤ x } :=
Subtype.coe_injective.orderedCommSemiring _ Nonneg.coe_zero Nonneg.coe_one
(fun _ _ => rfl) (fun _ _ => rfl)
(fun _ _ => rfl) (fun _ _ => rfl) fun _ => rfl
#align nonneg.ordered_comm_semiring Nonneg.orderedCommSemiring
instance strictOrderedCommSemiring [StrictOrderedCommSemiring α] :
StrictOrderedCommSemiring { x : α // 0 ≤ x } :=
Subtype.coe_injective.strictOrderedCommSemiring _ Nonneg.coe_zero Nonneg.coe_one
(fun _ _ => rfl) (fun _ _ => rfl)
(fun _ _ => rfl) (fun _ _ => rfl) fun _ => rfl
#align nonneg.strict_ordered_comm_semiring Nonneg.strictOrderedCommSemiring
-- These prevent noncomputable instances being found, as it does not require `LinearOrder` which
-- is frequently non-computable.
instance monoidWithZero [OrderedSemiring α] : MonoidWithZero { x : α // 0 ≤ x } := by infer_instance
#align nonneg.monoid_with_zero Nonneg.monoidWithZero
instance commMonoidWithZero [OrderedCommSemiring α] : CommMonoidWithZero { x : α // 0 ≤ x } := by
infer_instance
#align nonneg.comm_monoid_with_zero Nonneg.commMonoidWithZero
instance semiring [OrderedSemiring α] : Semiring { x : α // 0 ≤ x } :=
inferInstance
#align nonneg.semiring Nonneg.semiring
instance commSemiring [OrderedCommSemiring α] : CommSemiring { x : α // 0 ≤ x } :=
inferInstance
#align nonneg.comm_semiring Nonneg.commSemiring
instance nontrivial [LinearOrderedSemiring α] : Nontrivial { x : α // 0 ≤ x } :=
⟨⟨0, 1, fun h => zero_ne_one (congr_arg Subtype.val h)⟩⟩
#align nonneg.nontrivial Nonneg.nontrivial
instance linearOrderedSemiring [LinearOrderedSemiring α] :
LinearOrderedSemiring { x : α // 0 ≤ x } :=
Subtype.coe_injective.linearOrderedSemiring _ Nonneg.coe_zero Nonneg.coe_one
(fun _ _ => rfl) (fun _ _ => rfl)
(fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) fun _ _ => rfl
#align nonneg.linear_ordered_semiring Nonneg.linearOrderedSemiring
instance linearOrderedCommMonoidWithZero [LinearOrderedCommRing α] :
LinearOrderedCommMonoidWithZero { x : α // 0 ≤ x } :=
{ Nonneg.linearOrderedSemiring, Nonneg.orderedCommSemiring with
mul_le_mul_left := fun _ _ h c ↦ mul_le_mul_of_nonneg_left h c.prop }
#align nonneg.linear_ordered_comm_monoid_with_zero Nonneg.linearOrderedCommMonoidWithZero
/-- Coercion `{x : α // 0 ≤ x} → α` as a `RingHom`. -/
def coeRingHom [OrderedSemiring α] : { x : α // 0 ≤ x } →+* α :=
{ toFun := ((↑) : { x : α // 0 ≤ x } → α)
map_one' := Nonneg.coe_one
map_mul' := Nonneg.coe_mul
map_zero' := Nonneg.coe_zero,
map_add' := Nonneg.coe_add }
#align nonneg.coe_ring_hom Nonneg.coeRingHom
instance canonicallyOrderedAddCommMonoid [OrderedRing α] :
CanonicallyOrderedAddCommMonoid { x : α // 0 ≤ x } :=
{ Nonneg.orderedAddCommMonoid, Nonneg.orderBot with
le_self_add := fun _ b => le_add_of_nonneg_right b.2
exists_add_of_le := fun {a b} h =>
⟨⟨b - a, sub_nonneg_of_le h⟩, Subtype.ext (add_sub_cancel _ _).symm⟩ }
#align nonneg.canonically_ordered_add_monoid Nonneg.canonicallyOrderedAddCommMonoid
instance canonicallyOrderedCommSemiring [OrderedCommRing α] [NoZeroDivisors α] :
CanonicallyOrderedCommSemiring { x : α // 0 ≤ x } :=
{ Nonneg.canonicallyOrderedAddCommMonoid, Nonneg.orderedCommSemiring with
eq_zero_or_eq_zero_of_mul_eq_zero := by
rintro ⟨a, ha⟩ ⟨b, hb⟩
simp only [mk_mul_mk, mk_eq_zero, mul_eq_zero, imp_self]}
#align nonneg.canonically_ordered_comm_semiring Nonneg.canonicallyOrderedCommSemiring
instance canonicallyLinearOrderedAddCommMonoid [LinearOrderedRing α] :
CanonicallyLinearOrderedAddCommMonoid { x : α // 0 ≤ x } :=
{ Subtype.instLinearOrder _, Nonneg.canonicallyOrderedAddCommMonoid with }
#align nonneg.canonically_linear_ordered_add_monoid Nonneg.canonicallyLinearOrderedAddCommMonoid
section LinearOrder
variable [Zero α] [LinearOrder α]
/-- The function `a ↦ max a 0` of type `α → {x : α // 0 ≤ x}`. -/
def toNonneg (a : α) : { x : α // 0 ≤ x } :=
⟨max a 0, le_max_right _ _⟩
#align nonneg.to_nonneg Nonneg.toNonneg
@[simp]
theorem coe_toNonneg {a : α} : (toNonneg a : α) = max a 0 :=
rfl
#align nonneg.coe_to_nonneg Nonneg.coe_toNonneg
@[simp]
theorem toNonneg_of_nonneg {a : α} (h : 0 ≤ a) : toNonneg a = ⟨a, h⟩ := by simp [toNonneg, h]
#align nonneg.to_nonneg_of_nonneg Nonneg.toNonneg_of_nonneg
@[simp]
theorem toNonneg_coe {a : { x : α // 0 ≤ x }} : toNonneg (a : α) = a :=
toNonneg_of_nonneg a.2
#align nonneg.to_nonneg_coe Nonneg.toNonneg_coe
@[simp]
theorem toNonneg_le {a : α} {b : { x : α // 0 ≤ x }} : toNonneg a ≤ b ↔ a ≤ b := by
cases' b with b hb
simp [toNonneg, hb]
#align nonneg.to_nonneg_le Nonneg.toNonneg_le
@[simp]
theorem toNonneg_lt {a : { x : α // 0 ≤ x }} {b : α} : a < toNonneg b ↔ ↑a < b := by
cases' a with a ha
simp [toNonneg, ha.not_lt]
#align nonneg.to_nonneg_lt Nonneg.toNonneg_lt
instance sub [Sub α] : Sub { x : α // 0 ≤ x } :=
⟨fun x y => toNonneg (x - y)⟩
#align nonneg.has_sub Nonneg.sub
@[simp]
theorem mk_sub_mk [Sub α] {x y : α} (hx : 0 ≤ x) (hy : 0 ≤ y) :
(⟨x, hx⟩ : { x : α // 0 ≤ x }) - ⟨y, hy⟩ = toNonneg (x - y) :=
rfl
#align nonneg.mk_sub_mk Nonneg.mk_sub_mk
end LinearOrder
instance orderedSub [LinearOrderedRing α] : OrderedSub { x : α // 0 ≤ x } :=
⟨by
rintro ⟨a, ha⟩ ⟨b, hb⟩ ⟨c, hc⟩
simp only [sub_le_iff_le_add, Subtype.mk_le_mk, mk_sub_mk, mk_add_mk, toNonneg_le,
Subtype.coe_mk]⟩
#align nonneg.has_ordered_sub Nonneg.orderedSub
end Nonneg