Byte sized idris: How to handle impossible cases.

lteMagnitudeObvIsImpossible : (b : Nat) -> (v : Bin) -> LTE (magnitude (O b v)) 0 -> Void 
lteMagnitudeObvIsImpossible Z v =
succNotLTEzero
lteMagnitudeObvIsImpossible (S b) v =
succNotLTEzero
smallerNumberMeansFitsInNBits : (n : Nat) -> (a : Bin) -> LTE (magnitude a) n -> binToList (magnitude a) a = binToList n a 
smallerNumberMeansFitsInNBits n BNil lte =
rewrite binToListZeroIsEmpty n in
Refl
smallerNumberMeansFitsInNBits Z (O b v) lte =
absurd (lteMagnitudeObvIsImpossible b v lte)

An old programmer learning new tricks.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
art yerkes

art yerkes

An old programmer learning new tricks.

More from Medium

Email Spoofing 101: Methods of Prevention

Animation Domination Part 3: Top 25 Best Animated Feature Films of all time.

Why CPQ Integration for Manufacturers Can’t Be Missed

Questions I ask to scope a new project in g0v hackathon (in 1–2 hr)