Vorlesung 1

advertisement
Diskrete Ereignissysteme
Vorlesung 3
Vorlesung 3
09.11.2006
Skript 1 Seite 66 bis 83
Regular Expressions: Examples
1. 010
 Alle Ausdrücke mit genau einer 1

2.   
 Alle Ausdrücke mit gerader Anzahl Zeichen
3. 1 
 Die leere Menge (Verkettung mit der leeren Menge gibt leere Menge)
4.   0,1 ,{w | has at least one 1}
 1 oder  01 0  oder 01

5.   0,1 , {w | w starts and ends with the same symbol}
  0 0   11  0  1 (nur eine 0 oder 1 auch enthalten, was ist mit leere Menge?
6. {w | w is a numerical constant with sign and/or fractional part}
eg. 3.1415, -.001, +2000
         D   D .D   D  .D  , D  0,1,...,9
REX  NFA
- Theorem:
Given a regular expression r  there is an NFA N which simulates r.
L  N  L  r 
The NFA is constructible in linear time
- Proof: Induction
Example:

 ab  a 
1/3
Diskrete Ereignissysteme
Vorlesung 3
REX  NFA  FA?!?
NFA’s have 3 types of non-determinism
Nondeterminism Machine
 -function
type
Analogue
UnderCrash
No output
determined
OverRandom choice multi valued
determined
Pause reading
Redefine

alphabet
Easy to fix?
Formally
Yes, fail state
  q, a   0
no
  q, a   1
no
  q, a   1
Determinizing NFA’s
- Idea: keep track of all parallel active states as the input is being called out. If at the end
of the input one active state is an accept state, input is accepted.
- Example:
Derandomize
- n states of the NFA  2 n power-states in the FA
- First figure out which power-states will reach which power-states in the FA. (Using
the rules of the NFA.)
- Than add all epsilon-edges
e.g. a, b,c  a, b,c,d,e,f  if there is an epsilon-edge-only-path from any of a, b, c
to states d, e, f.
Do the same for the starting state: starting state of FA = {starting state of NFA, all
NFA states that can recursively be reached from there}
- Accepting states of FA are all states including an accept state of NFA.
2/3
Diskrete Ereignissysteme
Vorlesung 3
Example  ab  a  :

REX  NFA  FA
- Starting form any NFA we can use subset construction and the epsilon-transitiveclosure to find an equivalent FA accepting the same language.
- Theorem: If L is any language accepted by an NFA, then there exists a constructible
[deterministic] FA which also accepts L.
- Corollary: The class of regular languages is closed under the regular operations.
REX  NFA  FA  REX…
- FA’s are automatically NFA’s
- FA  REX simple!
- GNFA: Generalized NFA
GNFA’s
- A generalized nondeterministic finite automaton is a graph whose edges are labelled
by regular expressions
o With a unique start state with in-degree 0
o With a unique accept state with out-degree 0
Example
3/3
Download