"Ein Wort ist eine endliche Folge von Elementen aus dem Alphabet.\n",
"Im Skript schreiben wir $w \\in \\Sigma^{*}$; hier im Notebook schreiben wir\n",
"$w \\in seq(\\Sigma)$.\n",
"\n",
"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$.\n",
"\n",
"Also aus $abc \\in \\Sigma^*$ wird dies:"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/markdown": [
"$\\mathit{TRUE}$"
],
"text/plain": [
"TRUE"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"[a,b,c] ∈ seq(Σ)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/markdown": [
"$\\mathit{TRUE}$"
],
"text/plain": [
"TRUE"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"[a,a,b,c] ∈ seq(Σ)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"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",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/markdown": [
"$3$"
],
"text/plain": [
"3"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"size([a,b,c])"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/markdown": [
"$4$"
],
"text/plain": [
"4"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"size([a,a,b,c])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Das leere Wort ist das eindeutig bestimmte Wort der Laenge 0:"
"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.\n",
"\n",
"Eine formale Sprache ist eine jede Teilmenge von $\\Sigma^*$."
"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",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Preference changed: PP_SEQUENCES = TRUE\n"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
":pref PP_SEQUENCES=TRUE"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/markdown": [
"$[a,\\mathit{a},\\mathit{b},c]$"
],
"text/plain": [
"[a,a,b,c]"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"w₁"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Hier wird die Schreibweise von B für Folgen verwendet. Diese kann man auch so im Notebook eingeben."
":dot expr_as_graph (\"präfix\",{x,y | x |-> y : präfix & y : TW })"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "ProB 2",
"language": "prob",
"name": "prob2"
},
"language_info": {
"codemirror_mode": "prob2_jupyter_repl",
"file_extension": ".prob",
"mimetype": "text/x-prob2-jupyter-repl",
"name": "prob"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
%% Cell type:markdown id: tags:
## Formale Sprachen
%% Cell type:code id: tags:
``` prob
::load
MACHINE Alphabet
SETS Σ = {a,b,c}
END
```
%% Output
Loaded machine: Alphabet
%% Cell type:markdown id: tags:
Ein Wort ist eine endliche Folge von Elementen aus dem Alphabet.
Im Skript schreiben wir $w \in \Sigma^{*}$; hier im Notebook schreiben wir
$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$.
Also aus $abc \in \Sigma^*$ wird dies:
%% Cell type:code id: tags:
``` prob
[a,b,c] ∈ seq(Σ)
```
%% Output
$\mathit{TRUE}$
TRUE
%% Cell type:code id: tags:
``` prob
[a,a,b,c] ∈ seq(Σ)
```
%% Output
$\mathit{TRUE}$
TRUE
%% 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)```:
%% Cell type:code id: tags:
``` prob
size([a,b,c])
```
%% Output
$3$
3
%% Cell type:code id: tags:
``` prob
size([a,a,b,c])
```
%% Output
$4$
4
%% Cell type:markdown id: tags:
Das leere Wort ist das eindeutig bestimmte Wort der Laenge 0:
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^*$.
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:
``` prob
:pref PP_SEQUENCES=TRUE
```
%% Output
Preference changed: PP_SEQUENCES = TRUE
%% Cell type:code id: tags:
``` prob
w₁
```
%% Output
$[a,\mathit{a},\mathit{b},c]$
[a,a,b,c]
%% Cell type:markdown id: tags:
Hier wird die Schreibweise von B für Folgen verwendet. Diese kann man auch so im Notebook eingeben.