Example: a functional contract, the matrix product by a triple loop
Library · Source module
Example: a functional contract, the matrix product by a triple loop
The contract of mm is functional: the result is f of the two input blocks, for some f (NLAlib.Ops.Examples.mmFn, NLAlib.Ops.Examples.IsMM). Properties of f are mathematics.
Main results
* Abstract theorem (NLAlib.Ops.Examples.runs_sq2): squaring a matrix twice, for every f: two calls at [n, n, n], and the memory is given by f. Each call is one equation. * Exact satisfaction (NLAlib.Ops.Examples.mm_satisfies): the run of the triple loop NLAlib.Ops.Examples.mmImpl is the block function of NLAlib.Ops.Examples.mmF, the triple loop written as a function on lists through a machine. It reuses the accumulation loop of the dot product (NLAlib.Ops.Examples.dotLoop_wp) for each entry. * Mathematics (NLAlib.Ops.Examples.abs_dec_mmF_sub_le): each entry of mmF is a rounded dot product. * Corollary (NLAlib.Ops.Examples.runs_sq2_link): the linked program computes mmF, within 2 n² (lit + n (mul + add)) scalar operations and one scratch cell.
Declarations
- NLAlib.Ops.Examples.IsMM
- NLAlib.Ops.Examples.MOp
- NLAlib.Ops.Examples.MOp.ofNat
- NLAlib.Ops.Examples.MOp.ofNat_ctorIdx
- NLAlib.Ops.Examples.abs_dec_mmF_sub_le
- NLAlib.Ops.Examples.exists_isMM
- NLAlib.Ops.Examples.isMM_link
- NLAlib.Ops.Examples.length_mmPrefix
- NLAlib.Ops.Examples.mmCost
- NLAlib.Ops.Examples.mmEntry
- NLAlib.Ops.Examples.mmF
- NLAlib.Ops.Examples.mmFn
- NLAlib.Ops.Examples.mmFn_apply
- NLAlib.Ops.Examples.mmImpl
- NLAlib.Ops.Examples.mmPrefix
- NLAlib.Ops.Examples.mmPrefix_succ
- NLAlib.Ops.Examples.mmTable
- NLAlib.Ops.Examples.mm_accounts
- NLAlib.Ops.Examples.mm_satisfies
- NLAlib.Ops.Examples.mm_wp_entry
- NLAlib.Ops.Examples.push_mmCost_mm
- NLAlib.Ops.Examples.runs_sq2
- NLAlib.Ops.Examples.runs_sq2_link
- NLAlib.Ops.Examples.sq2