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

remove unicode Sigma in last B machine

due to issue in dot generation
fixed in lates prob nightly
parent 46c6b23e
No related branches found
No related tags found
No related merge requests found
%% 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:
%% Cell type:code id: tags:
``` prob
ε ∈ seq(Σ) ∧ size(ε) = 0
```
%% Output
$\renewcommand{\emptyset}{\mathord\varnothing}\mathit{TRUE}$
**Solution:**
* $ε = \emptyset$
TRUE
Solution:
ε = ∅
%% 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.
Eine formale Sprache ist eine jede Teilmenge von $\Sigma^*$.
%% Cell type:code id: tags:
``` prob
Sprachen = {L | L ⊆ seq(Σ)}
```
%% Output
$\mathit{TRUE}$
**Solution:**
* $\mathit{Sprachen} = \{\mathit{L}\mid \mathit{L} \subseteq \mathit{seq}(Σ)\}$
TRUE
Solution:
Sprachen = {L∣L ⊆ seq(Σ)}
%% Cell type:markdown id: tags:
In folgender B Maschine werden wir ein paar Sprachen definieren:
%% Cell type:code id: tags:
``` prob
::load
MACHINE Alphabet
SETS Σ = {a,b,c}
CONSTANTS ε, Sprachen, w₁, w₂, L₁, L₂
PROPERTIES
ε ∈ seq(Σ) ∧ size(ε) = 0 ∧
Sprachen = {L | L ⊆ seq(Σ)}∧
w₁ = [a,a,b,c] ∧
w₂ = [c,a,b,a] ∧
L₁ = {w₁,w₂} ∧
L₂ = {w₂, [a,a,a] }
END
```
%% Output
Loaded machine: Alphabet
%% Cell type:code id: tags:
``` prob
:constants
```
%% Output
Machine constants set up using operation 0: $setup_constants()
%% Cell type:code id: tags:
``` prob
w₁
```
%% Output
$\{(1\mapsto \mathit{a}),(2\mapsto \mathit{a}),(3\mapsto \mathit{b}),(4\mapsto \mathit{c})\}$
{(1↦a),(2↦a),(3↦b),(4↦c)}
%% 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:
%% 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.
%% Cell type:code id: tags:
``` prob
w₂
```
%% Output
$[c,\mathit{a},\mathit{b},a]$
[c,a,b,a]
%% Cell type:code id: tags:
``` prob
L₁
```
%% Output
$\{[a,\mathit{a},\mathit{b},c],[c,\mathit{a},\mathit{b},a]\}$
{[a,a,b,c],[c,a,b,a]}
%% 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:
%% Cell type:code id: tags:
``` prob
LeereSprache = ∅ ∧ LeereSprache ≠ {ε}
```
%% Output
$\mathit{TRUE}$
**Solution:**
* $\mathit{LeereSprache} = []$
TRUE
Solution:
LeereSprache = []
%% Cell type:markdown id: tags:
Die Kardinalität einer Sprache L ist die Anzahl der Wörter von L.
%% Cell type:code id: tags:
``` prob
card(L₁)
```
%% Output
$2$
2
%% Cell type:code id: tags:
``` prob
card( {ε} )
```
%% Output
$1$
1
%% Cell type:code id: tags:
``` prob
card( ∅ )
```
%% Output
$0$
0
%% Cell type:markdown id: tags:
Die Mengeoperatoren (Vereinigung, Schnitt, Differenz) kann man auch auf Sprachen anwenden:
%% Cell type:code id: tags:
``` prob
L₁ ∪ L₂
```
%% Output
$\{[a,\mathit{a},a],[a,\mathit{a},\mathit{b},c],[c,\mathit{a},\mathit{b},a]\}$
{[a,a,a],[a,a,b,c],[c,a,b,a]}
%% Cell type:code id: tags:
``` prob
{x| x∈seq(Σ) ∧ (x∈L₁ ∨ x∈L₂)}
```
%% Output
$\{[a,\mathit{a},a],[a,\mathit{a},\mathit{b},c],[c,\mathit{a},\mathit{b},a]\}$
{[a,a,a],[a,a,b,c],[c,a,b,a]}
%% Cell type:code id: tags:
``` prob
L₁ ∩ L₂
```
%% Output
$\{[c,\mathit{a},\mathit{b},a]\}$
{[c,a,b,a]}
%% Cell type:code id: tags:
``` prob
{x| x∈seq(Σ) ∧ (x∈L₁ ∧ x∈L₂)}
```
%% Output
$\{[c,\mathit{a},\mathit{b},a]\}$
{[c,a,b,a]}
%% Cell type:code id: tags:
``` prob
L₁ \ L₂
```
%% Output
$\{[a,\mathit{a},\mathit{b},c]\}$
{[a,a,b,c]}
%% Cell type:code id: tags:
``` prob
L₂ \ L₁
```
%% Output
$\{[a,\mathit{a},a]\}$
{[a,a,a]}
%% Cell type:code id: tags:
``` prob
Komplement = seq(Σ) \ L₁ ∧
[a,a,b,c] ∉ Komplement ∧
[a,a,c,c] ∈ Komplement
```
%% Output
$\mathit{TRUE}$
**Solution:**
* $\mathit{Komplement} = (\mathit{seq}(Σ) - \{[a,\mathit{a},\mathit{b},c],[c,\mathit{a},\mathit{b},a]\})$
TRUE
Solution:
Komplement = (seq(Σ) − {[a,a,b,c],[c,a,b,a]})
%% Cell type:markdown id: tags:
Konkatenation von Wörtern wird in B mit ^ geschrieben:
%% Cell type:code id: tags:
``` prob
w₁^w₁
```
%% Output
$[a,\mathit{a},\mathit{b},\mathit{c},\mathit{a},\mathit{a},\mathit{b},c]$
[a,a,b,c,a,a,b,c]
%% Cell type:code id: tags:
``` prob
w₁^ε
```
%% Output
$[a,\mathit{a},\mathit{b},c]$
[a,a,b,c]
%% Cell type:code id: tags:
``` prob
ε^w₁
```
%% Output
$[a,\mathit{a},\mathit{b},c]$
[a,a,b,c]
%% Cell type:markdown id: tags:
Die Verkettung von Sprachen:
%% Cell type:code id: tags:
``` prob
L₁
```
%% Output
$\{[a,\mathit{a},\mathit{b},c],[c,\mathit{a},\mathit{b},a]\}$
{[a,a,b,c],[c,a,b,a]}
%% Cell type:code id: tags:
``` prob
L₂
```
%% Output
$\{[a,\mathit{a},a],[c,\mathit{a},\mathit{b},a]\}$
{[a,a,a],[c,a,b,a]}
%% Cell type:code id: tags:
``` prob
{w | ∃(a,b).(a∈L₁ ∧ b∈L₂ ∧ w = a^b)}
```
%% 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,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]}
%% Cell type:markdown id: tags:
Man kann eine Sprache auch mit sich selber verketten:
%% Cell type:code id: tags:
``` prob
{w | ∃(a,b).(a∈L₁ ∧ b∈L₁ ∧ w = a^b)}
```
%% 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,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]}
%% Cell type:code id: tags:
``` prob
L₁
```
%% Output
$\{[a,\mathit{a},\mathit{b},c],[c,\mathit{a},\mathit{b},a]\}$
{[a,a,b,c],[c,a,b,a]}
%% Cell type:markdown id: tags:
Die Spiegelung eines Wortes kann im Notebook mit dem ```rev``` Operator verwirklicht werden:
%% Cell type:code id: tags:
``` prob
rev(w₁)
```
%% Output
$[c,\mathit{b},\mathit{a},a]$
[c,b,a,a]
%% Cell type:markdown id: tags:
Eine Sprache wird gespiegelt indem jedes Wort gespiegelt wird:
%% Cell type:code id: tags:
``` prob
{ws|∃w.(w∈L₁ ∧ ws=rev(w))}
```
%% Output
$\{[a,\mathit{b},\mathit{a},c],[c,\mathit{b},\mathit{a},a]\}$
{[a,b,a,c],[c,b,a,a]}
%% Cell type:markdown id: tags:
Die Teilwort und Präfix Relationen definieren wir in folgender B Maschine:
%% Cell type:code id: tags:
``` prob
::load
MACHINE Alphabet
SETS Σ = {a,b,c}
SETS Sigma = {a,b,c}
CONSTANTS ε, Sprachen, w₁, w₂, L₁, L₂
ABSTRACT_CONSTANTS
teilwort, präfix
PROPERTIES
ε ∈ seq(Σ) ∧ size(ε) = 0 ∧
Sprachen = {L | L ⊆ seq(Σ)}∧
ε ∈ seq(Sigma) ∧ size(ε) = 0 ∧
Sprachen = {L | L ⊆ seq(Sigma)}∧
w₁ = [a,a,b,c] ∧
w₂ = [c,a,b,a] ∧
L₁ = {w₁,w₂} ∧
L₂ = {w₂, [a,a,a] } ∧
teilwort = {ut,vt | ut∈seq(Σ) & vt∈seq(Σ) ∧ ∃(vt1,vt2).(vt1^ut^vt2 = vt)} ∧
präfix = {up,vp | up∈seq(Σ) & vp∈seq(Σ) ∧ ∃(wp).(up^wp = vp)}
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)}
DEFINITIONS SET_PREF_PP_SEQUENCES == TRUE
END
```
%% Output
Loaded machine: Alphabet
%% Cell type:code id: tags:
``` prob
:constants
```
%% Output
Machine constants set up using operation 0: $setup_constants()
%% Cell type:code id: tags:
``` prob
[a,a] ↦ [c,b,a,a,b] ∈ teilwort
```
%% Output
$\mathit{TRUE}$
**Solution:**
* $\mathit{TW} = \{[],[a],[a,b],[b],[b,c],[c],[a,\mathit{b},c]\}$
TRUE
Solution:
TW = {[],[a],[a,b],[b],[b,c],[c],[a,b,c]}
%% Cell type:code id: tags:
``` prob
[a,a,a] ↦ [c,b,a,a,b] ∈ teilwort
```
%% Output
$\mathit{FALSE}$
FALSE
%% Cell type:code id: tags:
``` prob
[c] ↦ [c,b,a,a,b] ∈ präfix
```
%% Output
$\mathit{TRUE}$
**Solution:**
* $\mathit{TW} = \{[],[a],[a,b],[b],[b,c],[c],[a,\mathit{b},c]\}$
TRUE
Solution:
TW = {[],[a],[a,b],[b],[b,c],[c],[a,b,c]}
%% Cell type:markdown id: tags:
Man kann den Verkettungs Operator mehrfach anwenden:
%% Cell type:code id: tags:
``` prob
{x| x ↦ [c,b,a,a,b] ∈ präfix}
```
%% 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,b,a],[c,b,a,a],[c,b,a,a,b]}
%% Cell type:code id: tags:
``` prob
{x| x ↦ [c,b,a,a,b] ∈ teilwort}
```
%% 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,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:
``` prob
:let TW {x| x ↦ [a,b,c] ∈ teilwort}
```
%% Output
$\{[],[a],[a,b],[b],[b,c],[c],[a,\mathit{b},c]\}$
{[],[a],[a,b],[b],[b,c],[c],[a,b,c]}
%% Cell type:code id: tags:
``` prob
:pref DOT_DECOMPOSE_NODES=FALSE
```
%% Output
Preference changed: DOT_DECOMPOSE_NODES = FALSE
%% Cell type:code id: tags:
``` prob
:dot expr_as_graph ("tw",{x,y | x |-> y : teilwort & y : TW })
```
%% 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})]>
%% Cell type:code id: tags:
``` prob
:dot expr_as_graph ("präfix",{x,y | x |-> y : präfix & y : TW })
```
%% 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})]>
%% Cell type:code id: tags:
``` prob
```
%% Cell type:code id: tags:
``` prob
```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment