Primitive recursive list operations

DefinitionBoolean membership test for lists of natural numbers#✓fully proved

For a list \(G\) of natural numbers and a natural number \(j\), the Boolean value that is true exactly when \(j\) is an entry of \(G\).

def memB (G : List ℕ) (j : ℕ) : Bool :=
  G.foldr (fun a b => decide (a = j) || b) false
Used by 51
Used byDeleting nonterminals from an encoded right-hand side · Computed deletions agree with nullable deletions · Productions of the encoded unit elimination · Unit reachability is computed · Reduction is primitive recursive · Unit elimination for encoded grammars · One round of unit reachability · Acceptance test for encoded DFAs · Equivalence test for encoded DFAs · Correctness of the infiniteness test for encoded DFAs · Emptiness test for encoded DFAs · Universality test for encoded DFAs · Correctness of the bounded reachability search · One round of the list reachability search · Equivalence of DFAs is decidable · Universality of DFAs is decidable · Emptiness of DFAs is decidable · Infiniteness of DFAs is decidable · Acceptance for DFAs is decidable · The equivalence test is primitive recursive · Emptiness of regular expressions is decidable · Inclusion of a regular language in a DFA language is decidable · Membership for regular expressions is decidable · Whether a symbol fits at a DFA state · The intersection-emptiness test for a grammar and a DFA · Correctness of the intersection-emptiness test · Completeness of the start states in a DFA · Emptiness of the intersection of a context-free and a regular language is decidable · Inclusion of a context-free language in a regular language is decidable · Emptiness of context-free grammars is computable · Soundness of the productive-nonterminal iteration · The generating nonterminals are closed under one more round · The emptiness test for context-free grammars · Correctness of the emptiness test · The membership test for context-free grammars · Correctness of the membership test · Completeness of the start positions · Pumping lemma for encoded grammars · Completeness of the generating-nonterminal computation · Fitting a symbol at a position · Acceptable symbols · Infiniteness of context-free languages is decidable · Membership for context-free grammars is decidable · Membership test for encoded NFAs · Correctness of the NFA membership test · Emptiness test for encoded NFAs · Letter step of an encoded NFA · The run of an encoded NFA agrees with ε-NFA evaluation · Emptiness of NFAs is decidable · Membership for NFAs is decidable · Duplicate removal for lists of natural numbers

DefinitionDuplicate removal for lists of natural numbers#✓fully proved

For a list \(l\) of natural numbers, the list obtained from \(l\) by deleting every entry that occurs again later in \(l\): each element of \(l\) is kept once, at its last occurrence, and the kept entries stay in their order in \(l\).

def dedupB (l : List ℕ) : List ℕ :=
  l.foldr (fun x acc => cond (memB acc x) acc (x :: acc)) []
Uses 1 · Used by 14

TheoremBounded monotone rounds on lists close off#✓fully proved

Let \(f\) map lists of natural numbers to lists of natural numbers and be monotone for list inclusion: \(f(G) \subseteq f(G')\) whenever \(G \subseteq G'\), where \(G \subseteq G'\) means that every entry of \(G\) is an entry of \(G'\). If \(B\) is a list with \(f(G) \subseteq B\) for every list \(G\), and \(n\) is the length of \(B\), then \(f(f^n([\,])) \subseteq f^n([\,])\), where \(f^n\) is the \(n\)-fold iterate of \(f\) and \([\,]\) is the empty list.

theorem iterate_closed {f : List ℕ → List ℕ} (hmono : ∀ G G', G ⊆ G' → f G ⊆ f G')
    (B : List ℕ) (hB : ∀ G, f G ⊆ B) : f (f^[B.length] []) ⊆ f^[B.length] []
Used by 5

TheoremPredicates with a primitive recursive decision procedure are computable#✓fully proved

Let \(\beta\) be a primcodable type, \(p\) a predicate on \(\beta\), and \(f : \beta \to \mathrm{Bool}\) a primitive recursive function such that \(f(b) = \mathrm{true}\) exactly when \(p(b)\) holds, for every \(b \in \beta\). Then \(p\) is a computable predicate.

theorem computablePred_of_primrec_bool {β : Type*} [Primcodable β] {p : β → Prop}
    {f : β → Bool} (hf : Primrec f) (h : ∀ b, f b = true ↔ p b) : ComputablePred p
Used by 16
4 fully proved

The dependency explorer needs JavaScript and its graph data.

Download the complete graph data.