TorchLean API

NN.Floats.IEEEExec.ERealSemantics

Total EReal semantics helpers for IEEE32Exec #

BridgeERealTotal.lean defines toEReal? : IEEE32Exec → Option EReal, which is the canonical extended-real interpretation we use when we want to distinguish +∞ from -∞ and treat NaN as "unordered" (none).

In a few proof scripts, it is convenient to have a total function into EReal. We therefore define:

Informal reading rule:

If you see a theorem stated using toEReal, it should be read under hypotheses that exclude NaNs (isNaN x = false). Under that assumption, toEReal x agrees with the intended toEReal? meaning and behaves exactly as you would expect:

This file also collects small helper lemmas (toEReal_eq_ite, signed-zero simp facts, etc.) used by multiple IEEEExec proof modules.

toEReal (totalized) and unfolding helpers #

Total EReal interpretation of IEEE32Exec.

This is toEReal? with the NaN case mapped to 0.

Intended invariant: Most theorems about interval endpoints assume isNaN x = false. Under that precondition, the NaN branch is unreachable and toEReal agrees with the partial EReal semantics.

Instances For
    @[simp]

    If toEReal? x = some r, then toEReal x = r.

    @[simp]

    If toEReal? x = none, then toEReal x = 0.

    Convenient unfolding lemma for toEReal.

    This is the form that works best with simp once you have established/assumed (non-)NaN and (non-)Inf facts.

    Small finiteness helpers #

    These are convenience lemmas for switching between isFinite and special-value predicates in proofs.

    If x is finite, then x is not an infinity.

    On finite values, toEReal reduces to ↑(toReal x).

    This is the lemma we use most often to turn an EReal endpoint goal into a goal.

    Signed-zero simp facts #

    IEEE-754 has distinct bit patterns for +0 and -0, but both decode to real 0. In endpoint proofs we frequently want this fact at the toEReal level.

    @[simp]

    Both signed zeros map to 0 under toEReal.

    This is safe to use as a simp lemma: it is a very specific pattern and does not cause unfolding loops.