Documentation

Linglib.Core.Computability.SyntacticMonoid

The syntactic monoid of a language #

The syntactic monoid of a language L : Language α is the quotient of the free monoid FreeMonoid α by the syntactic congruence Con.syntactic of L: two words are identified when no two-sided context distinguishes them as L-members, ∀ x y, x ++ u ++ y ∈ L ↔ x ++ v ++ y ∈ L.

It is the coarsest congruence saturating L, so the syntactic morphism factors through every recognizing homomorphism, and the quotient is finite exactly when L is regular. This is the two-sided refinement of the one-sided right-Nerode quotient Language.leftQuotient, carrying a monoid structure rather than a bare set of states.

Main definitions #

Main results #

References #

The syntactic congruence and monoid #

def Language.syntacticCon {α : Type u_1} (L : Language α) :
Con (FreeMonoid α)

The syntactic congruence of L is the syntactic congruence of its words in the free monoid.

Equations
Instances For
    theorem Language.syntacticCon_iff {α : Type u_1} {L : Language α} {u v : FreeMonoid α} :
    L.syntacticCon u v ↔ ∀ (x y : List α), x ++ FreeMonoid.toList u ++ y ∈ L ↔ x ++ FreeMonoid.toList v ++ y ∈ L
    theorem Language.syntacticCon_iff_leftQuotient {α : Type u_1} {L : Language α} {u v : FreeMonoid α} :
    L.syntacticCon u v ↔ ∀ (x : List α), L.leftQuotient (x ++ FreeMonoid.toList u) = L.leftQuotient (x ++ FreeMonoid.toList v)
    @[reducible, inline]
    abbrev Language.SyntacticMonoid {α : Type u_1} (L : Language α) :
    Type u_1

    The syntactic monoid of L is the quotient of FreeMonoid α by the syntactic congruence.

    Equations
    Instances For
      def Language.toSyntacticMonoid {α : Type u_1} (L : Language α) :
      FreeMonoid α →* L.SyntacticMonoid

      The syntactic morphism of L projects FreeMonoid α onto the syntactic monoid.

      Equations
      Instances For
        theorem Language.toSyntacticMonoid_eq_iff {α : Type u_1} {L : Language α} {u v : FreeMonoid α} :
        theorem Language.ker_toSyntacticMonoid {α : Type u_1} (L : Language α) :

        The syntactic class of a word #

        def Language.syntacticClass {α : Type u_1} (L : Language α) (w : List α) :

        The syntactic class of a word w is its image in the syntactic monoid.

        Equations
        Instances For
          @[simp]
          theorem Language.syntacticClass_nil {α : Type u_1} (L : Language α) :
          @[simp]
          theorem Language.syntacticClass_append {α : Type u_1} (L : Language α) (u v : List α) :
          theorem Language.syntacticClass_flatten {α : Type u_1} (L : Language α) (ws : List (List α)) :
          L.syntacticClass ws.flatten = (List.map L.syntacticClass ws).prod
          theorem Language.syntacticClass_surjective {α : Type u_1} (L : Language α) :
          Function.Surjective L.syntacticClass
          theorem Language.syntacticClass_eq_iff {α : Type u_1} {L : Language α} {u v : List α} :
          L.syntacticClass u = L.syntacticClass v ↔ ∀ (x y : List α), x ++ u ++ y ∈ L ↔ x ++ v ++ y ∈ L
          theorem Language.mem_iff_of_syntacticClass_eq {α : Type u_1} {L : Language α} {u v : List α} (h : L.syntacticClass u = L.syntacticClass v) :
          u ∈ L ↔ v ∈ L
          theorem Language.syntacticClass_reverse_eq_iff {α : Type u_1} {L : Language α} {u v : List α} :
          L.reverse.syntacticClass u = L.reverse.syntacticClass v ↔ L.syntacticClass u.reverse = L.syntacticClass v.reverse

          Universal property #

          def Language.Recognizes {α : Type u_1} {M : Type u_2} [Monoid M] (φ : FreeMonoid α →* M) (L : Language α) :

          φ recognizes L when L is the FreeMonoid.ofList-pullback of a union of φ-fibres.

          Equations
          Instances For
            theorem Language.recognizes_iff_ker_le {α : Type u_1} {L : Language α} {M : Type u_2} [Monoid M] {φ : FreeMonoid α →* M} :
            Recognizes φ L ↔ Con.ker φ ≤ L.syntacticCon
            theorem Language.ker_le_syntacticCon_of_recognizes {α : Type u_1} {L : Language α} {M : Type u_2} [Monoid M] {φ : FreeMonoid α →* M} (hrec : Recognizes φ L) :
            Con.ker φ ≤ L.syntacticCon
            theorem Language.Recognizes.comap {α : Type u_1} {L : Language α} {M : Type u_2} [Monoid M] {φ : FreeMonoid α →* M} {β : Type u_3} (hrec : Recognizes φ L) (ψ : FreeMonoid β →* FreeMonoid α) :
            Recognizes (φ.comp ψ) {w : List β | ψ (FreeMonoid.ofList w) ∈ L}
            theorem Language.Recognizes.syntacticMonoid_isSubquotient {α : Type u_1} {L : Language α} {M : Type u_2} [Monoid M] {φ : FreeMonoid α →* M} (hrec : Recognizes φ L) :

            Connection to the minimal DFA #

            theorem Language.recognizes_transitionHom {α : Type u_1} {σ : Type u_2} (M : DFA α σ) :
            @[simp]
            theorem Language.evalFrom_toDFA {α : Type u_1} {L : Language α} (s : ↑(Set.range L.leftQuotient)) (w : List α) :
            ↑(L.toDFA.evalFrom s w) = (↑s).leftQuotient w
            theorem Language.ker_transitionHom_toDFA_iff {α : Type u_1} {L : Language α} {u v : FreeMonoid α} :
            (Con.ker L.toDFA.transitionHom) u v ↔ ∀ (x : List α), L.leftQuotient (x ++ FreeMonoid.toList u) = L.leftQuotient (x ++ FreeMonoid.toList v)
            theorem Language.syntacticCon_eq_ker_transitionHom {α : Type u_1} {L : Language α} :
            L.syntacticCon = Con.ker L.toDFA.transitionHom
            noncomputable def Language.syntacticMonoidEquivTransitionMonoid {α : Type u_1} (L : Language α) :

            The syntactic monoid of L is the transition monoid of its minimal DFA.

            Equations
            Instances For

              Myhill–Nerode #

              theorem Language.IsRegular.finite_syntacticMonoid {α : Type u_1} {L : Language α} (h : L.IsRegular) :
              theorem Language.IsRegular.of_finite_syntacticMonoid {α : Type u_1} {L : Language α} (h : Finite L.SyntacticMonoid) :
              L.IsRegular
              theorem Language.isRegular_iff_finite_syntacticMonoid {α : Type u_1} {L : Language α} :
              L.IsRegular ↔ Finite L.SyntacticMonoid

              L is regular iff L.SyntacticMonoid is finite.

              Boolean combinations #

              theorem Language.syntacticCon_compl {α : Type u_1} {L : Language α} :
              theorem Language.inf_syntacticCon_le_syntacticCon_inf {α : Type u_1} {L L' : Language α} :
              L.syntacticCon ⊓ L'.syntacticCon ≤ (L ⊓ L').syntacticCon
              theorem Language.inf_syntacticCon_le_syntacticCon_sup {α : Type u_1} {L L' : Language α} :
              L.syntacticCon ⊓ L'.syntacticCon ≤ (L ⊔ L').syntacticCon
              theorem Language.subsingleton_syntacticMonoid_iff {α : Type u_1} {L : Language α} :
              Subsingleton L.SyntacticMonoid ↔ L = ⊥ ∨ L = ⊤

              The syntactic monoid of L is trivial exactly when L is empty or full.

              Quotients #

              def Language.rightQuotient {α : Type u_1} (L : Language α) (u : List α) :
              Language α

              The right quotient of L by u is the set of prefixes w such that w ++ u is in L.

              Equations
              Instances For
                @[simp]
                theorem Language.mem_rightQuotient {α : Type u_1} {L : Language α} {u w : List α} :
                w ∈ L.rightQuotient u ↔ w ++ u ∈ L
                @[simp]
                theorem Language.rightQuotient_nil {α : Type u_1} (L : Language α) :
                L.rightQuotient [] = L
                theorem Language.rightQuotient_append {α : Type u_1} (L : Language α) (u v : List α) :
                theorem Language.rightQuotient_eq_reverse_leftQuotient {α : Type u_1} (L : Language α) (u : List α) :
                L.rightQuotient u = (L.reverse.leftQuotient u.reverse).reverse
                theorem Language.syntacticCon_le_leftQuotient {α : Type u_1} (L : Language α) (u : List α) :
                L.syntacticCon ≤ (L.leftQuotient u).syntacticCon
                theorem Language.syntacticCon_le_rightQuotient {α : Type u_1} (L : Language α) (u : List α) :