Documentation

Linglib.Core.Computability.Subregular.Function.OSL

Output Strictly Local (OSL) Functions #

A function f : List α → List β is k-Output Strictly Local when each output block depends only on the last k - 1 output symbols plus the current input symbol. OSL captures iterative processes where the output already emitted at position i feeds forward to the decision at position i + 1. The function-level subregular hierarchy at this layer is ISL ⊊ OSL ⊊ Subsequential.

Main definitions #

Main results #

Implementation notes #

The witness style IsX k f := ∃ r : OSLRule k α β, r.apply = f mirrors IsLeftInputStrictlyLocal in ISL.lean. Unlike ISL, whose window is over input symbols and threads independently of what was emitted, the OSL window is over already-emitted output — each step truncates outputWindow ++ windowOutput outputWindow x to the last k - 1 symbols before recursing. The k parameter is a type-level annotation; window-length truncation in applyAux is what enforces it semantically.

OSLRule.toSFST deliberately repeats r.windowOutput outputWindow x in the two tuple components of step rather than let-binding it, so that (step ow x).2 reduces definitionally for toSFST_run_eq_apply.

structure Subregular.OSLRule (k : ) (α : Type u_3) (β : Type u_4) :
Type (max u_3 u_4)

A k-Output-Strictly-Local rule over input alphabet α and output alphabet β. The single field windowOutput consumes the (k − 1)-symbol output context window plus the current input symbol and emits an output block.

In contrast to ISLRule (whose window is over input symbols), the window here is over already-emitted output symbols. This lets the rule see what it has just produced and react accordingly — the mechanism behind iterative output dependence.

The k parameter is a type-level annotation; semantic enforcement happens in apply's window threading.

  • windowOutput : List βαList β

    Map from (output context window, current input symbol) to output block. The window argument has length at most k - 1 when called by OSLRule.apply.

Instances For
    def Subregular.OSLRule.applyAux {α : Type u_1} {β : Type u_2} {k : } (r : OSLRule k α β) (outputWindow : List β) (rest : List α) :
    List β

    Apply the rule, threading a window of accumulated output symbols. At each input position, emit r.windowOutput outputWindow x, then extend the output window with the just-emitted block (truncated to keep at most k − 1 symbols).

    Equations
    Instances For
      def Subregular.OSLRule.apply {α : Type u_1} {β : Type u_2} {k : } (r : OSLRule k α β) (input : List α) :
      List β

      Apply a k-OSL rule to an input string, scanning left-to-right.

      Equations
      Instances For
        @[simp]
        theorem Subregular.OSLRule.applyAux_nil {α : Type u_1} {β : Type u_2} {k : } (r : OSLRule k α β) (outputWindow : List β) :
        r.applyAux outputWindow [] = []
        @[simp]
        theorem Subregular.OSLRule.applyAux_cons {α : Type u_1} {β : Type u_2} {k : } (r : OSLRule k α β) (outputWindow : List β) (x : α) (xs : List α) :
        r.applyAux outputWindow (x :: xs) = r.windowOutput outputWindow x ++ r.applyAux ((outputWindow ++ r.windowOutput outputWindow x).rtake (k - 1)) xs
        @[simp]
        theorem Subregular.OSLRule.apply_nil {α : Type u_1} {β : Type u_2} {k : } (r : OSLRule k α β) :
        r.apply [] = []
        @[simp]
        theorem Subregular.OSLRule.apply_singleton {α : Type u_1} {β : Type u_2} {k : } (r : OSLRule k α β) (x : α) :
        r.apply [x] = r.windowOutput [] x
        def Subregular.IsLeftOutputStrictlyLocal {α : Type u_1} {β : Type u_2} (k : ) (f : List αList β) :

        A function f : List α → List β is k-Left-Output-Strictly-Local iff some k-OSL rule computes it via left-to-right scan.

        Equations
        Instances For
          def Subregular.IsRightOutputStrictlyLocal {α : Type u_1} {β : Type u_2} (k : ) (f : List αList β) :

          A function f : List α → List β is k-Right-Output-Strictly-Local iff some k-OSL rule computes it via right-to-left scan.

          Equations
          Instances For
            @[simp]
            theorem Subregular.isOutputStrictlyLocal_left {α : Type u_1} {β : Type u_2} (k : ) (f : List αList β) :
            @[simp]
            theorem Subregular.isOutputStrictlyLocal_right {α : Type u_1} {β : Type u_2} (k : ) (f : List αList β) :
            theorem Subregular.OSLRule.isLeftOutputStrictlyLocal_apply {α : Type u_1} {β : Type u_2} {k : } (r : OSLRule k α β) :

            Every OSL rule witnesses IsLeftOutputStrictlyLocal for the function it computes.

            theorem Subregular.isRightOutputStrictlyLocal_iff_left_reverse {α : Type u_1} {β : Type u_2} {k : } (f : List αList β) :
            IsRightOutputStrictlyLocal k f IsLeftOutputStrictlyLocal k fun (xs : List α) => (f xs.reverse).reverse

            Reverse-conjugation lemma: a function is k-Right-OSL iff its reverse-conjugate is k-Left-OSL. The two classes are isomorphic via the involution f ↦ List.reverse ∘ f ∘ List.reverse.

            OSL ⊆ Subsequential #

            OSLRule.toFinSFST projects an OSL rule into an SFST whose state is the bounded output window (length ≤ k − 1). The inclusion rides on the run-equality plus the Fintype instance for the bounded-window subtype (reusing fintypeListLengthLE from ISL.lean). Co-located on the source side because the dependency direction (SFST in Subsequential.lean; OSL projects into it) forces both construction and cast into this file.

            The output alphabet [Fintype β] constraint matches [Moh97]'s finite-alphabet assumption — the state space (a bounded output window) is finite precisely when the output alphabet is.

            def Subregular.OSLRule.toFinSFST {α : Type u_1} {β : Type u_2} {k : } (r : OSLRule k α β) :
            SFST α β { l : List β // l.length k - 1 }

            Construction: every Left-OSL rule induces an SFST whose state is the output window — a list of output symbols of length at most k − 1 — and whose finalOutput is empty.

            The windowOutput call is repeated in the two tuple components rather than let-bound so that (step ow x).2 reduces definitionally to r.windowOutput ow x for the proof of toFinSFST_run_eq_apply.

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For
              theorem Subregular.OSLRule.toFinSFST_run_eq_apply {α : Type u_1} {β : Type u_2} {k : } (r : OSLRule k α β) :

              The SFST induced by an OSL rule computes the same string function.

              theorem Subregular.isLeftOutputStrictlyLocal_left_subsequential {α : Type u_1} {β : Type u_2} {k : } [Fintype β] {f : List αList β} (h : IsLeftOutputStrictlyLocal k f) :

              Left-OSL ⊆ Left-Subsequential (over a finite output alphabet). The [Fintype β] matches [Moh97]'s finite-alphabet assumption and lets the bounded output window serve as a finite state space.

              theorem Subregular.isRightOutputStrictlyLocal_right_subsequential {α : Type u_1} {β : Type u_2} {k : } [Fintype β] {f : List αList β} (h : IsRightOutputStrictlyLocal k f) :

              Right-OSL ⊆ Right-Subsequential, derived from the Left- side via the reverse-conjugation lemmas. The Right-OSL ↔ Left-OSL and Right-Subseq ↔ Left-Subseq isomorphisms commute.

              theorem Subregular.isOutputStrictlyLocal_isSubsequential {α : Type u_1} {β : Type u_2} {d : Direction} {k : } [Fintype β] {f : List αList β} (h : IsOutputStrictlyLocal d k f) :

              Direction-parameterised OSL ⊆ Subsequential umbrella: in both scan directions, OSL functions are subsequential. Delegates to the Left- / Right- specialised theorems.