Documentation

DescriptiveComplexity.Computability.Reduction

First-order reductions are computable #

The last step of the bridge that does not need a machine: a first-order interpretation induces a computable map of concrete structures, so ¬ComputablePred transfers backwards along every reduction notion of the library – ≤ᶠᵒ, ≤ᶠᵒ[≤] and ≤ʳᶠᵒ[≤].

Everything is proved for the most general notion, the relativized ordered reduction; the other two are special cases of it (DescriptiveComplexity.FOReduction.toOrdered, DescriptiveComplexity.OrderedFOReduction.toRel).

What has to be computed #

Three things, in this order.

The defining formulas have free variables indexed by Fin n × Fin dim, while the evaluator of DescriptiveComplexity.Computability.Eval is written for sentences; DescriptiveComplexity.flatFormula flattens the former into the latter through Fin.finProdFinEquiv and FirstOrder.Language.BoundedFormula.relabel.

The ordered expansion of an instance, as data #

The one-symbol vocabulary of the order, presented.

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

    The rows of the table of an instance, cut to exactly one row per symbol. Appending anything to a raw table could otherwise be read as the row of a symbol whose row was missing.

    Equations
    Instances For
      Dependency graph
      Dependency graph
      Dependency graph

      The ordered expansion of an instance, as data: the same universe, the same rows, and one more row for the order of Fin (n + 1).

      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

        The data is the ordered expansion: the identity is an isomorphism from the encoded ordered expansion to the instance's universe with its own linear order.

        Equations
        Instances For
          Dependency graph
          Dependency graph

          Numbering the tagged tuples #

          A point of the target universe of an interpretation is a tag together with a dim-tuple of elements of the instance. It is numbered by putting the tag in the units digit, base |Tag|, and the tuple above it.

          def DescriptiveComplexity.ptIdx {L : FirstOrder.Language} {V : L.FinVocab} {Tag : Type} {dim : } (T : ) (tagEq : Fin (T + 1) Tag) (s : FirstOrder.Language.FinStruct V) (p : Tag × (Fin dims.Univ)) :

          The number of a tagged tuple.

          Equations
          Instances For
            Dependency graph
            def DescriptiveComplexity.ptOfIdx {L : FirstOrder.Language} {V : L.FinVocab} {Tag : Type} (T : ) (tagEq : Fin (T + 1) Tag) (dim : ) (s : FirstOrder.Language.FinStruct V) (u : ) :
            Tag × (Fin dims.Univ)

            The tagged tuple with a given number.

            Equations
            Instances For
              Dependency graph
              theorem DescriptiveComplexity.ptIdx_lt {L : FirstOrder.Language} {V : L.FinVocab} {Tag : Type} {dim : } (T : ) (tagEq : Fin (T + 1) Tag) (s : FirstOrder.Language.FinStruct V) (p : Tag × (Fin dims.Univ)) :
              ptIdx T tagEq s p < (T + 1) * s.card ^ dim
              Dependency graph
              theorem DescriptiveComplexity.ptOfIdx_ptIdx {L : FirstOrder.Language} {V : L.FinVocab} {Tag : Type} {dim : } (T : ) (tagEq : Fin (T + 1) Tag) (s : FirstOrder.Language.FinStruct V) (p : Tag × (Fin dims.Univ)) :
              ptOfIdx T tagEq dim s (ptIdx T tagEq s p) = p
              Dependency graph
              theorem DescriptiveComplexity.ptIdx_ptOfIdx {L : FirstOrder.Language} {V : L.FinVocab} {Tag : Type} {dim : } (T : ) (tagEq : Fin (T + 1) Tag) (s : FirstOrder.Language.FinStruct V) {u : } (hu : u < (T + 1) * s.card ^ dim) :
              ptIdx T tagEq s (ptOfIdx T tagEq dim s u) = u
              Dependency graph

              Flattening the defining formulas #

              The evaluator of DescriptiveComplexity.Computability.Eval is written for formulas with no free variables, while a defining formula has free variables indexed by Fin n × Fin dim and a domain formula by Fin dim. Both are relabelled into bound variables, the pairs through finProdFinEquiv.

              def DescriptiveComplexity.flatRel {L L' : FirstOrder.Language} {Tag : Type} {dim : } (I : RelFOInterpretation (L.sum FirstOrder.Language.order) L' Tag dim) {n : } (R : L'.Relations n) (τ : Fin nTag) :

              A defining formula, with its free variables turned into bound ones.

              Equations
              Instances For
                Dependency graph

                A domain formula, with its free variables turned into bound ones.

                Equations
                Instances For
                  Dependency graph
                  theorem DescriptiveComplexity.realize_flatRel {L L' : FirstOrder.Language} {Tag : Type} {dim : } (I : RelFOInterpretation (L.sum FirstOrder.Language.order) L' Tag dim) {M : Type} [(L.sum FirstOrder.Language.order).Structure M] {n : } (R : L'.Relations n) (τ : Fin nTag) (v : EmptyM) (x : Fin (n * dim)M) :
                  (flatRel I R τ).Realize v x (I.relFormula R τ).Realize (x finProdFinEquiv)
                  Dependency graph
                  theorem DescriptiveComplexity.realize_flatDom {L L' : FirstOrder.Language} {Tag : Type} {dim : } (I : RelFOInterpretation (L.sum FirstOrder.Language.order) L' Tag dim) {M : Type} [(L.sum FirstOrder.Language.order).Structure M] (t : Tag) (v : EmptyM) (x : Fin dimM) :
                  Dependency graph

                  Evaluating the defining formulas at numbered points #

                  Evaluating a formula on the encoded ordered expansion is realizing it on the instance's universe with its own linear order.

                  Dependency graph

                  The valuation read off a list of digits is the tuple those digits are.

                  Dependency graph
                  def DescriptiveComplexity.domBool {L L' : FirstOrder.Language} [L.IsRelational] {Tag : Type} {dim : } (I : RelFOInterpretation (L.sum FirstOrder.Language.order) L' Tag dim) (T : ) (tagEq : Fin (T + 1) Tag) (V : L.FinVocab) (s : FirstOrder.Language.FinStruct V) (u : ) :

                  Does the point numbered u survive the domain formula? The tag is only known at run time, so all |Tag| domain formulas are evaluated and the right one is selected.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For
                    Dependency graph
                    theorem DescriptiveComplexity.domBool_iff {L L' : FirstOrder.Language} [L.IsRelational] {Tag : Type} {dim : } (I : RelFOInterpretation (L.sum FirstOrder.Language.order) L' Tag dim) (T : ) (tagEq : Fin (T + 1) Tag) (V : L.FinVocab) (s : FirstOrder.Language.FinStruct V) (u : ) :
                    domBool I T tagEq V s u = true (I.domFormula (ptOfIdx T tagEq dim s u).1).Realize (ptOfIdx T tagEq dim s u).2
                    Dependency graph
                    def DescriptiveComplexity.relBool {L L' : FirstOrder.Language} [L.IsRelational] {Tag : Type} {dim : } (I : RelFOInterpretation (L.sum FirstOrder.Language.order) L' Tag dim) (T : ) (tagEq : Fin (T + 1) Tag) (V : L.FinVocab) (s : FirstOrder.Language.FinStruct V) {n : } (R : L'.Relations n) (p : List ) :

                    The value of a defining formula at a tuple of numbered points. The tags are only known at run time, so all |Tag|ⁿ instances of the formula are evaluated and the right one is selected.

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For
                      Dependency graph
                      theorem DescriptiveComplexity.valOf_ofFn_pair {L : FirstOrder.Language} {dim : } (T : ) (V : L.FinVocab) (s : FirstOrder.Language.FinStruct V) {n : } (p : List ) (q : Fin n × Fin dim) :
                      (ordStruct V s).valOf (List.ofFn fun (q' : Fin (n * dim)) => FirstOrder.Language.digitAt s.card (p.getD (↑(finProdFinEquiv.symm q').1) 0 / (T + 1)) (finProdFinEquiv.symm q').2) (finProdFinEquiv q) = FirstOrder.Language.digitAt s.card (p.getD (↑q.1) 0 / (T + 1)) q.2,

                      The valuation read off the pair-indexed list of digits.

                      Dependency graph
                      theorem DescriptiveComplexity.relBool_iff {L L' : FirstOrder.Language} [L.IsRelational] {Tag : Type} {dim : } (I : RelFOInterpretation (L.sum FirstOrder.Language.order) L' Tag dim) (T : ) (tagEq : Fin (T + 1) Tag) (V : L.FinVocab) (s : FirstOrder.Language.FinStruct V) {n : } (R : L'.Relations n) (p : List ) :
                      relBool I T tagEq V s R p = true (I.relFormula R fun (i : Fin n) => (ptOfIdx T tagEq dim s (p.getD (↑i) 0)).1).Realize fun (q : Fin n × Fin dim) => (ptOfIdx T tagEq dim s (p.getD (↑q.1) 0)).2 q.2
                      Dependency graph

                      The surviving points, and the image instance #

                      The numbers of the points that survive the domain formula, in increasing order: the renumbering of the target universe is the position in this list.

                      Equations
                      Instances For
                        Dependency graph
                        theorem DescriptiveComplexity.mem_goodList {L L' : FirstOrder.Language} [L.IsRelational] {Tag : Type} {dim : } (I : RelFOInterpretation (L.sum FirstOrder.Language.order) L' Tag dim) (T : ) (tagEq : Fin (T + 1) Tag) (V : L.FinVocab) (s : FirstOrder.Language.FinStruct V) (u : ) :
                        u goodList I T tagEq V s u < (T + 1) * s.card ^ dim domBool I T tagEq V s u = true
                        Dependency graph
                        theorem DescriptiveComplexity.nodup_goodList {L L' : FirstOrder.Language} [L.IsRelational] {Tag : Type} {dim : } (I : RelFOInterpretation (L.sum FirstOrder.Language.order) L' Tag dim) (T : ) (tagEq : Fin (T + 1) Tag) (V : L.FinVocab) (s : FirstOrder.Language.FinStruct V) :
                        (goodList I T tagEq V s).Nodup
                        Dependency graph
                        theorem DescriptiveComplexity.getD_goodList_mem {L L' : FirstOrder.Language} [L.IsRelational] {Tag : Type} {dim : } (I : RelFOInterpretation (L.sum FirstOrder.Language.order) L' Tag dim) (T : ) (tagEq : Fin (T + 1) Tag) (V : L.FinVocab) (s : FirstOrder.Language.FinStruct V) {j : } (hj : j < (goodList I T tagEq V s).length) :
                        (goodList I T tagEq V s).getD j 0 goodList I T tagEq V s
                        Dependency graph
                        noncomputable def DescriptiveComplexity.mapStruct {L L' : FirstOrder.Language} [L.IsRelational] {Tag : Type} {dim : } (I : RelFOInterpretation (L.sum FirstOrder.Language.order) L' Tag dim) (T : ) (tagEq : Fin (T + 1) Tag) (V : L.FinVocab) (V' : L'.FinVocab) (s : FirstOrder.Language.FinStruct V) :

                        The image of an instance under a relativized interpretation, as data. The universe is the list of surviving points, renumbered by position; a relation holds of a tuple exactly when the defining formula does of the points it names.

                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For
                          Dependency graph
                          @[simp]
                          theorem DescriptiveComplexity.card_mapStruct {L L' : FirstOrder.Language} [L.IsRelational] {Tag : Type} {dim : } (I : RelFOInterpretation (L.sum FirstOrder.Language.order) L' Tag dim) (T : ) (tagEq : Fin (T + 1) Tag) (V : L.FinVocab) (V' : L'.FinVocab) (s : FirstOrder.Language.FinStruct V) :
                          (mapStruct I T tagEq V V' s).card = (goodList I T tagEq V s).length - 1 + 1
                          Dependency graph
                          theorem DescriptiveComplexity.relMapBool_mapStruct {L L' : FirstOrder.Language} [L.IsRelational] {Tag : Type} {dim : } (I : RelFOInterpretation (L.sum FirstOrder.Language.order) L' Tag dim) (T : ) (tagEq : Fin (T + 1) Tag) (V : L.FinVocab) (V' : L'.FinVocab) (s : FirstOrder.Language.FinStruct V) {a : } (R' : L'.Relations a) (x : Fin a(mapStruct I T tagEq V V' s).Univ) :
                          (mapStruct I T tagEq V V' s).relMapBool R' x = relBool I T tagEq V s R' (List.ofFn fun (j : Fin a) => (goodList I T tagEq V s).getD (↑(x j)) 0)
                          Dependency graph

                          Everything above is primitive recursive #

                          theorem DescriptiveComplexity.filter_eq_flatMap (p : Bool) (l : List ) :
                          List.filter p l = List.flatMap (fun (a : ) => bif p a then [a] else []) l
                          Dependency graph
                          theorem DescriptiveComplexity.primrec_domBool {L L' : FirstOrder.Language} [L.IsRelational] {Tag : Type} {dim : } (I : RelFOInterpretation (L.sum FirstOrder.Language.order) L' Tag dim) (T : ) (tagEq : Fin (T + 1) Tag) (V : L.FinVocab) :
                          Primrec fun (q : FirstOrder.Language.FinStruct V × ) => domBool I T tagEq V q.1 q.2
                          Dependency graph
                          theorem DescriptiveComplexity.primrec_relBool {L L' : FirstOrder.Language} [L.IsRelational] {Tag : Type} {dim : } (I : RelFOInterpretation (L.sum FirstOrder.Language.order) L' Tag dim) (T : ) (tagEq : Fin (T + 1) Tag) (V : L.FinVocab) {n : } (R : L'.Relations n) :
                          Primrec fun (q : FirstOrder.Language.FinStruct V × List ) => relBool I T tagEq V q.1 R q.2
                          Dependency graph
                          theorem DescriptiveComplexity.primrec_goodList {L L' : FirstOrder.Language} [L.IsRelational] {Tag : Type} {dim : } (I : RelFOInterpretation (L.sum FirstOrder.Language.order) L' Tag dim) (T : ) (tagEq : Fin (T + 1) Tag) (V : L.FinVocab) :
                          Primrec fun (s : FirstOrder.Language.FinStruct V) => goodList I T tagEq V s
                          Dependency graph
                          theorem DescriptiveComplexity.primrec_mapStruct {L L' : FirstOrder.Language} [L.IsRelational] {Tag : Type} {dim : } (I : RelFOInterpretation (L.sum FirstOrder.Language.order) L' Tag dim) (T : ) (tagEq : Fin (T + 1) Tag) (V : L.FinVocab) (V' : L'.FinVocab) :
                          Primrec fun (s : FirstOrder.Language.FinStruct V) => mapStruct I T tagEq V V' s
                          Dependency graph

                          The data is the image structure #

                          theorem DescriptiveComplexity.getD_ofFn_nat {a : } (g : Fin a) (i : Fin a) :
                          (List.ofFn g).getD (↑i) 0 = g i
                          Dependency graph
                          noncomputable def DescriptiveComplexity.mapIso {L L' : FirstOrder.Language} [L.IsRelational] [L'.IsRelational] {Tag : Type} {dim : } (I : RelFOInterpretation (L.sum FirstOrder.Language.order) L' Tag dim) (T : ) (tagEq : Fin (T + 1) Tag) (V : L.FinVocab) (V' : L'.FinVocab) (s : FirstOrder.Language.FinStruct V) (hne : 0 < (goodList I T tagEq V s).length) :
                          L'.Equiv (mapStruct I T tagEq V V' s).Univ (I.MapRel s.Univ)

                          The renumbering is an isomorphism: the encoded image of an instance is the relativized interpretation of that instance.

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

                            Decidability transfers along reductions #

                            A relativized ordered reduction is a computable many-one reduction of the induced sets of concrete instances: if the target is decidable, so is the source.

                            The renumbering forced by the definable domain is the whole content; the interpretation itself is an evaluation of fixed formulas, primitive recursive by FirstOrder.Language.FinStruct.primrec_evalBF.

                            Dependency graph

                            ¬ComputablePred transfers backwards along a relativized ordered reduction.

                            Dependency graph
                            Dependency graph

                            The same for a plain first-order reduction.

                            Dependency graph