fact stringlengths 6 3.84k | type stringclasses 11
values | library stringclasses 32
values | imports listlengths 1 14 | filename stringlengths 20 95 | symbolic_name stringlengths 1 90 | docstring stringlengths 7 20k ⌀ |
|---|---|---|---|---|---|---|
tr_respects [Inhabited Γ] :
Respects (TM1.step M) (TM0.step (tr M))
fun (c₁ : TM1.Cfg Γ Λ σ) (c₂ : TM0.Cfg Γ (Λ' M)) ↦ trCfg M c₁ = c₂ :=
fun_respects.2 fun ⟨l₁, v, T⟩ ↦ by
rcases l₁ with - | l₁; · exact rfl
simp only [trCfg, TM1.step, FRespects, Option.map]
induction M l₁ generalizing v T with
... | theorem | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Finset.Prod",
"Mathlib.Data.Finset.Option",
"Mathlib.Data.Fintype.Defs",
"Mathlib.Data.PFun"
] | Mathlib/Computability/PostTuringMachine.lean | tr_respects | null |
tr_eval [Inhabited Γ] (l : List Γ) : TM0.eval (tr M) l = TM1.eval M l :=
(congr_arg _ (tr_eval' _ _ _ (tr_respects M) ⟨some _, _, _⟩)).trans
(by
rw [Part.map_eq_map, Part.map_map, TM1.eval]
congr with ⟨⟩)
variable [Fintype σ] | theorem | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Finset.Prod",
"Mathlib.Data.Finset.Option",
"Mathlib.Data.Fintype.Defs",
"Mathlib.Data.PFun"
] | Mathlib/Computability/PostTuringMachine.lean | tr_eval | null |
noncomputable trStmts (S : Finset Λ) : Finset (Λ' M) :=
(TM1.stmts M S) ×ˢ Finset.univ
attribute [local simp] TM1.stmts₁_self | def | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Finset.Prod",
"Mathlib.Data.Finset.Option",
"Mathlib.Data.Fintype.Defs",
"Mathlib.Data.PFun"
] | Mathlib/Computability/PostTuringMachine.lean | trStmts | Given a finite set of accessible `Λ` machine states, there is a finite set of accessible
machine states in the target (even though the type `Λ'` is infinite). |
tr_supports {S : Finset Λ} (ss : TM1.Supports M S) :
TM0.Supports (tr M) ↑(trStmts M S) := by
classical
constructor
· apply Finset.mem_product.2
constructor
· simp only [default, TM1.stmts, Finset.mem_insertNone, Option.mem_def, Option.some_inj,
forall_eq', Finset.mem_biUnion]
exact ⟨_, ... | theorem | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Finset.Prod",
"Mathlib.Data.Finset.Option",
"Mathlib.Data.Fintype.Defs",
"Mathlib.Data.PFun"
] | Mathlib/Computability/PostTuringMachine.lean | tr_supports | null |
exists_enc_dec [Inhabited Γ] [Finite Γ] :
∃ (n : ℕ) (enc : Γ → List.Vector Bool n) (dec : List.Vector Bool n → Γ),
enc default = List.Vector.replicate n false ∧ ∀ a, dec (enc a) = a := by
rcases Finite.exists_equiv_fin Γ with ⟨n, ⟨e⟩⟩
letI : DecidableEq Γ := e.decidableEq
let G : Fin n ↪ Fin n → Bool :=... | theorem | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Finset.Prod",
"Mathlib.Data.Finset.Option",
"Mathlib.Data.Fintype.Defs",
"Mathlib.Data.PFun"
] | Mathlib/Computability/PostTuringMachine.lean | exists_enc_dec | null |
Λ'
| normal : Λ → Λ'
| write : Γ → Stmt Γ Λ σ → Λ'
variable {Γ Λ σ} | inductive | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Finset.Prod",
"Mathlib.Data.Finset.Option",
"Mathlib.Data.Fintype.Defs",
"Mathlib.Data.PFun"
] | Mathlib/Computability/PostTuringMachine.lean | Λ' | The configuration state of the TM. |
readAux : ∀ n, (List.Vector Bool n → Stmt Bool (Λ' Γ Λ σ) σ) → Stmt Bool (Λ' Γ Λ σ) σ
| 0, f => f Vector.nil
| i + 1, f =>
Stmt.branch (fun a _ ↦ a) (Stmt.move Dir.right <| readAux i fun v ↦ f (true ::ᵥ v))
(Stmt.move Dir.right <| readAux i fun v ↦ f (false ::ᵥ v))
variable (n : ℕ) (enc : Γ → List.Vector ... | def | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Finset.Prod",
"Mathlib.Data.Finset.Option",
"Mathlib.Data.Fintype.Defs",
"Mathlib.Data.PFun"
] | Mathlib/Computability/PostTuringMachine.lean | readAux | Read a vector of length `n` from the tape. |
move (d : Dir) (q : Stmt Bool (Λ' Γ Λ σ) σ) : Stmt Bool (Λ' Γ Λ σ) σ :=
(Stmt.move d)^[n] q
variable {n} | def | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Finset.Prod",
"Mathlib.Data.Finset.Option",
"Mathlib.Data.Fintype.Defs",
"Mathlib.Data.PFun"
] | Mathlib/Computability/PostTuringMachine.lean | move | A move left or right corresponds to `n` moves across the super-cell. |
read (f : Γ → Stmt Bool (Λ' Γ Λ σ) σ) : Stmt Bool (Λ' Γ Λ σ) σ :=
readAux n fun v ↦ move n Dir.left <| f (dec v) | def | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Finset.Prod",
"Mathlib.Data.Finset.Option",
"Mathlib.Data.Fintype.Defs",
"Mathlib.Data.PFun"
] | Mathlib/Computability/PostTuringMachine.lean | read | To read a symbol from the tape, we use `readAux` to traverse the symbol,
then return to the original position with `n` moves to the left. |
write : List Bool → Stmt Bool (Λ' Γ Λ σ) σ → Stmt Bool (Λ' Γ Λ σ) σ
| [], q => q
| a :: l, q => (Stmt.write fun _ _ ↦ a) <| Stmt.move Dir.right <| write l q | def | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Finset.Prod",
"Mathlib.Data.Finset.Option",
"Mathlib.Data.Fintype.Defs",
"Mathlib.Data.PFun"
] | Mathlib/Computability/PostTuringMachine.lean | write | Write a list of bools on the tape. |
trNormal : Stmt Γ Λ σ → Stmt Bool (Λ' Γ Λ σ) σ
| Stmt.move d q => move n d <| trNormal q
| Stmt.write f q => read dec fun a ↦ Stmt.goto fun _ s ↦ Λ'.write (f a s) q
| Stmt.load f q => read dec fun a ↦ (Stmt.load fun _ s ↦ f a s) <| trNormal q
| Stmt.branch p q₁ q₂ =>
read dec fun a ↦ Stmt.branch (fun _ s ↦ ... | def | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Finset.Prod",
"Mathlib.Data.Finset.Option",
"Mathlib.Data.Fintype.Defs",
"Mathlib.Data.PFun"
] | Mathlib/Computability/PostTuringMachine.lean | trNormal | Translate a normal instruction. For the `write` command, we use a `goto` indirection so that
we can access the current value of the tape. |
stepAux_move (d : Dir) (q : Stmt Bool (Λ' Γ Λ σ) σ) (v : σ) (T : Tape Bool) :
stepAux (move n d q) v T = stepAux q v ((Tape.move d)^[n] T) := by
suffices ∀ i, stepAux ((Stmt.move d)^[i] q) v T = stepAux q v ((Tape.move d)^[i] T) from this n
intro i
induction i generalizing T with
| zero => rfl
| succ i IH... | theorem | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Finset.Prod",
"Mathlib.Data.Finset.Option",
"Mathlib.Data.Fintype.Defs",
"Mathlib.Data.PFun"
] | Mathlib/Computability/PostTuringMachine.lean | stepAux_move | null |
supportsStmt_move {S : Finset (Λ' Γ Λ σ)} {d : Dir} {q : Stmt Bool (Λ' Γ Λ σ) σ} :
SupportsStmt S (move n d q) = SupportsStmt S q := by
suffices ∀ {i}, SupportsStmt S ((Stmt.move d)^[i] q) = _ from this
intro i; induction i generalizing q <;> simp only [*, iterate]; rfl | theorem | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Finset.Prod",
"Mathlib.Data.Finset.Option",
"Mathlib.Data.Fintype.Defs",
"Mathlib.Data.PFun"
] | Mathlib/Computability/PostTuringMachine.lean | supportsStmt_move | null |
supportsStmt_write {S : Finset (Λ' Γ Λ σ)} {l : List Bool} {q : Stmt Bool (Λ' Γ Λ σ) σ} :
SupportsStmt S (write l q) = SupportsStmt S q := by
induction l <;> simp only [write, SupportsStmt, *] | theorem | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Finset.Prod",
"Mathlib.Data.Finset.Option",
"Mathlib.Data.Fintype.Defs",
"Mathlib.Data.PFun"
] | Mathlib/Computability/PostTuringMachine.lean | supportsStmt_write | null |
supportsStmt_read {S : Finset (Λ' Γ Λ σ)} :
∀ {f : Γ → Stmt Bool (Λ' Γ Λ σ) σ}, (∀ a, SupportsStmt S (f a)) →
SupportsStmt S (read dec f) :=
suffices
∀ (i) (f : List.Vector Bool i → Stmt Bool (Λ' Γ Λ σ) σ),
(∀ v, SupportsStmt S (f v)) → SupportsStmt S (readAux i f)
from fun hf ↦ this n _ (by i... | theorem | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Finset.Prod",
"Mathlib.Data.Finset.Option",
"Mathlib.Data.Fintype.Defs",
"Mathlib.Data.PFun"
] | Mathlib/Computability/PostTuringMachine.lean | supportsStmt_read | null |
trTape' (L R : ListBlank Γ) : Tape Bool := by
refine
Tape.mk' (L.flatMap (fun x ↦ (enc x).toList.reverse) ⟨n, ?_⟩)
(R.flatMap (fun x ↦ (enc x).toList) ⟨n, ?_⟩) <;>
simp only [enc0, List.Vector.replicate, List.reverse_replicate, Bool.default_bool,
List.Vector.toList_mk] | def | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Finset.Prod",
"Mathlib.Data.Finset.Option",
"Mathlib.Data.Fintype.Defs",
"Mathlib.Data.PFun"
] | Mathlib/Computability/PostTuringMachine.lean | trTape' | The low level tape corresponding to the given tape over alphabet `Γ`. |
trTape (T : Tape Γ) : Tape Bool :=
trTape' enc0 T.left T.right₀ | def | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Finset.Prod",
"Mathlib.Data.Finset.Option",
"Mathlib.Data.Fintype.Defs",
"Mathlib.Data.PFun"
] | Mathlib/Computability/PostTuringMachine.lean | trTape | The low level tape corresponding to the given tape over alphabet `Γ`. |
trTape_mk' (L R : ListBlank Γ) : trTape enc0 (Tape.mk' L R) = trTape' enc0 L R := by
simp only [trTape, Tape.mk'_left, Tape.mk'_right₀] | theorem | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Finset.Prod",
"Mathlib.Data.Finset.Option",
"Mathlib.Data.Fintype.Defs",
"Mathlib.Data.PFun"
] | Mathlib/Computability/PostTuringMachine.lean | trTape_mk' | null |
tr : Λ' Γ Λ σ → Stmt Bool (Λ' Γ Λ σ) σ
| Λ'.normal l => trNormal dec (M l)
| Λ'.write a q => write (enc a).toList <| move n Dir.left <| trNormal dec q | def | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Finset.Prod",
"Mathlib.Data.Finset.Option",
"Mathlib.Data.Fintype.Defs",
"Mathlib.Data.PFun"
] | Mathlib/Computability/PostTuringMachine.lean | tr | The top level program. |
trCfg : Cfg Γ Λ σ → Cfg Bool (Λ' Γ Λ σ) σ
| ⟨l, v, T⟩ => ⟨l.map Λ'.normal, v, trTape enc0 T⟩
variable {enc} | def | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Finset.Prod",
"Mathlib.Data.Finset.Option",
"Mathlib.Data.Fintype.Defs",
"Mathlib.Data.PFun"
] | Mathlib/Computability/PostTuringMachine.lean | trCfg | The machine configuration translation. |
trTape'_move_left (L R : ListBlank Γ) :
(Tape.move Dir.left)^[n] (trTape' enc0 L R) = trTape' enc0 L.tail (R.cons L.head) := by
obtain ⟨a, L, rfl⟩ := L.exists_cons
simp only [trTape', ListBlank.cons_flatMap, ListBlank.head_cons, ListBlank.tail_cons]
suffices ∀ {L' R' l₁ l₂} (_ : List.Vector.toList (enc a) = L... | theorem | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Finset.Prod",
"Mathlib.Data.Finset.Option",
"Mathlib.Data.Fintype.Defs",
"Mathlib.Data.PFun"
] | Mathlib/Computability/PostTuringMachine.lean | trTape'_move_left | null |
trTape'_move_right (L R : ListBlank Γ) :
(Tape.move Dir.right)^[n] (trTape' enc0 L R) = trTape' enc0 (L.cons R.head) R.tail := by
suffices ∀ i L, (Tape.move Dir.right)^[i] ((Tape.move Dir.left)^[i] L) = L by
refine (Eq.symm ?_).trans (this n _)
simp only [trTape'_move_left, ListBlank.cons_head_tail, ListB... | theorem | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Finset.Prod",
"Mathlib.Data.Finset.Option",
"Mathlib.Data.Fintype.Defs",
"Mathlib.Data.PFun"
] | Mathlib/Computability/PostTuringMachine.lean | trTape'_move_right | null |
stepAux_write (q : Stmt Bool (Λ' Γ Λ σ) σ) (v : σ) (a b : Γ) (L R : ListBlank Γ) :
stepAux (write (enc a).toList q) v (trTape' enc0 L (ListBlank.cons b R)) =
stepAux q v (trTape' enc0 (ListBlank.cons a L) R) := by
simp only [trTape', ListBlank.cons_flatMap]
suffices ∀ {L' R'} (l₁ l₂ l₂' : List Bool) (_ : ... | theorem | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Finset.Prod",
"Mathlib.Data.Finset.Option",
"Mathlib.Data.Fintype.Defs",
"Mathlib.Data.PFun"
] | Mathlib/Computability/PostTuringMachine.lean | stepAux_write | null |
stepAux_read (f : Γ → Stmt Bool (Λ' Γ Λ σ) σ) (v : σ) (L R : ListBlank Γ) :
stepAux (read dec f) v (trTape' enc0 L R) = stepAux (f R.head) v (trTape' enc0 L R) := by
suffices ∀ f, stepAux (readAux n f) v (trTape' enc0 L R) =
stepAux (f (enc R.head)) v (trTape' enc0 (L.cons R.head) R.tail) by
rw [read, t... | theorem | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Finset.Prod",
"Mathlib.Data.Finset.Option",
"Mathlib.Data.Fintype.Defs",
"Mathlib.Data.PFun"
] | Mathlib/Computability/PostTuringMachine.lean | stepAux_read | null |
tr_respects :
Respects (step M) (step (tr enc dec M)) fun c₁ c₂ ↦ trCfg enc enc0 c₁ = c₂ :=
fun_respects.2 fun ⟨l₁, v, T⟩ ↦ by
obtain ⟨L, R, rfl⟩ := T.exists_mk'
rcases l₁ with - | l₁
· exact rfl
suffices ∀ q R, Reaches (step (tr enc dec M)) (stepAux (trNormal dec q) v (trTape' enc0 L R))
... | theorem | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Finset.Prod",
"Mathlib.Data.Finset.Option",
"Mathlib.Data.Fintype.Defs",
"Mathlib.Data.PFun"
] | Mathlib/Computability/PostTuringMachine.lean | tr_respects | null |
noncomputable writes : Stmt Γ Λ σ → Finset (Λ' Γ Λ σ)
| Stmt.move _ q => writes q
| Stmt.write _ q => (Finset.univ.image fun a ↦ Λ'.write a q) ∪ writes q
| Stmt.load _ q => writes q
| Stmt.branch _ q₁ q₂ => writes q₁ ∪ writes q₂
| Stmt.goto _ => ∅
| Stmt.halt => ∅
open scoped Classical in | def | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Finset.Prod",
"Mathlib.Data.Finset.Option",
"Mathlib.Data.Fintype.Defs",
"Mathlib.Data.PFun"
] | Mathlib/Computability/PostTuringMachine.lean | writes | The set of accessible `Λ'.write` machine states. |
noncomputable trSupp (S : Finset Λ) : Finset (Λ' Γ Λ σ) :=
S.biUnion fun l ↦ insert (Λ'.normal l) (writes (M l))
open scoped Classical in | def | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Finset.Prod",
"Mathlib.Data.Finset.Option",
"Mathlib.Data.Fintype.Defs",
"Mathlib.Data.PFun"
] | Mathlib/Computability/PostTuringMachine.lean | trSupp | The set of accessible machine states, assuming that the input machine is supported on `S`,
are the normal states embedded from `S`, plus all write states accessible from these states. |
tr_supports [Inhabited Λ] {S : Finset Λ} (ss : Supports M S) :
Supports (tr enc dec M) (trSupp M S) :=
⟨Finset.mem_biUnion.2 ⟨_, ss.1, Finset.mem_insert_self _ _⟩, fun q h ↦ by
suffices ∀ q, SupportsStmt S q → (∀ q' ∈ writes q, q' ∈ trSupp M S) →
SupportsStmt (trSupp M S) (trNormal dec q) ∧
∀ ... | theorem | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Finset.Prod",
"Mathlib.Data.Finset.Option",
"Mathlib.Data.Fintype.Defs",
"Mathlib.Data.PFun"
] | Mathlib/Computability/PostTuringMachine.lean | tr_supports | null |
Λ'
| normal : Λ → Λ'
| act : TM0.Stmt Γ → Λ → Λ'
variable {Γ Λ} | inductive | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Finset.Prod",
"Mathlib.Data.Finset.Option",
"Mathlib.Data.Fintype.Defs",
"Mathlib.Data.PFun"
] | Mathlib/Computability/PostTuringMachine.lean | Λ' | The machine states for a TM1 emulating a TM0 machine. States of the TM0 machine are embedded
as `normal q` states, but the actual operation is split into two parts, a jump to `act s q`
followed by the action and a jump to the next `normal` state. |
tr : Λ' Γ Λ → TM1.Stmt Γ (Λ' Γ Λ) Unit
| Λ'.normal q =>
branch (fun a _ ↦ (M q a).isNone) halt <|
goto fun a _ ↦ match M q a with
| none => default -- unreachable
| some (q', s) => Λ'.act s q'
| Λ'.act (TM0.Stmt.move d) q => move d <| goto fun _ _ ↦ Λ'.normal q
| Λ'.act (TM0.Stmt.write a) q ... | def | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Finset.Prod",
"Mathlib.Data.Finset.Option",
"Mathlib.Data.Fintype.Defs",
"Mathlib.Data.PFun"
] | Mathlib/Computability/PostTuringMachine.lean | tr | The program. |
trCfg : TM0.Cfg Γ Λ → TM1.Cfg Γ (Λ' Γ Λ) Unit
| ⟨q, T⟩ => ⟨cond (M q T.1).isSome (some (Λ'.normal q)) none, (), T⟩ | def | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Finset.Prod",
"Mathlib.Data.Finset.Option",
"Mathlib.Data.Fintype.Defs",
"Mathlib.Data.PFun"
] | Mathlib/Computability/PostTuringMachine.lean | trCfg | The configuration translation. |
tr_respects : Respects (TM0.step M) (TM1.step (tr M)) fun a b ↦ trCfg M a = b :=
fun_respects.2 fun ⟨q, T⟩ ↦ by
rcases e : M q T.1 with - | val
· simp only [TM0.step, trCfg, e]; exact Eq.refl none
obtain ⟨q', s⟩ := val
simp only [FRespects, TM0.step, trCfg, e, Option.isSome, cond, Option.map_some]
... | theorem | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Finset.Prod",
"Mathlib.Data.Finset.Option",
"Mathlib.Data.Fintype.Defs",
"Mathlib.Data.PFun"
] | Mathlib/Computability/PostTuringMachine.lean | tr_respects | null |
in `Nat.Primrec'`. `Nat.Primrec'.prim_iff` then proves it is
equivalent to our chosen formulation. For more discussion of this and
other design choices in this formalization, see [carneiro2019]. | def | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | in | null |
@[simp, reducible]
unpaired {α} (f : ℕ → ℕ → α) (n : ℕ) : α :=
f n.unpair.1 n.unpair.2 | def | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | unpaired | Calls the given function on a pair of entries `n`, encoded via the pairing function. |
protected Primrec : (ℕ → ℕ) → Prop
| zero : Nat.Primrec fun _ => 0
| protected succ : Nat.Primrec succ
| left : Nat.Primrec fun n => n.unpair.1
| right : Nat.Primrec fun n => n.unpair.2
| pair {f g} : Nat.Primrec f → Nat.Primrec g → Nat.Primrec fun n => pair (f n) (g n)
| comp {f g} : Nat.Primrec f → Nat.Pr... | inductive | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | Primrec | The primitive recursive functions `ℕ → ℕ`. |
of_eq {f g : ℕ → ℕ} (hf : Nat.Primrec f) (H : ∀ n, f n = g n) : Nat.Primrec g :=
(funext H : f = g) ▸ hf | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | of_eq | null |
const : ∀ n : ℕ, Nat.Primrec fun _ => n
| 0 => zero
| n + 1 => Primrec.succ.comp (const n) | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | const | null |
protected id : Nat.Primrec id :=
(left.pair right).of_eq fun n => by simp | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | id | null |
prec1 {f} (m : ℕ) (hf : Nat.Primrec f) :
Nat.Primrec fun n => n.rec m fun y IH => f <| Nat.pair y IH :=
((prec (const m) (hf.comp right)).comp (zero.pair Primrec.id)).of_eq fun n => by simp | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | prec1 | null |
casesOn1 {f} (m : ℕ) (hf : Nat.Primrec f) : Nat.Primrec (Nat.casesOn · m f) :=
(prec1 m (hf.comp left)).of_eq <| by simp | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | casesOn1 | null |
casesOn' {f g} (hf : Nat.Primrec f) (hg : Nat.Primrec g) :
Nat.Primrec (unpaired fun z n => n.casesOn (f z) fun y => g <| Nat.pair z y) :=
(prec hf (hg.comp (pair left (left.comp right)))).of_eq fun n => by simp | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | casesOn' | null |
protected swap : Nat.Primrec (unpaired (swap Nat.pair)) :=
(pair right left).of_eq fun n => by simp | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | swap | null |
swap' {f} (hf : Nat.Primrec (unpaired f)) : Nat.Primrec (unpaired (swap f)) :=
(hf.comp .swap).of_eq fun n => by simp | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | swap' | null |
pred : Nat.Primrec pred :=
(casesOn1 0 Primrec.id).of_eq fun n => by cases n <;> simp [*] | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | pred | null |
add : Nat.Primrec (unpaired (· + ·)) :=
(prec .id ((Primrec.succ.comp right).comp right)).of_eq fun p => by
simp; induction p.unpair.2 <;> simp [*, Nat.add_assoc] | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | add | null |
sub : Nat.Primrec (unpaired (· - ·)) :=
(prec .id ((pred.comp right).comp right)).of_eq fun p => by
simp; induction p.unpair.2 <;> simp [*, Nat.sub_add_eq] | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | sub | null |
mul : Nat.Primrec (unpaired (· * ·)) :=
(prec zero (add.comp (pair left (right.comp right)))).of_eq fun p => by
simp; induction p.unpair.2 <;> simp [*, mul_succ, add_comm _ (unpair p).fst] | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | mul | null |
pow : Nat.Primrec (unpaired (· ^ ·)) :=
(prec (const 1) (mul.comp (pair (right.comp right) left))).of_eq fun p => by
simp; induction p.unpair.2 <;> simp [*, Nat.pow_succ] | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | pow | null |
Primcodable (α : Type*) extends Encodable α where
prim (α) : Nat.Primrec fun n => Encodable.encode (decode n) | class | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | Primcodable | A `Primcodable` type is, essentially, an `Encodable` type for which
the encode/decode functions are primitive recursive.
However, such a definition is circular.
Instead, we ask that the composition of `decode : ℕ → Option α` with
`encode : Option α → ℕ` is primitive recursive. Said composition is
the identity function... |
ofEquiv (α) {β} [Primcodable α] (e : β ≃ α) : Primcodable β :=
{ __ := Encodable.ofEquiv α e
prim := (Primcodable.prim α).of_eq fun n => by
rw [decode_ofEquiv]
cases (@decode α _ n) <;>
simp [encode_ofEquiv] } | def | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | ofEquiv | Builds a `Primcodable` instance from an equivalence to a `Primcodable` type. |
empty : Primcodable Empty :=
⟨zero⟩ | instance | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | empty | null |
unit : Primcodable PUnit :=
⟨(casesOn1 1 zero).of_eq fun n => by cases n <;> simp⟩ | instance | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | unit | null |
option {α : Type*} [h : Primcodable α] : Primcodable (Option α) :=
⟨(casesOn1 1 ((casesOn1 0 (.comp .succ .succ)).comp (Primcodable.prim α))).of_eq fun n => by
cases n with
| zero => rfl
| succ n =>
rw [decode_option_succ]
cases H : @decode α _ n <;> simp [H]⟩ | instance | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | option | null |
bool : Primcodable Bool :=
⟨(casesOn1 1 (casesOn1 2 zero)).of_eq fun n => match n with
| 0 => rfl
| 1 => rfl
| (n + 2) => by rw [decode_ge_two] <;> simp⟩ | instance | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | bool | null |
Primrec {α β} [Primcodable α] [Primcodable β] (f : α → β) : Prop :=
Nat.Primrec fun n => encode ((@decode α _ n).map f) | def | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | Primrec | `Primrec f` means `f` is primitive recursive (after
encoding its input and output as natural numbers). |
protected encode : Primrec (@encode α _) :=
(Primcodable.prim α).of_eq fun n => by cases @decode α _ n <;> rfl | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | encode | null |
protected decode : Primrec (@decode α _) :=
Nat.Primrec.succ.comp (Primcodable.prim α) | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | decode | null |
dom_denumerable {α β} [Denumerable α] [Primcodable β] {f : α → β} :
Primrec f ↔ Nat.Primrec fun n => encode (f (ofNat α n)) :=
⟨fun h => (pred.comp h).of_eq fun n => by simp, fun h =>
(Nat.Primrec.succ.comp h).of_eq fun n => by simp⟩ | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | dom_denumerable | null |
nat_iff {f : ℕ → ℕ} : Primrec f ↔ Nat.Primrec f :=
dom_denumerable | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | nat_iff | null |
encdec : Primrec fun n => encode (@decode α _ n) :=
nat_iff.2 (Primcodable.prim _) | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | encdec | null |
option_some : Primrec (@some α) :=
((casesOn1 0 (Nat.Primrec.succ.comp .succ)).comp (Primcodable.prim α)).of_eq fun n => by
cases @decode α _ n <;> simp | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | option_some | null |
of_eq {f g : α → σ} (hf : Primrec f) (H : ∀ n, f n = g n) : Primrec g :=
(funext H : f = g) ▸ hf | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | of_eq | null |
const (x : σ) : Primrec fun _ : α => x :=
((casesOn1 0 (.const (encode x).succ)).comp (Primcodable.prim α)).of_eq fun n => by
cases @decode α _ n <;> rfl | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | const | null |
protected id : Primrec (@id α) :=
(Primcodable.prim α).of_eq <| by simp | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | id | null |
comp {f : β → σ} {g : α → β} (hf : Primrec f) (hg : Primrec g) : Primrec fun a => f (g a) :=
((casesOn1 0 (.comp hf (pred.comp hg))).comp (Primcodable.prim α)).of_eq fun n => by
cases @decode α _ n <;> simp [encodek] | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | comp | null |
succ : Primrec Nat.succ :=
nat_iff.2 Nat.Primrec.succ | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | succ | null |
pred : Primrec Nat.pred :=
nat_iff.2 Nat.Primrec.pred | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | pred | null |
encode_iff {f : α → σ} : (Primrec fun a => encode (f a)) ↔ Primrec f :=
⟨fun h => Nat.Primrec.of_eq h fun n => by cases @decode α _ n <;> rfl, Primrec.encode.comp⟩ | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | encode_iff | null |
ofNat_iff {α β} [Denumerable α] [Primcodable β] {f : α → β} :
Primrec f ↔ Primrec fun n => f (ofNat α n) :=
dom_denumerable.trans <| nat_iff.symm.trans encode_iff | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | ofNat_iff | null |
protected ofNat (α) [Denumerable α] : Primrec (ofNat α) :=
ofNat_iff.1 Primrec.id | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | ofNat | null |
option_some_iff {f : α → σ} : (Primrec fun a => some (f a)) ↔ Primrec f :=
⟨fun h => encode_iff.1 <| pred.comp <| encode_iff.2 h, option_some.comp⟩ | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | option_some_iff | null |
of_equiv {β} {e : β ≃ α} :
haveI := Primcodable.ofEquiv α e
Primrec e :=
letI : Primcodable β := Primcodable.ofEquiv α e
encode_iff.1 Primrec.encode | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | of_equiv | null |
of_equiv_symm {β} {e : β ≃ α} :
haveI := Primcodable.ofEquiv α e
Primrec e.symm :=
letI := Primcodable.ofEquiv α e
encode_iff.1 (show Primrec fun a => encode (e (e.symm a)) by simp [Primrec.encode]) | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | of_equiv_symm | null |
of_equiv_iff {β} (e : β ≃ α) {f : σ → β} :
haveI := Primcodable.ofEquiv α e
(Primrec fun a => e (f a)) ↔ Primrec f :=
letI := Primcodable.ofEquiv α e
⟨fun h => (of_equiv_symm.comp h).of_eq fun a => by simp, of_equiv.comp⟩ | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | of_equiv_iff | null |
of_equiv_symm_iff {β} (e : β ≃ α) {f : σ → α} :
haveI := Primcodable.ofEquiv α e
(Primrec fun a => e.symm (f a)) ↔ Primrec f :=
letI := Primcodable.ofEquiv α e
⟨fun h => (of_equiv.comp h).of_eq fun a => by simp, of_equiv_symm.comp⟩ | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | of_equiv_symm_iff | null |
prod {α β} [Primcodable α] [Primcodable β] : Primcodable (α × β) :=
⟨((casesOn' zero ((casesOn' zero .succ).comp (pair right ((Primcodable.prim β).comp left)))).comp
(pair right ((Primcodable.prim α).comp left))).of_eq
fun n => by
simp only [Nat.unpaired, Nat.unpair_pair, decode_prod_val]
... | instance | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | prod | null |
fst {α β} [Primcodable α] [Primcodable β] : Primrec (@Prod.fst α β) :=
((casesOn' zero
((casesOn' zero (Nat.Primrec.succ.comp left)).comp
(pair right ((Primcodable.prim β).comp left)))).comp
(pair right ((Primcodable.prim α).comp left))).of_eq
fun n => by
simp only [Nat.unpai... | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | fst | null |
snd {α β} [Primcodable α] [Primcodable β] : Primrec (@Prod.snd α β) :=
((casesOn' zero
((casesOn' zero (Nat.Primrec.succ.comp right)).comp
(pair right ((Primcodable.prim β).comp left)))).comp
(pair right ((Primcodable.prim α).comp left))).of_eq
fun n => by
simp only [Nat.unpa... | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | snd | null |
pair {α β γ} [Primcodable α] [Primcodable β] [Primcodable γ] {f : α → β} {g : α → γ}
(hf : Primrec f) (hg : Primrec g) : Primrec fun a => (f a, g a) :=
((casesOn1 0
(Nat.Primrec.succ.comp <|
.pair (Nat.Primrec.pred.comp hf) (Nat.Primrec.pred.comp hg))).comp
(Primcodable.prim α)).... | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | pair | null |
unpair : Primrec Nat.unpair :=
(pair (nat_iff.2 .left) (nat_iff.2 .right)).of_eq fun n => by simp | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | unpair | null |
list_getElem?₁ : ∀ l : List α, Primrec (l[·]? : ℕ → Option α)
| [] => dom_denumerable.2 zero
| a :: l =>
dom_denumerable.2 <|
(casesOn1 (encode a).succ <| dom_denumerable.1 <| list_getElem?₁ l).of_eq fun n => by
cases n <;> simp
@[deprecated (since := "2025-02-14")] alias list_get?₁ := list_getEle... | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | list_getElem | null |
Primrec₂ {α β σ} [Primcodable α] [Primcodable β] [Primcodable σ] (f : α → β → σ) :=
Primrec fun p : α × β => f p.1 p.2 | def | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | Primrec₂ | `Primrec₂ f` means `f` is a binary primitive recursive function.
This is technically unnecessary since we can always curry all
the arguments together, but there are enough natural two-arg
functions that it is convenient to express this directly. |
PrimrecPred {α} [Primcodable α] (p : α → Prop) :=
∃ (_ : DecidablePred p), Primrec fun a => decide (p a) | def | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | PrimrecPred | `PrimrecPred p` means `p : α → Prop` is a
primitive recursive predicate, which is to say that
`decide ∘ p : α → Bool` is primitive recursive. |
PrimrecRel {α β} [Primcodable α] [Primcodable β] (s : α → β → Prop) :=
PrimrecPred fun p : α × β => s p.1 p.2 | def | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | PrimrecRel | `PrimrecRel p` means `p : α → β → Prop` is a
primitive recursive relation, which is to say that
`decide ∘ p : α → β → Bool` is primitive recursive. |
mk {f : α → β → σ} (hf : Primrec fun p : α × β => f p.1 p.2) : Primrec₂ f := hf | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | mk | null |
of_eq {f g : α → β → σ} (hg : Primrec₂ f) (H : ∀ a b, f a b = g a b) : Primrec₂ g :=
(by funext a b; apply H : f = g) ▸ hg | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | of_eq | null |
const (x : σ) : Primrec₂ fun (_ : α) (_ : β) => x :=
Primrec.const _ | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | const | null |
protected pair : Primrec₂ (@Prod.mk α β) :=
Primrec.pair .fst .snd | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | pair | null |
left : Primrec₂ fun (a : α) (_ : β) => a :=
.fst | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | left | null |
right : Primrec₂ fun (_ : α) (b : β) => b :=
.snd | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | right | null |
natPair : Primrec₂ Nat.pair := by simp [Primrec₂, Primrec]; constructor | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | natPair | null |
unpaired {f : ℕ → ℕ → α} : Primrec (Nat.unpaired f) ↔ Primrec₂ f :=
⟨fun h => by simpa using h.comp natPair, fun h => h.comp Primrec.unpair⟩ | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | unpaired | null |
unpaired' {f : ℕ → ℕ → ℕ} : Nat.Primrec (Nat.unpaired f) ↔ Primrec₂ f :=
Primrec.nat_iff.symm.trans unpaired | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | unpaired' | null |
encode_iff {f : α → β → σ} : (Primrec₂ fun a b => encode (f a b)) ↔ Primrec₂ f :=
Primrec.encode_iff | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | encode_iff | null |
option_some_iff {f : α → β → σ} : (Primrec₂ fun a b => some (f a b)) ↔ Primrec₂ f :=
Primrec.option_some_iff | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | option_some_iff | null |
ofNat_iff {α β σ} [Denumerable α] [Denumerable β] [Primcodable σ] {f : α → β → σ} :
Primrec₂ f ↔ Primrec₂ fun m n : ℕ => f (ofNat α m) (ofNat β n) :=
(Primrec.ofNat_iff.trans <| by simp).trans unpaired | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | ofNat_iff | null |
uncurry {f : α → β → σ} : Primrec (Function.uncurry f) ↔ Primrec₂ f := by
rw [show Function.uncurry f = fun p : α × β => f p.1 p.2 from funext fun ⟨a, b⟩ => rfl]; rfl | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | uncurry | null |
curry {f : α × β → σ} : Primrec₂ (Function.curry f) ↔ Primrec f := by
rw [← uncurry, Function.uncurry_curry] | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | curry | null |
Primrec.comp₂ {f : γ → σ} {g : α → β → γ} (hf : Primrec f) (hg : Primrec₂ g) :
Primrec₂ fun a b => f (g a b) :=
hf.comp hg | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | Primrec.comp₂ | null |
Primrec₂.comp {f : β → γ → σ} {g : α → β} {h : α → γ} (hf : Primrec₂ f) (hg : Primrec g)
(hh : Primrec h) : Primrec fun a => f (g a) (h a) :=
Primrec.comp hf (hg.pair hh) | theorem | Computability | [
"Mathlib.Algebra.Order.Ring.Nat",
"Mathlib.Logic.Encodable.Pi",
"Mathlib.Logic.Function.Iterate"
] | Mathlib/Computability/Primrec.lean | Primrec₂.comp | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.