• Keine Ergebnisse gefunden

Theory of Computer Science A2. Mathematical Foundations Gabriele R¨oger

N/A
N/A
Protected

Academic year: 2022

Aktie "Theory of Computer Science A2. Mathematical Foundations Gabriele R¨oger"

Copied!
17
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Theory of Computer Science

A2. Mathematical Foundations

Gabriele R¨ oger

University of Basel

(2)

Theory of Computer Science

— A2. Mathematical Foundations

A2.1 Sets, Tuples, Relations A2.2 Functions

A2.3 Summary

Gabriele R¨oger (University of Basel) Theory of Computer Science 2 / 17

(3)

A2.1 Sets, Tuples, Relations

(4)

Sets

I set: unordered collection of distinguishable objects;

each object contained at most once I notations:

I explicit, listing all elements, e. g. A = {1, 2, 3}

I implicit, specifying a property characterizing all elements, e. g. A = {x | x ∈ N and 1 ≤ x ≤ 3}

I implicit, as a sequence with dots, e. g. Z = {. . . , −2, −1, 0, 1, 2, . . . }

I e ∈ M: e is in set M (an element of the set) I e ∈ / M: e is not in set M

I empty set ∅ = {}

I cardinality |M | of a finite set M : number of elements in M German: Menge, Element, leere Menge, M¨ achtigkeit/Kardinalit¨ at

Gabriele R¨oger (University of Basel) Theory of Computer Science 4 / 17

(5)

Sets

I A ⊆ B: A is a subset of B,

i. e., every element of A is an element of B I A ⊂ B: A is a strict subset of B ,

i. e., A ⊆ B and A 6= B.

I power set P (M ): set of all subsets of M e. g., P({a, b}) =

I Cardinality of power set of finite set S : |P(S )| =

German: Teilmenge, echte Teilmenge, Potenzmenge

(6)

Set Operations

I intersection A ∩ B = {x | x ∈ A and x ∈ B}

A B

I union A ∪ B = {x | x ∈ A or x ∈ B }

A B

I difference A \ B = {x | x ∈ A and x ∈ / B}

A B

I complement A = B \ A, where A ⊆ B and

B is the set of all considered objects (in a given context) A

German: Schnitt, Vereinigung, Differenz, Komplement

Gabriele R¨oger (University of Basel) Theory of Computer Science 6 / 17

(7)

Tuples

I k -tuple: ordered sequence of k objects I written (o 1 , . . . , o k ) or ho 1 , . . . , o k i I unlike sets, order matters (h1, 2i 6= h2, 1i) I objects may occur multiple times in a tuple I objects contained in tuples are called components I terminology:

I k = 2: (ordered) pair I k = 3: triple

I more rarely: quadruple, quintuple, sextuple, septuple, . . . I if k is clear from context (or does not matter),

often just called tuple

German: k -Tupel, Komponente, Paar, Tripel

(8)

Cartesian Product

I for sets M 1 , M 2 , . . . , M n , the Cartesian product M 1 × · · · × M n is the set

M 1 × · · · × M n = {ho 1 , . . . , o n i | o 1 ∈ M 1 , . . . , o n ∈ M n }.

I Example: M 1 = {a, b, c}, M 2 = {1, 2},

M 1 × M 2 = {ha, 1i, ha, 2i, hb, 1i, hb, 2i, hc , 1i, hc , 2i}

I special case: M k = M × · · · × M (k times) I example with M = {1, 2}:

M 2 = {h1, 1i, h1, 2i, h2, 1i, h2, 2i}

German: kartesisches Produkt

Gabriele R¨oger (University of Basel) Theory of Computer Science 8 / 17

(9)

Relations

I an n-ary relation R over the sets M 1 , . . . , M n

is a subset of their Cartesian product: R ⊆ M 1 × · · · × M n . I example with M = {1, 2}:

R ≤ ⊆ M 2 as R ≤ = {h1, 1i, h1, 2i, h2, 2i}

German: (n-stellige) Relation

(10)

Exercise

Consider S = P({1, 2}) × {a, b}.

1

Write down three different elements of S.

2

What is |S |?

Gabriele R¨oger (University of Basel) Theory of Computer Science 10 / 17

(11)

A2.2 Functions

(12)

Functions

Definition (Total Function)

A (total) function f : D → C (with sets D, C ) maps every value of its domain D

to exactly one value of its codomain C .

German: (totale) Funktion, Definitionsbereich, Wertebereich Example

I square : Z → Z with square(x) = x 2 I add : N 2 0 → N 0 with add(x, y) = x + y I add R : R 2 → R with add R (x, y) = x + y

Gabriele R¨oger (University of Basel) Theory of Computer Science 12 / 17

(13)

Functions: Example

Example

Let Q = {q 0 , q 1 , q 2 , q accept , q reject } and Γ = {0, 1, }.

Define δ : (Q \ {q accept , q reject }) × Γ → Q × Γ × {L, R} by

δ 0 1

q 0 hq 0 , 0, Ri hq 0 , 1, Ri hq 1 , , Li

q 1 hq 2 , 1, Li hq 1 , 0, Li hq reject , 1, Li

q 2 hq 2 , 0, Li hq 2 , 1, Li hq accept , , Ri

Then, e. g., δ(q 0 , 1) = hq 0 , 1, Ri

(14)

Partial Functions

Definition (Partial Function)

A partial function f : X → p Y maps every value in X to at most one value in Y .

If f does not map x ∈ X to any value in Y , then f is undefined for x.

German: partielle Funktion Example

f : N 0 × N 0 → p N 0 with

f (x, y) =

( x − y if y ≤ x undefined otherwise

Gabriele R¨oger (University of Basel) Theory of Computer Science 14 / 17

(15)

Exercises

Let V = {X , Y , Z }, Σ = {a, b, c } and Q = {q 1 , q 2 } be three sets.

1

Specify a non-trivial example for a partial function δ : Q × Σ → p P(Q).

2

Specify a non-trivial example for a

relation P ⊆ (V ∪ Σ) 2 × V 2 .

(16)

A2.3 Summary

Gabriele R¨oger (University of Basel) Theory of Computer Science 16 / 17

(17)

Summary

I sets: unordered, contain every element at most once I tuples: ordered, can contain the same object multiple times I Cartesian product: M 1 × · · · × M n set of all n-tuples

where the i-th component is in M i

I function f : X → Y maps every value in X to exactly one value in Y

I partial function g : X → p Y may be undefined

for some values in X

Referenzen

ÄHNLICHE DOKUMENTE

The new grammar has all original rules except that S is replaced with a new variable S’ (allowing to derive everything from S’ that could originally be derived from the start

In addition, it has rules that allow to start from the original start variable but switch to S’ after the first rule application:. S

If you read a 1 at the first tape position, move every non-blank symbol on the tape one position to the right, write a 1 in the first tape position and accept...

I If you read a 1 at the first tape position, move every non-blank symbol on the tape one position to the right, write a 1 in the first tape position and accept...

for 2.: identical to (1), only that M B only recognizes B and therefore the simulation does not necessarily terminate if y 6∈ B. Since y 6∈ B iff x 6∈ A, the procedure still

for 2.: identical to (1), only that M B only recognizes B and therefore the simulation does not necessarily terminate if y 6∈ B. Since y 6∈ B iff x 6∈ A, the procedure still

I Instead, we prove a much more general result, Rice’s theorem, which shows that a very large class of different problems are undecidable.. I Rice’s theorem can be summarized

An oracle machine is like a Turing machine that has access to an oracle which can solve some decision problem in constant timeA. Example