NLA-lib Explorer

NLAlib.Ops.Examples.runs_mulAddMixed

Library · theorem

Standard rounding

The mixed-precision theorem: one machine and one standard model per tag, an exact cast. The counts are per tag: one multiplication at Lo, one addition at Hi, one cast.

NLAlib.Ops.Examples.runs_mulAddMixed {K Op Tst Lo Hi : Type}
  [Ops.Has (Ops.Tagged Lo Ops.ScalarOp) Op] [Ops.Has (Ops.Tagged Hi Ops.ScalarOp) Op]
  [Ops.Has (Ops.CastOp Lo Hi) Op] {Ml Mh : Ops.Machine K} {c : K → K} {ul uh : ℝ} {dec : K → ℝ}
  {I : Ops.Interp Op Tst K} (hLo : Ops.IsScalarAt Lo Ml I) (hHi : Ops.IsScalarAt Hi Mh I)
  (hC : Ops.IsCast Lo Hi c I) (hMl : Ops.StdModel ul dec Ml) (hMh : Ops.StdModel uh dec Mh)
  (hc : Ops.CastModel 0 dec c) (huh : 0 ≤ uh) (W : Op → List ℕ → ℕ) {τ : Ops.Tape K}
  {x y w z : ℕ × ℕ} {m : Ops.Mem K} {a b e : K} (hx : m.store.get x.1 x.2 = some a)
  (hy : m.store.get y.1 y.2 = some b) (hw : m.store.get w.1 w.2 = some e)
  (hz : z.2 < m.store.len z.1) :
  Ops.ConditionalRuns I W τ (Ops.Examples.mulAddMixed Lo Hi)
    { idx := [x.2, y.2, w.2, z.2], buf := [x.1, y.1, w.1, z.1] } m
    (Ops.Examples.mulAddMixedCount Lo Hi)
    (1 +
      max (W (Ops.Tagged.inj Lo Ops.ScalarOp.mul) [])
        (max (W (Ops.Has.inj Ops.CastOp.cast) []) (W (Ops.Tagged.inj Hi Ops.ScalarOp.add) [])))
    fun m' ↦
    ∃ v,
      m' = m.upd z v ∧
        |dec v - (dec a * dec b + dec e)| ≤
          uh * |dec a * dec b + dec e| + (1 + uh) * ul * |dec a * dec b|

Full source on GitHub

Import NLAlib.Ops.Examples.Mixed.