Documentation

Complexitylib.Classes.PCP.Internal.AlgGraph

A constraint graph as a string #

An algorithm that runs Dinur's amplification has to hold a constraint graph in its hand. Over a fixed finite alphabet a graph is a small amount of data: how many vertices, and for each edge its two endpoints and its constraint. The endpoints are numbers below the vertex count, and the constraint — a predicate on two symbols — is itself one of finitely many, so it too is a number.

That is the encoding used here: the vertex count in unary, followed by a list of records, each three unary numbers. Numbering the constraints rather than tabulating them keeps every record a triple of numbers, so the whole toolkit of UnaryList applies; and because the number of constraints is a constant, reading one back is a lookup on a bounded key.

Main definitions #

Main results #

Numbering the constraints #

noncomputable def Complexity.relOfCode (α : Type) [Fintype α] [DecidableEq α] (r : ) :
ααBool

The constraint a code stands for; the always-false constraint for a code that is out of range.

Equations
Instances For
    noncomputable def Complexity.codeOfRel {α : Type} [Fintype α] [DecidableEq α] (f : ααBool) :

    The code of a constraint.

    Equations
    Instances For
      theorem Complexity.codeOfRel_lt {α : Type} [Fintype α] [DecidableEq α] (f : ααBool) :
      codeOfRel f < Fintype.card (ααBool)
      @[simp]
      theorem Complexity.relOfCode_codeOfRel {α : Type} [Fintype α] [DecidableEq α] (f : ααBool) :

      The encoding #

      noncomputable def Complexity.edgeRecs {α : Type} [Fintype α] [DecidableEq α] (G : ConstraintGraph α) :

      One record for each edge: its two endpoints and the code of its constraint.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For

        Reading it back #

        How many vertices an encoded graph has.

        Equations
        Instances For
          noncomputable def Complexity.gEdges (z : List Bool) :

          How many edges.

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

            The first endpoint of an edge.

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

              The second endpoint.

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

                The code of the constraint.

                Equations
                Instances For
                  @[simp]
                  theorem Complexity.gTail_encGraph {α : Type} [Fintype α] [DecidableEq α] (G : ConstraintGraph α) (e : ) (he : e < G.numEdges) :
                  gTail (encGraph G) e = (G.tail e, he)
                  @[simp]
                  theorem Complexity.gHead_encGraph {α : Type} [Fintype α] [DecidableEq α] (G : ConstraintGraph α) (e : ) (he : e < G.numEdges) :
                  gHead (encGraph G) e = (G.head e, he)
                  theorem Complexity.gCode_encGraph {α : Type} [Fintype α] [DecidableEq α] (G : ConstraintGraph α) (e : ) (he : e < G.numEdges) :
                  theorem Complexity.gRel_encGraph {α : Type} [Fintype α] [DecidableEq α] (G : ConstraintGraph α) (e : ) (he : e < G.numEdges) :
                  relOfCode α (gCode (encGraph G) e) = G.rel e, he

                  The constraint of an edge survives the round trip.

                  theorem Complexity.length_encGraph_le {α : Type} [Fintype α] [DecidableEq α] (G : ConstraintGraph α) :
                  (encGraph G).length 2 * G.numVerts + 4 + G.numEdges * (8 * G.numVerts + 4 * Fintype.card (ααBool) + 10)

                  How long a graph's encoding is, in terms of its two counts.

                  Writing one out #

                  noncomputable def Complexity.buildGraph (nv cnt E : List BoolList Bool) (z : List Bool) :

                  A graph assembled from a vertex count, an edge count and a rule for each edge record.

                  Equations
                  Instances For
                    theorem Complexity.buildGraph_mem_FP {nv cnt E : List BoolList Bool} (hnv : nv FP) (hcnt : cnt FP) (hE : E FP) :
                    buildGraph nv cnt E FP
                    theorem Complexity.buildGraph_eq {α : Type} [Fintype α] [DecidableEq α] {nv cnt E : List BoolList Bool} {z : List Bool} {G : ConstraintGraph α} (hnv : nv z = List.replicate G.numVerts true) (hcnt : cnt z = List.replicate G.numEdges true) (hE : ∀ (e : ) (he : e < G.numEdges), E (pair z (List.replicate e true)) = encTriple (List.replicate (↑(G.tail e, he)) true) (List.replicate (↑(G.head e, he)) true) (List.replicate (codeOfRel (G.rel e, he)) true)) :
                    buildGraph nv cnt E z = encGraph G

                    The rule writes the graph.

                    Reading one, in polynomial time #

                    theorem Complexity.gVertsFn_mem_FP {g : List BoolList Bool} (hg : g FP) :
                    (fun (z : List Bool) => marks (pairFst (g z))) FP
                    theorem Complexity.gEdgesFn_mem_FP {g : List BoolList Bool} (hg : g FP) :
                    (fun (z : List Bool) => posCount (pairSnd (g z))) FP
                    theorem Complexity.gTailFn_mem_FP {f g : List BoolList Bool} (hf : f FP) (hg : g FP) :
                    (fun (z : List Bool) => recFst (pairSnd (g z)) (f z).length) FP
                    theorem Complexity.gHeadFn_mem_FP {f g : List BoolList Bool} (hf : f FP) (hg : g FP) :
                    (fun (z : List Bool) => recSnd (pairSnd (g z)) (f z).length) FP
                    theorem Complexity.gCodeFn_mem_FP {f g : List BoolList Bool} (hf : f FP) (hg : g FP) :
                    (fun (z : List Bool) => recThd (pairSnd (g z)) (f z).length) FP