Documentation

Complexitylib.Classes.Containments.Internal.BlockSearchCorrect

What the worklist search finds #

⚠️ Unreviewed by Bolton

The invariant of the search: the visited string is a list of distinct records, each the code of a configuration reachable from the initial one; the initial code is among them; and every record the counter has passed has both of its successors recorded.

Once the counter has passed every record — which it has after as many steps as there are configurations, since the records are distinct — the recorded codes are closed under the graph's steps, so every reachable configuration's code is there.

Main definitions #

Main results #

Records #

The width of one record: a whole code.

Equations
Instances For
    theorem Complexity.blockAt_records (k W : ) (bs : List (List Bool)) (hbs : bbs, b.length = recordWidth k W) (i : ) (hi : i < bs.length) :

    The records of a concatenation are its blocks.

    theorem Complexity.length_flatten_records (k W : ) (bs : List (List Bool)) (hbs : bbs, b.length = recordWidth k W) :
    theorem Complexity.memFlag_records (k W : ) (bs : List (List Bool)) (hbs : bbs, b.length = recordWidth k W) (u : List Bool) :

    The scan decides membership in the record list.

    Appending a record #

    theorem Complexity.addBlock_nodup (k W : ) (bs : List (List Bool)) (hbs : bbs, b.length = recordWidth k W) (b : List Bool) (hnd : bs.Nodup) (hm : memFlag (wideRuler (codeBlocks k) (Cobham.blockRuler W)) b bs.flatten = [false]) :
    (bs ++ [b]).Nodup

    The appended record was not there before.

    The invariant #

    noncomputable def Complexity.codesOf {k : } {Q : Type} [Fintype Q] [DecidableEq Q] (W : ) (cs : List (Cfg k Q)) :

    The records of a list of configurations.

    Equations
    Instances For
      theorem Complexity.codesOf_recordWidth {k : } {Q : Type} [Fintype Q] [DecidableEq Q] (W : ) (cs : List (Cfg k Q)) (b : List Bool) :
      b codesOf W csb.length = recordWidth k W
      @[simp]
      theorem Complexity.codesOf_length {k : } {Q : Type} [Fintype Q] [DecidableEq Q] (W : ) (cs : List (Cfg k Q)) :
      theorem Complexity.codesOf_getElem {k : } {Q : Type} [Fintype Q] [DecidableEq Q] (W : ) (cs : List (Cfg k Q)) (i : ) (hi : i < cs.length) :
      @[simp]
      theorem Complexity.codesOf_append {k : } {Q : Type} [Fintype Q] [DecidableEq Q] (W : ) (cs : List (Cfg k Q)) (c : Cfg k Q) :
      def Complexity.SearchOk {k : } (tm : NTM k) (x : List Bool) (W : ) (r V : List Bool) :

      The search state is sound: the visited string is the concatenation of the codes of finitely many reachable configurations, no two of them coded alike; the initial code is there; and every record the counter has passed has both successors recorded.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        theorem Complexity.searchOk_init {k : } (tm : NTM k) (x : List Bool) (W : ) :
        SearchOk tm x W [] (Cobham.cfgCode W (tm.initCfg x))

        The initial state is sound.

        One step preserves the invariant #

        theorem Complexity.exists_succ_code {k : } (tm : NTM k) {L : Language} {S : } (hdec : tm.DecidesInSpace L S) (x : List Bool) (W : ) (hq : Fintype.card tm.Q Cobham.blockWidth W) (hW : x.length + S x.length + 1 W) {c : Cfg k tm.Q} (hc : tm.ReachesCfg (tm.initCfg x) c) (β : Bool) :
        ∃ (c' : Cfg k tm.Q), tm.ReachesCfg (tm.initCfg x) c' nstepFn tm β (Cobham.blockRuler W) (Cobham.cfgCode W c) = Cobham.cfgCode W c'

        The two encoded successors of a reachable configuration are codes of reachable configurations.

        theorem Complexity.searchOk_add {k : } (tm : NTM k) (x : List Bool) (W : ) (cs : List (Cfg k tm.Q)) (hnd : (codesOf W cs).Nodup) (hreach : dcs, tm.ReachesCfg (tm.initCfg x) d) {c : Cfg k tm.Q} (hc : tm.ReachesCfg (tm.initCfg x) c) :
        ∃ (cs' : List (Cfg k tm.Q)), addBlock (wideRuler (codeBlocks k) (Cobham.blockRuler W)) (Cobham.cfgCode W c) (codesOf W cs).flatten = (codesOf W cs').flatten (codesOf W cs').Nodup (∀ dcs', tm.ReachesCfg (tm.initCfg x) d) (cs' = cs cs' = cs ++ [c]) Cobham.cfgCode W c codesOf W cs'

        Adding one successor keeps every part of the invariant.

        theorem Complexity.append_cases_prefix {α : Type} {cs cs' : List α} {c : α} (h : cs' = cs cs' = cs ++ [c]) :
        (∀ ycs, y cs') cs.length cs'.length ∀ (i : ) (hi : i < cs.length) (hi' : i < cs'.length), cs'[i] = cs[i]

        A list only grows at the end.

        theorem Complexity.searchStepPair_ok {k : } (tm : NTM k) {L : Language} {S : } (hdec : tm.DecidesInSpace L S) (x : List Bool) (W : ) (hq : Fintype.card tm.Q Cobham.blockWidth W) (hW : x.length + S x.length + 1 W) (r V : List Bool) (h : SearchOk tm x W r V) :

        One step of the search preserves the invariant.

        A saturated search has found everything #

        theorem Complexity.searchOk_complete {k : } (tm : NTM k) {L : Language} {S : } (hdec : tm.DecidesInSpace L S) (x : List Bool) (W : ) (hq : Fintype.card tm.Q Cobham.blockWidth W) (hW : x.length + S x.length + 1 W) (r V : List Bool) (h : SearchOk tm x W r V) (hsat : V.length r.length * recordWidth k W) {c : Cfg k tm.Q} (hc : tm.ReachesCfg (tm.initCfg x) c) :

        Once the counter has passed every record, the search is complete.

        How long the visited string can get #

        theorem Complexity.searchOk_length_le {k : } (tm : NTM k) {L : Language} {S : } (hdec : tm.DecidesInSpace L S) (x : List Bool) (W : ) (r V : List Bool) (h : SearchOk tm x W r V) :

        The visited string is bounded by the configuration count. The records are distinct and each is the code of a reachable configuration, and distinct configurations of the graph have distinct codes in the finite type of Complexitylib.Classes.Containments.Internal.ConfigCount.