frontend/itl_expr design
Design goal
The ITF1788 project publishes interval test cases for IEEE 1788-201511 IEEE Std 1788-2015, IEEE Standard for Interval Arithmetic. The
set-based flavor, decorations (clause 8) and the overlap relation (clause
10.6.4) are the parts exercised here.
in a small language, ITL. This package executes those cases against
interval, so that the interval claims in the
interval conformance page rest on an
external, pinned corpus. Like the other frontends it is pure: text in,
results out, no IO.
Mathematical background
Intervals and tightest results
In the set-based model an interval is a closed connected subset of : the empty set, the whole line, or with (infinite ends are open). For an operation and intervals , the range is over the points where is defined. In a number format (here binary64) the tightest result is the smallest -interval containing the hull of the range:
ITF1788 cases list this tightest interval as the expected value for the operations IEEE 1788 requires to be tightest. A test that compares bounds for equality therefore checks two things at once: containment (the result encloses the range) and tightness (no bound is one or more ulps too wide).
Decorations
A decorated interval is a pair with in the chain , recording what is known about the evaluation that produced (for example, : defined and continuous on a bounded box with a bounded result). NaI (“not an interval”) is the decorated empty set with . Operations propagate decorations by taking the minimum of the inputs’ decorations and the decoration of the operation on that box.
Overlap states
The overlap relation of two intervals has sixteen values: the thirteen
relations of Allen’s interval algebra for two nonempty intervals (before,
meets, overlaps, starts, containedBy, finishes, equals and their
converses) and three values for empty arguments. The package also maps a
NaI argument to undefined.
The pass rule
For an interval-valued case with actual result and expected , the case passes when
where holds when both are empty or both are
nonempty with and , comparing bounds
numerically (Binary::compare == 0, so , as in IEEE 1788 where
intervals are sets of reals). A number-valued case passes when the actual
number compares equal to the expected bound; a boolean case when the booleans
are equal; an overlap case when the state names are equal.
Design decisions
Execute against the public interval API
Each ITL operation maps to one public method of
@interval.DecoratedInterval (for example add to +, sqrt to
sqrt, pown to pown, overlap to overlap), and
results are rounded with IntervalContext::new(precision=p, e_max=1023), the format
the bounds were read in (binary64 for the default ). Testing through the
public API means the corpus checks exactly what users call, including the
decoration logic.
Reading bounds
Hexadecimal bounds 0x…p… are parsed exactly as an integer significand and a
binary exponent, then rounded to the working precision. Decimal bounds are
parsed as a decimal with digits and converted to binary with one
rounding to nearest-even at bits. For a literal with at most
significant digits the decimal parse is exact, so the bound is rounded once.
A longer literal is rounded twice, and the second rounding can then land on
the wrong side of a binary midpoint; the decimal expansion of a binary64
midpoint can have hundreds of digits, so this needs a literal with more than
significant digits, which ITF1788 data does not use.
Rounding to nearest rather than outward is the ITF1788 convention, not an
IEEE 1788 interval literal: the ITF1788 generator emits [l,u] as the inf-sup
constructor of the target type applied to two floating constants of that type,
so a decimal bound denotes the nearest number of the format. The corpus relies
on this (isSingleton [17.1, 17.1] = true, and the cancelPlus cases with
bound 5.1 expect the bounds computed from the nearest binary64 number).
Reading such bounds outward, as textToInterval would, fails strict cases in
the cancellation, power, atan2 and integer-power phases.
Decorations only when the case states one
ITL writes undecorated expectations ([4.0,6.0]) for the set-based tests and
decorated ones ([4.0,6.0]_com) for the decoration tests. The executor parses
an undecorated literal as but compares decorations only when the
expected text contains _, so set-based cases are not failed by the decoration
the implementation attaches.
Three dispositions and a strict summary
Unsupported marks cases the library does not implement (unknown operations
such as the reverse operations mulRevToPair, or, in the binary dispatch, an
expectation with a signal annotation). Diagnostic marks cases whose data
cannot be read. Support is decided from the operation name before any operand
is read, so an unknown operation is Unsupported whatever its operands
(nums2interval 1.0 2.0, rootn [1.0,8.0] 3). For a known operation the
classification is made by the dispatch path: a signal annotation on a unary,
ternary, numeric or integer-power case makes its expected value unreadable and
therefore a Diagnostic.
RunSummary::success fails on any failed case and on any diagnostic,
because unreadable data in a pinned corpus is a defect of the parser or the
corpus, not an excluded feature. Unsupported cases do not fail success; the
CLI’s --strict-supported turns them into a failing exit code for the phases
that claim full support.
Correctness and invariants
Counter identities. Every result has exactly one disposition, so and .
Soundness of a pass. If an interval-valued case passes, the actual bounds equal the expected bounds. When the expected value is the tightest binary64 enclosure, the actual result is then both an enclosure of the range and tightest; when the corpus only promises an enclosure (accurate rather than tightest operations), a pass shows that the implementation reached the same bounds.
Determinism. Parsing and execution depend only on the text and
precision; results do not depend on the order in which cases are executed,
so a caller may filter or reorder cases freely.
Totality. Every completed statement becomes a case or a parse diagnostic,
and execute_case never aborts on case content: every unreadable input is
reported through a disposition. Statement boundaries come from a line ending
in ; once its // comment is removed, so a trailing // … after ; does
not merge the statement with the next one.
Alternatives rejected
- Containment-only checking (). It would accept results that are many ulps too wide and hide accuracy regressions.
- Always comparing decorations. It would fail set-based cases on the default decoration, although those cases make no decoration claim.
- Treating signals as passes. IEEE 1788 signals (for example
UndefinedOperation) are not observable through the current API, so such cases are reported as not executed rather than silently passed.
Boundaries
- Reverse operations,
mulRevToPair, string conversions and exception signals are not executed. - Decimal bounds are rounded to nearest, as ITF1788 floating constants; an
[l,u]in ITL is not an IEEE 1788 interval literal. - The result format for
precision = phas the binary64 exponent range for every , soprecision = 24is not binary32. /*opens a block comment only at the start of a line.- No file IO and no operation filtering; both are in
cli/itl_expr_cli.
Footnotes
-
IEEE Std 1788-2015, IEEE Standard for Interval Arithmetic. The set-based flavor, decorations (clause 8) and the overlap relation (clause 10.6.4) are the parts exercised here. ↩