Documentation

DescriptiveComplexity.TransitiveClosureCompl

FO(TC) is closed under complement #

Immerman–Szelepcsényi, as a theorem about the logic: on finite ordered structures, the complement of an FO(TC) definable problem is FO(TC) definable (Immerman 1988, Szelepcsényi 1988).

The proof runs the inductive-counting machine of DescriptiveComplexity.InductiveCounting inside a single transitive closure. The machine's nodes are the nodes of the given DescriptiveComplexity.TCSpec, linearly ordered mode-major by the order of the structure; its configurations are a finite control together with eight registers, each holding a node or a count, and each stored as one k-tuple of elements beside a mode kept in the control. So a configuration is a mode together with a 8k-tuple, which is exactly what a TCSpec of arity 8k can walk on.

The one thing the translation must supply is the formulas: each atomic constraint of DescriptiveComplexity.InductiveCounting.VAtom becomes, given the modes recorded by the two control states, either a first-order formula over the two tuples or the information that no tuples can satisfy it (compileAtom). Since the modes are finite control data, every mode-level condition – "these two registers hold the same mode", "this mode is the least one", "this mode is covered by that one" – is decided outside the formula, and what remains for the formula is a condition on tuples of elements: equality, the lexicographic minimum, maximum or successor (DescriptiveComplexity.OrderWalk), or one of the given spec's own formulas.

Padding a specification with a spare mode #

The specification with one spare, isolated mode added, so that the mode type is nonempty: the new mode has no transitions and is neither a source nor a target.

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

    Padding does not change acceptance.

    Dependency graph

    The nodes of a specification as a finite linear order #

    @[reducible, inline]

    The nodes of the walk, ordered mode-major and then lexicographically on tuples.

    Equations
    Instances For
      Dependency graph
      def DescriptiveComplexity.TCCompl.toNode {L : FirstOrder.Language} {spec : TCSpec L} {A : Type} (z : NodeOrd spec A) :
      spec.Node A

      The node underlying an ordered node.

      Equations
      Instances For
        Dependency graph
        def DescriptiveComplexity.TCCompl.ofNode {L : FirstOrder.Language} {spec : TCSpec L} {A : Type} (n : spec.Node A) :
        NodeOrd spec A

        The ordered node of a node.

        Equations
        Instances For
          Dependency graph
          @[simp]
          Dependency graph
          @[simp]
          Dependency graph

          The edges of the walk, on ordered nodes.

          Equations
          Instances For
            Dependency graph

            The starting nodes of the walk, on ordered nodes.

            Equations
            Instances For
              Dependency graph

              The accepting nodes of the walk, on ordered nodes.

              Equations
              Instances For
                Dependency graph
                Dependency graph
                Dependency graph
                theorem DescriptiveComplexity.TCCompl.exists_reach_iff {L : FirstOrder.Language} (spec : TCSpec L) (A : Type) [L.Structure A] [LinearOrder A] :
                (∃ (a : NodeOrd spec A) (b : NodeOrd spec A), src a tgt b Relation.ReflTransGen edge a b) spec.Accepts A

                Acceptance of the specification, read on the ordered nodes.

                Dependency graph

                Registers inside one tuple #

                @[reducible, inline]

                The arity of the complement specification: eight registers of k elements each.

                Equations
                Instances For
                  Dependency graph
                  @[reducible, inline]

                  The variables of a transition formula: two tuples of that arity.

                  Equations
                  Instances For
                    Dependency graph

                    The variable holding coordinate i of register r.

                    Equations
                    Instances For
                      Dependency graph

                      The variables holding the tuple a slot reads.

                      Equations
                      Instances For
                        Dependency graph
                        def DescriptiveComplexity.TCCompl.regTup {L : FirstOrder.Language} {spec : TCSpec L} {A : Type} (x : Fin (dim spec)A) (r : InductiveCounting.Reg) :
                        Fin spec.kA

                        The tuple a register holds inside a tuple of the walk.

                        Equations
                        Instances For
                          Dependency graph
                          def DescriptiveComplexity.TCCompl.mkTup {L : FirstOrder.Language} (spec : TCSpec L) {A : Type} (f : InductiveCounting.RegFin spec.kA) :
                          Fin (dim spec)A

                          Assembling the eight registers into one tuple.

                          Equations
                          Instances For
                            Dependency graph
                            @[simp]
                            Dependency graph
                            def DescriptiveComplexity.TCCompl.slotTup {L : FirstOrder.Language} {spec : TCSpec L} {A : Type} (x y : Fin (dim spec)A) :

                            The tuple a slot reads, from the two tuples of a transition.

                            Equations
                            Instances For
                              Dependency graph
                              theorem DescriptiveComplexity.TCCompl.realize_slotSel {L : FirstOrder.Language} {spec : TCSpec L} {A : Type} (x y : Fin (dim spec)A) (a : InductiveCounting.Slot) (i : Fin spec.k) :
                              Sum.elim x y (slotSel spec a i) = slotTup x y a i
                              Dependency graph

                              The formulas of the atomic constraints #

                              Two slots hold the same tuple.

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

                                The two slots hold tuples joined by a transition of the given modes.

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

                                  The slot holds a starting tuple of the given mode.

                                  Equations
                                  Instances For
                                    Dependency graph

                                    The slot holds an accepting tuple of the given mode.

                                    Equations
                                    Instances For
                                      Dependency graph
                                      theorem DescriptiveComplexity.TCCompl.realize_eqTupF {L : FirstOrder.Language} {spec : TCSpec L} {A : Type} [L.Structure A] [LinearOrder A] (x y : Fin (dim spec)A) (a b : InductiveCounting.Slot) :
                                      (eqTupF spec a b).Realize (Sum.elim x y) slotTup x y a = slotTup x y b
                                      Dependency graph
                                      theorem DescriptiveComplexity.TCCompl.realize_stepF {L : FirstOrder.Language} {spec : TCSpec L} {A : Type} [L.Structure A] [LinearOrder A] (x y : Fin (dim spec)A) (m m' : spec.Mode) (a b : InductiveCounting.Slot) :
                                      (stepF spec m m' a b).Realize (Sum.elim x y) spec.Step (m, slotTup x y a) (m', slotTup x y b)
                                      Dependency graph
                                      theorem DescriptiveComplexity.TCCompl.realize_srcF {L : FirstOrder.Language} {spec : TCSpec L} {A : Type} [L.Structure A] [LinearOrder A] (x y : Fin (dim spec)A) (m : spec.Mode) (a : InductiveCounting.Slot) :
                                      (srcF spec m a).Realize (Sum.elim x y) spec.IsSrc (m, slotTup x y a)
                                      Dependency graph
                                      theorem DescriptiveComplexity.TCCompl.realize_tgtF {L : FirstOrder.Language} {spec : TCSpec L} {A : Type} [L.Structure A] [LinearOrder A] (x y : Fin (dim spec)A) (m : spec.Mode) (a : InductiveCounting.Slot) :
                                      (tgtF spec m a).Realize (Sum.elim x y) spec.IsTgt (m, slotTup x y a)
                                      Dependency graph
                                      theorem DescriptiveComplexity.TCCompl.realize_minTup {L : FirstOrder.Language} {spec : TCSpec L} {A : Type} [L.Structure A] [LinearOrder A] (x y : Fin (dim spec)A) (a : InductiveCounting.Slot) :
                                      (minTupF (slotSel spec a)).Realize (Sum.elim x y) ∀ (p : Fin spec.k) (z : A), slotTup x y a p z
                                      Dependency graph
                                      theorem DescriptiveComplexity.TCCompl.realize_maxTup {L : FirstOrder.Language} {spec : TCSpec L} {A : Type} [L.Structure A] [LinearOrder A] (x y : Fin (dim spec)A) (a : InductiveCounting.Slot) :
                                      (maxTupF (slotSel spec a)).Realize (Sum.elim x y) ∀ (p : Fin spec.k) (z : A), z slotTup x y a p
                                      Dependency graph
                                      theorem DescriptiveComplexity.TCCompl.realize_succTup {L : FirstOrder.Language} {spec : TCSpec L} {A : Type} [L.Structure A] [LinearOrder A] (x y : Fin (dim spec)A) (a b : InductiveCounting.Slot) :
                                      (succTupF (slotSel spec a) (slotSel spec b)).Realize (Sum.elim x y) TupSucc (slotTup x y a) (slotTup x y b)
                                      Dependency graph

                                      Register values #

                                      def DescriptiveComplexity.TCCompl.fuse {L : FirstOrder.Language} (spec : TCSpec L) {A : Type} (om : Option spec.Mode) (t : Fin spec.kA) :
                                      WithBot (NodeOrd spec A)

                                      The value of a register: when the control records no mode, the node made of the mode and the tuple otherwise.

                                      Equations
                                      Instances For
                                        Dependency graph
                                        theorem DescriptiveComplexity.TCCompl.fuse_none {L : FirstOrder.Language} {spec : TCSpec L} {A : Type} (t : Fin spec.kA) :
                                        fuse spec none t =
                                        Dependency graph
                                        theorem DescriptiveComplexity.TCCompl.fuse_some {L : FirstOrder.Language} {spec : TCSpec L} {A : Type} (m : spec.Mode) (t : Fin spec.kA) :
                                        fuse spec (some m) t = (ofNode (m, t))
                                        Dependency graph
                                        theorem DescriptiveComplexity.TCCompl.fuse_eq_iff {L : FirstOrder.Language} {spec : TCSpec L} {A : Type} {m m' : spec.Mode} {t t' : Fin spec.kA} :
                                        fuse spec (some m) t = fuse spec (some m') t' m = m' t = t'
                                        Dependency graph
                                        theorem DescriptiveComplexity.TCCompl.fuse_ne_bot {L : FirstOrder.Language} {spec : TCSpec L} {A : Type} {m : spec.Mode} {t : Fin spec.kA} :
                                        fuse spec (some m) t
                                        Dependency graph
                                        theorem DescriptiveComplexity.TCCompl.covBy_fuse {L : FirstOrder.Language} {spec : TCSpec L} [LinearOrder spec.Mode] {A : Type} [LinearOrder A] [Nonempty A] {m m' : spec.Mode} {t t' : Fin spec.kA} :
                                        fuse spec (some m) t fuse spec (some m') t' m = m' TupSucc t t' m m' (∀ (p : Fin spec.k) (z : A), z t p) ∀ (p : Fin spec.k) (z : A), t' p z
                                        Dependency graph
                                        theorem DescriptiveComplexity.TCCompl.bot_covBy_fuse {L : FirstOrder.Language} {spec : TCSpec L} [LinearOrder spec.Mode] {A : Type} [LinearOrder A] {m : spec.Mode} {t : Fin spec.kA} :
                                        fuse spec (some m) t (∀ (m' : spec.Mode), m m') ∀ (p : Fin spec.k) (z : A), t p z
                                        Dependency graph
                                        theorem DescriptiveComplexity.TCCompl.eW_fuse {L : FirstOrder.Language} {spec : TCSpec L} {A : Type} [L.Structure A] [LinearOrder A] {m m' : spec.Mode} {t t' : Fin spec.kA} :
                                        InductiveCounting.EW edge (fuse spec (some m) t) (fuse spec (some m') t') spec.Step (m, t) (m', t')
                                        Dependency graph
                                        theorem DescriptiveComplexity.TCCompl.eW_fuse_none_left {L : FirstOrder.Language} {spec : TCSpec L} {A : Type} [L.Structure A] [LinearOrder A] {om : Option spec.Mode} {t t' : Fin spec.kA} :
                                        ¬InductiveCounting.EW edge (fuse spec none t) (fuse spec om t')
                                        Dependency graph
                                        theorem DescriptiveComplexity.TCCompl.eW_fuse_none_right {L : FirstOrder.Language} {spec : TCSpec L} {A : Type} [L.Structure A] [LinearOrder A] {om : Option spec.Mode} {t t' : Fin spec.kA} :
                                        ¬InductiveCounting.EW edge (fuse spec om t) (fuse spec none t')
                                        Dependency graph
                                        theorem DescriptiveComplexity.TCCompl.pW_fuse {L : FirstOrder.Language} {spec : TCSpec L} {A : Type} {P : NodeOrd spec AProp} {m : spec.Mode} {t : Fin spec.kA} :
                                        InductiveCounting.PW P (fuse spec (some m) t) P (ofNode (m, t))
                                        Dependency graph
                                        theorem DescriptiveComplexity.TCCompl.pW_fuse_none {L : FirstOrder.Language} {spec : TCSpec L} {A : Type} {P : NodeOrd spec AProp} {t : Fin spec.kA} :
                                        Dependency graph
                                        theorem DescriptiveComplexity.TCCompl.pW_fuse_isMin {L : FirstOrder.Language} {spec : TCSpec L} [LinearOrder spec.Mode] {A : Type} [LinearOrder A] {m : spec.Mode} {t : Fin spec.kA} :
                                        InductiveCounting.PW (fun (p : NodeOrd spec A) => ∀ (z : NodeOrd spec A), p z) (fuse spec (some m) t) (∀ (m' : spec.Mode), m m') ∀ (p : Fin spec.k) (z : A), t p z
                                        Dependency graph
                                        theorem DescriptiveComplexity.TCCompl.pW_fuse_isMax {L : FirstOrder.Language} {spec : TCSpec L} [LinearOrder spec.Mode] {A : Type} [LinearOrder A] {m : spec.Mode} {t : Fin spec.kA} :
                                        InductiveCounting.PW (fun (p : NodeOrd spec A) => ∀ (z : NodeOrd spec A), z p) (fuse spec (some m) t) (∀ (m' : spec.Mode), m' m) ∀ (p : Fin spec.k) (z : A), z t p
                                        Dependency graph

                                        Compiling an atomic constraint #

                                        The mode a slot reads, from the modes the two control states record.

                                        Equations
                                        Instances For
                                          Dependency graph

                                          The formula of an atomic constraint, given the modes recorded by the two control states: none when those modes already make the constraint unsatisfiable. Every mode-level condition is decided here, outside the formula.

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

                                            The registers a control state and a tuple describe.

                                            Equations
                                            Instances For
                                              Dependency graph
                                              theorem DescriptiveComplexity.TCCompl.slotVal_regsOf {L : FirstOrder.Language} {spec : TCSpec L} {A : Type} (pm qm : InductiveCounting.RegOption spec.Mode) (x y : Fin (dim spec)A) (a : InductiveCounting.Slot) :
                                              InductiveCounting.slotVal (regsOf pm x) (regsOf qm y) a = fuse spec (slotMode spec pm qm a) (slotTup x y a)
                                              Dependency graph
                                              theorem DescriptiveComplexity.TCCompl.ofNode_eq_iff {L : FirstOrder.Language} {spec : TCSpec L} {A : Type} {m m' : spec.Mode} {t t' : Fin spec.kA} :
                                              ofNode (m, t) = ofNode (m', t') m = m' t = t'
                                              Dependency graph

                                              The atomic constraints are first-order: given the modes, an atomic constraint holds of the registers exactly when its compiled formula holds of the tuples.

                                              Dependency graph

                                              Compiling a table entry #

                                              The formula of one alternative: the conjunction of its atomic constraints.

                                              Equations
                                              Instances For
                                                Dependency graph

                                                The formula of a table entry: the disjunction of its satisfiable alternatives.

                                                Equations
                                                Instances For
                                                  Dependency graph
                                                  Dependency graph
                                                  Dependency graph

                                                  The complement specification #

                                                  @[reducible, inline]

                                                  The control states of the counting machine: a phase, the flag, and the mode of each of the eight registers.

                                                  Equations
                                                  Instances For
                                                    Dependency graph

                                                    The formula defining the initial configurations: the source scan is about to start with a zero count and the outer register at the least node.

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

                                                      The complement specification: the inductive-counting machine, as a single transitive closure over 8k-tuples.

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

                                                        The configuration a node of the complement specification describes.

                                                        Equations
                                                        Instances For
                                                          Dependency graph
                                                          Dependency graph
                                                          noncomputable def DescriptiveComplexity.TCCompl.splitTup {L : FirstOrder.Language} {spec : TCSpec L} {A : Type} [Nonempty A] (w : WithBot (NodeOrd spec A)) :
                                                          Fin spec.kA

                                                          The tuple a register value records.

                                                          Equations
                                                          Instances For
                                                            Dependency graph
                                                            Dependency graph
                                                            noncomputable def DescriptiveComplexity.TCCompl.ofCfg {L : FirstOrder.Language} {spec : TCSpec L} [LinearOrder spec.Mode] {A : Type} [Nonempty A] (s : InductiveCounting.Cfg (NodeOrd spec A)) :
                                                            (complSpec spec).Node A

                                                            Every configuration comes from a node of the complement specification.

                                                            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
                                                              Dependency graph
                                                              theorem DescriptiveComplexity.TCCompl.realize_srcFormula {L : FirstOrder.Language} {spec : TCSpec L} [LinearOrder spec.Mode] {A : Type} [L.Structure A] [LinearOrder A] (p : Ctrl spec) (x : Fin (dim spec)A) :
                                                              (srcFormula spec p).Realize x p.1 = InductiveCounting.Phase.initCount p.2.1 = false p.2.2 InductiveCounting.Reg.c = none ∃ (m : spec.Mode), p.2.2 InductiveCounting.Reg.v = some m (∀ (m' : spec.Mode), m m') ∀ (i : Fin spec.k) (z : A), x (regIdx spec InductiveCounting.Reg.v i) z
                                                              Dependency graph
                                                              Dependency graph
                                                              Dependency graph
                                                              Dependency graph
                                                              Dependency graph

                                                              The complement specification is correct: it accepts exactly the structures the given specification rejects.

                                                              Dependency graph