Automata Behind Regular Expressions

About this lecture

Regular expressions are neither magic nor string comparison. They are compiled into small machines that read your input one character at a time, and this lecture builds one by hand. Four translation rules turn the pattern (a|b)*abb into a nondeterministic state machine, drawn as circles and arrows. A string is then fed through it with several states alive at once, and that machine is determinised by tracking sets of live states until a deterministic one falls out of the bookkeeping. It closes with two honest limits: a harmless looking pattern whose deterministic machine grows exponentially, and balanced brackets, which no regular expression can match at all, proved concretely by finding a loop the machine cannot avoid repeating. For working programmers. No automata background assumed.

Transcript

Loading discussion…