Skip to content
Snippets Groups Projects
Commit a231c472 authored by Michael Leuschel's avatar Michael Leuschel
Browse files

add more comments and Verkettung

parent d918c695
Branches
No related tags found
No related merge requests found
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
## Formale Sprachen ## Formale Sprachen
Dieses Notebook begleitet Vorlesung 3 und erläutert die grundlegenden Definitionen der formalen Sprachen.
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
::load ::load
MACHINE Alphabet MACHINE Alphabet
SETS Σ = {a,b,c} SETS Σ = {a,b,c}
END END
``` ```
%% Output %% Output
Loaded machine: Alphabet Loaded machine: Alphabet
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Ein Wort ist eine endliche Folge von Elementen aus dem Alphabet. Ein Wort ist eine endliche Folge von Elementen aus dem Alphabet.
Im Skript schreiben wir $w \in \Sigma^{*}$; hier im Notebook schreiben wir Im Skript schreiben wir $w \in \Sigma^{*}$; hier im Notebook schreiben wir
$w \in seq(\Sigma)$. $w \in seq(\Sigma)$.
Im Skript schreiben wir Wörter in dem wir die Symbole aus $\Sigma$ hintereinander setzten: $abc$. Im Notebook schreiben wir $[a,b,c]$ für die Folge mit den drei Symbolen $a$, $b$ und $c$. Im Skript schreiben wir Wörter in dem wir die Symbole aus $\Sigma$ hintereinander setzten: $abc$. Im Notebook schreiben wir $[a,b,c]$ für die Folge mit den drei Symbolen $a$, $b$ und $c$.
Also aus $abc \in \Sigma^*$ wird dies: Also aus $abc \in \Sigma^*$ wird dies:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
[a,b,c] ∈ seq(Σ) [a,b,c] ∈ seq(Σ)
``` ```
%% Output %% Output
$\mathit{TRUE}$ $\mathit{TRUE}$
TRUE TRUE
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
[a,a,b,c] ∈ seq(Σ) [a,a,b,c] ∈ seq(Σ)
``` ```
%% Output %% Output
$\mathit{TRUE}$ $\mathit{TRUE}$
TRUE TRUE
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Die Länge eines Wortes $w$ ist die Anzahl der Symbole in $w$. Im Skript schreiben wir $\|w\|$, im Notebook benutzen wir ```size(w)```: Die Länge eines Wortes $w$ ist die Anzahl der Symbole in $w$. Im Skript schreiben wir $\|w\|$, im Notebook benutzen wir ```size(w)```:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
size([a,b,c]) size([a,b,c])
``` ```
%% Output %% Output
$3$ $3$
3 3
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
size([a,a,b,c]) size([a,a,b,c])
``` ```
%% Output %% Output
$4$ $4$
4 4
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Das leere Wort ist das eindeutig bestimmte Wort der Laenge 0: Das leere Wort ist das eindeutig bestimmte Wort der Laenge 0:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
ε ∈ seq(Σ) ∧ size(ε) = 0 ε ∈ seq(Σ) ∧ size(ε) = 0
``` ```
%% Output %% Output
$\renewcommand{\emptyset}{\mathord\varnothing}\mathit{TRUE}$ $\renewcommand{\emptyset}{\mathord\varnothing}\mathit{TRUE}$
**Solution:** **Solution:**
* $ε = \emptyset$ * $ε = \emptyset$
TRUE TRUE
Solution: Solution:
ε = ∅ ε = ∅
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Leider ist in der B Sprache das Symbol λ schon vergeben (zur Definition von Funktionen). Deshalb müssen wir in einer weiteren Abweichung vom Skript Epsilon verwenden. Leider ist in der B Sprache das Symbol λ schon vergeben (zur Definition von Funktionen). Deshalb müssen wir in einer weiteren Abweichung vom Skript Epsilon verwenden.
Eine formale Sprache ist eine jede Teilmenge von $\Sigma^*$. Eine formale Sprache ist eine jede Teilmenge von $\Sigma^*$.
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
Sprachen = {L | L ⊆ seq(Σ)} Sprachen = {L | L ⊆ seq(Σ)}
``` ```
%% Output %% Output
$\mathit{TRUE}$ $\mathit{TRUE}$
**Solution:** **Solution:**
* $\mathit{Sprachen} = \{\mathit{L}\mid \mathit{L} \subseteq \mathit{seq}(Σ)\}$ * $\mathit{Sprachen} = \{\mathit{L}\mid \mathit{L} \subseteq \mathit{seq}(Σ)\}$
TRUE TRUE
Solution: Solution:
Sprachen = {L∣L ⊆ seq(Σ)} Sprachen = {L∣L ⊆ seq(Σ)}
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
In folgender B Maschine werden wir ein paar Sprachen definieren: In folgender B Maschine werden wir ein paar Sprachen und Wörter definieren:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
::load ::load
MACHINE Alphabet MACHINE Alphabet
SETS Σ = {a,b,c} SETS Σ = {a,b,c}
CONSTANTS ε, Sprachen, w₁, w₂, L₁, L₂ CONSTANTS ε, Sprachen, w₁, w₂, L₁, L₂
PROPERTIES PROPERTIES
ε ∈ seq(Σ) ∧ size(ε) = 0 ∧ ε ∈ seq(Σ) ∧ size(ε) = 0 ∧
Sprachen = {L | L ⊆ seq(Σ)}∧ Sprachen = {L | L ⊆ seq(Σ)}∧
w₁ = [a,a,b,c] ∧ w₁ = [a,a,b,c] ∧
w₂ = [c,a,b,a] ∧ w₂ = [c,c] ∧
L₁ = {w₁,w₂} ∧ L₁ = {w₁,w₂} ∧
L₂ = {w₂, [a,a,a] } L₂ = {w₂, [a,a,a] }
END END
``` ```
%% Output %% Output
Loaded machine: Alphabet Loaded machine: Alphabet
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:constants :constants
``` ```
%% Output %% Output
Machine constants set up using operation 0: $setup_constants() Machine constants set up using operation 0: $setup_constants()
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
w₁ w₁
``` ```
%% Output %% Output
$\{(1\mapsto \mathit{a}),(2\mapsto \mathit{a}),(3\mapsto \mathit{b}),(4\mapsto \mathit{c})\}$ $\{(1\mapsto \mathit{a}),(2\mapsto \mathit{a}),(3\mapsto \mathit{b}),(4\mapsto \mathit{c})\}$
{(1↦a),(2↦a),(3↦b),(4↦c)} {(1↦a),(2↦a),(3↦b),(4↦c)}
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Man sieht hier, dass die Folge aabc, mathematisch gesehen eine totale Funktion von 1..4 nach $\Sigma$ ist. Wir können aber den "Pretty-Printer" beeinflussen und Folgen anders ausgeben: Man sieht hier, dass die Folge aabc, mathematisch gesehen eine totale Funktion von 1..4 nach $\Sigma$ ist. Wir können aber den "Pretty-Printer" beeinflussen und Folgen anders ausgeben:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:pref PP_SEQUENCES=TRUE :pref PP_SEQUENCES=TRUE
``` ```
%% Output %% Output
Preference changed: PP_SEQUENCES = TRUE Preference changed: PP_SEQUENCES = TRUE
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
w₁ w₁
``` ```
%% Output %% Output
$[a,\mathit{a},\mathit{b},c]$ $[a,\mathit{a},\mathit{b},c]$
[a,a,b,c] [a,a,b,c]
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Hier wird die Schreibweise von B für Folgen verwendet. Diese kann man auch so im Notebook eingeben. Hier wird die Schreibweise von B für Folgen verwendet. Diese kann man auch so im Notebook eingeben.
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
w₂ w₂
``` ```
%% Output %% Output
$[c,\mathit{a},\mathit{b},a]$ $[c,c]$
[c,a,b,a] [c,c]
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
L₁ L₁
``` ```
%% Output %% Output
$\{[a,\mathit{a},\mathit{b},c],[c,\mathit{a},\mathit{b},a]\}$ $\{[c,c],[a,\mathit{a},\mathit{b},c]\}$
{[a,a,b,c],[c,a,b,a]} {[c,c],[a,a,b,c]}
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Die Leere Sprache ist die Sprache die keine Wörter enthält, sie ist unterschiedlich von der Sprache die nur das leere Wort beinhaltet: Die Leere Sprache ist die Sprache die keine Wörter enthält, sie ist unterschiedlich von der Sprache die nur das leere Wort beinhaltet:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
LeereSprache = ∅ ∧ LeereSprache ≠ {ε} LeereSprache = ∅ ∧ LeereSprache ≠ {ε}
``` ```
%% Output %% Output
$\mathit{TRUE}$ $\mathit{TRUE}$
**Solution:** **Solution:**
* $\mathit{LeereSprache} = []$ * $\mathit{LeereSprache} = []$
TRUE TRUE
Solution: Solution:
LeereSprache = [] LeereSprache = []
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Die Kardinalität einer Sprache L ist die Anzahl der Wörter von L. Die Kardinalität einer Sprache L ist die Anzahl der Wörter von L.
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
card(L₁) card(L₁)
``` ```
%% Output %% Output
$2$ $2$
2 2
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
card( {ε} ) card( {ε} )
``` ```
%% Output %% Output
$1$ $1$
1 1
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
card( ∅ ) card( ∅ )
``` ```
%% Output %% Output
$0$ $0$
0 0
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Die Mengeoperatoren (Vereinigung, Schnitt, Differenz) kann man auch auf Sprachen anwenden: Die Mengeoperatoren (Vereinigung, Schnitt, Differenz) kann man auch auf Sprachen anwenden:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
L₁
```
%% Output
$\{[c,c],[a,\mathit{a},\mathit{b},c]\}$
{[c,c],[a,a,b,c]}
%% Cell type:code id: tags:
``` prob
L₂
```
%% Output
$\{[c,c],[a,\mathit{a},a]\}$
{[c,c],[a,a,a]}
%% Cell type:code id: tags:
``` prob
L₁ ∪ L₂ L₁ ∪ L₂
``` ```
%% Output %% Output
$\{[a,\mathit{a},a],[a,\mathit{a},\mathit{b},c],[c,\mathit{a},\mathit{b},a]\}$ $\{[c,c],[a,\mathit{a},a],[a,\mathit{a},\mathit{b},c]\}$
{[a,a,a],[a,a,b,c],[c,a,b,a]} {[c,c],[a,a,a],[a,a,b,c]}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
{x| x∈seq(Σ) ∧ (x∈L₁ ∨ x∈L₂)} {x| x∈seq(Σ) ∧ (x∈L₁ ∨ x∈L₂)}
``` ```
%% Output %% Output
$\{[a,\mathit{a},a],[a,\mathit{a},\mathit{b},c],[c,\mathit{a},\mathit{b},a]\}$ $\{[c,c],[a,\mathit{a},a],[a,\mathit{a},\mathit{b},c]\}$
{[a,a,a],[a,a,b,c],[c,a,b,a]} {[c,c],[a,a,a],[a,a,b,c]}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
L₁ ∩ L₂ L₁ ∩ L₂
``` ```
%% Output %% Output
$\{[c,\mathit{a},\mathit{b},a]\}$ $\{[c,c]\}$
{[c,a,b,a]} {[c,c]}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
{x| x∈seq(Σ) ∧ (x∈L₁ ∧ x∈L₂)} {x| x∈seq(Σ) ∧ (x∈L₁ ∧ x∈L₂)}
``` ```
%% Output %% Output
$\{[c,\mathit{a},\mathit{b},a]\}$ $\{[c,c]\}$
{[c,a,b,a]} {[c,c]}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
L₁ \ L₂ L₁ \ L₂
``` ```
%% Output %% Output
$\{[a,\mathit{a},\mathit{b},c]\}$ $\{[a,\mathit{a},\mathit{b},c]\}$
{[a,a,b,c]} {[a,a,b,c]}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
L₂ \ L₁ L₂ \ L₁
``` ```
%% Output %% Output
$\{[a,\mathit{a},a]\}$ $\{[a,\mathit{a},a]\}$
{[a,a,a]} {[a,a,a]}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
Komplement = seq(Σ) \ L₁ ∧ Komplement = seq(Σ) \ L₁ ∧
[a,a,b,c] ∉ Komplement ∧ [a,a,b,c] ∉ Komplement ∧
[a,a,c,c] ∈ Komplement [a,a,c,c] ∈ Komplement
``` ```
%% Output %% Output
$\mathit{TRUE}$ $\mathit{TRUE}$
**Solution:** **Solution:**
* $\mathit{Komplement} = (\mathit{seq}(Σ) - \{[a,\mathit{a},\mathit{b},c],[c,\mathit{a},\mathit{b},a]\})$ * $\mathit{Komplement} = (\mathit{seq}(Σ) - \{[c,c],[a,\mathit{a},\mathit{b},c]\})$
TRUE TRUE
Solution: Solution:
Komplement = (seq(Σ) − {[a,a,b,c],[c,a,b,a]}) Komplement = (seq(Σ) − {[c,c],[a,a,b,c]})
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Konkatenation von Wörtern wird in B mit ^ geschrieben: Konkatenation von Wörtern wird in B mit ^ geschrieben:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
w₁
```
%% Output
$[a,\mathit{a},\mathit{b},c]$
[a,a,b,c]
%% Cell type:code id: tags:
``` prob
w₁^w₁ w₁^w₁
``` ```
%% Output %% Output
$[a,\mathit{a},\mathit{b},\mathit{c},\mathit{a},\mathit{a},\mathit{b},c]$ $[a,\mathit{a},\mathit{b},\mathit{c},\mathit{a},\mathit{a},\mathit{b},c]$
[a,a,b,c,a,a,b,c] [a,a,b,c,a,a,b,c]
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
w₁^ε w₁^ε
``` ```
%% Output %% Output
$[a,\mathit{a},\mathit{b},c]$ $[a,\mathit{a},\mathit{b},c]$
[a,a,b,c] [a,a,b,c]
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
ε^w₁ ε^w₁
``` ```
%% Output %% Output
$[a,\mathit{a},\mathit{b},c]$ $[a,\mathit{a},\mathit{b},c]$
[a,a,b,c] [a,a,b,c]
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Die Verkettung von Sprachen: Die Verkettung von Sprachen:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
L₁ L₁
``` ```
%% Output %% Output
$\{[a,\mathit{a},\mathit{b},c],[c,\mathit{a},\mathit{b},a]\}$ $\{[c,c],[a,\mathit{a},\mathit{b},c]\}$
{[a,a,b,c],[c,a,b,a]} {[c,c],[a,a,b,c]}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
L₂ L₂
``` ```
%% Output %% Output
$\{[a,\mathit{a},a],[c,\mathit{a},\mathit{b},a]\}$ $\{[c,c],[a,\mathit{a},a]\}$
{[a,a,a],[c,a,b,a]} {[c,c],[a,a,a]}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
{w | ∃(a,b).(a∈L₁ ∧ b∈L₂ ∧ w = a^b)} {w | ∃(a,b).(a∈L₁ ∧ b∈L₂ ∧ w = a^b)}
``` ```
%% Output %% Output
$\{[c,\mathit{a},\mathit{b},\mathit{a},\mathit{a},\mathit{a},a],[c,\mathit{a},\mathit{b},\mathit{a},\mathit{c},\mathit{a},\mathit{b},a],[a,\mathit{a},\mathit{b},\mathit{c},\mathit{a},\mathit{a},a],[a,\mathit{a},\mathit{b},\mathit{c},\mathit{c},\mathit{a},\mathit{b},a]\}$ $\{[c,\mathit{c},\mathit{c},c],[c,\mathit{c},\mathit{a},\mathit{a},a],[a,\mathit{a},\mathit{b},\mathit{c},\mathit{c},c],[a,\mathit{a},\mathit{b},\mathit{c},\mathit{a},\mathit{a},a]\}$
{[c,a,b,a,a,a,a],[c,a,b,a,c,a,b,a],[a,a,b,c,a,a,a],[a,a,b,c,c,a,b,a]} {[c,c,c,c],[c,c,a,a,a],[a,a,b,c,c,c],[a,a,b,c,a,a,a]}
%% Cell type:markdown id: tags:
Man kann eine Sprache auch mit sich selber verketten.
Dies ist die Sprache $L_1^2$:
%% Cell type:code id: tags:
``` prob
:let L1_2 {w | ∃(a,b).(a∈L₁ ∧ b∈L₁ ∧ w = a^b)}
```
%% Output
$\{[c,\mathit{c},\mathit{c},c],[c,\mathit{c},\mathit{a},\mathit{a},\mathit{b},c],[a,\mathit{a},\mathit{b},\mathit{c},\mathit{c},c],[a,\mathit{a},\mathit{b},\mathit{c},\mathit{a},\mathit{a},\mathit{b},c]\}$
{[c,c,c,c],[c,c,a,a,b,c],[a,a,b,c,c,c],[a,a,b,c,a,a,b,c]}
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Man kann eine Sprache auch mit sich selber verketten: Man kann eine Sprache auch mehrfach mit sich selber verketten.
Dies sind die Sprachen $L_1^3$ und $L_1^4$:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
{w | ∃(a,b).(a∈L₁ ∧ b∈L ∧ w = a^b)} :let L1_3 {w | ∃(a,b).(a∈L₁ ∧ b∈L1_2 ∧ w = a^b)}
``` ```
%% Output %% Output
$\{[c,\mathit{a},\mathit{b},\mathit{a},\mathit{a},\mathit{a},\mathit{b},c],[c,\mathit{a},\mathit{b},\mathit{a},\mathit{c},\mathit{a},\mathit{b},a],[a,\mathit{a},\mathit{b},\mathit{c},\mathit{a},\mathit{a},\mathit{b},c],[a,\mathit{a},\mathit{b},\mathit{c},\mathit{c},\mathit{a},\mathit{b},a]\}$ $\{[c,\mathit{c},\mathit{c},\mathit{c},\mathit{c},c],[c,\mathit{c},\mathit{a},\mathit{a},\mathit{b},\mathit{c},\mathit{c},c],[a,\mathit{a},\mathit{b},\mathit{c},\mathit{c},\mathit{c},\mathit{c},c],[c,\mathit{c},\mathit{c},\mathit{c},\mathit{a},\mathit{a},\mathit{b},c],[a,\mathit{a},\mathit{b},\mathit{c},\mathit{a},\mathit{a},\mathit{b},\mathit{c},\mathit{c},c],[c,\mathit{c},\mathit{a},\mathit{a},\mathit{b},\mathit{c},\mathit{a},\mathit{a},\mathit{b},c],[a,\mathit{a},\mathit{b},\mathit{c},\mathit{c},\mathit{c},\mathit{a},\mathit{a},\mathit{b},c],[a,\mathit{a},\mathit{b},\mathit{c},\mathit{a},\mathit{a},\mathit{b},\mathit{c},\mathit{a},\mathit{a},\mathit{b},c]\}$
{[c,a,b,a,a,a,b,c],[c,a,b,a,c,a,b,a],[a,a,b,c,a,a,b,c],[a,a,b,c,c,a,b,a]} {[c,c,c,c,c,c],[c,c,a,a,b,c,c,c],[a,a,b,c,c,c,c,c],[c,c,c,c,a,a,b,c],[a,a,b,c,a,a,b,c,c,c],[c,c,a,a,b,c,a,a,b,c],[a,a,b,c,c,c,a,a,b,c],[a,a,b,c,a,a,b,c,a,a,b,c]}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
L₁ :let L1_4 {w | ∃(a,b).(a∈L₁ ∧ b∈L1_3 ∧ w = a^b)}
``` ```
%% Output %% Output
$\{[a,\mathit{a},\mathit{b},c],[c,\mathit{a},\mathit{b},a]\}$ $\{[c,\mathit{c},\mathit{c},\mathit{c},\mathit{c},\mathit{c},\mathit{c},c],[c,\mathit{c},\mathit{c},\mathit{c},\mathit{a},\mathit{a},\mathit{b},\mathit{c},\mathit{c},c],[c,\mathit{c},\mathit{a},\mathit{a},\mathit{b},\mathit{c},\mathit{c},\mathit{c},\mathit{c},c],[a,\mathit{a},\mathit{b},\mathit{c},\mathit{c},\mathit{c},\mathit{c},\mathit{c},\mathit{c},c],[c,\mathit{c},\mathit{c},\mathit{c},\mathit{c},\mathit{c},\mathit{a},\mathit{a},\mathit{b},c],[a,\mathit{a},\mathit{b},\mathit{c},\mathit{a},\mathit{a},\mathit{b},\mathit{c},\mathit{c},\mathit{c},\mathit{c},c],[c,\mathit{c},\mathit{c},\mathit{c},\mathit{a},\mathit{a},\mathit{b},\mathit{c},\mathit{a},\mathit{a},\mathit{b},c],[c,\mathit{c},\mathit{a},\mathit{a},\mathit{b},\mathit{c},\mathit{c},\mathit{c},\mathit{a},\mathit{a},\mathit{b},c],[c,\mathit{c},\mathit{a},\mathit{a},\mathit{b},\mathit{c},\mathit{a},\mathit{a},\mathit{b},\mathit{c},\mathit{c},c],[a,\mathit{a},\mathit{b},\mathit{c},\mathit{c},\mathit{c},\mathit{c},\mathit{c},\mathit{a},\mathit{a},\mathit{b},c],[a,\mathit{a},\mathit{b},\mathit{c},\mathit{c},\mathit{c},\mathit{a},\mathit{a},\mathit{b},\mathit{c},\mathit{c},c],[c,\mathit{c},\mathit{a},\mathit{a},\mathit{b},\mathit{c},\mathit{a},\mathit{a},\mathit{b},\mathit{c},\mathit{a},\mathit{a},\mathit{b},c],[a,\mathit{a},\mathit{b},\mathit{c},\mathit{c},\mathit{c},\mathit{a},\mathit{a},\mathit{b},\mathit{c},\mathit{a},\mathit{a},\mathit{b},c],[a,\mathit{a},\mathit{b},\mathit{c},\mathit{a},\mathit{a},\mathit{b},\mathit{c},\mathit{c},\mathit{c},\mathit{a},\mathit{a},\mathit{b},c],[a,\mathit{a},\mathit{b},\mathit{c},\mathit{a},\mathit{a},\mathit{b},\mathit{c},\mathit{a},\mathit{a},\mathit{b},\mathit{c},\mathit{c},c],[a,\mathit{a},\mathit{b},\mathit{c},\mathit{a},\mathit{a},\mathit{b},\mathit{c},\mathit{a},\mathit{a},\mathit{b},\mathit{c},\mathit{a},\mathit{a},\mathit{b},c]\}$
{[a,a,b,c],[c,a,b,a]} {[c,c,c,c,c,c,c,c],[c,c,c,c,a,a,b,c,c,c],[c,c,a,a,b,c,c,c,c,c],[a,a,b,c,c,c,c,c,c,c],[c,c,c,c,c,c,a,a,b,c],[a,a,b,c,a,a,b,c,c,c,c,c],[c,c,c,c,a,a,b,c,a,a,b,c],[c,c,a,a,b,c,c,c,a,a,b,c],[c,c,a,a,b,c,a,a,b,c,c,c],[a,a,b,c,c,c,c,c,a,a,b,c],[a,a,b,c,c,c,a,a,b,c,c,c],[c,c,a,a,b,c,a,a,b,c,a,a,b,c],[a,a,b,c,c,c,a,a,b,c,a,a,b,c],[a,a,b,c,a,a,b,c,c,c,a,a,b,c],[a,a,b,c,a,a,b,c,a,a,b,c,c,c],[a,a,b,c,a,a,b,c,a,a,b,c,a,a,b,c]}
%% Cell type:code id: tags:
``` prob
:unlet L1_2
```
%% Cell type:code id: tags:
``` prob
:unlet L1_3
```
%% Cell type:code id: tags:
``` prob
:unlet L1_4
```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Die Spiegelung eines Wortes kann im Notebook mit dem ```rev``` Operator verwirklicht werden: Die Spiegelung eines Wortes kann im Notebook mit dem ```rev``` Operator verwirklicht werden:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
rev(w₁) rev(w₁)
``` ```
%% Output %% Output
$[c,\mathit{b},\mathit{a},a]$ $[c,\mathit{b},\mathit{a},a]$
[c,b,a,a] [c,b,a,a]
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Eine Sprache wird gespiegelt indem jedes Wort gespiegelt wird: Eine Sprache wird gespiegelt indem jedes Wort gespiegelt wird:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
{ws|∃w.(w∈L₁ ∧ ws=rev(w))} {ws|∃w.(w∈L₁ ∧ ws=rev(w))}
``` ```
%% Output %% Output
$\{[a,\mathit{b},\mathit{a},c],[c,\mathit{b},\mathit{a},a]\}$ $\{[a,\mathit{b},\mathit{a},c],[c,\mathit{b},\mathit{a},a]\}$
{[a,b,a,c],[c,b,a,a]} {[a,b,a,c],[c,b,a,a]}
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Die Teilwort und Präfix Relationen definieren wir in folgender B Maschine: Die Teilwort und Präfix Relationen definieren wir in folgender B Maschine:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
::load ::load
MACHINE Alphabet MACHINE Alphabet
SETS Sigma = {a,b,c} SETS Sigma = {a,b,c}
CONSTANTS ε, Sprachen, w₁, w₂, L₁, L₂ CONSTANTS ε, Sprachen, w₁, w₂, L₁, L₂
ABSTRACT_CONSTANTS ABSTRACT_CONSTANTS
teilwort, präfix teilwort, präfix
PROPERTIES PROPERTIES
ε ∈ seq(Sigma) ∧ size(ε) = 0 ∧ ε ∈ seq(Sigma) ∧ size(ε) = 0 ∧
Sprachen = {L | L ⊆ seq(Sigma)}∧ Sprachen = {L | L ⊆ seq(Sigma)}∧
w₁ = [a,a,b,c] ∧ w₁ = [a,a,b,c] ∧
w₂ = [c,a,b,a] ∧ w₂ = [c,a,b,a] ∧
L₁ = {w₁,w₂} ∧ L₁ = {w₁,w₂} ∧
L₂ = {w₂, [a,a,a] } ∧ L₂ = {w₂, [a,a,a] } ∧
teilwort = {ut,vt | ut∈seq(Sigma) & vt∈seq(Sigma) ∧ ∃(vt1,vt2).(vt1^ut^vt2 = vt)} ∧ teilwort = {ut,vt | ut∈seq(Sigma) & vt∈seq(Sigma) ∧ ∃(vt1,vt2).(vt1^ut^vt2 = vt)} ∧
präfix = {up,vp | up∈seq(Sigma) & vp∈seq(Sigma) ∧ ∃(wp).(up^wp = vp)} präfix = {up,vp | up∈seq(Sigma) & vp∈seq(Sigma) ∧ ∃(wp).(up^wp = vp)}
DEFINITIONS SET_PREF_PP_SEQUENCES == TRUE DEFINITIONS SET_PREF_PP_SEQUENCES == TRUE
END END
``` ```
%% Output %% Output
Loaded machine: Alphabet Loaded machine: Alphabet
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:constants :constants
``` ```
%% Output %% Output
Machine constants set up using operation 0: $setup_constants() Machine constants set up using operation 0: $setup_constants()
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
[a,a] ↦ [c,b,a,a,b] ∈ teilwort [a,a] ↦ [c,b,a,a,b] ∈ teilwort
``` ```
%% Output %% Output
$\mathit{TRUE}$ $\mathit{TRUE}$
**Solution:**
* $\mathit{TW} = \{[],[a],[a,b],[b],[b,c],[c],[a,\mathit{b},c]\}$
TRUE TRUE
Solution:
TW = {[],[a],[a,b],[b],[b,c],[c],[a,b,c]}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
[a,a,a] ↦ [c,b,a,a,b] ∈ teilwort [a,a,a] ↦ [c,b,a,a,b] ∈ teilwort
``` ```
%% Output %% Output
$\mathit{FALSE}$ $\mathit{FALSE}$
FALSE FALSE
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
[c] ↦ [c,b,a,a,b] ∈ präfix [c] ↦ [c,b,a,a,b] ∈ präfix
``` ```
%% Output %% Output
$\mathit{TRUE}$ $\mathit{TRUE}$
**Solution:**
* $\mathit{TW} = \{[],[a],[a,b],[b],[b,c],[c],[a,\mathit{b},c]\}$
TRUE TRUE
Solution:
TW = {[],[a],[a,b],[b],[b,c],[c],[a,b,c]}
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Man kann den Verkettungs Operator mehrfach anwenden: Man kann den Verkettungs Operator mehrfach anwenden:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
{x| x ↦ [c,b,a,a,b] ∈ präfix} {x| x ↦ [c,b,a,a,b] ∈ präfix}
``` ```
%% Output %% Output
$\{[],[c],[c,b],[c,\mathit{b},a],[c,\mathit{b},\mathit{a},a],[c,\mathit{b},\mathit{a},\mathit{a},b]\}$ $\{[],[c],[c,b],[c,\mathit{b},a],[c,\mathit{b},\mathit{a},a],[c,\mathit{b},\mathit{a},\mathit{a},b]\}$
{[],[c],[c,b],[c,b,a],[c,b,a,a],[c,b,a,a,b]} {[],[c],[c,b],[c,b,a],[c,b,a,a],[c,b,a,a,b]}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
{x| x ↦ [c,b,a,a,b] ∈ teilwort} {x| x ↦ [c,b,a,a,b] ∈ teilwort}
``` ```
%% Output %% Output
$\{[],[a],[a,a],[a,b],[b],[b,a],[c],[c,b],[a,\mathit{a},b],[b,\mathit{a},a],[b,\mathit{a},\mathit{a},b],[c,\mathit{b},a],[c,\mathit{b},\mathit{a},a],[c,\mathit{b},\mathit{a},\mathit{a},b]\}$ $\{[],[a],[a,a],[a,b],[b],[b,a],[c],[c,b],[a,\mathit{a},b],[b,\mathit{a},a],[b,\mathit{a},\mathit{a},b],[c,\mathit{b},a],[c,\mathit{b},\mathit{a},a],[c,\mathit{b},\mathit{a},\mathit{a},b]\}$
{[],[a],[a,a],[a,b],[b],[b,a],[c],[c,b],[a,a,b],[b,a,a],[b,a,a,b],[c,b,a],[c,b,a,a],[c,b,a,a,b]} {[],[a],[a,a],[a,b],[b],[b,a],[c],[c,b],[a,a,b],[b,a,a],[b,a,a,b],[c,b,a],[c,b,a,a],[c,b,a,a,b]}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:let TW {x| x ↦ [a,b,c] ∈ teilwort} :let TW {x| x ↦ [a,b,c] ∈ teilwort}
``` ```
%% Output %% Output
$\{[],[a],[a,b],[b],[b,c],[c],[a,\mathit{b},c]\}$ $\{[],[a],[a,b],[b],[b,c],[c],[a,\mathit{b},c]\}$
{[],[a],[a,b],[b],[b,c],[c],[a,b,c]} {[],[a],[a,b],[b],[b,c],[c],[a,b,c]}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:pref DOT_DECOMPOSE_NODES=FALSE :pref DOT_DECOMPOSE_NODES=FALSE
``` ```
%% Output %% Output
Preference changed: DOT_DECOMPOSE_NODES = FALSE Preference changed: DOT_DECOMPOSE_NODES = FALSE
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:dot expr_as_graph ("tw",{x,y | x |-> y : teilwort & y : TW }) :dot expr_as_graph ("tw",{x,y | x |-> y : teilwort & y : TW })
``` ```
%% Output %% Output
<Dot visualization: expr_as_graph [TWTW={[],[a],[a,b],[b],[b,c],[c],[a,b,c]}("tw",{x,y|(x,y):teilwort & y:TW})]> <Dot visualization: expr_as_graph [TWTW={[],[a],[a,b],[b],[b,c],[c],[a,b,c]}("tw",{x,y|(x,y):teilwort & y:TW})]>
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:dot expr_as_graph ("präfix",{x,y | x |-> y : präfix & y : TW }) :dot expr_as_graph ("präfix",{x,y | x |-> y : präfix & y : TW })
``` ```
%% Output %% Output
<Dot visualization: expr_as_graph [TWTW={[],[a],[a,b],[b],[b,c],[c],[a,b,c]}("präfix",{x,y|(x,y):präfix & y:TW})]> <Dot visualization: expr_as_graph [TWTW={[],[a],[a,b],[b],[b,c],[c],[a,b,c]}("präfix",{x,y|(x,y):präfix & y:TW})]>
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:unlet TW
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
``` ```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment