2020-08-19 00:26:56 +03:00
|
|
|
||| Implementation of ordering relations for `Nat`ural numbers
|
|
|
|
module Data.Nat.Order
|
|
|
|
|
|
|
|
import Data.Nat
|
|
|
|
import Data.Fun
|
|
|
|
import Data.Rel
|
|
|
|
import Decidable.Decidable
|
|
|
|
|
2021-06-09 01:05:10 +03:00
|
|
|
%default total
|
|
|
|
|
2020-08-19 00:26:56 +03:00
|
|
|
public export
|
2021-07-13 17:32:01 +03:00
|
|
|
zeroNeverGreater : Not (LTE (S n) Z)
|
2021-02-16 14:56:43 +03:00
|
|
|
zeroNeverGreater LTEZero impossible
|
|
|
|
zeroNeverGreater (LTESucc _) impossible
|
2020-08-19 00:26:56 +03:00
|
|
|
|
|
|
|
public export
|
2021-07-09 11:06:27 +03:00
|
|
|
zeroAlwaysSmaller : {n : Nat} -> LTE Z n
|
2020-08-19 00:26:56 +03:00
|
|
|
zeroAlwaysSmaller = LTEZero
|
|
|
|
|
|
|
|
public export
|
2021-07-09 11:06:27 +03:00
|
|
|
ltesuccinjective : {0 n, m : Nat} -> Not (LTE n m) -> Not (LTE (S n) (S m))
|
2021-02-16 14:56:43 +03:00
|
|
|
ltesuccinjective disprf (LTESucc nLTEm) = void (disprf nLTEm)
|
|
|
|
ltesuccinjective disprf LTEZero impossible
|
2020-08-19 00:26:56 +03:00
|
|
|
|
2021-10-24 14:06:57 +03:00
|
|
|
-- Remove any time after release of 0.6.0
|
|
|
|
||| Deprecated. Use `Nat.isLTE`.
|
2020-08-19 00:26:56 +03:00
|
|
|
public export
|
2021-07-09 11:06:27 +03:00
|
|
|
decideLTE : (n : Nat) -> (m : Nat) -> Dec (LTE n m)
|
2021-10-24 14:06:57 +03:00
|
|
|
decideLTE = isLTE
|
2020-08-19 00:26:56 +03:00
|
|
|
|
|
|
|
public export
|
2021-07-09 11:06:27 +03:00
|
|
|
Decidable 2 [Nat,Nat] LTE where
|
2020-08-19 00:26:56 +03:00
|
|
|
decide = decideLTE
|
|
|
|
|
2021-07-26 21:12:05 +03:00
|
|
|
public export
|
|
|
|
Decidable 2 [Nat,Nat] LT where
|
|
|
|
decide m = decideLTE (S m)
|
|
|
|
|
2020-08-19 00:26:56 +03:00
|
|
|
public export
|
|
|
|
lte : (m : Nat) -> (n : Nat) -> Dec (LTE m n)
|
|
|
|
lte m n = decide {ts = [Nat,Nat]} {p = LTE} m n
|
|
|
|
|
|
|
|
public export
|
|
|
|
shift : (m : Nat) -> (n : Nat) -> LTE m n -> LTE (S m) (S n)
|
|
|
|
shift m n mLTEn = LTESucc mLTEn
|