on master help sign in
Add ifNotLtThenGte to Prelude
commit8f0934c53f96e0e6f12a9ee0ce1d4756699b3f7e authorRui Gonçalves <ruippeixotog@gmail.com> dateSun 23 Jul 2017, 17:22 (9 years ago) parent0f8b4ca
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+ifNotLtThenGte : Not (LT a b) -> GTE a b
165+ifNotLtThenGte {b = Z} _ = LTEZero
166+ifNotLtThenGte {a = Z} {b = S k} notLt = absurd (notLt (LTESucc LTEZero))
167+ifNotLtThenGte {a = S k} {b = S j} notLt = LTESucc (ifNotLtThenGte (notLt . LTESucc))
163168
164169||| Boolean test than one Nat is less than or equal to another
165170total lte : Nat -> Nat -> Bool