1 / 30

Regular Expressions: Review

b. a. b. a. b. a. e. e. e. e. a. a. a. a. e. e. e. e. b. b. e. e. a. a. e. e. e. e. e. e. e. e. e. e. e. e. e. e. e. e. b. b. b. b. e. e. e. e. e. e. a. a. e. e. b. e. a. e. e. e. e. e. e. e. e. b. b. e. e.

rozella
Télécharger la présentation

Regular Expressions: Review

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. b a b a b a e e e e a a a a e e e e b b e e a a e e e e e e e e e e e e e e e e b b b b e e e e e e a a e e b e a e e e e e e e e b b e e Regular Expressions: Review A FA for a regular expressionscan be built by composition: Ex: all strings over S={a,b} where $ a “b” preceding an “a” (a+b)*b(a+b)*a(a+b)* = (a+b)*ba(a+b)* Why? e e e e e e e e e e e e e e e Remove previous start/final states

  2. e e a a e e b e a e e e e e e b b e e e e b a,b a a,b e e e e e a,b a,b b a e e e a,b a,b a b e e a a e e b e a e e e e e e e e b b e e FA Minimization: Review Idea: “Equivalent” states can be merged: 16 states! merge merge 3 states!

  3. FA Minimization: Review Theorem [Hopcroft 1971]: the number N of states in a FA can be minimized within time O(N log N). Based on earlier work by [Huffman 1954] and [Moore 1956]. Conjecture: Minimizing the number of states in a nondeterministic FA can not be done in polynomial time. Theorem: Minimizing the number of states in a pushdown automaton (or TM) is undecidable. Project idea: implement a finite automaton minimization tool. Try to design it to run reasonably efficiently. Consider also including: • A regular-expression-to-FA transformer, • A non-deterministic-to-deterministic FA converter.

  4. M M FAs and Regular Expressions: Review Theorem: Any FA accepts a language denoted by some RE. Proof: Use “generalized finite automata” where each transition can be a regular expression (not just a symbol), and: Only one superstart state and one (separate) superfinal state. Every state has transitions to all other states (including itself), except the super start state, with no incoming transitions, and the super final state, which has no outgoing transitions. e M’ Ø e e Ø Ø e e Ø e Ø Ø e Ø e Ø Ø e Original FA M Generalized FA (GFA) M’

  5. M’ P FAs and Regular Expressions: Review Now reduce the size of the GFA by one state at each step. A transformation step is as follows: P P P + RS*T qi qj qi qj qi qj R T q’ RS*T S Such a transformation step is always possible, until the GFA has only two states, the super-start and super-final states: Label of last remaining transition is the regular expression corresponding to the language of the original FA! Corollary: FAs and REs denote the same class of languages.

  6. Regular Expressions Identities: Review • R+S = S+R • R(ST) = (RS)T • R(S+T) = RS+RT • (R+S)T = RT+ST • Ø* = e* = e • R+Ø= Ø+R = R • Re = eR = R • (R*)* = R* • (e + R)* = R* • (R*S*)* = (R+S)* R+e ≠ R RØ ≠ R

  7. Extra credit: use this tool! (to implement some nontrivial TMs, PDAs, grammars, etc.)

  8. Why Study Non-determinism? 1. Helps understand the ubiquitous concept of parallelism / concurrency; 2. Illuminates the structure of problems; 3. Can help save time & effort by solving intractable problems more efficiently; 4. Enables vast, deep, and general studies of “completeness” theories; 5. Helps explain why verifying proofs & solutions seems to be easier than constructing them;

  9. Why Study Non-determinism? 6. Gave rise to new and novel mathematical approaches, proofs, and analyses; 7. Robustly decouples / abstracts complexity from underlying computational models; 8. Gives disciplined techniques for identifying “hardest” problems / languages; 9. Forged new unifications between computer science, math & logic; 10. Non-determinism is interesting fun, and cool!

  10. Problem: compute 1111111112 in your head. 1111111112 = 12345678987654321 111111111 ´111111111 111111111 111111111 111111111 111111111 111111111 111111111 111111111 111111111 111111111 12345678987654321

  11. Problem: What is the approximate value of: 85 2 3 ( ) 1 + = 6*7 -(4 ) 9 85 2 3 ( ) 1 1 + = 6*7 4 9 85 2 3 ( ) 1 1 + = ? 85 2 3 (1+9^(-(4^(7*6))))^(3^(2^85)) ≈? = e to 18,457,734,525,360,901,453,873,570 digitsof precision! N N

  12. Problem: Does the Pythagorean theorem generalize toarbitrary figures on the sides of a right triangle?

  13. Problem: Does every closed simple curve containthe vertices of an equilateral triangle? • What approaches fail? • What techniques work and why? • Lessons and generalizations

  14. = 31 x ? Problem: Can an 8x8 board with two opposite corners missing be tiles with 31 dominoes? • What approaches fail? • What techniques work and why? • Lessons and generalizations

  15. Problem: Explain the apparent discrepancy between the areas of the two arrangements. 5 5 13 5 13 • What approaches fail? • What techniques work and why? • Lessons and generalizations

  16. Problem: Explain the apparent discrepancy between the areas of the three arrangements. • What approaches fail? • What techniques work and why? • Lessons and generalizations

  17. Larger alphabet: old: Σ={0,1} new: Σ’ ={a,b,c,d} b old: δ b a d c a 0 1 new: δ' 0 1 0 0 1 1 1 0 0 0 Turing Machine “Enhancements” Idea: Encode larger alphabet using smaller one. Encoding example: a=00, b=01, c=10, d=11

  18. Double-sided infinite tape: 1 0 1 L/R L/R L/R old: δ new: δ' L/R R/L R/L Turing Machine “Enhancements” 1 0 1 1 0 0 1 Idea: Fold into a normal single-sided infinite tape 1 0 0 1 1 1 0 0 0 1 1

  19. Multiple heads: b b a b a b b a a Turing Machine “Enhancements” b b a b a b b a a Idea: Mark heads locations on tape and simulate b B B a A A b B B b A Modified δ' processes each “virtual” head independently: • Each move of δ is simulated by a long scan & update • δ' updates & marks all “virtual” head positions

  20. Multiple tapes: 1 1 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 Turing Machine “Enhancements” 1 1 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 Idea: Interlace multiple tapes into a single tape Modified δ' processes each “virtual” tape independently: • Each move of δ is simulated by a long scan & update • δ' updates R/W head positions on all “virtual tapes”

  21. Two-dimensional tape: 1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 0 0 0 $ $ $ Turing Machine “Enhancements” This is how compilers implement 2D arrays! Idea: Flatten 2-D tape into a 1-D tape Modified 1-D δ' simulates the original 2-D δ: • Left/right δ moves: δ' moves horizontally • Up/down δ moves: δ' jumps between tape sections

  22. Non-determinism: 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 1 1 1 1 0 0 0 0 1 1 1 1 1 1 1 1 0 0 1 1 0 0 $ Turing Machine “Enhancements” 1 Idea: Parallel-simulate non-deterministic threads $ $ Modified deterministic δ' simulates the original ND δ: • Each ND move by δ spawns another independent “thread” • All current threads are simulated “in parallel”

  23. 9 H e l l o 3 . 1 4 1 5 W o r l d ! Π λ α τ ω ν Turing Machine “Enhancements” Combinations: 3 ND Idea: “Enhancements” are independent (and commutative WRT preserving the language recognized). Theorem: Combinations of “enhancements” do not increase the power of Turing machines.

More Related