You are on page 1of 18

Introduction

Wen-Guey Tzeng
Computer Science Department
National Chiao Tung University
Formal languages and finite automata
• We have been building computing machines for
solving computing problems.22222
• Computers are everywhere.
• Questions
– What is a computing machine?
– What problems can be solved by a computing machine?
– What problems cannot be solved?
• Finite automata: abstract models of computing
machines
• Formal languages: formal representation of
computing problems
2017 Spring 2
Classification
• Finite automata: by types of memories
– Finite automata
– Pushdown automata
– Turing machines
• Formal languages: by types of grammars
– Regular languages
– Context-free languages
– Recursive languages (solvable)
– Recursively enumerable languages (semi-solvable)
– …
2017 Spring 3
Relations
• Finite automata and regular languages
• Pushdown down automata and context-free
languages
• Turing machines and recursive languages
• Complexity classes: by runtime or space used by
Turing machines
– P: polynomial time computable
– NP: non-deterministic polynomial time computable
– EXP: solvable in exponential time
– …

2017 Spring 4
Computing Computing
problems machines

Formalization

Abstraction
Yes/No
problems Classification
by: memory,
runtime,
space, etc.
Formal Relations Finite
languages automata

Classification
by: grammars,
machines, etc. • Regular vs. finite automata
• Context-free vs. pushdown
• Recursive vs. Turing machines
• Complexity classes
• …

2017 Spring 5
Applications
• Programming languages
• Compilers
• Natural language processing
• Algorithm design
• Software engineering
• Pattern recognitions
• Machine learning
• …

2017 Spring 6
2017 Spring 7
How to compile a Java program, like the above?
• We need a grammar for the Java programming
language
• Context-free grammar
• We need a compiler to compile it
• Pushdown automata

2017 Spring 8
2017 Spring 9
Mathematical notation
• Set: a collection of elements
– |S|: the number of elements in S
– SxT={(x, y) | xS, yT}
• Function
– f: S1S2
• Binary relation
– R  S1xS2
– xS1 and yS2 has relation R if (x, y)R

2017 Spring 10
Three Basic Concepts
1. Languages
– Symbol set (alphabet) ={a, b, c, …} Alphabet
={a,b}
– String: w=a1a2…an, n0, ai
• |w|: length of string
• String concatenation: w1w2
Strings:
• String reversing: wR=anan-1…a1 aba, baba, …
• an = aa… a (repeated n times)
• Prefix(w)={, a1, a1a2, …, a1a2…an}
• Suffix(w)={, an, an-1an, …, a1a2…an} Languages:
• Empty string , L={aba, abbaa,
– ||=0 aaba, aa, …}
– w= w=w
2017 Spring 11
– A language L over  is a subset of strings over 
– The language consists of all strings: *
• * over {a,b} = {, a, b, aa, ab, ba, bb, …}
– The language consists of all non-empty strings +
• + = * - {}
– Operations over languages
• Reverse L: LR = {wR: wL }
• Complementation of L: Lc = * - L
• Concatenation: L1L2 = {xy: xL1, yL2}
• Ln = {x1x2…xn: xiL}
– L0 = {}
– L* = L0  L1  …
– L+ = L1  L2  …

2017 Spring 12
2. Grammar: a set of rules for generating strings
– G=(V, T, P, S)
– V: set of variables
– T: set of terminals (symbols)
– P: set of production rules
– SV: the start variable

2017 Spring 13
Example
G=({S,A,B}, {a,b}, {SaA, AbS, S}, S)
• String generation/derivation

• The language generated by G


– L(G) = {w | S * w}

2017 Spring 14
• Problem: find grammars for languages over ={a, b}
– L1 = {anbn | n0}
– L2 = {w | na(w)=nb(w)}
– L3 = {anbm | nm0}

2017 Spring 15
3. Automaton: an abstract model of a digital
computer
– Input
– Control unit: represented by “states”
– Storage
– Output
– Operating in discrete time frame

2017 Spring 16
2017 Spring 17
Language representation
• Informal description
– L = {aa, aaa, aab, aaaa, …}
– L = {anbn | n0 }
• Formal description
– Grammar: language generator
• It tells us how a string in a language is generated
– Automata: language acceptor
• It tells us whether a given string belongs to a language

2017 Spring 18

You might also like