Documentation

Complexitylib.Circuits.Basis.Defs

Bases of Boolean operations #

This file defines bit strings, families of Boolean functions, and the bases of Boolean operations over which circuits are built.

Each basis is also a CSLib signature, so CSLib's circuits (Cslib.Circuits.Circuit, straight-line programs over a signature) can be built over it without changing its cost model. An operation symbol of B.signature is a whole gate kind of B: an operation, a fan-in that the operation allows, and a negation flag for each input. Its interpretation B.interpretation negates the flagged inputs and applies the operation, so negations stay free, and a basis with unbounded fan-in becomes a signature with infinitely many operation symbols. CSLib's size over B.signature is thus this library's convention (one unit per gate, whatever its fan-in or negation pattern), not the size over CSLib's De Morgan basis, which charges negation gates; Complexitylib.Interop.Cslib.Circuit relates the two.

Main definitions #

@[reducible, inline]

A BitString of length n.

Equations
Instances For
    @[reducible, inline]

    A family of Boolean functions indexed by input length N.

    Each member maps N-bit strings to a single output bit.

    Equations
    Instances For

      Arity constraint for operations in a basis.

      • unbounded : Arity

        Any number of inputs is allowed.

      • exactly (k : ℕ) : Arity

        Exactly k inputs are required.

      • upto (k : ℕ) : Arity

        At most k inputs are allowed.

      Instances For
        Equations
        Instances For

          Whether n satisfies an arity constraint.

          Equations
          Instances For
            @[instance_reducible]
            Equations
            • One or more equations did not get rendered due to their size.
            structure Complexity.Basis :

            A basis of Boolean operations.

            Each operation has an arity constraint and an evaluation function that computes the output bit from any valid number of input bits.

            • Op : Type

              The type of operations (e.g., AND, OR, NOT).

            • arity : self.Op → Arity

              The arity constraint for each operation.

            • eval (op : self.Op) (n : ℕ) : (self.arity op).satisfiedBy n → BitString n → Bool

              Evaluate an operation on n input bits, given that n satisfies the arity.

            Instances For

              A gate kind of the basis B: an operation, a fan-in that the operation allows, and a negation flag for each input.

              • op : B.Op

                The basis operation.

              • fanIn : ℕ

                The number of inputs.

              • arityOk : (B.arity self.op).satisfiedBy self.fanIn

                The operation allows this fan-in.

              • negated : Fin self.fanIn → Bool

                Which inputs are negated before the operation is applied.

              Instances For

                The CSLib signature of a basis: one operation symbol per gate kind, with the gate kind's fan-in as its arity.

                Equations
                Instances For

                  The interpretation of a basis's signature: a gate kind negates the flagged inputs and applies its operation, exactly as Gate.eval does (Basis.interpretation_kind in Complexitylib.Circuits.StraightLine).

                  Equations
                  Instances For