Documentation

Complexity.Computability.Circuit.Boolean.Encoding.Certificate

Circuits as certificates #

A verifier that guesses a circuit reads it from a certificate of a fixed length. This file fixes such a format for De Morgan circuits with n inputs, one output and at most s gates, of length certLength n s, monotone in the number of inputs (certLength_mono_left). Wire numbers are below w = n + s and are written in unary in fields of w bits (unaryField); an operation takes three bits (Op.bits). A certificate lists the number of gates in a field of s bits, the output wire, and then s rows of 3 + 2 w bits, the first of which hold the gates (certificate).

Every bit string reads as a list of gates and an output wire (readCertificate): a field is read as its number of ones, any three bits as an operation, and the arguments of a gate are cut to the arity of its operation. Reading is polynomial-time (Cslib.Circuits.Boolean.computableInPolyTime_readCertificate), and the certificate of a circuit, followed by any bits, reads as its code (readCertificate_certificate_append). A string that is not the certificate of a circuit may read as gates that read wires not yet computed; the polynomial-time test codeCheck tells the codes of circuits apart (codeCheck_eq_true_iff).

Main definitions #

Main results #

References #

Fields and rows #

The number a in a field of width bits: a ones, then zeros.

Instances For
    @[simp]
    theorem Cslib.Circuits.Boolean.length_unaryField (width a : ℕ) (h : a ≤ width) :
    (unaryField width a).length = width

    An operation in three bits.

    Instances For

      The operation read from any three bits.

      Instances For

        The row of a gate whose wire numbers are below width: its operation, then its first two arguments in fields of width bits.

        Instances For

          The gate read from a row of 3 + 2 * width bits, with as many arguments as its operation takes.

          Instances For
            theorem Cslib.Circuits.Boolean.length_gateRow {width : ℕ} {g : Op × List ℕ} (h : ∀ i ∈ g.2, i ≤ width) :
            (gateRow width g).length = 3 + 2 * width
            theorem Cslib.Circuits.Boolean.readRow_gateRow {width : ℕ} {g : Op × List ℕ} (harity : g.2.length = signature.Arity g.1) (h : ∀ i ∈ g.2, i ≤ width) :
            readRow width (gateRow width g) = g

            A row reads as its gate, when the gate has the arity of its operation.

            Certificates #

            The length of the certificates of circuits with n inputs and at most s gates.

            Instances For

              Certificate length is monotone in the number of inputs.

              def Cslib.Circuits.Boolean.certificate (n s : ℕ) (gates : List (Op × List ℕ)) (output : ℕ) :

              The certificate of a circuit with n inputs and at most s gates, given by its gate list and its output wire: the number of gates and the output wire in fields of s and n + s bits, the rows of the gates, and rows of zeros up to s rows.

              Instances For

                The gates and the output wire read from a certificate for circuits with n inputs and at most s gates. Every bit string reads as some gates and some wire.

                Instances For

                  A certificate reads as at most s gates.

                  theorem Cslib.Circuits.Boolean.length_certificate {n s : ℕ} {gates : List (Op × List ℕ)} {output : ℕ} (hs : gates.length ≤ s) (houtput : output ≤ n + s) (hgates : ∀ g ∈ gates, ∀ i ∈ g.2, i ≤ n + s) :
                  (certificate n s gates output).length = certLength n s

                  The certificate of a circuit has length certLength n s.

                  theorem Cslib.Circuits.Boolean.readCertificate_certificate_append {n s : ℕ} {gates : List (Op × List ℕ)} {output : ℕ} (hcode : Program.IsCodeFrom signature n 0 gates) (hs : gates.length ≤ s) (houtput : output ≤ n + s) (extra : List Bool) :
                  readCertificate n s (certificate n s gates output ++ extra) = (gates, output)

                  A certificate reads as the code of its circuit, whatever bits follow it.

                  The certificate of a circuit with at most s gates reads as its code.

                  The certificate of a circuit with at most s gates has length certLength n s.

                  Checking codes #

                  Whether a list of gates is the code of a program on n inputs (Program.IsCodeFrom), as a Boolean test: every entry has the arity of its operation and reads only inputs and earlier gates.

                  Instances For

                    Reading certificates in polynomial time #

                    Checking that a list of gates is a code is polynomial-time, with the number of inputs in unary.