Documentation

Complexitylib.Circuits.Encoding.Family

Encodings of whole circuit families #

This module adds the length-zero wrapper around the positive-arity circuit codec. A leading tag distinguishes the explicit empty-input answer from an ordinary encoded circuit.

Encode the member of an AND/OR circuit family at input length n.

The zero-length member is the tag false followed by its explicit answer. Positive lengths use the tag true followed by the ordinary circuit code.

Equations
Instances For
    @[simp]

    The length-zero member encodes as the false tag followed by the explicit answer bit.

    @[simp]

    A positive-length member encodes as the true tag followed by its circuit's code.

    Evaluate a tagged family code on a variable-length input.

    The zero tag is accepted only for the empty input and must carry exactly one answer bit. The positive tag is accepted only for a nonempty input and delegates to the exact-arity circuit evaluator.

    Equations
    Instances For

      Decode one self-delimiting machine input into a tagged family code and its argument, then evaluate the code. Malformed outer pairs and malformed inner circuit codes both return none.

      Equations
      Instances For
        @[simp]

        Evaluating a canonical pair delegates directly to the tagged family-code evaluator.

        On the empty input, successful evaluation is exactly a canonical zero tag carrying one answer bit.

        theorem Complexity.CircuitCode.evalFamilyCode_isSome_iff_of_ne_nil (code input : List Bool) (hne : input []) :
        (evalFamilyCode code input).isSome = true ∃ (circuit : RawCircuit), code = true :: circuit.encode RawCircuit.WellFormed input.length circuit

        On a nonempty input, successful evaluation is exactly a positive tag carrying a canonical, topologically well-formed circuit code.

        @[simp]

        Tagged family encoding handles the explicit empty-input bit and agrees with the typed circuit at every positive input length.

        @[simp]

        Machine-facing list form of evalFamilyCode_encodeAt: selecting the member at the supplied input's length agrees with CircuitFamily.evalList.

        Pairing a family member's canonical code with its input evaluates to the family's Boolean answer.

        The length-zero tagged code has exactly two bits: the tag and the answer.

        @[simp]

        A positive-length tagged code is one bit (the tag) longer than the underlying circuit code.

        theorem Complexity.CircuitCode.encodeAt_succ_length_le (F : CircuitFamily Basis.andOr2) (n : ) :
        (F.encodeAt (n + 1)).length 2 + F.size (n + 1) * (2 * (n + 1 + F.size (n + 1)) + 6)

        The positive-length tagged family code inherits the concrete polynomial bound for its member circuit.

        Every tagged family code satisfies the concrete length bound, including the explicit two-bit code at input length zero.

        theorem Complexity.CircuitCode.encodeAt_length_bigO (F : CircuitFamily Basis.andOr2) {d : } (hsize : BigO F.size fun (x : ) => x ^ d) :
        BigO (fun (n : ) => (F.encodeAt n).length) fun (x : ) => x ^ (2 * (d + 1))

        Polynomial-size families have polynomial-length tagged member encodings.