8.9 KiB
Übungsblatt 2
Wenzel Schwan (1125033), Paul Kneidl (1125219), David Schirrmeister (1125746), Michelle Klein (1126422)
Übung 1
Betrachten Sie den Automaten A aus Abbildung 1:
(a) Wie lautet die formale Tupeldarstellung des Automaten?
A=(Σ,Q,q_s,Q_a, δ)
Σ = \{x,y\}
Q = \{a,b,c,d\}
q_s = \{a\}
Q_a = \{d\}
δ:
-
Zustand δ(.,x) δ(.,y) a b b c b c d b d b
-
(b) Beschreiben Sie wie der Automat die Eingabe xyyxyx
verarbeitet.
- Start in Zustand
a
- x →
δ(a,x)=b
- x →
- Zustand
b
- y →
δ(b,y)=b
- y →
- Zustand
b
- y →
δ(b,y)=b
- y →
- Zustand
b
- x →
δ(b,x)=c
- x →
- Zustand
c
- y →
δ(c,y)=b
- y →
- Zustand
b
- x →
δ(b,x)=c
- x →
→ Endzustand: c
, da der akzeptierende Zustand d
ist, wird die Eingabe nicht akzeptiert.
(c) Nennen Sie zwei verschiedene kürzeste Wörter, die von A akzeptiert werden und die jeweils jeden Übergang (Kante) aus Abbildung 1 mindestens einmal benutzen.
w_1 ∈ Σ^* := xyxxyxyxx
w_2 ∈ Σ^* := xxyxxyyxx
(d) Beschreiben Sie die von A akzeptierte Sprache sowohl informal (in Worten) als auch formal (als Teilmenge von \{x,y\}^*
).
Informal:
Die von A akzeptierte Sprache muss mit x beginnen und mit xx aufhören. Dazwischen dürfen beliebig viele x und y in beliebiger Reihenfolge sein.
Formal:
L_A:= \{w \space | \space w = x*a*xx, a ∈ \{x,y\}^*\}
(e) Automat A
ist unvollständig (die Übergangsfunktion ist partiell). Geben Sie einen vollständigen Automaten A′
mit L(A′) = L(A)
in Graphdarstellung an.
@startuml
scale 0.5
left to right direction
skinparam dpi 150
skinparam state {
BackgroundColor #96cf95
BorderColor black
FontName Helvetica
RoundCorner 30
Shadowing false
LineThickness 0
}
state a
state d##[bold]
[*] --> a
a --> b : x
a --> e : y
b --> b : y
b --> c : x
c --> b : y
c --> d : x
d --> d : x
d --> b : y
e --> e : x,y
@enduml
Übung 2
Betrachten Sie die Sprache L = \{s ∈ Σ^* \space | \space s \space hat \space das\space Präfix\space 42\space und \space endet \space nicht \space auf \space 23 \}
über dem Alphabet Σ=\{0,1,...,9\}
.
(a) Beschreiben Sie einen vollständigen endlichen Automaten in Graphdarstellung der die Sprache L akzeptiert.
Annahme, dass das Wort
423
von L nicht akzeptiert wird, da42
der Präfix ist und das Wort gleichzeitig auf23
endet.
@startuml
scale 0.5
left to right direction
skinparam dpi 150
skinparam state {
BackgroundColor #96cf95
BorderColor black
FontName Helvetica
RoundCorner 30
Shadowing false
LineThickness 0
}
state c##[bold]
state d##[bold]
[*] --> a
a -up-> f : {0,...,9}\{4}
a --> b : {4}
b -up-> f : {0,...,9}\{2}
f --> f : {0,...,9}
b --> d: {2}
c --> c : {0,...,9}\{2}
c --> d : {2}
d --> c : {0,...,9}\{2,3}
d --> d : {2}
d --> e : {3}
e --> c : {0,...,9}\{2}
e --> d : {2}
@enduml
(b) Beschreiben Sie einen vollständigen endlichen Automaten in Graphdarstellung der genau die nicht-leeren Zeichenketten über dem Alphabet Σ
akzeptiert, die keine Wörter der Sprache L sind.
@startuml
scale 0.5
left to right direction
skinparam dpi 150
skinparam state {
BackgroundColor #96cf95
BorderColor black
FontName Helvetica
RoundCorner 30
Shadowing false
LineThickness 0
}
state f##[bold]
state b##[bold]
state e##[bold]
[*] --> a
a -up-> f : {0,...,9}\{4}
a --> b : {4}
b -up-> f : {0,...,9}\{2}
f --> f : {0,...,9}
b --> d: {2}
c --> c : {0,...,9}\{2}
c --> d : {2}
d --> c : {0,...,9}\{2,3}
d --> d : {2}
d --> e : {3}
e --> c : {0,...,9}\{2}
e --> d : {2}
@enduml
Übung 3
Beschreiben Sie für jede der nachfolgend definierten Sprachen jeweils einen endlichen
deterministischen Automaten, der die Sprache akzeptiert. Geben Sie die Automaten
dabei sowohl in der formalen Tupel- als auch in der Graphdarstellung an. Begründen1
Sie jeweils die Korrektheit Ihrer Konstruktion.
(a) Die Sprache L1
aller geraden natürlichen Zahlen in Dezimaldarstellung ohne führende Null (d.h. \{0, 2, 8, 42 \} ⊆ L1
, aber \{02, 23 \} ∩ L1 = ∅
).
Tupeldarstellung (a)
A=(Σ,Q,q_s,Q_a, δ)
Σ = \{0,...,9\}
Q = \{a,b,c,d,e\}
q_s = \{a\}
Q_a = \{b,d\}
δ:
Zustand | δ(.,0) | δ(.,1) | δ(.,2) | δ(.,3) | δ(.,4) | δ(.,5) | δ(.,6) | δ(.,7) | δ(.,8) | δ(.,9) |
---|---|---|---|---|---|---|---|---|---|---|
a | b | e | d | e | d | e | d | e | d | e |
b | c | c | c | c | c | c | c | c | c | c |
c | c | c | c | c | c | c | c | c | c | c |
d | d | e | d | e | d | e | d | e | d | e |
e | d | e | d | e | d | e | d | e | d | e |
Graphdarstellung (a)
@startuml
scale 0.5
left to right direction
skinparam dpi 150
skinparam state {
BackgroundColor #96cf95
BorderColor black
FontName Helvetica
RoundCorner 30
Shadowing false
LineThickness 0
}
state b##[bold]
state d##[bold]
[*] --> a
a --> b : {0}
b -up-> c : {0,...,9}
b --> c : {0,...,9}
a --> d : {2,4,6,8}
a --> e : {1,3,5,7,9}
d --> e : {1,3,5,7,9}
d --> d : {0,2,4,6,8}
e --> d : {0,2,4,6,8}
e --> e : {1,3,5,7,9}
@enduml
Begründung (a)
- Startzustand a: nur 0 wird in b geschickt (direkt akzeptierend)
- Andere Ziffern (2, 4, 6, 8) leiten in d, auch akzeptierend, aber nur wenn keine führenden Nullen davor kamen
- Zustand e „hält“ ungerade Endziffern (nicht akzeptierend)
- Folgeziffern verhalten sich konsistent
(b) Die Sprache L2 = \{ w ∈ \{ 0, 7 \}^* \space|\space w\space enthält\space 007\space genau\space einmal\space als\space Teilwort \}
.
Tupeldarstellung (b)
A=(Σ,Q,q_s,Q_a, δ)
Σ = \{0,7\}
Q = \{a,b,c,d,e,f,g\}
q_s = \{a\}
Q_a = \{d,e,f\}
δ:
-
Zustand δ(.,0) δ(.,7) a b a b c a c d c d e d e f d f g f g g g
-
Graphdarstellung (b)
@startuml
scale 0.5
skinparam dpi 150
skinparam state {
BackgroundColor #96cf95
BorderColor black
FontName Helvetica
RoundCorner 30
Shadowing false
LineThickness 0
}
state d##[bold]
state e##[bold]
state f##[bold]
[*] -right-> a
a -right-> b : {0}
b -right-> c : {0}
c --> d : {7}
d -right-> e : {0}
e -right-> f : {0}
f --> g : {7}
b --> a : {7}
a --> a : {7}
c --> c : {0}
d --> d : {7}
e --> d : {7}
f --> f : {0}
g --> g : {0,7}
@enduml
Begründung (b)
- Einmaliges Vorkommen von 007 wird erkannt und in d akzeptiert
- Zweites Vorkommen leitet in g, das nicht akzeptierend ist
- Rücksprünge für unpassende Sequenzen sind korrekt konstruiert
(c) Die Sprache L3 = \{ w ∈ \{ a, b \}^* \space| \space \#_a(w) ≡ \#_b(w) mod 3 \}
.
Tupeldarstellung (c)
A=(Σ,Q,q_s,Q_a, δ)
Σ=\{a,b\}
Q=\{q0,q1,q2\}
q_s=\{q0\}
Q_a=\{q0\}
δ:
δ(q,a)=(q+1) \space mod \space 3,δ(q,b)=(q−1) \space mod \space 3
-
Zustand δ(.,a) δ(.,b) q0 q1 q2 q1 q2 q0 q2 q0 q1
Graphdarstellung (c)
@startuml
scale 0.5
left to right direction
skinparam dpi 150
skinparam state {
BackgroundColor #96cf95
BorderColor black
FontName Helvetica
RoundCorner 30
Shadowing false
LineThickness 0
}
state q0##[bold]
[*] -right-> q0
q0 -right-> q1 : a
q0 --> q2 : b
q1 -right-> q2: a
q1 --> q0 : b
q2 --> q0 : a
q2 --> q1 : b
@enduml
Begründung (c)
- q0 wird genau dann erreicht, wenn
\#_a ≡ \#_b mod 3
- Übergänge sind konsistent
Übung 4
Betrachten Sie die Sprache L = \{ w ∈ \{ 0, 1 \}^* \space|\space \#_1(w) = 3 \}
. Beschreiben Sie einen
Automaten in der Graphdarstellung, der die Sprache L
akzeptiert, und beweisen Sie die
Korrektheit Ihrer Konstruktion.
@startuml
scale 0.5
left to right direction
skinparam dpi 150
skinparam state {
BackgroundColor #96cf95
BorderColor black
FontName Helvetica
RoundCorner 30
Shadowing false
LineThickness 0
}
state q3##[bold]
[*] --> q0
q0 --> q1 : 1
q0 --> q0 : 0
q1 --> q2 : 1
q1 --> q1 : 0
q2 --> q3 : 1
q2 --> q2 : 0
q3 --> q3 : 0
q3 --> q4 : 1
q4 --> q4 : 0,1
@enduml