Langlib

Langlib.Grammars.LR.Equivalence.Endmarker

Removing an explicit endmarker #

An LR parser can read a fresh marker to make end-of-input observable. This file packages the language-level step which removes that implementation device: quotient by the singleton marker, then pull the result back along the injective Option.some embedding.

def endmarked {T : Type} (L : Language T) :

Append a fresh none endmarker after embedding every original terminal with some.

Equations
Instances For

    The regular shape language consisting of any number of embedded terminals followed by exactly one endmarker.

    Equations
    Instances For

      Properly endmarked words form a regular language.

      theorem is_DCF_endmarked_of_marked_machine {T : Type} [Fintype T] (L : Language T) (K : Language (Option T)) (hK : is_DCF K) (hcorrect : ∀ (w : List T), List.map some w ++ [none] K w L) :

      It suffices for a DPDA implementation to be correct on properly marked inputs. Intersecting its language with the regular marker-shape language removes any behavior it may have on malformed encodings.

      Removing the final marker from an endmarked language leaves exactly the letterwise some image of the original language.

      theorem is_DCF_of_is_DCF_endmarked {T : Type} [Fintype T] (L : Language T) (hL : is_DCF (endmarked L)) :

      If the explicitly endmarked language is deterministic context-free, then so is the original language.