"<text text-anchor=\"middle\" x=\"425.701\" y=\"-164.8\" font-family=\"Times,serif\" font-size=\"14.00\">LET h BE  h={(2|->1),(4|->2),(6|->3),(8|->4),(10|->5)} IN "h" |-> h |-> "hh" |-> (h ; h) END</text>\n",
"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",
"execution_count": 69,
"metadata": {},
"outputs": [
{
"data": {
"text/markdown": [
"$\\{1,2\\}$"
],
"text/plain": [
"{1,2}"
]
},
"execution_count": 69,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"closure1(r)~[{3}]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Anmerkung: die reflexive und transitive Hülle in B wird als ```closure``` geschrieben, ist bei Relationen über Zahlen immer unendlich."
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:
* _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._
* $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$:
: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:
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.