Executable ReLU approximation for configured IEEE formats #
hingeFunBinary evaluates a hinge network with a configured FloatFormat, storage plan, and
ModelCodec. Refinement to RoundedReLUApprox requires format.isIEEE = true and finite
intermediates. The result preserves the exact fold order and combines real approximation,
parameter quantization, and arithmetic rounding error.
HingeSumFinite records the finite intermediates. HingeSumBounds supplies sufficient bounds
on exact subtractions, products, and partial sums to establish that witness through FloatLib's
range theorems. Dyadic quantization bounds use the selected format's rounding and half-ulp API.
Embedding configured binary values into the rounded-real model #
Read an executable configured IEEE value as a point of the rounded-real model.
Instances For
Pointwise embedding of a vector of Value values into the rounded-real model.
Instances For
Configured binary hinge network (same shape as RoundedReLUApprox.hingeFun format) #
ReLU in the executable backend, as maximum x 0 rather than a branch, so that the IEEE 754
treatment of signed zeros and NaN comes from maximum itself.
Instances For
One hinge term cᵢ * ReLU(x - tᵢ) evaluated in the executable configured binary backend.
Instances For
Fold step for summing hinge terms, used by hingeSumBinary.
Instances For
Executable configured binary sum of hinge terms, in ascending index order.
Instances For
Executable configured binary hinge network: sum hinge terms, then add the executable bias.
Instances For
A finiteness witness for IEEE evaluation (no NaN/Inf intermediates) #
Every intermediate of the hinge fold is finite: no subtraction, ReLU, product, or partial sum overflows to an infinity or produces a NaN.
Stating it as an inductive over the remaining index list rather than as a conjunction is what makes
it checkable by decide on a concrete input, via the instance instDecHingeSumFinite.
- nil {format : FloatLib.Floats.Formats.BinaryInterchange.FloatFormat} {plan : FloatLib.Floats.Formats.BinaryInterchange.Configured.StoragePlan format} {code : Type} [FloatLib.Floats.ExecFloat.ModelCodec plan (FloatLib.Floats.Formats.BinaryInterchange.Model format) code] {n : ℕ} {t c : Fin n → FloatLib.Floats.ExecFloat (FloatLib.Floats.Formats.BinaryInterchange.Configured.Family format code plan)} {x acc : FloatLib.Floats.ExecFloat (FloatLib.Floats.Formats.BinaryInterchange.Configured.Family format code plan)} (hacc : FloatLib.Floats.ExecFloat.Binary.isFinite acc = true) : HingeSumFinite t c x acc []
- cons {format : FloatLib.Floats.Formats.BinaryInterchange.FloatFormat} {plan : FloatLib.Floats.Formats.BinaryInterchange.Configured.StoragePlan format} {code : Type} [FloatLib.Floats.ExecFloat.ModelCodec plan (FloatLib.Floats.Formats.BinaryInterchange.Model format) code] {n : ℕ} {t c : Fin n → FloatLib.Floats.ExecFloat (FloatLib.Floats.Formats.BinaryInterchange.Configured.Family format code plan)} {x acc : FloatLib.Floats.ExecFloat (FloatLib.Floats.Formats.BinaryInterchange.Configured.Family format code plan)} {i : Fin n} {xs : List (Fin n)} (hsub : FloatLib.Floats.ExecFloat.Binary.isFinite (x.sub (t i)) = true) (hmax : (x.sub (t i) ⊔ 0).isFinite = true) (hmul : FloatLib.Floats.ExecFloat.Binary.isFinite (hingeTermBinary c t x i) = true) (hadd : FloatLib.Floats.ExecFloat.Binary.isFinite (acc.add (hingeTermBinary c t x i)) = true) (hrest : HingeSumFinite t c x (acc.add (hingeTermBinary c t x i)) xs) : HingeSumFinite t c x acc (i :: xs)
Instances For
Discharging HingeSumFinite for concrete networks by computation #
For typical verification workflows, t, c, and x are concrete configured binary constants
coming from a lowered model artifact. In that setting, the easiest way to satisfy the
HingeSumFinite … hypotheses is to compute the configured binary kernel and check finiteness at
every intermediate.
instDecHingeSumFinite is a Decidable instance for HingeSumFinite … that walks the fold, so a
true concrete instance closes by computation:
have hSum : HingeSumFinite t c x (0 : Value) (List.finRange n) := by
decide
This does not solve the symbolic “no overflow for all x” problem, but it makes the pointwise theorems in this file directly usable for concrete executions.
Decide HingeSumFinite by walking the fold, which is what lets concrete runs use decide.
A compact finiteness hypothesis bundle (pointwise) #
The finiteness hypotheses the pointwise theorems need, bundled into one conjunction.
Instances For
Sufficient range bounds for finite intermediates #
Exact arithmetic bounds along the executable fold. Each bound compares the unrounded operation with the selected format's largest finite value.
- nil {format : FloatLib.Floats.Formats.BinaryInterchange.FloatFormat} {plan : FloatLib.Floats.Formats.BinaryInterchange.Configured.StoragePlan format} {code : Type} [FloatLib.Floats.ExecFloat.ModelCodec plan (FloatLib.Floats.Formats.BinaryInterchange.Model format) code] {n : ℕ} {t c : Fin n → FloatLib.Floats.ExecFloat (FloatLib.Floats.Formats.BinaryInterchange.Configured.Family format code plan)} {x acc : FloatLib.Floats.ExecFloat (FloatLib.Floats.Formats.BinaryInterchange.Configured.Family format code plan)} : HingeSumBounds t c x acc []
- cons {format : FloatLib.Floats.Formats.BinaryInterchange.FloatFormat} {plan : FloatLib.Floats.Formats.BinaryInterchange.Configured.StoragePlan format} {code : Type} [FloatLib.Floats.ExecFloat.ModelCodec plan (FloatLib.Floats.Formats.BinaryInterchange.Model format) code] {n : ℕ} {t c : Fin n → FloatLib.Floats.ExecFloat (FloatLib.Floats.Formats.BinaryInterchange.Configured.Family format code plan)} {x acc : FloatLib.Floats.ExecFloat (FloatLib.Floats.Formats.BinaryInterchange.Configured.Family format code plan)} {i : Fin n} {xs : List (Fin n)} (hsub : |(FloatLib.Floats.ExecFloat.Binary.toModel x).toReal - (FloatLib.Floats.ExecFloat.Binary.toModel (t i)).toReal| ≤ (FloatLib.Floats.Formats.BinaryInterchange.Model.posMaxFinite format).toReal) (hmul : |(FloatLib.Floats.ExecFloat.Binary.toModel (c i)).toReal| * |(FloatLib.Floats.ExecFloat.Binary.toModel (reluBinary (x.sub (t i)))).toReal| ≤ (FloatLib.Floats.Formats.BinaryInterchange.Model.posMaxFinite format).toReal) (hadd : |(FloatLib.Floats.ExecFloat.Binary.toModel acc).toReal + (FloatLib.Floats.ExecFloat.Binary.toModel (hingeTermBinary c t x i)).toReal| ≤ (FloatLib.Floats.Formats.BinaryInterchange.Model.posMaxFinite format).toReal) (hrest : HingeSumBounds t c x (acc.add (hingeTermBinary c t x i)) xs) : HingeSumBounds t c x acc (i :: xs)
Instances For
Bounds on each exact subtraction, product, and partial sum rule out exceptional intermediates, starting from finite inputs, parameters, and accumulator.
A finite-fold witness guarantees that its final accumulator is finite.
Range bounds on the fold and final bias addition discharge the complete execution witness.
Refinement to rounded-real execution #
Refine an executable hinge-term fold to the rounded-real fold with the same order.
Floating-point addition is not associative, so the theorem preserves the exact List.finRange
evaluation order. This is why the proof is fold-based rather than rewriting directly to an
unordered finite sum.
Refine the whole executable hinge network to the rounded-real network.
The theorem composes the fold refinement with the final rounded bias addition. Its hypotheses are exactly the finiteness obligations needed by the IEEE-754 bridge lemmas.
Configured binary error bound inherited from the rounded-real bound #
Lift the rounded-real hinge-network error bound to executable evaluation.
The refinement toReal_hinge_fun_binary_eq_rounded_val identifies the executable result
with the rounded-real model, so its error bound transfers directly.
“Approximation error + rounding error” (pointwise) #
Pointwise triangle bound: target error to executable output is bounded by real approximation error plus the certified IEEE arithmetic rounding error.
Strict version of hinge_fun_total_abs_error_binary_le, useful for approximation theorems.
Configured binary pointwise ReLU approximation packaging (1D) #
1D ReLU approximation statement over configured binary values.
This is not a full universal approximation theorem, because it does not construct IEEE weights
from a real target. Instead it packages the already-proved pointwise inequality
hinge_fun_total_abs_error_binary_lt into an existence/for-all form:
- assume there exist configured binary hinge parameters
(t,c,b0)that approximatefat the real level (viahingeFunReal formaton the embedded reals), - and assume a finiteness/no-NaN/no-Inf witness for configured binary evaluation,
- then configured binary evaluation approximates
fwith an explicit extra rounding termhingeFunErrorBound format.
Real approximation + quantization + IEEE rounding (1D, pointwise) #
1D configured binary ReLU approximation with an explicit 3-term error decomposition, relative to a
caller-supplied real reference bias bR:
- Real approximation error: $|f(r)-\operatorname{hinge\_fun}(\ldots,r)|<\varepsilon_{\mathrm{approx}}$.
- Quantization/reference error: $|\operatorname{hinge\_fun}(\ldots,r) -\operatorname{hinge\_fun}_{\mathbb R}(\operatorname{embed}(\text{IEEE parameters}), \operatorname{embed}(r))|\leq\varepsilon_Q$.
- IEEE rounding error (proved):
hingeFunErrorBound format.
To obtain a fully synthesized configured binary approximation theorem, callers must additionally:
- construct configured binary parameters
(t,c,b0)from the real hinge parameters, and - prove the finiteness/no-NaN/no-Inf witnesses (
HingeSumFinite+ finite output), and - prove a uniform bound
εQfor the parameter-quantization step.
Specialization of relu_approximation_Icc_binary_three_term_bias to the real bias f a, which is
the bias the constructive one-dimensional interpolation theorem emits.
Dyadic quantization helpers #
Half-ulp error bound for dyadic values rounded into executable configured binary values.
The finiteness hypothesis excludes overflow/NaN paths, after which the executable rounding of a
dyadic agrees with the real Model.roundAt format operation used by the rounded-real model,
and FloatLib's local rounding bound Model.abs_roundAt_sub_le applies.
Real hinge network sensitivity to parameter rounding (for a compact input domain) #
This is the “εQ quantization” step for relu_approximation_Icc_binary_three_term.
The lemma below uses the compact-domain assumption that the reference knot locations tR
lie in the input interval [a,b], then bounds the output perturbation using:
- a width term
|b-a|to boundrelu(x - tR i)on the interval, and relu_lipschitzto control the sensitivity to perturbingt.
Sensitivity of a real hinge network to perturbing all parameters on a compact interval.
The bound decomposes into a bias perturbation, a coefficient perturbation weighted by the interval
width, and a knot perturbation weighted by the absolute executable coefficients. This is the real
analysis step that supplies the quantization term εQ.
Uniform version of hinge_fun_abs_error_le_of_params_Icc.
Instead of summing per-neuron perturbation bounds, this theorem uses uniform coefficient and knot
budgets Δc, C, and Δt, producing the simpler expression
|bR-bI| + n * (Δc * |b-a| + C * Δt).
Removing the quantization term when reals are exactly representable #
The embedded real reference is exactly the ordinary real hinge network evaluated on
entrywise ExecFloat.Binary.toModel followed by Model.toReal parameters.
Uniform quantization-error bound between a real hinge network and executable IEEE parameters.
This is the user-facing εQ discharge lemma when callers can bound coefficient and knot rounding
errors uniformly.
Dyadic-to-configured binary quantization bound (εQ) #
This lemma is a drop-in way to discharge the εQ premise of
relu_approximation_Icc_binary_three_term when IEEE parameters are obtained by rounding dyadic
rationals with Model.roundDyadic format.
Dyadic quantization error for a hinge network on [a,b].
The real reference uses exact dyadic parameters, while the executable reference uses those dyadics rounded to configured binary values. The result is still expressed as a sum of concrete per-parameter rounding errors.
Dyadic quantization error with each per-parameter rounding error bounded by a half-ulp term.
This is the more automated version of hinge_fun_dyadic_quantization_error_le_Icc: callers provide
finiteness of every rounded dyadic value, and the theorem substitutes the standard half-ulp bounds.
Packaged “dyadic quantization + IEEE rounding” theorem (1D, pointwise) #
This is the “dyadic next step”: it replaces the abstract εQ premise of
relu_approximation_Icc_binary_three_term_bias with a concrete bound coming from:
- dyadic→arithmetic rounding (
≤ 1/2 ulp), and - a Lipschitz-style sensitivity bound for the real hinge network on
x ∈ [a,b].
It still assumes the IEEE finiteness witnesses for evaluation (HingeSumFinite + finite output).
Three-term configured binary approximation bound with the quantization term instantiated by the
half-ulp
dyadic rounding budget of hinge_fun_dyadic_quantization_error_le_Icc_half_ulp.
Two-term 1D configured binary ReLU approximation statement:
- assume the real hinge network built from the IEEE parameters’
toRealvalues already approximatesfontoRealinputs in[a,b], - and assume finiteness/no-NaN/no-Inf witnesses,
- then IEEE execution approximates
fwith an explicit IEEE rounding term.
This is a specialization of the 3-term theorem with εQ = 0.