1.09k likes | 1.41k Views
Chapter 0. CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne. Foundations for Programming Languages Introduction to Lexical Analysis. CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne.
E N D
Chapter 0 CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne Foundations for Programming Languages Introduction to Lexical Analysis
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne Regular Expressions, Finite State Machines, Regular Grammars Languages and Strings Given some string s and some language L, is s in L? For example, is the string ѡ is a string representation of a floating point number for a given programming language JAVA? An alphabet ∑ is a finite set which contains symbols or characters. Example, for a machine language, the alphabet ∑ consists of 0 and 1. ∑ consists of 127 ASCII characters or 255 Extended ASCII characters.
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne Strings A string ѡ is a finite sequence, possibly empty ɛ, of symbols in ∑. Given an alphabet ∑, the shortest string that can be formed from ∑ is the empty string ɛ. The length of ɛ, | ɛ| = 0. The length of a string ѡ is the number of symbols in ѡ. The set of all possible strings over an alphabet ∑, is written as ∑*. * is the Kleene star operator. For example, let ∑ = {0, 1}. Then ∑* = { ɛ, 0, 1, 00, 01, 10, 11, 000, 001, 010, 011, 100, 101, 110, 111, 0000, 0001, ….}
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne For any symbol c and string ѡ, define the function #c(ѡ) to be the number of times that the symbol c occurs in ѡ. For example #c(cadcbcc) = 4. The concatenation of two strings s and t, (written as s||t or st) is the string formed by appending t to s. For example, let x = good and y = bye, then xy = goodbye. So |xy| = |x| + |y|. The empty string, ɛ, is the identity for concatenation of strings. For every x, x ɛ = ɛx = x. Let concentration be a function defined on strings. Then concentration is associative. So, for strings s, t, w, (st)w = s(tw).
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne Define string replication. Let each string w and each natural number i, the string wi is defined as follows: w0 = ɛ wi+1 = wi w. For example, a3 = aaa. (good)2 = goodgood. a0b3 = bbb. Define string reversal. For each string w, the reverse of ѡ, which is ѡR . We define ѡR as: If |ѡ| = 0. Then ѡR = ѡ = ɛ. If |ѡ| ≥ 1, then there exists a in ∑ and there exists u in ∑*, ѡ = ua. Then define ѡR = auR
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne Theorem 0.1 Concatenation and Reverse of Strings If w and x are string, then (wx)R = xRwR .
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne Relations on Strings A string s is a substring of a string t if and only if s occurs contiguously as part of t. For example, aaa is a substring of aaabbbaaa. aaaa is not a substring of aaabbbaaa. A string s is a proper substring of a string t iff s is a substring of t and s ≠ t. Every string is a substring (although not a proper substring) of itself. The empty string ɛ, is a substring of every string.
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne Relations on Strings A string s is a prefix of t iff there exist x in ∑*, t = sx. A string s is a proper prefix of a string t iff s is a prefix of t and s ≠ t. Every string is a prefix (although not a proper prefix) of itself The empty string ɛ, is a prefix of every string. For example, the prefixes of abba are: ɛ, a, ab, abb, abba.
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne Relations on Strings A string s is a suffix of t iff there exist x in ∑*, t = xs. A string s is a proper suffix of a string t iff s is a suffix of t and s ≠ t. Every string is a suffix (although not a proper suffix) of itself The empty string ɛ, is a suffix of every string. For example, the prefixes of abba are: ɛ, a, ba, bba, abba.
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne Languages A language is a finite or infinite set of strings over a finite alphabet ∑. Use the notation ∑L to mean the alphabet from which the strings in the language L are formed. (∑L denotes “L is the subscript of ∑.) Example: Defining Languages over Given an Alphabet Let ∑ = {a, b}. ∑* = { ɛ, a, b, aa, ab, ba, bb, aaa, aab, …}. Some examples of languages over ∑ are: , { ɛ }, {b}, {a, b}, { ɛ, a, aa, aaa, aaaa, aaaaa}, { ɛ, a, aa, aaaa, aaaaaaaaa, aaaaa, …..}. Given L = { ɛ, a, aa, aaa, aaaa, aaaaa}, ∑L = { a }.
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne Techniques for defining languages: Example: Strings that end in 0. Let L = { x | y {0, 1}*, x = y0}. L contains of all strings that can be formed by taking some string in {0, 1}* and concatenating a string 0 onto the end of it. The strings 0, 00, 000, 0110, 1100 and 10 are in L. The strings ɛ, 101, and 11001 are not in L. L contains of all strings that can be formed by taking some string in {0, 1}* and concatenating a string 0 onto the end of it.
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne Example: The empty Language: Let L = { } = . L is the language that contains no strings. Example: The Empty language is different from the empty string. Let L = { ɛ }, the language that contains a single string ɛ, which is an empty string. Note that this L= { ɛ } is different from (i.e., L = { } = . )
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne Language Generator (Language Enumerator) The logical definition, L = { x | y {0, 1}*, x = y0} can be turned into either a language generator (enumerator) or a language recognizer.
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne What is the total order? The key properties a total order must have are: Transitivity - if x comes before y, and y comes before z, then x comes before z.Totality - either x comes before y, or y comes before x.Asymmetry - if x comes before y, then y doesn't come before x. (If they are, then x and y must be the same one.) A partial order relation iff R is transitive and anti-symmetric.
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne When considering an enumerator for a language L, if there exists a total order D of the element of ∑L, then we can use D to define on L a useful order called lexicographic order (written as <L). e.g., the letters of the Roman alphabet or symbols for the digits 0 – 9 are in total order. A program lexicographically enumerates the elements of L if and only if it enumerates them in lexicographic order, (written as <L, a total order). Example: Lexicographic Enumeration Let L = {x {a, b}*| all a’s precede all b’s}. The lexicographic enumeration of L is: ɛ, a, b, aa, ab, bb, aaa, aab, abb, bbb, aaaa, aaab, aabb, abbb, bbbb, aaaaaa, …..
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne The Cardinality of a Language How large is a language? The smallest language over any alphabet is , whose cardinality is 0. The largest over any alphabet ∑ is ∑*. What is |∑*|? Suppose that ∑ = Then∑* = { ɛ } and | ∑*| = 1. Suppose that ∑ = {0, 1}, Then ∑* = { ɛ, 0, 1, 00, 01, 10, 11, 000, 001, …}. Some examples of languages over ∑ are: , { ɛ }, {0}, {1}, {0, 1}, { ɛ, 0, 01, 000, 001, …}, { ɛ, 1, 11, 111, 1111, 11111, …..}. What is the Cardinality of this language | ∑* |? This is, | {0, 1}*|.
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne Theorem 2.2 The Cardinality of ∑* : If ∑ ≠ , then ∑* is countably infinite, Proof: The element of ∑* can be lexicographically enumerated by a straightforward procedure that: Enumerates all strings of length 0, then length 1, then length 2, and so forth. Within the strings of a given length, enumerates them in dictionary order. The enumeration is infinite since there is no longest string in ∑*. Since there exists an infinite enumeration of ∑*, it is countably infinite. (need to show!) QED.
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne How many languages are there? Let ∑ be an alphabet. How many different languages are there that are defined on ∑? The set of languages defined on ∑ is P(∑*), the power set of ∑*, or the set of all subsets of ∑*. If ∑ = , then ∑* is { ɛ } and P(∑*) is { , { ɛ } }. What about the useful case in which ∑ is not empty?
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne Theorem 2.3 An uncountably infinite number of languages: Theorem: If ∑ ≠ , then the set of language over ∑ is uncountably infinite. Proof: The set of languages defined on ∑ is P(∑*). By Theorem 2.2, ∑* is countably infinite. Then if S is a countably infinite set, P(∑*) is uncountably infinite. (need to show!). So P(∑*) is uncountably infinite. QED.
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne Concatenation of two Languages Let L1 and L2 be two languages defined over some alphabet ∑. Then their concatenation, written L1 L2 is: L1 L2 = {ѡ∑* | s L1 ( t L2 (ѡ = st))}. Example: Concatenation of two languages Let L1 = {cat, dog, mouse, bird}, and L2 = {bone, food}. Then L1 L2 = { catbone, catfood, dogbone, dogfood, mousebone, mousefood, birdbone, birdfood}. The language { ɛ } is the identity for concatenation of languages. For all languages L, L{ɛ} = {ɛ}L = L.
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne The language is a zero for concatenation of languages. For all languages L, L = L = . The is a zero follows from the definition of the concatenation of two languages as the set consisting of all strings that can be formed by selecting some string s from the first language and some string t from the second language and then concatenating them together. Concatenation, as a function defined on languages, is associative. So for all languages L1 , L2 and L3 : ((L1 L2 ) L3 ) = (L1 ( L2 L3 ))
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne Let L1 = { an | n ≥ 0 } which is a brief statement of { ѡ | n ≥ 0 (ѡ = an )}. L2 = { bn | n ≥ 0 }. Then L1 L2 = { ambn| m, n ≥ 0 }. That is, L1 L2 consists of a (possible empty) a region followed by a (possible empty) b region. This L1 L2 = { ambn| m, n ≥ 0 } ≠ L1 L2 = { anbn| n ≥ 0 }, which requires every string to have the same number of b’s as a’s.
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne Kleene Star of L Let L be a language defined over some alphabet ∑. Then the Kleene star of L, written L* is: L* = { ɛ }{ ѡ | ѡ L (ѡ = ѡ1 ѡ2 …,ѡk ))}. That means, L* is the set of strings that can be formed by concatenating together zero or more strings over L. Example of Kleene Star Let L = {dog, cat, fish}. Then L* = { ɛ, dog, cat, fish, dogdog, dogcat, …, fishdog, …. fishcatfish, fishdogfishcat, ….}
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne L* always contains an infinite number of strings as long as L is not equal to either or { ɛ }. If L = then L* = { ɛ }, since there are no strings that could be concatenated to ɛ to make it longer. If L = { ɛ }, then L* = { ɛ } also. For requiring that at least one element of L be selected, we define: L+ = L L*. L+ is the closure of L under concatenation. That is L+ = L* - { ɛ } if and only if ɛ L. Example of L+: Let L = {0, 1}+ be the set of binary strings L does not include ɛ.
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne Reverse of Languages Let L be a language defined over some alphabet ∑. Then the reverse of L, written LR is: LR = { ѡ ∑* | ѡ = x R for some x L}.
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne Theorem 2.4 Concatenation and Reverse of Languages Theorem: If L1 and L2 are languages. Then (L1 L2 )R = L2R L1R . Proof: if x and y are strings , then for ((xy )R = yRxR ))) Theorem 2.1. (L1 L2 )R = { (xy )R | x L2 } Definition of Concatenation of languages = { yRxR | x L2 } Lines 1 and 2 = L2R L1R . Definition of concatenation of languages.
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne Example: Conclude what we have learnt to our real world. Let ∑ = {+, -, =, 1, 4, x, i, n, t, ;}. ∑* = { ɛ, +, -, =, 1, 4, x, i, n, t, ;, ++, +-, -+, --, +=, =+, ==, +1, + 4, + i, … +++, …, iii,… 4 = int x; x++;, int x = 4; x++;} Some examples of languages over ∑ are: , { ɛ }, {+, -, =, 1, 4, i, n, t, ;}, { ɛ, +, ++ }, { ɛ, -, -- }, { 4 = int x; x++;, 4 = int x; ++x; , 4 = int x; x = x +1;, 4 = int x, x = x - -1;}, {int x = 4; x++;, int x = 4; ++x; , int x = 4; x = x +1;, int x = 4, x = x - -1;}. The language{ int x = 4; ++x; , int x = 4; x = x +1;, int x = 4, x = x - -1;} are chunks of Java code all of which do the same thing. Each string in this language has a special specification through formal grammar, and has its own semantics (meanings).
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne • Language Recognition • Assume that we are given: • The definition of a language L, and • A string ѡ • Then we must answer the question “is string ѡ in language L?”. The answer is yes/no decision. • We call decision problems. A decision problem is simply a problem that requires a yes or no answer. • An algorithm is a detailed procedure that accomplishes some clearly specified task. • A decision procedure is an algorithm to solve a decision problem. That is, it is a program whose result is a Boolean value. For guaranteed to return a Boolean value, a decision procedure must be guaranteed to halt on all inputs.
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne A Machine-based Hierarchy of Language Classes FSM and Regular Languages At a state, the machine reads an input, then take the transition to next state. The class of languages that can be accepted by some Finite State Machine (FSM) is regular. e.g., binary strings with even parity, syntactically well-formed floating point numbers, and sequences of coins that are sufficient to buy a soda, … are useful languages which are regular. Note that FSM accepts L = {0m 1n} but not L = {0n 1n}.
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne Pushdown Automaton and Context-Free Languages Any machine which consists of an FSM, plus a single stack, is a Pushdown Automaton (PDA). We label an arrow (a transition) going from a state to another state x/y/z, which means “if the input is an x, and it is possible to pop y off the stack, then take the transition, do the pop of y, and push z”. The class of languages that can be accepted by some PDA is context-free. e.g., The language of balanced parentheses, palindrome, most programming languages, query languages, markup languages, …, are examples of useful context free languages. Note that, PDA accepts L = {0n 1n} but not L = {0n 1n 0n}. x/y/z s t
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne Turing Machine and Language L which is decidable Any machine has an infinite tape with a single read/write head. The read/write head can be moved one tape square in either direction on each move. This machine is a Turing machine. A language L is decidableiff there exists a Turing machine M that halts on all inputs, accepts all strings that are in L, and rejects all strings that are not in L. In other words, M can always say yes or no, as appropriate. A language L is semidecidableiff there exists a Turing machine M that accepts all strings that are in L, and fails to accept every string that is not in L. Given a string that is not in L, M may reject or it may loop forever. In other words, M can recognize a solution and then says yes, but it may not know when it should give up looking for a solution and say no.
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne SD Languages D Languages Context-Free Languages Context-free Languages Regular Language Regular Languages FSM PDA Turing Machine Figure 3.4 A hierarchy of language classes.
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne • We may ask questions such as: • Given a machine (an FSM, a PDA, or a Turing machine), does it accept any strings? • Given two machines, do they accept the same strings? • Given a machine, is it the smallest (simplest) machine that does it jobs?
Decision Procedures • If we have in mind a decision problem to which we want an answer, there are three things we may want to know: • Does there exist a decision procedure (i.e, an algorithm) to answer the question? • A decision problem is decidableiff the answer to this question is yes. • A decision problem is undecidableiff the answer to this question is no. • A decision problem is semidecidableiff there exists an algorithm that halts and returns True iff True is the answer. When False is the answer, it may either halt and return False or it may loop. Some undecidable problems are semidecidable; some are not even that. • If any decision procedures exist, find one. • Again, if any decision procedures exist, what is the most efficient one and how efficient is it?
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne • Decision procedures are programs. They must possess two correctness properties: • The program must be guaranteed to halt on all inputs. • When the program halts and returns an answer, it must be the correct answer for the given input. • Example of Checking for Even Numbers • Is the integer x even? • Assume that / performs (truncating) integer division. Then the following program answers the question: • even( x : integer) = • if (x / 2) * 2 = x then return True else return False;
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne Finite State Machines A finite state machine (or FSM) is a computational device whose input is a string whose output is one of two values that we can call Accept and Reject. FSMs are also called finite state automata (or FSA). e.g. , A telephone switching circuit can easily be modeled as a DFSM.
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne • For example: A vending machine controller can be implemented using a DFSM. • Let consider to buy a drink for $1.25. We only allow the vender machine accepts dimes, quarters, 1-dollar bills, and 5-dollar bill. • The vending machine controller will receive a sequence of inputs, each of which corresponds to one of the following events: • A coin/bill is deposited into the machine. We can use the symbols Q (for quarter), B (for 1-dollar bill) and D (for 5-dollar bill) to represent these events. • The coin return button is pushed. We can use the symbol R (for return) to represent this event. • A drink button is pushed and a drink is dispensed. We can use this symbol S (for soda) for this event. • After any finite sequence of inputs, the controller will be in either: • A dispensing state, in which it is willing to dispense a drink button is pushed. • A nondispensing state, in which not enough money has been inserted into the machine.
S/R (Buy drink or Return coins) S0 R (Return) R Q R R Q Q 25 Q Q 100 50 125 75 B B ($1.00) 200 R Q S R 225 250 R 375 S S S D ($5.00) 500 R 400 275 S R S 525 S S (Soda) 150 S
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne Deterministic Finite State Machines Formally a deterministic FSM (or DFSM) M is a quintuple (K, ∑, δ, s, A). where K is a finite set of states, ∑ is the input alphabet, s K is the start state, A K is the set of accepting states, and δ is the transition function mapping from K x ∑ to K. (That is δ: K x ∑ → K.) A configuration of a DFSM M is an element of K x ∑*. It is a snapshot of M, capturing its current state, and the input that is still left to read. For example, (q , cѡ) to denote at a state q, that input that is still left to read cѡ.
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne The initial configuration of a DFSM M, on input ѡ, is (sM , ѡ), where sM is the start state of M. The transition function δ defines the operation of a DFSM M one step at a time. We can use it to define the sequence of configuration that M will enter. We define the relation yield-in-one-step, |M. yield-in-one-step relates configuration1 to configuration2 if and only if M can move from configuration1 to configuration2 in one step. Let c be any element of ∑ and let ѡ be any element of ∑*. Then (q1 , cѡ) |M (q2 , ѡ) if and only if ((q1 , c), q2 ) δ. We now can define the relation yields, written |M* to be reflexive, transitive and closure of |M. So configuration C1 yields configuration C2iff M can go from C1 to C2 in zero or more steps. In this case we will write: C1 |M* C2. Closure of |M: |M + = |M* - { ε } iffε is not in the configuration |M.
A computation by M is a finite sequence of configuration C0, C1, C2, … Cn for some n ≥ 0 such that : • C0 is an initial configuration • Cn is of the form (q, ɛ), for some state q KM (i.e., the entire input string has been read), and • C0 |MC1 |MC2 |M…. |MCn. • Let ѡ be an element of ∑*. We say that: • M acceptsѡ iff (s, ѡ) |M*(q, ɛ), for some q AM.Any configuration (q, ɛ), for some q AM, is called an accepting configurationof M. • M rejects s ѡ iff (s, ѡ) |M*(q, ɛ), for some q AM.Any configuration (q, ɛ), for some q AM, is called a rejecting configurationof M. • M halts whenever it enters either an accepting or a rejecting configuration. • The language accepted by M, denoted by L(M), is the set of all strings accepts by M.
Example: Checking for odd parity Let L = { ѡ {0, 1}* | ѡ has odd parity}. A binary string has odd parity iff the number of 1’s in it is odd. So L can be accepted by the DFSM M: 0 1 0 An example of M’s operation, consider the input string 001110. M’s computation is the sequence of configurations: (q0, 001110), (q0, 01110), (q0, 1110), (q1, 110), (q0, 10), (q1, 0), (q1, ɛ). Since q1 is an accepting state, M accepts. q1 q0 1 M = ({q0 , q1 }, {0, 1}, δ, q0, { q1}), where δ = { ((q0, 0), q0), ((q0, 1), q1), ((q1, 0), q1), ((q1, 1), q0) }
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne Example of Even Length Regions of 0’s Let L = { ѡ {0, 1}* | every 0 region in ѡ is of even length}. L can be accepted by the DFSM M. If M sees an 1 in state q1, then there has been an 0 region whose length is odd. So no matter what happens next, M must reject. So it goes to the dead state d. 0 1 q0 q1 0 1 0, 1 d
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne Theorem 5.1 DFSMs Halt. Theorem: Every DFSM M, on input ѡ, halts after | ѡ | steps. Proof: On input ѡ, M executes some computation C0 |-M C1 |-M C2 |-M … |-M Cn, where C0 is an initial configuration and Cn is of the form (q, ɛ), for some state q KM . Cn is either an accepting or a rejecting configuration, so M will halt when it reaches Cn. Each step in the computation consumes one character of ѡ. So n = | ѡ |. Thus M will halt after | ѡ | steps. QED
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne We define the set of regular languages to be exactly those that can be accepting by some DFSM. Note: The language of universal resource identifiers (URIs), used to describe objects on the World Wide Web, is regular.
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne • Example: Floating Point numbers. • Let FLOAT = { ѡ | ѡ is the string representation of a floating point number}. • Assume the following syntax for floating numbers: • A floating point number is an optional sign, followed by a decimal number, followed by an optional exponent. • A decimal number may be of the form x or x.y where x and y are non-empty strings of decimal digits. • An exponent begins with E and is followed by an optional sign and then an integer. • An integer is a non-empty string of decimal digits’ • e.g., these strings represent floating point numbers: • +3.0, 3.0, 0.3E1, 0.3E+1, -0.3E+1, -3E8, 4E-32.
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne d d d d E . +,- d +, - E d d In this diagram d stands for any one of the decimal digits (0, 1, …, 9). We omitted the dead state to avoid arrows crossing over each other. d
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne Example: A simple Communication Protocol Let L be a language that contains all the legal sequences of messages that can be exchanged between a client and a server using a simple communication protocol. Let consider only a very simplified version of such a protocol, but the idea can be extended to a realistic model. Let ∑L = {Open, Request, Reply, Close}. Every string in L begins with Open and ends with Close. Every Request, except possibly the last, must be followed by Reply and no unsolicited Reply’s may occur. L is regular because it be accepted by the DFSM: Let Omit the dead state. Reply Close Request Open Close
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne Note: More realistic communication protocols can also be modeled as FSMs. Note: A building security system can be described as a DFSM that sounds an alarm if given an input sequence that signals an intruder.
CS 35000 Programming Language Design Indiana University – Purdue University Fort Wayne Simulating Deterministic FSMs We begin by considering only deterministic FSMs. On approach is to think of an FSM as the specification for a simple table-driven program and then proceed to write the code. Example: Hardcoding a Deterministic FSM Consider the following deterministic FSM M that accepts the language L = { ѡ {0, 1}* | ѡ contains no more than one 1}. 0 What is L? L = {0, 1}* = { ε, 0, 1, 00, 01, 10, 11, 000, 001, 010, 100, 011, 101, 110, 111, …} 0 1 t s