NLAlib.Ops.Routine.algorithm
Library · def
A certificate of a routine. The program of a routine that meets Sp under every interpretation of the model is certified against a specification S of the problem, for any weights. The supplied buffers hold the blocks input, which satisfy the precondition, and have room for the written blocks (hinit); the output of S follows from the postcondition, the declared draws and the frame of the run (hgood); the resource fields of S bound the static count and scratch of the tree as in NLAlib.Ops.Algorithm.ofWp.
This is the one construction of certificates from routines. Every certificate of the library uses it through NLAlib.Ops.Routine.Domain.algorithmAt (or its special case NLAlib.Ops.Routine.Domain.algorithm), on the problem derived from the routine, where hinit holds by construction; no certificate calls it directly. It is stated for any problem so that the derived problem is one instance and not a separate proof. Liveness and separation of the supplied buffers are not hypotheses: they hold for every problem (NLAlib.Ops.Problem.live_slots, NLAlib.Ops.Routine.separated_slots). When the budget, the scratch, the work and the span of S are those of the tree (staticCost, staticPeak and their weights, as in NLAlib.Ops.Routine.manifest), hcost, hspace, hwork and hspan hold by le_rfl and may be omitted: write (hmemory := …).
A counted certificate, whose work and span are a closed polynomial in the sizes, is this certificate followed by NLAlib.Ops.Algorithm.withCountPoly: the instruction polynomial of the tree is evaluated by the kernel (kernel_rfl) and bounded by the polynomial (poly_eval). NLAlib.Ops.Routine.certify is that construction for the canonical specification NLAlib.Ops.Routine.manifest; a family whose certificate states its own output (a state of the iteration, say) applies withCountPoly to its own algorithm.
NLAlib.Ops.Routine.algorithm {Op Tst K : Type} {r b : ℕ} (R : Ops.Routine Op Tst)
{P : Ops.Problem K r b} {M : Ops.AccessModel Op Tst P} {S : Ops.Specification Op Tst P}
(Sp : (d : Fin r → ℕ) → P.Input d → Ops.Routine.Spec K)
(input : (d : Fin r → ℕ) → P.Input d → List (List K))
(hmeets :
∀ (d : Fin r → ℕ),
P.valid d →
∀ (x : P.Input d) (I : Ops.Interp Op Tst K), M.contracts d x I → R.Meets I (Sp d x))
(hinit :
∀ (d : Fin r → ℕ),
P.valid d →
∀ (x : P.Input d),
(P.initial d x).readBlocks (R.readArgs (Ops.slots b)) (R.readLens (List.ofFn d)) =
some (input d x) ∧
(∀ (τ : Ops.Tape K), (Sp d x).pre (List.ofFn d) τ (input d x)) ∧
(P.initial d x).Room (R.writeArgs (Ops.slots b)) (R.writeLens (List.ofFn d)))
(hgood :
∀ (d : Fin r → ℕ),
P.valid d →
∀ (x : P.Input d) (τ : Ops.Tape K) (m' : Ops.Mem K),
Ops.Store.EqOff (Ops.Fp.blocks (R.writeArgs (Ops.slots b)) (R.writeLens (List.ofFn d)))
(P.initial d x).store m'.store →
R.Advances (List.ofFn d) 0 m'.pos →
∀ (ys : List (List K)),
m'.readBlocks (R.outArgs (Ops.slots b)) (R.outLens (List.ofFn d)) = some ys →
(Sp d x).post (List.ofFn d) τ (input d x) ys →
∀ c ≤ S.budget d, S.good d x τ c m')
(hcost : ∀ (d : Fin r → ℕ), P.valid d → Ops.staticCost (R.close r b) d ≤ S.budget d := by
intro _ _; exact le_rfl)
(hspace :
∀ (d : Fin r → ℕ), P.valid d → Ops.staticPeak M.resources (R.close r b) d ≤ S.scratch d := by
intro _ _; exact le_rfl)
(hwork : ∀ (d : Fin r → ℕ), P.valid d → M.resources.work (S.budget d) ≤ S.work d := by intro _ _;
exact le_rfl)
(hspan : ∀ (d : Fin r → ℕ), P.valid d → M.resources.span (S.budget d) ≤ S.span d := by intro _ _;
exact le_rfl)
(hmemory :
∀ (d : Fin r → ℕ), P.valid d → ∀ (x : P.Input d), P.initialBytes d x + S.scratch d ≤ S.memory d)
(hshape : R.nd = r ∧ R.ports.length = b := by exact ⟨rfl, rfl⟩)
(ht : (R.close r b).wellTyped M.resources P.formats = true := by rfl)
(hfit : R.bindsFit b = true := by rfl) (hflat : R.flat = true := by rfl)
(hcontig : R.contiguous = true := by rfl) : Ops.Algorithm M SImport NLAlib.Ops.Routine.