Documentation

Complexitylib.Classes.P.FinsetDomain.Internal

Finite-domain lookup machine (internal) #

Construction and correctness of a deterministic Turing machine computing a function of the form fun s => if s ∈ S then g s else [], where S is a finite set of "inputs of interest" and g an arbitrary target function. Such a function differs from the constant empty-output function on only finitely many inputs, so it can be computed by a table lookup that runs in linear time.

The machine has no work tapes. It works in two phases:

Since the read phase takes |x| steps and the write phase is bounded by the longest possible output, the runtime is linear.

The public statement (ite_mem_finset_mem_FP) lives in Complexitylib.Classes.P.FinsetDomain.

Output finset #

The read phase tracks membership in S.prefixes and the write phase tracks membership in (outputsFinset g S).suffixes; both finsets come from the generic Finset.prefixes/Finset.suffixes API.

The possible output strings: g s for s ∈ S, together with [].

Equations
Instances For

    The lookup machine #

    States of the lookup machine.

    Instances For

      LookupState as a sum of two finite subtypes and two extra states. This equivalence supplies the DecidableEq and Fintype instances, which cannot be derived because the read/write constructors have dependent fields.

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

        The read-phase state after consuming prefix p: the viable prefix p if it is still a prefix of some element of S, otherwise the dead state.

        Equations
        Instances For

          The write-phase state carrying output suffix c.

          Equations
          Instances For

            The lookup machine for g and S. See the module docstring for the construction. It has no work tapes.

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

              Correctness #

              theorem Complexity.TM.FinsetDomain.lookupTM_computesInTime (g : List BoolList Bool) (S : Finset (List Bool)) :
              (lookupTM g S).ComputesInTime (fun (s : List Bool) => if s S then g s else []) fun (m : ) => (m + S.sup fun (s : List Bool) => (g s).length) + 3

              The lookup machine computes fun s => if s ∈ S then g s else [] within a linear time bound.

              theorem Complexity.ite_mem_finset_mem_FP_internal (g : List BoolList Bool) (S : Finset (List Bool)) :
              (fun (s : List Bool) => if s S then g s else []) FP

              Internal proof that a function supported on a finite set belongs to FP: the lookup machine's linear time bound is packaged as a degree-one polynomial.