Reference · The Applied Higher-Order Functions catalogue
rainbow.algorithms.proofs.ahof.beam-search
AHoF D-family Beam Search: a bounded-breadth heuristic search that, at each level, expands only the K highest-scoring partial solutions (the beam) instead of the full frontier -- trading completeness for tractable memory, as in machine translation decoding and structured prediction. A candidate stays in the beam exactly when its score meets the beam's cutoff (the K-th best score at that level): in-beam? score cutoff = decide (cutoff <= score) over exact-rational candidate scores. Proved native and axiom-free: the beam-membership test; that a high-scoring candidate is kept; that a low-scoring candidate is pruned; and the certificate that a retained candidate really meets the cutoff (cutoff <= score as native nnrat/at-most). The successor expansion and the cutoff (K-th order statistic) are executable; what is proved is the beam pruning decision. Requires nnrat/at-most, audit/decide-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.beam-search` prints this classification.
beam-search/in-beam?
beam-search/in-beam? : (x₁ x₂ : ℚ≥0) → data/Bool
ℚ≥0 = nnrat/NonnegativeRational
beam-search/keeps-high-scorer
beam-search/keeps-high-scorer : → bo/is-safe 7 5 = data/true
= = equality/Eq
beam-search/retained-meets-cutoff
beam-search/retained-meets-cutoff : → 5 ≤ 7
≤ = nnrat/at-most
beam-search/prunes-low-scorer
beam-search/prunes-low-scorer : → bo/is-safe 3 5 = data/false
= = equality/Eq