Reference · The Applied Higher-Order Functions catalogue
rainbow.algorithms.proofs.ahof.manacher
AHoF Manacher's Algorithm: find the longest palindromic substring (and all maximal palindrome radii) in LINEAR time, beating the O(n^2) expand-around-center approach by reusing mirror symmetry so each position is examined O(1) amortized. The one primitive operation, whether an expand-around-center step continues, is a character MATCH between the mirrored positions: characters-match? left-char right-char = (left-char <= right-char) AND (right-char <= left-char) (the two characters are equal), over exact-rational (integer) character codes. The match test is defined as a conjunction of two comparisons via logic/if-data. Proved native and axiom-free, as worked instances: codes 65 and 65 match; the one-direction worked certificate 65 <= 65 (native nnrat/at-most); and codes 65 and 66 do not match. Manacher's correctness and its linear-time bound are classical and not proved here; the center iteration with mirror-radius reuse is executable. Requires 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.manacher` prints this classification.
manacher/characters-match?
manacher/characters-match? : (x₁ x₂ : ℚ≥0) → data/Bool
ℚ≥0 = nnrat/NonnegativeRational
manacher/equal-chars-extend
manacher/equal-chars-extend : → floyd-cycle/meet? 65 65 = data/true
= = equality/Eq
manacher/matching-chars-coincide
manacher/matching-chars-coincide : → 65 ≤ 65
≤ = nnrat/at-most
manacher/different-chars-stop
manacher/different-chars-stop : → floyd-cycle/meet? 65 66 = data/false
= = equality/Eq