TorchLean API

NN.Proofs.RL.Floats.CheckedRuntime

Runtime Checked Preconditions → Float32 Semantics Theorems #

NN.Proofs.RL.Floats.IEEE32Exec proves refinement theorems for RL formulas in the executable ExecFloat.Binary 8 23 float32 semantics, but those theorems are intentionally stated with explicit isFinite … = true hypotheses for each intermediate.

In the runtime layer, TorchLean typically enforces these hypotheses by checked preconditions: Runtime.RL.Numerics.Float32.*Checked returns Except String and fails fast if any intermediate becomes NaN/Inf.

This file is the glue: it turns “the runtime checker returned .ok” into the proof hypotheses needed by the refinement theorem, yielding a user-facing statement:

checked boundary ⇒ theorem applies.

References:

theorem Proofs.RL.Float32Exec.toReal_discountedBackupChecked_eq_fp32Round_chain (reward gamma bootstrap : FloatLib.Floats.ExecFloat.Binary 8 23 FloatLib.Floats.Formats.BinaryInterchange.FloatFormat.Encoding.ieee (FloatLib.Floats.Formats.BinaryInterchange.FloatFormat.Encoding.ieee.defaultBias 8) toReal_discountedBackupChecked_eq_fp32Round_chain._proof_1 toReal_discountedBackupChecked_eq_fp32Round_chain._proof_2 toReal_discountedBackupChecked_eq_fp32Round_chain._proof_3 toReal_discountedBackupChecked_eq_fp32Round_chain._proof_4) (done : Bool) (out : FloatLib.Floats.ExecFloat.Binary 8 23 FloatLib.Floats.Formats.BinaryInterchange.FloatFormat.Encoding.ieee (FloatLib.Floats.Formats.BinaryInterchange.FloatFormat.Encoding.ieee.defaultBias 8) toReal_discountedBackupChecked_eq_fp32Round_chain._proof_1 toReal_discountedBackupChecked_eq_fp32Round_chain._proof_2 toReal_discountedBackupChecked_eq_fp32Round_chain._proof_3 toReal_discountedBackupChecked_eq_fp32Round_chain._proof_4) (h : Runtime.RL.Numerics.Float32.discountedBackupChecked reward gamma bootstrap done = Except.ok out) :

If Runtime.RL.Numerics.Float32.discountedBackupChecked returns .ok, then the decoded real meaning of the result agrees with the standard “real-op + round-to-float32” model (fp32Round) at each primitive operation.

This is the direct checked boundary ⇒ semantics theorem applies wrapper.

theorem Proofs.RL.Float32Exec.toReal_tdResidualChecked_eq_fp32Round_chain (value reward gamma nextValue : FloatLib.Floats.ExecFloat.Binary 8 23 FloatLib.Floats.Formats.BinaryInterchange.FloatFormat.Encoding.ieee (FloatLib.Floats.Formats.BinaryInterchange.FloatFormat.Encoding.ieee.defaultBias 8) toReal_discountedBackupChecked_eq_fp32Round_chain._proof_1 toReal_discountedBackupChecked_eq_fp32Round_chain._proof_2 toReal_discountedBackupChecked_eq_fp32Round_chain._proof_3 toReal_discountedBackupChecked_eq_fp32Round_chain._proof_4) (done : Bool) (out : FloatLib.Floats.ExecFloat.Binary 8 23 FloatLib.Floats.Formats.BinaryInterchange.FloatFormat.Encoding.ieee (FloatLib.Floats.Formats.BinaryInterchange.FloatFormat.Encoding.ieee.defaultBias 8) toReal_discountedBackupChecked_eq_fp32Round_chain._proof_1 toReal_discountedBackupChecked_eq_fp32Round_chain._proof_2 toReal_discountedBackupChecked_eq_fp32Round_chain._proof_3 toReal_discountedBackupChecked_eq_fp32Round_chain._proof_4) (h : Runtime.RL.Numerics.Float32.tdResidualChecked value reward gamma nextValue done = Except.ok out) :

If Runtime.RL.Numerics.Float32.tdResidualChecked returns .ok, then the decoded real meaning of the result agrees with the standard “real-op + round-to-float32” model (fp32Round) at each primitive operation.

This is the checked boundary ⇒ semantics theorem applies wrapper for TD residuals.