Documentation

DescriptiveComplexity.Problems.ReachabilityDet.Complement

UNREACHd, and L = coL #

Deterministic logarithmic space is closed under complement (DescriptiveComplexity.LOGSPACE_eq_coLOGSPACE), and UNREACHd – non-reachability along forced arcs – is LOGSPACE-complete (DescriptiveComplexity.UNREACHd_LOGSPACE_complete).

Unlike NL = coNL this needs no inductive counting, and unlike the clausal fragments FO(DTC) has no built-in asymmetry between a problem and its complement: everything reduces to one membership statement, DescriptiveComplexity.unreachd_dtcDefinable. Given it, the complement of any FO(DTC) definable problem is FO(DTC) definable, because a reduction complements along with the problem (DescriptiveComplexity.OrderedFOReduction.compl) and REACHd is LOGSPACE-hard.

Complementing a deterministic walk #

REACHdᶜ says that no marked source has a marked target ahead of it. Three things make that a deterministic walk:

A node is therefore a mode – scanning or done – with a triple (s, x, c): the source candidate, the current position, the budget. The walk gets stuck exactly when it finds a marked target ahead of a marked source, so it reaches its accepting node exactly when there is nothing to find.

The forced-arc successor map #

theorem DescriptiveComplexity.detEdge_unique {A : Type} [FirstOrder.Language.stGraph.Structure A] {x y z : A} (hy : DetEdge x y) (hz : DetEdge x z) :
y = z

The forced arcs are functional: that is the whole point of DescriptiveComplexity.DetEdge.

Dependency graph

A vertex is stuck when no arc out of it is forced: either it has no outgoing arc at all, or it has several.

Equations
Instances For
    Dependency graph

    The successor map of the deterministic walk: the endpoint of the forced arc out of x, and x itself where the walk is stuck – the walk of the forced arcs read as an iterated function, DescriptiveComplexity.stepNext. Making it total is what lets reachability be read as iteration.

    Equations
    Instances For
      Dependency graph
      Dependency graph
      Dependency graph
      Dependency graph

      Reachability along forced arcs is iteration of the successor map.

      Dependency graph

      The step budget: a vertex reachable along forced arcs is reachable in fewer steps than the universe has elements – the machine-free DescriptiveComplexity.exists_iterate_lt_card, read for the forced arcs.

      Dependency graph

      The scanning walk #

      A node is a mode – false while scanning, true once done – together with a triple (s, x, c): the source candidate being tested, the current position of the walk, and the budget, itself a vertex, counted by its rank in the order.

      Dependency graph
      Dependency graph
      Dependency graph

      The arc from u to v is forced, as a formula: it is an arc, and it is the only one out of u.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        Dependency graph
        Dependency graph
        Dependency graph
        Dependency graph
        Dependency graph
        @[simp]
        theorem DescriptiveComplexity.UnreachD.realize_edgeF {A : Type} [FirstOrder.Language.stGraph.Structure A] [LinearOrder A] {γ : Type} {v : γA} (u w : γ) :
        (edgeF u w).Realize v SGEdge (v u) (v w)
        Dependency graph
        @[simp]
        theorem DescriptiveComplexity.UnreachD.realize_eqF {A : Type} [FirstOrder.Language.stGraph.Structure A] [LinearOrder A] {γ : Type} {v : γA} (u w : γ) :
        (eqF u w).Realize v v u = v w
        Dependency graph
        @[simp]
        theorem DescriptiveComplexity.UnreachD.realize_detEdgeF {A : Type} [FirstOrder.Language.stGraph.Structure A] [LinearOrder A] {γ : Type} {v : γA} (u w : γ) :
        (detEdgeF u w).Realize v DetEdge (v u) (v w)
        Dependency graph
        Dependency graph

        The specification #

        @[reducible, inline]

        The current source candidate.

        Equations
        Instances For
          Dependency graph
          @[reducible, inline]

          The current position of the walk.

          Equations
          Instances For
            Dependency graph
            @[reducible, inline]

            The current budget.

            Equations
            Instances For
              Dependency graph
              @[reducible, inline]

              The next source candidate.

              Equations
              Instances For
                Dependency graph
                @[reducible, inline]

                The next position.

                Equations
                Instances For
                  Dependency graph
                  @[reducible, inline]

                  The next budget.

                  Equations
                  Instances For
                    Dependency graph

                    The transition of the scanning mode to itself: either follow the forced arc and spend one unit of budget, or – when the walk is stuck or the budget is exhausted – move on to the next source candidate. Both are guarded by the absence of a marked target ahead of a marked source, which is where the walk stops for good.

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

                      The transition to the accepting mode: the last candidate has been scanned through.

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

                        The starting nodes: the least candidate, the walk at that candidate, the full budget.

                        Equations
                        Instances For
                          Dependency graph
                          @[reducible, inline]

                          The specification whose deterministic walk scans for a forced path from a marked source to a marked target, accepting when it finds none.

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

                            Semantics of the walk #

                            a is a least element of the order.

                            Equations
                            Instances For
                              Dependency graph

                              a is a greatest element of the order.

                              Equations
                              Instances For
                                Dependency graph

                                z covers w: the budget goes from w to z in one step.

                                Equations
                                Instances For
                                  Dependency graph

                                  One step of the scanning walk, in Lean: follow the forced arc while there is budget, otherwise move to the next candidate, or finish.

                                  Equations
                                  • One or more equations did not get rendered due to their size.
                                  Instances For
                                    Dependency graph
                                    theorem DescriptiveComplexity.UnreachD.realize_stepFF {A : Type} [FirstOrder.Language.stGraph.Structure A] [LinearOrder A] (x y : Fin 3A) :
                                    stepFF.Realize (Sum.elim x y) ¬(SGSource (x 0) SGTarget (x 1)) (y 0 = x 0 DetEdge (x 1) (y 1) IsSuccA (x 2) (y 2) (Stuck (x 1) IsMaxA (x 2)) IsSuccA (x 0) (y 0) y 1 = y 0 IsMinA (y 2))
                                    Dependency graph
                                    Dependency graph

                                    The walk of the specification is the scanning walk.

                                    Dependency graph
                                    Dependency graph

                                    The accepting nodes of the walk: those of the finished mode.

                                    Dependency graph

                                    Order arithmetic for the budget #

                                    theorem DescriptiveComplexity.UnreachD.isMinA_unique {A : Type} [LinearOrder A] {a b : A} (ha : IsMinA a) (hb : IsMinA b) :
                                    a = b
                                    Dependency graph
                                    theorem DescriptiveComplexity.UnreachD.isSuccA_unique {A : Type} [LinearOrder A] {c b b' : A} (h : IsSuccA c b) (h' : IsSuccA c b') :
                                    b = b'
                                    Dependency graph
                                    Dependency graph
                                    theorem DescriptiveComplexity.UnreachD.lt_or_eq_of_lt_isSuccA {A : Type} [LinearOrder A] {w z a : A} (h : IsSuccA w z) (ha : a < z) :
                                    a < w a = w
                                    Dependency graph
                                    Dependency graph

                                    The rank of an element is smaller than the size of the universe: the budget allows exactly as many steps as there are elements, less one.

                                    Dependency graph
                                    Dependency graph
                                    Dependency graph
                                    Dependency graph

                                    Determinism of the scanning walk #

                                    Dependency graph

                                    Correctness of the scan #

                                    A marked source with a marked target ahead of it: what the scan looks for, and what its acceptance denies.

                                    Equations
                                    Instances For
                                      Dependency graph
                                      Dependency graph
                                      Dependency graph

                                      The invariant carried along the scan: every candidate already passed is harmless, and if the current one is not, its target is still ahead of the walk and within the remaining budget.

                                      Equations
                                      • One or more equations did not get rendered due to their size.
                                      Instances For
                                        Dependency graph
                                        theorem DescriptiveComplexity.UnreachD.not_bad_of_end {A : Type} [FirstOrder.Language.stGraph.Structure A] [LinearOrder A] [Finite A] [Nonempty A] {a : Bool × (Fin 3A)} (hguard : ¬(SGSource (a.2 0) SGTarget (a.2 1))) (hend : Stuck (a.2 1) IsMaxA (a.2 2)) (hinv : Bad (a.2 0)∃ (t : A) (n : ), SGTarget t n + orank (a.2 2) < Nat.card A detNext^[n] (a.2 1) = t) :
                                        ¬Bad (a.2 0)

                                        At the end of an inner loop – the walk stuck, or the budget spent – the current candidate is harmless: its target would have to be where the walk already stands, and the walk has not stopped there.

                                        Dependency graph
                                        theorem DescriptiveComplexity.UnreachD.inv_step {A : Type} [FirstOrder.Language.stGraph.Structure A] [LinearOrder A] [Finite A] [Nonempty A] {a b : Bool × (Fin 3A)} (h : UStep a b) (hinv : Inv a) :
                                        Inv b

                                        The invariant is preserved by every step of the scan.

                                        Dependency graph
                                        Dependency graph

                                        The starting node satisfies the invariant: nothing has been scanned, and the whole universe is still available as budget.

                                        Dependency graph

                                        Soundness: if the scan finishes, there was nothing to find.

                                        Dependency graph

                                        Completeness of the scan #

                                        Nothing to find means nothing stops the walk, so it runs the inner loop to its end for every candidate and finishes.

                                        theorem DescriptiveComplexity.UnreachD.reach_of_inner {A : Type} [FirstOrder.Language.stGraph.Structure A] [LinearOrder A] [Finite A] (hnb : ∀ (s : A), ¬Bad s) (s : A) (z : Bool × (Fin 3A)) (hz : ∀ (x c : A), Relation.ReflTransGen DetEdge s xStuck x IsMaxA cUStep (false, ![s, x, c]) z) (m : ) (c x : A) :

                                        The inner loop: from any position of the walk on the candidate s, with any budget, the node z that ends the loop is reached.

                                        Dependency graph
                                        theorem DescriptiveComplexity.UnreachD.reach_candidate {A : Type} [FirstOrder.Language.stGraph.Structure A] [LinearOrder A] [Finite A] (hnb : ∀ (s : A), ¬Bad s) {a₀ : A} (h₀ : IsMinA a₀) (s : A) :

                                        The outer loop: every candidate is reached, in the order of the structure.

                                        Dependency graph

                                        Completeness: if there is nothing to find, the scan finishes.

                                        Dependency graph
                                        Dependency graph

                                        UNREACHd, and the closure of LOGSPACE under complement #

                                        The complement of REACHd is FO(DTC) definable: the scan is deterministic (DescriptiveComplexity.UnreachD.functional_unreachdSpec), so its determinization is itself, and it accepts exactly the marked graphs in which no marked target lies ahead of a marked source.

                                        Dependency graph

                                        FO(DTC) definability is closed under complement. The complement of P reduces to the complement of REACHd – a reduction complements along with its two problems – and that complement is FO(DTC) definable.

                                        Dependency graph

                                        Membership in LOGSPACE is closed under complement.

                                        Dependency graph
                                        @[reducible, inline]

                                        coLOGSPACE, the complement class of LOGSPACE. That it is LOGSPACE is DescriptiveComplexity.LOGSPACE_eq_coLOGSPACE.

                                        Equations
                                        Instances For
                                          Dependency graph

                                          L = coL: deterministic logarithmic space is closed under complement. Unlike NL = coNL (DescriptiveComplexity.NL_eq_coNL, Immerman–Szelepcsényi) this needs no inductive counting: a deterministic walk has only one thing to do at each node, so not arriving is witnessed by walking until the budget runs out.

                                          Dependency graph

                                          UNREACHd, the complement of REACHd: no marked target is reachable from a marked source along forced arcs.

                                          Equations
                                          Instances For
                                            Dependency graph

                                            UNREACHd is in LOGSPACE, by the scan.

                                            Dependency graph

                                            UNREACHd is LOGSPACE-hard, by complementing the discharge: the complement of a problem of the class is again in the class, it reduces to REACHd, and the very same interpretation reduces the problem itself to UNREACHd.

                                            Dependency graph

                                            UNREACHd is LOGSPACE-complete. Both halves come from the same side here, unlike the REACH/UNREACH pair one level up: an operator-based logic defines a problem and its complement alike, so no analogue of Immerman–Szelepcsényi is needed to complete the picture.

                                            Dependency graph