Documentation

DescriptiveComplexity.Problems.Parity

PARITY: the parity of a marked subset #

The problem the switching lemma is about, and the one DescriptiveComplexity.EVEN must not be confused with. The vocabulary is a single unary predicate, so an instance is a finite set with a marked subset, and the question is whether the marked subset has an even number of elements.

Why it is here, given that EVEN is already here #

DescriptiveComplexity.EVEN asks the parity of the universe – of the input's length – and that is AC⁰: an AC⁰ circuit family is indexed by the length, and in the logic the numeric predicates read the top rank (DescriptiveComplexity.even_ac0Definable). PARITY asks the parity of part of the input, and is the classical example of a problem outside AC⁰ (Ajtai 1983; Furst, Saxe & Sipser 1984; Håstad 1986). Keeping both in the catalog is what makes the distinction concrete rather than a warning in a docstring.

What is proved here is the easy side of that separation, and it is worth having on its own:

What would finish the story, and is not here #

AC⁰ ⊊ LOGSPACE is now one theorem away: PARITY ∉ AC⁰. That theorem is the switching lemma (Håstad 1986), a major formalization on its own, and nothing in this library proves any AC⁰ lower bound. The gap is deliberate and documented; what is recorded here is that the other three sides of the square – PARITY in LOGSPACE, PARITY not in FO(≤), EVEN in AC⁰, AC⁰ inside PTIME – are theorems.

Dependency graph
Dependency graph

The relational vocabulary of a marked subset: a finite set with a distinguished subset of it.

Equations
Instances For
    Dependency graph

    The relation symbols of the language.

    Instances For
      Dependency graph
      @[reducible, inline]

      mark x: the element x belongs to the marked subset.

      Equations
      Instances For
        Dependency graph
        def FirstOrder.Language.instDecidableEqMarkedSetRel.decEq {a✝ : } (x✝ x✝¹ : markedSetRel a✝) :
        Decidable (x✝ = x✝¹)
        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          Dependency graph
          @[reducible, inline]

          The marking symbol, in the ordered expansion. Sum-language symbols are referenced through an abbreviation with a declared type, never as a raw Sum.inl, or rw fails to match at implicit transparency.

          Equations
          Instances For
            Dependency graph

            The problem #

            Dependency graph
            Dependency graph

            PARITY: the marked subset has an even number of elements. Contrast DescriptiveComplexity.EVEN, which asks this of the universe: that one is AC⁰, this one is the classical AC⁰ lower bound.

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

              PARITY is a deterministic walk #

              One bit, one element, one pass along the order: the mode is the parity of the marked elements up to and including the current one, so it flips exactly at a marked element. Both the successor and the new mode are determined by the current node, which is why the walk is functional and the determinization is free.

              Dependency graph
              @[simp]
              Dependency graph

              The number of marked elements up to and including x.

              Equations
              Instances For
                Dependency graph

                The mode carried at x: whether an even number of marked elements has been seen so far.

                Equations
                Instances For
                  Dependency graph

                  The transition of the parity walk: step to the immediate successor, and flip the mode exactly when the element stepped onto is marked.

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

                    The walk starts at the minimum, in the mode that element prescribes: even unless the minimum is itself marked.

                    Equations
                    Instances For
                      Dependency graph

                      The walk accepts at the maximum, in the even mode.

                      Equations
                      Instances For
                        Dependency graph

                        PARITY as a single walk: one element, one bit, flipped at the marked elements.

                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For
                          Dependency graph
                          theorem DescriptiveComplexity.realize_parStep {A : Type} [FirstOrder.Language.markedSet.Structure A] [LinearOrder A] (m m' : Bool) (x y : Fin 1A) :
                          (parStep m m').Realize (Sum.elim x y) x 0 y 0 (m' = !m y 0 Marked A m' = m y 0Marked A)
                          Dependency graph
                          theorem DescriptiveComplexity.step_parSpec_iff {A : Type} [FirstOrder.Language.markedSet.Structure A] [LinearOrder A] (m m' : Bool) (x y : Fin 1A) :
                          parSpec.Step (m, x) (m', y) x 0 y 0 (m' = !m y 0 Marked A m' = m y 0Marked A)
                          Dependency graph
                          theorem DescriptiveComplexity.isSrc_parSpec_iff {A : Type} [FirstOrder.Language.markedSet.Structure A] [LinearOrder A] (m : Bool) (x : Fin 1A) :
                          parSpec.IsSrc (m, x) (∀ (a : A), x 0 a) (m = true x 0Marked A m = false x 0 Marked A)
                          Dependency graph
                          Dependency graph
                          theorem DescriptiveComplexity.parCount_isMin_marked {A : Type} [FirstOrder.Language.markedSet.Structure A] [LinearOrder A] [Finite A] {z : A} (hz : ∀ (a : A), z a) (hm : z Marked A) :

                          The prefix of a minimum is the minimum itself, when it is marked.

                          Dependency graph
                          theorem DescriptiveComplexity.parCount_isMin_not_marked {A : Type} [FirstOrder.Language.markedSet.Structure A] [LinearOrder A] [Finite A] {z : A} (hz : ∀ (a : A), z a) (hm : zMarked A) :

                          The prefix of an unmarked minimum is empty.

                          Dependency graph

                          The prefix grows by one along a cover onto a marked element.

                          Dependency graph

                          The prefix is unchanged along a cover onto an unmarked element.

                          Dependency graph

                          The mode of a marked minimum is odd.

                          Dependency graph
                          theorem DescriptiveComplexity.parMode_isMin_not_marked {A : Type} [FirstOrder.Language.markedSet.Structure A] [LinearOrder A] [Finite A] {z : A} (hz : ∀ (a : A), z a) (hm : zMarked A) :

                          The mode of an unmarked minimum is even.

                          Dependency graph

                          The mode flips along a cover onto a marked element.

                          Dependency graph

                          The mode is unchanged along a cover onto an unmarked element.

                          Dependency graph
                          theorem DescriptiveComplexity.reach_parSpec {A : Type} [FirstOrder.Language.markedSet.Structure A] [LinearOrder A] [Finite A] {x₀ : A} (h₀ : ∀ (a : A), x₀ a) (x : A) :
                          parSpec.Reach (parMode x₀, fun (x : Fin parSpec.k) => x₀) (parMode x, fun (x_1 : Fin parSpec.k) => x)

                          The walk reaches every element, in the mode its prefix prescribes.

                          Dependency graph
                          theorem DescriptiveComplexity.parMode_of_reach {A : Type} [FirstOrder.Language.markedSet.Structure A] [LinearOrder A] [Finite A] {x₀ : A} (p : parSpec.Node A) :
                          parSpec.Reach (parMode x₀, fun (x : Fin parSpec.k) => x₀) pp.1 = parMode (p.2 0)

                          The mode of a reachable node is the parity of its prefix: the invariant that reads the walk backwards.

                          Dependency graph

                          The walk accepts exactly the structures whose marked subset is even: it visits every element once, from the minimum to the maximum, so the mode it ends in is the parity of the whole marked subset.

                          Dependency graph

                          The walk is functional: the successor of an element is unique in a finite linear order, and the new mode is determined by its markedness.

                          Dependency graph

                          PARITY is FO(DTC) definable, by the deterministic parity walk: the determinization changes nothing, the walk being functional.

                          Dependency graph

                          PARITY is in LOGSPACE. With DescriptiveComplexity.parity_not_foDefinable below, and the AC⁰ layer, this is three of the four sides of AC⁰ ⊊ LOGSPACE; the fourth is PARITY ∉ AC⁰, which this library does not prove.

                          Dependency graph

                          EVEN is the special case where everything is marked #

                          The interpretation marking every element: EVEN read as an instance of PARITY, one dimension and one tag.

                          Equations
                          Instances For
                            Dependency graph

                            Every point of the interpreted structure is marked.

                            Dependency graph

                            EVEN reduces to PARITY: mark everything.

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

                              PARITY is not first-order definable, even order-invariantly: EVEN is not (DescriptiveComplexity.even_not_foDefinable), and it reduces to PARITY.

                              Dependency graph