Documentation

Complexity.Logics.FirstOrder.Basic

First-order formula and sentence combinators #

This file provides reusable first-order formula and sentence combinators over FirstOrder.Language:

Main definitions #

Main results #

References #

Closure and atomic combinators #

noncomputable def Cslib.Logic.FO.closeAll {L : FirstOrder.Language} (V : Type) [Finite V] (φ : L.Formula V) :

Universal closure of a formula over a finite type of free variables.

Instances For
    noncomputable def Cslib.Logic.FO.closeEx {L : FirstOrder.Language} (V : Type) [Finite V] (φ : L.Formula V) :

    Existential closure of a formula over a finite type of free variables.

    Instances For
      @[simp]
      theorem Cslib.Logic.FO.realize_closeAll {L : FirstOrder.Language} {M : Type w} [L.Structure M] (V : Type) [Finite V] (φ : L.Formula V) :
      M ⊨ closeAll V φ ↔ ∀ (v : V → M), φ.Realize v

      The universal closure holds exactly when the formula holds under every assignment of its free variables.

      @[simp]
      theorem Cslib.Logic.FO.realize_closeEx {L : FirstOrder.Language} {M : Type w} [L.Structure M] (V : Type) [Finite V] (φ : L.Formula V) :
      M ⊨ closeEx V φ ↔ ∃ (v : V → M), φ.Realize v

      The existential closure holds exactly when the formula holds under some assignment of its free variables.

      def Cslib.Logic.FO.atVar {L : FirstOrder.Language} (φ : L.Formula (Fin 1)) {V : Type u_1} (u : V) :

      Relabel a single-variable formula φ : L.Formula (Fin 1) to free variable u : V.

      Instances For
        @[simp]
        theorem Cslib.Logic.FO.realize_atVar {L : FirstOrder.Language} {M : Type w} [L.Structure M] (φ : L.Formula (Fin 1)) {V : Type u_1} (v : V → M) (u : V) :
        (atVar φ u).Realize v ↔ φ.Realize ![v u]
        def Cslib.Logic.FO.varEq {L : FirstOrder.Language} {V : Type u_1} (u w : V) :

        Equality of two free variables as a formula.

        Instances For
          def Cslib.Logic.FO.rel₁ {L : FirstOrder.Language} {V : Type u_1} (r : L.Relations 1) (u : V) :

          Application of a unary relation symbol to a free variable.

          Instances For
            def Cslib.Logic.FO.rel₂ {L : FirstOrder.Language} {V : Type u_1} (r : L.Relations 2) (u w : V) :

            Application of a binary relation symbol to two free variables.

            Instances For
              @[simp]
              theorem Cslib.Logic.FO.realize_varEq {L : FirstOrder.Language} {M : Type w} [L.Structure M] {V : Type u_1} (v : V → M) (u w : V) :
              (varEq u w).Realize v ↔ v u = v w
              @[simp]
              theorem Cslib.Logic.FO.realize_rel₁ {L : FirstOrder.Language} {M : Type w} [L.Structure M] {V : Type u_1} (v : V → M) (r : L.Relations 1) (u : V) :
              @[simp]
              theorem Cslib.Logic.FO.realize_rel₂ {L : FirstOrder.Language} {M : Type w} [L.Structure M] {V : Type u_1} (v : V → M) (r : L.Relations 2) (u w : V) :
              theorem Cslib.Logic.FO.formula_realize_top {L : FirstOrder.Language} {M : Type w} [L.Structure M] {V : Type u_1} {v : V → M} :

              The formula ⊤ holds, as a term.

              An isomorphism preserves a binary relation on pairs.

              An isomorphism preserves a unary relation.

              Order combinators on Fin B #

              def Cslib.Logic.FO.lt {L : FirstOrder.Language} (r : L.Relations 2) {V : Type u_1} (u w : V) :

              The strict order formula u < w with respect to a binary relation symbol r.

              Instances For
                def Cslib.Logic.FO.le {L : FirstOrder.Language} (r : L.Relations 2) {V : Type u_1} (u w : V) :

                The weak order formula u ≤ w (¬ (w < u)) with respect to r.

                Instances For
                  def Cslib.Logic.FO.isZero {L : FirstOrder.Language} (r : L.Relations 2) {V : Type u_1} (u : V) :

                  The formula ∀ z, ¬ (z < u), characterizing the minimum element 0 of Fin B.

                  Instances For
                    def Cslib.Logic.FO.isMax {L : FirstOrder.Language} (r : L.Relations 2) {V : Type u_1} (u : V) :

                    The formula ∀ z, ¬ (u < z), characterizing the maximum element B - 1 of Fin B.

                    Instances For
                      def Cslib.Logic.FO.succ {L : FirstOrder.Language} (r : L.Relations 2) {V : Type u_1} (u w : V) :

                      The successor formula u < w ∧ ∀ z, ¬ (u < z) ∨ ¬ (z < w), characterizing (w : ℕ) = (u : ℕ) + 1 on Fin B.

                      Instances For
                        noncomputable def Cslib.Logic.FO.isFirstOut {L : FirstOrder.Language} (r : L.Relations 2) (inDom : L.Formula (Fin 1)) {V : Type u_1} (u : V) :

                        Given a domain formula inDom : L.Formula (Fin 1) holding of < M, the formula isFirstOut r inDom u asserts ¬ inDom(u) ∧ ∀ k < u, inDom(k), holding solely of M.

                        Instances For
                          theorem Cslib.Logic.FO.realize_lt {L : FirstOrder.Language} {B : ℕ} [L.Structure (Fin B)] {r : L.Relations 2} (hlt : ∀ (x : Fin 2 → Fin B), FirstOrder.Language.Structure.RelMap r x ↔ x 0 < x 1) {V : Type u_1} (v : V → Fin B) (u w : V) :
                          (lt r u w).Realize v ↔ v u < v w
                          theorem Cslib.Logic.FO.realize_le {L : FirstOrder.Language} {B : ℕ} [L.Structure (Fin B)] {r : L.Relations 2} (hlt : ∀ (x : Fin 2 → Fin B), FirstOrder.Language.Structure.RelMap r x ↔ x 0 < x 1) {V : Type u_1} (v : V → Fin B) (u w : V) :
                          (le r u w).Realize v ↔ v u ≤ v w
                          theorem Cslib.Logic.FO.realize_isZero {L : FirstOrder.Language} {B : ℕ} [L.Structure (Fin B)] {r : L.Relations 2} (hlt : ∀ (x : Fin 2 → Fin B), FirstOrder.Language.Structure.RelMap r x ↔ x 0 < x 1) {V : Type u_1} (v : V → Fin B) (u : V) :
                          (isZero r u).Realize v ↔ ↑(v u) = 0

                          On Fin B, with r read as <, isZero r u holds exactly when u is assigned 0.

                          theorem Cslib.Logic.FO.realize_isMax {L : FirstOrder.Language} {B : ℕ} [L.Structure (Fin B)] {r : L.Relations 2} (hlt : ∀ (x : Fin 2 → Fin B), FirstOrder.Language.Structure.RelMap r x ↔ x 0 < x 1) {V : Type u_1} (v : V → Fin B) (u : V) :
                          (isMax r u).Realize v ↔ ↑(v u) = B - 1

                          On Fin B, with r read as <, isMax r u holds exactly when u is assigned B - 1.

                          theorem Cslib.Logic.FO.realize_succ {L : FirstOrder.Language} {B : ℕ} [L.Structure (Fin B)] {r : L.Relations 2} (hlt : ∀ (x : Fin 2 → Fin B), FirstOrder.Language.Structure.RelMap r x ↔ x 0 < x 1) {V : Type u_1} (v : V → Fin B) (u w : V) :
                          (succ r u w).Realize v ↔ ↑(v w) = ↑(v u) + 1

                          On Fin B, with r read as <, succ r u w holds exactly when w is assigned the successor of the value of u.

                          theorem Cslib.Logic.FO.realize_isFirstOut {L : FirstOrder.Language} {B : ℕ} [L.Structure (Fin B)] {r : L.Relations 2} (hlt : ∀ (x : Fin 2 → Fin B), FirstOrder.Language.Structure.RelMap r x ↔ x 0 < x 1) {inDom : L.Formula (Fin 1)} {M : ℕ} (hMB : M < B) (hdom : ∀ (j : Fin B), inDom.Realize ![j] ↔ ↑j < M) {V : Type u_1} (v : V → Fin B) (u : V) :
                          (isFirstOut r inDom u).Realize v ↔ ↑(v u) = M

                          On Fin B, with r read as < and a domain formula holding exactly below M < B, isFirstOut r inDom u holds exactly when u is assigned M.

                          Finite-domain cardinality and truth-table sentences #

                          On a finite structure M, Mathlib's Sentence.cardGe L n holds iff n ≤ Nat.card M.

                          The first-order sentence Sentence.cardGe L n ⊓ ∼(Sentence.cardGe L (n + 1)), which holds on a finite structure M iff Nat.card M = n.

                          Instances For
                            @[simp]

                            On a finite structure, cardEqSentence L n holds exactly when the structure has n elements.

                            noncomputable def Cslib.Logic.FO.truthTableSentence {L : FirstOrder.Language} {m : ℕ} (φ : Fin m → L.Sentence) (P : (Fin m → Bool) → Prop) :

                            Given m sentences φ and a predicate P on bit vectors Fin m → Bool, the first-order sentence asserting that the truth values i ↦ (M ⊨ φ i) satisfy P.

                            Instances For
                              @[simp]
                              theorem Cslib.Logic.FO.realize_truthTableSentence {L : FirstOrder.Language} {M : Type w} [L.Structure M] {m : ℕ} (φ : Fin m → L.Sentence) (P : (Fin m → Bool) → Prop) :
                              M ⊨ truthTableSentence φ P ↔ P fun (i : Fin m) => decide (M ⊨ φ i)

                              truthTableSentence φ P holds exactly when the truth values of the sentences φ i satisfy P.