Skip to content
Rainbow docs menu

Reference · The Applied Higher-Order Functions catalogue

rainbow.algorithms.proofs.ahof.matrix-chain

The Applied Higher-Order Functions cataloguesrc/rainbow/algorithms/proofs/ahof/matrix_chain.clj2 definitions, 3 theorems

AHoF Matrix Chain Multiplication (dynamic programming): find the parenthesization of a chain of matrix products that minimizes the number of scalar multiplications. The DP considers every split point k: the cost is the cost of the left sub-chain plus the cost of the right sub-chain plus the cost of multiplying the two resulting matrices, split-cost left right multiply = left + right + multiply and each cell takes the minimum split cost (better-split, a decidable rational min). Proved native and axiom-free, as worked instances: split-cost(2, 3, 4) = 9; better-split(9, 6) = 6; and the worked certificate 6 <= 9 (native nnrat/at-most). The DP's optimal parenthesization is classical and not proved here; the dimension array and the split sweep are executable. Requires nnrat/add, audit/decide-nnrat-at-most, logic/if-data, nnrat/at-most, nnrat/decide-at-most-true-sound (all in the D63 checkpoint). Scope (measured by the kernel): this module has 3 worked instances (statements about specific values). None of its theorems is a guarantee about the algorithm for all inputs; `lein verify rainbow.algorithms.proofs.ahof.matrix-chain` prints this classification.

matrix-chain/split-cost

DefinitionSource, line 65

matrix-chain/split-cost :
  (x₁ x₂ x₃ : ℚ≥0)
  → ℚ≥0

ℚ≥0 = nnrat/NonnegativeRational

matrix-chain/better-split

DefinitionSource, line 73

matrix-chain/better-split :
  (x₁ x₂ : ℚ≥0)
  → ℚ≥0

ℚ≥0 = nnrat/NonnegativeRational

matrix-chain/split-cost-example

TheoremWorked exampleNo axiomsSource, line 85

matrix-chain/split-cost-example :
  → matrix-chain/split-cost 2 3 4 = 9

= = equality/Eq

matrix-chain/takes-cheaper-split

TheoremWorked exampleNo axiomsSource, line 92

matrix-chain/takes-cheaper-split :
  → held-karp/better 9 6 = 6

= = equality/Eq

matrix-chain/chosen-split-is-minimal

TheoremWorked exampleNo axiomsSource, line 99

matrix-chain/chosen-split-is-minimal :
  → 6 ≤ 9

≤ = nnrat/at-most