Documentation

Linglib.Core.Computability.NonContextFree.AnBnCnDn

{aⁿbⁿcⁿdⁿ}: a four-symbol non-context-free witness language #

The single-parameter four-symbol witness anbncndn = {aⁿbⁿcⁿdⁿ | n ≥ 0}. Membership requires na = nb = nc = nd (all four counts equal) and the sorted shape aⁿbⁿcⁿdⁿ.

Non-context-freeness is derived by closure, not re-proved by pumping: the erasing homomorphism dropD : d ↦ ε maps anbncndn exactly onto the irreducible counting core anbnc = {aⁿbⁿcⁿ} (AnBnCn), so anbncndn_not_contextFree follows from anbnc_not_contextFree through Language.IsContextFree.stringMap (the hom-closure root in Map, run contrapositively via Closure). aⁿbⁿcⁿdⁿ is the nested-counting case; the genuinely crossing witness that [Shi85]'s Swiss-German argument requires is the two-parameter ambncmdn sibling, which does not reduce by single-symbol erasure.

This file also hosts the shared FourSymbol substrate consumed by the two-parameter relaxation in NonContextFree.AmBnCmDn:

inductive FourSymbol :

Alphabet for the four-symbol counting witness languages.

Instances For
    @[implicit_reducible]
    Equations
    @[implicit_reducible]
    Equations
    def instReprFourSymbol.repr :
    FourSymbolStd.Format
    Equations
    Instances For
      @[reducible, inline]
      Equations
      Instances For

        The language {aⁿbⁿcⁿdⁿ | n ≥ 0}: the pedagogical four-symbol counting language. The genuinely crossing witness that [Shi85]'s Swiss-German non-context-freeness argument requires is the two-parameter ambncmdn sibling; this single-parameter language is the nested-counting case (cf. [BKPZ82] on Dutch cross-serial word order, which is itself only weakly context-free).

        Equations
        Instances For

          Generate aⁿbⁿcⁿdⁿ.

          Equations
          Instances For
            def anbncndn :
            Language FourSymbol

            The language {aⁿbⁿcⁿdⁿ | n ≥ 0} as a mathlib Language.

            Equations
            Instances For
              theorem filter_count (n : ) (s : FourSymbol) :
              (List.filter (fun (x : FourSymbol) => x == s) (makeString_anbncndn n)).length = n

              Each symbol's filter count in makeString_anbncndn n equals n. Shared with AmBnCmDn (which pumps over the same diagonal witness).

              The four-symbol witness is structurally BlockWitness [a, b, c, d] n.

              theorem not_a_and_c_in_vxy (p : ) (u vxy z : FourString) (hw : makeString_anbncndn p = u ++ vxy ++ z) (hvxy : List.length vxy p) :
              ¬(FourSymbol.a vxy FourSymbol.c vxy)
              theorem not_b_and_d_in_vxy (p : ) (u vxy z : FourString) (hw : makeString_anbncndn p = u ++ vxy ++ z) (hvxy : List.length vxy p) :
              ¬(FourSymbol.b vxy FourSymbol.d vxy)
              theorem filter_eq_nil_of_not_mem (l : FourString) (s : FourSymbol) (h : sl) :
              List.filter (fun (x : FourSymbol) => x == s) l = []
              theorem fourSymbol_filter_total (l : FourString) :
              (List.filter (fun (x : FourSymbol) => x == FourSymbol.a) l).length + (List.filter (fun (x : FourSymbol) => x == FourSymbol.b) l).length + (List.filter (fun (x : FourSymbol) => x == FourSymbol.c) l).length + (List.filter (fun (x : FourSymbol) => x == FourSymbol.d) l).length = List.length l

              makeString_anbncndn n is always in {aⁿbⁿcⁿdⁿ}.

              theorem mem_anbncndn_iff (w : FourString) :
              w anbncndn ∃ (n : ), w = makeString_anbncndn n

              Membership characterization: every string in anbncndn is makeString_anbncndn n for some n. The converse to makeString_in_language.

              The erasing homomorphism d ↦ ε (per-symbol map; the string action is List.flatMap dropD, the free-monoid lift), relabelling the surviving a/b/c into the ThreeSymbol alphabet. The witness for the reduction aⁿbⁿcⁿdⁿ → aⁿbⁿcⁿ.

              Equations
              Instances For
                @[simp]
                theorem dropD_makeString (n : ) :

                dropD erases the dⁿ block and relabels, sending the witness to makeString_anbnc n.

                dropD maps anbncndn exactly onto the counting core anbnc. This image equality is what powers the closure reduction.

                theorem anbncndn_not_contextFree :
                ¬anbncndn.IsContextFree

                {aⁿbⁿcⁿdⁿ} is not context-free — derived by closure from the counting core anbnc_not_contextFree via the erasing homomorphism dropD, rather than re-proved by pumping.