NLA-lib Explorer

NLAlib.ShiftedQR.optimalDecide_writes_word

Library · theorem

The decision of Optimal on any scalar machine with exact comparisons: optimalDecide sets the flag to the literal 1 if the rounded norm NLAlib.ShiftedQR.pairVecNormWord of the stored row is below NLAlib.ShiftedQR.optimalThresholdWord, to the literal 0 otherwise, and writes only the flag and its scratch. A fragment of the tree NLAlib.ShiftedQR.optimalTestWithScratch.

NLAlib.ShiftedQR.optimalDecide_writes_word {Op Tst : Type} [Ops.Has Ops.ScalarOp Op]
  [Ops.Has Ops.CmpTst Tst] {M : Ops.Machine ℝ} {I : Ops.Interp Op Tst ℝ} (hS : Ops.IsScalar M I)
  (hC : Ops.IsCmp id I) {τ : Ops.Tape ℝ} {m : Ops.Mem ℝ} {n k : ℕ} {a c v w q f : ℕ × ℕ}
  {H : Matrix (Fin (n + 1)) (Fin (n + 1)) ℂ} {r : Fin (n + 1) → ℂ} {cv : ℝ} (hk : k ≤ n)
  (hH : HoldsMatrix a H m.store) (hc : m.store.get c.1 c.2 = some cv)
  (hV : HoldsMatrix v (replicateCol (Fin 1) r) m.store) (hw : w.2 + 3 ≤ m.store.len w.1)
  (hq : q.2 + 2 ≤ m.store.len q.1) (hf : f.2 < m.store.len f.1) (hl : m.Live [a, c, v, w, q, f])
  (hsep :
    (Ops.Store.inBlock w.1 w.2 3 ⊔ Ops.Store.inBlock q.1 q.2 2 ⊔ Ops.Store.inBlock f.1 f.2 1).Disj
      (Ops.Store.inBlock a.1 a.2 (2 * ((n + 1) * (n + 1))) ⊔ Ops.Store.inBlock c.1 c.2 1 ⊔
        Ops.Store.inBlock v.1 v.2 (2 * (1 * (n + 1)))))
  (hwq : Ops.Fp.Disj (Ops.Store.inBlock w.1 w.2 3) (Ops.Store.inBlock q.1 q.2 2)) :
  Ops.Writes Ops.Mode.total I τ ShiftedQR.optimalDecide
    (Ops.Env.frame [n + 1, k] [a, c, v, w, q, f])
    (Ops.Store.inBlock w.1 w.2 3 ⊔ Ops.Store.inBlock q.1 q.2 2 ⊔ Ops.Store.inBlock f.1 f.2 1)
    (fun m' ↦
      m'.pos = m.pos ∧
        m'.store.get f.1 f.2 =
          some
            (if ShiftedQR.pairVecNormWord M r < ShiftedQR.optimalThresholdWord M H k cv then M.lit 1
            else M.lit 0))
    m

Full source on GitHub

Import NLAlib.Eigensolvers.ShiftedQR.RoundedRitz.