I have a function which subtracts two Nat
s. How do I prove that first argument I'm passing to it is actually smaller than the second
dummy : (k : Nat) -> (n : Nat) -> {auto smaller : LTE k n} -> Nat
dummy k n = n - k
I've tried couple of solutions which don't work
smallerThan : (k : Nat) -> (n : Nat) -> Maybe (LTE k n)
smallerThan Z k = Just (LTEZero {right=k})
smallerThan (S k) Z = Nothing
smallerThan (S k) (S n) = case isLTE k n of
Yes prf => Just prf
No contra => Nothing
smallerThan (S k) (S n) = case smallerThan k n of
Nothing => Nothing
Just lte => Just (cong lte)
I know that type of my hole smallerThan (S k) (S n) = Just (?hole)
is LTE (S k) (S n)
but how to properly use fromLteSucc
or any other function in order to implement that?
I've found this question but that was solved without the proof I need.
Could you provide a hints of what I'm doing wrong and how to properly implement this kind of check?