Copyright | (c) Masahiro Sakai 2011-2014 |
---|---|
License | BSD-style |
Maintainer | masahiro.sakai@gmail.com |
Stability | provisional |
Portability | non-portable (ScopedTypeVariables, DeriveDataTypeable) |
Safe Haskell | Safe |
Language | Haskell2010 |
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
).
Synopsis
- data IntegerInterval
- module Data.ExtendedReal
- data Boundary
- interval :: ( Extended Integer , Boundary ) -> ( Extended Integer , Boundary ) -> IntegerInterval
- (<=..<=) :: Extended Integer -> Extended Integer -> IntegerInterval
- (<..<=) :: Extended Integer -> Extended Integer -> IntegerInterval
- (<=..<) :: Extended Integer -> Extended Integer -> IntegerInterval
- (<..<) :: Extended Integer -> Extended Integer -> IntegerInterval
- whole :: IntegerInterval
- empty :: IntegerInterval
- singleton :: Integer -> IntegerInterval
- null :: IntegerInterval -> Bool
- isSingleton :: IntegerInterval -> Bool
- member :: Integer -> IntegerInterval -> Bool
- notMember :: Integer -> IntegerInterval -> Bool
- isSubsetOf :: IntegerInterval -> IntegerInterval -> Bool
- isProperSubsetOf :: IntegerInterval -> IntegerInterval -> Bool
- isConnected :: IntegerInterval -> IntegerInterval -> Bool
- lowerBound :: IntegerInterval -> Extended Integer
- upperBound :: IntegerInterval -> Extended Integer
- lowerBound' :: IntegerInterval -> ( Extended Integer , Boundary )
- upperBound' :: IntegerInterval -> ( Extended Integer , Boundary )
- width :: IntegerInterval -> Integer
- (<!) :: IntegerInterval -> IntegerInterval -> Bool
- (<=!) :: IntegerInterval -> IntegerInterval -> Bool
- (==!) :: IntegerInterval -> IntegerInterval -> Bool
- (>=!) :: IntegerInterval -> IntegerInterval -> Bool
- (>!) :: IntegerInterval -> IntegerInterval -> Bool
- (/=!) :: IntegerInterval -> IntegerInterval -> Bool
- (<?) :: IntegerInterval -> IntegerInterval -> Bool
- (<=?) :: IntegerInterval -> IntegerInterval -> Bool
- (==?) :: IntegerInterval -> IntegerInterval -> Bool
- (>=?) :: IntegerInterval -> IntegerInterval -> Bool
- (>?) :: IntegerInterval -> IntegerInterval -> Bool
- (/=?) :: IntegerInterval -> IntegerInterval -> Bool
- (<??) :: IntegerInterval -> IntegerInterval -> Maybe ( Integer , Integer )
- (<=??) :: IntegerInterval -> IntegerInterval -> Maybe ( Integer , Integer )
- (==??) :: IntegerInterval -> IntegerInterval -> Maybe ( Integer , Integer )
- (>=??) :: IntegerInterval -> IntegerInterval -> Maybe ( Integer , Integer )
- (>??) :: IntegerInterval -> IntegerInterval -> Maybe ( Integer , Integer )
- (/=??) :: IntegerInterval -> IntegerInterval -> Maybe ( Integer , Integer )
- intersection :: IntegerInterval -> IntegerInterval -> IntegerInterval
- intersections :: [ IntegerInterval ] -> IntegerInterval
- hull :: IntegerInterval -> IntegerInterval -> IntegerInterval
- hulls :: [ IntegerInterval ] -> IntegerInterval
- mapMonotonic :: ( Integer -> Integer ) -> IntegerInterval -> IntegerInterval
- pickup :: IntegerInterval -> Maybe Integer
- simplestIntegerWithin :: IntegerInterval -> Maybe Integer
- toInterval :: Real r => IntegerInterval -> Interval r
- fromInterval :: Interval Integer -> IntegerInterval
- fromIntervalOver :: RealFrac r => Interval r -> IntegerInterval
- fromIntervalUnder :: RealFrac r => Interval r -> IntegerInterval
- relate :: IntegerInterval -> IntegerInterval -> Relation
Interval type
data IntegerInterval Source #
The intervals ( i.e. connected and convex subsets) over integers ( Z ).
Instances
module Data.ExtendedReal
Boundary of an interval may be open (excluding an endpoint) or closed (including an endpoint).
Since: 2.0.0
Instances
Construction
:: ( Extended Integer , Boundary ) |
lower bound and whether it is included |
-> ( Extended Integer , Boundary ) |
upper bound and whether it is included |
-> IntegerInterval |
smart constructor for
IntegerInterval
:: Extended Integer |
lower bound
|
-> Extended Integer |
upper bound
|
-> IntegerInterval |
closed interval [
l
,
u
]
:: Extended Integer |
lower bound
|
-> Extended Integer |
upper bound
|
-> IntegerInterval |
left-open right-closed interval (
l
,
u
]
:: Extended Integer |
lower bound
|
-> Extended Integer |
upper bound
|
-> IntegerInterval |
left-closed right-open interval [
l
,
u
)
:: Extended Integer |
lower bound
|
-> Extended Integer |
upper bound
|
-> IntegerInterval |
open interval (
l
,
u
)
whole :: IntegerInterval Source #
whole real number line (-∞, ∞)
empty :: IntegerInterval Source #
empty (contradicting) interval
singleton :: Integer -> IntegerInterval Source #
singleton set [x,x]
Query
null :: IntegerInterval -> Bool Source #
Is the interval empty?
isSingleton :: IntegerInterval -> Bool Source #
Is the interval single point?
Since: 2.0.0
isSubsetOf :: IntegerInterval -> IntegerInterval -> Bool Source #
Is this a subset?
(i1 `
tells whether
isSubsetOf
` i2)
i1
is a subset of
i2
.
isProperSubsetOf :: IntegerInterval -> IntegerInterval -> Bool Source #
Is this a proper subset? ( i.e. a subset but not equal).
isConnected :: IntegerInterval -> IntegerInterval -> Bool Source #
Does the union of two range form a set which is the intersection between the integers and a connected real interval?
lowerBound :: IntegerInterval -> Extended Integer Source #
Lower endpoint ( i.e. greatest lower bound) of the interval.
-
lowerBound
of the empty interval isPosInf
. -
lowerBound
of a left unbounded interval isNegInf
. -
lowerBound
of an interval may or may not be a member of the interval.
upperBound :: IntegerInterval -> Extended Integer Source #
Upper endpoint ( i.e. least upper bound) of the interval.
-
upperBound
of the empty interval isNegInf
. -
upperBound
of a right unbounded interval isPosInf
. -
upperBound
of an interval is a member of the interval.
lowerBound' :: IntegerInterval -> ( Extended Integer , Boundary ) Source #
lowerBound
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 , Boundary ) Source #
upperBound
of the interval and whether it is included in the interval.
The result is convenient to use as an argument for
interval
.
width :: IntegerInterval -> Integer Source #
Width of a interval. Width of an unbounded interval is
undefined
.
Universal comparison operators
(<!) :: IntegerInterval -> IntegerInterval -> Bool infix 4 Source #
For all
x
in
X
,
y
in
Y
.
x
?
<
y
(<=!) :: IntegerInterval -> IntegerInterval -> Bool infix 4 Source #
For all
x
in
X
,
y
in
Y
.
x
?
<=
y
(==!) :: IntegerInterval -> IntegerInterval -> Bool infix 4 Source #
For all
x
in
X
,
y
in
Y
.
x
?
==
y
(>=!) :: IntegerInterval -> IntegerInterval -> Bool infix 4 Source #
For all
x
in
X
,
y
in
Y
.
x
?
>=
y
(>!) :: IntegerInterval -> IntegerInterval -> Bool infix 4 Source #
For all
x
in
X
,
y
in
Y
.
x
?
>
y
(/=!) :: IntegerInterval -> IntegerInterval -> Bool infix 4 Source #
For all
x
in
X
,
y
in
Y
.
x
?
/=
y
Existential comparison operators
(<?) :: IntegerInterval -> IntegerInterval -> Bool infix 4 Source #
Does there exist an
x
in
X
,
y
in
Y
such that
x
?
<
y
(<=?) :: IntegerInterval -> IntegerInterval -> Bool infix 4 Source #
Does there exist an
x
in
X
,
y
in
Y
such that
x
?
<=
y
(==?) :: IntegerInterval -> IntegerInterval -> Bool infix 4 Source #
Does there exist an
x
in
X
,
y
in
Y
such that
x
?
==
y
(>=?) :: IntegerInterval -> IntegerInterval -> Bool infix 4 Source #
Does there exist an
x
in
X
,
y
in
Y
such that
x
?
>=
y
(>?) :: IntegerInterval -> IntegerInterval -> Bool infix 4 Source #
Does there exist an
x
in
X
,
y
in
Y
such that
x
?
>
y
(/=?) :: IntegerInterval -> IntegerInterval -> Bool infix 4 Source #
Does there exist an
x
in
X
,
y
in
Y
such that
x
?
/=
y
Existential comparison operators that produce witnesses (experimental)
(<??) :: IntegerInterval -> IntegerInterval -> Maybe ( Integer , Integer ) infix 4 Source #
Does there exist an
x
in
X
,
y
in
Y
such that
x
?
<
y
(<=??) :: IntegerInterval -> IntegerInterval -> Maybe ( Integer , Integer ) infix 4 Source #
Does there exist an
x
in
X
,
y
in
Y
such that
x
?
<=
y
(==??) :: IntegerInterval -> IntegerInterval -> Maybe ( Integer , Integer ) infix 4 Source #
Does there exist an
x
in
X
,
y
in
Y
such that
x
?
==
y
(>=??) :: IntegerInterval -> IntegerInterval -> Maybe ( Integer , Integer ) infix 4 Source #
Does there exist an
x
in
X
,
y
in
Y
such that
x
?
>=
y
(>??) :: IntegerInterval -> IntegerInterval -> Maybe ( Integer , Integer ) infix 4 Source #
Does there exist an
x
in
X
,
y
in
Y
such that
x
?
>
y
(/=??) :: IntegerInterval -> IntegerInterval -> Maybe ( Integer , Integer ) infix 4 Source #
Does there exist an
x
in
X
,
y
in
Y
such that
x
?
/=
y
Combine
intersection :: IntegerInterval -> IntegerInterval -> IntegerInterval Source #
intersection of two intervals
intersections :: [ IntegerInterval ] -> IntegerInterval Source #
intersection of a list of intervals.
hull :: IntegerInterval -> IntegerInterval -> IntegerInterval Source #
convex hull of two intervals
hulls :: [ IntegerInterval ] -> IntegerInterval Source #
convex hull of a list of intervals.
Map
mapMonotonic :: ( Integer -> Integer ) -> IntegerInterval -> IntegerInterval Source #
mapMonotonic f i
is the image of
i
under
f
, where
f
must be a strict monotone function.
Operations
pickup :: IntegerInterval -> Maybe Integer Source #
pick up an element from the interval if the interval is not empty.
simplestIntegerWithin :: IntegerInterval -> Maybe Integer Source #
simplestIntegerWithin
returns the simplest rational number within the interval.
An integer
y
is said to be
simpler
than another
y'
if
(see also
approxRational
and
simplestRationalWithin
)
Conversion
toInterval :: Real r => IntegerInterval -> Interval r Source #
Convert the interval to
Interval
data type.
fromInterval :: Interval Integer -> IntegerInterval Source #
Conversion from
Interval
data type.
fromIntervalOver :: RealFrac r => Interval r -> IntegerInterval Source #
Given a
Interval
I
over R, compute the smallest
IntegerInterval
J
such that
I ⊆ J
.
fromIntervalUnder :: RealFrac r => Interval r -> IntegerInterval Source #
Given a
Interval
I
over R, compute the largest
IntegerInterval
J
such that
J ⊆ I
.
Intervals relation
relate :: IntegerInterval -> IntegerInterval -> Relation Source #
Computes how two intervals are related according to the
classification
Relation