File size: 2,050 Bytes
4a56cd6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | import Mathlib
namespace OAI
namespace SimpleFInftyOvergroups.EffectiveNames.Finite
variable {A B P : Type*} {n : β}
def traverse (f : A β Part B) (x : Fin n β A) : Part (Fin n β B) :=
(List.Vector.mOfFn (fun i => f (x i))).map List.Vector.get
theorem vector_full (f : Fin n β Part B) (g : Fin n β B) (h : β i, g i β f i) :
List.Vector.ofFn g β List.Vector.mOfFn f := by
induction n with
| zero => exact Part.mem_some _
| succ n ih =>
simp only [List.Vector.mOfFn]
refine Part.mem_bind_iff.mpr β¨g 0, h 0, ?_β©
exact Part.mem_bind_iff.mpr β¨_,ih (fun i => f i.succ) (fun i => g i.succ)
(fun i => h i.succ), Part.mem_some _β©
theorem traverse_full (f : A β Part B) (g : A β B) (x : Fin n β A)
(h : β i, g (x i) β f (x i)) : (fun i => g (x i)) β traverse f x := by
change _ β (List.Vector.mOfFn (fun i => f (x i))).map List.Vector.get
convert Part.mem_map List.Vector.get (vector_full (fun i => f (x i)) (fun i => g (x i)) h) using 1
funext i
exact (List.Vector.get_ofFn (fun i => g (x i)) i).symm
variable [Primcodable A] [Primcodable B] [Primcodable P]
theorem partrec_traverse {f : P β A β Part B} (hf : Partrecβ f) :
Partrecβ (fun p : P => traverse (n:=n) (f p)) := by
have hh : β i : Fin n, Partrec (fun p : P Γ (Fin n β A) => f p.1 (p.2 i)) :=
fun i => hf.comp Computable.fst (Primrec.fin_app.to_comp.comp Computable.snd (Computable.const i))
exact (Partrec.vector_mOfFn hh).map (Primrec.vector_get'.to_comp.comp Computable.snd).toβ
theorem computable_function {f : P β Fin n β B} (hf : β i, Computable (fun p => f p i)) :
Computable f := by
exact (Primrec.vector_get'.to_comp.comp (Computable.vector_ofFn hf)).of_eq
(fun p => by funext i; simp)
theorem primrec_function {f : P β Fin n β B} (hf : β i, Primrec (fun p => f p i)) :
Primrec f := by
exact (Primrec.vector_get'.comp (Primrec.vector_ofFn hf)).of_eq
(fun p => by funext i; simp)
end SimpleFInftyOvergroups.EffectiveNames.Finite
end OAI
|