NLA-lib Explorer

NLAlib.SpectralBisection.downSlot_writes

Library · theorem

One stored-size query and its active-node branch satisfy total correctness from actual word reads and node output geometry. Inactive slots perform no node call. A fragment of NLAlib.SpectralBisection.bisectionRoutine.

NLAlib.SpectralBisection.downSlot_writes {K Op Tst : Type} [Inhabited K] [Ops.Has Ops.ScalarOp Op]
  [Ops.Has Ops.IndexOp Op] [Ops.Has Ops.MatrixOp Op] [Ops.Has Ops.CmpTst Tst]
  [Ops.Has Ops.IdxTst Tst] (M : Ops.Machine K) (dec : K → ℝ) (mm : MatMulMap (K × K))
  (qr : QRMap (K × K)) {I : Ops.Interp Op Tst K} (hS : Ops.IsScalar M I) (hL : Ops.IsIndexLit M I)
  (hC : Ops.IsCmp dec I) (hMM : Ops.IsMatrixMul (Ops.EntryCodec.pair K) (fun {l m n} ↦ mm) I)
  (hQR : Ops.IsMatrixQR (Ops.EntryCodec.pair K) (fun {m n} ↦ qr) I) (hQ : Ops.IsToNat dec I)
  {τ : Ops.Tape K} {μ : Ops.Mem K} {n L fuel d lo k : ℕ}
  {par lv su sg ma ua qa ea sz kd kp c t : ℕ × ℕ} (A : Matrix (Fin k) (Fin k) (K × K))
  (R0 beta R eps U : K) (S : ℕ → ℕ → K × K) (hslot : lo + k ≤ n)
  (hexact : Ops.IsExactNatLit dec M (max n 4))
  (hl : μ.Live [par, lv, su, sg, ma, ua, qa, ea, sz, kd, kp, c, t]) (ht : t.2 + 5 ≤ μ.store.len t.1)
  (hsize : μ.store.get sz.1 (sz.2 + n * d + lo) = some (M.lit ↑k))
  (hread :
    0 < k →
      μ.readBlocks (SpectralBisection.nodeInputs n d lo par lv su sg ma c)
          (SpectralBisection.nodeInputLengths n k) =
        some (SpectralBisection.nodeInputWords M n R0 beta R eps U S A))
  (hprotect :
    0 < k →
      Ops.Fp.Disj (Ops.Store.inBlock t.1 (t.2 + 4) 1)
        (Ops.Fp.blocks (SpectralBisection.nodeInputs n d lo par lv su sg ma c)
          (SpectralBisection.nodeInputLengths n k)))
  (hgeometry :
    0 < k →
      (μ.Room
            [(ua.1, ua.2 + 2 * (n * n) * d + 2 * n * lo), (ea.1, ea.2 + n * d + lo),
              (kd.1, kd.2 + n * d + lo)]
            [2 * (k * k), k, 1] ∧
          Ops.Fp.Apart
              [(ua.1, ua.2 + 2 * (n * n) * d + 2 * n * lo), (ea.1, ea.2 + n * d + lo),
                (kd.1, kd.2 + n * d + lo)]
              [2 * (k * k), k, 1] ∧
            (Ops.Fp.blocks
                  [(ua.1, ua.2 + 2 * (n * n) * d + 2 * n * lo), (ea.1, ea.2 + n * d + lo),
                    (kd.1, kd.2 + n * d + lo)]
                  [2 * (k * k), k, 1]).Disj
              (Ops.Fp.blocks (SpectralBisection.nodeInputs n d lo par lv su sg ma c)
                (SpectralBisection.nodeInputLengths n k))) ∧
        ∀ r ≤ k,
          μ.Room (SpectralBisection.branchOutputs n d lo k r ma qa sz kd kp)
              (SpectralBisection.branchLengths k r) ∧
            Ops.Fp.Apart (SpectralBisection.branchOutputs n d lo k r ma qa sz kd kp)
                (SpectralBisection.branchLengths k r) ∧
              (Ops.Fp.blocks (SpectralBisection.branchOutputs n d lo k r ma qa sz kd kp)
                    (SpectralBisection.branchLengths k r)).Disj
                (Ops.Fp.blocks (SpectralBisection.nodeInputs n d lo par lv su sg ma c)
                  (SpectralBisection.nodeInputLengths n k))) :
  have N :=
    M.toFloatMachine dec (fun {l m n} ↦ mm) (fun {m n} ↦ qr) M.mul fun z ↦ M.normalWords z.1 z.2;
  have outcome :=
    eighStep N n fuel R0 beta A R eps (L + d) (SpectralBisection.storedNodeSample n lo U S);
  Ops.Writes Ops.Mode.total I τ SpectralBisection.downSlotsBody
    ((Ops.Env.frame [n, L, fuel, d] [par, lv, su, sg, ma, ua, qa, ea, sz, kd, kp, c, t]).pushIdx lo)
    (SpectralBisection.activeStepFp n d lo ma ua qa ea sz kd kp outcome ⊔
      Ops.Store.inBlock t.1 (t.2 + 4) 1)
    (fun ν ↦
      ν.pos = μ.pos ∧
        if 0 < k then SpectralBisection.StoresStep M R n d lo ma ua qa ea sz kd kp outcome ν
        else True)
    μ

Full source on GitHub

Import NLAlib.Eigensolvers.SpectralBisection.DownSlots.