NLA-lib Explorer

NLAlib.SpectralBisection.downLevel_writes_stored

Library · theorem

One complete actual level stores its mathematical outcomes and the next level inputs. All execution assumptions concern primitive contracts, actual input words and bounded storage. A fragment of NLAlib.SpectralBisection.bisectionRoutine.

NLAlib.SpectralBisection.downLevel_writes_stored {K Op Tst : Type} [Inhabited K]
  [Ops.Has Ops.ScalarOp Op] [Ops.Has Ops.IndexOp Op] [Ops.Has Ops.SampleOp 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}
  {τ : Ops.Tape K} {μ : Ops.Mem K} {n L fuel d base : ℕ}
  {par lv su sg ma ua qa ea sz kd kp c t : ℕ × ℕ} (R0 eps0 beta : K)
  (A : Matrix (Fin n) (Fin n) (K × 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)
  (hSample : Ops.IsSample I) (hexact : Ops.IsExactNatLit dec M (max n 4))
  (hPos : μ.pos = base + d * SpectralBisection.levelSampleSize n)
  (hLevel :
    SpectralBisection.StoresLevel M
      (SpectralBisection.tapeMachine M dec (fun {l m n} ↦ mm) (fun {m n} ↦ qr) n base τ) n fuel R0
      beta { k := n, A := A, R := R0, ε := eps0, ℓ := L } d ma sz lv μ)
  (hpar : μ.store.readBlock par.1 par.2 3 = some [R0, eps0, beta])
  (hc :
    μ.store.readBlock c.1 c.2 5 =
      some [M.lit 1, M.lit 2, M.div (M.lit 1) (M.lit 2), M.neg (M.lit 1), M.sqrtHalf])
  (hGeometry :
    SpectralBisection.DownLevelGeometry n d
      (fun lo ↦
        ((fun lo ↦
              SpectralBisection.nodeAtSlot
                (SpectralBisection.tapeMachine M dec (fun {l m n} ↦ mm) (fun {m n} ↦ qr) n base τ) n
                fuel R0 beta { k := n, A := A, R := R0, ε := eps0, ℓ := L } d lo)
            lo).k)
      par lv su sg ma ua qa ea sz kd kp c t μ.store)
  (hZero : ∀ j < n, μ.store.get sz.1 (sz.2 + n * (d + 1) + j) = some (M.lit 0)) :
  Ops.Writes Ops.Mode.total I τ (SpectralBisection.downLevelBody SpectralBisection.node)
    (Ops.Env.frame [n, L, fuel, d] [par, lv, su, sg, ma, ua, qa, ea, sz, kd, kp, c, t])
    (SpectralBisection.downPrepareFp n d lv su sg t ⊔
      (Ops.Fp.loopPrefix
          (fun lo ↦
            SpectralBisection.activeStepFp n d lo ma ua qa ea sz kd kp
              ((fun lo ↦
                  eighStep
                    (M.toFloatMachine dec (fun {l m n} ↦ mm) (fun {m n} ↦ qr) M.mul fun z ↦
                      M.normalWords z.1 z.2)
                    n fuel R0 beta
                    ((fun lo ↦
                          SpectralBisection.nodeAtSlot
                            (SpectralBisection.tapeMachine M dec (fun {l m n} ↦ mm) (fun {m n} ↦ qr)
                              n base τ)
                            n fuel R0 beta { k := n, A := A, R := R0, ε := eps0, ℓ := L } d lo)
                        lo).A
                    (eighLevelParams
                        (SpectralBisection.tapeMachine M dec (fun {l m n} ↦ mm) (fun {m n} ↦ qr) n
                          base τ)
                        R0 eps0 L d).1
                    (eighLevelParams
                        (SpectralBisection.tapeMachine M dec (fun {l m n} ↦ mm) (fun {m n} ↦ qr) n
                          base τ)
                        R0 eps0 L d).2
                    (L + d)
                    (SpectralBisection.storedNodeSample n lo
                      (Ops.vec (SpectralBisection.levelUniformWords n base τ d) lo)
                      (SpectralBisection.levelGaussianMatrix n base τ d)))
                lo))
          n ⊔
        Ops.Store.inBlock t.1 (t.2 + 4) 1))
    (fun ν ↦
      ν.pos = base + (d + 1) * SpectralBisection.levelSampleSize n ∧
        SpectralBisection.StoresRecords M
            (SpectralBisection.tapeMachine M dec (fun {l m n} ↦ mm) (fun {m n} ↦ qr) n base τ) n
            fuel R0 beta { k := n, A := A, R := R0, ε := eps0, ℓ := L } d ma ua qa ea sz kd kp ν ∧
          SpectralBisection.StoresLevel M
            (SpectralBisection.tapeMachine M dec (fun {l m n} ↦ mm) (fun {m n} ↦ qr) n base τ) n
            fuel R0 beta { k := n, A := A, R := R0, ε := eps0, ℓ := L } (d + 1) ma sz lv ν)
    μ

Full source on GitHub

Import NLAlib.Eigensolvers.SpectralBisection.DownLevelStored.