Routines: an interface, one judgment, a checkable certificate
Library · Source module
Routines: an interface, one judgment, a checkable certificate
A routine (NLAlib.Ops.Routine) is a fixed tree with an interface: its dimensions and, for each operand (NLAlib.Ops.Port), how it is used (NLAlib.Ops.Access: read, written, updated in place, or isolated) and its length as a function of the dimensions. Operands are written with NLAlib.Ops.Port.read, .write, .update, .isolated. Interfaces and their separation are defined in NLAlib/Ops/RoutineInterface.lean.
NLAlib.Ops.Routine.Meets is what an author states about a routine, NLAlib.Ops.Interp.Satisfies says that an interpretation satisfies the contract of a primitive operation, and NLAlib.Ops.Impl.Satisfies says that an implementation of an operation, the entry of a linking table, satisfies that contract; it is derived from the judgments of the routines that share the entry's tree (NLAlib.Ops.Routine.Meets.satisfies_ofRel). A caller uses the first (NLAlib.Ops.Routine.Meets.call); the operation model of a certificate is made of the second; the third is obtained by NLAlib.Ops.Routine.Meets.satisfies (NLAlib/Ops/RoutineLink.lean).
The judgment
NLAlib.Ops.Routine.Meets: on live separated operands (NLAlib.Ops.Routine.SeparatedAt), with the readable blocks satisfying the precondition of the specification, the tree terminates, changes nothing outside the written blocks, advances the tape position by exactly the declared number of draws, and the reported blocks satisfy the postcondition. The postcondition names the draws relative to the position of the call, on any stream. The judgment holds at every memory, so a routine is called by framing its tree (NLAlib.Ops.Routine.Meets.call).
Certificates
A certificate is the judgment read at the initial memory of a problem (NLAlib.Ops.Routine.algorithm); its program is the routine run on the supplied buffers (NLAlib.Ops.Routine.close): the tree itself, or, for a routine with a layout, the tree framed once by its layout. NLAlib.Ops.Routine.certify is that certificate with its work replaced by a bound on the instruction polynomial that the kernel computes from the tree. What it states is in NLAlib.Ops.Routine.specification:
* the output: the reported buffers hold blocks satisfying the postcondition for the supplied input blocks; * the cost: the work and span of the run are at most work, under weights at most one. The bound is not supplied by a proof of the routine; * the memory: the supplied payload plus the static scratch of the tree.
A reader checks an algorithm by reading its NLAlib.Ops.Routine.Spec, its work and its operation model; the rest is checked by the kernel.
Main definitions
* NLAlib.Ops.Routine.Spec, NLAlib.Ops.Routine.Meets: the specification and the judgment. * NLAlib.Ops.Routine.close, NLAlib.Ops.Routine.specification: the program of a routine on a problem and what its counted certificate states.
Main results
* NLAlib.Ops.Routine.Meets.call: a routine that meets its specification is called by a frame. * NLAlib.Ops.Routine.separated_slots, NLAlib.Ops.Problem.live_slots: the supplied buffers of a problem are live separated operands of every interface. * NLAlib.Ops.Routine.algorithm: the certificate against any specification, for any weights. * NLAlib.Ops.Routine.certify: the same certificate with kernel-computed work.
Declarations
- NLAlib.Ops.Problem.live_slots
- NLAlib.Ops.Program.environment_eq_slots
- NLAlib.Ops.Routine.Advances
- NLAlib.Ops.Routine.Advances.eq_of_draws
- NLAlib.Ops.Routine.Advances.eq_of_start
- NLAlib.Ops.Routine.Meets
- NLAlib.Ops.Routine.Meets.call
- NLAlib.Ops.Routine.Meets.close
- NLAlib.Ops.Routine.RoomAt
- NLAlib.Ops.Routine.Spec
- NLAlib.Ops.Routine.Spec.terminates
- NLAlib.Ops.Routine.algorithm
- NLAlib.Ops.Routine.allReported
- NLAlib.Ops.Routine.bindsFit
- NLAlib.Ops.Routine.certify
- NLAlib.Ops.Routine.close
- NLAlib.Ops.Routine.closeDims
- NLAlib.Ops.Routine.closeOps
- NLAlib.Ops.Routine.evalList_closeDims
- NLAlib.Ops.Routine.evalList_closeOps
- NLAlib.Ops.Routine.footprint
- NLAlib.Ops.Routine.footprint_eq_views
- NLAlib.Ops.Routine.footprint_of_contiguous
- NLAlib.Ops.Routine.manifest
- NLAlib.Ops.Routine.outArgs
- NLAlib.Ops.Routine.outLens
- NLAlib.Ops.Routine.outViews
- NLAlib.Ops.Routine.outs
- NLAlib.Ops.Routine.outs_eq_sel
- NLAlib.Ops.Routine.outs_map
- NLAlib.Ops.Routine.readAt
- NLAlib.Ops.Routine.readAt_eq_readViews
- NLAlib.Ops.Routine.readAt_of_contiguous
- NLAlib.Ops.Routine.readViews
- NLAlib.Ops.Routine.reportAt
- NLAlib.Ops.Routine.reportAt_eq_readViews
- NLAlib.Ops.Routine.reportAt_of_contiguous
- NLAlib.Ops.Routine.roomAt_iff_roomViews
- NLAlib.Ops.Routine.roomAt_of_contiguous
- NLAlib.Ops.Routine.sel_map
- NLAlib.Ops.Routine.separated_of_nodup
- NLAlib.Ops.Routine.separated_slots
- NLAlib.Ops.Routine.specification
- NLAlib.Ops.Routine.views_of_contiguous
- NLAlib.Ops.Routine.writeViews
- NLAlib.Ops.slots