NLA-lib Explorer

NLAlib.Ops.Routine.Domain.algorithm

Library · def

The certificate of a routine on its problem when the specification depends only on the data of the input, the usual case: NLAlib.Ops.Routine.Domain.algorithmAt at such a specification. It is stated as its own application of NLAlib.Ops.Routine.algorithm, not through algorithmAt, so that elaborating a certificate with a large tree does not unfold one more definition.

NLAlib.Ops.Routine.Domain.algorithm {K Op Tst : Type} {r b : ℕ} {R : Ops.Routine Op Tst}
  (D : R.Domain K r b) {M : Ops.AccessModel Op Tst D.problem}
  {S : Ops.Specification Op Tst D.problem} (Sp : (d : Fin r → ℕ) → D.In d → Ops.Routine.Spec K)
  (hmeets :
    ∀ (d : Fin r → ℕ),
      D.valid d →
        ∀ (X : D.problem.Input d) (I : Ops.Interp Op Tst K),
          M.contracts d X I → R.Meets I (Sp d (↑X).1))
  (hpre :
    ∀ (d : Fin r → ℕ),
      D.valid d →
        ∀ (x : D.In d),
          D.accepts d x → ∀ (τ : Ops.Tape K), (Sp d x).pre (List.ofFn d) τ (D.blocks d x))
  (hgood :
    ∀ (d : Fin r → ℕ),
      D.valid d →
        ∀ (X : D.problem.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)))
              (D.problem.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).1).post (List.ofFn d) τ (D.blocks d (↑X).1) ys →
                    ∀ c ≤ S.budget d, S.good d X τ c m')
  (hcost : ∀ (d : Fin r → ℕ), D.valid d → Ops.staticCost (R.close r b) d ≤ S.budget d := by
    intro _ _; exact le_rfl)
  (hspace :
    ∀ (d : Fin r → ℕ), D.valid d → Ops.staticPeak M.resources (R.close r b) d ≤ S.scratch d := by
    intro _ _; exact le_rfl)
  (hwork : ∀ (d : Fin r → ℕ), D.valid d → M.resources.work (S.budget d) ≤ S.work d := by intro _ _;
    exact le_rfl)
  (hspan : ∀ (d : Fin r → ℕ), D.valid d → M.resources.span (S.budget d) ≤ S.span d := by intro _ _;
    exact le_rfl)
  (hmemory :
    ∀ (d : Fin r → ℕ),
      D.valid d → ∀ (X : D.problem.Input d), D.problem.initialBytes d X + S.scratch d ≤ S.memory d)
  (ht : (R.close r b).wellTyped M.resources D.problem.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 S

Full source on GitHub

Import NLAlib.Ops.RoutineProblem.