Covered:

  • Lecture 3 (Tue 22.09.): recap of the canonical order; formal languages (Hromkovič Ch. 2, towards Def. 2.9); Lemma 2.1 and Lemma 2.2; algorithmic problems and decision problems; introduction to finite automata (Ch. 3, Def. 3.1, configurations, steps, computations, ); exercise “ends with or ” (left as a cliffhanger).
  • Lecture 4 (Fri 25.09.): the / automaton completed; table representation; Def. 3.2 (, ); regular languages; Lemma 3.1 with the class method; worked example (infix, prefix, suffix); §3.3 Simulation (product automaton).

1. Executive Overview & Core Objectives

Week 2 builds the formal ground for “problem” and “computation”. A language is any set of words; a decision problem asks whether a given word belongs to a language. The first, deliberately very weak model of computation is the deterministic finite automaton (DFA): it reads the input exactly once, left to right, with a read-only head, and remembers only which of finitely many states it is in. You learn to describe its computations formally (configurations, steps, , ), to prove that an automaton accepts exactly a given language (class method plus induction), and to combine automata via the product construction.

Learning objectives. After this week you should be able to:

  • define language, complement, , , concatenation , powers , , , and compute them for small examples, including all edge cases with and ;
  • prove language identities by double inclusion, and refute false ones with a counterexample (Lemma 2.1, Lemma 2.2);
  • define a decision problem and what it means for an algorithm to solve (recognise) it;
  • state Def. 3.1 (DFA as a 5-tuple), and define configuration, start/end configuration, step , computation, accepting/rejecting computation, and ;
  • state Def. 3.2 ( and ) and write in both forms;
  • construct complete DFAs for “contains / starts with / ends with a pattern” languages;
  • define the classes , describe them for a given automaton, and use them in an induction proof (Lemma 3.1);
  • build product automata for , and .

2. Core Concepts & Formal Definitions

2.1 Recap: canonical order (kanonische Ordnung)

Definition (kanonische Ordnung)

Let with a total order . For :

where and . Criterion 1 is length; criterion 2 is lexicographic order at the first difference.
Example (): , , .
Over :

Why length first? Pure lexicographic order lists forever and never reaches a word containing a 1. The canonical order lists every word at a finite position.

Exam Trap: a misspoken example

The transcript says “the word is smaller than the word ”. That is wrong: both have length 2, they first differ at position 1, and , so . The handwritten notes have the correct example , which holds by length.

2.2 Formal languages (formale Sprachen, Hromkovič Ch. 2, Def. 2.9)

Definition 2.9 (Sprache, Komplement, leere Sprache)

Let be an alphabet.

  • Every subset is a language (Sprache) over .
  • The complement (Komplement) of is . It is always taken with respect to the alphabet .
  • is the empty language (leere Sprache).
  • is the language containing only the empty word.
  • : the first has no word, the second has one word (of length 0).

Definition 2.9 continued (Konkatenation, Potenzen, Kleene-Stern)

For languages :

  • Concatenation (Konkatenation): .
  • Powers: , , .
  • Kleene star: .
  • Kleene plus: .

Convention: always includes 0 in this course. “In a midterm or exam, contains 0.”

Rules worth memorising (the edge cases came up repeatedly in the student questions):

ExpressionValueReason
no can be taken from
for every
(for every , including )by definition
only is non-empty
and
always
iff see §3.3
vs. in general differentconcatenation of words is not commutative

Exam Trap: two statements made in the lecture and corrected

  1. Before the break the lecturer said firmly that is never in . After the break he retracted this (“that is simply wrong”). With : . So holds only if .
  2. Answering a student, he said ” is empty”. That is a slip: , which is non-empty. ( is a non-empty language whose only word is empty.)

Also, the first version on the board wrote ; a student pointed out it must be .

2.3 Algorithmic problems and decision problems

Algorithm (still informal): a deterministic procedure (no randomness, no quantum states) that computes, for every input, an output. Formally, it describes a map

What exactly counts as an algorithm stays open until Turing machines are defined. Python, C++, recipes and directions are all intuitive examples.

Definition (Entscheidungsproblem)

Let be an alphabet and . The decision problem is: for every , decide whether or .
An algorithm solves if for all :

We then say ” recognises (erkennt) / decides (entscheidet) the language ”.
The lecture did not give this a number; look it up in Ch. 2 after Def. 2.9.

Examples:

  • (primality testing as a decision problem).
  • : binary encodings of adjacency matrices of graphs with a Hamiltonian cycle.
  • Analogous languages for spanning trees, cliques, independent sets, …

Remarks:

  • Finite languages are “boring” (you can list them). is trivial (always answer 1). The interesting languages are infinite, and some of them are undecidable (later).
  • This is exactly the “Entscheidungsproblem” from the title of Turing’s 1936 paper.

Exam Trap: leading zeros depend on the definition

In Lecture 3 the lecturer said that for decimal encodings of primes, strings with leading zeros (e.g. ) should not count as encoding 13. They would then belong to the complement.
But the notes define via Nummer(x), and is prime, so under that definition.
These are two different languages. In an exam, use the definition exactly as stated in the task.

2.4 Finite automata (endliche Automaten, Hromkovič Ch. 3)

Model (a strongly restricted Turing machine):

  • A finite control (endliche Kontrolle): the “logic”, i.e. finitely many states.
  • An input tape with one symbol per cell, read by a read-only head (Lesekopf):
    • no writing (unlike a TM’s read/write head);
    • only left to right, one cell per step, never backwards;
    • the input is read exactly once, and the computation ends after the last symbol.
  • The only memory is which state it is in.
  • Output is only yes/no: did it end in an accepting state?

Why study such a weak model?

  1. It formalises computation cleanly. Configuration, step and computation all reappear for TMs.
  2. Nondeterminism is easy to understand here first.
  3. DFAs are exactly as expressive as regular expressions (not proved in this course).

Definition 3.1 (deterministischer endlicher Automat, EA)

A (deterministic) finite automaton is a 5-tuple where:

  • is a finite set of states (Zustände), usually ;
  • is an alphabet, the input alphabet (Eingabealphabet);
  • is the unique start state (Anfangszustand);
  • is the set of accepting states (akzeptierende Zustände, also final states or Endzustände);
  • is the transition function (Übergangsfunktion, Transitionsfunktion). It is a total function, e.g. .

“Finite” because all components are finite, in particular .

Diagram conventions (Zustandsdiagramm):

  • a state is a circle;
  • the start state has an incoming arrow from nowhere;
  • accepting states have a double circle;
  • an edge means ;
  • several letters may share one edge ("").

Table representation (Tabellendarstellung): one row per state, one column per letter, and the entry in row , column is .

Exam Trap: rules for drawing DFAs

  • Complete: from every state, for every letter, there is exactly one outgoing edge. Not zero (the automaton would get stuck) and not two (ambiguity). Nondeterministic automata come later and do allow this.
  • Only letters on edges, never and never words. (-automata exist as an extension but are not DFAs.)
  • To label “all letters”, list them (). Don’t write , which already means Kleene star. (The lecturer’s remarks about a label were contradictory in the transcript, so listing the letters is the safe choice.)
  • Mark the start state, which must be unique.
  • The lecturer’s sanity check “at least one accepting state, otherwise it’s strange” is a heuristic, not a rule. is a valid DFA; it accepts .
  • Useful fact: .

Definitions (Konfiguration, Schritt, Berechnung — part of Def. 3.1 in the notes)

Let be a DFA.

  • A configuration (Konfiguration) of is an element of : the current state, plus the remaining input still to be read.
  • is the start configuration (Startkonfiguration) of on .
  • Every configuration in is an end configuration (Endkonfiguration). It is accepting if it is in and rejecting (verwerfend) if it is in .
  • A step (Schritt) of is the relation defined by
  • A computation (Berechnung) of is a finite sequence of configurations with for all .
  • It is a computation of on input if and .
  • If , is an accepting computation and accepts . Otherwise it is a rejecting computation (verwerfende Berechnung).
  • The language accepted by is

Remarks:

  • For a DFA, the computation on is unique and has exactly steps, so it is automatically finite. For TMs, finiteness will not be automatic.
  • Student question: is , reached in the middle of a run, a start configuration? Only for the suffix as an input of its own, not for the original word.

Definition 3.2 ( und )

Let be a DFA.

  1. is the reflexive and transitive closure (reflexive und transitive Hülle) of :
    • (i) with , and
    • (ii) there exist with .
  2. (extended transition function) is defined by:
    • (i) for all ;
    • (ii) for all , , .

Intuitively: is one step with one letter; is any number of steps (including zero); gives the state reached after reading a whole word.

The language of a DFA, two equivalent forms


Because is total, is defined for every : the automaton never gets stuck. It ends in a state that is either in (accept) or not (reject).

Exam Trap: recurses on the LAST letter

A student first proposed a version that splits off the first letter. The book’s (and lecture’s) recursion splits off the last letter: . A front-splitting version defines the same function, but induction proofs in this course (Lemma 3.1) use the back-splitting form. Use the book’s.

Definition (reguläre Sprachen)

A language is regular (regulär) if there is a DFA with . The class of all regular languages is ; check the book’s exact symbol.
Facts:

  • every DFA accepts exactly one language;
  • a language has many DFAs (different sizes and structures), and “the” correct automaton does not exist;
  • non-regular languages exist (proved later);
  • regular languages = languages describable by regular expressions (mentioned only, not covered).

2.5 Classes of an automaton (Klassen)

Definition ( )

For a DFA and a state :

the set of all words that lead from the start state to .

Properties

  • The classes are pairwise disjoint, because is a function and so every word ends in exactly one state.
  • , so partitions into classes, one per state.
  • .
  • (The lecture did not use the name “Nerode congruence” and it is not needed here.)

Exam Trap: classes need not be infinite or non-empty

The lecturer said the classes are “obviously infinite, because is infinite”. That holds for the examples shown, but not in general:

  • in the prefix automaton for (§4.3), , which is finite;
  • a state unreachable from has an empty class.

So ” partitions into classes” is strictly true only if all states are reachable; otherwise some classes are empty. Only (the classes cover everything) is guaranteed.

2.6 Simulation: the product automaton (Produktautomat, §3.3)

Idea: to decide membership in a combination of and (same alphabet), run both automata simultaneously on the input. A state of the new automaton is a pair (state of , state of ).

Definition (product automaton — formalised in the next lecture)

Let and be DFAs over the same . The product automaton is


and the choice of decides the language:

Target languageAccepting states
(inclusive or)
(lecturer deferred this to next week)

; unreachable pairs may be omitted.

In the drawing: ‘s state determines the row, ‘s state the column. Each transition moves “vertically” as does and “horizontally” as does, at the same time.


3. Step-by-Step Derivations & Mathematical Proofs

3.1 Lemma 2.1: concatenation distributes over union

Lemma 2.1

For languages over :

Standard method: equality of sets by double inclusion.

(1) "". It suffices to show and .

  • The first equality is the definition of concatenation.
  • The inclusion holds because implies : we only weaken the condition.
  • The last equality is the definition of concatenation again.

is analogous. A union of two subsets is a subset, so .

(2) "". This was skipped in the lecture as “trivial”; here it is in full. Let . By definition with and .

  • Case : then .
  • Case : then .

In both cases . ∎

3.2 Lemma 2.2: concatenation and intersection (only one inclusion)

Lemma 2.2


and in general not "".

Proof of "": let , so with , and . Then and , so is in the intersection. ∎

Counterexample for "". This one is my own; the book’s may differ. Over take , , .

  • , so .
  • and , so .

So .

Intuition: why intersection breaks

A word can have several factorisations. (using ) and (using ). Being in both and may be witnessed by different splits. needs one split whose second part is in both. For union this problem does not arise, because you only need one split anyway.

Exam Trap: proving vs. refuting language identities

  • To prove an identity: show both inclusions, element by element, using the definitions.
  • To refute one: one concrete counterexample (specific finite languages plus one word) is enough and is the expected answer.

3.3

  • "": if , then with and . So .
  • "": if , then with , . Since , . So . ∎

3.4 Lemma 3.1 (class method plus induction)

The automaton over (labels as in the Friday lecture and the book):

(accepting)
(accepting)

Reading a toggles and ; reading a toggles and . .

Lemma 3.1

Proof idea: for each state, guess its class, prove the guess by induction on , then take the union over .

Step 1: claim the classes.

Step 2: the claim implies the lemma.

since even + even and odd + odd are even, while mixed parities give odd.

Step 3: prove the claim by induction on .

Base case (Induktionsanfang). The lecture checked all words of length . Only length 0 is actually needed (see the remark below), but the table is a useful check:

parities class matches?
(even, even)✓
(even, odd)✓
(odd, even)✓
(even, even)✓
(odd, odd)✓
(odd, odd)✓
(even, even)✓

Induction hypothesis (Induktionsannahme): the claim holds for all with .

Induction step (Induktionsschritt): let , written with and . By Def. 3.2(ii),

By the hypothesis, is the state matching ‘s parities. Appending flips exactly one parity: the 0-parity if , the 1-parity if . There are four cases by the parities of ; the lecture did (a) and left the others as “analogous”.

  • (a) , both even, so . Then , which is if (now even, odd ✓) and if ( odd, even ✓).
  • (b) even, odd, so the state is . : both even ✓. : both odd ✓.
  • (c) odd, even, so the state is . : both even ✓. : both odd ✓.
  • (d) both odd, so the state is . : (even, odd) ✓. : (odd, even) ✓.

In every case lands in the correct class. ∎

Intuition: why the example is "too big"

Several students noticed (and the lecturer agreed) that the statement only depends on being even, so a 2-state automaton suffices. The base case alone would also suffice, and simple (not strong) induction is enough. The 4-state version and the extended base case were kept for didactic reasons, to show the method with four genuinely different classes. Later automata will not be proved at this low level.

Exam Trap: different state labels in the two lectures

The Tuesday lecture used the same automaton shape with and swapped:

  • Tuesday: , , ;
  • Friday (and above): , , .

Both accept the same language. The Friday version matches the book and the class names in Lemma 3.1. In the Tuesday trace (§4.1), "" means “both parities odd”.

3.5 Correctness of the product construction

The lecturer called this “trivial” and will formalise it next lecture. The precise argument:

Claim: for all , .

Induction on :

  • : both sides are .
  • Step :

Consequence (union):

Intersection (, ) and difference () are proved the same way. ∎

Corollary: regular languages are closed under , and .


4. Worked Examples & Applications

4.1 Running a DFA: configurations (Lecture 3)

Tuesday’s automaton (labels as described in the trap above): , , , , , . Input :

  • 5 letters give exactly 5 steps.
  • The end configuration is with , so this is a rejecting computation: .
  • Consistent with the language: is odd.

4.2 DFA for “ends with or ” (Lecture 3 exercise, completed in Lecture 4)

Design idea (suffix tracking). The state index stores the longest suffix of the input read so far that is a prefix of or . Storing the whole word is impossible (finitely many states, unboundedly long words) and also unnecessary.

Components:

  • start state
(accepting) (loop)
(loop)
(accepting)

Why the non-obvious edges are right:

  • : after the accumulated ‘s are useless, but the last is a prefix of . Going back to would be wrong: after , the input must still lead to acceptance ( ends with ). This was the cliffhanger at the end of Lecture 3.
  • : still ends with .
  • : after , the longest useful suffix is , since and are not prefixes of either pattern.
  • : after , only the final is useful.
  • : still ends with .
  • : after , is not a prefix of , but is a prefix of .
  • and : as for .

Final check: every state has exactly one -edge and one -edge ✓; unique start ✓; accepting states marked ✓.

Example: traces

  • : , so reject ✓ (does not end with or ).
  • : , so accept ✓.
  • : , so accept ✓ (ends with ).

Intuition: suffix patterns are the hard case

Prefix conditions are easy: once you fail, go to a sink state. Infix conditions are medium: after success, stay in an absorbing accepting state. Suffix conditions are the hardest, because after reaching an accepting state you can fall out again, and on a mismatch you must jump back to the right “partial match” state. Never jump back to blindly.

4.3 Pattern : infix, suffix, prefix (Lecture 4, group exercise)

(a) Infix (Teilwort): .

(accepting)
  • = “the longest suffix that is a prefix of has length ”.
  • : still ends with .
  • : ends with no prefix of .
  • : this loop was forgotten on the board and added after a student’s remark.
  • is absorbing: once has been seen, the word is in whatever follows.

(b) Suffix (): words ending in . Same as (a) but is not absorbing:

  • : ends with .
  • : ends with no prefix of .

The lecturer first drew the -edge wrongly and corrected it to during the lecture.

(c) Prefix (): words starting with . Add a sink state (Senke) (“Abfall”):

(accepting)

There is exactly one chance, the first four letters; any mismatch goes to the non-accepting sink forever. The sink is needed because DFAs must be complete. This is the easiest of the three cases.

Classes for the infix automaton (a). The lecture’s wording is completed here with the condition "":

  • no non-empty prefix of is a suffix of , or ends with but not with
  • ends with and no longer prefix of is a suffix ends with but not with
  • ends with
  • ends with

Exam Trap: absorbing states and class descriptions

Because is absorbing, every word containing ends in , including words like that also “end with ”. So must explicitly exclude . Otherwise the classes overlap and the answer is wrong. On the board this condition was written for and but omitted for and .
Check that your classes are disjoint, cover , and are consistent with the edges.

4.4 Product automaton (Lecture 4, §3.3)

accepts ; the 1s are ignored.

(accepting)

counts 1s up to 3.

(accepting)
(accepting)

So .

Exam Trap: "three 1s" means "at least three"

The lecture described as accepting “no 1 or three 1s”. Because loops on , it accepts at least three 1s. Always derive the language from the automaton itself, not from a spoken summary.

Product (rows from , columns from ), start :

switches the row (as does) and keeps the column ( loops on 0, except that from it loops anyway). keeps the row ( loops on 1) and advances the column. In column , loops in both components and still switches rows.

Trace of :

  • :
  • :
  • :

Accepting states:

  • : the whole row plus and . ends in , so it is accepted (two 0s).
  • : . is rejected (only two 1s).
  • (deferred to next week): . is accepted.

Exam Trap: union means inclusive or

For the union you need all pairs where or accepts, including both, so both accepting columns ( and ) in the non-accepting row. In the lecture only one column was mentioned explicitly (“and then the column”); both are required.

4.5 Student questions

Q: Is the same as ?

In general no. The order matters, because words are concatenated in that order. Example: . (For a set such as the order of listing elements doesn’t matter; that is a different question.)

Q: May a language contain ?

Yes. always, and iff (see the trap in §2.2).

Q: In , is a single letter?

Yes. , and processes the word letter by letter via .


5. Intuition & Conceptual Bridges

Intuition: a DFA is a program with constant memory

Think of a loop for c in input: state = delta[state][c] followed by return state in F. No counters that grow, no lists, no going back. Designing a DFA means deciding what finite summary of the past is enough for the future: the parity of counts, the longest partial match, “seen the pattern already?”. The classes are exactly these summaries written as sets of words.

Intuition: why parities work but counting does not

in Lemma 3.1 only needs parities (2 × 2 possibilities). A language like would need to remember an unbounded count. That is impossible with finitely many states, which is the preview of non-regular languages next.

Intuition: the product automaton is parallel execution

Running two programs in lockstep on the same input stream needs memory for both states, i.e. a pair. The cost is multiplicative ( states), but the construction is completely mechanical.

Connections:

  • Back to Week 1: decision problems as languages are now fully formal (, ” recognises ”). The concatenation and iteration of words lifts directly to languages.
  • Regular expressions: the Kleene star is the regex *. Regular languages are exactly the regex-describable ones (not proved here).
  • Ahead:
    • proving languages non-regular (limits of DFAs);
    • nondeterministic finite automata (several or zero edges per letter);
    • extending the model step by step to the Turing machine, where configurations, steps and computations are defined analogously, but computations need not be finite;
    • the formal proof of the product construction and the case (next lecture);
    • next week: an alternative, more intuitive but larger automaton for infix recognition.

6. Summary & Self-Assessment Questions

Cheat table

ConceptKey statement
Languageany
Complement
vs. vs. , which are different
Concatenation, not commutative
Absorbing / neutral,
Powers,
Star / plus, ; iff
Lemma 2.1
Lemma 2.2, and not
Decision problem: decide ; solves it iff
DFA (Def. 3.1) with total
Configurationelement of ; start ; end
Step
(Def. 3.2)reflexive-transitive closure of
(Def. 3.2),
Regular for some DFA
Class; the classes partition ;
Lemma 3.1the 4-state parity DFA accepts
Product; by “or” / “and” / “and not”
DFA checklistcomplete, deterministic, letters only on edges, unique marked start, accepting states double-circled

Self-assessment questions

Question 1. Compute: , , , , , , and for . Then decide: is ? Is ?

Question 2. True or false? Prove or give a counterexample.
(a) .
(b) .
(c) .

Question 3. Construct a complete DFA over for . Give all classes and check that they partition . Then give the configuration sequence on input .

Question 4 (the lecturer’s voluntary task). Let and . Build a DFA for each, then use the product construction for .

Question 5. Using the classes of the 4-state parity automaton from Lemma 3.1, give without simulating. Then explain why the induction step must use and what exactly the induction hypothesis provides.