Langlib

Langlib.Utilities.WordEnumeration

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.

def wordsOfLen {α : Type} (alphabet : List α) :
List (List α)

All words of exactly length n over the symbols in alphabet.

Equations
Instances For
    def wordsUpTo {α : Type} (alphabet : List α) (n : ) :
    List (List α)

    All words of length at most n over the symbols in alphabet.

    Equations
    Instances For
      theorem wordsOfLen_eq {α : Type} (alphabet : List α) (n : ) :
      wordsOfLen alphabet n = Nat.rec [[]] (fun (x : ) (ih : (fun (x : ) => List (List α)) x) => List.flatMap (fun (w : List α) => List.map (fun (a : α) => a :: w) alphabet) ih) n
      theorem wordsOfLen_primrec {α : Type} [Primcodable α] :
      Primrec fun (x : List α × ) => wordsOfLen x.1 x.2
      theorem wordsUpTo_primrec {α : Type} [Primcodable α] :
      Primrec fun (x : List α × ) => wordsUpTo x.1 x.2
      theorem mem_wordsOfLen {α : Type} (alphabet : List α) (n : ) (w : List α) :
      w wordsOfLen alphabet n w.length = n aw, a alphabet
      def wordSearch {α : Type} (candidates : List (List α)) (p : List αBool) :

      Search a finite candidate list for a word satisfying p.

      Equations
      Instances For
        theorem wordSearch_rec_true_iff {α : Type} (candidates : List (List α)) (p : List αBool) (k : ) :
        Nat.rec false (fun (i : ) (acc : Bool) => acc || p (candidates.getD i [])) k = true i < k, p (candidates.getD i []) = true
        theorem wordSearch_true_iff_exists_mem {α : Type} (candidates : List (List α)) (p : List αBool) :
        wordSearch candidates p = true wcandidates, p w = true
        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)