Documentation

MathematicalLogic.Computability.Partrec

inductive Partrec :
Type
Instances For
    @[reducible, inline]
    abbrev Partrec.comp₁ {n : } (f : Partrec 1) (g : Partrec n) :
    Equations
    Instances For
      @[reducible, inline]
      abbrev Partrec.comp₂ {n : } (f : Partrec 2) (g₁ g₂ : Partrec n) :
      Equations
      Instances For
        @[reducible, inline]
        abbrev Partrec.comp₃ {n : } (f : Partrec 3) (g₁ g₂ g₃ : Partrec n) :
        Equations
        Instances For
          def Partrec.eval {n : } :
          Equations
          Instances For
            @[simp]
            theorem Partrec.zero_eval {n n✝ : } {v : Vec n✝} :
            @[simp]
            @[simp]
            theorem Partrec.proj_eval {n✝ : } {i : Fin n✝} {v : Vec n✝} :
            (proj i).eval v = Part.some (v i)
            @[simp]
            theorem Partrec.comp_eval {a✝ : } {f : Partrec a✝} {a✝¹ : } {g : Fin a✝Partrec a✝¹} {v : Vec a✝¹} :
            (f.comp g).eval v = (Part.bindVec fun (i : Fin a✝) => (g i).eval v) >>= f.eval
            theorem Partrec.prec_eval {a✝ : } {f : Partrec a✝} {g : Partrec (a✝ + 2)} {v : Vec (a✝ + 1)} :
            (f.prec g).eval v = (f.eval v.tail).natrec (fun (n ih : ) => do let m(some ih) g.eval (n ∷ᵥ m ∷ᵥ v.tail)) v.head
            theorem Partrec.prec_eval_zero {a✝ : } {f : Partrec a✝} {g : Partrec (a✝ + 2)} {v : Vec a✝} :
            (f.prec g).eval (0 ∷ᵥ v) = f.eval v
            theorem Partrec.prec_eval_succ {a✝ : } {f : Partrec a✝} {g : Partrec (a✝ + 2)} {v : Vec a✝} {n : } :
            (f.prec g).eval (n.succ ∷ᵥ v) = do let m(f.prec g).eval (n ∷ᵥ v) g.eval (n ∷ᵥ m ∷ᵥ v)
            @[simp]
            theorem Partrec.mu_eval {a✝ : } {f : Partrec (a✝ + 1)} {v : Vec a✝} :
            f.mu.eval v = Part.find fun (n : ) => f.eval (n ∷ᵥ v)
            def Partrec.Total {n : } (f : Partrec n) :
            Equations
            Instances For
              @[simp]
              theorem Partrec.ofPrim_eval {a✝ : } {f : Primrec a✝} {v : Vec a✝} :
              (ofPrim f).eval v = Part.some (f.eval v)
              theorem Partrec.ofPrim_total {a✝ : } {f : Primrec a✝} :
              @[reducible, inline]
              abbrev Primrec.toPart {n : } :
              Equations
              Instances For
                def Partrec.loop {n : } :
                Equations
                Instances For
                  @[simp]
                  theorem Partrec.loop_eval {n✝ : } {v : Vec n✝} :
                  def Partrec.cov {n : } (f : Partrec (n + 2)) :
                  Partrec (n + 1)
                  Equations
                  Instances For
                    theorem Partrec.cov_dom {n : } {v : Vec n} {f : Partrec (n + 2)} (hf : ∀ (a b : ), (f.eval (a ∷ᵥ b ∷ᵥ v)).Dom) (m : ) :
                    (f.cov.eval (m ∷ᵥ v)).Dom
                    theorem Partrec.cov_eval {n : } {v : Vec n} {m : } {f : Partrec (n + 2)} (hf : ∀ (a b : ), (f.eval (a ∷ᵥ b ∷ᵥ v)).Dom) :
                    f.cov.eval (m ∷ᵥ v) = Part.some (Vec.paired fun (i : Fin m) => (f.eval (i ∷ᵥ (f.cov.eval (i ∷ᵥ v)).get ∷ᵥ v)).get )
                    def Partrec.covrec {n : } (f : Partrec (n + 2)) :
                    Partrec (n + 1)

                    Course-of-values recursion. For simplicity we assume the totality of f on the first two arguments.

                    Equations
                    Instances For
                      theorem Partrec.covrec_dom {n : } {v : Vec n} {f : Partrec (n + 2)} (hf : ∀ (a b : ), (f.eval (a ∷ᵥ b ∷ᵥ v)).Dom) (m : ) :
                      (f.covrec.eval (m ∷ᵥ v)).Dom
                      theorem Partrec.covrec_eval {n : } {v : Vec n} {m : } {f : Partrec (n + 2)} (hf : ∀ (a b : ), (f.eval (a ∷ᵥ b ∷ᵥ v)).Dom) :
                      f.covrec.eval (m ∷ᵥ v) = f.eval (m ∷ᵥ (Vec.paired fun (i : Fin m) => (f.covrec.eval (i ∷ᵥ v)).get ) ∷ᵥ v)
                      def Partrec.bd {n : } :
                      Partrec nPrimrec (n + 1)

                      bd f (k ∷ᵥ v) replaces all unbounded mu in f v with a Primrec.bdMu bounded by k; it returns 0 for Part.none, and x + 1 for Part.some x.

                      bd is similar to Nat.Partrec.Code.evaln in mathlib, although bd itself is not primitive recursive (since bd f is equivalent to f + 1 when f is primitive recursive).

                      Equations
                      Instances For
                        theorem Partrec.bd_mono {a✝ : } {f : Partrec a✝} {k : } {v : Vec a✝} {m k' : } :
                        f.bd.eval (k ∷ᵥ v) = m + 1k' kf.bd.eval (k' ∷ᵥ v) = m + 1
                        theorem Partrec.bd_sound {a✝ : } {f : Partrec a✝} {k : } {v : Vec a✝} {m : } :
                        f.bd.eval (k ∷ᵥ v) = m + 1m f.eval v
                        theorem Partrec.bd_zero_of_not_dom {a✝ : } {f : Partrec a✝} {v : Vec a✝} :
                        ¬(f.eval v).Dom∀ (k : ), f.bd.eval (k ∷ᵥ v) = 0
                        theorem Partrec.bd_pos_of_mem {a✝ : } {f : Partrec a✝} {m : } {v : Vec a✝} :
                        m f.eval v∃ (k : ), f.bd.eval (k ∷ᵥ v) = m + 1
                        theorem Partrec.bd_of_mem {a✝ : } {f : Partrec a✝} {m : } {v : Vec a✝} :
                        m f.eval v∃ (k : ), ∀ (k' : ), f.bd.eval (k' ∷ᵥ v) = if k' < k then 0 else m + 1
                        theorem Partrec.bd_ofPrim {n k : } {v : Vec n} {f : Primrec n} :
                        (ofPrim f).bd.eval (k ∷ᵥ v) = f.eval v + 1
                        theorem Partrec.dom_iff_exists_bd_pos {a✝ : } {f : Partrec a✝} {v : Vec a✝} :
                        (f.eval v).Dom ∃ (k : ), 0 < f.bd.eval (k ∷ᵥ v)
                        def Partrec.site {n : } (f g h : Partrec n) :

                        Short-circuit if-then-else. site f g h is equivalent to g when f is positive, and equivalent to h when f is zero.

                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For
                          theorem Partrec.mem_site_eval_iff {a✝ : } {f g h : Partrec a✝} {v : Vec a✝} {m : } :
                          m (f.site g h).eval v 0 < f.eval v m g.eval v 0 f.eval v m h.eval v
                          theorem Partrec.site_dom {a✝ : } {f g h : Partrec a✝} {v : Vec a✝} :
                          ((f.site g h).eval v).Dom 0 < f.eval v (g.eval v).Dom 0 f.eval v (h.eval v).Dom
                          def Partrec.sand {n : } (f g : Partrec n) :

                          Short-circuit and.

                          Equations
                          Instances For
                            theorem Partrec.sand_dom {a✝ : } {f g : Partrec a✝} {v : Vec a✝} :
                            ((f.sand g).eval v).Dom 0 < f.eval v (g.eval v).Dom 0 f.eval v
                            theorem Partrec.sand_eval_pos_iff {a✝ : } {f g : Partrec a✝} {v : Vec a✝} :
                            0 < (f.sand g).eval v 0 < f.eval v 0 < g.eval v
                            theorem Partrec.sand_eval_zero_iff {a✝ : } {f g : Partrec a✝} {v : Vec a✝} :
                            0 (f.sand g).eval v 0 < f.eval v 0 g.eval v 0 f.eval v
                            def Partrec.par {n : } (f g : Partrec n) :

                            Parallel execution of f and g.

                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For
                              theorem Partrec.par_dom {a✝ : } {f g : Partrec a✝} {v : Vec a✝} :
                              ((f.par g).eval v).Dom (f.eval v).Dom (g.eval v).Dom
                              theorem Partrec.mem_par_eval_left {a✝ : } {f : Partrec a✝} {m : } {g : Partrec a✝} {v : Vec a✝} :
                              m f.eval v¬(g.eval v).Domm (f.par g).eval v
                              theorem Partrec.mem_par_eval_right {a✝ : } {f g : Partrec a✝} {m : } {v : Vec a✝} :
                              ¬(f.eval v).Domm g.eval vm (f.par g).eval v
                              theorem Partrec.mem_par_eval {a✝ : } {f g : Partrec a✝} {v : Vec a✝} {m : } :
                              m (f.par g).eval vm f.eval v m g.eval v
                              def Partrec.repr {n : } :
                              Equations
                              Instances For
                                instance Partrec.instRepr {n : } :
                                Equations
                                class Recursive {α : Type u} [Encodable α] (s : Set α) :

                                A set is recursive if it can be decided by a recursive function f.

                                Note: for flexibility, we only require f's totality on the image of Encodable.encode, instead of the whole .

                                Instances
                                  theorem Recursive.not_mem_iff {α : Type u} [Encodable α] {s : Set α} [Recursive s] (x : α) :
                                  def Recursive.compl {α : Type u} [Encodable α] {s : Set α} [Recursive s] :
                                  Equations
                                  Instances For
                                    instance Recursive.dec {α : Type u} [Encodable α] (s : Set α) [Recursive s] (x : α) :
                                    Equations
                                    def IsRecursive {α : Type u} [Encodable α] (s : Set α) :

                                    Prop version of Recursive.

                                    Equations
                                    Instances For
                                      theorem IsRecursive.def {α : Type u} [Encodable α] {s : Set α} :
                                      IsRecursive s ∃ (f : Partrec 1), (∀ (x : α), (f.eval [Encodable.encode x]ᵥ).Dom) ∀ (x : α), x s 0 < f.eval [Encodable.encode x]ᵥ
                                      class Enumerable {α : Type u} [Encodable α] (s : Set α) :

                                      A set is enumerable (also called recursively enumerable, or RE) if it can be decided through a "μ-operator search" over a recursive function. The equivalent definitions are IsEnumerable.iff_range_partrec and IsEnumerable.iff_semi_decidable.

                                      Instances
                                        theorem Enumerable.not_mem_iff {α : Type u} [Encodable α] {s : Set α} [Enumerable s] (x : α) :
                                        xs ∀ (n : ), 0 (enum s).eval [n, Encodable.encode x]ᵥ
                                        instance Recursive.enumerable {α : Type u} [Encodable α] {s : Set α} [Recursive s] :
                                        Equations
                                        def IsEnumerable {α : Type u} [Encodable α] (s : Set α) :

                                        Prop version of Enumerable.

                                        Equations
                                        Instances For
                                          theorem IsRecursive.enumerable {α : Type u} [Encodable α] {s : Set α} :
                                          theorem IsEnumerable.def {α : Type u} [Encodable α] {s : Set α} :
                                          IsEnumerable s ∃ (f : Partrec 2), (∀ (n : ) (x : α), (f.eval [n, Encodable.encode x]ᵥ).Dom) ∀ (x : α), x s ∃ (n : ), 0 < f.eval [n, Encodable.encode x]ᵥ
                                          theorem IsEnumerable.iff_range_partrec {α : Type u} [Encodable α] {s : Set α} :
                                          IsEnumerable s ∃ (f : Partrec 1), ∀ (x : α), x s ∃ (n : ), Encodable.encode x f.eval [n]ᵥ

                                          A set is enumerable if and only if it is the range of some partial recursive function f.

                                          theorem IsEnumerable.iff_semi_decidable {α : Type u} [Encodable α] {s : Set α} :
                                          IsEnumerable s ∃ (f : Partrec 1), ∀ (x : α), x s (f.eval [Encodable.encode x]ᵥ).Dom

                                          A set is enumerable if and only if it can be semi-decided.

                                          A set is recursive if and only if it and its complement are both enumerable.