Sie sind auf Seite 1von 11

FORMALE

SPRACHEN
UND
COMPILER
– MODUL 2
ERGÄNZUNG
Dominik Johannes KNOLL

dominik.johannes.knoll@scs.ubbcluj.ro
djknoll.github.io

2020, v2
ENDLICHER AUTOMAT (EA) – FINITE AUTOMATON (FA)

2
https://commons.wikimedia.org/wiki/File:Moore-Automat-de.svg
FINITE AUTOMATON – PSEUDO CODE

State = {startState, state1, … stateN}


State state ⃪ startState
WHILE ( input.hasNextSymbol ) {
symbol ⃪ input.readSymbol
state ß transition(state, symbol)
}
acceptWord ß isFinal(state)
3
ENDLICHER AUTOMAT (EA) – FINITE AUTOMATON (FA)

Definition: A finite automaton (FA) is a 5-tuple


M = (Q,Σ,δ,q0,F)
where:
• Q – finite set of states (|Q|<∞)
• Σ – finite alphabet (|Σ|<∞)
• δ – transition relation : δ:Q×Σ→P(Q)
• q0 – initial state q0 ∊ Q
• F⊆Q – set of final states
4
ERGÄNZUNGEN

1. Q∩Σ=∅
2. δ:Q×Σ→P(Q) , ε∈Σ0 - relation δ(q,ε)=p NOT allowed
3. If |δ(q,a)|≤1 => deterministic finite automaton (DFA)
4. If |δ(q,a)|>1 (more than one state obtained as result) =>
nondeterministic finite automaton (NFA)

5
NICHT-DETERMINISTISCHER ENDLICHER AUTOMAT (NEA)

¡ Welchen Zustand hat der Automat


nach der Eingabe von 001 ?

Definition: reachable state


(erreichbare Zustände)
𝐷𝑒𝑙𝑡𝑎(𝑞, 𝑐) = 1 𝛿 (𝑞, 𝑐)
!∈#

https://studyflix.de/informatik/nichtdeterministischer-automat-1213
NEA – BEISPIEL

¡ Welche Wörter erkennt dieser


Automat?

https://commons.wikimedia.org/wiki/File:Nichtdeterministischer_endlicher_Automat_2.svg
VERBINDEN VON AUTOMATEN

Thompson-Konstruktion
¡ Konkatenation
¡ Alternative
¡ Wiederholung
¡ Verwendung von ε-Übergängen

8
ALGORITHMUS
VON EINEM NEA ZU EINEM DEA

Teilmengen-Konstruktion, Potenzmengen-Konstruktion, Myhill-construction


Suppose there is an NFA N = (Q, ∑, q0, δ, F ) which recognizes a language L. Then
the DFA D = (Q’, ∑, q0, δ’, F’ ) can be constructed for language L as:
Step 1: Initially Q’ = ɸ.
Step 2: Add q0 to Q’.
Step 3: For each state in Q’, find the reachable states for each input symbol using
δ. If this set of states is not in Q’, add it to Q’.
Step 4: F’ is composed of all states in Q’ which contain elements of F. 9
BEISPIEL – TEILMENGEN-KONSTRUKTION

10
https://www.geeksforgeeks.org/conversion-from-nfa-to-dfa/
BEISPIEL 2 – TEILMENGEN-KONSTRUKTION

11
https://www.geeksforgeeks.org/conversion-from-nfa-to-dfa/

Das könnte Ihnen auch gefallen