TorchLean API

FloatLib.Floats.Formats.DecimalInterchange.Environment.Proof

Sticky flags and scoped rounding laws #

Flags raised by an operation remain set after later operations. Clearing and restoring affect exactly the requested group. Scoped rounding restores the caller's direction while preserving the flags produced by the inner computation.

Restoring all saved flags preserves the current rounding direction.

@[simp]
theorem FloatLib.Floats.Formats.DecimalInterchange.Environment.accept_value (environment : Environment) (outcome : Outcome) :
(environment.accept outcome).1 = outcome.value

Exception accumulation never changes the operation's delivered datum.

@[simp]
theorem FloatLib.Floats.Formats.DecimalInterchange.Environment.run_rounding (environment : Environment) (operation : RoundingModeOutcome) :
(environment.run operation).2.rounding = environment.rounding

An operation preserves the ambient rounding direction.

theorem FloatLib.Floats.Formats.DecimalInterchange.Environment.run_isSet (environment : Environment) (operation : RoundingModeOutcome) (exception : Exception) :
Numerics.IEEEStatus.isSet (environment.run operation).2.flags exception = (Numerics.IEEEStatus.isSet environment.flags exception || Numerics.IEEEStatus.isSet (operation environment.rounding).status exception)

A flag after execution is the disjunction of its previous and newly raised states.

Two operations accumulate the union of both outcomes and the initial flags.

@[simp]
theorem FloatLib.Floats.Formats.DecimalInterchange.Environment.withRounding_rounding {α : Type u_1} (environment : Environment) (rounding : RoundingMode) (computation : Environmentα × Environment) :
(environment.withRounding rounding computation).2.rounding = environment.rounding

Scoped rounding restores the caller's direction, regardless of the inner computation.

theorem FloatLib.Floats.Formats.DecimalInterchange.Environment.withRounding_flags {α : Type u_1} (environment : Environment) (rounding : RoundingMode) (computation : Environmentα × Environment) :
(environment.withRounding rounding computation).2.flags = (computation { rounding := rounding, flags := environment.flags }).2.flags

Scoped rounding preserves the inner computation's resulting exception flags.