Derive Left-Binary-Branching Interval Algebra

NOTE: This algebra derives an algebra very similar to the Left Branching Interval Algebra, except that it uses a left-branching point algebra that only allows binary branching. See the section, below, titled, “Left-Binary-Branching Point Algebra”.

References

  1. “Maintaining Knowledge about Temporal Intervals” by J.F. Allen - Allen’s original paper

  2. Allen’s Interval Algebra or here - summarizes Allen’s algebra of proper time intervals

  3. “Intervals, Points, and Branching Time” by A.J. Reich - basis for the extensions here to Allen’s algebra

  4. W3C Time Ontology in OWL - temporal vocabulary used here is based on the W3C vocabulary of time

  5. bitsets Python package - used to implement Algebra relation sets and operations

  6. NetworkX Python package - used to represent directed graph of constraints

  7. Python format string syntax - used in Algebra summary method

  8. Spatial Ontology - I’m still looking for a standard spatial vocabulary; maybe start here

  9. Qualitative Spatial Relations (QSR) Library - an alternative library to the one defined here

Dependencies

import os
import qualreas as qr
import numpy as np

import sys
sys.setrecursionlimit(10000)
path = os.path.join(os.getenv('PYPROJ'), 'qualreas')

Deriving the Left-Binary-Branching (LBB) Interval Algebra from LBB Point Algebra

LBB Point Algebra

pt_alg = qr.Algebra(os.path.join(path, "Algebras/Left_Binary_Branching_Point_Algebra.json"))
pt_alg.summary()
  Algebra Name: Left_Binary_Branching_Point_Algebra
   Description: Left-Binary-Branching Point Algebra
 Equality Rels: =
     Relations:
            NAME (SYMBOL)         CONVERSE (ABBREV)  REFLEXIVE  SYMMETRIC TRANSITIVE   DOMAIN        RANGE
           LessThan (  <)         GreaterThan (  >)    False      False       True         Pt            Pt
             Equals (  =)              Equals (  =)     True       True       True         Pt            Pt
        GreaterThan (  >)            LessThan (  <)    False      False       True         Pt            Pt
       Incomparable ( l~)        Incomparable ( l~)    False       True      False         Pt            Pt

Domain & Range Abbreviations:
   Pt = Point
 PInt = Proper Interval
qr.print_point_algebra_composition_table(pt_alg)
Left_Binary_Branching_Point_Algebra
Elements: <, =, >, l~
==============================
 rel1 ; rel2 = composition
==============================
   <      <      <
   <      =      <
   <      >      <|=|>|l~
   <     l~      l~
------------------------------
   =      <      <
   =      =      =
   =      >      >
   =     l~      l~
------------------------------
   >      <      <|=|>
   >      =      >
   >      >      >
   >     l~      >|l~
------------------------------
  l~      <      <|l~
  l~      =      l~
  l~      >      l~
  l~     l~      <|=|>
------------------------------

Derive LBB Algebra as a Dictionary

The definition of less than, below, either restricts intervals to be proper (‘<’) or allows intervals to be degenerate (‘=|<’) (i.e., integrates points and intervals).

less_than_rel = '=|<'
#less_than_rel = '<'
lbb_alg_name="Derived_Left_Binary_Branching_Interval_Algebra"
lbb_alg_desc="Extended left-binary-branching interval algebra derived from point relations"

%time test_lbb_alg_dict = qr.derive_algebra(pt_alg, less_than_rel, name=lbb_alg_name, description=lbb_alg_desc)
24 consistent networks
test_lbb_alg_dict

Save RBB Algebra Dictionary to JSON File

test_lbb_json_path = os.path.join(path, "Algebras/test_derived_left_binary_branching_interval_algebra.json")
test_lbb_json_path
qr.algebra_to_json_file(test_lbb_alg_dict, test_lbb_json_path)

Instantiate a LBB Algebra Object from JSON File

test_lbb_alg = qr.Algebra(test_lbb_json_path)
test_lbb_alg
test_lbb_alg.summary()
test_lbb_alg.check_composition_identity()
test_lbb_alg.is_associative()