Derive Right-Binary-Branching Interval Algebra
NOTE: This algebra derives an algebra very similar to the Right Branching Interval Algebra, except that it uses a right-branching point algebra that only allows binary branching. See the section, below, titled, “Right-Binary-Branching Point Algebra”.
References
“Maintaining Knowledge about Temporal Intervals” by J.F. Allen - Allen’s original paper
Allen’s Interval Algebra or here - summarizes Allen’s algebra of proper time intervals
“Intervals, Points, and Branching Time” by A.J. Reich - basis for the extensions here to Allen’s algebra
W3C Time Ontology in OWL - temporal vocabulary used here is based on the W3C vocabulary of time
bitsets Python package - used to implement Algebra relation sets and operations
NetworkX Python package - used to represent directed graph of constraints
Python format string syntax - used in Algebra summary method
Spatial Ontology - I’m still looking for a standard spatial vocabulary; maybe start here
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 Right-Binary-Branching (RBB) Interval Algebra from RBB Point Algebra
RBB Point Algebra
pt_alg = qr.Algebra(os.path.join(path, "Algebras/Right_Binary_Branching_Point_Algebra.json"))
pt_alg.summary()
Algebra Name: Right_Binary_Branching_Point_Algebra
Description: Right-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 ( r~) Incomparable ( r~) False True False Pt Pt
Domain & Range Abbreviations:
Pt = Point
PInt = Proper Interval
qr.print_point_algebra_composition_table(pt_alg)
Right_Binary_Branching_Point_Algebra Elements: <, =, >, r~ ============================== rel1 ; rel2 = composition ============================== < < < < = < < > <|=|> < r~ <|r~ ------------------------------ = < < = = = = > > = r~ r~ ------------------------------ > < <|=|>|r~ > = > > > > > r~ r~ ------------------------------ r~ < r~ r~ = r~ r~ > >|r~ r~ r~ <|=|> ------------------------------
Derive RBB 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 = '<'
rbb_alg_name="Derived_Right_Binary_Branching_Interval_Algebra"
rbb_alg_desc="Extended right-binary-branching interval algebra derived from point relations"
%time test_rbb_alg_dict = qr.derive_algebra(pt_alg, less_than_rel, name=rbb_alg_name, description=rbb_alg_desc)
24 consistent networks
test_rbb_alg_dict
Save RBB Algebra Dictionary to JSON File
test_rbb_json_path = os.path.join(path, "Algebras/test_derived_right_binary_branching_interval_algebra.json")
test_rbb_json_path
qr.algebra_to_json_file(test_rbb_alg_dict, test_rbb_json_path)
Instantiate a RBB Algebra Object from JSON File
test_rbb_alg = qr.Algebra(test_rbb_json_path)
test_rbb_alg
test_rbb_alg.summary()
test_rbb_alg.check_composition_identity()
test_rbb_alg.is_associative()