Theoretical Computer Science through Examples

  1. A Formal Language as a Set of Strings

    A formal language is a set of finite strings over a chosen alphabet. It can include the empty string, regardless of whether longer strings are present.

    Undergraduate
  2. The Empty Word and the Empty Language

    The empty word is one string of length zero. The empty language is a set containing no strings.

    Undergraduate
  3. Concatenating Two Formal Words

    Concatenation joins strings in order and adds their lengths. Changing word order can change the resulting sequence.

    Undergraduate
  4. Union and Concatenation for Languages

    Language union keeps words accepted by either input set. Language concatenation uses all pairs to create joined words.

    Undergraduate
  5. Kleene Star on a Small Language

    The Kleene star contains all concatenations of zero or more words from its input language.

    Undergraduate
  6. Running a Deterministic Automaton by Hand

    A deterministic finite automaton starts in a designated state, reads one symbol at a time, and accepts when the final state is designated accepting.

    Undergraduate
  7. A Finite State Remembers Parity Without a Count

    A machine can retain just enough information about earlier symbols to decide later behavior. For parity, two states summarize all possible counts.

    Undergraduate
  8. Tracking the Last Symbol with a Finite State

    A small automaton can recognize words ending in a specified symbol by updating its retained state on every step.

    Undergraduate
  9. Remembering That a Pattern Has Occurred

    An automaton recognizing whether a substring occurred can preserve a found state after the first detection.

    Undergraduate
  10. A Dead State for Unsupported Prefixes

    A complete deterministic automaton defines a transition for every state and alphabet symbol. A dead state can preserve rejection when no future extension can repair a prefix.

    Undergraduate
  11. Running Two Automata in a Product State

    A product automaton can track two machines over the same input by storing their current states as an ordered pair.

    Undergraduate
  12. Two Possible Paths in a Nondeterministic Automaton

    A nondeterministic automaton can allow several next states for one input. A word is accepted if at least one valid complete path accepts.

    Undergraduate
  13. Reading Three Regular Expression Operations

    Alternation selects either pattern. Concatenation places matches one after another. Star repeats a pattern zero or more times.

    Undergraduate
  14. Whole-Input and Substring Matching

    A whole-input match asks whether a complete string belongs to a language. A substring search asks whether some contiguous portion belongs.

    Undergraduate
  15. Token Kinds and Their Source Spellings

    A lexer can classify spans into token kinds while keeping their original spellings or parsed values for later stages.

    Undergraduate
  16. Recognizing One Kind of Balanced Parenthesis

    For a single bracket kind, a count of currently open brackets can track whether a prefix can still be extended to a balanced string.

    Undergraduate
  17. One Grammar with Two Alternative Forms

    A grammar production specifies replacements for a category of strings. Alternatives can describe different valid forms under one name.

    Undergraduate
  18. Terminals and Nonterminals in a Grammar

    Terminal symbols form the final words. Nonterminals represent categories that a production may replace during derivation.

    Undergraduate
  19. Ambiguity Through Two Parse Trees

    A grammar is ambiguous when one terminal string has more than one distinct parse tree under that grammar.

    Undergraduate
  20. Associativity in an Expression Tree

    Associativity rules can decide which repeated operator binds first when an expression has no grouping parentheses.

    Undergraduate
  21. A Tape as Abstract Read–Write Storage

    A Turing machine can store symbols on a tape, observe the current cell, and use its finite control to choose a write and movement.

    Undergraduate
  22. What It Means to Decide a Language

    A decider halts on every allowed input and gives the correct yes or no answer to membership.

    Undergraduate
  23. Recognition by Searching for a Witness

    Some recognizers answer yes once they find acceptable evidence but may keep searching when none exists.

    Undergraduate
  24. A Certificate for an Efficiently Checkable Yes Answer

    A certificate supplies information a verifier can inspect along with an input to establish an affirmative instance under a defined problem.

    Undergraduate
  25. Finding a Witness and Checking a Supplied Witness

    A search procedure must obtain evidence satisfying the condition. A verifier can start from already supplied evidence and test it.

    Undergraduate
  26. Checking a Reduction in Both Directions

    A many-one reduction translates an instance so its yes or no answer agrees with that of the original instance.

    Undergraduate
  27. The Direction of a Problem Reduction

    Reducing problem A to B gives a way to use a solver for B when answering inputs of A, under the reduction's conditions.

    Undergraduate
  28. Encoded Input Length and Numeric Magnitude

    A numeric value can be much larger than the number of bits needed to write it. Complexity claims depend on the chosen input encoding.

    Undergraduate
  29. Why a Small State Description Can Have Many Configurations

    A state made from several independent fields has a number of possible combinations given by the product of their possible values.

    Undergraduate
  30. Turning an Optimization Question into a Threshold Decision

    An optimization task seeks the best feasible value. A threshold version asks whether any feasible result reaches a specified limit.

    Undergraduate