Upload
nathaniel-banks
View
256
Download
7
Embed Size (px)
Citation preview
11
Chapter 1 Automata: the Chapter 1 Automata: the Methods & the MadnessMethods & the Madness
Angkor Wat, Cambodia
Chapter 1 - Chapter 1 - 22
OutlineOutline
1.1 Why Study Automata Theory?1.1 Why Study Automata Theory?1.2 Introduction to Formal Proof1.2 Introduction to Formal Proof1.3 Additional Forms of Proof1.3 Additional Forms of Proof1.4 Inductive Proofs1.4 Inductive Proofs1.5 Central Concepts of Automata 1.5 Central Concepts of Automata
TheoryTheory
Chapter 1 - Chapter 1 - 33
1.1 Why Study Automata 1.1 Why Study Automata Theory?Theory?
1.1.1 Introduction to Automata1.1.1 Introduction to Automata
Properties of finite-state systemsProperties of finite-state systems
Having a Having a finite finite number of statesnumber of states
Entire history Entire history cannotcannot be remembered. be remembered.
Good to implement with a fixed set of resourcesGood to implement with a fixed set of resources
Can be modeled by Can be modeled by finite automata (FA)finite automata (FA)
Chapter 1 - Chapter 1 - 44
1.1 Why Study Automata 1.1 Why Study Automata Theory?Theory?
Example 1.1 --- an FA modeling an on/off switchExample 1.1 --- an FA modeling an on/off switch
Example 1.2 --- an FA modeling recognition of the Example 1.2 --- an FA modeling recognition of the keyword “then” in a lexical analyzerkeyword “then” in a lexical analyzer
The double circles specify the final or “accepting state.”The double circles specify the final or “accepting state.”
startstart t
t h
th e
the n
then
offstartstart on
push
push
Chapter 1 - Chapter 1 - 55
1.1 Why Study Automata 1.1 Why Study Automata Theory?Theory?
1.1.2 Structural Representation1.1.2 Structural RepresentationTwo other models (not automaton-like)Two other models (not automaton-like)
Grammar Grammar --- processing data with a recursive structure--- processing data with a recursive structureE.g., grammatical rule E E.g., grammatical rule E E + E for generating arithmetic e E + E for generating arithmetic e
xpressionsxpressions
Regular expressionRegular expression --- describing text strings --- describing text stringsE.g., UNIX-style regular expression E.g., UNIX-style regular expression
’’[A-Z][a-z]*[ ][A-Z][A-Z]’ describes [A-Z][a-z]*[ ][A-Z][A-Z]’ describes Ithaca NYIthaca NY, , Lafayette INLafayette IN……
Chapter 1 - Chapter 1 - 66
1.1 Why Study Automata 1.1 Why Study Automata Theory?Theory?
1.1.3 Automata and Complexity1.1.3 Automata and Complexity
What can a computer do? --- What can a computer do? ---
Computability:Computability:
Studying problems which can be solved by Studying problems which can be solved by
computer, called computer, called decidable problems.decidable problems.
Decidability Decidability is the main topic in computability.is the main topic in computability.
Chapter 1 - Chapter 1 - 77
1.1 Why Study Automata 1.1 Why Study Automata Theory?Theory?
1.1.3 Automata and Complexity1.1.3 Automata and ComplexityWhat can a computer do efficiently? --- What can a computer do efficiently? ---
Computational ComplexityComputational Complexity::Studying Studying tractable problemstractable problems solvable with some solvable with some
slowly growing function (like polynomial) of input slowly growing function (like polynomial) of input
size, & size, & intractableintractable problemsproblems solvable with fast solvable with fast
growing function (like exponential).growing function (like exponential).
Intractability Intractability is the main topic of computational is the main topic of computational
complexity.complexity.
Chapter 1 - Chapter 1 - 88
1.2 Introduction to Formal 1.2 Introduction to Formal ProofProof
1.2.0 Concepts ---1.2.0 Concepts ---
Formal proof techniques are indispensable Formal proof techniques are indispensable
for proving theorems in theory of for proving theorems in theory of
computation.computation.
Understanding workings of correct Understanding workings of correct
programs is equivalent to proving theorems programs is equivalent to proving theorems
by induction.by induction.
Chapter 1 - Chapter 1 - 99
1.2 Introduction to Formal 1.2 Introduction to Formal ProofProof
1.2.1 Deductive Proofs (1.2.1 Deductive Proofs ( 演繹法演繹法 ))
Given facts (e.g. axioms), previous statementsGiven facts (e.g. axioms), previous statements
HypothesisHypothesis deduced statementsdeduced statements … … conclusion conclusion Logic principlesLogic principles
Logic principles: modus ponens (Logic principles: modus ponens ( 正前律、離斷規則、肯定正前律、離斷規則、肯定前件前件 )), syllogism (, syllogism ( 三段論三段論 )…)…
1.2.2~1.2.4 --- read by yourself1.2.2~1.2.4 --- read by yourself
Chapter 1 - Chapter 1 - 1010
1.2 Introduction to Formal 1.2 Introduction to Formal ProofProof
Modus ponensModus ponens ( (正前律、離斷規則、肯定前正前律、離斷規則、肯定前件件 ))An example:An example:
If it rains, the sidewalk will be wet.If it rains, the sidewalk will be wet.It rains now.It rains now.So the sidewalk is wet.So the sidewalk is wet.
SyllogismSyllogism ( ( 三段論三段論 ) ) (supplemental)(supplemental)An example:An example:
All humans will die. All humans will die. Socrates is a human. Socrates is a human. So, Socrates will die.So, Socrates will die.
Chapter 1 - Chapter 1 - 1111
1.3 Additional Forms of Proof1.3 Additional Forms of Proof
1.3.0 Some more proof techniques ---1.3.0 Some more proof techniques ---Proofs about setsProofs about setsProofs by contradictionProofs by contradictionProofs by counterexamplesProofs by counterexamples
1.3.1~1.3.4 --- read by yourself1.3.1~1.3.4 --- read by yourself
Chapter 1 - Chapter 1 - 1212
1.4 Inductive Proofs (1.4 Inductive Proofs ( 歸納法歸納法 ))
1.4.1 Induction on Integers1.4.1 Induction on IntegersTo prove a statement To prove a statement SS((nn) about an integer ) about an integer n n
by induction, we do:by induction, we do:
Basis Basis --- --- show show SS((ii) true for a particular ) true for a particular basis intebasis integerger ii (0 or 1 usually) (0 or 1 usually)
Inductive stepInductive step --- assume --- assume nn i (basis integer)i (basis integer), sh, show that the statement “if S(ow that the statement “if S(nn), then S(), then S(nn + 1)” is tr + 1)” is true.ue.
1.4.2~1.4.4 --- read by yourself1.4.2~1.4.4 --- read by yourself
Chapter 1 - Chapter 1 - 1313
1.5 Central Concepts of 1.5 Central Concepts of Automata TheoryAutomata Theory
1.5.0 Three basic concepts1.5.0 Three basic concepts
Alphabet Alphabet --- a set of symbols--- a set of symbols
Strings Strings --- a sequence of symbols from an --- a sequence of symbols from an
alphabetalphabet
Language Language --- a set of strings from the same --- a set of strings from the same
alphabetalphabet
Chapter 1 - Chapter 1 - 1414
1.5 Central Concepts of 1.5 Central Concepts of Automata TheoryAutomata Theory
1.5.1 Alphabets1.5.1 Alphabets
Definition --- Definition ---
An An alphabetalphabet is a is a finitefinite, , nonempty nonempty set set
of symbols.of symbols.
Conventional notation --- Conventional notation ---
Chapter 1 - Chapter 1 - 1515
1.5 Central Concepts of 1.5 Central Concepts of Automata TheoryAutomata Theory
1.5.1 Alphabets1.5.1 Alphabets
The term “symbolsymbol” is usually undefined.
Examples ---
Binary alphabet
a, b, …, z} …
Chapter 1 - Chapter 1 - 1616
1.5 Central Concepts of 1.5 Central Concepts of Automata TheoryAutomata Theory
1.5.2 Strings1.5.2 StringsDefinition --- Definition ---
A A stringstring (or word) is a (or word) is a finite sequencefinite sequence of of
symbols from an alphabet.symbols from an alphabet.
Example --- Example --- 1011 is a string from alphabet 1011 is a string from alphabet
Chapter 1 - Chapter 1 - 1717
1.5 Central Concepts of 1.5 Central Concepts of Automata TheoryAutomata Theory
1.5.2 Strings1.5.2 Strings
Empty string Empty string --- a string with zero --- a string with zero
occurrences of symbolsoccurrences of symbols
Length |Length |ww| | of string of string ww --- the number of --- the number of
positions positions for symbols in for symbols in ww
Examples --- |0111|=4, |Examples --- |0111|=4, ||=0, …|=0, …
Chapter 1 - Chapter 1 - 1818
1.5 Central Concepts of 1.5 Central Concepts of Automata TheoryAutomata Theory
1.5.2 Strings1.5.2 Strings
PowerPower of an alphabet of an alphabet kk --- ---
a set of all strings of length a set of all strings of length kk
Examples --- Examples ---
givengiven we havewe have
= {= {22 = {00, 01, 10, 11} = {00, 01, 10, 11}
Supplemental --- Supplemental --- 1100 = = (01)(01)00 = = … …
Chapter 1 - Chapter 1 - 1919
1.5 Central Concepts of 1.5 Central Concepts of Automata TheoryAutomata Theory
1.5.2 Strings1.5.2 Strings
Set of all strings over Set of all strings over --- denoted as --- denoted as
It is not difficult to know that It is not difficult to know that
∪∪ ∪∪ ∪∪ ……
Chapter 1 - Chapter 1 - 2020
1.5 Central Concepts of 1.5 Central Concepts of Automata TheoryAutomata Theory
1.5.2 Strings1.5.2 Stringsset of nonempty strings fromset of nonempty strings from
Therefore, we haveTherefore, we have
∪∪ ∪∪ ∪∪……
∪∪
Chapter 1 - Chapter 1 - 2121
1.5 Central Concepts of 1.5 Central Concepts of Automata TheoryAutomata Theory
1.5.2 Strings1.5.2 StringsConcatenationConcatenation of two strings of two strings xx and y --- and y --- xyxy
Example --- Example ---
ifif x x = 01101= 01101, y, y = = 110110, then, then
xyxy = 01101 = 01101110, 110, xx xx = x= x= = 0110101101, …0110101101, …
is the is the identity identity for concatenation for concatenation
since since ww = = www.w.
Chapter 1 - Chapter 1 - 2222
1.5 Central Concepts of 1.5 Central Concepts of Automata TheoryAutomata Theory
1.5.2 Strings 1.5.2 Strings (supplemental)(supplemental)PowerPower of a string --- of a string ---
Defined by concatenation ---Defined by concatenation ---
xxii = = xxxx……xx ( (xx concatenated concatenated ii times) times)
Defined by recursion ---Defined by recursion ---
xx00 = = (by definition) (by definition)
xxii = = xxxxii-1-1
Chapter 1 - Chapter 1 - 2323
1.5 Central Concepts of 1.5 Central Concepts of Automata TheoryAutomata Theory
1.5.3 Languages1.5.3 LanguagesDefinition --- Definition ---
a a languagelanguage is a set of strings all chosen is a set of strings all chosen from some from some **
If If is an alphabet, and is an alphabet, and LL**, then , then LL is a is a language over language over ..
Chapter 1 - Chapter 1 - 2424
1.5 Central Concepts of 1.5 Central Concepts of Automata TheoryAutomata Theory
1.5.3 Languages1.5.3 LanguagesExamples ---Examples ---
The set of all legal English The set of all legal English words words is a is a language. Why? What is the alphabet language. Why? What is the alphabet here? here?
Answer:Answer: the set of all letters the set of all letters
A legal program of C is a language. Why? A legal program of C is a language. Why? What is the alphabet here? What is the alphabet here?
Answer:Answer: a subset of the ASCII characters. a subset of the ASCII characters.
Chapter 1 - Chapter 1 - 2525
1.5 Central Concepts of 1.5 Central Concepts of Automata TheoryAutomata Theory
1.5.3 Languages1.5.3 Languages
More examples of languages ---More examples of languages ---
The set of all strings of The set of all strings of nn 0’s followed by 0’s followed by nn 1’s 1’s
for for nn 0 0::
{{, 01, 0011, 000111, …}, 01, 0011, 000111, …}
* * is anis an infiniteinfinite language for any alphabet language for any alphabet ..
Chapter 1 - Chapter 1 - 2626
1.5 Central Concepts of 1.5 Central Concepts of Automata TheoryAutomata Theory
1.5.3 Languages1.5.3 Languages
More examples of languages (cont’d) ---More examples of languages (cont’d) ---
the the empty languageempty language (not the empty string (not the empty string
is a language over any alphabet.is a language over any alphabet.
{{}} is a language over is a language over anyany alphabet (consisting alphabet (consisting
of only one string, the empty string of only one string, the empty string ).).
Chapter 1 - Chapter 1 - 2727
1.5 Central Concepts of 1.5 Central Concepts of Automata TheoryAutomata Theory
1.5.3 Languages1.5.3 Languages Ways to describe languages (1/3) ---Ways to describe languages (1/3) ---
Description byDescription by exhaustive listing exhaustive listing --- ---
LL1 = {1 = {aa, , abab, , abcabc} (finite language; listed one by one)} (finite language; listed one by one)
LL2 = {2 = {aa, , abab, , abbabb, , abbb, abbb, ...} (infinite language; listed pa...} (infinite language; listed pa
rtially)rtially)
LL3 = 3 = LL((abab*)*) (infinite language; expressed by a regular (infinite language; expressed by a regular
expression) expression)
Chapter 1 - Chapter 1 - 2828
1.5 Central Concepts of 1.5 Central Concepts of Automata TheoryAutomata Theory
1.5.3 Languages1.5.3 Languages
Ways to define languages (2/3) ---Ways to define languages (2/3) ---
Description byDescription by generic elements generic elements --- ---
LL4 = {4 = {xx | | xx is over is over VV = { = {aa, , bb}, begins with }, begins with a,a,
followed by any number of followed by any number of bb, possible none} , possible none}
(note: (note: LL4 = 4 = LL3 = 3 = LL2)2)
Chapter 1 - Chapter 1 - 2929
1.5 Central Concepts of 1.5 Central Concepts of Automata TheoryAutomata Theory
1.5.3 Languages1.5.3 Languages
Ways to define languages (3/3) ---Ways to define languages (3/3) ---
Description byDescription by integer parameters integer parameters --- ---
LL5 = {5 = {ababnn | | n n 0} 0}
(note: (note: LL5 = 5 = LL4 = 4 = LL3 = 3 = LL2)2)
*** *** bbnn = power of a symbol = power of a symbol
Chapter 1 - Chapter 1 - 3030
1.5 Central Concepts of 1.5 Central Concepts of Automata TheoryAutomata Theory
1.5.3a Operations on Languages 1.5.3a Operations on Languages (supplemental)(supplemental)(1/2)(1/2)
Languages are sets, and operations of sets may be Languages are sets, and operations of sets may be
applied to them:applied to them:
(1) union --- (1) union --- AA∪∪BB = { = {aa | | aa AA or or aa BB}}
(2) intersection --- (2) intersection --- AA∩∩BB = { = {aa | | aa AA and and aa BB}}
(3) difference --- (3) difference --- AA B B = {= {aa | | aa AA and and aa BB}}
A
Chapter 1 - Chapter 1 - 3131
1.5 Central Concepts of 1.5 Central Concepts of Automata TheoryAutomata Theory
1.5.3a Operations on Languages 1.5.3a Operations on Languages (supplemental)(supplemental)(2/2)(2/2)
Languages are sets, and operations of sets may be Languages are sets, and operations of sets may be
applied to them:applied to them:
(4) product --- (4) product --- AA BB = {( = {(aa, , bb) | ) | aa AA and and bb BB}}
(5) complement --- (5) complement --- ĀĀ = {= {aa | | aa UU and and aa AA}}
(6)(6) power set --- power set --- 22AA = { = {BB | | BB AA}}
Note:Note: UU is the is the universal setuniversal set, like , like which is the which is the closureclosure of an of an
alphabetalphabet
A
Chapter 1 - Chapter 1 - 3232
1.5 Central Concepts of 1.5 Central Concepts of Automata TheoryAutomata Theory
1.5.3b More Operations on Languages 1.5.3b More Operations on Languages (supplement(supplement
al)(1/2)al)(1/2)
Concatenation of two languages Concatenation of two languages LL11 and and LL22 --- ---
LL11LL22 = { = {xx11xx2 2 | | xx11 LL11 and and xx22 LL22}}
Power of a language Power of a language L ---L --- Defined directly --- Defined directly ---
LLkk = { = {xx11xx22……xxkk | x | x11, , xx22, …, , …, xxkk LL}}
Defined by recursion --- Defined by recursion --- LL00 = { = {}}
LLii == LL LLii-1-1
A
Chapter 1 - Chapter 1 - 3333
1.5 Central Concepts of 1.5 Central Concepts of Automata TheoryAutomata Theory
1.5.3b More Operations on Languages 1.5.3b More Operations on Languages (supplemental)(2/2)(supplemental)(2/2)
ClosureClosure of language of language LL --- ---
LL** = = = = LL∪∪ LL∪∪ LL∪∪ ……
Positive closurePositive closure of a language of a language L ---L ---
LL++ = = LL∪∪ LL∪∪ ……
It can be shown thatIt can be shown that L L LLLL – – {{} } when when LL
A
0
i
i
L
Chapter 1 - Chapter 1 - 3434
1.5 Central Concepts of 1.5 Central Concepts of Automata TheoryAutomata Theory
1.5.4 Problems1.5.4 ProblemsA problem in automata theory ---A problem in automata theory ---
a question of deciding whether a given string is a question of deciding whether a given string is
a member of some particular language.a member of some particular language.
That is, if That is, if is an alphabet, and is an alphabet, and LL is a is a language over language over , the , the problem problem LL is: is:
given a string given a string ww in in **, decide if, decide ifw w LL or or notnot