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

add more material on relations

parent d8a1803c
Branches
No related tags found
No related merge requests found
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# Vorlesung 0 - Teil 2 Mengentheorie # Vorlesung 0 - Teil 2 Mengentheorie
Grundlagen der Logik und Mengentheorie sind nicht im Skript. Grundlagen der Logik und Mengentheorie sind nicht im Skript.
Hier definieren wir einige Grundlagen und Notationen die im Skript verwendet werden. Hier definieren wir einige Grundlagen und Notationen die im Skript verwendet werden.
Ein gutes Verständnis dieser Grundlagen und Notationen ist für das Verständnis des Skripts, aber auch anderer Teile der Informatik unumgänglich. Ein gutes Verständnis dieser Grundlagen und Notationen ist für das Verständnis des Skripts, aber auch anderer Teile der Informatik unumgänglich.
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# Mengen # Mengen
Fundamentale Idee der Mengentheorie: Fundamentale Idee der Mengentheorie:
* _"The ability to regard any collection of objects as a single entity (i.e., as a set)."_ (Keith Devlin. Joy of Sets.) * _"The ability to regard any collection of objects as a single entity (i.e., as a set)."_ (Keith Devlin. Joy of Sets.)
In der Regel gibt es eine Domäne an "Objekten" aus denen man Mengen bauen kann. In der Regel gibt es eine Domäne an "Objekten" aus denen man Mengen bauen kann.
Was genau diese Objekte sind interessiert uns in der Mengentheorie nicht. Was genau diese Objekte sind interessiert uns in der Mengentheorie nicht.
Fundamental sind diese beiden Symbole: Fundamental sind diese beiden Symbole:
* wenn $a$ ein Objekt ist und $x$ eine Menge, dann * wenn $a$ ein Objekt ist und $x$ eine Menge, dann
* ist $a \in x$ wahr, wenn $a$ ein Element von $x$ ist * ist $a \in x$ wahr, wenn $a$ ein Element von $x$ ist
* ist $a \not\in x$ wahr, wenn $a$ **kein** Element von $x$ ist. * ist $a \not\in x$ wahr, wenn $a$ **kein** Element von $x$ ist.
$\in$ und $\not\in$ sind Prädikate, verbunden durch die Eigenschaft: $\in$ und $\not\in$ sind Prädikate, verbunden durch die Eigenschaft:
* $\forall(a,x).(a\not\in x \Leftrightarrow \neg(a \in x))$ * $\forall(a,x).(a\not\in x \Leftrightarrow \neg(a \in x))$
Eine besondere Menge ist die leere Menge $\emptyset$. Eine besondere Menge ist die leere Menge $\emptyset$.
Sie hat keine Elemente: Sie hat keine Elemente:
* $z = \emptyset \Leftrightarrow \forall(a).(a\not\in z)$ * $z = \emptyset \Leftrightarrow \forall(a).(a\not\in z)$
Zwei Mengen $x$ und $y$ sind gleich gdw wenn sie die gleichen Elemente haben: Zwei Mengen $x$ und $y$ sind gleich gdw wenn sie die gleichen Elemente haben:
* $\forall(x,y).(x=y \Leftrightarrow \forall(a).(a\in x \Leftrightarrow a \in y))$ * $\forall(x,y).(x=y \Leftrightarrow \forall(a).(a\in x \Leftrightarrow a \in y))$
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
∅ = {1} ∅ = {1}
``` ```
%% Output %% Output
$\mathit{FALSE}$ $\mathit{FALSE}$
FALSE FALSE
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
{1} = {1,2} {1} = {1,2}
``` ```
%% Output %% Output
$\mathit{FALSE}$ $\mathit{FALSE}$
FALSE FALSE
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
{1,2} = {1,2} {1,2} = {1,2}
``` ```
%% Output %% Output
$\mathit{TRUE}$ $\mathit{TRUE}$
TRUE TRUE
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# Notationen für Mengen: endliche Enumeration # Notationen für Mengen: endliche Enumeration
* explizite Auflistung aller Elemente $\{a_1,\ldots,a_n\}$ * explizite Auflistung aller Elemente $\{a_1,\ldots,a_n\}$
* die Reihenfolge spielt keine Rolle: * die Reihenfolge spielt keine Rolle:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
{2,5,3} = {2,3,5} {2,5,3} = {2,3,5}
``` ```
%% Output %% Output
$\mathit{TRUE}$ $\mathit{TRUE}$
TRUE TRUE
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Dies ist im Unterschied zu Tupeln und Listen, die oft mit runden und eckigen Klammern geschriben werden: Dies ist im Unterschied zu Tupeln und Listen, die oft mit runden und eckigen Klammern geschriben werden:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
(2,5,3) = (2,3,5) (2,5,3) = (2,3,5)
``` ```
%% Output %% Output
$\mathit{FALSE}$ $\mathit{FALSE}$
FALSE FALSE
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
[2,5,3] = [2,5,3] [2,5,3] = [2,5,3]
``` ```
%% Output %% Output
$\mathit{TRUE}$ $\mathit{TRUE}$
TRUE TRUE
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
* Elemente können in der Enumeration mehrfach auftauchen: * Elemente können in der Enumeration mehrfach auftauchen:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
{2,5,3,2,5} = {2,3,5} {2,5,3,2,5} = {2,3,5}
``` ```
%% Output %% Output
$\mathit{TRUE}$ $\mathit{TRUE}$
TRUE TRUE
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# Vereinigung, Schnitt, Differenz # Vereinigung, Schnitt, Differenz
Drei wichtige Operationen auf Mengen sind wie folgt. Drei wichtige Operationen auf Mengen sind wie folgt.
Vereinigung von Mengen $\cup$ : Vereinigung von Mengen $\cup$ :
* $z = x\cup y \Leftrightarrow \forall(a).(a\in z \Leftrightarrow (a\in x \vee a \in y))$ * $z = x\cup y \Leftrightarrow \forall(a).(a\in z \Leftrightarrow (a\in x \vee a \in y))$
Schnitt von Mengen $\cap$: Schnitt von Mengen $\cap$:
* $z = x\cap y \Leftrightarrow \forall(a).(a\in z \Leftrightarrow (a\in x \wedge a \in y))$ * $z = x\cap y \Leftrightarrow \forall(a).(a\in z \Leftrightarrow (a\in x \wedge a \in y))$
Differenz von Mengen $\setminus$: Differenz von Mengen $\setminus$:
* $z = x \setminus y \Leftrightarrow \forall(a).(a\in z \Leftrightarrow (a\in x \wedge a \not\in y))$ * $z = x \setminus y \Leftrightarrow \forall(a).(a\in z \Leftrightarrow (a\in x \wedge a \not\in y))$
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
{2,3,5} ∪ {5,7} {2,3,5} ∪ {5,7}
``` ```
%% Output %% Output
$\{2,3,5,7\}$ $\{2,3,5,7\}$
{2,3,5,7} {2,3,5,7}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
{2,3,5}∩{5,7} {2,3,5}∩{5,7}
``` ```
%% Output %% Output
$\{5\}$ $\{5\}$
{5} {5}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
{2,3,5}−{5,7} {2,3,5}−{5,7}
``` ```
%% Output %% Output
$\{2,3\}$ $\{2,3\}$
{2,3} {2,3}
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# Notationen für Mengen: per Prädikat # Notationen für Mengen: per Prädikat
Definition der Elemente durch ein Prädikat $\{a \mid P(a)\}$: Definition der Elemente durch ein Prädikat $\{a \mid P(a)\}$:
* $z = \{a \mid P(a)\} \Leftrightarrow \forall(a).(a\in z \equiv P(a))$ * $z = \{a \mid P(a)\} \Leftrightarrow \forall(a).(a\in z \equiv P(a))$
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
{a | a>1 & a<6 & a≠4} {a | a>1 & a<6 & a≠4}
``` ```
%% Output %% Output
$\{2,3,5\}$ $\{2,3,5\}$
{2,3,5} {2,3,5}
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Man kann damit auch unendliche Mengen darstellen: Man kann damit auch unendliche Mengen darstellen:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
{a | a>10} {a | a>10}
``` ```
%% Output %% Output
$\{\mathit{a}\mid \mathit{a} > 10\}$ $\{\mathit{a}\mid \mathit{a} > 10\}$
{a∣a > 10} {a∣a > 10}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
{a | a mod 2 = 0} ∩ {2,3,5} {a | a mod 2 = 0} ∩ {2,3,5}
``` ```
%% Output %% Output
$\{2\}$ $\{2\}$
{2} {2}
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Man kann damit auch die drei Mengenoperationen definieren: Man kann damit auch die drei Mengenoperationen definieren:
* $x \cup y = \{a \mid a\in x \vee a\in y\}$ * $x \cup y = \{a \mid a\in x \vee a\in y\}$
* $x \cap y = \{a \mid a\in x \wedge a\in y\}$ * $x \cap y = \{a \mid a\in x \wedge a\in y\}$
* $x \setminus y = \{a \mid a\in x \wedge a\not\in y\}$ * $x \setminus y = \{a \mid a\in x \wedge a\not\in y\}$
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
x = {2,3} & y = {2,5} & xy = {a| a∈x ∨ a∈y} x = {2,3} & y = {2,5} & xy = {a| a∈x ∨ a∈y}
``` ```
%% Output %% Output
$\mathit{TRUE}$ $\mathit{TRUE}$
**Solution:** **Solution:**
* $\mathit{xy} = \{2,3,5\}$ * $\mathit{xy} = \{2,3,5\}$
* $\mathit{x} = \{2,3\}$ * $\mathit{x} = \{2,3\}$
* $\mathit{y} = \{2,5\}$ * $\mathit{y} = \{2,5\}$
TRUE TRUE
Solution: Solution:
xy = {2,3,5} xy = {2,3,5}
x = {2,3} x = {2,3}
y = {2,5} y = {2,5}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
x = {2,3} & y = {2,5} & xy = {a| a∈x ∧ a∈y} x = {2,3} & y = {2,5} & xy = {a| a∈x ∧ a∈y}
``` ```
%% Output %% Output
$\mathit{TRUE}$ $\mathit{TRUE}$
**Solution:** **Solution:**
* $\mathit{xy} = \{2\}$ * $\mathit{xy} = \{2\}$
* $\mathit{x} = \{2,3\}$ * $\mathit{x} = \{2,3\}$
* $\mathit{y} = \{2,5\}$ * $\mathit{y} = \{2,5\}$
TRUE TRUE
Solution: Solution:
xy = {2} xy = {2}
x = {2,3} x = {2,3}
y = {2,5} y = {2,5}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
x = {2,3} & y = {2,5} & xy = {a| a∈x ∧ a∉y} x = {2,3} & y = {2,5} & xy = {a| a∈x ∧ a∉y}
``` ```
%% Output %% Output
$\mathit{TRUE}$ $\mathit{TRUE}$
**Solution:** **Solution:**
* $\mathit{xy} = \{3\}$ * $\mathit{xy} = \{3\}$
* $\mathit{x} = \{2,3\}$ * $\mathit{x} = \{2,3\}$
* $\mathit{y} = \{2,5\}$ * $\mathit{y} = \{2,5\}$
TRUE TRUE
Solution: Solution:
xy = {3} xy = {3}
x = {2,3} x = {2,3}
y = {2,5} y = {2,5}
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Als Kürzel führen wir auch die Notation $a..b$ für $\{x \mid x \geq a \wedge x \leq b\}$ ein. Als Kürzel führen wir auch die Notation $a..b$ für $\{x \mid x \geq a \wedge x \leq b\}$ ein.
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
1..10 1..10
``` ```
%% Output %% Output
$\{1,2,3,4,5,6,7,8,9,10\}$ $\{1,2,3,4,5,6,7,8,9,10\}$
{1,2,3,4,5,6,7,8,9,10} {1,2,3,4,5,6,7,8,9,10}
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# Ein Theorem (Distributivgesetz 1) # Ein Theorem (Distributivgesetz 1)
Für alle Mengen $x$, $y$, $z$ gilt: Für alle Mengen $x$, $y$, $z$ gilt:
* $x \cup (y \cap z) = (x\cup y) \cap (x\cup z)$ * $x \cup (y \cap z) = (x\cup y) \cap (x\cup z)$
<img src="./img/Venn.pdf" width="300"> <img src="./img/Venn.pdf" width="300">
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
{2,3,55}∪({2,44,77}∩{2,44,66}) {2,3,55}∪({2,44,77}∩{2,44,66})
``` ```
%% Output %% Output
$\{2,3,44,55\}$ $\{2,3,44,55\}$
{2,3,44,55} {2,3,44,55}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
({2,3,55}∪{2,44,77})∩({2,3,55}∪{2,44,66}) ({2,3,55}∪{2,44,77})∩({2,3,55}∪{2,44,66})
``` ```
%% Output %% Output
$\{2,3,44,55\}$ $\{2,3,44,55\}$
{2,3,44,55} {2,3,44,55}
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
## Beweis von $x \cup (y \cap z) = (x\cup y) \cap (x\cup z)$ ## Beweis von $x \cup (y \cap z) = (x\cup y) \cap (x\cup z)$
Lemmata: Lemmata:
1. $x \cup y = \{a \mid a\in x \vee a\in y\}$ 1. $x \cup y = \{a \mid a\in x \vee a\in y\}$
2. $x \cap y = \{a \mid a\in x \wedge a\in y\}$ 2. $x \cap y = \{a \mid a\in x \wedge a\in y\}$
3. $a \in \{b \mid P(b)\} \equiv P(a)$ 3. $a \in \{b \mid P(b)\} \equiv P(a)$
4. $\phi \vee (\psi \wedge \rho) \equiv (\phi \vee \psi) \wedge (\phi \vee \rho)$ 4. $\phi \vee (\psi \wedge \rho) \equiv (\phi \vee \psi) \wedge (\phi \vee \rho)$
Äquivalenzbeweis Äquivalenzbeweis
1. $x \cup (y \cap z)$ 1. $x \cup (y \cap z)$
2. (Lemma 1) $\Longleftrightarrow$ $\{a \mid a\in x \vee a\in (y \cap z)\}$ 2. (Lemma 1) $\Longleftrightarrow$ $\{a \mid a\in x \vee a\in (y \cap z)\}$
3. (Lemma 2) $\Longleftrightarrow$ $\{a \mid a\in x \vee a\in \{b \mid b\in y \wedge b\in z\} \}$ 3. (Lemma 2) $\Longleftrightarrow$ $\{a \mid a\in x \vee a\in \{b \mid b\in y \wedge b\in z\} \}$
4. (Lemma 3) $\Longleftrightarrow$ $\{a \mid a\in x \vee (a\in y \wedge a\in z) \}$ 4. (Lemma 3) $\Longleftrightarrow$ $\{a \mid a\in x \vee (a\in y \wedge a\in z) \}$
5. (Lemma 4) $\Longleftrightarrow$ $\{a \mid (a\in x \vee a\in y) \wedge (a\in x \vee a\in z) \}$ 5. (Lemma 4) $\Longleftrightarrow$ $\{a \mid (a\in x \vee a\in y) \wedge (a\in x \vee a\in z) \}$
6. (Lemma 3, $\Leftarrow$) $\Longleftrightarrow$ $\{a \mid a\in \{b \mid b\in x \vee b\in y\} \wedge a\in \{b \mid b\in x \vee b\in z\} \}$ 6. (Lemma 3, $\Leftarrow$) $\Longleftrightarrow$ $\{a \mid a\in \{b \mid b\in x \vee b\in y\} \wedge a\in \{b \mid b\in x \vee b\in z\} \}$
7. (Lemma 1, $\Leftarrow$) $\Longleftrightarrow$ $\{a \mid a\in x \cup y \wedge a\in x \cup z) \}$ 7. (Lemma 1, $\Leftarrow$) $\Longleftrightarrow$ $\{a \mid a\in x \cup y \wedge a\in x \cup z) \}$
8. (Lemma 2, $\Leftarrow$) $(x\cup y) \cap (x\cup z)$ 8. (Lemma 2, $\Leftarrow$) $(x\cup y) \cap (x\cup z)$
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# Gesetze # Gesetze
Für alle Mengen $x$, $y$, $z$ gilt: Für alle Mengen $x$, $y$, $z$ gilt:
* $x \cup y = y \cup x$ (Kommutativ 1) * $x \cup y = y \cup x$ (Kommutativ 1)
* $x \cap y = y \cap x$ (Kommutativ 2) * $x \cap y = y \cap x$ (Kommutativ 2)
* $x \cup (y \cup z) = (x\cup y) \cup z$ (Assoziativ 1) * $x \cup (y \cup z) = (x\cup y) \cup z$ (Assoziativ 1)
* $x \cap (y \cap z) = (x\cap y) \cap z$ (Assoziativ 2) * $x \cap (y \cap z) = (x\cap y) \cap z$ (Assoziativ 2)
* $x \cup (y \cap z) = (x\cup y) \cap (x\cup z)$ (Distributiv 1, siehe oben) * $x \cup (y \cap z) = (x\cup y) \cap (x\cup z)$ (Distributiv 1, siehe oben)
* $x \cap (y \cup z) = (x\cap y) \cup (x\cap z)$ (Distributiv 2) * $x \cap (y \cup z) = (x\cap y) \cup (x\cap z)$ (Distributiv 2)
* $z \setminus (x \cup y) = (z\setminus x) \cap (z\setminus y)$ (De Morgan 1) * $z \setminus (x \cup y) = (z\setminus x) \cap (z\setminus y)$ (De Morgan 1)
* $z \setminus (x \cap y) = (z\setminus x) \cup (z\setminus y)$ (De Morgan 2) * $z \setminus (x \cap y) = (z\setminus x) \cup (z\setminus y)$ (De Morgan 2)
* $x \cup \emptyset = x$ (Leere Menge 1) * $x \cup \emptyset = x$ (Leere Menge 1)
* $x \cap \emptyset = \emptyset$ (Leere Menge 2) * $x \cap \emptyset = \emptyset$ (Leere Menge 2)
* $x \cap (z \setminus x) = \emptyset$ (Leere Menge 3) * $x \cap (z \setminus x) = \emptyset$ (Leere Menge 3)
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
(1..10) \ ({2,4,6,8} ∪ {5,10}) // De Morgan 1 - linke Seite (1..10) \ ({2,4,6,8} ∪ {5,10}) // De Morgan 1 - linke Seite
``` ```
%% Output %% Output
$\{1,3,7,9\}$ $\{1,3,7,9\}$
{1,3,7,9} {1,3,7,9}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
(1..10) \ {2,4,6,8} (1..10) \ {2,4,6,8}
``` ```
%% Output %% Output
$\{1,3,5,7,9,10\}$ $\{1,3,5,7,9,10\}$
{1,3,5,7,9,10} {1,3,5,7,9,10}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
(1..10) \ {5,10} (1..10) \ {5,10}
``` ```
%% Output %% Output
$\{1,2,3,4,6,7,8,9\}$ $\{1,2,3,4,6,7,8,9\}$
{1,2,3,4,6,7,8,9} {1,2,3,4,6,7,8,9}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
((1..10) \ {2,4,6,8}) ∩ ((1..10) \ {5,10}) // De Morgan 1 - rechte Seite ((1..10) \ {2,4,6,8}) ∩ ((1..10) \ {5,10}) // De Morgan 1 - rechte Seite
``` ```
%% Output %% Output
$\{1,3,7,9\}$ $\{1,3,7,9\}$
{1,3,7,9} {1,3,7,9}
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Gesetze von De Morgan: $Op1( x ~ Op2 ~ y)$ wird umgewandelt nach $Op1(x) ~ Op2' ~ Op1(y)$, wo Op2' der duale Operator von Op2 ist. Gesetze von De Morgan: $Op1( x ~ Op2 ~ y)$ wird umgewandelt nach $Op1(x) ~ Op2' ~ Op1(y)$, wo Op2' der duale Operator von Op2 ist.
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
{2,4} ∩ (ℤ \ {2,4}) {2,4} ∩ (ℤ \ {2,4})
``` ```
%% Output %% Output
$\renewcommand{\emptyset}{\mathord\varnothing}\emptyset$ $\renewcommand{\emptyset}{\mathord\varnothing}\emptyset$
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# Teilmenge # Teilmenge
Eine Menge $x$ ist eine Teilmenge oder Untermenge von $y$ wenn gilt: Eine Menge $x$ ist eine Teilmenge oder Untermenge von $y$ wenn gilt:
* $\forall a. a\in x \Rightarrow a \in y$ * $\forall a. a\in x \Rightarrow a \in y$
Wir benutzen diese Schreibweise $x \subseteq y$. Wir benutzen diese Schreibweise $x \subseteq y$.
In diesem Fall ist $y$ auch eine Obermenge von $y$, geschrieben als $y \supseteq x$. In diesem Fall ist $y$ auch eine Obermenge von $y$, geschrieben als $y \supseteq x$.
Für die echte Teilmenge benutzen wir folgende Schreibweise und Definition: Für die echte Teilmenge benutzen wir folgende Schreibweise und Definition:
* $x \subset y$ $\Leftrightarrow$ $(x \subseteq y \wedge x\neq y)$. * $x \subset y$ $\Leftrightarrow$ $(x \subseteq y \wedge x\neq y)$.
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
x={1,3} ∧ y = 1..5 ∧ ∀a.(a∈x ⇒ a∈y) x={1,3} ∧ y = 1..5 ∧ ∀a.(a∈x ⇒ a∈y)
``` ```
%% Output %% Output
$\newcommand{\upto}{\mathbin{.\mkern1mu.}}\mathit{TRUE}$ $\newcommand{\upto}{\mathbin{.\mkern1mu.}}\mathit{TRUE}$
**Solution:** **Solution:**
* $\mathit{x} = \{1,3\}$ * $\mathit{x} = \{1,3\}$
* $\mathit{y} = (1 \upto 5)$ * $\mathit{y} = (1 \upto 5)$
TRUE TRUE
Solution: Solution:
x = {1,3} x = {1,3}
y = (1 ‥ 5) y = (1 ‥ 5)
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
x={1,3} ∧ y = 1..5 ∧ ∀a.(a∈y ⇒ a∈x) x={1,3} ∧ y = 1..5 ∧ ∀a.(a∈y ⇒ a∈x)
``` ```
%% Output %% Output
$\mathit{FALSE}$ $\mathit{FALSE}$
FALSE FALSE
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
{1,3} ⊂ 1..5 {1,3} ⊂ 1..5
``` ```
%% Output %% Output
$\mathit{TRUE}$ $\mathit{TRUE}$
TRUE TRUE
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# Kardinalität # Kardinalität
Die Anzahl der Elemente einer Menge $x$ schreiben wir als Die Anzahl der Elemente einer Menge $x$ schreiben wir als
* $\mid x\mid$ oder auch als $card(x)$ (B Schreibweise). * $\mid x\mid$ oder auch als $card(x)$ (B Schreibweise).
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
card({1,2,3}) card({1,2,3})
``` ```
%% Output %% Output
$3$ $3$
3 3
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
card({1,1,2,3,2}) card({1,1,2,3,2})
``` ```
%% Output %% Output
$3$ $3$
3 3
%% 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:
Achtung, die Kardinalität kann auch unendlich sein: je nach Formalismus, ist folgender Ausdruck entweder unendlich oder nicht wohl definiert: $\mid \{x \mid x>0\} \mid$ Achtung, die Kardinalität kann auch unendlich sein: je nach Formalismus, ist folgender Ausdruck entweder unendlich oder nicht wohl definiert: $\mid \{x \mid x>0\} \mid$
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
card({x|x>0}) card({x|x>0})
``` ```
%% Output %% Output
:eval: NOT-WELL-DEFINED: :eval: NOT-WELL-DEFINED:
card applied to very large set, cardinality not representable in ProB: closure([x],[integer],b(greater(b(identifier(...),integer,[...]),b(value(...),integer,[...])),pred,[nodeid(pos(...))])) card applied to very large set, cardinality not representable in ProB: closure([x],[integer],b(greater(b(identifier(...),integer,[...]),b(value(...),integer,[...])),pred,[nodeid(pos(...))]))
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# SEND+MORE=MONEY # SEND+MORE=MONEY
Klassisches arithmetisches Puzzle wo acht unterschiedliche Ziffern gefunden werden sollen die folgende Gleichung erfüllen: Klassisches arithmetisches Puzzle wo acht unterschiedliche Ziffern gefunden werden sollen die folgende Gleichung erfüllen:
| | | | | | | | | | | |
|---|---|---|---|---| |---|---|---|---|---|
| | S | E | N | D | | | S | E | N | D |
| + | M | O | R | E | | + | M | O | R | E |
| |
|= M| O | N | E | Y | |= M| O | N | E | Y |
| | | | | | | | | | | |
Wir können dies nun in Logik, Mengentheorie und Arithmetik modellieren und lösen. Wir können dies nun in Logik, Mengentheorie und Arithmetik modellieren und lösen.
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Wir haben acht Ziffern: Wir haben acht Ziffern:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
{S,E,N,D,M,O,R,Y} ⊆ 0..9 {S,E,N,D,M,O,R,Y} ⊆ 0..9
``` ```
%% Output %% Output
$\mathit{TRUE}$ $\mathit{TRUE}$
**Solution:** **Solution:**
* $\mathit{R} = 0$ * $\mathit{R} = 0$
* $\mathit{S} = 0$ * $\mathit{S} = 0$
* $\mathit{D} = 0$ * $\mathit{D} = 0$
* $\mathit{E} = 0$ * $\mathit{E} = 0$
* $\mathit{Y} = 0$ * $\mathit{Y} = 0$
* $\mathit{M} = 0$ * $\mathit{M} = 0$
* $\mathit{N} = 0$ * $\mathit{N} = 0$
* $\mathit{O} = 0$ * $\mathit{O} = 0$
TRUE TRUE
Solution: Solution:
R = 0 R = 0
S = 0 S = 0
D = 0 D = 0
E = 0 E = 0
Y = 0 Y = 0
M = 0 M = 0
N = 0 N = 0
O = 0 O = 0
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
diese Ziffern sind alle unterschiedlich: diese Ziffern sind alle unterschiedlich:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
{S,E,N,D,M,O,R,Y} ⊆ 0..9 ∧ {S,E,N,D,M,O,R,Y} ⊆ 0..9 ∧
card({S,E,N,D,M,O,R,Y}) = 8 card({S,E,N,D,M,O,R,Y}) = 8
``` ```
%% Output %% Output
$\mathit{TRUE}$ $\mathit{TRUE}$
**Solution:** **Solution:**
* $\mathit{R} = 1$ * $\mathit{R} = 1$
* $\mathit{S} = 7$ * $\mathit{S} = 7$
* $\mathit{D} = 4$ * $\mathit{D} = 4$
* $\mathit{E} = 6$ * $\mathit{E} = 6$
* $\mathit{Y} = 0$ * $\mathit{Y} = 0$
* $\mathit{M} = 3$ * $\mathit{M} = 3$
* $\mathit{N} = 5$ * $\mathit{N} = 5$
* $\mathit{O} = 2$ * $\mathit{O} = 2$
TRUE TRUE
Solution: Solution:
R = 1 R = 1
S = 7 S = 7
D = 4 D = 4
E = 6 E = 6
Y = 0 Y = 0
M = 3 M = 3
N = 5 N = 5
O = 2 O = 2
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
und wobei die zwei führenden Ziffern S und M ungleich 0 sind: und wobei die zwei führenden Ziffern S und M ungleich 0 sind:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
{S,E,N,D,M,O,R,Y} ⊆ 0..9 ∧ card({S,E,N,D,M,O,R,Y}) = 8 ∧ {S,E,N,D,M,O,R,Y} ⊆ 0..9 ∧ card({S,E,N,D,M,O,R,Y}) = 8 ∧
S ≠ 0 & M ≠ 0 S ≠ 0 & M ≠ 0
``` ```
%% Output %% Output
$\mathit{TRUE}$ $\mathit{TRUE}$
**Solution:** **Solution:**
* $\mathit{R} = 1$ * $\mathit{R} = 1$
* $\mathit{S} = 7$ * $\mathit{S} = 7$
* $\mathit{D} = 4$ * $\mathit{D} = 4$
* $\mathit{E} = 6$ * $\mathit{E} = 6$
* $\mathit{Y} = 0$ * $\mathit{Y} = 0$
* $\mathit{M} = 3$ * $\mathit{M} = 3$
* $\mathit{N} = 5$ * $\mathit{N} = 5$
* $\mathit{O} = 2$ * $\mathit{O} = 2$
TRUE TRUE
Solution: Solution:
R = 1 R = 1
S = 7 S = 7
D = 4 D = 4
E = 6 E = 6
Y = 0 Y = 0
M = 3 M = 3
N = 5 N = 5
O = 2 O = 2
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
und wo die Summe von SEND+MORE MONEY ergibt: und wo die Summe von SEND+MORE MONEY ergibt:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
{S,E,N,D,M,O,R,Y} ⊆ 0..9 ∧ card({S,E,N,D,M,O,R,Y}) = 8 ∧ S ≠ 0 & M ≠ 0 ∧ {S,E,N,D,M,O,R,Y} ⊆ 0..9 ∧ card({S,E,N,D,M,O,R,Y}) = 8 ∧ S ≠ 0 & M ≠ 0 ∧
S*1000 + E*100 + N*10 + D + S*1000 + E*100 + N*10 + D +
M*1000 + O*100 + R*10 + E = M*1000 + O*100 + R*10 + E =
M*10000 + O*1000 + N*100 + E*10 + Y M*10000 + O*1000 + N*100 + E*10 + Y
``` ```
%% Output %% Output
$\mathit{TRUE}$ $\mathit{TRUE}$
**Solution:** **Solution:**
* $\mathit{R} = 8$ * $\mathit{R} = 8$
* $\mathit{S} = 9$ * $\mathit{S} = 9$
* $\mathit{D} = 7$ * $\mathit{D} = 7$
* $\mathit{E} = 5$ * $\mathit{E} = 5$
* $\mathit{Y} = 2$ * $\mathit{Y} = 2$
* $\mathit{M} = 1$ * $\mathit{M} = 1$
* $\mathit{N} = 6$ * $\mathit{N} = 6$
* $\mathit{O} = 0$ * $\mathit{O} = 0$
TRUE TRUE
Solution: Solution:
R = 8 R = 8
S = 9 S = 9
D = 7 D = 7
E = 5 E = 5
Y = 2 Y = 2
M = 1 M = 1
N = 6 N = 6
O = 0 O = 0
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Aber ist dies die einzige Lösung ? Wir können einfach die Menge aller Lösungen berechnen: Aber ist dies die einzige Lösung ? Wir können einfach die Menge aller Lösungen berechnen:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
{S,E,N,D, M,O,R, Y | {S,E,N,D, M,O,R, Y |
{S,E,N,D, M,O,R, Y} ⊆ 0..9 ∧ S >0 ∧ M >0 ∧ {S,E,N,D, M,O,R, Y} ⊆ 0..9 ∧ S >0 ∧ M >0 ∧
card({S,E,N,D, M,O,R, Y}) = 8 ∧ card({S,E,N,D, M,O,R, Y}) = 8 ∧
S*1000 + E*100 + N*10 + D + S*1000 + E*100 + N*10 + D +
M*1000 + O*100 + R*10 + E = M*1000 + O*100 + R*10 + E =
M*10000 + O*1000 + N*100 + E*10 + Y } M*10000 + O*1000 + N*100 + E*10 + Y }
``` ```
%% Output %% Output
$\{(9\mapsto 5\mapsto 6\mapsto 7\mapsto 1\mapsto 0\mapsto 8\mapsto 2)\}$ $\{(9\mapsto 5\mapsto 6\mapsto 7\mapsto 1\mapsto 0\mapsto 8\mapsto 2)\}$
{(9↦5↦6↦7↦1↦0↦8↦2)} {(9↦5↦6↦7↦1↦0↦8↦2)}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:table {S,E,N,D, M,O,R, Y | :table {S,E,N,D, M,O,R, Y |
{S,E,N,D, M,O,R, Y} ⊆ 0..9 ∧ S >0 ∧ M >0 ∧ {S,E,N,D, M,O,R, Y} ⊆ 0..9 ∧ S >0 ∧ M >0 ∧
card({S,E,N,D, M,O,R, Y}) = 8 ∧ card({S,E,N,D, M,O,R, Y}) = 8 ∧
S*1000 + E*100 + N*10 + D + S*1000 + E*100 + N*10 + D +
M*1000 + O*100 + R*10 + E = M*1000 + O*100 + R*10 + E =
M*10000 + O*1000 + N*100 + E*10 + Y } M*10000 + O*1000 + N*100 + E*10 + Y }
``` ```
%% Output %% Output
|S|E|N|D|M|O|R|Y| |S|E|N|D|M|O|R|Y|
|---|---|---|---|---|---|---|---| |---|---|---|---|---|---|---|---|
|$9$|$5$|$6$|$7$|$1$|$0$|$8$|$2$| |$9$|$5$|$6$|$7$|$1$|$0$|$8$|$2$|
S E N D M O R Y S E N D M O R Y
9 5 6 7 1 0 8 2 9 5 6 7 1 0 8 2
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
| | | | | | | | | | | |
|---|---|---|---|---| |---|---|---|---|---|
| | S=9 | E=5 | N=6 | D=7 | | | S=9 | E=5 | N=6 | D=7 |
| + | M=1 | O=0 | R=8 | E=5 | | + | M=1 | O=0 | R=8 | E=5 |
| |
|= M=1| O=0 | N=6 | E=5 | Y=2 | |= M=1| O=0 | N=6 | E=5 | Y=2 |
| | | | | | | | | | | |
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Ein anderes arithmetisches Puzzle ist KISS*KISS=PASSION. Ein anderes arithmetisches Puzzle ist KISS*KISS=PASSION.
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:table {K, I, S, P, A, O, N | :table {K, I, S, P, A, O, N |
{K,P} ⊆ 1..9 ∧ {K,P} ⊆ 1..9 ∧
{I,S,A,O,N} ⊆ 0..9 ∧ {I,S,A,O,N} ⊆ 0..9 ∧
(1000*K+100*I+10*S+S) * (1000*K+100*I+10*S+S) (1000*K+100*I+10*S+S) * (1000*K+100*I+10*S+S)
= 1000000*P+100000*A+10000*S+1000*S+100*I+10*O+N & = 1000000*P+100000*A+10000*S+1000*S+100*I+10*O+N &
card({K, I, S, P, A, O, N}) = 7} card({K, I, S, P, A, O, N}) = 7}
``` ```
%% Output %% Output
|K|I|S|P|A|O|N| |K|I|S|P|A|O|N|
|---|---|---|---|---|---|---| |---|---|---|---|---|---|---|
|$2$|$0$|$3$|$4$|$1$|$8$|$9$| |$2$|$0$|$3$|$4$|$1$|$8$|$9$|
K I S P A O N K I S P A O N
2 0 3 4 1 8 9 2 0 3 4 1 8 9
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# Mengen von Mengen # Mengen von Mengen
Mengen können selber auch Mengen beinhalten Mengen können selber auch Mengen beinhalten
Dies sind alles unterschiedliche Mengen: Dies sind alles unterschiedliche Mengen:
* $\{\{2\},\{3,4\}\}$ * $\{\{2\},\{3,4\}\}$
* $\{\{2,3\},\{4\}\}$ * $\{\{2,3\},\{4\}\}$
* $\{\{2,3\},\{3,4\}\}$ * $\{\{2,3\},\{3,4\}\}$
* $\{\{2,3,4\}\}$ * $\{\{2,3,4\}\}$
* $\{2,3,4\}$ * $\{2,3,4\}$
Wir haben zum Beispiel: Wir haben zum Beispiel:
* $\mathit{card}(\{\{2,3,4\}\}) = 1$ * $\mathit{card}(\{\{2,3,4\}\}) = 1$
* $\mathit{card}(\{\{2\},\{3,4\}\}) = 2$ * $\mathit{card}(\{\{2\},\{3,4\}\}) = 2$
* $\mathit{card}(\{2,3,4\}) = 3$ * $\mathit{card}(\{2,3,4\}) = 3$
* $\{2\} \in \{\{2\},\{3,4\}\} $ * $\{2\} \in \{\{2\},\{3,4\}\} $
* $\{2\} \not\in \{\{2,3\},\{4\}\} $ * $\{2\} \not\in \{\{2,3\},\{4\}\} $
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
card({2,3,4}) card({2,3,4})
``` ```
%% Output %% Output
$3$ $3$
3 3
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
card({{2,3,4}}) card({{2,3,4}})
``` ```
%% Output %% Output
$1$ $1$
1 1
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
card({{2},{3,4}}) card({{2},{3,4}})
``` ```
%% Output %% Output
$2$ $2$
2 2
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
{2} ∈ {{2}, {3,4}} {2} ∈ {{2}, {3,4}}
``` ```
%% Output %% Output
$\mathit{TRUE}$ $\mathit{TRUE}$
TRUE TRUE
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
{2} ∈ {{2,3}, {4}} {2} ∈ {{2,3}, {4}}
``` ```
%% Output %% Output
$\mathit{FALSE}$ $\mathit{FALSE}$
FALSE FALSE
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
## Mengen von Mengen und die leere Menge ## Mengen von Mengen und die leere Menge
Achtung: man muss die leere Menge von der Menge die die leere Menge beinhaltet unterscheiden: Achtung: man muss die leere Menge von der Menge die die leere Menge beinhaltet unterscheiden:
* $\emptyset \neq \{\emptyset\}$ * $\emptyset \neq \{\emptyset\}$
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
∅ = {∅} ∅ = {∅}
``` ```
%% Output %% Output
$\mathit{FALSE}$ $\mathit{FALSE}$
FALSE FALSE
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
card(∅) card(∅)
``` ```
%% Output %% Output
$0$ $0$
0 0
%% 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
∅ ∈ {∅} ∅ ∈ {∅}
``` ```
%% Output %% Output
$\mathit{TRUE}$ $\mathit{TRUE}$
TRUE TRUE
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
∅ ∈ ∅ ∅ ∈ ∅
``` ```
%% Output %% Output
$\mathit{FALSE}$ $\mathit{FALSE}$
FALSE FALSE
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
∅ ∉ ∅ ∅ ∉ ∅
``` ```
%% Output %% Output
$\mathit{TRUE}$ $\mathit{TRUE}$
TRUE TRUE
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# Potenzmenge # Potenzmenge
Die Menge aller Untermengen einer Menge $A$ schreiben wir als $\pow(\mathit{A}) $ oder auch als $2^{A}$. Die Menge aller Untermengen einer Menge $A$ schreiben wir als $\pow(\mathit{A}) $ oder auch als $2^{A}$.
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
POW({1,2}) POW({1,2})
``` ```
%% Output %% Output
$\renewcommand{\emptyset}{\mathord\varnothing}\{\emptyset,\{1\},\{1,2\},\{2\}\}$ $\renewcommand{\emptyset}{\mathord\varnothing}\{\emptyset,\{1\},\{1,2\},\{2\}\}$
{∅,{1},{1,2},{2}} {∅,{1},{1,2},{2}}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
POW(∅) POW(∅)
``` ```
%% Output %% Output
$\renewcommand{\emptyset}{\mathord\varnothing}\{\emptyset\}$ $\renewcommand{\emptyset}{\mathord\varnothing}\{\emptyset\}$
{∅} {∅}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
POW(1..3) POW(1..3)
``` ```
%% Output %% Output
$\renewcommand{\emptyset}{\mathord\varnothing}\{\emptyset,\{1\},\{1,2\},\{1,3\},\{2\},\{1,2,3\},\{2,3\},\{3\}\}$ $\renewcommand{\emptyset}{\mathord\varnothing}\{\emptyset,\{1\},\{1,2\},\{1,3\},\{2\},\{1,2,3\},\{2,3\},\{3\}\}$
{∅,{1},{1,2},{1,3},{2},{1,2,3},{2,3},{3}} {∅,{1},{1,2},{1,3},{2},{1,2,3},{2,3},{3}}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:table POW(1..3) :table POW(1..3)
``` ```
%% Output %% Output
|Elements| |Elements|
|---| |---|
|$\renewcommand{\emptyset}{\mathord\varnothing}\emptyset$| |$\renewcommand{\emptyset}{\mathord\varnothing}\emptyset$|
|$\{1\}$| |$\{1\}$|
|$\{1,2\}$| |$\{1,2\}$|
|$\{1,3\}$| |$\{1,3\}$|
|$\{2\}$| |$\{2\}$|
|$\{1,2,3\}$| |$\{1,2,3\}$|
|$\{2,3\}$| |$\{2,3\}$|
|$\{3\}$| |$\{3\}$|
Elements Elements
{} {}
{1} {1}
{1,2} {1,2}
{1,3} {1,3}
{2} {2}
{1,2,3} {1,2,3}
{2,3} {2,3}
{3} {3}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:table POW(POW({1})) :table POW(POW({1}))
``` ```
%% Output %% Output
|Elements| |Elements|
|---| |---|
|$\renewcommand{\emptyset}{\mathord\varnothing}\renewcommand{\emptyset}{\mathord\varnothing}\renewcommand{\emptyset}{\mathord\varnothing}\emptyset$| |$\renewcommand{\emptyset}{\mathord\varnothing}\renewcommand{\emptyset}{\mathord\varnothing}\renewcommand{\emptyset}{\mathord\varnothing}\emptyset$|
|$\{\emptyset\}$| |$\{\emptyset\}$|
|$\{\emptyset,\{1\}\}$| |$\{\emptyset,\{1\}\}$|
|$\{\{1\}\}$| |$\{\{1\}\}$|
Elements Elements
{} {}
{{}} {{}}
{{},{1}} {{},{1}}
{{1}} {{1}}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
card(POW(1..3)) card(POW(1..3))
``` ```
%% Output %% Output
$8$ $8$
8 8
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
card(POW(1..10)) card(POW(1..10))
``` ```
%% Output %% Output
$1024$ $1024$
1024 1024
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
card(POW(1..100)) card(POW(1..100))
``` ```
%% Output %% Output
$1267650600228229401496703205376$ $1267650600228229401496703205376$
1267650600228229401496703205376 1267650600228229401496703205376
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
card(POW(POW(1..7))) card(POW(POW(1..7)))
``` ```
%% Output %% Output
$340282366920938463463374607431768211456$ $340282366920938463463374607431768211456$
340282366920938463463374607431768211456 340282366920938463463374607431768211456
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
card(POW(POW(POW(1..3)))) card(POW(POW(POW(1..3))))
``` ```
%% Output %% Output
$115792089237316195423570985008687907853269984665640564039457584007913129639936$ $115792089237316195423570985008687907853269984665640564039457584007913129639936$
115792089237316195423570985008687907853269984665640564039457584007913129639936 115792089237316195423570985008687907853269984665640564039457584007913129639936
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# Relationen in der Mengentheorie # Relationen in der Mengentheorie
* Was ist eine Relation? * Was ist eine Relation?
* Wie kann man Relationen in Mengentheorie und Logik abbilden? * Wie kann man Relationen in Mengentheorie und Logik abbilden?
* https://en.wikipedia.org/wiki/Finitary\_relation}: * https://en.wikipedia.org/wiki/Finitary\_relation}:
* _In set theory and logic, a relation is a property that assigns truth values to k-tuples of individuals. Typically, the property describes a possible connection between the components of a k-tuple._ * _In set theory and logic, a relation is a property that assigns truth values to k-tuples of individuals. Typically, the property describes a possible connection between the components of a k-tuple._
* k-Tupel: $(1,2)$ (k=2, Paar) * k-Tupel: $(1,2)$ (k=2, Paar)
* Eine Relation weist k-Tupeln Wahrheitswerte zu: * Eine Relation weist k-Tupeln Wahrheitswerte zu:
* Beispiel: $(1,2) \mapsto TRUE$, $(2,1) \mapsto FALSE$. * Beispiel: $(1,2) \mapsto TRUE$, $(2,1) \mapsto FALSE$.
## Unäre Relationen ## Unäre Relationen
Eine unäre Relation über $x$ entspricht einfach einer Untermenge von $x$: Eine unäre Relation über $x$ entspricht einfach einer Untermenge von $x$:
* die Menge an Werten für die die Relation wahr ist. * die Menge an Werten für die die Relation wahr ist.
\end{itemize} \end{itemize}
Beispiele: Beispiele:
* Relation ``Ziffer'' über die ganzen Zahlen ist * Relation ``Ziffer'' über die ganzen Zahlen ist
* $0 .. 9 \subseteq$ ℤ * $0 .. 9 \subseteq$ ℤ
* Relation ``Gt0'' über die ganzen Zahlen ist * Relation ``Gt0'' über die ganzen Zahlen ist
* $\{ \mathit{x}|\mathit{x} \in $ℤ $\wedge \mathit{x} > 0\} \subseteq$ ℤ. * $\{ \mathit{x}|\mathit{x} \in $ℤ $\wedge \mathit{x} > 0\} \subseteq$ ℤ.
* Relation ``Gerade'' über die ganzen Zahlen ist * Relation ``Gerade'' über die ganzen Zahlen ist
* $\{ \mathit{x}|\mathit{x} \in $ ℤ $\wedge \mathit{x} \mod 2 = 0\} \subseteq$ ℤ. * $\{ \mathit{x}|\mathit{x} \in $ ℤ $\wedge \mathit{x} \mod 2 = 0\} \subseteq$ ℤ.
## Relationen vs Prädikate ## Relationen vs Prädikate
Relationen ist die explizite Darstellung eines Prädikats als Menge: Relationen ist die explizite Darstellung eines Prädikats als Menge:
* Prädikate können mit logischen Junktoren und Quantoren verarabeitet werden: * Prädikate können mit logischen Junktoren und Quantoren verarabeitet werden:
* $\exists x. is\_rich(x)$, $\forall x.(is\_poor(x) \Rightarrow \neg is\_rich(x))$ * $\exists x. is\_rich(x)$, $\forall x.(is\_poor(x) \Rightarrow \neg is\_rich(x))$
* Relationen können mit mengentheoretischen Operationen verarbeitet werden: * Relationen können mit mengentheoretischen Operationen verarbeitet werden:
* $rich \neq \emptyset$, $rich \cap poor = \emptyset$. * $rich \neq \emptyset$, $rich \cap poor = \emptyset$.
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# Kartesisches Produkt und Paare # Kartesisches Produkt und Paare
Das kartesische Produkt $x \times y$ zweier Mengen $x$ und $y$ ist definiert als Das kartesische Produkt $x \times y$ zweier Mengen $x$ und $y$ ist definiert als
* $\{ (a,b) \mid a\in x \wedge b\in y\}$. * $\{ (a,b) \mid a\in x \wedge b\in y\}$.
$(a,b)$ steht hier fü¼r ein geordnetes Paar, $(a,b)$ steht hier fü¼r ein geordnetes Paar,
d.h. $(1 \mapsto 2) \neq (2 \mapsto 1) $. d.h. $(1 \mapsto 2) \neq (2 \mapsto 1) $.
Wir schreiben manchmal auch $a \mapsto b$ anstatt $(a,b)$. Wir schreiben manchmal auch $a \mapsto b$ anstatt $(a,b)$.
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
(1 .. 2) × (4 .. 5) (1 .. 2) × (4 .. 5)
``` ```
%% Output %% Output
$\{(1\mapsto 4),(1\mapsto 5),(2\mapsto 4),(2\mapsto 5)\}$ $\{(1\mapsto 4),(1\mapsto 5),(2\mapsto 4),(2\mapsto 5)\}$
{(1↦4),(1↦5),(2↦4),(2↦5)} {(1↦4),(1↦5),(2↦4),(2↦5)}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
(1 .. 2) × {4} (1 .. 2) × {4}
``` ```
%% Output %% Output
$\{(1\mapsto 4),(2\mapsto 4)\}$ $\{(1\mapsto 4),(2\mapsto 4)\}$
{(1↦4),(2↦4)} {(1↦4),(2↦4)}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
(1 .. 2) × BOOL (1 .. 2) × BOOL
``` ```
%% Output %% Output
$\{(1\mapsto \mathit{FALSE}),(1\mapsto \mathit{TRUE}),(2\mapsto \mathit{FALSE}),(2\mapsto \mathit{TRUE})\}$ $\{(1\mapsto \mathit{FALSE}),(1\mapsto \mathit{TRUE}),(2\mapsto \mathit{FALSE}),(2\mapsto \mathit{TRUE})\}$
{(1↦FALSE),(1↦TRUE),(2↦FALSE),(2↦TRUE)} {(1↦FALSE),(1↦TRUE),(2↦FALSE),(2↦TRUE)}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
(1 .. 3) × (1 .. 3) (1 .. 3) × (1 .. 3)
``` ```
%% Output %% Output
$\{(1\mapsto 1),(1\mapsto 2),(1\mapsto 3),(2\mapsto 1),(2\mapsto 2),(2\mapsto 3),(3\mapsto 1),(3\mapsto 2),(3\mapsto 3)\}$ $\{(1\mapsto 1),(1\mapsto 2),(1\mapsto 3),(2\mapsto 1),(2\mapsto 2),(2\mapsto 3),(3\mapsto 1),(3\mapsto 2),(3\mapsto 3)\}$
{(1↦1),(1↦2),(1↦3),(2↦1),(2↦2),(2↦3),(3↦1),(3↦2),(3↦3)} {(1↦1),(1↦2),(1↦3),(2↦1),(2↦2),(2↦3),(3↦1),(3↦2),(3↦3)}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
card((1..10)×(1..10)) card((1..10)×(1..10))
``` ```
%% Output %% Output
$100$ $100$
100 100
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Das Kartesische Produkt ist nicht kommutativ: Das Kartesische Produkt ist nicht kommutativ:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
{2}×{3} {2}×{3}
``` ```
%% Output %% Output
$\{(2\mapsto 3)\}$ $\{(2\mapsto 3)\}$
{(2↦3)} {(2↦3)}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
{3}×{2} {3}×{2}
``` ```
%% Output %% Output
$\{(3\mapsto 2)\}$ $\{(3\mapsto 2)\}$
{(3↦2)} {(3↦2)}
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Es gilt: Es gilt:
* $A \times B = \emptyset \equiv (A = \emptyset \vee B=\emptyset)$. * $A \times B = \emptyset \equiv (A = \emptyset \vee B=\emptyset)$.
Das Kartesische Produkt wird auch Kreuzmenge oder Produktmenge genannt. Das Kartesische Produkt wird auch Kreuzmenge oder Produktmenge genannt.
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# Binäre Relationen # Binäre Relationen
Eine binäre Relation über $x$ und $y$ ist eine Untermenge des kartesischen Produkts $x \times y$ zweier Mengen. Die Mengen $x$ und $y$ können identisch sein. Eine binäre Relation über $x$ und $y$ ist eine Untermenge des kartesischen Produkts $x \times y$ zweier Mengen. Die Mengen $x$ und $y$ können identisch sein.
Beispiel: die Relation ``kleiner'' über die Ziffern $0..9$: Beispiel: die Relation ``kleiner'' über die Ziffern $0..9$:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
{a,b| (a,b)∈(1..9)×(1..9) ∧ a<b} {a,b| (a,b)∈(1..9)×(1..9) ∧ a<b}
``` ```
%% Output %% Output
$\{(1\mapsto 2),(1\mapsto 3),(1\mapsto 4),(1\mapsto 5),(1\mapsto 6),(1\mapsto 7),(1\mapsto 8),(1\mapsto 9),(2\mapsto 3),(2\mapsto 4),(2\mapsto 5),(2\mapsto 6),(2\mapsto 7),(2\mapsto 8),(2\mapsto 9),(3\mapsto 4),(3\mapsto 5),(3\mapsto 6),(3\mapsto 7),(3\mapsto 8),(3\mapsto 9),(4\mapsto 5),(4\mapsto 6),(4\mapsto 7),(4\mapsto 8),(4\mapsto 9),(5\mapsto 6),(5\mapsto 7),(5\mapsto 8),(5\mapsto 9),(6\mapsto 7),(6\mapsto 8),(6\mapsto 9),(7\mapsto 8),(7\mapsto 9),(8\mapsto 9)\}$ $\{(1\mapsto 2),(1\mapsto 3),(1\mapsto 4),(1\mapsto 5),(1\mapsto 6),(1\mapsto 7),(1\mapsto 8),(1\mapsto 9),(2\mapsto 3),(2\mapsto 4),(2\mapsto 5),(2\mapsto 6),(2\mapsto 7),(2\mapsto 8),(2\mapsto 9),(3\mapsto 4),(3\mapsto 5),(3\mapsto 6),(3\mapsto 7),(3\mapsto 8),(3\mapsto 9),(4\mapsto 5),(4\mapsto 6),(4\mapsto 7),(4\mapsto 8),(4\mapsto 9),(5\mapsto 6),(5\mapsto 7),(5\mapsto 8),(5\mapsto 9),(6\mapsto 7),(6\mapsto 8),(6\mapsto 9),(7\mapsto 8),(7\mapsto 9),(8\mapsto 9)\}$
{(1↦2),(1↦3),(1↦4),(1↦5),(1↦6),(1↦7),(1↦8),(1↦9),(2↦3),(2↦4),(2↦5),(2↦6),(2↦7),(2↦8),(2↦9),(3↦4),(3↦5),(3↦6),(3↦7),(3↦8),(3↦9),(4↦5),(4↦6),(4↦7),(4↦8),(4↦9),(5↦6),(5↦7),(5↦8),(5↦9),(6↦7),(6↦8),(6↦9),(7↦8),(7↦9),(8↦9)} {(1↦2),(1↦3),(1↦4),(1↦5),(1↦6),(1↦7),(1↦8),(1↦9),(2↦3),(2↦4),(2↦5),(2↦6),(2↦7),(2↦8),(2↦9),(3↦4),(3↦5),(3↦6),(3↦7),(3↦8),(3↦9),(4↦5),(4↦6),(4↦7),(4↦8),(4↦9),(5↦6),(5↦7),(5↦8),(5↦9),(6↦7),(6↦8),(6↦9),(7↦8),(7↦9),(8↦9)}
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Diese Relation ist eine Untermenge von ℤ×ℤ. Diese Relation ist eine Untermenge von ℤ×ℤ.
Ein anderes Beispiel ist die Relation ``halb'' über die ganzen Zahlen $1..10$: Ein anderes Beispiel ist die Relation ``halb'' über die ganzen Zahlen $1..10$:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
{a,b| a∈1..10 ∧ b∈1..10 ∧ b*2=a} {a,b| a∈1..10 ∧ b∈1..10 ∧ b*2=a}
``` ```
%% Output %% Output
$\{(2\mapsto 1),(4\mapsto 2),(6\mapsto 3),(8\mapsto 4),(10\mapsto 5)\}$ $\{(2\mapsto 1),(4\mapsto 2),(6\mapsto 3),(8\mapsto 4),(10\mapsto 5)\}$
{(2↦1),(4↦2),(6↦3),(8↦4),(10↦5)} {(2↦1),(4↦2),(6↦3),(8↦4),(10↦5)}
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Eine binäre Relation kann auch als gerichteter Graph angesehen werden: Eine binäre Relation kann auch als gerichteter Graph angesehen werden:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:dot expr_as_graph ("halb",{a,b| a∈1..10 ∧ b∈1..10 & b*2=a}) :dot expr_as_graph ("halb",{a,b| a∈1..10 ∧ b∈1..10 & b*2=a})
``` ```
%% Output %% Output
<Dot visualization: expr_as_graph [("halb",{a,b|a:1..10 & b:1..10 & b*2=a})]> <Dot visualization: expr_as_graph [("halb",{a,b|a:1..10 & b:1..10 & b*2=a})]>
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Die Typen der Elemente kann abweichen. Die Typen der Elemente kann abweichen.
Zum Beispiel die Relation ``durch drei teilbar'' über die ganzen Zahlen $1..7$ zum Datentypen $STRING$ Zum Beispiel die Relation ``durch drei teilbar'' über die ganzen Zahlen $1..7$ zum Datentypen $STRING$
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
{x,y| x:1..7 ∧ (x mod 3 =0 => y = "ja") ∧ (x mod 3 >0 => y= "nein")} {x,y| x:1..7 ∧ (x mod 3 =0 => y = "ja") ∧ (x mod 3 >0 => y= "nein")}
``` ```
%% Output %% Output
$\{(1\mapsto\text{"nein"}),(2\mapsto\text{"nein"}),(3\mapsto\text{"ja"}),(4\mapsto\text{"nein"}),(5\mapsto\text{"nein"}),(6\mapsto\text{"ja"}),(7\mapsto\text{"nein"})\}$ $\{(1\mapsto\text{"nein"}),(2\mapsto\text{"nein"}),(3\mapsto\text{"ja"}),(4\mapsto\text{"nein"}),(5\mapsto\text{"nein"}),(6\mapsto\text{"ja"}),(7\mapsto\text{"nein"})\}$
{(1↦"nein"),(2↦"nein"),(3↦"ja"),(4↦"nein"),(5↦"nein"),(6↦"ja"),(7↦"nein")} {(1↦"nein"),(2↦"nein"),(3↦"ja"),(4↦"nein"),(5↦"nein"),(6↦"ja"),(7↦"nein")}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:dot expr_as_graph ("teilbar",{x,y| x:1..7 ∧ (x mod 3 =0 => y = "ja") ∧ (x mod 3 >0 => y= "nein")}) :dot expr_as_graph ("teilbar",{x,y| x:1..7 ∧ (x mod 3 =0 => y = "ja") ∧ (x mod 3 >0 => y= "nein")})
``` ```
%% Output %% Output
<Dot visualization: expr_as_graph [("teilbar",{x,y|x:1..7 & (x mod 3=0 => y="ja") & (x mod 3>0 => y="nein")})]> <Dot visualization: expr_as_graph [("teilbar",{x,y|x:1..7 & (x mod 3=0 => y="ja") & (x mod 3>0 => y="nein")})]>
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Das Kartesische Produkt stellt die Relation dar die immer wahr ist (für die angegebenen Basismengen). Als Graph ist dies der vollständige Graph über die Basismengen: Das Kartesische Produkt stellt die Relation dar die immer wahr ist (für die angegebenen Basismengen). Als Graph ist dies der vollständige Graph über die Basismengen:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:pref DOT_ENGINE=circo :pref DOT_ENGINE=circo
``` ```
%% Output %% Output
Preference changed: DOT_ENGINE = circo Preference changed: DOT_ENGINE = circo
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:dot expr_as_graph ("K5",(1..5)×(1..5)) :dot expr_as_graph ("K5",(1..5)×(1..5))
``` ```
%% Output %% Output
<Dot visualization: expr_as_graph [("K5",(1..5)*(1..5))]> <Dot visualization: expr_as_graph [("K5",(1..5)*(1..5))]>
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:pref DOT_ENGINE=circo :pref DOT_ENGINE=circo
``` ```
%% Output %% Output
Preference changed: DOT_ENGINE = circo Preference changed: DOT_ENGINE = circo
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:dot expr_as_graph ("K10",(1..10)×(1..10)) :dot expr_as_graph ("K10",(1..10)×(1..10))
``` ```
%% Output %% Output
<Dot visualization: expr_as_graph [("K10",(1..10)*(1..10))]> <Dot visualization: expr_as_graph [("K10",(1..10)*(1..10))]>
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:dot expr_as_graph ("K20",(1..20)×(1..20)) :dot expr_as_graph ("K20",(1..20)×(1..20))
``` ```
%% Output %% Output
<Dot visualization: expr_as_graph [("K20",(1..20)*(1..20))]> <Dot visualization: expr_as_graph [("K20",(1..20)*(1..20))]>
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:pref DOT_ENGINE=dot :pref DOT_ENGINE=dot
``` ```
%% Output %% Output
Preference changed: DOT_ENGINE = dot Preference changed: DOT_ENGINE = dot
%% Cell type:markdown id: tags:
# Definitions- und Wertebereich
Definitionsbereich (Domain in Englisch):
* $dom(r) = \{a \mid \exists b.((a,b)\in r)\}$
Wertebereich (Bildmenge, Range in Englisch):
* $ran(r) = \{b \mid \exists a.((a,b)\in r)\}$
%% Cell type:code id: tags:
``` prob
:let h {a,b| a∈1..10 ∧ b∈1..10 & b*2=a}
```
%% Output
$\{(2\mapsto 1),(4\mapsto 2),(6\mapsto 3),(8\mapsto 4),(10\mapsto 5)\}$
{(2↦1),(4↦2),(6↦3),(8↦4),(10↦5)}
%% Cell type:code id: tags:
``` prob
{a| ∃b.((a,b)∈h)}
```
%% Output
$\{2,4,6,8,10\}$
{2,4,6,8,10}
%% Cell type:code id: tags:
``` prob
{b| ∃a.((a,b)∈h)}
```
%% Output
$\{1,2,3,4,5\}$
{1,2,3,4,5}
%% Cell type:code id: tags:
``` prob
dom(h)
```
%% Output
$\{2,4,6,8,10\}$
{2,4,6,8,10}
%% Cell type:code id: tags:
``` prob
:let h {a,b| a∈1..10 ∧ b∈1..10 & b*2=a}
```
%% Output
$\{(2\mapsto 1),(4\mapsto 2),(6\mapsto 3),(8\mapsto 4),(10\mapsto 5)\}$
{(2↦1),(4↦2),(6↦3),(8↦4),(10↦5)}
%% Cell type:code id: tags:
``` prob
:dot expr_as_graph ("h",h)
```
%% Output
<Dot visualization: expr_as_graph [dhd={(1,"nein"),(2,"nein"),(3,"ja"),(4,"nein"),(5,"nein"),(6,"ja"),(7,"nein")} & h={(2,1),(4,2),(6,3),(8,4),(10,5)}("h",h)]>
%% Cell type:code id: tags:
``` prob
:let d {x,y| x:1..7 ∧ (x mod 3 =0 => y = "ja") ∧ (x mod 3 >0 => y= "nein")}
```
%% Output
$\{(1\mapsto\text{"nein"}),(2\mapsto\text{"nein"}),(3\mapsto\text{"ja"}),(4\mapsto\text{"nein"}),(5\mapsto\text{"nein"}),(6\mapsto\text{"ja"}),(7\mapsto\text{"nein"})\}$
{(1↦"nein"),(2↦"nein"),(3↦"ja"),(4↦"nein"),(5↦"nein"),(6↦"ja"),(7↦"nein")}
%% Cell type:code id: tags:
``` prob
dom(d)
```
%% Output
$\{1,2,3,4,5,6,7\}$
{1,2,3,4,5,6,7}
%% Cell type:code id: tags:
``` prob
ran(d)
```
%% Output
$\{\text{"ja"},\text{"nein"}\}$
{"ja","nein"}
%% Cell type:code id: tags:
``` prob
:dot expr_as_graph ("d",d)
```
%% Output
<Dot visualization: expr_as_graph [dhd={(1,"nein"),(2,"nein"),(3,"ja"),(4,"nein"),(5,"nein"),(6,"ja"),(7,"nein")} & h={(2,1)}("d",d)]>
%% Cell type:markdown id: tags:
# Relationales Abbild und Umkehrrelation
Abbild:
* $r[A] = \{b \mid \exists a.((a,b)\in r \wedge a\in A)\}$
Umkehrrelation:
* $r^{-1} = \{(b,a) \mid (a,b)\in r \}$\\
Im Notebook muss für die Umkehrrelation leider Tilde (~) verwendet werden:
%% Cell type:code id: tags:
``` prob
h[8..10]
```
%% Output
$\{4,5\}$
{4,5}
%% Cell type:code id: tags:
``` prob
d[{3,6}]
```
%% Output
$\{\text{"ja"}\}$
{"ja"}
%% Cell type:code id: tags:
``` prob
d[{0}]
```
%% Output
$\renewcommand{\emptyset}{\mathord\varnothing}\emptyset$
%% Cell type:code id: tags:
``` prob
d~
```
%% Output
$\{(\text{"ja"}\mapsto 3),(\text{"ja"}\mapsto 6),(\text{"nein"}\mapsto 1),(\text{"nein"}\mapsto 2),(\text{"nein"}\mapsto 4),(\text{"nein"}\mapsto 5),(\text{"nein"}\mapsto 7)\}$
{("ja"↦3),("ja"↦6),("nein"↦1),("nein"↦2),("nein"↦4),("nein"↦5),("nein"↦7)}
%% Cell type:code id: tags:
``` prob
:dot expr_as_graph ("d~",d~)
```
%% Output
<Dot visualization: expr_as_graph [dhd={(1,"nein"),(2,"nein"),(3,"ja"),(4,"nein"),(5,"nein"),(6,"ja"),(7,"nein")} & h={(2,1),(4,2),(6,3),(8,4),(10,5)}("d~",d~)]>
%% Cell type:markdown id: tags:
Man kann natürlich auch beide Operatore verknüpfen, zum Beispiel um herauszufinden welche Zahlen durch 3 teilbar sind:
%% Cell type:code id: tags:
``` prob
d~[{"ja"}]
```
%% Output
$\{3,6\}$
{3,6}
%% Cell type:code id: tags:
``` prob
:unlet d
```
%% Cell type:code id: tags:
``` prob
# Binäre Relationen - Verknüpfung
Wir können Relationen $r_1$ und $r_2$ mit dem Operator ``;'' verknüpfen:
* $(r_1 ; r_2)$ = $\{(a,c) \mid \exists b. ( (a,b)\in r_1 \wedge (b,c)\in r_2)\}$.
```
%% Output
$1 = 2$
1 = 2
%% Cell type:code id: tags:
``` prob
({1↦2, 2↦3} ; {2↦4, 2↦8})
```
%% Output
$\{(1\mapsto 4),(1\mapsto 8)\}$
{(1↦4),(1↦8)}
%% Cell type:markdown id: tags:
Man kann eine Relation auch mit sich selber verknüpfen wenn Werte- und Definitionsbereich kompatibel sind.
Zum Beispiel $h^2 = (h;h)$:
%% Cell type:code id: tags:
``` prob
(h ; h)
```
%% Output
$\{(4\mapsto 1),(8\mapsto 2)\}$
{(4↦1),(8↦2)}
%% Cell type:code id: tags:
``` prob
:dot expr_as_graph ("h",h,"hh",(h;h))
```
%% Output
<Dot visualization: expr_as_graph [dhd={(1,"nein"),(2,"nein"),(3,"ja"),(4,"nein"),(5,"nein"),(6,"ja"),(7,"nein")} & h={(2,1),(4,2),(6,3),(8,4),(10,5)}("h",h)]>
%% Cell type:code id: tags:
``` prob
:dot expr_as_graph ("hh",(h;h))
```
%% Output
<Dot visualization: expr_as_graph [dhd={(1,"nein"),(2,"nein"),(3,"ja"),(4,"nein"),(5,"nein"),(6,"ja"),(7,"nein")} & h={(2,1),(4,2),(6,3),(8,4),(10,5)}("hh",(h;h))]>
%% Cell type:code id: tags:
``` prob
:dot expr_as_graph ("h",(h))
```
%% Output
<Dot visualization: expr_as_graph [dhd={(1,"nein"),(2,"nein"),(3,"ja"),(4,"nein"),(5,"nein"),(6,"ja"),(7,"nein")} & h={(2,1),(4,2),(6,3),(8,4),(10,5)}("h",h)]>
%% Cell type:markdown id: tags:
# Transitive und Reflexive Hülle
Gegeben eine Relation $r$ von $A$ nach $A$
* $r^0 = \{(a,a) \mid a\in A\}$
* $r^1 = r$
* $r^k = (r^{k-1} ; r) = (r ; r^{k-1})$
* $r^*$ = $\bigcup_{i\geq 0} r^i$
Die transitive Hülle von $r$ ist:
* $r^+$ = $\bigcup_{i\geq 1} r^i$
%% Cell type:code id: tags:
``` prob
:let A {1,2,3}
```
%% Output
$\{1,2,3\}$
{1,2,3}
%% Cell type:code id: tags:
``` prob
:let r {(1,2), (2,3)}
```
%% Output
$\{(1\mapsto 2),(2\mapsto 3)\}$
{(1↦2),(2↦3)}
%% Cell type:code id: tags:
``` prob
:dot expr_as_graph ("r",r)
```
%% Output
<Dot visualization: expr_as_graph [ArhA={1,2,3} & r={(1,2),(2,3)} & h={(2,1),(4,2),(6,3),(8,4),(10,5)}("r",r)]>
%% Cell type:code id: tags:
``` prob
(r;r)
```
%% Output
$\{(1\mapsto 3)\}$
{(1↦3)}
%% Cell type:markdown id: tags:
In B kann man $r^0$ auch als die Identitätsrelation über A beschreiben:
%% Cell type:code id: tags:
``` prob
id(A)
```
%% Output
$\{(1\mapsto 1),(2\mapsto 2),(3\mapsto 3)\}$
{(1↦1),(2↦2),(3↦3)}
%% Cell type:markdown id: tags:
Die transitive und reflexive Hülle ist hier:
%% Cell type:code id: tags:
``` prob
id(A) \/ r \/ (r;r) \/ (r;r;r) \/ (r;r;r;r)
```
%% Output
$\{(1\mapsto 1),(1\mapsto 2),(1\mapsto 3),(2\mapsto 2),(2\mapsto 3),(3\mapsto 3)\}$
{(1↦1),(1↦2),(1↦3),(2↦2),(2↦3),(3↦3)}
%% Cell type:code id: tags:
``` prob
:dot expr_as_graph ("r*",id(A) \/ r \/ (r;r) \/ (r;r;r) \/ (r;r;r;r))
```
%% Output
<Dot visualization: expr_as_graph [ArhA={1,2,3} & r={(1,2),(2,3)} & h={(2,1),(4,2),(6,3),(8,4),(10,5)}("r*",id(A)\/r\/(r;r)\/((r;r);r)\/(((r;r);r);r))]>
%% Cell type:markdown id: tags:
Die transitive Hülle wird in B als ```closure1``` geschrieben:
%% Cell type:code id: tags:
``` prob
closure1(r)
```
%% Output
$\{(1\mapsto 2),(1\mapsto 3),(2\mapsto 3)\}$
{(1↦2),(1↦3),(2↦3)}
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` prob ``` prob
:dot expr_as_graph ("r+",closure1(r))
``` ```
%% Output
<Dot visualization: expr_as_graph [ArhA={1,2,3} & r={(1,2),(2,3)} & h={(2,1),(4,2),(6,3),(8,4),(10,5)}("r+",closure1(r))]>
%% Cell type:markdown id: tags:
Man kann die transitive Hülle natürlich mit den anderen Operatoren verknüpfen, zum Beispiel um auszurechnen von welchen Knoten aus man den Knoten 3 erreichen kann:
%% Cell type:code id: tags:
``` prob
closure1(r)~[{3}]
```
%% Output
$\{1,2\}$
{1,2}
%% Cell type:markdown id: tags:
Anmerkung: die reflexive und transitive Hülle in B wird als ```closure``` geschrieben, ist bei Relationen über Zahlen immer unendlich.
%% Cell type:code id: tags:
``` prob
closure(r)
```
%% Output
$/*@symbolic*/ \{\mathit{z\_},\mathit{z\_\_}\mid \mathit{z\_} \mapsto \mathit{z\_\_} \in \{(1\mapsto 2),(1\mapsto 3),(2\mapsto 3)\} \lor \mathit{z\_} = \mathit{z\_\_}\}$
/*@symbolic*/ {z_,z__∣z_ ↦ z__ ∈ {(1↦2),(1↦3),(2↦3)} ∨ z_ = z__}
%% Cell type:code id: tags:
``` prob
closure(r)~[{3}]
```
%% Output
$\{1,2,3\}$
{1,2,3}
%% Cell type:markdown id: tags:
# Funktionen
Was unterscheidet Funktionen von Relationen?
Wie kann man Funktionen in Mengentheorie und Logik darstellen?
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment