Interval-union semiring #
This file defines the semiring of finite unions of pairwise-disjoint intervals over a dense linear order, used for provenance in temporal and numeric-range databases.
An IntervalUnion α is a sorted, non-overlapping list of intervals. Addition is union,
multiplication is intersection, and monus is set difference. The natural order is
set inclusion.
Main definitions #
IntervalUnion α– a finite union of pairwise-disjoint, sorted intervalsIntervalUnion.toSet– the corresponding point setIntervalUnion.union– union of two interval unions (addition)IntervalUnion.inter– intersection of two interval unions (multiplication)IntervalUnion.diff– set difference of two interval unions (monus)
Main results #
IntervalUnion.ext_toSet– two interval unions with the same point set are equal (requiresDenselyOrdered)IntervalUnion.mem_union/mem_inter/mem_diff– membership characterizationsinstance : SemiringWithMonus (IntervalUnion α)– interval unions form an m-semiring for anyDenselyOrderedandBoundedOrderlinear orderIntervalUnion.absorptive– the semiring is absorptive (1 + a = 1): the whole space absorbs any interval union under unionIntervalUnion.mul_sub_left_distributive–a * (b - c) = a * b - a * c, i.e.,A ∩ (B \ C) = (A ∩ B) \ (A ∩ C)
Concrete instances #
SemiringWithMonus (IntervalUnion EReal)– interval unions over the extended realsSemiringWithMonus (IntervalUnion (WithBot (WithTop ℚ)))– interval unions over the extended rationals
References #
A finite union of pairwise-disjoint intervals sorted from left to right.
The invariants pairwise_disjoint and pairwise_before ensure the canonical
representation.
- pairwise_disjoint : List.Pairwise Interval.disjoint self.intervals
- pairwise_before : List.Pairwise Interval.before self.intervals
Instances For
Dependency graph
The point set of an interval union: the union of the point sets of its intervals.
Instances For
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Merge two overlapping or adjacent intervals into one.
Instances For
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Insert an interval into a sorted disjoint list, merging with any overlapping or adjacent intervals.
Equations
Instances For
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Equations
- IntervalUnion.insertMerge I U = { intervals := IntervalUnion.insertMergeList I U.intervals, pairwise_disjoint := ⋯, pairwise_before := ⋯ }
Instances For
Dependency graph
Dependency graph
Union of two interval unions (the semiring addition).
Equations
- U.union V = List.foldl (fun (acc : IntervalUnion α) (I : Interval α) => IntervalUnion.insertMerge I acc) U V.intervals
Instances For
Dependency graph
Dependency graph
Intersection of two interval unions (the semiring multiplication).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
Dependency graph
Set difference of two interval unions (the semiring monus).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
Dependency graph
Dependency graph
Equations
- One or more equations did not get rendered due to their size.
Dependency graph
Equations
- instAddIntervalUnion = { add := fun (U V : IntervalUnion α) => U.union V }
Dependency graph
Equations
- instMulIntervalUnion = { mul := fun (U V : IntervalUnion α) => U.inter V }
Dependency graph
Equations
- instSubIntervalUnion = { sub := fun (U V : IntervalUnion α) => U.diff V }
Dependency graph
Equations
- One or more equations did not get rendered due to their size.
Dependency graph
Equations
- One or more equations did not get rendered due to their size.
Dependency graph
Interval unions over a dense bounded linear order form a commutative m-semiring, with union as addition, intersection as multiplication, set inclusion as natural order, and set difference as monus.
Equations
- One or more equations did not get rendered due to their size.
Dependency graph
On interval unions the identity is an admissible δ, so it is the one used
(ProvSQL's IntervalUnion::delta); delta_absorb is A ∩ (A ∪ B) = A.
Dependency graph
Equations
- instCommSemiringWithMonusIntervalUnionOfDenselyOrderedOfBoundedOrder = { toSemiringWithMonus := instSemiringWithMonusIntervalUnionOfDenselyOrderedOfBoundedOrder, mul_comm := ⋯ }
Dependency graph
The interval-union semiring is absorptive: the multiplicative identity (the whole space) absorbs any element under addition (union).
Dependency graph
Left-distributivity of multiplication (intersection) over monus (set difference):
A ∩ (B \ C) = (A ∩ B) \ (A ∩ C).
Dependency graph
The interval-union semiring is idempotent: a + a = a (derived from absorptivity).
Dependency graph
Dependency graph
The interval-union semiring has characteristic 0 in the CharP sense: it is
idempotent and nontrivial (the empty list differs from the singleton [⊥,⊤]), so
every positive natural-number cast equals 1.
Dependency graph
The interval-union semiring over the extended reals [-∞, +∞].
Dependency graph
Dependency graph
The interval-union semiring over the extended rationals.
Dependency graph
Dependency graph
Homomorphism from BoolFunc Y to IntervalUnion #
For any assignment ν : Y → IntervalUnion β with Y finite, there is an
m-semiring homomorphism BoolFunc Y →+* IntervalUnion β sending each
variable to its assigned interval union.
Construction. For f ∈ BoolFunc Y, write f in disjunctive normal form
over the finite variable set Y:
f = ⋁_σ (⋀_i var_i^{σ(i)}), where σ : Y → Bool ranges over assignments
with f σ = true and var_i^true = var_i, var_i^false = 1 - var_i. Define
evalBF ν f := ∑_σ (if f σ then atomIU ν σ else 0) where
atomIU ν σ := ∏_i (if σ i then ν i else 1 - ν i). This is a finite Boolean
combination of the ν(i)'s, hence lies in IntervalUnion β.
The correctness rests on the set-theoretic characterization
mem_atomIU_iff_sig: x ∈ (atomIU ν σ).toSet iff σ is the ν-signature of
x, where the ν-signature sigOf ν x sends each i to decide (x ∈ ν i).
This yields (evalBF ν f).toSet = {x : β | f (sigOf ν x) = true}
(evalBF_toSet), from which preservation of 0, 1, +, *, monus,
and the variable mapping all follow.
For infinite Y, no such homomorphism exists in general: the set
{x | f(τ_x) = true} need not be a finite union of intervals when f
depends non-trivially on infinitely many variables. So Fintype Y is
essential.
For any assignment ν : Y → IntervalUnion β with Y finite, there is an
m-semiring homomorphism BoolFunc Y →+* IntervalUnion β sending each
variable BoolFunc.var i to ν i. The homomorphism is the DNF evaluation
evalBF: f ↦ ∑_σ (if f σ then atomIU ν σ else 0).
Dependency graph
Specialization of IntervalUnion.homomorphism_from_BoolFunc to the
extended rationals.