interval-algebra: An implementation of Allen's interval algebra for temporal logic

[ algebra, bsd3, library, program, time ] [ Propose Tags ]
Versions [RSS] 0.1.2, 0.2.0, 0.3.0, 0.3.1, 0.3.2, 0.3.3, 0.4.0, 0.5.0, 0.6.0, 0.6.1, 0.6.2, 0.6.3, 0.7.0, 0.7.1, 0.8.0, 0.8.1, 0.8.2, 0.8.3, 0.8.4, 0.8.5, 0.8.6, 0.9.0, 0.10.0, 0.10.1, 0.10.2, 1.0.0, 1.0.1, 1.1.0, 1.1.1, 1.1.2, 1.1.3, 1.2.0, 1.3.0, 1.4.0, 2.0.0, 2.0.1, 2.0.2, 2.1.0, 2.1.1, 2.1.2, 2.1.3, 2.2.0
Change log
Dependencies base (>=4.7 && <5), binary (>=0.8 && <0.9), containers (>=0.6 && <0.7), deepseq (>=1.1 && <1.5), foldl (>=1.4 && <1.5), interval-algebra, prettyprinter (>=1.7 && <1.8), QuickCheck (>=2.14 && <2.15), text (>=1.2 && <1.3 || >=2.0 && <2.1), time (>=1.9 && <2) [details]
License BSD-3-Clause
Copyright (c) NoviSci 2020-2022, Target RWE 2023
Author Bradley Saul, Brendan Brown
Maintainer <> 2020-2022, <> 2023
Category Algebra, Time
Home page
Bug tracker
Source repo head: git clone
Uploaded by brendanrbrown at 2023-05-26T12:21:22Z
Reverse Dependencies 1 direct, 0 indirect [details]
Executables tutorial
Downloads 8610 total (162 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for interval-algebra-2.2.0

[back to package description]


The interval-algebra package implements Allen's interval algebra in Haskell, for a canonical representation of intervals as a pair of points representing a begin and an end. The main module provides data types and related classes for the interval-based temporal logic described in Allen (1983) and axiomatized in Allen and Hayes (1987). A good primer on Allen's algebra can be found here.


The module provides an Interval type wrapping the most basic type of interval needed for the relation algebra defined in the papers cited above. Interval a wraps (a, a), giving the interval's begin and end points.

However, the module provides typeclasses to generalize an Interval and the interval algebra for temporal logic:

  1. Iv provides an abstract interface for defining the 13 relations of the interval algebra. Instances are provided for the canonical Interval a, when a is an instance of Ord, as described in Allen 1983. However, the interval algebra can be used for temporal logic on "intervals" that are qualitative and not represented as pairs of points in an ordered set, as provided in examples of that paper.
  2. PointedIv is an interface for types that, in effect, be cast to the canonical Interval.
  3. SizedIv provides a generic interface for creating and manipulating PointedIv intervals. In particular, when the interval type also is an instance of Iv, it specifies class properties to ensure intervals created or altered via its methods are valid for the purpose using the interval algebra.
  4. Intervallic provides an interface for data structures which contain an Interval, allowing the relation algebra to be performed relative to the Interval within. The PairedInterval defined here is the prototypical case.

The module defines instances of the classes above for Interval a, and only provides SizedIv (Interval a) instances for a few common a. See class documentation for examples of other possible use-cases. It also defines a variety of ways to construct valid Interval a values for supported point types a.

The loose naming convention is: "Bare" names such as starts or contains are generalized over Intervallic and their Iv* class counterparts start with iv, for example ivStarts and ivContains.

Axiom tests

The package includes tests that the functions of the IntervalAlgebraic typeclass meets the axioms for intervals (not points) as laid out in Allen and Hayes (1987).


interval-algebra differs from data-interval mainly in that it is more general and has as its starting point the relation algebra from Allen 1983. The latter package provides an interval type that is tied to the notion of an interval as a connected convex subset of the integer or real lines, differentiating for example between closed and open endpoints. It provides a Relation type codifying the 13 temporal relations from Allen 1983.

For use-cases where that structure is meaningful, data-interval might be a more natural choice. interval-algebra might be used instead when more abstract concepts are needed or there is no need for the notion of connectedness between the starting and ending points.

An important difference is that data-interval supports empty intervals. interval-algebra does not, since Allen's interval relations cannot be defined for such intervals.