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 ⌀ |
|---|---|---|---|---|---|---|
protected Computable.partrec {α σ} [Primcodable α] [Primcodable σ] {f : α → σ}
(hf : Computable f) : Partrec (f : α →. σ) :=
hf | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | Computable.partrec | null |
protected Computable₂.partrec₂ {α β σ} [Primcodable α] [Primcodable β] [Primcodable σ]
{f : α → β → σ} (hf : Computable₂ f) : Partrec₂ fun a => (f a : β →. σ) :=
hf | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | Computable₂.partrec₂ | null |
of_eq {f g : α → σ} (hf : Computable f) (H : ∀ n, f n = g n) : Computable g :=
(funext H : f = g) ▸ hf | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | of_eq | null |
const (s : σ) : Computable fun _ : α => s :=
(Primrec.const _).to_comp | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | const | null |
ofOption {f : α → Option β} (hf : Computable f) : Partrec fun a => (f a : Part β) :=
(Nat.Partrec.ppred.comp hf).of_eq fun n => by
rcases decode (α := α) n with - | a <;> simp
rcases f a with - | b <;> simp | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | ofOption | null |
to₂ {f : α × β → σ} (hf : Computable f) : Computable₂ fun a b => f (a, b) :=
hf.of_eq fun ⟨_, _⟩ => rfl | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | to₂ | null |
protected id : Computable (@id α) :=
Primrec.id.to_comp | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | id | null |
fst : Computable (@Prod.fst α β) :=
Primrec.fst.to_comp | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | fst | null |
snd : Computable (@Prod.snd α β) :=
Primrec.snd.to_comp
nonrec theorem pair {f : α → β} {g : α → γ} (hf : Computable f) (hg : Computable g) :
Computable fun a => (f a, g a) :=
(hf.pair hg).of_eq fun n => by cases decode (α := α) n <;> simp [Seq.seq] | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | snd | null |
unpair : Computable Nat.unpair :=
Primrec.unpair.to_comp | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | unpair | null |
succ : Computable Nat.succ :=
Primrec.succ.to_comp | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | succ | null |
pred : Computable Nat.pred :=
Primrec.pred.to_comp | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | pred | null |
nat_bodd : Computable Nat.bodd :=
Primrec.nat_bodd.to_comp | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | nat_bodd | null |
nat_div2 : Computable Nat.div2 :=
Primrec.nat_div2.to_comp | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | nat_div2 | null |
sumInl : Computable (@Sum.inl α β) :=
Primrec.sumInl.to_comp | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | sumInl | null |
sumInr : Computable (@Sum.inr α β) :=
Primrec.sumInr.to_comp | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | sumInr | null |
list_cons : Computable₂ (@List.cons α) :=
Primrec.list_cons.to_comp | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | list_cons | null |
list_reverse : Computable (@List.reverse α) :=
Primrec.list_reverse.to_comp | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | list_reverse | null |
list_getElem? : Computable₂ ((·[·]? : List α → ℕ → Option α)) :=
Primrec.list_getElem?.to_comp | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | list_getElem | null |
list_append : Computable₂ ((· ++ ·) : List α → List α → List α) :=
Primrec.list_append.to_comp | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | list_append | null |
list_concat : Computable₂ fun l (a : α) => l ++ [a] :=
Primrec.list_concat.to_comp | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | list_concat | null |
list_length : Computable (@List.length α) :=
Primrec.list_length.to_comp | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | list_length | null |
vector_cons {n} : Computable₂ (@List.Vector.cons α n) :=
Primrec.vector_cons.to_comp | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | vector_cons | null |
vector_toList {n} : Computable (@List.Vector.toList α n) :=
Primrec.vector_toList.to_comp | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | vector_toList | null |
vector_length {n} : Computable (@List.Vector.length α n) :=
Primrec.vector_length.to_comp | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | vector_length | null |
vector_head {n} : Computable (@List.Vector.head α n) :=
Primrec.vector_head.to_comp | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | vector_head | null |
vector_tail {n} : Computable (@List.Vector.tail α n) :=
Primrec.vector_tail.to_comp | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | vector_tail | null |
vector_get {n} : Computable₂ (@List.Vector.get α n) :=
Primrec.vector_get.to_comp | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | vector_get | null |
vector_ofFn' {n} : Computable (@List.Vector.ofFn α n) :=
Primrec.vector_ofFn'.to_comp | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | vector_ofFn' | null |
fin_app {n} : Computable₂ (@id (Fin n → σ)) :=
Primrec.fin_app.to_comp | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | fin_app | null |
protected encode : Computable (@encode α _) :=
Primrec.encode.to_comp | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | encode | null |
protected decode : Computable (decode (α := α)) :=
Primrec.decode.to_comp | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | decode | null |
protected ofNat (α) [Denumerable α] : Computable (ofNat α) :=
(Primrec.ofNat _).to_comp | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | ofNat | null |
encode_iff {f : α → σ} : (Computable fun a => encode (f a)) ↔ Computable f :=
Iff.rfl | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | encode_iff | null |
option_some : Computable (@Option.some α) :=
Primrec.option_some.to_comp | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | option_some | null |
of_eq {f g : α →. σ} (hf : Partrec f) (H : ∀ n, f n = g n) : Partrec g :=
(funext H : f = g) ▸ hf | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | of_eq | null |
of_eq_tot {f : α →. σ} {g : α → σ} (hf : Partrec f) (H : ∀ n, g n ∈ f n) : Computable g :=
hf.of_eq fun a => eq_some_iff.2 (H a) | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | of_eq_tot | null |
none : Partrec fun _ : α => @Part.none σ :=
Nat.Partrec.none.of_eq fun n => by cases decode (α := α) n <;> simp | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | none | null |
protected some : Partrec (@Part.some α) :=
Computable.id | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | some | null |
_root_.Decidable.Partrec.const' (s : Part σ) [Decidable s.Dom] : Partrec fun _ : α => s :=
(Computable.ofOption (const (toOption s))).of_eq fun _ => of_toOption s | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | _root_.Decidable.Partrec.const' | null |
const' (s : Part σ) : Partrec fun _ : α => s :=
haveI := Classical.dec s.Dom
Decidable.Partrec.const' s | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | const' | null |
protected bind {f : α →. β} {g : α → β →. σ} (hf : Partrec f) (hg : Partrec₂ g) :
Partrec fun a => (f a).bind (g a) :=
(hg.comp (Nat.Partrec.some.pair hf)).of_eq fun n => by
simp [Seq.seq]; rcases e : decode (α := α) n with - | a <;> simp [e, encodek] | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | bind | null |
map {f : α →. β} {g : α → β → σ} (hf : Partrec f) (hg : Computable₂ g) :
Partrec fun a => (f a).map (g a) := by
simpa [bind_some_eq_map] using Partrec.bind (g := fun a x => some (g a x)) hf hg | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | map | null |
to₂ {f : α × β →. σ} (hf : Partrec f) : Partrec₂ fun a b => f (a, b) :=
hf.of_eq fun ⟨_, _⟩ => rfl | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | to₂ | null |
nat_rec {f : α → ℕ} {g : α →. σ} {h : α → ℕ × σ →. σ} (hf : Computable f) (hg : Partrec g)
(hh : Partrec₂ h) : Partrec fun a => (f a).rec (g a) fun y IH => IH.bind fun i => h a (y, i) :=
(Nat.Partrec.prec' hf hg hh).of_eq fun n => by
rcases e : decode (α := α) n with - | a <;> simp [e]
induction f a with simp | succ m IH
rw [IH, Part.bind_map]
congr; funext s
simp [encodek]
nonrec theorem comp {f : β →. σ} {g : α → β} (hf : Partrec f) (hg : Computable g) :
Partrec fun a => f (g a) :=
(hf.comp hg).of_eq fun n => by simp; rcases e : decode (α := α) n with - | a <;> simp [encodek] | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | nat_rec | null |
nat_iff {f : ℕ →. ℕ} : Partrec f ↔ Nat.Partrec f := by simp [Partrec, map_id'] | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | nat_iff | null |
map_encode_iff {f : α →. σ} : (Partrec fun a => (f a).map encode) ↔ Partrec f :=
Iff.rfl | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | map_encode_iff | null |
unpaired {f : ℕ → ℕ →. α} : Partrec (Nat.unpaired f) ↔ Partrec₂ f :=
⟨fun h => by simpa using Partrec.comp (g := fun p : ℕ × ℕ => (p.1, p.2)) h Primrec₂.pair.to_comp,
fun h => h.comp Primrec.unpair.to_comp⟩ | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | unpaired | null |
unpaired' {f : ℕ → ℕ →. ℕ} : Nat.Partrec (Nat.unpaired f) ↔ Partrec₂ f :=
Partrec.nat_iff.symm.trans unpaired
nonrec theorem comp {f : β → γ →. σ} {g : α → β} {h : α → γ} (hf : Partrec₂ f) (hg : Computable g)
(hh : Computable h) : Partrec fun a => f (g a) (h a) :=
hf.comp (hg.pair hh) | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | unpaired' | null |
comp₂ {f : γ → δ →. σ} {g : α → β → γ} {h : α → β → δ} (hf : Partrec₂ f)
(hg : Computable₂ g) (hh : Computable₂ h) : Partrec₂ fun a b => f (g a b) (h a b) :=
hf.comp hg hh | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | comp₂ | null |
comp₂ {f : γ → σ} {g : α → β → γ} (hf : Computable f) (hg : Computable₂ g) :
Computable₂ fun a b => f (g a b) :=
hf.comp hg | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | comp₂ | null |
mk {f : α → β → σ} (hf : Computable fun p : α × β => f p.1 p.2) : Computable₂ f := hf
nonrec theorem comp {f : β → γ → σ} {g : α → β} {h : α → γ} (hf : Computable₂ f)
(hg : Computable g) (hh : Computable h) : Computable fun a => f (g a) (h a) :=
hf.comp (hg.pair hh) | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | mk | null |
comp₂ {f : γ → δ → σ} {g : α → β → γ} {h : α → β → δ} (hf : Computable₂ f)
(hg : Computable₂ g) (hh : Computable₂ h) : Computable₂ fun a b => f (g a b) (h a b) :=
hf.comp hg hh | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | comp₂ | null |
rfind {p : α → ℕ →. Bool} (hp : Partrec₂ p) : Partrec fun a => Nat.rfind (p a) :=
(Nat.Partrec.rfind <|
hp.map ((Primrec.dom_bool fun b => cond b 0 1).comp Primrec.snd).to₂.to_comp).of_eq
fun n => by
rcases e : decode (α := α) n with - | a <;> simp [e, Nat.rfind_zero_none, map_id']
congr; funext n
simp only [map_map]
refine map_id' (fun b => ?_) _
cases b <;> rfl | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | rfind | null |
rfindOpt {f : α → ℕ → Option σ} (hf : Computable₂ f) :
Partrec fun a => Nat.rfindOpt (f a) :=
(rfind (Primrec.option_isSome.to_comp.comp hf).partrec.to₂).bind (ofOption hf) | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | rfindOpt | null |
nat_casesOn_right {f : α → ℕ} {g : α → σ} {h : α → ℕ →. σ} (hf : Computable f)
(hg : Computable g) (hh : Partrec₂ h) : Partrec fun a => (f a).casesOn (some (g a)) (h a) :=
(nat_rec hf hg (hh.comp fst (pred.comp <| hf.comp fst)).to₂).of_eq fun a => by
simp only [PFun.coe_val, Nat.pred_eq_sub_one]; rcases f a with - | n <;> simp
refine ext fun b => ⟨fun H => ?_, fun H => ?_⟩
· rcases mem_bind_iff.1 H with ⟨c, _, h₂⟩
exact h₂
· have : ∀ m, (Nat.rec (motive := fun _ => Part σ)
(Part.some (g a)) (fun y IH => IH.bind fun _ => h a n) m).Dom := by
intro m
induction m <;> simp [*, H.fst]
exact ⟨⟨this n, H.fst⟩, H.snd⟩ | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | nat_casesOn_right | null |
bind_decode₂_iff {f : α →. σ} :
Partrec f ↔ Nat.Partrec fun n => Part.bind (decode₂ α n) fun a => (f a).map encode :=
⟨fun hf =>
nat_iff.1 <|
(Computable.ofOption Primrec.decode₂.to_comp).bind <|
(map hf (Computable.encode.comp snd).to₂).comp snd,
fun h =>
map_encode_iff.1 <| by simpa [encodek₂] using (nat_iff.2 h).comp (@Computable.encode α _)⟩ | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | bind_decode₂_iff | null |
vector_mOfFn :
∀ {n} {f : Fin n → α →. σ},
(∀ i, Partrec (f i)) → Partrec fun a : α => Vector.mOfFn fun i => f i a
| 0, _, _ => const _
| n + 1, f, hf => by
simp only [Vector.mOfFn, pure_eq_some, bind_eq_bind]
exact
(hf 0).bind
(Partrec.bind ((vector_mOfFn fun i => hf i.succ).comp fst)
(Primrec.vector_cons.to_comp.comp (snd.comp fst) snd)) | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | vector_mOfFn | null |
@[simp]
Vector.mOfFn_part_some {α n} :
∀ f : Fin n → α,
(List.Vector.mOfFn fun i => Part.some (f i)) = Part.some (List.Vector.ofFn f) :=
Vector.mOfFn_pure | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | Vector.mOfFn_part_some | null |
option_some_iff {f : α → σ} : (Computable fun a => Option.some (f a)) ↔ Computable f :=
⟨fun h => encode_iff.1 <| Primrec.pred.to_comp.comp <| encode_iff.2 h, option_some.comp⟩ | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | option_some_iff | null |
bind_decode_iff {f : α → β → Option σ} :
(Computable₂ fun a n => (decode (α := β) n).bind (f a)) ↔ Computable₂ f :=
⟨fun hf =>
Nat.Partrec.of_eq
(((Partrec.nat_iff.2
(Nat.Partrec.ppred.comp <| Nat.Partrec.of_primrec <| Primcodable.prim (α := β))).comp
snd).bind
(Computable.comp hf fst).to₂.partrec₂)
fun n => by
simp only [decode_prod_val, decode_nat, Option.map_some, PFun.coe_val, bind_eq_bind,
bind_some, Part.map_bind, map_some]
cases decode (α := α) n.unpair.1 <;> simp
cases decode (α := β) n.unpair.2 <;> simp,
fun hf => by
have :
Partrec fun a : α × ℕ =>
(encode (decode (α := β) a.2)).casesOn (some Option.none)
fun n => Part.map (f a.1) (decode (α := β) n) :=
Partrec.nat_casesOn_right
(h := fun (a : α × ℕ) (n : ℕ) ↦ map (fun b ↦ f a.1 b) (Part.ofOption (decode n)))
(Primrec.encdec.to_comp.comp snd) (const Option.none)
((ofOption (Computable.decode.comp snd)).map (hf.comp (fst.comp <| fst.comp fst) snd).to₂)
refine this.of_eq fun a => ?_
simp; cases decode (α := β) a.2 <;> simp [encodek]⟩ | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | bind_decode_iff | null |
map_decode_iff {f : α → β → σ} :
(Computable₂ fun a n => (decode (α := β) n).map (f a)) ↔ Computable₂ f := by
convert (bind_decode_iff (f := fun a => Option.some ∘ f a)).trans option_some_iff
apply Option.map_eq_bind | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | map_decode_iff | null |
nat_rec {f : α → ℕ} {g : α → σ} {h : α → ℕ × σ → σ} (hf : Computable f) (hg : Computable g)
(hh : Computable₂ h) :
Computable fun a => Nat.rec (motive := fun _ => σ) (g a) (fun y IH => h a (y, IH)) (f a) :=
(Partrec.nat_rec hf hg hh.partrec₂).of_eq fun a => by simp; induction f a <;> simp [*] | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | nat_rec | null |
nat_casesOn {f : α → ℕ} {g : α → σ} {h : α → ℕ → σ} (hf : Computable f) (hg : Computable g)
(hh : Computable₂ h) :
Computable fun a => Nat.casesOn (motive := fun _ => σ) (f a) (g a) (h a) :=
nat_rec hf hg (hh.comp fst <| fst.comp snd).to₂ | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | nat_casesOn | null |
cond {c : α → Bool} {f : α → σ} {g : α → σ} (hc : Computable c) (hf : Computable f)
(hg : Computable g) : Computable fun a => cond (c a) (f a) (g a) :=
(nat_casesOn (encode_iff.2 hc) hg (hf.comp fst).to₂).of_eq fun a => by cases c a <;> rfl | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | cond | null |
option_casesOn {o : α → Option β} {f : α → σ} {g : α → β → σ} (ho : Computable o)
(hf : Computable f) (hg : Computable₂ g) :
@Computable _ σ _ _ fun a => Option.casesOn (o a) (f a) (g a) :=
option_some_iff.1 <|
(nat_casesOn (encode_iff.2 ho) (option_some_iff.2 hf) (map_decode_iff.2 hg)).of_eq fun a => by
cases o a <;> simp [encodek] | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | option_casesOn | null |
option_bind {f : α → Option β} {g : α → β → Option σ} (hf : Computable f)
(hg : Computable₂ g) : Computable fun a => (f a).bind (g a) :=
(option_casesOn hf (const Option.none) hg).of_eq fun a => by cases f a <;> rfl | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | option_bind | null |
option_map {f : α → Option β} {g : α → β → σ} (hf : Computable f) (hg : Computable₂ g) :
Computable fun a => (f a).map (g a) := by
convert option_bind hf (option_some.comp₂ hg)
apply Option.map_eq_bind | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | option_map | null |
option_getD {f : α → Option β} {g : α → β} (hf : Computable f) (hg : Computable g) :
Computable fun a => (f a).getD (g a) :=
(Computable.option_casesOn hf hg (show Computable₂ fun _ b => b from Computable.snd)).of_eq
fun a => by cases f a <;> rfl | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | option_getD | null |
subtype_mk {f : α → β} {p : β → Prop} [DecidablePred p] {h : ∀ a, p (f a)}
(hp : PrimrecPred p) (hf : Computable f) :
@Computable _ _ _ (Primcodable.subtype hp) fun a => (⟨f a, h a⟩ : Subtype p) :=
hf | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | subtype_mk | null |
sumCasesOn {f : α → β ⊕ γ} {g : α → β → σ} {h : α → γ → σ} (hf : Computable f)
(hg : Computable₂ g) (hh : Computable₂ h) :
@Computable _ σ _ _ fun a => Sum.casesOn (f a) (g a) (h a) :=
option_some_iff.1 <|
(cond (nat_bodd.comp <| encode_iff.2 hf)
(option_map (Computable.decode.comp <| nat_div2.comp <| encode_iff.2 hf) hh)
(option_map (Computable.decode.comp <| nat_div2.comp <| encode_iff.2 hf) hg)).of_eq
fun a => by
rcases f a with b | c <;> simp [Nat.div2_val] | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | sumCasesOn | null |
nat_strong_rec (f : α → ℕ → σ) {g : α → List σ → Option σ} (hg : Computable₂ g)
(H : ∀ a n, g a ((List.range n).map (f a)) = Option.some (f a n)) : Computable₂ f :=
suffices Computable₂ fun a n => (List.range n).map (f a) from
option_some_iff.1 <|
(list_getElem?.comp (this.comp fst (succ.comp snd)) snd).to₂.of_eq fun a => by
simp
option_some_iff.1 <|
(nat_rec snd (const (Option.some []))
(to₂ <|
option_bind (snd.comp snd) <|
to₂ <|
option_map (hg.comp (fst.comp <| fst.comp fst) snd)
(to₂ <| list_concat.comp (snd.comp fst) snd))).of_eq
fun a => by
induction a.2 with
| zero => rfl
| succ n IH => simp [IH, H, List.range_succ] | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | nat_strong_rec | null |
list_ofFn :
∀ {n} {f : Fin n → α → σ},
(∀ i, Computable (f i)) → Computable fun a => List.ofFn fun i => f i a
| 0, _, _ => by
simp only [List.ofFn_zero]
exact const []
| n + 1, f, hf => by
simp only [List.ofFn_succ]
exact list_cons.comp (hf 0) (list_ofFn fun i => hf i.succ) | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | list_ofFn | null |
vector_ofFn {n} {f : Fin n → α → σ} (hf : ∀ i, Computable (f i)) :
Computable fun a => List.Vector.ofFn fun i => f i a :=
(Partrec.vector_mOfFn hf).of_eq fun a => by simp | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | vector_ofFn | null |
option_some_iff {f : α →. σ} : (Partrec fun a => (f a).map Option.some) ↔ Partrec f :=
⟨fun h => (Nat.Partrec.ppred.comp h).of_eq fun n => by simp [Part.bind_assoc, bind_some_eq_map],
fun hf => hf.map (option_some.comp snd).to₂⟩ | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | option_some_iff | null |
optionCasesOn_right {o : α → Option β} {f : α → σ} {g : α → β →. σ} (ho : Computable o)
(hf : Computable f) (hg : Partrec₂ g) :
@Partrec _ σ _ _ fun a => Option.casesOn (o a) (Part.some (f a)) (g a) :=
have :
Partrec fun a : α =>
Nat.casesOn (encode (o a)) (Part.some (f a)) (fun n => Part.bind (decode (α := β) n) (g a)) :=
nat_casesOn_right (h := fun a n ↦ Part.bind (ofOption (decode n)) fun b ↦ g a b)
(encode_iff.2 ho) hf.partrec <|
((@Computable.decode β _).comp snd).ofOption.bind (hg.comp (fst.comp fst) snd).to₂
this.of_eq fun a => by rcases o a with - | b <;> simp [encodek] | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | optionCasesOn_right | null |
sumCasesOn_right {f : α → β ⊕ γ} {g : α → β → σ} {h : α → γ →. σ} (hf : Computable f)
(hg : Computable₂ g) (hh : Partrec₂ h) :
@Partrec _ σ _ _ fun a => Sum.casesOn (f a) (fun b => Part.some (g a b)) (h a) :=
have :
Partrec fun a =>
(Option.casesOn (Sum.casesOn (f a) (fun _ => Option.none) Option.some : Option γ)
(some (Sum.casesOn (f a) (fun b => some (g a b)) fun _ => Option.none)) fun c =>
(h a c).map Option.some :
Part (Option σ)) :=
optionCasesOn_right (g := fun a n => Part.map Option.some (h a n))
(sumCasesOn hf (const Option.none).to₂ (option_some.comp snd).to₂)
(sumCasesOn (g := fun a n => Option.some (g a n)) hf (option_some.comp hg)
(const Option.none).to₂)
(option_some_iff.2 hh)
option_some_iff.1 <| this.of_eq fun a => by cases f a <;> simp | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | sumCasesOn_right | null |
sumCasesOn_left {f : α → β ⊕ γ} {g : α → β →. σ} {h : α → γ → σ} (hf : Computable f)
(hg : Partrec₂ g) (hh : Computable₂ h) :
@Partrec _ σ _ _ fun a => Sum.casesOn (f a) (g a) fun c => Part.some (h a c) :=
(sumCasesOn_right (sumCasesOn hf (sumInr.comp snd).to₂ (sumInl.comp snd).to₂) hh hg).of_eq
fun a => by cases f a <;> simp | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | sumCasesOn_left | null |
fix_aux {α σ} (f : α →. σ ⊕ α) (a : α) (b : σ) :
let F : α → ℕ →. σ ⊕ α := fun a n =>
n.rec (some (Sum.inr a)) fun _ IH => IH.bind fun s => Sum.casesOn s (fun _ => Part.some s) f
(∃ n : ℕ,
((∃ b' : σ, Sum.inl b' ∈ F a n) ∧ ∀ {m : ℕ}, m < n → ∃ b : α, Sum.inr b ∈ F a m) ∧
Sum.inl b ∈ F a n) ↔
b ∈ PFun.fix f a := by
intro F; refine ⟨fun h => ?_, fun h => ?_⟩
· rcases h with ⟨n, ⟨_x, h₁⟩, h₂⟩
have : ∀ m a', Sum.inr a' ∈ F a m → b ∈ PFun.fix f a' → b ∈ PFun.fix f a := by
intro m a' am ba
induction m generalizing a' with simp [F] at am
| zero => rwa [← am]
| succ m IH =>
rcases am with ⟨a₂, am₂, fa₂⟩
exact IH _ am₂ (PFun.mem_fix_iff.2 (Or.inr ⟨_, fa₂, ba⟩))
cases n <;> simp [F] at h₂
rcases h₂ with (h₂ | ⟨a', am', fa'⟩)
· obtain ⟨a', h⟩ := h₁ (Nat.lt_succ_self _)
injection mem_unique h h₂
· exact this _ _ am' (PFun.mem_fix_iff.2 (Or.inl fa'))
· suffices ∀ a', b ∈ PFun.fix f a' → ∀ k, Sum.inr a' ∈ F a k →
∃ n, Sum.inl b ∈ F a n ∧ ∀ m < n, k ≤ m → ∃ a₂, Sum.inr a₂ ∈ F a m by
rcases this _ h 0 (by simp [F]) with ⟨n, hn₁, hn₂⟩
exact ⟨_, ⟨⟨_, hn₁⟩, fun {m} mn => hn₂ m mn (Nat.zero_le _)⟩, hn₁⟩
intro a₁ h₁
apply @PFun.fixInduction _ _ _ _ _ _ h₁
intro a₂ h₂ IH k hk
rcases PFun.mem_fix_iff.1 h₂ with (h₂ | ⟨a₃, am₃, _⟩)
· refine ⟨k.succ, ?_, fun m mk km => ⟨a₂, ?_⟩⟩
· simpa [F] using Or.inr ⟨_, hk, h₂⟩
· rwa [le_antisymm (Nat.le_of_lt_succ mk) km]
· rcases IH _ am₃ k.succ (by simpa [F] using ⟨_, hk, am₃⟩) with ⟨n, hn₁, hn₂⟩
grind | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | fix_aux | null |
fix {f : α →. σ ⊕ α} (hf : Partrec f) : Partrec (PFun.fix f) := by
let F : α → ℕ →. σ ⊕ α := fun a n =>
n.rec (some (Sum.inr a)) fun _ IH => IH.bind fun s => Sum.casesOn s (fun _ => Part.some s) f
have hF : Partrec₂ F :=
Partrec.nat_rec snd (sumInr.comp fst).partrec
(sumCasesOn_right (snd.comp snd) (snd.comp <| snd.comp fst).to₂ (hf.comp snd).to₂).to₂
let p a n := @Part.map _ Bool (fun s => Sum.casesOn s (fun _ => true) fun _ => false) (F a n)
have hp : Partrec₂ p :=
hF.map ((sumCasesOn Computable.id (const true).to₂ (const false).to₂).comp snd).to₂
exact ((Partrec.rfind hp).bind (hF.bind (sumCasesOn_right snd snd.to₂ none.to₂).to₂).to₂).of_eq
fun a => ext fun b => by simpa [p] using fix_aux f _ _ | theorem | Computability | [
"Mathlib.Computability.Primrec",
"Mathlib.Data.Nat.PSub",
"Mathlib.Data.PFun"
] | Mathlib/Computability/Partrec.lean | fix | null |
rfind' {f} (hf : Nat.Partrec f) :
Nat.Partrec
(Nat.unpaired fun a m =>
(Nat.rfind fun n => (fun m => m = 0) <$> f (Nat.pair a (n + m))).map (· + m)) :=
Partrec₂.unpaired'.2 <| by
refine
Partrec.map
((@Partrec₂.unpaired' fun a b : ℕ =>
Nat.rfind fun n => (fun m => m = 0) <$> f (Nat.pair a (n + b))).1
?_)
(Primrec.nat_add.comp Primrec.snd <| Primrec.snd.comp Primrec.fst).to_comp.to₂
have : Nat.Partrec (fun a => Nat.rfind (fun n => (fun m => decide (m = 0)) <$>
Nat.unpaired (fun a b => f (Nat.pair (Nat.unpair a).1 (b + (Nat.unpair a).2)))
(Nat.pair a n))) :=
rfind
(Partrec₂.unpaired'.2
((Partrec.nat_iff.2 hf).comp
(Primrec₂.pair.comp (Primrec.fst.comp <| Primrec.unpair.comp Primrec.fst)
(Primrec.nat_add.comp Primrec.snd
(Primrec.snd.comp <| Primrec.unpair.comp Primrec.fst))).to_comp))
simpa | theorem | Computability | [
"Mathlib.Computability.Partrec",
"Mathlib.Data.Option.Basic"
] | Mathlib/Computability/PartrecCode.lean | rfind' | null |
Code : Type
| zero : Code
| succ : Code
| left : Code
| right : Code
| pair : Code → Code → Code
| comp : Code → Code → Code
| prec : Code → Code → Code
| rfind' : Code → Code
compile_inductive% Code | inductive | Computability | [
"Mathlib.Computability.Partrec",
"Mathlib.Data.Option.Basic"
] | Mathlib/Computability/PartrecCode.lean | Code | Code for partial recursive functions from ℕ to ℕ.
See `Nat.Partrec.Code.eval` for the interpretation of these constructors. |
instInhabited : Inhabited Code :=
⟨zero⟩ | instance | Computability | [
"Mathlib.Computability.Partrec",
"Mathlib.Data.Option.Basic"
] | Mathlib/Computability/PartrecCode.lean | instInhabited | null |
protected const : ℕ → Code
| 0 => zero
| n + 1 => comp succ (Code.const n) | def | Computability | [
"Mathlib.Computability.Partrec",
"Mathlib.Data.Option.Basic"
] | Mathlib/Computability/PartrecCode.lean | const | Returns a code for the constant function outputting a particular natural. |
const_inj : ∀ {n₁ n₂}, Nat.Partrec.Code.const n₁ = Nat.Partrec.Code.const n₂ → n₁ = n₂
| 0, 0, _ => by simp
| n₁ + 1, n₂ + 1, h => by
dsimp [Nat.Partrec.Code.const] at h
injection h with h₁ h₂
simp only [const_inj h₂] | theorem | Computability | [
"Mathlib.Computability.Partrec",
"Mathlib.Data.Option.Basic"
] | Mathlib/Computability/PartrecCode.lean | const_inj | null |
protected id : Code :=
pair left right | def | Computability | [
"Mathlib.Computability.Partrec",
"Mathlib.Data.Option.Basic"
] | Mathlib/Computability/PartrecCode.lean | id | A code for the identity function. |
curry (c : Code) (n : ℕ) : Code :=
comp c (pair (Code.const n) Code.id) | def | Computability | [
"Mathlib.Computability.Partrec",
"Mathlib.Data.Option.Basic"
] | Mathlib/Computability/PartrecCode.lean | curry | Given a code `c` taking a pair as input, returns a code using `n` as the first argument to `c`. |
encodeCode : Code → ℕ
| zero => 0
| succ => 1
| left => 2
| right => 3
| pair cf cg => 2 * (2 * Nat.pair (encodeCode cf) (encodeCode cg)) + 4
| comp cf cg => 2 * (2 * Nat.pair (encodeCode cf) (encodeCode cg) + 1) + 4
| prec cf cg => (2 * (2 * Nat.pair (encodeCode cf) (encodeCode cg)) + 1) + 4
| rfind' cf => (2 * (2 * encodeCode cf + 1) + 1) + 4 | def | Computability | [
"Mathlib.Computability.Partrec",
"Mathlib.Data.Option.Basic"
] | Mathlib/Computability/PartrecCode.lean | encodeCode | An encoding of a `Nat.Partrec.Code` as a ℕ. |
ofNatCode : ℕ → Code
| 0 => zero
| 1 => succ
| 2 => left
| 3 => right
| n + 4 =>
let m := n.div2.div2
have hm : m < n + 4 := by
simp only [m, div2_val]
exact
lt_of_le_of_lt (le_trans (Nat.div_le_self _ _) (Nat.div_le_self _ _))
(Nat.succ_le_succ (Nat.le_add_right _ _))
have _m1 : m.unpair.1 < n + 4 := lt_of_le_of_lt m.unpair_left_le hm
have _m2 : m.unpair.2 < n + 4 := lt_of_le_of_lt m.unpair_right_le hm
match n.bodd, n.div2.bodd with
| false, false => pair (ofNatCode m.unpair.1) (ofNatCode m.unpair.2)
| false, true => comp (ofNatCode m.unpair.1) (ofNatCode m.unpair.2)
| true, false => prec (ofNatCode m.unpair.1) (ofNatCode m.unpair.2)
| true, true => rfind' (ofNatCode m) | def | Computability | [
"Mathlib.Computability.Partrec",
"Mathlib.Data.Option.Basic"
] | Mathlib/Computability/PartrecCode.lean | ofNatCode | A decoder for `Nat.Partrec.Code.encodeCode`, taking any ℕ to the `Nat.Partrec.Code` it represents. |
private encode_ofNatCode : ∀ n, encodeCode (ofNatCode n) = n
| 0 => by simp [ofNatCode, encodeCode]
| 1 => by simp [ofNatCode, encodeCode]
| 2 => by simp [ofNatCode, encodeCode]
| 3 => by simp [ofNatCode, encodeCode]
| n + 4 => by
let m := n.div2.div2
have hm : m < n + 4 := by
simp only [m, div2_val]
exact
lt_of_le_of_lt (le_trans (Nat.div_le_self _ _) (Nat.div_le_self _ _))
(Nat.succ_le_succ (Nat.le_add_right _ _))
have _m1 : m.unpair.1 < n + 4 := lt_of_le_of_lt m.unpair_left_le hm
have _m2 : m.unpair.2 < n + 4 := lt_of_le_of_lt m.unpair_right_le hm
have IH := encode_ofNatCode m
have IH1 := encode_ofNatCode m.unpair.1
have IH2 := encode_ofNatCode m.unpair.2
conv_rhs => rw [← Nat.bit_bodd_div2 n, ← Nat.bit_bodd_div2 n.div2]
simp only [ofNatCode.eq_5]
cases n.bodd <;> cases n.div2.bodd <;>
simp [m, encodeCode, IH, IH1, IH2, Nat.bit_val] | theorem | Computability | [
"Mathlib.Computability.Partrec",
"Mathlib.Data.Option.Basic"
] | Mathlib/Computability/PartrecCode.lean | encode_ofNatCode | Proof that `Nat.Partrec.Code.ofNatCode` is the inverse of `Nat.Partrec.Code.encodeCode` |
instDenumerable : Denumerable Code :=
mk'
⟨encodeCode, ofNatCode, fun c => by
induction c <;> simp [encodeCode, ofNatCode, Nat.div2_val, *],
encode_ofNatCode⟩ | instance | Computability | [
"Mathlib.Computability.Partrec",
"Mathlib.Data.Option.Basic"
] | Mathlib/Computability/PartrecCode.lean | instDenumerable | null |
encodeCode_eq : encode = encodeCode :=
rfl | theorem | Computability | [
"Mathlib.Computability.Partrec",
"Mathlib.Data.Option.Basic"
] | Mathlib/Computability/PartrecCode.lean | encodeCode_eq | null |
ofNatCode_eq : ofNat Code = ofNatCode :=
rfl | theorem | Computability | [
"Mathlib.Computability.Partrec",
"Mathlib.Data.Option.Basic"
] | Mathlib/Computability/PartrecCode.lean | ofNatCode_eq | null |
encode_lt_pair (cf cg) :
encode cf < encode (pair cf cg) ∧ encode cg < encode (pair cf cg) := by
simp only [encodeCode_eq, encodeCode]
have := Nat.mul_le_mul_right (Nat.pair cf.encodeCode cg.encodeCode) (by decide : 1 ≤ 2 * 2)
rw [one_mul, mul_assoc] at this
have := lt_of_le_of_lt this (lt_add_of_pos_right _ (by decide : 0 < 4))
exact ⟨lt_of_le_of_lt (Nat.left_le_pair _ _) this, lt_of_le_of_lt (Nat.right_le_pair _ _) this⟩ | theorem | Computability | [
"Mathlib.Computability.Partrec",
"Mathlib.Data.Option.Basic"
] | Mathlib/Computability/PartrecCode.lean | encode_lt_pair | null |
encode_lt_comp (cf cg) :
encode cf < encode (comp cf cg) ∧ encode cg < encode (comp cf cg) := by
have : encode (pair cf cg) < encode (comp cf cg) := by simp [encodeCode_eq, encodeCode]
exact (encode_lt_pair cf cg).imp (fun h => lt_trans h this) fun h => lt_trans h this | theorem | Computability | [
"Mathlib.Computability.Partrec",
"Mathlib.Data.Option.Basic"
] | Mathlib/Computability/PartrecCode.lean | encode_lt_comp | null |
encode_lt_prec (cf cg) :
encode cf < encode (prec cf cg) ∧ encode cg < encode (prec cf cg) := by
have : encode (pair cf cg) < encode (prec cf cg) := by simp [encodeCode_eq, encodeCode]
exact (encode_lt_pair cf cg).imp (fun h => lt_trans h this) fun h => lt_trans h this | theorem | Computability | [
"Mathlib.Computability.Partrec",
"Mathlib.Data.Option.Basic"
] | Mathlib/Computability/PartrecCode.lean | encode_lt_prec | null |
encode_lt_rfind' (cf) : encode cf < encode (rfind' cf) := by
simp only [encodeCode_eq, encodeCode]
cutsat | theorem | Computability | [
"Mathlib.Computability.Partrec",
"Mathlib.Data.Option.Basic"
] | Mathlib/Computability/PartrecCode.lean | encode_lt_rfind' | null |
primrec₂_pair : Primrec₂ pair :=
Primrec₂.ofNat_iff.2 <|
Primrec₂.encode_iff.1 <|
nat_add.comp
(nat_double.comp <|
nat_double.comp <|
Primrec₂.natPair.comp (encode_iff.2 <| (Primrec.ofNat Code).comp fst)
(encode_iff.2 <| (Primrec.ofNat Code).comp snd))
(Primrec₂.const 4)
@[deprecated (since := "2025-05-12")] alias pair_prim := primrec₂_pair | theorem | Computability | [
"Mathlib.Computability.Partrec",
"Mathlib.Data.Option.Basic"
] | Mathlib/Computability/PartrecCode.lean | primrec₂_pair | null |
primrec₂_comp : Primrec₂ comp :=
Primrec₂.ofNat_iff.2 <|
Primrec₂.encode_iff.1 <|
nat_add.comp
(nat_double.comp <|
nat_double_succ.comp <|
Primrec₂.natPair.comp (encode_iff.2 <| (Primrec.ofNat Code).comp fst)
(encode_iff.2 <| (Primrec.ofNat Code).comp snd))
(Primrec₂.const 4)
@[deprecated (since := "2025-05-12")] alias comp_prim := primrec₂_comp | theorem | Computability | [
"Mathlib.Computability.Partrec",
"Mathlib.Data.Option.Basic"
] | Mathlib/Computability/PartrecCode.lean | primrec₂_comp | null |
primrec₂_prec : Primrec₂ prec :=
Primrec₂.ofNat_iff.2 <|
Primrec₂.encode_iff.1 <|
nat_add.comp
(nat_double_succ.comp <|
nat_double.comp <|
Primrec₂.natPair.comp (encode_iff.2 <| (Primrec.ofNat Code).comp fst)
(encode_iff.2 <| (Primrec.ofNat Code).comp snd))
(Primrec₂.const 4)
@[deprecated (since := "2025-05-12")] alias prec_prim := primrec₂_prec | theorem | Computability | [
"Mathlib.Computability.Partrec",
"Mathlib.Data.Option.Basic"
] | Mathlib/Computability/PartrecCode.lean | primrec₂_prec | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.