Documentation

Complexity.Computability.Complexity.Fagin.Layout

Existential second-order layout of framed structure encodings #

On the canonical power structure (Fin B, v.powerStructure a B) for a well-formed input a : EncodedStructure with (frame (encStructure a)).length < B, the Cook–Levin tableau needs the input tape word u = frame (encStructure a) and its length u.length as unary predicates on Fin B.

Because encStructure a = frame (encUnary a.1) ++ (a.2.flatMap frame) and u = frame (encStructure a), every stage of the binary encoding is an application of Turing.MultiTapeTM.frame at some starting offset base. We therefore axiomatize a single stride-2 framing step (FO.frameChunkSentence) in first-order logic using the linear order powerLt on Fin B:

Chaining v.count + 1 instances of frameChunkSentence reconstructs encStructure a and its length, and one final instance reconstructs frame (encStructure a) and its length.

Main definitions #

Main results #

References #

Generic stride-2 framing sentence #

noncomputable def Cslib.Logic.FO.frameChunkSentence {L' : FirstOrder.Language} (r : L'.Relations 2) (inDom inBit : L'.Formula (Fin 1)) (baseRel nextBaseRel : L'.Relations 1) (mapRel : L'.Relations 2) (outBitRel : L'.Relations 1) :

The first-order sentence axiomatizing a single stride-2 framing step on Fin B: starting at baseRel, the binary relation mapRel(j, p) maps j ≤ w.length to base + 2 * j, writes [true, w[j]] into outBitRel at base + 2 * j and base + 2 * j + 1, writes the terminator false at base + 2 * w.length, and sets nextBaseRel to {base + 2 * w.length + 1}.

Instances For
    theorem Cslib.Logic.FO.nextBase_and_getElem?_frame_of_realize_frameChunkSentence {L' : FirstOrder.Language} {B : ℕ} [L'.Structure (Fin B)] {r : L'.Relations 2} (hlt : ∀ (x : Fin 2 → Fin B), FirstOrder.Language.Structure.RelMap r x ↔ x 0 < x 1) {inDom inBit : L'.Formula (Fin 1)} {baseRel nextBaseRel : L'.Relations 1} {mapRel : L'.Relations 2} {outBitRel : L'.Relations 1} {w : List Bool} {base : ℕ} (hbound : base + (Turing.MultiTapeTM.frame w).length < B) (hdom : ∀ (j : Fin B), inDom.Realize ![j] ↔ ↑j < w.length) (hbit : ∀ (j : Fin B), ↑j < w.length → (inBit.Realize ![j] ↔ w[↑j]? = some true)) (hbase : ∀ (z : Fin B), FirstOrder.Language.Structure.RelMap baseRel ![z] ↔ ↑z = base) (hreal : Fin B ⊨ frameChunkSentence r inDom inBit baseRel nextBaseRel mapRel outBitRel) :
    (∀ (z : Fin B), FirstOrder.Language.Structure.RelMap nextBaseRel ![z] ↔ ↑z = base + (Turing.MultiTapeTM.frame w).length) ∧ ∀ (p : Fin B), base ≤ ↑p → ↑p < base + (Turing.MultiTapeTM.frame w).length → (FirstOrder.Language.Structure.RelMap outBitRel ![p] ↔ (Turing.MultiTapeTM.frame w)[↑p - base]? = some true)

    Soundness of frameChunkSentence: when baseRel holds solely of base and base + (frame w).length < B, any realization of frameChunkSentence forces nextBaseRel to hold solely of base + (frame w).length and outBitRel to agree with frame w on [base, base + (frame w).length).

    theorem Cslib.Logic.FO.realize_frameChunkSentence_of_canonical {L' : FirstOrder.Language} {B : ℕ} [L'.Structure (Fin B)] {r : L'.Relations 2} (hlt : ∀ (x : Fin 2 → Fin B), FirstOrder.Language.Structure.RelMap r x ↔ x 0 < x 1) {inDom inBit : L'.Formula (Fin 1)} {baseRel nextBaseRel : L'.Relations 1} {mapRel : L'.Relations 2} {outBitRel : L'.Relations 1} {w : List Bool} {base : ℕ} (hbound : base + (Turing.MultiTapeTM.frame w).length < B) (hdom : ∀ (j : Fin B), inDom.Realize ![j] ↔ ↑j < w.length) (hbit : ∀ (j : Fin B), ↑j < w.length → (inBit.Realize ![j] ↔ w[↑j]? = some true)) (hbase : ∀ (z : Fin B), FirstOrder.Language.Structure.RelMap baseRel ![z] ↔ ↑z = base) (hnext : ∀ (z : Fin B), FirstOrder.Language.Structure.RelMap nextBaseRel ![z] ↔ ↑z = base + (Turing.MultiTapeTM.frame w).length) (hmap : ∀ (j p : Fin B), FirstOrder.Language.Structure.RelMap mapRel ![j, p] ↔ ↑j ≤ w.length ∧ ↑p = base + 2 * ↑j) (hout : ∀ (p : Fin B), base ≤ ↑p → ↑p < base + (Turing.MultiTapeTM.frame w).length → (FirstOrder.Language.Structure.RelMap outBitRel ![p] ↔ (Turing.MultiTapeTM.frame w)[↑p - base]? = some true)) :
    Fin B ⊨ frameChunkSentence r inDom inBit baseRel nextBaseRel mapRel outBitRel

    Completeness of frameChunkSentence: the canonical stride-2 relation mapRel(j, p) ↔ j ≤ w.length ∧ p = base + 2 * j satisfies frameChunkSentence whenever baseRel is {base}, nextBaseRel is {base + (frame w).length}, and outBitRel agrees with frame w on [base, base + (frame w).length).

    Prefix decomposition of encStructure a #

    The prefix of encStructure a consisting of frame (encUnary a.1) followed by the framed truth tables of the first m relation symbols of v.

    Instances For

      The prefix through the first m tables ends where the table at position m starts (Cslib.Logic.tableStart).

      The input variable language and layout ESO sentence #

      @[reducible, inline]

      The language of the two unary relations exposed by layoutESOSentence to the Cook–Levin tableau:

      • false (uBitSym): bit p of u = frame (encStructure a), and
      • true (uLenSym): the singleton {u.length}.
      Instances For

        The unary relation symbol uBit(p) in inputVarLanguage.

        Instances For

          The unary relation symbol uLen(p) in inputVarLanguage.

          Instances For
            @[reducible, inline]

            The index type of internal relation variables quantified by v.layoutESOSentence:

            • .inl (.inl m) (m : Fin (v.count + 2)): unary base_m,
            • .inl (.inr ()): unary rawBit,
            • .inr (.inl m) (m : Fin (v.count + 1)): binary chunkMap_m,
            • .inr (.inr ()): binary outerMap.
            Instances For

              The arities of LayoutVar: 1 on the left summand and 2 on the right summand.

              Instances For
                @[reducible, inline]

                The combined language of v.layoutESOSentence's first-order matrix.

                Instances For

                  Unary relation table bit i inside v.layoutMatrixLanguage.

                  Instances For

                    Unary base_m (m : Fin (v.count + 2)) inside v.layoutMatrixLanguage.

                    Instances For

                      Binary chunkMap_m (m : Fin (v.count + 1)) inside v.layoutMatrixLanguage.

                      Instances For

                        The domain formula j < rawLen for the outer framing step (base_{v.count + 1} is rawLen).

                        Instances For

                          The first-order matrix of v.layoutESOSentence:

                          1. base_0 holds solely of 0,
                          2. chunk 0 frames encUnary a.1 (inDom = powerIsElem, inBit = ⊤) from base_0 to base_1 into rawBit,
                          3. for each i : Fin v.count, chunk i + 1 frames table i (inDom = powerInTable i, inBit = powerTableBit i) from base_{i + 1} to base_{i + 2} into rawBit, and
                          4. the outer chunk frames encStructure a (inDom = layoutInRaw, inBit = rawBit) from base_0 to uLen into uBit.
                          Instances For

                            The existential second-order sentence over v.powerLanguage.sum inputVarLanguage that forces uLenSym to hold solely of (frame (encStructure a)).length and uBitSym to agree with frame (encStructure a) below (frame (encStructure a)).length.

                            Instances For

                              Characterization of layoutESOSentence: on (Fin B, v.powerStructure a B) for a well-formed input a with (frame (encStructure a)).length < B, an interpretation I_in of inputVarLanguage satisfies v.layoutESOSentence iff I_in true (uLenSym) holds solely of (frame (encStructure a)).length and I_in false (uBitSym) agrees with frame (encStructure a) on all positions < (frame (encStructure a)).length.