DOC PREVIEW
UT CS 341 - Interpreters for Finite State Machines

This preview shows page 1 out of 2 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Lecture Notes 6 Interpreters for Finite State Machines 1 Interpreters for Finite State Machines Deterministic FSAs as Algorithms Example: No more than one b a a a,b b b S T U Length of Program: |K| × (|Σ| + 2) Time required to analyze string w: O(|w| × |Σ|) We have to write new code for every new FSM. Until accept or reject do: S: s := get-next-symbol; if s = end-of-file then accept; else if s = a then go to S; else if s = b then go to T; T: s:= get-next-symbol; if s = end-of-file then accept; else if s = a then go to T; else if s = b then go to U; etc. A Deterministic FSA Interpreter To simulate M = (K, Σ, δ, s, F): ST := s; Repeat i := get-next-symbol; if i ≠ end-of-string then ST := δ(ST, i) Until i = end-of-string; If ST ∈ F then accept else reject Simulate the no more than one b machine on input: aabaa Nondeterministic FSAs as Algorithms Real computers are deterministic, so we have three choices if we want to execute a nondeterministic FSA: 1. Convert the NDFSA to a deterministic one: • Conversion can take time and space 2K. • Time to analyze string w: O(|w|) 2. Simulate the behavior of the nondeterministic one by constructing sets of states "on the fly" during execution • No conversion cost • Time to analyze string w: O(|w| × K2) 3. Do a depth-first search of all paths through the nondeterministic machine.Lecture Notes 6 Interpreters for Finite State Machines 2 A Nondeterministic FSA Interpreter To simulate M = (K, Σ, ∆, s, F): SET ST; ST := E(s); Repeat i := get-next-symbol; if i ≠ end-of-string then ST1 := ∅ For all q ∈ ST do For all r ∈ ∆(q, i) do ST1 := ST1 ∪ E(r); ST := ST1; Until i = end-of-string; If ST ∩ F ≠ ∅ then accept else reject A Deterministic Finite State Transducer Interpreter To simulate M = (K, Σ, O, δ, s, F), given that: δ1(state, symbol) returns a single new state (i.e., M is deterministic), and δ2(state, symbol) returns an element of O*, the string to be output. ST := s; Repeat: i := get-next-symbol; if i ≠ end-of-string then write(δ2(ST, i)); ST := δ1(ST, i) Until i = end-of-string; If ST ∈ F then accept else


View Full Document

UT CS 341 - Interpreters for Finite State Machines

Documents in this Course
Load more
Download Interpreters for Finite State Machines
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Interpreters for Finite State Machines and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Interpreters for Finite State Machines 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?