Skip to content

Commit 16e6988

Browse files
fix defintions of min and max, add comment on limitations of UsingEq (#1270)
1 parent ca7c15c commit 16e6988

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

Cubical/Data/Nat/Properties.agda

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ private
2323
min :
2424
min zero m = zero
2525
min (suc n) zero = zero
26-
min (suc n) (suc m) with n <ᵇ m
27-
... | false = suc m
28-
... | true = suc n
26+
min (suc n) (suc m) with n <ᵇ m UsingEq
27+
... | false , _ = suc m
28+
... | true , _ = suc n
2929

3030
minSuc : min (suc n) (suc m) ≡ suc (min n m)
3131
minSuc {zero} {zero} = refl
@@ -44,9 +44,9 @@ minComm (suc n) (suc m) = minSuc ∙∙ cong suc (minComm n m) ∙∙ sym minSuc
4444
max :
4545
max zero m = m
4646
max (suc n) zero = suc n
47-
max (suc n) (suc m) with n <ᵇ m
48-
... | false = suc n
49-
... | true = suc m
47+
max (suc n) (suc m) with n <ᵇ m UsingEq
48+
... | false , _ = suc n
49+
... | true , _ = suc m
5050

5151
maxSuc : max (suc n) (suc m) ≡ suc (max n m)
5252
maxSuc {zero} {zero} = refl

Cubical/Foundations/Prelude.agda

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,9 @@ infixl 0 _i0:>_UsingEqP
506506

507507
-- Similar to `inspect`, but more convenient when `a` is not a function
508508
-- application, or when the applied function is not relevant
509+
-- Note: when defining a term with `UsingEq`, it's still possible to prove its properties
510+
-- using a with-abstraction without `UsingEq`, but not the other way around.
511+
-- See `min`/`max` and their properties in Data.Nat.Properties for examples of this.
509512
_UsingEq : (a : A) singl a
510513
a UsingEq = isContrSingl a .fst
511514

0 commit comments

Comments
 (0)