Langlib

Langlib.Grammars.ContextSensitive.Definition

Context-Sensitive Grammar Definitions #

This file defines context-sensitive grammars, their derivations, and the induced language predicate.

A context-sensitive grammar has rules of the form αAβ → αγβ where:

The non-emptiness requirement on γ ensures that derivation steps never decrease the length of the sentential form, which is the defining property of context-sensitive grammars.

Main declarations #

structure csrule (T N : Type) :

Transformation rule for a context-sensitive grammar.

A rule αAβ → αγβ where α is context_left, A is input_nonterminal, β is context_right, and γ is output_string.

Instances For
    structure CS_grammar (T : Type) :

    Context-sensitive grammar that generates words over the alphabet T (a type of terminals).

    The output_nonempty field ensures that every rule has a non-empty output string, matching the standard definition of context-sensitive grammars. This guarantees that derivation steps never decrease the length of the sentential form.

    Instances For
      def CS_transforms {T : Type} (g : CS_grammar T) (w₁ w₂ : List (symbol T g.nt)) :

      One step of context-sensitive transformation.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        def CS_derives {T : Type} (g : CS_grammar T) :
        List (symbol T g.nt)List (symbol T g.nt)Prop

        Any number of steps of context-sensitive transformation; reflexive+transitive closure of CS_transforms.

        Equations
        Instances For
          def CS_language {T : Type} (g : CS_grammar T) :

          The Set of words that can be derived from the initial nonterminal.

          Equations
          Instances For