Allen's thirteen relations between two spans, their inverses and their composition, and the everyday predicates as sets of them.
A span is [from, to). The relation of two spans is read from four
comparisons, start against start, end against end, the first's end against
the second's start and the first's start against the second's end
(relation/2); every pair of spans stands in exactly one relation. The
composition table is derived from the classifier when this module compiles,
so the two cannot disagree. The everyday predicates (before?/2, within?/2,
...) are the sets of relations Tempo.before?/2 and its companions answer
by for two single spans.
Summary
Functions
The composition of two relations: the relations a first span may stand in to a third, given its relation to a second and the second's to the third.
Whether the first span contains the second, under Allen's own name.
Whether the first span during the second, under Allen's own name.
Whether the first span equals the second, under Allen's own name.
Whether the first span finished by the second, under Allen's own name.
Whether the first span finishes the second, under Allen's own name.
Whether a predicate or a relation holds between two spans.
The inverse of a relation: the relation of the second span to the first.
Whether the first span meets the second, under Allen's own name.
Whether the first span met by the second, under Allen's own name.
Whether the first span overlapped by the second, under Allen's own name.
Whether the first span overlaps the second, under Allen's own name.
Whether the first span preceded by the second, under Allen's own name.
Whether the first span precedes the second, under Allen's own name.
The relations an everyday predicate stands for.
The everyday predicates: :before, :after, :adjacent, :within,
:contains, :disjoint, :overlaps and :equal.
The relation of one span to another, from four comparisons.
The thirteen relations, in Allen's order.
Whether the first span started by the second, under Allen's own name.
Whether the first span starts the second, under Allen's own name.
Types
@type predicate() ::
:before
| :after
| :adjacent
| :within
| :contains
| :disjoint
| :overlaps
| :equal
@type relation() ::
:precedes
| :meets
| :overlaps
| :finished_by
| :contains
| :starts
| :equals
| :started_by
| :during
| :finishes
| :overlapped_by
| :met_by
| :preceded_by
A span as two positions on one frame, {from, to}, half-open.
Functions
The composition of two relations: the relations a first span may stand in to a third, given its relation to a second and the second's to the third.
Arguments
firstis therelation/0of the first span to the second.secondis therelation/0of the second span to the third.
Returns
- The
relation/0atoms the first span may stand in to the third, in Allen's order.
Examples
iex> Tempo.Allen.compose(:precedes, :precedes)
[:precedes]
iex> Tempo.Allen.compose(:equals, :during)
[:during]
iex> Tempo.Allen.compose(:overlaps, :overlaps)
[:precedes, :meets, :overlaps]
Whether the first span contains the second, under Allen's own name.
Arguments
aandbare each aTempo.t/0that names one span, or each aspan/0, as forrelation/2.
Returns
truewhen the relation ofatobis:contains, andfalsewhen it is not.
Examples
iex> Tempo.Allen.contains?({1, 5}, {2, 3})
true
Whether the first span during the second, under Allen's own name.
Arguments
aandbare each aTempo.t/0that names one span, or each aspan/0, as forrelation/2.
Returns
truewhen the relation ofatobis:during, andfalsewhen it is not.
Examples
iex> Tempo.Allen.during?({2, 3}, {1, 5})
true
Whether the first span equals the second, under Allen's own name.
Arguments
aandbare each aTempo.t/0that names one span, or each aspan/0, as forrelation/2.
Returns
truewhen the relation ofatobis:equals, andfalsewhen it is not.
Examples
iex> Tempo.Allen.equals?({1, 3}, {1, 3})
true
Whether the first span finished by the second, under Allen's own name.
Arguments
aandbare each aTempo.t/0that names one span, or each aspan/0, as forrelation/2.
Returns
truewhen the relation ofatobis:finished_by, andfalsewhen it is not.
Examples
iex> Tempo.Allen.finished_by?({1, 5}, {3, 5})
true
Whether the first span finishes the second, under Allen's own name.
Arguments
aandbare each aTempo.t/0that names one span, or each aspan/0, as forrelation/2.
Returns
truewhen the relation ofatobis:finishes, andfalsewhen it is not.
Examples
iex> Tempo.Allen.finishes?({3, 5}, {1, 5})
true
Whether a predicate or a relation holds between two spans.
Arguments
nameis apredicate/0or arelation/0.aandbare each aTempo.t/0that names one span, or each aspan/0, as forrelation/2.
Returns
truewhen the relation ofatobis one the name stands for, andfalsewhen it is not.
Examples
iex> Tempo.Allen.holds?(:before, {1, 3}, {3, 5})
true
iex> Tempo.Allen.holds?(:precedes, {1, 3}, {3, 5})
false
The inverse of a relation: the relation of the second span to the first.
Arguments
relationis arelation/0.
Returns
- The
relation/0the second span stands in to the first.
Examples
iex> Tempo.Allen.inverse(:precedes)
:preceded_by
iex> Tempo.Allen.inverse(:equals)
:equals
Whether the first span meets the second, under Allen's own name.
Arguments
aandbare each aTempo.t/0that names one span, or each aspan/0, as forrelation/2.
Returns
truewhen the relation ofatobis:meets, andfalsewhen it is not.
Examples
iex> Tempo.Allen.meets?({1, 3}, {3, 5})
true
Whether the first span met by the second, under Allen's own name.
Arguments
aandbare each aTempo.t/0that names one span, or each aspan/0, as forrelation/2.
Returns
truewhen the relation ofatobis:met_by, andfalsewhen it is not.
Examples
iex> Tempo.Allen.met_by?({3, 5}, {1, 3})
true
Whether the first span overlapped by the second, under Allen's own name.
Arguments
aandbare each aTempo.t/0that names one span, or each aspan/0, as forrelation/2.
Returns
truewhen the relation ofatobis:overlapped_by, andfalsewhen it is not.
Examples
iex> Tempo.Allen.overlapped_by?({3, 6}, {1, 4})
true
Whether the first span overlaps the second, under Allen's own name.
Arguments
aandbare each aTempo.t/0that names one span, or each aspan/0, as forrelation/2.
Returns
truewhen the relation ofatobis:overlaps, andfalsewhen it is not.
Examples
iex> Tempo.Allen.overlaps?({1, 4}, {3, 6})
true
Whether the first span preceded by the second, under Allen's own name.
Arguments
aandbare each aTempo.t/0that names one span, or each aspan/0, as forrelation/2.
Returns
truewhen the relation ofatobis:preceded_by, andfalsewhen it is not.
Examples
iex> Tempo.Allen.preceded_by?({3, 4}, {1, 2})
true
Whether the first span precedes the second, under Allen's own name.
Arguments
aandbare each aTempo.t/0that names one span, or each aspan/0, as forrelation/2.
Returns
truewhen the relation ofatobis:precedes, andfalsewhen it is not.
Examples
iex> Tempo.Allen.precedes?({1, 2}, {3, 4})
true
The relations an everyday predicate stands for.
Arguments
nameis apredicate/0, or arelation/0, which stands for itself.
Returns
- The
relation/0atoms the predicate holds for.
Examples
iex> Tempo.Allen.predicate(:within)
[:equals, :starts, :during, :finishes]
iex> Tempo.Allen.predicate(:meets)
[:meets]
@spec predicates() :: [predicate(), ...]
The everyday predicates: :before, :after, :adjacent, :within,
:contains, :disjoint, :overlaps and :equal.
Returns
- A list of the
predicate/0atoms.
Examples
iex> :within in Tempo.Allen.predicates()
true
The relation of one span to another, from four comparisons.
Arguments
Returns
- One of the thirteen
relation/0atoms. For two expressions it is whatTempo.relation/2answers, and the error that would return is raised; a value that is neither an expression nor a span raises aTempo.ConversionError.
Examples
iex> Tempo.Allen.relation(~o"2026-01", ~o"2026-02")
:meets
iex> Tempo.Allen.relation({1, 3}, {3, 5})
:meets
iex> Tempo.Allen.relation({1, 5}, {2, 3})
:contains
iex> Tempo.Allen.relation({2, 3}, {1, 5})
:during
@spec relations() :: [relation(), ...]
The thirteen relations, in Allen's order.
Returns
- A list of the thirteen
relation/0atoms.
Examples
iex> length(Tempo.Allen.relations())
13
iex> hd(Tempo.Allen.relations())
:precedes
Whether the first span started by the second, under Allen's own name.
Arguments
aandbare each aTempo.t/0that names one span, or each aspan/0, as forrelation/2.
Returns
truewhen the relation ofatobis:started_by, andfalsewhen it is not.
Examples
iex> Tempo.Allen.started_by?({1, 5}, {1, 3})
true
Whether the first span starts the second, under Allen's own name.
Arguments
aandbare each aTempo.t/0that names one span, or each aspan/0, as forrelation/2.
Returns
truewhen the relation ofatobis:starts, andfalsewhen it is not.
Examples
iex> Tempo.Allen.starts?({1, 3}, {1, 5})
true