Documentation

CslibFrontier.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) and at most 3 (n + s + 1) ^ 2 (certLength_le_three_mul_sq). 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 checker Cslib.Circuits.codeCheck from CslibFrontier.Computability.Circuit.Encoding.Check tells the codes of circuits apart (Cslib.Circuits.codeCheck_eq_true_iff), and this module registers its De Morgan polynomial-time certificate (Cslib.Circuits.Boolean.computableInPolyTime_codeCheck).

Main definitions #

Main results #

References #

Fields and rows #

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

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

A unary field of width width for a ≤ width has length width.

@[simp]

A unary field of width width for a contains a ones.

An operation in three bits.

@[simp]

The 3-bit encoding op.bits has length 3.

The operation read from any three bits.

Decoding the three bits of op.bits via Op.ofBits recovers op.

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

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

Certificates #

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

Certificate length is monotone in the number of inputs.

The certificate length is at most 3 (n + s + 1) ^ 2.

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.

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.

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.

Reading certificates in polynomial time #

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