Documentation

Provenance.Semirings.IntervalUnion

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 #

Main results #

Concrete instances #

References #

structure IntervalUnion (α : Type) [LinearOrder α] :

A finite union of pairwise-disjoint intervals sorted from left to right. The invariants pairwise_disjoint and pairwise_before ensure the canonical representation.

Instances For

    The point set of an interval union: the union of the point sets of its intervals.

    Equations
    Instances For
      theorem IntervalUnion.ext_toSet {α : Type} [LinearOrder α] [DenselyOrdered α] (U V : IntervalUnion α) (h : U.toSet = V.toSet) :
      U = V
      theorem IntervalUnion.ext {α : Type} [LinearOrder α] (U V : IntervalUnion α) (h : U.intervals = V.intervals) :
      U = V
      @[simp]
      theorem IntervalUnion.mem {α : Type} [LinearOrder α] (x : α) (U : IntervalUnion α) :
      x U.toSet IU.intervals, x I.toSet
      def IntervalUnion.merge {α : Type} [LinearOrder α] (I J : Interval α) (h : ¬(I.before J J.before I)) :

      Merge two overlapping or adjacent intervals into one.

      Equations
      Instances For
        theorem IntervalUnion.merge_commutative {α : Type} [LinearOrder α] {I J : Interval α} {h : ¬(I.before J J.before I)} :
        merge I J h = merge J I
        theorem IntervalUnion.mem_merge' {α : Type} [LinearOrder α] {I J : Interval α} (h : ¬(I.before J J.before I)) (x : α) :
        x I.toSetx (merge I J h).toSet
        theorem IntervalUnion.mem_merge {α : Type} [LinearOrder α] {I J : Interval α} {h : ¬(I.before J J.before I)} (x : α) :
        x (merge I J h).toSet x I.toSet x J.toSet
        theorem IntervalUnion.merge_preserves_le {α : Type} [LinearOrder α] {I J K : Interval α} (hKI : K I) (hKJ : K J) (h : ¬(I.before J J.before I)) :
        K merge I J h

        Insert an interval into a sorted disjoint list, merging with any overlapping or adjacent intervals.

        Equations
        Instances For
          theorem IntervalUnion.mem_insertMergeList {α : Type} [LinearOrder α] (I : Interval α) (L : List (Interval α)) (x : α) :
          (∃ JinsertMergeList I L, x J.toSet) x I.toSet JL, x J.toSet
          Equations
          Instances For
            theorem IntervalUnion.mem_insertMerge {α : Type} [LinearOrder α] (I : Interval α) (U : IntervalUnion α) (x : α) :

            Union of two interval unions (the semiring addition).

            Equations
            Instances For
              theorem IntervalUnion.mem_union {α : Type} [LinearOrder α] (U V : IntervalUnion α) (x : α) :
              x (U.union V).toSet x U.toSet x V.toSet

              Intersection of two interval unions (the semiring multiplication).

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                theorem IntervalUnion.mem_inter {α : Type} [LinearOrder α] (U V : IntervalUnion α) (x : α) :
                x (U.inter V).toSet x U.toSet x V.toSet

                Set difference of two interval unions (the semiring monus).

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  theorem IntervalUnion.mem_diff {α : Type} [LinearOrder α] (U V : IntervalUnion α) (x : α) :
                  x (U.diff V).toSet x U.toSet xV.toSet
                  @[implicit_reducible]
                  Equations
                  @[implicit_reducible]
                  Equations
                  • One or more equations did not get rendered due to their size.
                  @[implicit_reducible]
                  Equations
                  @[implicit_reducible]
                  Equations
                  @[implicit_reducible]
                  Equations
                  @[implicit_reducible]
                  Equations
                  • One or more equations did not get rendered due to their size.
                  @[implicit_reducible]
                  Equations
                  • One or more equations did not get rendered due to their size.
                  @[implicit_reducible]

                  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.

                  The interval-union semiring is absorptive: the multiplicative identity (the whole space) absorbs any element under addition (union).

                  Left-distributivity of multiplication (intersection) over monus (set difference): A ∩ (B \ C) = (A ∩ B) \ (A ∩ C).

                  The interval-union semiring is idempotent: a + a = a (derived from absorptivity).

                  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.

                  @[implicit_reducible]

                  The interval-union semiring over the extended reals [-∞, +∞].

                  Equations

                  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 characterisation 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.

                  theorem IntervalUnion.homomorphism_from_BoolFunc (β : Type) [LinearOrder β] [DenselyOrdered β] [BoundedOrder β] (Y : Type) [Fintype Y] [DecidableEq Y] (ν : YIntervalUnion β) :
                  ∃ (h : SemiringWithMonusHom (BoolFunc Y) (IntervalUnion β)), ∀ (i : Y), (fun (x : BoolFunc Y) => h.toRingHom x) (BoolFunc.var i) = ν i

                  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).

                  Specialisation of IntervalUnion.homomorphism_from_BoolFunc to the extended rationals.