-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Interval arithmetic for both open and closed intervals
--
-- Interval datatype and interval arithmetic for Haskell. Unlike the
-- intervals package
-- (http://hackage.haskell.org/package/intervals), this package
-- provides both open and closed intervals and is intended to be used
-- with exact number types such as Rational and Integer.
@package data-interval
@version 1.2.0
-- | Interval datatype and interval arithmetic.
--
-- Unlike the intervals package
-- (http://hackage.haskell.org/package/intervals), this module
-- provides both open and closed intervals and is intended to be used
-- with Rational.
--
-- For the purpose of abstract interpretation, it might be convenient to
-- use Lattice instance. See also lattices package
-- (http://hackage.haskell.org/package/lattices).
module Data.Interval
-- | The intervals (i.e. connected and convex subsets) over real
-- numbers R.
data Interval r
-- | Endpoints of intervals
-- | Deprecated: EndPoint is deprecated. Please use Extended
-- instead.
type EndPoint r = Extended r
-- | smart constructor for Interval
interval :: Ord r => (Extended r, Bool) -> (Extended r, Bool) -> Interval r
-- | closed interval [l,u]
(<=..<=) :: Ord r => Extended r -> Extended r -> Interval r
-- | left-open right-closed interval (l,u]
(<..<=) :: Ord r => Extended r -> Extended r -> Interval r
-- | left-closed right-open interval [l, u)
(<=..<) :: Ord r => Extended r -> Extended r -> Interval r
-- | open interval (l, u)
(<..<) :: Ord r => Extended r -> Extended r -> Interval r
-- | whole real number line (-∞, ∞)
whole :: Ord r => Interval r
-- | empty (contradicting) interval
empty :: Ord r => Interval r
-- | singleton set [x,x]
singleton :: Ord r => r -> Interval r
-- | Is the interval empty?
null :: Ord r => Interval r -> Bool
-- | Is the element in the interval?
member :: Ord r => r -> Interval r -> Bool
-- | Is the element not in the interval?
notMember :: Ord r => r -> Interval r -> Bool
-- | Is this a subset? (i1 `isSubsetOf` i2) tells whether
-- i1 is a subset of i2.
isSubsetOf :: Ord r => Interval r -> Interval r -> Bool
-- | Is this a proper subset? (i.e. a subset but not equal).
isProperSubsetOf :: Ord r => Interval r -> Interval r -> Bool
-- | Lower endpoint (i.e. greatest lower bound) of the interval.
--
--
lowerBound :: Interval r -> Extended r
-- | Upper endpoint (i.e. least upper bound) of the interval.
--
--
upperBound :: Interval r -> Extended r
-- | lowerBound of the interval and whether it is included in the
-- interval. The result is convenient to use as an argument for
-- interval.
lowerBound' :: Interval r -> (Extended r, Bool)
-- | upperBound of the interval and whether it is included in the
-- interval. The result is convenient to use as an argument for
-- interval.
upperBound' :: Interval r -> (Extended r, Bool)
-- | Width of a interval. Width of an unbounded interval is
-- undefined.
width :: (Num r, Ord r) => Interval r -> r
-- | For all x in X, y in Y. x
-- < y?
( Interval r -> Interval r -> Bool
-- | For all x in X, y in Y. x
-- <= y?
(<=!) :: Ord r => Interval r -> Interval r -> Bool
-- | For all x in X, y in Y. x
-- == y?
(==!) :: Ord r => Interval r -> Interval r -> Bool
-- | For all x in X, y in Y. x
-- >= y?
(>=!) :: Ord r => Interval r -> Interval r -> Bool
-- | For all x in X, y in Y. x
-- > y?
(>!) :: Ord r => Interval r -> Interval r -> Bool
-- | For all x in X, y in Y. x
-- /= y?
--
-- Since 1.0.1
(/=!) :: Ord r => Interval r -> Interval r -> Bool
-- | Does there exist an x in X, y in Y
-- such that x < y?
() :: Ord r => Interval r -> Interval r -> Bool
-- | Does there exist an x in X, y in Y
-- such that x <= y?
(<=?) :: Ord r => Interval r -> Interval r -> Bool
-- | Does there exist an x in X, y in Y
-- such that x == y?
--
-- Since 1.0.0
(==?) :: Ord r => Interval r -> Interval r -> Bool
-- | Does there exist an x in X, y in Y
-- such that x >= y?
(>=?) :: Ord r => Interval r -> Interval r -> Bool
-- | Does there exist an x in X, y in Y
-- such that x > y?
(>?) :: Ord r => Interval r -> Interval r -> Bool
-- | Does there exist an x in X, y in Y
-- such that x /= y?
--
-- Since 1.0.1
(/=?) :: Ord r => Interval r -> Interval r -> Bool
-- | Does there exist an x in X, y in Y
-- such that x < y?
--
-- Since 1.0.0
(?) :: (Real r, Fractional r) => Interval r -> Interval r -> Maybe (r, r)
-- | Does there exist an x in X, y in Y
-- such that x <= y?
--
-- Since 1.0.0
(<=??) :: (Real r, Fractional r) => Interval r -> Interval r -> Maybe (r, r)
-- | Does there exist an x in X, y in Y
-- such that x == y?
--
-- Since 1.0.0
(==??) :: (Real r, Fractional r) => Interval r -> Interval r -> Maybe (r, r)
-- | Does there exist an x in X, y in Y
-- such that x >= y?
--
-- Since 1.0.0
(>=??) :: (Real r, Fractional r) => Interval r -> Interval r -> Maybe (r, r)
-- | Does there exist an x in X, y in Y
-- such that x > y?
--
-- Since 1.0.0
(>??) :: (Real r, Fractional r) => Interval r -> Interval r -> Maybe (r, r)
-- | Does there exist an x in X, y in Y
-- such that x /= y?
--
-- Since 1.0.1
(/=??) :: (Real r, Fractional r) => Interval r -> Interval r -> Maybe (r, r)
-- | intersection of two intervals
intersection :: Ord r => Interval r -> Interval r -> Interval r
-- | intersection of a list of intervals.
--
-- Since 0.6.0
intersections :: Ord r => [Interval r] -> Interval r
-- | convex hull of two intervals
hull :: Ord r => Interval r -> Interval r -> Interval r
-- | convex hull of a list of intervals.
--
-- Since 0.6.0
hulls :: Ord r => [Interval r] -> Interval r
-- | pick up an element from the interval if the interval is not empty.
pickup :: (Real r, Fractional r) => Interval r -> Maybe r
-- | simplestRationalWithin returns the simplest rational number
-- within the interval.
--
-- A rational number y is said to be simpler than another
-- y' if
--
--
--
-- (see also approxRational)
--
-- Since 0.4.0
simplestRationalWithin :: RealFrac r => Interval r -> Maybe Rational
instance Typeable Interval
instance Eq r => Eq (Interval r)
instance (Real r, Fractional r) => Fractional (Interval r)
instance (Num r, Ord r) => Num (Interval r)
instance (Ord r, Data r) => Data (Interval r)
instance (Ord r, Read r) => Read (Interval r)
instance (Ord r, Show r) => Show (Interval r)
instance Ord r => BoundedLattice (Interval r)
instance Ord r => BoundedMeetSemiLattice (Interval r)
instance Ord r => BoundedJoinSemiLattice (Interval r)
instance Ord r => Lattice (Interval r)
instance Ord r => MeetSemiLattice (Interval r)
instance Ord r => JoinSemiLattice (Interval r)
instance Hashable r => Hashable (Interval r)
instance NFData r => NFData (Interval r)
-- | Interval datatype and interval arithmetic over integers.
--
-- Since 1.2.0
--
-- For the purpose of abstract interpretation, it might be convenient to
-- use Lattice instance. See also lattices package
-- (http://hackage.haskell.org/package/lattices).
module Data.IntegerInterval
-- | The intervals (i.e. connected and convex subsets) over integers
-- (Z).
data IntegerInterval
-- | smart constructor for Interval
interval :: (Extended Integer, Bool) -> (Extended Integer, Bool) -> IntegerInterval
-- | closed interval [l,u]
(<=..<=) :: Extended Integer -> Extended Integer -> IntegerInterval
-- | left-open right-closed interval (l,u]
(<..<=) :: Extended Integer -> Extended Integer -> IntegerInterval
-- | left-closed right-open interval [l, u)
(<=..<) :: Extended Integer -> Extended Integer -> IntegerInterval
-- | open interval (l, u)
(<..<) :: Extended Integer -> Extended Integer -> IntegerInterval
-- | whole real number line (-∞, ∞)
whole :: IntegerInterval
-- | empty (contradicting) interval
empty :: IntegerInterval
-- | singleton set [x,x]
singleton :: Integer -> IntegerInterval
-- | Is the interval empty?
null :: IntegerInterval -> Bool
-- | Is the element in the interval?
member :: Integer -> IntegerInterval -> Bool
-- | Is the element not in the interval?
notMember :: Integer -> IntegerInterval -> Bool
-- | Is this a subset? (i1 `isSubsetOf` i2) tells whether
-- i1 is a subset of i2.
isSubsetOf :: IntegerInterval -> IntegerInterval -> Bool
-- | Is this a proper subset? (i.e. a subset but not equal).
isProperSubsetOf :: IntegerInterval -> IntegerInterval -> Bool
-- | Lower endpoint (i.e. greatest lower bound) of the interval.
--
--
lowerBound :: IntegerInterval -> Extended Integer
-- | Upper endpoint (i.e. least upper bound) of the interval.
--
--
upperBound :: IntegerInterval -> Extended Integer
-- | lowerBound of the interval and whether it is included in the
-- interval. The result is convenient to use as an argument for
-- interval.
lowerBound' :: IntegerInterval -> (Extended Integer, Bool)
-- | upperBound of the interval and whether it is included in the
-- interval. The result is convenient to use as an argument for
-- interval.
upperBound' :: IntegerInterval -> (Extended Integer, Bool)
-- | Width of a interval. Width of an unbounded interval is
-- undefined.
width :: IntegerInterval -> Integer
-- | For all x in X, y in Y. x
-- < y?
( IntegerInterval -> Bool
-- | For all x in X, y in Y. x
-- <= y?
(<=!) :: IntegerInterval -> IntegerInterval -> Bool
-- | For all x in X, y in Y. x
-- == y?
(==!) :: IntegerInterval -> IntegerInterval -> Bool
-- | For all x in X, y in Y. x
-- >= y?
(>=!) :: IntegerInterval -> IntegerInterval -> Bool
-- | For all x in X, y in Y. x
-- > y?
(>!) :: IntegerInterval -> IntegerInterval -> Bool
-- | For all x in X, y in Y. x
-- /= y?
(/=!) :: IntegerInterval -> IntegerInterval -> Bool
-- | Does there exist an x in X, y in Y
-- such that x < y?
() :: IntegerInterval -> IntegerInterval -> Bool
-- | Does there exist an x in X, y in Y
-- such that x <= y?
(<=?) :: IntegerInterval -> IntegerInterval -> Bool
-- | Does there exist an x in X, y in Y
-- such that x == y?
(==?) :: IntegerInterval -> IntegerInterval -> Bool
-- | Does there exist an x in X, y in Y
-- such that x >= y?
(>=?) :: IntegerInterval -> IntegerInterval -> Bool
-- | Does there exist an x in X, y in Y
-- such that x > y?
(>?) :: IntegerInterval -> IntegerInterval -> Bool
-- | Does there exist an x in X, y in Y
-- such that x /= y?
(/=?) :: IntegerInterval -> IntegerInterval -> Bool
-- | Does there exist an x in X, y in Y
-- such that x < y?
(?) :: IntegerInterval -> IntegerInterval -> Maybe (Integer, Integer)
-- | Does there exist an x in X, y in Y
-- such that x <= y?
(<=??) :: IntegerInterval -> IntegerInterval -> Maybe (Integer, Integer)
-- | Does there exist an x in X, y in Y
-- such that x == y?
(==??) :: IntegerInterval -> IntegerInterval -> Maybe (Integer, Integer)
-- | Does there exist an x in X, y in Y
-- such that x >= y?
(>=??) :: IntegerInterval -> IntegerInterval -> Maybe (Integer, Integer)
-- | Does there exist an x in X, y in Y
-- such that x > y?
(>??) :: IntegerInterval -> IntegerInterval -> Maybe (Integer, Integer)
-- | Does there exist an x in X, y in Y
-- such that x /= y?
(/=??) :: IntegerInterval -> IntegerInterval -> Maybe (Integer, Integer)
-- | intersection of two intervals
intersection :: IntegerInterval -> IntegerInterval -> IntegerInterval
-- | intersection of a list of intervals.
intersections :: [IntegerInterval] -> IntegerInterval
-- | convex hull of two intervals
hull :: IntegerInterval -> IntegerInterval -> IntegerInterval
-- | convex hull of a list of intervals.
hulls :: [IntegerInterval] -> IntegerInterval
-- | pick up an element from the interval if the interval is not empty.
pickup :: IntegerInterval -> Maybe Integer
-- | simplestIntegerWithin returns the simplest rational number
-- within the interval.
--
-- An integer y is said to be simpler than another
-- y' if
--
--
--
-- (see also approxRational)
simplestIntegerWithin :: IntegerInterval -> Maybe Integer
-- | Convert the interval to Interval data type.
toInterval :: Real r => IntegerInterval -> Interval r
-- | Conversion from Interval data type.
fromInterval :: Interval Integer -> IntegerInterval
-- | Given a Interval I over R, compute the smallest
-- IntegerInterval J such that I ⊆ J.
fromIntervalOver :: RealFrac r => Interval r -> IntegerInterval
-- | Given a Interval I over R, compute the largest
-- IntegerInterval J such that J ⊆ I.
fromIntervalUnder :: RealFrac r => Interval r -> IntegerInterval
instance Typeable IntegerInterval
instance Eq IntegerInterval
instance Num IntegerInterval
instance Data IntegerInterval
instance Read IntegerInterval
instance Show IntegerInterval
instance BoundedLattice IntegerInterval
instance BoundedMeetSemiLattice IntegerInterval
instance BoundedJoinSemiLattice IntegerInterval
instance Lattice IntegerInterval
instance MeetSemiLattice IntegerInterval
instance JoinSemiLattice IntegerInterval
instance Hashable IntegerInterval
instance NFData IntegerInterval