on master help sign in
Merge pull request #3941 from ruippeixotog/if-not-lt-then-gte

Add notLTImpliesGTE to Prelude

commitb352960b4b70146ebd6b748f7ed4093786a5c5c8 authorAhmad Salim Al-Sibahi <asal@itu.dk> dateThu 17 Aug 2017, 16:16 (9 years ago) parent8b60548b7c0ee9
1 file changed+5
libs/prelude/Prelude/Nat.idr+5
libs/prelude/Prelude/Nat.idr+5
@@ -160,6 +160,11 @@ lteAddRight : (n : Nat) -> LTE n (plus n m)
160160lteAddRight Z = LTEZero
161161lteAddRight (S k) = LTESucc (lteAddRight k)
162162
163+||| If a number is not less than another, it is greater than or equal to it
164+notLTImpliesGTE : Not (LT a b) -> GTE a b
165+notLTImpliesGTE {b = Z} _ = LTEZero
166+notLTImpliesGTE {a = Z} {b = S k} notLt = absurd (notLt (LTESucc LTEZero))
167+notLTImpliesGTE {a = S k} {b = S j} notLt = LTESucc (notLTImpliesGTE (notLt . LTESucc))
163168
164169||| Boolean test than one Nat is less than or equal to another
165170total lte : Nat -> Nat -> Bool