Documentation

Linglib.Theories.Phonology.Process.LocalRewrite

Local Phonological Rewrite Rules #

A local rewrite rule is a triple (target, effect, context) that specifies a featurally-conditioned transformation of segment strings. The canonical SPE notation A → B / C __ D originates with @cite{chomsky-halle-1968} The Sound Pattern of English; the formal-language characterization of ordered SPE-rule cascades as regular relations is @cite{johnson-1972} and @cite{kaplan-kay-1994}. Pedagogical exposition: @cite{hayes-2009} Ch 6. The notation denotes the function "every segment matching natural class A becomes B when preceded by context C and followed by context D."

Theoretical framing (2026) #

Local rewrite rules are not a theory of phonology in the 2026 sense — the cognitive-theory claim that ordered rules with extrinsic ordering correctly model phonological grammars is a 1960s framing largely superseded by Optimality Theory (OptimalityTheory/) and its constraint-based descendants. What survives in 2026 mainstream computational phonology is the formal-language-theoretic role: local rewrite rules characterize a particular subclass of regular relations — specifically the Input Strictly Local (ISL) functions of @cite{chandlee-2014} @cite{chandlee-heinz-2018}.

This file therefore frames Rule as a convenient surface notation for local maps, with the formal claim grounded in Core/Computability/Subregular/Function/ISL.lean. The connection is made explicit by Rule.apply_isInputStrictlyLocal (currently a documented sorry — the construction of the witness ISLRule requires careful handling of word-boundary contexts via the augmented alphabet Option Segment, deferred to a follow-up PR).

Sibling architectures #

FrameworkKey fileRelation to LocalRewrite
Tier-based alternationProcess/Alternation.leanTierRule (Belth 2026); a single tier-adjacent context LocalRewrite.Rule is subsumed by TierRule (subsumption bridge deferred).
Optimality TheoryOptimalityTheory/Constraint-ranking (parallel evaluation); SPE-vs-OT is the central theoretical fault line of late-20th-century phonology.
Harmonic SerialismCore/Constraint/OT/HarmonicSerialism.leanIterative constraint-based; named in HS docstring as architecturally-distinct alternative for counterfeeding.
Stratal OTOptimalityTheory/Stratal.leanConstraint-ranking within strata, with extrinsic strata ordering — keeps SPE-style derivationality at the stratum boundary.
Output-driven (OSL/WD)Core/Computability/Subregular/Function/{OSL,Hierarchy}.leanIterative spreading and bidirectional harmony — strictly above the ISL class that LocalRewrite occupies.

What this file does NOT cover #

Main definitions #

This file replaces Process/RuleBased/Defs.lean (deleted), which framed the substrate as "the SPE rule formalism following Hayes Ch 6."

An element of a rule's structural description. Context positions hold either a segment pattern (a natural class via Segment partial specification) or a word boundary marker.

Instances For

    The structural change effected by a rule.

    • changeFeatures : SegmentEffect

      Merge a feature bundle into the target segment. SPE notation: A → B where B is a partial specification.

    • delete : Effect

      Delete the target segment. SPE notation: A → ∅.

    Instances For

      Apply an effect to a target segment. Returns none if the segment is deleted; some s' if features are merged into s'.

      Equations
      Instances For

        A local rewrite rule in SPE notation A → B / C __ D.

        • target — natural class A matched by the affected segment.
        • effect — structural change B: feature merge or deletion.
        • leftContext — preceding context C, ordered left-to-right (so the rightmost element is closest to the target).
        • rightContext — following context D, ordered left-to-right.

        The name field is informational.

        Instances For

          Match a right-context list against the suffix right to the right of the current position. Both lists are scanned head-to-head: right's head is the segment immediately following the target.

          Equations
          Instances For
            def Phonology.LocalRewrite.matchLeftContext (ctx : List ContextElem) (left : List Segment) :
            Bool

            Match a left-context list against the prefix left to the left of the current position. Context elements are ordered left-to-right (so the rightmost element is closest to the target); we reverse both lists once and then scan head-to-head.

            Equations
            Instances For
              def Phonology.LocalRewrite.Rule.apply (r : Rule) (input : List Segment) :
              List Segment

              Apply a single rule to a segment string. Scans left-to-right; at every position where the target and contexts match, applies the effect. Application is simultaneous: context matches are evaluated against the input (the prefix left accumulates original segments, not their post-rule values), per the SPE default (@cite{chomsky-halle-1968} p. 344; @cite{chandlee-heinz-2018} §5.1).

              The recursion is structural on right (the unprocessed suffix), so Rule.apply reduces cleanly under decide for finite inputs.

              Equations
              Instances For
                Equations
                Instances For
                  def Phonology.LocalRewrite.derive (rules : List Rule) (input : List Segment) :
                  List Segment

                  Apply an ordered sequence of rules. Each rule sees the output of the previous rule (extrinsic ordering, the SPE convention).

                  Equations
                  Instances For

                    Headline classification (deferred) #

                    Every Rule.apply is conjecturally a k-Left-ISL function in the sense of @cite{chandlee-heinz-2018}, where k = r.leftContext.length + r.rightContext.length + 1. The construction exhibits an ISLRule k (Option Segment) (Option Segment) whose windowOutput:

                    1. Augments input to List (Option Segment) with none as the word boundary (mirroring Subregular/Basic.lean's Augmented α pattern).
                    2. Fires the rule when the window's central position matches target and the surrounding window matches both contexts (wordBoundarynone).
                    3. For rules with right context of length n, the FST emits output delayed by n symbols (Chandlee-Heinz §4 simulation; see Function/Hierarchy.lean::ISLRule.toSFST for the analogous simulation pattern at the abstract level).
                    4. Strips boundary markers from the output to recover List Segment.

                    The theorem is not stated in this PR rather than stated with sorry — the right-context output-delay construction is non-trivial and the audit (mathlib reviewer B2) flagged the previous sorry'd shape (∃ k, IsInputStrictlyLocal k (fun input : List (Option Segment) => …)) as malformed: the function should live over List Segment directly with boundary handling internalised, and the existential k should be the explicit r.leftContext.length + r.rightContext.length + 1. Land the witness construction in a dedicated Theories/Phonology/Process/ LocalRewriteISL.lean follow-up file once a Studies consumer needs the explicit classification (the MeinhardtEtAl2024.lean Studies file demonstrates substrate use without going through Rule.apply).