Concrete languages and their complexity — aggregation #
Each file under Complexitylib.Languages defines a family of concrete
languages together with complexity-class memberships. They serve as
non-emptiness witnesses for the classes in Complexitylib.Classes and as
worked examples of building TMs from reusable building blocks.
Submodules #
Trivial—∅andSet.univ, decided inO(1)bywriteTM.FirstCell— languages determined by the first input bit:{[]},firstBitOne,firstBitZero,nonempty, and their Boolean combinations.LengthParity—evenLength,oddLength— the first genuinely linear-time examples, proved by induction on the input.AnBn—{0ⁿ 1ⁿ : n ≥ 0}— the first non-regular example, decided in linear time by a push-down TM that uses its work tape as a unary counter.ZeroPrefix—{0ⁿ 1ᵐ : n ≥ m}— anAnBnvariant that accepts strings with at least as many leading zeros as trailing ones, decided by the same push-down construction.Balanced— strings with equal numbers offalses andtrues — generalizesanbnto arbitrary interleavings, decided in linear time by a push-down TM whose control state records the sign of the count difference.AllSymbol—allZeros,allOnes— strings consisting entirely of a single bit, decided by thescannerTMcombinator.Contains—containsZero,containsOne— strings containing at least one copy of a given bit, also decided viascannerTM.LengthDivBy—lengthDivBy k— strings whose length is divisible byk, withZMod kcounter as the scan state.LastBit—lastBitOne,lastBitZero— strings whose final bit equals a target, withOption Boolscan state.Palindromes— strings equal to their reverse, decided in linear time by a 1-work-tape TM that copies the input then compares forward against backward.