Documentation

CslibFrontier.Computability.Complexity.Classes.SharpP.Combinators

Combining verifiers #

The counting classes #P, PP, RP and BPP are all defined through polynomial-time functions V : α × List Bool → Bool that read an instance and a string of bits, and through the number Cslib.Complexity.acceptCount V a n of strings of length n that V accepts together with a. This file provides verifiers built from other verifiers, each with its polynomial-time rule (registered with fun_prop) and the number of strings it accepts.

Running two verifiers on disjoint parts of the random string is the usual way to combine independent random choices Arora and Barak, Chapters 7 and 17.

Main definitions #

Main results #

References #

The string of falses #

The verifier accepting, with every instance, exactly the strings of falses.

Instances For
    @[simp]

    allFalseVerifier accepts one string of each length.

    Conjunction on disjoint parts of the string #

    def Cslib.Complexity.andVerifier {α : Type} (k : α → ℕ) (V₁ V₂ : α × List Bool → Bool) (x : α × List Bool) :

    Run V₁ on the first k a bits and V₂ on the remaining bits, and accept when both accept.

    Instances For
      theorem Cslib.Complexity.acceptCount_andVerifier {α : Type} (k : α → ℕ) (V₁ V₂ : α × List Bool → Bool) (a : α) (n : ℕ) :
      acceptCount (andVerifier k V₁ V₂) a (k a + n) = acceptCount V₁ a (k a) * acceptCount V₂ a n

      Independent runs multiply: on strings of length k a + n, andVerifier k V₁ V₂ accepts the product of the numbers of strings that V₁ and V₂ accept.

      theorem Cslib.Complexity.acceptCount_andVerifier_true {α : Type} (k : α → ℕ) (V : α × List Bool → Bool) (a : α) (n : ℕ) :
      acceptCount (andVerifier k V fun (x : α × List Bool) => true) a (k a + n) = acceptCount V a (k a) * 2 ^ n

      Ignoring the bits after the first k a multiplies the number of accepted strings by a power of two.

      Padding #

      def Cslib.Complexity.padVerifier {α : Type} (k : α → ℕ) (V : α × List Bool → Bool) :
      α × List Bool → Bool

      Run V on the first k a bits and require the remaining bits to be false.

      Instances For
        theorem Cslib.Complexity.acceptCount_padVerifier_of_le {α : Type} (k : α → ℕ) (V : α × List Bool → Bool) {a : α} {n : ℕ} (h : k a ≤ n) :
        acceptCount (padVerifier k V) a n = acceptCount V a (k a)

        Padding: on strings of any length n ≥ k a, padVerifier k V accepts as many strings as V accepts of length k a.

        Disjunction on disjoint parts of the string #

        def Cslib.Complexity.orVerifier {α : Type} (k : α → ℕ) (V₁ V₂ : α × List Bool → Bool) (x : α × List Bool) :

        Run V₁ on the first k a bits and V₂ on the remaining bits, and accept when either accepts.

        Instances For
          theorem Cslib.Complexity.acceptCount_orVerifier {α : Type} (k : α → ℕ) (V₁ V₂ : α × List Bool → Bool) (a : α) (n : ℕ) :
          acceptCount (orVerifier k V₁ V₂) a (k a + n) + acceptCount (fun (x : α × List Bool) => !V₁ x) a (k a) * acceptCount (fun (x : α × List Bool) => !V₂ x) a n = 2 ^ (k a + n)

          Independent rejections multiply: on strings of length k a + n, orVerifier k V₁ V₂ rejects the product of the numbers of strings that V₁ and V₂ reject.

          Choosing by the first bit #

          def Cslib.Complexity.selectVerifier {α : Type} (V₀ V₁ : α × List Bool → Bool) (x : α × List Bool) :

          Run V₀ on the remaining bits when the first bit is false, and V₁ when it is true.

          Instances For
            theorem Cslib.Complexity.acceptCount_selectVerifier {α : Type} (V₀ V₁ : α × List Bool → Bool) (a : α) (n : ℕ) :
            acceptCount (selectVerifier V₀ V₁) a (n + 1) = acceptCount V₀ a n + acceptCount V₁ a n

            Choices add: on strings of length n + 1, selectVerifier V₀ V₁ accepts the sum of the numbers of strings of length n that V₀ and V₁ accept.

            Sums of two counts #

            def Cslib.Complexity.sumVerifier {α : Type} (k₁ k₂ : α → ℕ) (V₁ V₂ : α × List Bool → Bool) :
            α × List Bool → Bool

            Let the first bit choose between V₁ on k₁ a bits and V₂ on k₂ a bits, padding the chosen verifier's strings to k₁ a + k₂ a bits with falses.

            Instances For
              theorem Cslib.Complexity.acceptCount_sumVerifier {α : Type} (k₁ k₂ : α → ℕ) (V₁ V₂ : α × List Bool → Bool) (a : α) :
              acceptCount (sumVerifier k₁ k₂ V₁ V₂) a (k₁ a + k₂ a + 1) = acceptCount V₁ a (k₁ a) + acceptCount V₂ a (k₂ a)

              Counts add: on strings of length k₁ a + k₂ a + 1, sumVerifier k₁ k₂ V₁ V₂ accepts the sum of the numbers of strings that V₁ accepts of length k₁ a and V₂ of length k₂ a.