Documentation

MIPRE.Foundations.Cost.Reader

Programs as readers of a shared input #

A program built by composition out of comp, pair, fst and snd is written point-free, and a point-free term for a formula of forty conjuncts is unreadable. This file gives the applicative reading instead: a PolyTimeFun ι α is a reader of the shared input ι, and ap₁, ap₂, ap₃ and listOf apply a program to readers. In that style a program transcribes its mathematical definition line for line, and its toFun is definitionally the function it transcribes, so the congr that names it closes by rfl.

Also here, because they are the list operations the describer's programs need and they are generic: take, tail, headD and nthD (planning/succinct-cook-levin.md, S3).

Applying a program to readers #

noncomputable def MIPRE.Cost.PolyTimeFun.ap₁ {ι : Type u_1} {α : Type u_2} {β : Type u_3} [SizedEncoding ι] [SizedEncoding α] [SizedEncoding β] (F : PolyTimeFun α β) (f : PolyTimeFun ι α) :

Apply a one-argument program to a reader.

Equations
Instances For
    @[simp]
    theorem MIPRE.Cost.PolyTimeFun.ap₁_apply {ι : Type u_1} {α : Type u_2} {β : Type u_3} [SizedEncoding ι] [SizedEncoding α] [SizedEncoding β] (F : PolyTimeFun α β) (f : PolyTimeFun ι α) (i : ι) :
    (F.ap₁ f).toFun i = F.toFun (f.toFun i)
    noncomputable def MIPRE.Cost.PolyTimeFun.ap₂ {ι : Type u_1} {α : Type u_2} {β : Type u_3} {γ : Type u_4} [SizedEncoding ι] [SizedEncoding α] [SizedEncoding β] [SizedEncoding γ] (F : PolyTimeFun (α × β) γ) (f : PolyTimeFun ι α) (g : PolyTimeFun ι β) :

    Apply a two-argument program to two readers.

    Equations
    Instances For
      @[simp]
      theorem MIPRE.Cost.PolyTimeFun.ap₂_apply {ι : Type u_1} {α : Type u_2} {β : Type u_3} {γ : Type u_4} [SizedEncoding ι] [SizedEncoding α] [SizedEncoding β] [SizedEncoding γ] (F : PolyTimeFun (α × β) γ) (f : PolyTimeFun ι α) (g : PolyTimeFun ι β) (i : ι) :
      (F.ap₂ f g).toFun i = F.toFun (f.toFun i, g.toFun i)
      noncomputable def MIPRE.Cost.PolyTimeFun.ap₃ {ι : Type u_1} {α : Type u_2} {β : Type u_3} {γ : Type u_4} {δ : Type u_5} [SizedEncoding ι] [SizedEncoding α] [SizedEncoding β] [SizedEncoding γ] [SizedEncoding δ] (F : PolyTimeFun (α × β × γ) δ) (f : PolyTimeFun ι α) (g : PolyTimeFun ι β) (h : PolyTimeFun ι γ) :

      Apply a three-argument program to three readers.

      Equations
      Instances For
        @[simp]
        theorem MIPRE.Cost.PolyTimeFun.ap₃_apply {ι : Type u_1} {α : Type u_2} {β : Type u_3} {γ : Type u_4} {δ : Type u_5} [SizedEncoding ι] [SizedEncoding α] [SizedEncoding β] [SizedEncoding γ] [SizedEncoding δ] (F : PolyTimeFun (α × β × γ) δ) (f : PolyTimeFun ι α) (g : PolyTimeFun ι β) (h : PolyTimeFun ι γ) (i : ι) :
        (F.ap₃ f g h).toFun i = F.toFun (f.toFun i, g.toFun i, h.toFun i)
        noncomputable def MIPRE.Cost.PolyTimeFun.ap₂' {ι : Type u_1} {α : Type u_2} {β : Type u_3} {γ : Type u_4} [SizedEncoding ι] [SizedEncoding α] [SizedEncoding β] [SizedEncoding γ] (F : PolyTimeFun (α × β) γ) (f : PolyTimeFun ι α) :
        PolyTimeFun (ι × β) γ

        A two-argument program with its left argument curried away: the reader f of the shared input supplies it.

        Equations
        Instances For
          @[simp]
          theorem MIPRE.Cost.PolyTimeFun.ap₂'_apply {ι : Type u_1} {α : Type u_2} {β : Type u_3} {γ : Type u_4} [SizedEncoding ι] [SizedEncoding α] [SizedEncoding β] [SizedEncoding γ] (F : PolyTimeFun (α × β) γ) (f : PolyTimeFun ι α) (p : ι × β) :
          (F.ap₂' f).toFun p = F.toFun (f.toFun p.1, p.2)
          noncomputable def MIPRE.Cost.PolyTimeFun.listOf {ι : Type u_1} {α : Type u_2} [SizedEncoding ι] [SizedEncoding α] :
          List (PolyTimeFun ι α) → PolyTimeFun ι (List α)

          A list of readers as a reader of the list of their values.

          Equations
          Instances For
            @[simp]
            theorem MIPRE.Cost.PolyTimeFun.listOf_apply {ι : Type u_1} {α : Type u_2} [SizedEncoding ι] [SizedEncoding α] (fs : List (PolyTimeFun ι α)) (i : ι) :
            (listOf fs).toFun i = List.map (fun (f : PolyTimeFun ι α) => f.toFun i) fs

            Prefixes, tails and heads #

            noncomputable def MIPRE.Cost.PolyTimeFun.take {α : Type u_2} [SizedEncoding α] :

            Taking a prefix, the length in unary.

            Equations
            Instances For
              noncomputable def MIPRE.Cost.PolyTimeFun.tail {α : Type u_2} [SizedEncoding α] :

              The tail of a list.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                @[simp]
                noncomputable def MIPRE.Cost.PolyTimeFun.headD {α : Type u_2} [SizedEncoding α] (d : α) :

                The head of a list, or a default.

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  @[simp]
                  theorem MIPRE.Cost.PolyTimeFun.headD_apply {α : Type u_2} [SizedEncoding α] (d : α) (l : List α) :
                  (headD d).toFun l = l.headD d

                  Dropping a prefix, the length in unary: iterated tail.

                  noncomputable def MIPRE.Cost.PolyTimeFun.drop {α : Type u_2} [SizedEncoding α] :

                  Dropping a prefix, the length in unary.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For
                    noncomputable def MIPRE.Cost.PolyTimeFun.nthD {α : Type u_2} [SizedEncoding α] (d : α) :
                    ℕ → PolyTimeFun (List α) α

                    The k-th entry of a list, or a default.

                    Equations
                    Instances For
                      @[simp]
                      theorem MIPRE.Cost.PolyTimeFun.nthD_apply {α : Type u_2} [SizedEncoding α] (d : α) (k : ℕ) (l : List α) :
                      (nthD d k).toFun l = l.getD k d