# Mathematical Background
## πerminology
The pair of two elements is called a `Slot` if the following conditions are met
- each element is either `nil` or an instance of a datetime with defined timezone
- if both elements are datetimes, the first element does not superseed the second one
- if either element is `nil`, the `Slot` is called _open_, if both are `nil`, itβs called _identity_
`Slot` id denoted `[from β to]`. Letβs define a binary _union_ operation on slots, denoted `βͺ`. Slots do not form a group with `βͺ`, but sorted sets of slots of arbitrary length having no joint slots (denoted `π₯` or more verbose `π₯[[fromβ, toβ], [fromβ, toβ], β¦]`) do indeed form a group, denoted `π`, together with a binary operation `βͺ` on `π`, such as the following group axioms are satisfied:
### Associativity
β π₯β, π₯β, π₯β β π, (π₯β βͺ π₯β) βͺ π₯β = π₯β βͺ (π₯β βͺ π₯β)
### Identity element
β π₯β β π (`π₯[]`) such that, for every π₯ in π, (π₯ βͺ π₯β) = (π₯β βͺ π₯) = π₯
### Inverse element
For each π₯ in π, there exist π₯Β―ΒΉ such that π₯ βͺ π₯Β―ΒΉ = π₯Β―ΒΉ βͺ π₯ = π₯β
That said, slots form an Abelian group with union binary operation and empty set as identity element.
## Slots Semigroup
Slots themselves form a semigroup with a binary union operation, an identity element `[nil β nil]`, without inverse.
## Binary Operation
β π₯β = π₯[[fromβ β toβ]], π₯β = π₯[[fromβ β toβ]] β π, π₯β βͺ π₯β is defined as
- π₯[[fromβ β toβ], [fromβ β toβ]] if toβ < fromβ
- π₯[[fromβ β toβ], [fromβ β toβ]] if toβ < fromβ
- π₯[[min(fromβ, fromβ) β max(toβ β toβ)]] otherwise
`nil` is considered to be less than any datetime _and_ greater than any datetime, thus `π₯[[nil β toβ]] βͺ π₯[[fromβ β toβ]]` would be either `π₯[[nil β max(toβ, toβ)]]` if `toβ > fromβ` or `π₯[[nil β toβ], [fromβ β toβ]]` otherwise.
## Mergeability
Once `π` is a group, each two elements of it _might be merged_. Even if they are infinite. Thatβs why `Stream` implementation of `π` exists.