# Is DV_INTERVAL missing invariants? **Category:** [Specifications](https://discourse.openehr.org/c/specifications/6) **Created:** 2021-12-18 01:53 UTC **Views:** 471 **Replies:** 6 **URL:** https://discourse.openehr.org/t/is-dv-interval-missing-invariants/2210 --- ## Post #1 by @pablo Reading the RM 1.1.0 data types spec, in DV_INTERVAL and Interval types I think we are missing an invariant, for instance, if lower_included = true and lower = NULL, is that valid? Same with upper. I'm not seeing any constraint/invariant that says something about those cases. IMO lower/upper_included should imply lower/upper is not NULL. REFs: - https://specifications.openehr.org/releases/RM/Release-1.1.0/data_types.html#_dv_interval_class - https://specifications.openehr.org/releases/BASE/latest/foundation_types.html#_interval_class --- ## Post #2 by @thomas.beale DV_INTERVAL inherits the invariants from [Interval (BASE/Foundation Types)](https://specifications.openehr.org/releases/BASE/latest/foundation_types.html#_interval_class). --- ## Post #3 by @pablo Hi @thomas.beale I have considered the interval rules (see link above; though I don't see that case considered. That is why I'm asking :) --- ## Post #4 by @thomas.beale Sorry, read too fast - I thought I read 'missing invariants' ;) Yes, we should add the following: ``` lower_included implies lower /= NULL upper_included implies upper /= NULL ``` Do you mind adding a PR for this, containing this suggestion? We will need to process your waiting list of PRs pretty soon ;) --- ## Post #5 by @pablo Thanks @thomas.beale rechecking this I believe it should be: > !lower_unbounded <=> lower != NULL > !upper_unbounded <=> upper != NULL Note the <=> is stronger than the implies because this is an IFF (https://en.wikipedia.org/wiki/If_and_only_if) Because for intervals that have boundaries the lower/upper should always be there, but the interval could or not include the boundaries, like: - [1..10] includes both boundaries in the interval (lower_included = upper_included = true) - (1..10] includes only the upper boundary (lower_included = false, upper_included = true) - [1..10) includes only the lower boundary (lower_included = true, upper_included = false) --- ## Post #6 by @thomas.beale You could do this to be strict - the original invariant specification was designed with the sense that if lower_unbounded or upper_unbounded = True, it doesn't actually matter if any value is attached to lower or upper. The simpler way to state the stricter conditions is: ``` lower_unbounded xor lower /= Null upper_unbounded xor upper /= Null ``` --- ## Post #7 by @pablo Makes sense. --- **Canonical:** https://discourse.openehr.org/t/is-dv-interval-missing-invariants/2210 **Original content:** https://discourse.openehr.org/t/is-dv-interval-missing-invariants/2210