Applied Computer Science II Chapter 1 Regular Languages

  • Slides: 61
Download presentation
Applied Computer Science II Chapter 1 : Regular Languages Prof. Dr. Luc De Raedt

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

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,

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

A finite automaton • Figure 1. 4 • Formally

Other examples • 7, 8, 9

Other examples • 7, 8, 9

Another example

Another example

Formal definition of computation

Formal definition of computation

Designing finite automata • Design automaton for language consisting of binary strings with an

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

Another example • Design an automaton to recognize the language of binary strings containing the string 001 as substring • Fig 13

The regular operations

The regular operations

Regular languages are closed under … • Proof

Regular languages are closed under … • Proof

Non deterministic finite automata • Deterministic – One successor state – transitions not allowed

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

Deterministic versus non deterministic computation • Figure 15

Example

Example

Every NFA has an equivalent DFA • Figures 17 -18

Every NFA has an equivalent DFA • Figures 17 -18

Another NFA

Another NFA

Nondeterministic finite automaton

Nondeterministic finite automaton

Example • Example 18

Example • Example 18

Formal definition of computation

Formal definition of computation

Equivalence NFA and DFA

Equivalence NFA and DFA

Proof

Proof

An example

An example

Closure under the regular operations

Closure under the regular operations

Proof idea • INSERT FIG 1. 24

Proof idea • INSERT FIG 1. 24

 • PROOF P 60 !

• PROOF P 60 !

Proof idea

Proof idea

Proof idea

Proof idea

Regular expressions

Regular expressions

Applications • Design of compilers • awk, grep, vi … in unix (search for

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 :

Proof through :

 • Two steps – DFA into GNFA (generalized nondeterministic finite automaton) – GNFA

• 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

GNFAs • Two states q and r are connected in both directions • Exception : – Start state – Accept state – One direction only • Labels are regular expressions

Formally

Formally

Convert DFA into GNFA

Convert DFA into GNFA

Convert GNFA into regular expression

Convert GNFA into regular expression

Induction Proof • Induction proof

Induction Proof • Induction proof

Nonregular Languages • Finite Automata have a finite memory • Are the following languages

Nonregular Languages • Finite Automata have a finite memory • Are the following languages regular ? • Mathematical proof necessary

The pumping lemma

The pumping lemma

Proof Idea

Proof Idea

Nonregular languages

Nonregular languages

Summary • • Deterministic finite automata Regular languages Nondeterministic finite automata Closure operations Regular

Summary • • Deterministic finite automata Regular languages Nondeterministic finite automata Closure operations Regular expressions Nonregular languages The pumping lemma