h&ǻ      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ *Implementation of Allen's interval algebra=(c) NoviSci, Inc 2020-2022 TargetRWE, 2023BSD36bsaul@novisci.com 2020-2022, bbrown@targetrwe.com 2023 Safe-Inferred-89>?yinterval-algebra5Defines a predicate of two object of different types.interval-algebra+Defines a predicate of two objects of type a.interval-algebraThe  typeclass is a generic interface for constructing and manipulating intervals. The class imposes strong requirements on its methods, in large part to ensure the constructors   and   return "valid" intervals, particularly in the typical case where iv' also implements the interval algebra.In all cases,   and   should preserve the value of the point *not* shifted. That is, ivBegin (ivExpandr d i) == ivBegin i ivEnd (ivExpandl d i) == ivEnd i In addition, using 1% as example, the following must hold:When iv is Ord , for all i == Interval (b, e), &ivExpandr d i >= i ivExpandl d i <= i When  Moment iv is Ord, duration (ivExpandr d i) >= max moment (duration i) duration (ivExpandl d i) >= max moment (duration i) In particular, if the duration d! by which to expand is less than , and  i >= moment1 then these constructors should return the input. &ivExpandr d i == i ivExpandl d i == i When  Moment iv also is Num, the default  value is 1& and in all cases should be positive. moment @iv > 0 When in addition Point iv ~ Moment iv, the class provides a default  as  duration i = ivEnd i - ivBegin i.This module enforces   (Interval a) = a . However, it need not be that  a ~ Moment iv. For example ,Moment (Interval UTCTime) ~ NominalDiffTime. SizedIv and the interval algebraWhen iv is an instance of , the methods of this class should ensure the validity of the resulting interval with respect to the interval algebra. For example, when   iv is -, they must always produce a valid interval i such that   i <  i.!In addition, the requirements of + implementations in the common case where  iv is  and 5 require the constructors to produce intervals with  of at least .+In order to preserve the properties above, ivExpandr, ivExpandl will not want to assume validity of the input interval. In other words,   d i need not be the identity when d <  since it will need to ensure the result is a valid interval even if i is not.These two methods can therefore be used as constructors for valid intervals.interval-algebraType of .interval-algebraThe smallest duration for an iv&. When 'Moment iv' is an instance of , the default is 1. If  iv is Ord and Num,  > 0 is required.interval-algebraThe duration of an iv. When Moment iv ~ Point iv and Point iv is Num this defaults to ivEnd i - ivBegin i. interval-algebraResize iv by expanding to the "left" or to the "right" by some duration. If iv% implements the interval algebra via Iv, these methods must produce valid intervals regardless of the validity of the input and thus serve as constructors for intervals. See also \,  endverval, ` and related.5See the class documentation for details requirements.ivExpandr 1 (safeInterval (0, 1) :: Interval Int) == safeInterval (0, 2)TrueivExpandr 0 (safeInterval (0, 1) :: Interval Int) == safeInterval (0, 1)TrueivExpandl 1 (safeInterval (0, 1) :: Interval Int) == safeInterval (-1, 1)TrueivExpandl 0 (safeInterval (0, 1) :: Interval Int) == safeInterval (0, 1)True interval-algebraResize iv by expanding to the "left" or to the "right" by some duration. If iv% implements the interval algebra via Iv, these methods must produce valid intervals regardless of the validity of the input and thus serve as constructors for intervals. See also \,  endverval, ` and related.5See the class documentation for details requirements.ivExpandr 1 (safeInterval (0, 1) :: Interval Int) == safeInterval (0, 2)TrueivExpandr 0 (safeInterval (0, 1) :: Interval Int) == safeInterval (0, 1)TrueivExpandl 1 (safeInterval (0, 1) :: Interval Int) == safeInterval (-1, 1)TrueivExpandl 0 (safeInterval (0, 1) :: Interval Int) == safeInterval (0, 1)True interval-algebraClass representing intervals that can be cast to and from the canonical representation 1 a.When iv is also an instance of  , with Ord (Point iv), it should adhere to Allen's construction of the interval algebra for intervals represented by left and right endpoints. See  :https://cse.unl.edu/~choueiry/Documents/Allen-CACM1983.pdfsections 3 and 4 of Allen 1983.;Specifically, the requirements for interval relations imply ivBegin i < ivEnd i We found the letter during dinner, after we made the decision.:{ 3data GoingsOn = Dinner | FoundLetter | MadeDecision deriving (Show, Eq)instance Iv GoingsOn where& ivRelate MadeDecision Dinner = Before+ ivRelate MadeDecision FoundLetter = Before% ivRelate FoundLetter Dinner = During ivRelate x y | x == y = Equals0 | otherwise = converseRelation (ivRelate y x):}interval-algebraThe  between two intervals.interval-algebraIs  x y == Meets?  = flip .interval-algebraIs  x y == Meets?  = flip .interval-algebraIs  x y == Overlaps?  = flip .interval-algebraIs  x y == Overlaps?  = flip .interval-algebraIs  x y == Starts?  = flip .interval-algebraIs  x y == Starts?  = flip .interval-algebraIs  x y == Finishes?  = flip .interval-algebraIs  x y == Finishes?  = flip .interval-algebraIs  x y == During?  = flip .interval-algebraIs  x y == During?  = flip .interval-algebraIs  x y == Equals?interval-algebraThe  type and the associated predicate functions enumerate the thirteen possible ways that two  objects may S according to Allen's interval algebra. Constructors are shown with their corresponding predicate function.interval-algebra8 interval-algebra6!interval-algebra<"interval-algebraA#interval-algebraC$interval-algebra>%interval-algebraD&interval-algebra?'interval-algebraB(interval-algebra@)interval-algebra=*interval-algebra7+interval-algebra9,interval-algebraThe ,* typeclass defines how to get and set the 1 content of a data structure. , types can be compared via  s on their underlying 1, and functions of this module define versions of the methods from ,   and  for instances of ,, by applying them to the contained interval."Only the canonical representation 10 should define an instance of all four classes.PairedInterval# is the prototypical example of an ,.getInterval (Interval (0, 10))(0, 10)begin (Interval (0, 10))0end (Interval (0, 10))10-interval-algebraGet the interval from an i a..interval-algebraSet the interval in an i a./interval-algebra+A type identifying interval parsing errors.1interval-algebraAn 1 a is a pair  (x, y) \text{ such that } x < y. To create intervals use the 2, \, or ^ functions.2interval-algebraParse a pair of as to create an 1 a. Note this checks only that  begin < end4 and has no relation to checking the conditions of .parseInterval 0 1 Right (0, 1)parseInterval 1 0 Left (ParseErrorInterval "0<=1")3interval-algebraA synonym for 24interval-algebraAccess the endpoints of an i a .5interval-algebraAccess the endpoints of an i a .6interval-algebraDoes x 6 y? Is x 7 y?(Example data with corresponding diagram: x = bi 5 0 y = bi 5 57pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []----- <- [x] ----- <- [y] ========== Examples: x `meets` yTrue x `metBy` yFalse y `meets` xFalse y `metBy` xTrue7interval-algebraDoes x 6 y? Is x 7 y?(Example data with corresponding diagram: x = bi 5 0 y = bi 5 57pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []----- <- [x] ----- <- [y] ========== Examples: x `meets` yTrue x `metBy` yFalse y `meets` xFalse y `metBy` xTrue8interval-algebraIs x 8 y? Does x : y? Is x 9 y? Is x ; y?(Example data with corresponding diagram: x = bi 3 0 y = bi 4 67pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []--- <- [x] ---- <- [y] ========== Examples: x `before` yTruex `precedes` yTrue x `after`yFalsex `precededBy` yFalse y `before` xFalsey `precedes` xFalse y `after` xTruey `precededBy` xTrue9interval-algebraIs x 8 y? Does x : y? Is x 9 y? Is x ; y?(Example data with corresponding diagram: x = bi 3 0 y = bi 4 67pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []--- <- [x] ---- <- [y] ========== Examples: x `before` yTruex `precedes` yTrue x `after`yFalsex `precededBy` yFalse y `before` xFalsey `precedes` xFalse y `after` xTruey `precededBy` xTrue:interval-algebraIs x 8 y? Does x : y? Is x 9 y? Is x ; y?(Example data with corresponding diagram: x = bi 3 0 y = bi 4 67pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []--- <- [x] ---- <- [y] ========== Examples: x `before` yTruex `precedes` yTrue x `after`yFalsex `precededBy` yFalse y `before` xFalsey `precedes` xFalse y `after` xTruey `precededBy` xTrue;interval-algebraIs x 8 y? Does x : y? Is x 9 y? Is x ; y?(Example data with corresponding diagram: x = bi 3 0 y = bi 4 67pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []--- <- [x] ---- <- [y] ========== Examples: x `before` yTruex `precedes` yTrue x `after`yFalsex `precededBy` yFalse y `before` xFalsey `precedes` xFalse y `after` xTruey `precededBy` xTrue<interval-algebraDoes x < y? Is x = y?(Example data with corresponding diagram: x = bi 6 0 y = bi 6 47pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []------ <- [x] ------ <- [y] ========== Examples:x `overlaps` yTruex `overlappedBy` yFalsey `overlaps` xFalsey `overlappedBy` xTrue=interval-algebraDoes x < y? Is x = y?(Example data with corresponding diagram: x = bi 6 0 y = bi 6 47pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []------ <- [x] ------ <- [y] ========== Examples:x `overlaps` yTruex `overlappedBy` yFalsey `overlaps` xFalsey `overlappedBy` xTrue>interval-algebraDoes x > y? Is x ? y?(Example data with corresponding diagram: x = bi 3 4 y = bi 6 47pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] --- <- [x] ------ <- [y] ========== Examples: x `starts` yTruex `startedBy` yFalse y `starts` xFalsey `startedBy` xTrue?interval-algebraDoes x > y? Is x ? y?(Example data with corresponding diagram: x = bi 3 4 y = bi 6 47pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] --- <- [x] ------ <- [y] ========== Examples: x `starts` yTruex `startedBy` yFalse y `starts` xFalsey `startedBy` xTrue@interval-algebraDoes x @ y? Is x A y?(Example data with corresponding diagram: x = bi 3 7 y = bi 6 47pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] --- <- [x] ------ <- [y] ========== Examples:x `finishes` yTruex `finishedBy` yFalsey `finishes` xFalsey `finishedBy` xTrueAinterval-algebraDoes x @ y? Is x A y?(Example data with corresponding diagram: x = bi 3 7 y = bi 6 47pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] --- <- [x] ------ <- [y] ========== Examples:x `finishes` yTruex `finishedBy` yFalsey `finishes` xFalsey `finishedBy` xTrueBinterval-algebraIs x B y? Does x C y?(Example data with corresponding diagram: x = bi 3 5 y = bi 6 47pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] --- <- [x] ------ <- [y] ========== Examples: x `during` yTruex `contains` yFalse y `during` xFalsey `contains` xTrueCinterval-algebraIs x B y? Does x C y?(Example data with corresponding diagram: x = bi 3 5 y = bi 6 47pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] --- <- [x] ------ <- [y] ========== Examples: x `during` yTruex `contains` yFalse y `during` xFalsey `contains` xTrueDinterval-algebraDoes x D y?(Example data with corresponding diagram: x = bi 6 4 y = bi 6 47pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] ------ <- [x] ------ <- [y] ========== Examples: x `equals` yTrue y `equals` xTrueEinterval-algebra6Operator for composing the union of two predicates on , s.Finterval-algebra The set of IntervalRelation$ meaning two intervals are disjoint.Ginterval-algebra The set of IntervalRelation* meaning one interval is within the other.Hinterval-algebra The set of IntervalRelation5 meaning one interval is *strictly* within the other.Iinterval-algebra Are x and y I (8, 9, 6, or 7)?(Example data with corresponding diagram: x = bi 3 0 y = bi 3 57pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []--- <- [x] --- <- [y]======== Examples:x `disjoint` yTruey `disjoint` xTrue(Example data with corresponding diagram: x = bi 3 0 y = bi 3 37pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] --- <- [x] --- <- [y]====== Examples:x `disjoint` yTruey `disjoint` xTrue(Example data with corresponding diagram: x = bi 6 0 y = bi 3 37pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] ------ <- [x] --- <- [y]====== Examples:x `disjoint` yFalsey `disjoint` xFalseJinterval-algebraDoes x K y , meaning x and y share some support? Is x J y? This is the U of I.(Example data with corresponding diagram: x = bi 3 0 y = bi 3 47pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []--- <- [x] --- <- [y]======= Examples:x `notDisjoint` yFalse y `concur` xFalse(Example data with corresponding diagram: x = bi 3 0 y = bi 3 37pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] --- <- [x] --- <- [y]====== Examples:x `notDisjoint` yFalse y `concur` xFalse(Example data with corresponding diagram: x = bi 6 0 y = bi 3 37pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] ------ <- [x] --- <- [y]====== Examples:x `notDisjoint` yTrue y `concur` xTrueKinterval-algebraDoes x K y , meaning x and y share some support? Is x J y? This is the U of I.(Example data with corresponding diagram: x = bi 3 0 y = bi 3 47pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []--- <- [x] --- <- [y]======= Examples:x `notDisjoint` yFalse y `concur` xFalse(Example data with corresponding diagram: x = bi 3 0 y = bi 3 37pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] --- <- [x] --- <- [y]====== Examples:x `notDisjoint` yFalse y `concur` xFalse(Example data with corresponding diagram: x = bi 6 0 y = bi 3 37pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] ------ <- [x] --- <- [y]====== Examples:x `notDisjoint` yTrue y `concur` xTrueLinterval-algebraIs x L (M) y? That is, B, >, @, or D?(Example data with corresponding diagram: x = bi 6 4 y = bi 6 47pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] ------ <- [x] ------ <- [y] ========== Examples: x `within` yTruey `enclosedBy` xTrue(Example data with corresponding diagram: x = bi 6 4 y = bi 5 47pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] ------ <- [x] ----- <- [y] ========== Examples: x `within` yFalsey `enclosedBy` xTrue(Example data with corresponding diagram: x = bi 6 4 y = bi 4 57pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] ------ <- [x] ---- <- [y] ========== Examples: x `within` yFalsey `enclosedBy` xTrue(Example data with corresponding diagram: x = bi 2 7 y = bi 1 57pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] -- <- [x] - <- [y] ========= Examples: x `within` yFalsey `enclosedBy` xFalseMinterval-algebraIs x L (M) y? That is, B, >, @, or D?(Example data with corresponding diagram: x = bi 6 4 y = bi 6 47pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] ------ <- [x] ------ <- [y] ========== Examples: x `within` yTruey `enclosedBy` xTrue(Example data with corresponding diagram: x = bi 6 4 y = bi 5 47pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] ------ <- [x] ----- <- [y] ========== Examples: x `within` yFalsey `enclosedBy` xTrue(Example data with corresponding diagram: x = bi 6 4 y = bi 4 57pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] ------ <- [x] ---- <- [y] ========== Examples: x `within` yFalsey `enclosedBy` xTrue(Example data with corresponding diagram: x = bi 2 7 y = bi 1 57pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] -- <- [x] - <- [y] ========= Examples: x `within` yFalsey `enclosedBy` xFalseNinterval-algebraDoes x N y? That is, is y L x?(Example data with corresponding diagram: x = bi 6 4 y = bi 6 47pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] ------ <- [x] ------ <- [y] ========== Examples:x `encloses` yTruey `encloses` xTrue(Example data with corresponding diagram: x = bi 6 4 y = bi 5 47pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] ------ <- [x] ----- <- [y] ========== Examples:x `encloses` yTruey `encloses` xFalse(Example data with corresponding diagram: x = bi 6 4 y = bi 4 57pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] ------ <- [x] ---- <- [y] ========== Examples:x `encloses` yTruey `encloses` xFalse(Example data with corresponding diagram: x = bi 2 7 y = bi 1 57pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] -- <- [x] - <- [y] ========= Examples:x `encloses` yFalsey `encloses` xFalseOinterval-algebraThe  of all s.Pinterval-algebraFind the converse of a single Qinterval-algebraCompose a list of interval relations with _or_ to create a new  i a. For example, unionPredicates [before, meets] creates a predicate function determining if one interval is either before or meets another interval.Rinterval-algebra6Forms a predicate function from the union of a set of s.Sinterval-algebra Compare two i a to determine their ./relate (Interval (0::Int, 1)) (Interval (1, 2))Meets/relate (Interval (1::Int, 2)) (Interval (0, 1))MetByTinterval-algebraCompose two interval relations according to the rules of the algebra. The rules are enumerated according to  https://thomasalspaugh.org/pub/fnd/allen.html#BasicCompositionsTable this table.Uinterval-algebraFinds the complement of a  .Vinterval-algebraFind the intersection of two s of s.Winterval-algebraFind the union of two s of s.Xinterval-algebraFind the converse of a  .Yinterval-algebra Resize an i a to by expanding to "left" by l and to the "right" by r. In the case that l or r are less than a ) the respective endpoints are unchanged.!iv2to4 = safeInterval (2::Int, 4)iv2to4' = expand 0 0 iv2to4iv1to5 = expand 1 1 iv2to4iv2to4(2, 4)iv2to4'(2, 4)iv1to5(1, 5)pretty $ standardExampleDiagram [(iv2to4, "iv2to4"), (iv1to5, "iv1to5")] [] -- <- [iv2to4] ---- <- [iv1to5]=====Zinterval-algebra Expands an i a to the "left".(iv2to4 = (safeInterval (2::Int, 4::Int))iv0to4 = expandl 2 iv2to4iv2to4(2, 4)iv0to4(0, 4)pretty $ standardExampleDiagram [(iv2to4, "iv2to4"), (iv0to4, "iv0to4")] [] -- <- [iv2to4]---- <- [iv0to4]====[interval-algebra Expands an i a to the "right".(iv2to4 = (safeInterval (2::Int, 4::Int))iv2to6 = expandr 2 iv2to4iv2to4(2, 4)iv2to6(2, 6)pretty $ standardExampleDiagram [(iv2to4, "iv2to4"), (iv2to6, "iv2to6")] [] -- <- [iv2to4] ---- <- [iv2to6]======\interval-algebra%Safely creates an 'Interval a' using x as the 4 and adding max  dur to x as the 5 . For the ! instances this module exports, \ is the same as interval+. However, it is defined separately since \ will always have this behavior whereas interval) behavior might differ by implementation.beginerval (0::Int) (0::Int)(0, 1)beginerval (1::Int) (0::Int)(0, 1)beginerval (2::Int) (0::Int)(0, 2)]interval-algebraA synonym for \^interval-algebra%Safely creates an 'Interval a' using x as the 5 and adding  negate max  dur to x as the 4.enderval (0::Int) (0::Int)(-1, 0)enderval (1::Int) (0::Int)(-1, 0)enderval (2::Int) (0::Int)(-2, 0)_interval-algebraA synonym for ^`interval-algebraSafely creates an 1 from a pair of endpoints, expanding from the left endpoint if necessary to create a valid interval according to the rules of . This function simply wraps  .safeInterval (4, 5 ::Int)(4, 5)safeInterval (4, 3 :: Int)(4, 5)ainterval-algebraA synonym for `binterval-algebraCreates a new 1 from the 5 of another.cinterval-algebraCreates a new 1 from the 4 of another.dinterval-algebraSafely creates a new Interval with  length with 4 at xbeginervalMoment (10 :: Int)(10, 11)einterval-algebraSafely creates a new Interval with  length with 5 at xendervalMoment (10 :: Int)(9, 10)finterval-algebraCreates a new Interval spanning the extent x and y.0extenterval (Interval (0, 1)) (Interval (9, 10))(0, 10)ginterval-algebraModifies the endpoints of second argument's interval by taking the difference from the first's input's 4.(Example data with corresponding diagram:a = bi 3 2 :: Interval Inta(2, 5)x = bi 3 7 :: Interval Intx(7, 10)y = bi 4 9 :: Interval Inty(9, 13)pretty $ standardExampleDiagram [(a, "a"), (x, "x"), (y, "y")] [] --- <- [a] --- <- [x] ---- <- [y] ============= Examples:x' = shiftFromBegin a xx'(5, 8)y' = shiftFromBegin a yy'(7, 11);pretty $ standardExampleDiagram [(x', "x'"), (y', "y'")] [] --- <- [x'] ---- <- [y'] ===========hinterval-algebraModifies the endpoints of second argument's interval by taking the difference from the first's input's 5.(Example data with corresponding diagram:a = bi 3 2 :: Interval Inta(2, 5)x = bi 3 7 :: Interval Intx(7, 10)y = bi 4 9 :: Interval Inty(9, 13)pretty $ standardExampleDiagram [(a, "a"), (x, "x"), (y, "y")] [] --- <- [a] --- <- [x] ---- <- [y] ============= Examples:x' = shiftFromEnd a xx'(2, 5)y' = shiftFromEnd a yy'(4, 8);pretty $ standardExampleDiagram [(x', "x'"), (y', "y'")] [] --- <- [x'] ---- <- [y']========iinterval-algebra Converts an i a to an i Int via fromEnum. This assumes the provided fromEnum- method is strictly monotone increasing: For a types that are Ord with values x, y, then x < y implies fromEnum x < fromEnum y), so long as the latter is well-defined.jinterval-algebra Converts an i Int to an i a via toEnum. This assumes the provided toEnum- method is strictly monotone increasing: For a types that are Ord , then for Int values x, y it holds that x < y implies toEnum x < toEnum y.kinterval-algebraChanges the duration of an ,$ value to a moment starting at the 4 of the interval. Uses d.momentize (Interval (6, 10))(6, 7)linterval-algebraImposes a total ordering on 1 a based on first ordering the 4 s then the 5s.sinterval-algebraImplements the interval algebra for intervals represented as left and right endpoints, with points in a totally ordered set, as prescribed in  )https://dl.acm.org/doi/10.1145/182.358434 Allen 1983.uinterval-algebraNote this instance changes the moment to 1  second, not 1 second as would be the case if the default were used.interval-algebraxinterval-algebrayinterval-algebraxinterval-algebrayinterval-algebraxinterval-algebrayinterval-algebraxinterval-algebrayinterval-algebraxinterval-algebrayinterval-algebraxinterval-algebrayinterval-algebraxinterval-algebrayinterval-algebraxinterval-algebrayinterval-algebraxinterval-algebrayinterval-algebraxinterval-algebrayinterval-algebraxinterval-algebrayinterval-algebraxinterval-algebrayinterval-algebraxinterval-algebrayYinterval-algebraduration to subtract from the 4interval-algebraduration to add to the 5\interval-algebraduration to add to the 4interval-algebrathe 4 point of the 1]interval-algebraduration to add to the 4interval-algebrathe 4 point of the 1^interval-algebraduration to subtract from the 5interval-algebrathe 5 point of the 1_interval-algebraduration to subtract from the 5interval-algebrathe 5 point of the 1binterval-algebraduration to add to the 5interval-algebrathe i a from which to get the 5cinterval-algebraduration to subtract from the 4interval-algebrathe i a from which to get the 4 ! "#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijk1  ,-.45/023\]^_`aYZ[f! "#$%&'()*+6789<=A@CB>?D:;IJKLNMERQFGHbcdeghkjiOSTUWVXPExtends the Interval Algebra to an interval paired with some data.<(c) NoviSci, Inc 2020-2022 TargetRWE, 2023BSD36bsaul@novisci.com 2020-2022, bbrown@targetrwe.com 2023 experimental Safe-Inferred8>? interval-algebra#Empty is used to trivially lift an  Interval a into a PairedInterval.interval-algebraAn  Interval a% paired with some other data of type b.interval-algebraMake a paired interval.interval-algebra,Gets the data (i.e. non-interval) part of a PairedInterval.interval-algebra$Tests for equality of the data in a PairedInterval.interval-algebra3Gets the intervals from a list of paired intervals.interval-algebra Lifts an  Interval a into a PairedInterval Empty a, where Empty, is a trivial type that contains no data.interval-algebraLifts a Functor containing  Interval a (s) into a Functor containing PairedInterval Empty a(s).interval-algebraDefines A total ordering on 'PairedInterval b a' based on the 'Interval a' part.  3Functions for operating on containers of Intervals.<(c) NoviSci, Inc 2020-2022 TargetRWE, 2023BSD36bsaul@novisci.com 2020-2022, bbrown@targetrwe.com 2023 experimental Safe-Inferred >?r interval-algebra Gets the durations of gaps (via !) between all pairs of the input.interval-algebraCreates a new Interval2 of a provided lookback duration ending at the 4 of the input interval.%lookback 4 (beginerval 10 (1 :: Int))(-3, 1)interval-algebraCreates a new Interval6 of a provided lookahead duration beginning at the 5 of the input interval.%lookahead 4 (beginerval 1 (1 :: Int))(2, 6)interval-algebraReturns a list of the " between each consecutive pair of i a.*relations [beginerval 1 0, beginerval 1 1][Meets]:relations [beginerval 1 0, beginerval 1 1, beginerval 2 1][Meets,Starts]relations [beginerval 1 0][]interval-algebraForms  a new interval from the intersection of two intervals, provided the intervals are not I.intersect (bi 5 0) (bi 2 3) Just (3, 5)interval-algebraReturns a list of intervals consisting of the gaps between consecutive intervals in the input, after they have been sorted by interval ordering. x1 = bi 4 1 x2 = bi 4 8 x3 = bi 3 11ivs = [x1, x2, x3]ivs[(1, 5),(8, 12),(11, 14)]gaps ivs[(5, 8)]?pretty $ standardExampleDiagram (zip ivs ["x1", "x2", "x3"]) [] ---- <- [x1] ---- <- [x2] --- <- [x3]============== x1 = bi 4 1 x2 = bi 3 7 x3 = bi 2 13ivs = [x1, x2, x3]ivs[(1, 5),(7, 10),(13, 15)]gapIvs = gaps ivsgapIvs[(5, 7),(10, 13)]:{ pretty $ standardExampleDiagram (zip ivs ["x1", "x2", "x3"]) [(gapIvs, "gapIvs")]:} ---- <- [x1] --- <- [x2] -- <- [x3] -- --- <- [gapIvs]===============interval-algebra Returns the " of each 'Intervallic i a' in the  f.3durations [bi 9 1, bi 10 2, bi 1 5 :: Interval Int][9,10,1]interval-algebraIn the case that x y are not disjoint, clips y to the extent of x.(clip (bi 5 0) ((bi 3 3) :: Interval Int) Just (3, 5)(clip (bi 3 0) ((bi 2 4) :: Interval Int)Nothinginterval-algebraReturns a list of intervals where any intervals that meet or share support are combined into one interval. This function sorts the input. If you know the input intervals are sorted, use combineIntervalsLFromSorted. x1 = bi 10 0 x2 = bi 5 2 x3 = bi 2 10 x4 = bi 2 13ivs = [x1, x2, x3, x4]ivs"[(0, 10),(2, 7),(10, 12),(13, 15)]xComb = combineIntervals ivsxComb[(0, 12),(13, 15)]:{ pretty $ standardExampleDiagram& (zip ivs ["x1", "x2", "x3", "x4"]) [(xComb, "xComb")]:}---------- <- [x1] ----- <- [x2] -- <- [x3] -- <- [x4]------------ -- <- [xComb]===============interval-algebraReturns a list of intervals where any intervals that meet or share support are combined into one interval. The operation is applied cumulatively, from left to right, so to work properly, the input list should be sorted in increasing order.>combineIntervalsFromSorted [bi 10 0, bi 5 2, bi 2 10, bi 2 13][(0, 12),(13, 15)]4combineIntervalsFromSorted [bi 10 0, bi 5 2, bi 0 8] [(0, 10)]interval-algebraMaybe form an  Interval a from !Control.Foldl t => t (Interval a)= spanning the range of all intervals in the list, i.e. whose begin is the minimum of begin( across intervals in the list and whose end is the maximum of end.$rangeInterval ([] :: [Interval Int])Nothing x1 = bi 2 2 x2 = bi 3 6 x3 = bi 4 7$ivs = [x1, x2, x3] :: [Interval Int]ivs[(2, 4),(6, 9),(7, 11)]spanIv = rangeInterval ivsspanIv Just (2, 11):{ case spanIv of Nothing -> pretty ""- (Just x) -> pretty $ standardExampleDiagram3 (zip (ivs ++ [x]) ["x1", "x2", "x3", "spanIv"]) []:} -- <- [x1] --- <- [x2] ---- <- [x3] --------- <- [spanIv] ===========/rangeInterval (Nothing :: Maybe (Interval Int))NothingrangeInterval (Just (bi 1 0)) Just (0, 1)interval-algebraIf x is 8 y, then form a new Just Interval a+ from the interval in the "gap" between x and y from the 5 of x to the 4 of y . Otherwise, .interval-algebraMaybe form a new  Interval a by the union of two  Interval as that 6.interval-algebralookback durationinterval-algebralookahead duration  Tools for visualizing intervals<(c) NoviSci, Inc 2020-2022 TargetRWE, 2023BSD36bsaul@novisci.com 2020-2022, bbrown@targetrwe.com 2023 Safe-Inferred '(>?interval-algebraType representing errors that may occur when parsing inputs into an .Not every possible state of a "bad" diagram is currently captured by . In particular, line labels can be a source of problems. The labels accept arbitrary Text. Newline characters in a label would, for example, throw things off. Labels that extend beyond the   will also cause problems.interval-algebraIndicates that one or more of the input intervals extend beyond the axis.interval-algebra5Indicates that the reference axis is longer than the  given in the .interval-algebraIndicates that left padding is >0 and no axis is printed. This is considered an error because it be impossible to know the 4" values of intervals in a printed IntervalDiagram) that has been padded and has no axis.interval-algebraIndicates that an error occurring when checking the document options.interval-algebra&Indicates something is wrong with the Axis.interval-algebraIndicates that at least one error occurred when parsing the interval lines.interval-algebraType containing the data needed to pretty print an interval document.interval-algebra)A type representing the types of invalid .interval-algebraIndicates that  is  Unbounded0, which isn't allowed for an IntervalDiagram.interval-algebra5Indicates that the left padding in the option is < 0.interval-algebra,A record containing options for printing an .interval-algebraSee  interval-algebraNumber of spaces to pad the left of the diagram by. Must be greater than or equal to 0.interval-algebra?A type representing errors that can occur when parsing an axis.interval-algebraIndicates that the position of one ore more axis labels is outside the reference intervalinterval-algebraIndicates that multiple labels have been put at the same positioninterval-algebraA type representing options of where to place the axis in a printed diagram.interval-algebra(Print the axis at the top of the diagraminterval-algebra+Print the axis at the bottom of the diagraminterval-algebra9A type representing errors that may occur when a list of  IntervalText is parsed into a IntervalTextLine.interval-algebraThe inputs contains concurring intervals. All inputs should be I.interval-algebraThe inputs are not sorted.interval-algebra!At least one of the inputs has a 4 less than zero.interval-algebra IntervalText' is an internal type which contains an  Interval a and the Char) used to print the interval in a diagram.5pretty $ makeIntervalText '-' (beginerval 5 (0::Int))-----6pretty $ makeIntervalText '*' (beginerval 10 (0::Int)) **********interval-algebraDefault  optionsinterval-algebra.Parse inputs into a pretty printable document.This function provides the most flexibility in producing interval diagrams.Here's a basic diagram that shows how to put more than one interval interval on a line:9let mkIntrvl c d b = makeIntervalText c (bi d (b :: Int))let x = mkIntrvl '=' 20 0let l1 = [ mkIntrvl '-' 1 4 ]let l2 = [ mkIntrvl '*' 3 5, mkIntrvl '*' 5 10, mkIntrvl 'x' 1 17 ]let l3 = [ mkIntrvl '#' 2 18]pretty $ parseIntervalDiagram defaultIntervalDiagramOptions [] (Just Bottom) x [ (l1, []), (l2, []), (l3, []) ] - *** ***** x ##====================We can put the axis on the top:pretty $ parseIntervalDiagram defaultIntervalDiagramOptions [] (Just Top) x [ (l1, []), (l2, []), (l3, []) ]==================== - *** ***** x ##We can annotate the axis:pretty $ parseIntervalDiagram defaultIntervalDiagramOptions [(5, 'a')] (Just Bottom) x [ (l1, []), (l2, []), (l3, []) ] - *** ***** x ##==================== | a+We can also annotate each line with labels:pretty $ parseIntervalDiagram defaultIntervalDiagramOptions [] (Just Bottom) x [ (l1, ["line1"]), (l2, ["line2a", "line2b"]), (l3, ["line3"]) ] - <- [line1]( *** ***** x <- [line2a, line2b] ## <- [line3]====================The parser tries to check that the data can be printed. For example, the default  is 80 characters. Providing an reference interval wider than 80 characters results in an error.let x = mkIntrvl '=' 100 5let ivs = [ mkIntrvl '-' 1 1 ]parseIntervalDiagram defaultIntervalDiagramOptions [] Nothing x [ (ivs, []) ]Left AxisWiderThanAvailableSee  for all the cases handled.interval-algebraGiven a reference interval and a list of intervals, produces an ' with one line per interval, using the .pretty $ simpleIntervalDiagram (bi 10 (0 :: Int)) (fmap (bi 1) [0..9]) - - - - - - - - - - ==========let ref = bi 30 (0 :: Int)&let ivs = [ bi 2 0, bi 5 10, bi 6 16 ]&pretty $ simpleIntervalDiagram ref ivs-- ----- ------==============================interval-algebraGiven various inputs containing intervals and their label, creates an interval diagram with labels, along with a reference range that spans all of the intervals and is extended to include 0 if necesary.In more detail, an interval diagram is created with one row in the diagram for each interval and label pair provided as the first input, and followed by a sequence of additional rows with one row per list element in the second input and such that each row displays each interval provided in the intervals list and label pair.x1 = beginerval 4 1x2 = beginerval 3 7x3 = beginerval 2 13ivs = [x1, x2, x3](gaps = [beginerval 2 5, beginerval 3 10]:{pretty $ standardExampleDiagram (zip ivs ["x1", "x2", "x3"]) [(gaps, "gaps")]:} ---- <- [x1] --- <- [x2] -- <- [x3] -- --- <- [gaps]===============:{?pretty $ standardExampleDiagram (zip ivs ["x1", "x2", "x3"]) []:} ---- <- [x1] --- <- [x2] -- <- [x3]===============3pretty $ standardExampleDiagram [] [(gaps, "gaps")] -- --- <- [gaps] =============%pretty $ standardExampleDiagram [] []IntervalsExtendBeyondAxisinterval-algebraDocument options (see )interval-algebraA list of axis labelsinterval-algebra An optional  of the axisinterval-algebraThe reference (axis interval)interval-algebraIntervals to include in the diagram. Each item in the list creates a new line in the printed diagram. Text creates an optional label for the line.interval-algebraThe axis intervalinterval-algebra,List of intervals to be printed one per line!! *Implementation of Allen's interval algebra<(c) NoviSci, Inc 2020-2022 TargetRWE, 2023BSD3bsaul@novisci.com 2020-2022 bbrown@targetrwe.com 2023 Safe-Inferred'   +*)('&%$#" !,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijk,Functions for generating arbitrary intervals<(c) NoviSci, Inc 2020-2022 TargetRWE, 2023BSD36bsaul@novisci.com 2020-2022, bbrown@targetrwe.com 2023 experimental Safe-Inferred >?interval-algebraConditional generation of intervals relative to a reference. If the reference iv is of  duration, it is not possible to generate intervals from the strict enclose relations StartedBy, Contains, FinishedBy. If iv and rs are such that no possible relations can be generated, this function returns . Otherwise, it returns  an interval that satisfies at least one of the possible relations in rs relative to iv. > import Test.QuickCheck (generate) > import Data.Set (fromList) > isJust $ generate $ arbitraryWithRelation (beginerval 10 (0::Int)) (fromList [Before]) Just (20, 22) > generate $ arbitraryWithRelation (beginerval 1 (0::Int)) (fromList [StartedBy]) Nothing > generate $ arbitraryWithRelation (beginerval 1 (0::Int)) (fromList [StartedBy, Before]) Just (4, 13) interval-algebrareference intervalinterval-algebraset of s, of which at least one will hold for the generated interval relative to the referenceProperties of Intervals<(c) NoviSci, Inc 2020-2022 TargetRWE, 2023BSD36bsaul@novisci.com 2020-2022, bbrown@targetrwe.com 2023 Safe-Inferred >?interval-algebraA set used for testing M5.interval-algebraA set used for testing M2 defined so that the M2 condition is true.interval-algebraA set used for testing M1 defined so that the M1 condition is true.interval-algebraInternal function for converting a number to a strictly positive value.interval-algebraSmart constructor of .interval-algebraAxiom M1The first axiom of Allen and Hayes (1987) states that if "two periods both meet a third, thn any period met by one must also be met by the other." That is: \forall \text{ i,j,k,l } s.t. (i:j \text{ & } i:k \text{ & } l:j) \implies l:k interval-algebraSmart constructor of .interval-algebraAxiom M2If period i meets period j and period k meets l, then exactly one of the following holds:1) i meets l; 2) there is an m such that i meets m and m meets l; 3) there is an n such that k meets n and n meets j.That is, \forall i,j,k,l s.t. (i:j \text { & } k:l) \implies i:l \oplus (\exists m s.t. i:m:l) \oplus (\exists m s.t. k:m:j) interval-algebra Axiom ML1An interval cannot meet itself. \forall i \lnot i:i interval-algebra Axiom ML2$If i meets j then j does not meet i.$ \forall i,j i:j \implies \lnot j:i interval-algebraAxiom M3Time does not start or stop:" \forall i \exists j,k s.t. j:i:k interval-algebraML3 says that For all i, there does not exist m such that i meets m and m meet i. Not testing that this axiom holds, as I'm not sure how I would test the lack of existence easily.Axiom M4If two meets are separated by intervals, then this sequence is a longer interval. \forall i,j i:j \implies (\exists k,m,n s.t m:i:j:n \text { & } m:k:n) interval-algebraSmart constructor of .interval-algebraAxiom M5=There is only one time period between any two meeting places.7 \forall i,j,k,l (i:j:l \text{ & } i:k:l) \equiv j = k interval-algebra Axiom M4.1Ordered unions: \forall i,j i:j \implies (\exists m,n s.t. m:i:j:n \text{ & } m:(i+j):n) Properties of Intervals<(c) NoviSci, Inc 2020-2022 TargetRWE, 2023BSD36bsaul@novisci.com 2020-2022, bbrown@targetrwe.com 2023 Safe-Inferred>?linterval-algebra*For any two pair of intervals exactly one  should holdinterval-algebraGiven a set of interval relations and predicate function, test that the predicate between two interval is equivalent to the relation of two intervals being in the set of relations.  Safe-Inferred    !"#$%&'()*+,-./0123456789:;<=>>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~          interval-algebra-2.2.0-inplaceIntervalAlgebra.IntervalDiagramIntervalAlgebra.CoreIntervalAlgebra.PairedInterval!IntervalAlgebra.IntervalUtilitiesIntervalAlgebra.ArbitraryIntervalAlgebra.Axioms"IntervalAlgebra.RelationProperties PrettyPrinter pageWidth LayoutOptionsIntervalAlgebraPaths_interval_algebraprettyprinter-1.7.1-a7aefb3cc2c5e3a1c24691222b3d98381c8f4da6debc4b37281d36aa71a19b97Prettyprinter.Internal prettyListprettyPrettyComparativePredicateOf2ComparativePredicateOf1SizedIvMomentmomentduration ivExpandr ivExpandl PointedIvPointivBeginivEndIvivRelateivBeforeivAfterivMeetsivMetBy ivOverlapsivOverlappedByivStarts ivStartedBy ivFinishes ivFinishedByivDuring ivContainsivEqualsIntervalRelationBeforeMeetsOverlaps FinishedByContainsStartsEquals StartedByDuringFinishes OverlappedByMetByAfter Intervallic getInterval setIntervalParseErrorIntervalInterval parseIntervalprsibeginendmeetsmetBybeforeafterprecedes precededByoverlaps overlappedBystarts startedByfinishes finishedByduringcontainsequals<|>disjointRelationswithinRelationsstrictWithinRelationsdisjoint notDisjointconcurwithin enclosedByenclosesintervalRelationsconverseRelationunionPredicates predicaterelatecompose complement intersectionunionconverseexpandexpandlexpandr beginervalbiendervalei safeIntervalsibeginervalFromEndendervalFromBeginbeginervalMomentendervalMoment extentervalshiftFromBegin shiftFromEndfromEnumIntervaltoEnumInterval momentize $fOrdInterval$fNFDataInterval$fBinaryInterval$fShowInterval$fIntervallicInterval$fOrdIntervalRelation$fBoundedIntervalRelation $fIvInterval$fPointedIvInterval$fSizedIvInterval$fSizedIvInterval0$fSizedIvInterval1$fSizedIvInterval2$fSizedIvInterval3$fEnumIntervalRelation$fEqIntervalRelation$fShowIntervalRelation$fEqParseErrorInterval$fShowParseErrorInterval $fEqInterval$fGenericIntervalEmptyPairedIntervalmakePairedInterval getPairData equalPairData intervals toTrivialPair trivialize$fShowPairedInterval$fOrdPairedInterval$fBinaryPairedInterval$fNFDataPairedInterval$fIntervallicPairedInterval $fMonoidEmpty$fSemigroupEmpty $fEqEmpty $fOrdEmpty $fShowEmpty$fEqPairedInterval$fGenericPairedIntervalpairGapslookback lookahead relations intersectgaps durationsclipcombineIntervalscombineIntervalsFromSorted rangeInterval><.+.IntervalDiagramParseErrorIntervalsExtendBeyondAxisAxisWiderThanAvailablePaddingWithNoAxis OptionsError AxisErrorIntervalLineErrorIntervalDiagramIntervalDiagramOptionsErrorUnboundedPageWidthLeftPaddingLessThan0IntervalDiagramOptionsMkIntervalDiagramOptionslayout leftPaddingAxisParseErrorLabelsBeyondReferenceMultipleLabelAtSamePosition AxisPlacementTopBottomIntervalTextLineParseErrorConcurringIntervalsUnsortedIntervalsBeginsLessThanZero IntervalTextdefaultIntervalDiagramOptionsparseIntervalDiagramsimpleIntervalDiagramstandardExampleDiagram$fPrettyIntervalText$fIntervallicIntervalText$fPrettyIntervalTextLine$fPrettyEither $fPrettyAxis$fPrettyEither0$fPrettyIntervalDiagram$fPrettyEither1$fEqIntervalDiagramParseError$fShowIntervalDiagramParseError$fShowIntervalDiagram$fEqIntervalDiagramOptionsError!$fShowIntervalDiagramOptionsError$fEqIntervalDiagramOptions$fShowIntervalDiagramOptions$fEqAxisParseError$fShowAxisParseError$fEqAxis $fShowAxis$fEqAxisConfig$fShowAxisConfig$fEqAxisLabels$fShowAxisLabels$fEqAxisPlacement$fShowAxisPlacement$fEqIntervalTextLineParseError $fShowIntervalTextLineParseError$fOrdIntervalTextLineParseError$fShowIntervalTextLine$fEqIntervalText$fShowIntervalTextarbitrarySizedPositive maxDiffTimesizedIntervalGengenDaygenNominalDiffTime genDiffTime genUTCTimearbitraryWithRelation$fArbitraryInterval$fArbitraryInterval0$fArbitraryInterval1$fArbitraryInterval2$fArbitraryInterval3M5setm51m52M2setm21m22m23m24M1setm11m12m13m14xormakePosm1setprop_IAaxiomM1m2setprop_IAaxiomM2prop_IAaxiomML1prop_IAaxiomML2prop_IAaxiomM3prop_IAaxiomM4m5setprop_IAaxiomM5prop_IAaxiomM4_1$fArbitraryM1set$fArbitraryM1set0$fArbitraryM1set1$fArbitraryM2set$fArbitraryM2set0$fArbitraryM2set1$fArbitraryM5set$fArbitraryM5set0$fArbitraryM5set1 $fShowM5set $fShowM2set $fShowM1setallIArelationsprop_exclusiveRelationsprop_predicate_unions prop_IAbefore prop_IAstartsprop_IAfinishesprop_IAoverlaps prop_IAduringprop_disjoint_predicateprop_notdisjoint_predicateprop_concur_predicateprop_within_predicateprop_enclosedBy_predicateprop_encloses_predicateghc-prim GHC.ClassesOrdbaseGHC.NumNumcontainers-0.6.5.1Data.Set.InternalSet Data.FixedPico GHC.MaybeJustGHC.BaseFunctorNothing PageWidthversiongetDataFileName getBinDir getLibDir getDynLibDir getDataDir getLibexecDir getSysconfDir