Enumerating Bounded Words #
This file provides a small computable enumeration of all words up to a given length over an explicitly supplied finite alphabet list, plus a reusable bounded search combinator over such word lists.
All words of exactly length n over the symbols in alphabet.
Equations
- wordsOfLen alphabet 0 = [[]]
- wordsOfLen alphabet k.succ = List.flatMap (fun (w : List α) => List.map (fun (a : α) => a :: w) alphabet) (wordsOfLen alphabet k)
Instances For
All words of length at most n over the symbols in alphabet.
Equations
- wordsUpTo alphabet n = List.flatMap (wordsOfLen alphabet) (List.range (n + 1))
Instances For
theorem
wordsOfLen_primrec
{α : Type}
[Primcodable α]
:
Primrec fun (x : List α × ℕ) => wordsOfLen x.1 x.2
theorem
wordSearch_computable
{α δ : Type}
[Primcodable α]
[Primcodable δ]
{candidates : δ → List (List α)}
{p : δ → List α → Bool}
(hcandidates : Computable candidates)
(hp : Computable₂ p)
:
Computable fun (d : δ) => wordSearch (candidates d) (p d)