Applied Computer Science II Chapter 1 : Regular Languages Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany
Overview • • Deterministic finite automata Regular languages Nondeterministic finite automata Closure operations Regular expressions Nonregular languages The pumping lemma
Finite Automata • An intuitive example : supermarket door controller • Figures 1, 2, 3 • Probabilistic counterparts exist – Markov chains, bayesian nets, etc. – Not in this course
A finite automaton • Figure 1. 4 • Formally
Other examples • 7, 8, 9
Another example
Formal definition of computation
Designing finite automata • Design automaton for language consisting of binary strings with an odd number of 1 s • Design first states • Then transitions • Accept and reject states • Fig. 12
Another example • Design an automaton to recognize the language of binary strings containing the string 001 as substring • Fig 13
The regular operations
Regular languages are closed under … • Proof
Non deterministic finite automata • Deterministic – One successor state – transitions not allowed • Non deterministic – Several successor states possible – transitions possible • Figure 14
Deterministic versus non deterministic computation • Figure 15
Example
Every NFA has an equivalent DFA • Figures 17 -18
Another NFA
Nondeterministic finite automaton
Example • Example 18
Formal definition of computation
Equivalence NFA and DFA
Proof
An example
Closure under the regular operations
Proof idea • INSERT FIG 1. 24
• PROOF P 60 !
Proof idea
Proof idea
Regular expressions
Applications • Design of compilers • awk, grep, vi … in unix (search for strings) • Perl programming language • Bioinformatics – So called motifs (patterns occurring in sequences, e. g. proteins)
Proof through :
• Two steps – DFA into GNFA (generalized nondeterministic finite automaton) – GNFA into regular expression
GNFAs • Two states q and r are connected in both directions • Exception : – Start state – Accept state – One direction only • Labels are regular expressions
Formally
Convert DFA into GNFA
Convert GNFA into regular expression
Induction Proof • Induction proof
Nonregular Languages • Finite Automata have a finite memory • Are the following languages regular ? • Mathematical proof necessary
The pumping lemma
Proof Idea
Nonregular languages
Summary • • Deterministic finite automata Regular languages Nondeterministic finite automata Closure operations Regular expressions Nonregular languages The pumping lemma