LAProof.accuracy_proofs.dot_acc

Dot Product Accuracy Proofs (Non-FMA)

This file establishes floating-point accuracy bounds for the non-fused multiply-add (non-FMA) dot product computation over lists of floating-point numbers. It provides both mixed-error and forward-error analyses, as well as a refined bound for sparse vectors.

Error Factors

Throughout, the accumulated relative error factor is \(g(n) = (1 + \mathbf{u})^n - 1\) and the mixed absolute error factor is \(g_1(n_1, n_2) = n_1 \cdot \eta \cdot (1 + g(n_2))\), where \(\mathbf{u}\) is the unit roundoff and \(\eta\) is the underflow threshold for the given floating-point type. Both are defined in common.

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

This file relies on the following modules from LAProof.accuracy_proofs:

Structure

The file is organised into two Sections:

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)\).

Lemma sparse_dotprod_forward_error :
  Rabs (FT2R (dotprodF v1 v2) - dotprodR v1R v2R)
   g nnzR × dotprodR v1R' v2R' + g1 nnzR (nnzR - 1).

End ForwardError.