Reference · The Applied Higher-Order Functions catalogue
rainbow.algorithms.proofs.ahof.roulette-selection
AHoF genetic-algorithm operator: fitness-proportionate (roulette-wheel) selection. Individuals are chosen for reproduction with probability proportional to fitness. The wheel is the cumulative fitness (a prefix-sum scan); a spin s selects the first individual whose cumulative fitness reaches s: lands? cumulative s = decide (s <= cumulative) over exact-rational cumulative fitness. Proved native and axiom-free: the landing test and worked instances on concrete values -- spin 6 lands on an individual with cumulative fitness 9; the worked certificate 6 <= 9 as a native nnrat/at-most; and an individual with cumulative fitness 4 is passed over by spin 6. The cumulative wheel (a prefix-sum scan) and the RNG spin are executable. What is proved here is the landing decision at these instances; that selection probability is proportional to fitness is the classical property of the operator and is not proved here. 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.roulette-selection` prints this classification.
roulette/lands?
roulette/lands? : (x₁ x₂ : ℚ≥0) → data/Bool
ℚ≥0 = nnrat/NonnegativeRational
roulette/lands-on-individual
roulette/lands-on-individual : → bo/is-safe 9 6 = data/true
= = equality/Eq
roulette/landing-is-valid
roulette/landing-is-valid : → 6 ≤ 9
≤ = nnrat/at-most
roulette/passes-over-below-spin
roulette/passes-over-below-spin : → bo/is-safe 4 6 = data/false
= = equality/Eq