Documentation

Complexitylib.Classes.PCP.Internal.UnaryList

Reading a table of unary numbers #

An algorithm that materializes a graph writes a list of records and reads them back. PosScan reads an entry of an encoded list, and DataEncode writes the entries; what is missing is getting a number back out, in the unary form the loops of the toolkit consume.

Storing the number in unary makes that a length computation: the encoding of a unary string of w marks is 4 * w + 2 bits long — two brackets, and four bits a mark — so dividing the length by four recovers the marks. No parsing of the encoding is needed, and no binary arithmetic.

The same scan reads the two halves of an encoded pair, since a pair is encoded as the two-element list of its halves.

Main definitions #

Main results #

Numbers #

The size of an encoded unary string: two brackets and four bits a mark.

noncomputable def Complexity.unaryOf (e : List Bool) :

The unary number an encoded unary string stands for.

Equations
Instances For
    theorem Complexity.unaryOf_mem_FP {a : List BoolList Bool} (ha : a FP) :
    (fun (z : List Bool) => unaryOf (a z)) FP

    Pairs #

    noncomputable def Complexity.fstEnc (e : List Bool) :

    The first half of an encoded pair.

    Equations
    Instances For
      noncomputable def Complexity.sndEnc (e : List Bool) :

      The second half of an encoded pair.

      Equations
      Instances For
        theorem Complexity.fstEnc_mem_FP {a : List BoolList Bool} (ha : a FP) :
        (fun (z : List Bool) => fstEnc (a z)) FP
        theorem Complexity.sndEnc_mem_FP {a : List BoolList Bool} (ha : a FP) :
        (fun (z : List Bool) => sndEnc (a z)) FP

        Unary arithmetic with constants #

        noncomputable def Complexity.marks (s : List Bool) :

        Any string, as that many marks.

        Equations
        Instances For
          theorem Complexity.marks_mem_FP {a : List BoolList Bool} (ha : a FP) :
          (fun (z : List Bool) => marks (a z)) FP
          noncomputable def Complexity.divC (c : ) (s : List Bool) :

          Division by a constant.

          Equations
          Instances For
            theorem Complexity.divC_eq {c : } (hc : 0 < c) (s : List Bool) :
            theorem Complexity.divC_mem_FP {a : List BoolList Bool} (ha : a FP) (c : ) :
            (fun (z : List Bool) => divC c (a z)) FP
            noncomputable def Complexity.modC (c : ) (s : List Bool) :

            Remainder by a constant.

            Equations
            Instances For
              theorem Complexity.modC_eq {c : } (hc : 0 < c) (s : List Bool) :
              theorem Complexity.modC_mem_FP {a : List BoolList Bool} (ha : a FP) (c : ) :
              (fun (z : List Bool) => modC c (a z)) FP

              The product of two lengths.

              Equations
              Instances For
                @[simp]
                theorem Complexity.mulLen_mem_FP {f g : List BoolList Bool} (hf : f FP) (hg : g FP) :
                (fun (z : List Bool) => mulLen (f z) (g z)) FP

                Multiplication by a constant, as a length.

                Equations
                Instances For
                  @[simp]
                  theorem Complexity.length_mulC (c : ) (s : List Bool) :
                  (mulC c s).length = s.length * c
                  theorem Complexity.mulC_mem_FP {a : List BoolList Bool} (ha : a FP) (c : ) :
                  (fun (z : List Bool) => mulC c (a z)) FP

                  Writing records #

                  The encoding of a unary string.

                  Equations
                  Instances For
                    theorem Complexity.encUnary_mem_FP {a : List BoolList Bool} (ha : a FP) :
                    (fun (z : List Bool) => encUnary (a z)) FP

                    The encoding of a pair of unary strings.

                    Equations
                    Instances For
                      theorem Complexity.encPair_mem_FP {a b : List BoolList Bool} (ha : a FP) (hb : b FP) :
                      (fun (z : List Bool) => encPair (a z) (b z)) FP

                      The encoding of a list is two brackets and its entries' encodings.

                      Tables of pairs of numbers #

                      noncomputable def Complexity.tableFst (T : List Bool) (j : ) :

                      The first number of the j-th record of a table, in unary.

                      Equations
                      Instances For
                        noncomputable def Complexity.tableSnd (T : List Bool) (j : ) :

                        The second number of the j-th record of a table, in unary.

                        Equations
                        Instances For
                          theorem Complexity.tableFst_mem_FP {a b : List BoolList Bool} (ha : a FP) (hb : b FP) :
                          (fun (z : List Bool) => tableFst (b z) (a z).length) FP
                          theorem Complexity.tableSnd_mem_FP {a b : List BoolList Bool} (ha : a FP) (hb : b FP) :
                          (fun (z : List Bool) => tableSnd (b z) (a z).length) FP

                          Records of three numbers #

                          The encoding of three unary strings.

                          Equations
                          Instances For
                            theorem Complexity.encTriple_mem_FP {a b c : List BoolList Bool} (ha : a FP) (hb : b FP) (hc : c FP) :
                            (fun (z : List Bool) => encTriple (a z) (b z) (c z)) FP
                            noncomputable def Complexity.recFst (T : List Bool) (j : ) :

                            The first number of the j-th record of a table of triples.

                            Equations
                            Instances For
                              noncomputable def Complexity.recSnd (T : List Bool) (j : ) :

                              The second.

                              Equations
                              Instances For
                                noncomputable def Complexity.recThd (T : List Bool) (j : ) :

                                The third.

                                Equations
                                Instances For
                                  theorem Complexity.recFst_mem_FP {f g : List BoolList Bool} (hf : f FP) (hg : g FP) :
                                  (fun (z : List Bool) => recFst (g z) (f z).length) FP
                                  theorem Complexity.recSnd_mem_FP {f g : List BoolList Bool} (hf : f FP) (hg : g FP) :
                                  (fun (z : List Bool) => recSnd (g z) (f z).length) FP
                                  theorem Complexity.recThd_mem_FP {f g : List BoolList Bool} (hf : f FP) (hg : g FP) :
                                  (fun (z : List Bool) => recThd (g z) (f z).length) FP

                                  Digit sums #

                                  noncomputable def Complexity.digitSum (radix : ) (digit : List BoolList Bool) :

                                  A number from its digits: ∑ j < n, digit j · radix ^ j, written in marks. The digits are read from the input, so this is how an algorithm assembles a mixed-radix number out of constantly many pieces.

                                  Equations
                                  Instances For
                                    theorem Complexity.digitSum_mem_FP {radix : } {digit : List BoolList Bool} (hd : ∀ (i : ), digit i FP) (n : ) :
                                    digitSum radix digit n FP
                                    @[simp]
                                    theorem Complexity.length_digitSum (radix : ) (digit : List BoolList Bool) (w : List Bool) (n : ) :
                                    (digitSum radix digit n w).length = jFinset.range n, (digit j w).length * radix ^ j
                                    theorem Complexity.length_digitSum_le {radix : } (hr : 0 < radix) {digit : List BoolList Bool} {d : } (hd : ∀ (j : ) (w : List Bool), (digit j w).length d) (n : ) (w : List Bool) :
                                    (digitSum radix digit n w).length n * (d * radix ^ n)