Primitive recursive functions on Lists #
The primitive recursive functions are defined in Mathlib.Computability.Primrec.Basic.
This file contains definitions and theorems about primitive recursive functions that
relate to operation on lists.
References #
Equations
- Primcodable.list = { toEncodable := List.encodable, prim := ⋯ }
Filtering a list for elements that satisfy a decidable predicate is primitive recursive.
Checking if any element of a list satisfies a decidable predicate is primitive recursive.
Checking if every element of a list satisfies a decidable predicate is primitive recursive.
Bounded existential quantifiers are primitive recursive.
Bounded universal quantifiers are primitive recursive.
A helper lemma for proofs about bounded quantifiers on decidable relations.
If R a b is decidable, then given L : List α and b : β, it is primitive recursive
to filter L for elements a with R a b
If R a b is decidable, then given L : List α and b : β, g L b ↔ ∃ a L, R a b
is a primitive recursive relation.
If R a b is decidable, then given L : List α and b : β, g L b ↔ ∀ a L, R a b
is a primitive recursive relation.
If R a b is decidable, then for any fixed n and y, g n y ↔ ∃ x < n, R x y is a
primitive recursive relation.
If R a b is decidable, then for any fixed n and y, g n y ↔ ∀ x < n, R x y is a
primitive recursive relation.
Equations
Equations
An alternative inductive definition of Primrec which
does not use the pairing function on ℕ, and so has to
work with n-ary functions on ℕ instead of unary functions.
We prove that this is equivalent to the regular notion
in to_prim and of_prim.
- zero : Primrec' fun (x : List.Vector ℕ 0) => 0
- succ : Primrec' fun (v : List.Vector ℕ 1) => v.head.succ
- get {n : ℕ} (i : Fin n) : Primrec' fun (v : List.Vector ℕ n) => v.get i
- comp {m n : ℕ} {f : List.Vector ℕ n → ℕ} (g : Fin n → List.Vector ℕ m → ℕ) : Primrec' f → (∀ (i : Fin n), Primrec' (g i)) → Primrec' fun (a : List.Vector ℕ m) => f (List.Vector.ofFn fun (i : Fin n) => g i a)
- prec {n : ℕ} {f : List.Vector ℕ n → ℕ} {g : List.Vector ℕ (n + 2) → ℕ} : Primrec' f → Primrec' g → Primrec' fun (v : List.Vector ℕ (n + 1)) => Nat.rec (f v.tail) (fun (y IH : ℕ) => g (y ::ᵥ IH ::ᵥ v.tail)) v.head
Instances For
A function from vectors to vectors is primitive recursive when all of its projections are.
Equations
- Nat.Primrec'.Vec f = ∀ (i : Fin m), Nat.Primrec' fun (v : List.Vector ℕ n) => (f v).get i