Documentation

DescriptiveComplexity.TransitiveClosureFlatten

Flattening a walk whose steps are decided: the suspension #

The nested case of the normal form for FO(TC): a walk over an expansion – whose step formulas read the reachability relations of other walks – becomes a walk over the base vocabulary (DescriptiveComplexity.ParamTCSpec.flat), given a DescriptiveComplexity.Decider for each of its step formulas. The outer walk is suspended at a node, the decider of the step to a candidate successor is run, and where it exits yes the outer walk resumes at that successor.

Two ways to pick the candidate #

A node of the outer walk is encoded with the candidate and every decider's coordinates at the minimum (DescriptiveComplexity.ParamTCSpec.flatEnc), which is where the walk resumes after a yes; this is what makes the encoding a bijection onto the outer nodes the flat walk can stand on.

The flat walk carries its coordinates as a type rather than an arity (DescriptiveComplexity.CoordWalk), the coordinates of the deciders being a dependent sum over the pairs of modes; DescriptiveComplexity.CoordWalk.toParam enumerates them for the DescriptiveComplexity.ParamTCSpec the rest of the development consumes.

Walks with a type of coordinates #

A parameterized walk whose coordinates are an arbitrary finite type.

Instances For
    Dependency graph
    @[reducible, inline]

    A node: a mode and a tuple.

    Equations
    Instances For
      Dependency graph
      def DescriptiveComplexity.CoordWalk.StepAt {L : FirstOrder.Language} (C : CoordWalk L) {A : Type} [L.Structure A] (z : Fin C.par → A) (a b : C.Node A) :

      One step, at a valuation of the parameters.

      Equations
      Instances For
        Dependency graph
        @[reducible, inline]
        abbrev DescriptiveComplexity.CoordWalk.ReachAt {L : FirstOrder.Language} (C : CoordWalk L) {A : Type} [L.Structure A] (z : Fin C.par → A) :
        C.Node A → C.Node A → Prop

        Reachability, at a valuation of the parameters.

        Equations
        Instances For
          Dependency graph

          The walk is functional when no node has two successors.

          Equations
          Instances For
            Dependency graph

            The coordinates, enumerated.

            Equations
            Instances For
              Dependency graph
              @[reducible]

              The walk with its coordinates enumerated, as a DescriptiveComplexity.ParamTCSpec. Reducible, so that its modes and parameters are those of the walk transparently.

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

                The flat walk #

                @[instance_reducible]

                An arbitrary linear order on the modes of the outer walk, for the search.

                Equations
                Instances For
                  Dependency graph
                  @[reducible, inline]

                  The coordinates of the flat walk: the current tuple and the candidate, then the coordinates of every decider.

                  Equations
                  Instances For
                    Dependency graph
                    @[reducible, inline]

                    The modes of the flat walk: a mode of the outer walk, or a pair of modes with a mode of their decider.

                    Equations
                    Instances For
                      Dependency graph

                      A coordinate belongs to the slice of a pair of modes.

                      Equations
                      Instances For
                        Dependency graph

                        The formulas #

                        def DescriptiveComplexity.ParamTCSpec.flatRunVar {L : FirstOrder.Language} {B : SOBlock} (S : ParamTCSpec ((L.sum FirstOrder.Language.order).sum B.lang)) (D : S.Mode → S.Mode → Decider L ((Fin S.k ⊕ Fin S.k) ⊕ Fin S.par)) (p : S.Mode × S.Mode) :
                        ((D p.1 p.2).Coord ⊕ (D p.1 p.2).Coord) ⊕ (Fin S.k ⊕ Fin S.k) ⊕ Fin S.par → (S.FlatCoord D ⊕ S.FlatCoord D) ⊕ Fin S.par

                        The variables of a decider's step, in the flat walk's.

                        Equations
                        Instances For
                          Dependency graph

                          The variables of a decider's exit, in the flat walk's step (read on the current tuple).

                          Equations
                          Instances For
                            Dependency graph
                            @[reducible, inline]

                            The current tuple's coordinate, as a step variable.

                            Equations
                            Instances For
                              Dependency graph
                              @[reducible, inline]

                              The next tuple's coordinate, as a step variable.

                              Equations
                              Instances For
                                Dependency graph

                                Every coordinate outside a slice is copied.

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

                                  Every decider coordinate of the next tuple is at the minimum.

                                  Equations
                                  Instances For
                                    Dependency graph

                                    The next tuple is the candidate, with everything else at the minimum.

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

                                      The current tuple is copied.

                                      Equations
                                      Instances For
                                        Dependency graph

                                        The candidate advances: same mode and the successor tuple, or the next mode with the tuple from the maximum to the minimum.

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

                                          Entering a decider: the current tuple is copied and the decider's coordinates are reset; when searching, the candidate is the least node.

                                          Equations
                                          • One or more equations did not get rendered due to their size.
                                          Instances For
                                            Dependency graph
                                            noncomputable def DescriptiveComplexity.ParamTCSpec.runF {L : FirstOrder.Language} {B : SOBlock} (S : ParamTCSpec ((L.sum FirstOrder.Language.order).sum B.lang)) (D : S.Mode → S.Mode → Decider L ((Fin S.k ⊕ Fin S.k) ⊕ Fin S.par)) (p : S.Mode × S.Mode) (d d' : (D p.1 p.2).Mode) :

                                            Running a decider: its step on its slice, everything else copied.

                                            Equations
                                            Instances For
                                              Dependency graph
                                              noncomputable def DescriptiveComplexity.ParamTCSpec.retF {L : FirstOrder.Language} {B : SOBlock} (S : ParamTCSpec ((L.sum FirstOrder.Language.order).sum B.lang)) (D : S.Mode → S.Mode → Decider L ((Fin S.k ⊕ Fin S.k) ⊕ Fin S.par)) (p : S.Mode × S.Mode) (d : (D p.1 p.2).Mode) :

                                              Resuming the outer walk: the decider exits yes, and the walk stands on the candidate.

                                              Equations
                                              Instances For
                                                Dependency graph
                                                noncomputable def DescriptiveComplexity.ParamTCSpec.advF {L : FirstOrder.Language} {B : SOBlock} (S : ParamTCSpec ((L.sum FirstOrder.Language.order).sum B.lang)) (D : S.Mode → S.Mode → Decider L ((Fin S.k ⊕ Fin S.k) ⊕ Fin S.par)) (p : S.Mode × S.Mode) (d : (D p.1 p.2).Mode) (p' : S.Mode × S.Mode) :

                                                Trying the next candidate: the decider exits no, the candidate advances, and the decider's coordinates are reset.

                                                Equations
                                                • One or more equations did not get rendered due to their size.
                                                Instances For
                                                  Dependency graph
                                                  noncomputable def DescriptiveComplexity.ParamTCSpec.innerF {L : FirstOrder.Language} {B : SOBlock} (S : ParamTCSpec ((L.sum FirstOrder.Language.order).sum B.lang)) (D : S.Mode → S.Mode → Decider L ((Fin S.k ⊕ Fin S.k) ⊕ Fin S.par)) (det : Bool) (p : S.Mode × S.Mode) (d : (D p.1 p.2).Mode) (p' : S.Mode × S.Mode) (d' : (D p'.1 p'.2).Mode) :

                                                  The step between two decider nodes: the run, or (when searching) an advance to the start of the next candidate's decider.

                                                  Equations
                                                  Instances For
                                                    Dependency graph
                                                    @[reducible]

                                                    The flat walk: the outer walk with each step decided in place. Guessing (det = false) or searching (det = true) the candidate.

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

                                                      Tuples of the flat walk #

                                                      @[reducible, inline]
                                                      abbrev DescriptiveComplexity.ParamTCSpec.tx {L : FirstOrder.Language} {B : SOBlock} {S : ParamTCSpec ((L.sum FirstOrder.Language.order).sum B.lang)} {D : S.Mode → S.Mode → Decider L ((Fin S.k ⊕ Fin S.k) ⊕ Fin S.par)} {A : Type} (t : S.FlatCoord D → A) :
                                                      Fin S.k → A

                                                      The current tuple.

                                                      Equations
                                                      Instances For
                                                        Dependency graph
                                                        @[reducible, inline]
                                                        abbrev DescriptiveComplexity.ParamTCSpec.ty {L : FirstOrder.Language} {B : SOBlock} {S : ParamTCSpec ((L.sum FirstOrder.Language.order).sum B.lang)} {D : S.Mode → S.Mode → Decider L ((Fin S.k ⊕ Fin S.k) ⊕ Fin S.par)} {A : Type} (t : S.FlatCoord D → A) :
                                                        Fin S.k → A

                                                        The candidate.

                                                        Equations
                                                        Instances For
                                                          Dependency graph
                                                          @[reducible, inline]
                                                          abbrev DescriptiveComplexity.ParamTCSpec.tsl {L : FirstOrder.Language} {B : SOBlock} {S : ParamTCSpec ((L.sum FirstOrder.Language.order).sum B.lang)} {D : S.Mode → S.Mode → Decider L ((Fin S.k ⊕ Fin S.k) ⊕ Fin S.par)} {A : Type} (t : S.FlatCoord D → A) (p : S.Mode × S.Mode) :
                                                          (D p.1 p.2).Coord → A

                                                          The slice of a pair of modes.

                                                          Equations
                                                          Instances For
                                                            Dependency graph
                                                            @[reducible, inline]
                                                            abbrev DescriptiveComplexity.ParamTCSpec.dpar {L : FirstOrder.Language} {B : SOBlock} {S : ParamTCSpec ((L.sum FirstOrder.Language.order).sum B.lang)} {D : S.Mode → S.Mode → Decider L ((Fin S.k ⊕ Fin S.k) ⊕ Fin S.par)} {A : Type} (t : S.FlatCoord D → A) (z : Fin S.par → A) :
                                                            (Fin S.k ⊕ Fin S.k) ⊕ Fin S.par → A

                                                            The valuation of a decider's parameters: the current tuple, the candidate and the outer parameters.

                                                            Equations
                                                            Instances For
                                                              Dependency graph
                                                              def DescriptiveComplexity.ParamTCSpec.flatEnc {L : FirstOrder.Language} {B : SOBlock} (S : ParamTCSpec ((L.sum FirstOrder.Language.order).sum B.lang)) (D : S.Mode → S.Mode → Decider L ((Fin S.k ⊕ Fin S.k) ⊕ Fin S.par)) {A : Type} (det : Bool) (a₀ : A) (a : S.Node A) :
                                                              (S.flat D det).Node A

                                                              The encoding of a node of the outer walk, at a bottom element a₀.

                                                              Equations
                                                              Instances For
                                                                Dependency graph

                                                                Semantics of the formulas #

                                                                theorem DescriptiveComplexity.ParamTCSpec.realize_initF {L : FirstOrder.Language} {B : SOBlock} (S : ParamTCSpec ((L.sum FirstOrder.Language.order).sum B.lang)) (D : S.Mode → S.Mode → Decider L ((Fin S.k ⊕ Fin S.k) ⊕ Fin S.par)) {det : Bool} {A : Type} [L.Structure A] [LinearOrder A] (z : Fin S.par → A) (p : S.Mode × S.Mode) (t t' : S.FlatCoord D → A) :
                                                                (S.initF D det p).Realize (Sum.elim (Sum.elim t t') z) ↔ (det = true → (∀ (c' : S.Mode), p.2 ≤ c') ∧ ∀ (i : Fin S.k) (a : A), t' (Sum.inl (Sum.inr i)) ≤ a) ∧ tx t' = tx t ∧ ∀ (c : (p : S.Mode × S.Mode) × (D p.1 p.2).Coord) (a : A), t' (Sum.inr c) ≤ a
                                                                Dependency graph
                                                                theorem DescriptiveComplexity.ParamTCSpec.realize_runF {L : FirstOrder.Language} {B : SOBlock} (S : ParamTCSpec ((L.sum FirstOrder.Language.order).sum B.lang)) (D : S.Mode → S.Mode → Decider L ((Fin S.k ⊕ Fin S.k) ⊕ Fin S.par)) {A : Type} [L.Structure A] [LinearOrder A] (z : Fin S.par → A) (p : S.Mode × S.Mode) (d d' : (D p.1 p.2).Mode) (t t' : S.FlatCoord D → A) :
                                                                (S.runF D p d d').Realize (Sum.elim (Sum.elim t t') z) ↔ (D p.1 p.2).StepAt (dpar t z) (d, tsl t p) (d', tsl t' p) ∧ ∀ (c : S.FlatCoord D), ¬S.InSlice D p c → t' c = t c
                                                                Dependency graph
                                                                theorem DescriptiveComplexity.ParamTCSpec.realize_exit_relabel {L : FirstOrder.Language} {B : SOBlock} (S : ParamTCSpec ((L.sum FirstOrder.Language.order).sum B.lang)) (D : S.Mode → S.Mode → Decider L ((Fin S.k ⊕ Fin S.k) ⊕ Fin S.par)) {A : Type} [L.Structure A] [LinearOrder A] (z : Fin S.par → A) (p : S.Mode × S.Mode) (d : (D p.1 p.2).Mode) (o : Bool) (t t' : S.FlatCoord D → A) :
                                                                (FirstOrder.Language.Formula.relabel (S.flatExitVar D p) ((D p.1 p.2).exit d o)).Realize (Sum.elim (Sum.elim t t') z) ↔ (D p.1 p.2).ExitAt (dpar t z) (d, tsl t p) o
                                                                Dependency graph
                                                                theorem DescriptiveComplexity.ParamTCSpec.realize_retF {L : FirstOrder.Language} {B : SOBlock} (S : ParamTCSpec ((L.sum FirstOrder.Language.order).sum B.lang)) (D : S.Mode → S.Mode → Decider L ((Fin S.k ⊕ Fin S.k) ⊕ Fin S.par)) {A : Type} [L.Structure A] [LinearOrder A] (z : Fin S.par → A) (p : S.Mode × S.Mode) (d : (D p.1 p.2).Mode) (t t' : S.FlatCoord D → A) :
                                                                (S.retF D p d).Realize (Sum.elim (Sum.elim t t') z) ↔ (D p.1 p.2).ExitAt (dpar t z) (d, tsl t p) true ∧ tx t' = ty t ∧ (∀ (i : Fin S.k) (a : A), t' (Sum.inl (Sum.inr i)) ≤ a) ∧ ∀ (c : (p : S.Mode × S.Mode) × (D p.1 p.2).Coord) (a : A), t' (Sum.inr c) ≤ a
                                                                Dependency graph

                                                                Steps of the flat walk #

                                                                theorem DescriptiveComplexity.ParamTCSpec.flat_stepAt_inl_inr {L : FirstOrder.Language} {B : SOBlock} (S : ParamTCSpec ((L.sum FirstOrder.Language.order).sum B.lang)) (D : S.Mode → S.Mode → Decider L ((Fin S.k ⊕ Fin S.k) ⊕ Fin S.par)) {det : Bool} {A : Type} [L.Structure A] [LinearOrder A] (z : Fin S.par → A) (m : S.Mode) (p : S.Mode × S.Mode) (d : (D p.1 p.2).Mode) (t t' : S.FlatCoord D → A) :
                                                                (S.flat D det).StepAt z (Sum.inl m, t) (Sum.inr ⟨p, d⟩, t') ↔ p.1 = m ∧ d = (D p.1 p.2).start ∧ (det = true → (∀ (c' : S.Mode), p.2 ≤ c') ∧ ∀ (i : Fin S.k) (a : A), t' (Sum.inl (Sum.inr i)) ≤ a) ∧ tx t' = tx t ∧ ∀ (c : (p : S.Mode × S.Mode) × (D p.1 p.2).Coord) (a : A), t' (Sum.inr c) ≤ a
                                                                Dependency graph
                                                                theorem DescriptiveComplexity.ParamTCSpec.flat_not_stepAt_inl_inl {L : FirstOrder.Language} {B : SOBlock} (S : ParamTCSpec ((L.sum FirstOrder.Language.order).sum B.lang)) (D : S.Mode → S.Mode → Decider L ((Fin S.k ⊕ Fin S.k) ⊕ Fin S.par)) {det : Bool} {A : Type} [L.Structure A] [LinearOrder A] (z : Fin S.par → A) (m n : S.Mode) (t t' : S.FlatCoord D → A) :
                                                                ¬(S.flat D det).StepAt z (Sum.inl m, t) (Sum.inl n, t')
                                                                Dependency graph
                                                                theorem DescriptiveComplexity.ParamTCSpec.flat_stepAt_inr_inl {L : FirstOrder.Language} {B : SOBlock} (S : ParamTCSpec ((L.sum FirstOrder.Language.order).sum B.lang)) (D : S.Mode → S.Mode → Decider L ((Fin S.k ⊕ Fin S.k) ⊕ Fin S.par)) {det : Bool} {A : Type} [L.Structure A] [LinearOrder A] (z : Fin S.par → A) (p : S.Mode × S.Mode) (d : (D p.1 p.2).Mode) (n : S.Mode) (t t' : S.FlatCoord D → A) :
                                                                (S.flat D det).StepAt z (Sum.inr ⟨p, d⟩, t) (Sum.inl n, t') ↔ p.2 = n ∧ (D p.1 p.2).ExitAt (dpar t z) (d, tsl t p) true ∧ tx t' = ty t ∧ (∀ (i : Fin S.k) (a : A), t' (Sum.inl (Sum.inr i)) ≤ a) ∧ ∀ (c : (p : S.Mode × S.Mode) × (D p.1 p.2).Coord) (a : A), t' (Sum.inr c) ≤ a
                                                                Dependency graph

                                                                Correctness #

                                                                theorem DescriptiveComplexity.ParamTCSpec.dpar_eq {L : FirstOrder.Language} {B : SOBlock} (S : ParamTCSpec ((L.sum FirstOrder.Language.order).sum B.lang)) (D : S.Mode → S.Mode → Decider L ((Fin S.k ⊕ Fin S.k) ⊕ Fin S.par)) {A : Type} (z : Fin S.par → A) (t : S.FlatCoord D → A) :
                                                                Sum.elim (Sum.elim (tx t) (ty t)) z = dpar t z
                                                                Dependency graph
                                                                theorem DescriptiveComplexity.ParamTCSpec.tuple_ext {L : FirstOrder.Language} {B : SOBlock} (S : ParamTCSpec ((L.sum FirstOrder.Language.order).sum B.lang)) (D : S.Mode → S.Mode → Decider L ((Fin S.k ⊕ Fin S.k) ⊕ Fin S.par)) {A : Type} {t t' : S.FlatCoord D → A} (hx : tx t' = tx t) (hy : ty t' = ty t) (hs : ∀ (p : S.Mode × S.Mode), tsl t' p = tsl t p) :
                                                                t' = t
                                                                Dependency graph
                                                                theorem DescriptiveComplexity.ParamTCSpec.tx_flatEnc {L : FirstOrder.Language} {B : SOBlock} (S : ParamTCSpec ((L.sum FirstOrder.Language.order).sum B.lang)) (D : S.Mode → S.Mode → Decider L ((Fin S.k ⊕ Fin S.k) ⊕ Fin S.par)) {det : Bool} {A : Type} (a₀ : A) (a : S.Node A) :
                                                                tx (S.flatEnc D det a₀ a).2 = a.2
                                                                Dependency graph
                                                                theorem DescriptiveComplexity.ParamTCSpec.ty_flatEnc {L : FirstOrder.Language} {B : SOBlock} (S : ParamTCSpec ((L.sum FirstOrder.Language.order).sum B.lang)) (D : S.Mode → S.Mode → Decider L ((Fin S.k ⊕ Fin S.k) ⊕ Fin S.par)) {det : Bool} {A : Type} (a₀ : A) (a : S.Node A) :
                                                                ty (S.flatEnc D det a₀ a).2 = fun (x : Fin S.k) => a₀
                                                                Dependency graph

                                                                The step deciders decide the steps of the outer walk.

                                                                Equations
                                                                Instances For
                                                                  Dependency graph
                                                                  @[reducible, inline]

                                                                  The candidates, ordered.

                                                                  Equations
                                                                  Instances For
                                                                    Dependency graph
                                                                    theorem DescriptiveComplexity.ParamTCSpec.reachAt_flat_iff {L : FirstOrder.Language} {B : SOBlock} (S : ParamTCSpec ((L.sum FirstOrder.Language.order).sum B.lang)) (D : S.Mode → S.Mode → Decider L ((Fin S.k ⊕ Fin S.k) ⊕ Fin S.par)) {A : Type} [L.Structure A] [LinearOrder A] [instE : ((L.sum FirstOrder.Language.order).sum B.lang).Structure A] {z : Fin S.par → A} [Nonempty A] (hD : S.DecidesSteps D z) {a₀ : A} (hbot : ∀ (a : A), a₀ ≤ a) (a b : S.Node A) :
                                                                    (S.flat D false).ReachAt z (S.flatEnc D false a₀ a) (S.flatEnc D false a₀ b) ↔ S.ReachAt z a b

                                                                    Guessing simulates the outer walk, at the encodings.

                                                                    Dependency graph
                                                                    theorem DescriptiveComplexity.ParamTCSpec.reachAt_flat_iff_of_functional {L : FirstOrder.Language} {B : SOBlock} (S : ParamTCSpec ((L.sum FirstOrder.Language.order).sum B.lang)) (D : S.Mode → S.Mode → Decider L ((Fin S.k ⊕ Fin S.k) ⊕ Fin S.par)) {A : Type} [L.Structure A] [LinearOrder A] [instE : ((L.sum FirstOrder.Language.order).sum B.lang).Structure A] {z : Fin S.par → A} [Nonempty A] [Finite A] (hD : S.DecidesSteps D z) {a₀ : A} (hbot : ∀ (a : A), a₀ ≤ a) (hS : ∀ (a b c : S.Node A), S.StepAt z a b → S.StepAt z a c → b = c) (a b : S.Node A) :
                                                                    (S.flat D true).ReachAt z (S.flatEnc D true a₀ a) (S.flatEnc D true a₀ b) ↔ S.ReachAt z a b

                                                                    Searching simulates a functional outer walk, at the encodings.

                                                                    Dependency graph

                                                                    Functionality of the searching flat walk #

                                                                    theorem DescriptiveComplexity.ParamTCSpec.functional_flat {L : FirstOrder.Language} {B : SOBlock} (S : ParamTCSpec ((L.sum FirstOrder.Language.order).sum B.lang)) (D : S.Mode → S.Mode → Decider L ((Fin S.k ⊕ Fin S.k) ⊕ Fin S.par)) {A : Type} [L.Structure A] [LinearOrder A] [Nonempty A] (hDf : ∀ (p : S.Mode × S.Mode), (D p.1 p.2).Functional A) :

                                                                    The searching flat walk is functional when the deciders are.

                                                                    Dependency graph