{-# language DataKinds #-}
{-# language ExplicitForAll #-}
{-# language KindSignatures #-}
{-# language TypeFamilies #-}
{-# language TypeOperators #-}
module Arithmetic.Lte
(
zero
, reflexive
, substituteL
, substituteR
, incrementL
, incrementR
, decrementL
, decrementR
, weakenL
, weakenR
, transitive
, plus
, fromStrict
, constant
) where
import Arithmetic.Unsafe (type (<)(Lt),type (:=:)(Eq))
import Arithmetic.Unsafe (type (<=)(Lte))
import GHC.TypeNats (CmpNat,type (+))
import qualified GHC.TypeNats as GHC
substituteL :: (b :=: c) -> (b <= a) -> (c <= a)
substituteL Eq Lte = Lte
substituteR :: (b :=: c) -> (a <= b) -> (a <= c)
substituteR Eq Lte = Lte
plus :: (a <= b) -> (c <= d) -> (a + c <= b + d)
plus Lte Lte = Lte
transitive :: (a <= b) -> (b <= c) -> (a <= c)
transitive Lte Lte = Lte
reflexive :: a <= a
reflexive = Lte
incrementL :: forall (c :: GHC.Nat) (a :: GHC.Nat) (b :: GHC.Nat).
(a <= b) -> (c + a <= c + b)
incrementL Lte = Lte
incrementR :: forall (c :: GHC.Nat) (a :: GHC.Nat) (b :: GHC.Nat).
(a <= b) -> (a + c <= b + c)
incrementR Lte = Lte
weakenL :: forall (c :: GHC.Nat) (a :: GHC.Nat) (b :: GHC.Nat).
(a <= b) -> (a <= c + b)
weakenL Lte = Lte
weakenR :: forall (c :: GHC.Nat) (a :: GHC.Nat) (b :: GHC.Nat).
(a <= b) -> (a <= b + c)
weakenR Lte = Lte
decrementL :: forall (c :: GHC.Nat) (a :: GHC.Nat) (b :: GHC.Nat).
(c + a <= c + b) -> (a <= b)
decrementL Lte = Lte
decrementR :: forall (c :: GHC.Nat) (a :: GHC.Nat) (b :: GHC.Nat).
(a + c <= b + c) -> (a <= b)
decrementR Lte = Lte
fromStrict :: (a < b) -> (a <= b)
fromStrict Lt = Lte
zero :: 0 <= a
zero = Lte
constant :: forall a b. (IsLte (CmpNat a b) ~ 'True) => (a <= b)
constant = Lte
type family IsLte (o :: Ordering) :: Bool where
IsLte 'GT = 'False
IsLte 'LT = 'True
IsLte 'EQ = 'True