Skip to content

Make interval-valued quantities part of the type system #30

Description

@isomorphisms

Current status — 2026-09-02

PARTIALLY_IMPLEMENTED. Verified open PR #44 supplies exact rational one-dimensional intervals, open/closed/half-open endpoints, empty handling, membership, and interval addition. Still open: multiplication/division, outward floating rounding, dependency/correlation such as x - x, unbounded forms, comparison outcomes, dimensional composition, and broader uncertainty/probability semantics. Do not treat the first kernel as completion of this issue.


Goal

Idriç should support interval-valued quantities as a type-system concern rather than treating intervals as an isolated numeric library idea.

The compiler should understand that a value may represent a set/range of possible values while preserving whatever other semantic structure the quantity carries:

Interval Float16
Interval Length
Interval Temperature
Interval (Quantity D)

Do not collapse the range, dimension, unit, or uncertainty source into a bare scalar prematurely.

Settled interval kernel

Preserve ordinary interval forms explicitly:

[a,b]
(a,b)
[a,b)
(a,b]
empty
unbounded endpoints where supported

Basic exact arithmetic should obey the usual enclosure semantics:

[1,3] + [4,9] = [5,12]

Multiplication should enclose all endpoint-product possibilities using the appropriate extrema.

When endpoint arithmetic is finite precision, especially Float16/Float32, require outward rounding where necessary so the represented interval contains the exact mathematical result. A numerically close but too-narrow interval is semantically wrong.

Dependency / correlation is deliberately not solved by naive intervals

Keep this forcing example visible:

x : [0,1]
x - x

Naive independent interval propagation gives [-1,1], while the compiler may know that both occurrences are the same x, in which case the exact result is 0.

Do not claim ordinary interval arithmetic solves this. Preserve room for expression identity, affine arithmetic, symbolic constraints, or another correlation-aware refinement later.

Nominal value, tolerance, uncertainty, and rounding are different facts

The August 29, 2026 discussion made this distinction explicit:

exact nominal value
manufacturing tolerance
measurement uncertainty
machine rounding

A nominal 1/4 inch can be an exact rational quantity. A physical socket labelled 1/4 inch is not thereby asserted to have mathematically exact physical width.

A useful first tolerance representation is simply an interval around an exact nominal value:

0.250 in ± 0.001 in
    -> [0.249 in, 0.251 in]

0.250 in +0.002/-0.001
    -> [0.249 in, 0.252 in]

This should compose with #28 dimensional/unit information.

Comparisons need not immediately become Bool

When ranges overlap, the type system should preserve the unresolved state rather than manufacture a Boolean answer. Candidate semantic outcomes include:

definitely_less
definitely_greater
definitely_equal where justified
overlap / unresolved

The final decision type is open; the requirement is not to erase uncertainty merely because the machine eventually has predicate bits.

This may also be useful for physical-fit questions: a tolerance-bearing socket/fastener relation can be definitely fitting, definitely not fitting, or unresolved/overlapping under the supplied tolerances.

Do not conflate interval uncertainty with infinitesimals

Keep distinct unless a later mathematical design explicitly relates them:

  • dual-number infinitesimal ε² = 0 — first-order/tangent information;
  • an ordered infinitesimal in an ordered field extension;
  • measurement tolerance/uncertainty;
  • finite-precision rounding error;
  • a symbolic placeholder such as x ± ε whose semantics have not yet been chosen.

A dual number may become valuable elsewhere in Idriç, but it should not silently become the universal representation of physical tolerance.

Candidate tests

[1,3] + [4,9] = [5,12]
exact rational endpoints stay exact where possible
open/closed endpoint semantics are preserved
empty intervals are explicit
unbounded intervals are explicit
finite-precision operations round outward
Interval Length + Interval Length -> Interval Length
Interval Length + Interval Time -> unresolved/incompatible dimension
0.250 in ± 0.001 in -> [0.249 in,0.251 in]
x:[0,1]; x-x remains a documented dependency/correlation probe

Open questions

  • endpoint openness at type level vs value level;
  • exact representation of infinities and empty sets;
  • correlation-aware refinement;
  • whether a general uncertainty wrapper sits above intervals;
  • efficient lowering of fixed-shape interval operations;
  • interaction with numerical sensitivity work (Future: carry numerical sensitivity information through Idriç #14);
  • how much static interval normalization belongs in elaboration;
  • whether the separate intervals repository remains useful as a research notebook even if Idriç becomes the implementation home.

Related

Broader goal: make “this quantity lies somewhere in this range” a first-class mathematical fact that survives typing, inference, optimization, and lowering.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions