File size: 2,177 Bytes
9dbc64e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
49
50
51
52
53
54
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