math / data /lean /OAI /Computability /DegreeRigidity /Syntax /BoundedRecursive.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
2.18 kB
import OAI.Computability.DegreeRigidity.Effective.UniformOracle
namespace OAI
namespace TuringRigidity.BoundedRecursive
open UniformOracle
def allBelow (f : β„• β†’ β„•) (a : β„•) : β„• β†’ β„•
| 0 => 1
| n+1 => if allBelow f a n = 1 ∧ f (Nat.pair a n) = 1 then 1 else 0
theorem allBelow_spec (f : β„• β†’ β„•) (a n : β„•) :
allBelow f a n = 1 ↔ βˆ€ i < n, f (Nat.pair a i) = 1 := by
induction n with
| zero => simp [allBelow]
| succ n ih =>
simp only [allBelow, ite_eq_left_iff, Nat.zero_ne_one, imp_false, not_not, ih]
exact ⟨fun ⟨h, hn⟩ i hi => (Nat.lt_succ_iff_lt_or_eq.mp hi).elim (h i) (fun he => he β–Έ hn),
fun h => ⟨fun i hi => h i (Nat.lt_succ_of_lt hi), h n (Nat.lt_succ_self n)⟩⟩
theorem allBelow_binary (f : β„• β†’ β„•) (a n : β„•) : allBelow f a n = 0 ∨ allBelow f a n = 1 := by
cases n with
| zero => exact Or.inr rfl
| succ n => unfold allBelow; split <;> simp
theorem allBelow_recursive {O : Set (β„• β†’. β„•)} {f : β„• β†’ β„•}
(hf : Nat.RecursiveIn O (fun n => Part.some (f n))) :
Nat.RecursiveIn O (fun z => Part.some (allBelow f (Nat.unpair z).1 (Nat.unpair z).2)) := by
have harg := total_pair (O := O) (total_primrec (Primrec.fst.comp Primrec.unpair))
(total_primrec (Primrec.fst.comp (Primrec.unpair.comp (Primrec.snd.comp Primrec.unpair))))
have hval := total_comp hf harg
have hprev := total_primrec (O := O)
(Primrec.snd.comp (Primrec.unpair.comp (Primrec.snd.comp Primrec.unpair)))
have htest := total_primrec (O := O)
(Primrec.ite ((Primrec.eq.comp (Primrec.fst.comp Primrec.unpair) (Primrec.const 1)).and
(Primrec.eq.comp (Primrec.snd.comp Primrec.unpair) (Primrec.const 1)))
(Primrec.const 1) (Primrec.const 0))
have hstep := total_comp htest (total_pair hprev hval)
have hrec := Nat.RecursiveIn.prec (total_primrec (O := O) (Primrec.const 1)) hstep
apply hrec.of_eq
intro z
generalize hz : Nat.unpair z = v
obtain ⟨a, n⟩ := v
simp only [Nat.unpair_pair, Part.bind_eq_bind]
clear hz
induction n with
| zero => rfl
| succ n ih =>
simp only [ih, Part.bind_some, allBelow]
end TuringRigidity.BoundedRecursive
end OAI