LAProof.accuracy_proofs.dot_acc
Dot Product Accuracy Proofs (Non-FMA)
Error Factors
Main Results
- dotprod_mixed_error: Shows that the computed dot product can be
expressed as an exact dot product of slightly perturbed inputs plus a
small absolute error term. Each input component is perturbed by a
relative factor bounded by \(g(n)\), and the absolute
residual is bounded by \(g_1(n,n)\), where
\(n\) is the vector length.
- dotprod_forward_error: Bounds the absolute forward error
\(|\mathtt{fl}(v_1 \cdot v_2) - v_1 \cdot v_2|\)
by \(g(n)\,(|v_1| \cdot |v_2|) + g_1(n,\,n-1)\),
where \(|v|\) denotes componentwise absolute value.
- sparse_dotprod_forward_error: Refines dotprod_forward_error for sparse inputs by replacing the full vector length \(n\) with the number of nonzero entries \(n_{\mathrm{nz}}\), giving a tighter bound when the input vectors are sparse.
Dependencies
- preamble: basic setup and notation,
- common: shared definitions including
nnzRandneg_zero, - dotprod_model: the floating-point model dotprodF and its relational characterization dotprodF_rel_fold_right,
- sum_model: summation model infrastructure,
- float_acc_lems: generic floating-point accuracy lemmas,
- dot_acc_lemmas: the core relational accuracy lemmas dotprod_mixed_error_rel, dotprod_forward_error_rel, and sparse_dotprod_forward_error_rel that drive the proofs here.
Structure
- MixedError: proves dotprod_mixed_error.
- ForwardError: proves dotprod_forward_error and sparse_dotprod_forward_error.
From LAProof.accuracy_proofs Require Import
preamble
common
dotprod_model
sum_model
float_acc_lems
dot_acc_lemmas.
Require Import Reals.
Open Scope R.
Section MixedError.
Context {NAN : FPCore.Nans} {t : type}.
Notation g := (@g t).
Notation g1 := (@g1 t).
Notation D := (@default_rel t).
Notation E := (@default_abs t).
Notation neg_zero := (@common.neg_zero t).
Variables (v1 v2 : list (ftype t)).
Hypothesis Hlen : size v1 = size v2.
Hypothesis Hfin : Binary.is_finite (dotprodF v1 v2) = true.
dotprod_mixed_error expresses the computed dot product as an exact inner
product of component-wise perturbed inputs plus a small absolute offset.
The relative perturbation on each input component is bounded by
\(g(n)\) and the absolute residual by \(g_1(n,n)\).
Lemma dotprod_mixed_error :
∃ (u : list R) (eta : R),
size u = size v2
∧ FT2R (dotprodF v1 v2) = dotprodR u (map FT2R v2) + eta
∧ (∀ n, (n < size v2)%nat →
∃ delta,
nth 0 u n = FT2R (nth neg_zero v1 n) × (1 + delta)
∧ Rabs delta ≤ g (size v2))
∧ Rabs eta ≤ g1 (size v2) (size v2).
End MixedError.
Section ForwardError.
Context {NAN : FPCore.Nans} {t : type}.
Variables v1 v2 : list (ftype t).
Notation v1R := (map FT2R v1).
Notation v2R := (map FT2R v2).
Notation v1R' := (map Rabs v1R).
Notation v2R' := (map Rabs v2R).
Notation n := (size v2).
Notation g := (@g t).
Notation g1 := (@g1 t).
Hypothesis Hlen : size v1 = size v2.
Hypothesis Hfin : Binary.is_finite (dotprodF v1 v2) = true.
dotprod_forward_error bounds the absolute forward error of the computed
dot product by \(g(n)\,(|v_1| \cdot |v_2|) + g_1(n,\,n-1)\),
where \(|v|\) denotes the componentwise absolute-value vector.
Lemma dotprod_forward_error :
Rabs (FT2R (dotprodF v1 v2) - dotprodR v1R v2R)
≤ g n × dotprodR v1R' v2R' + g1 n (n - 1).
Notation nnzR := (common.nnzR v1R).
sparse_dotprod_forward_error refines dotprod_forward_error for sparse
inputs: the vector length \(n\) is replaced by the number of
nonzero entries \(n_{\mathrm{nz}}\), yielding
\(g(n_{\mathrm{nz}})\,(|v_1| \cdot |v_2|) + g_1(n_{\mathrm{nz}},\,n_{\mathrm{nz}}-1)\).