2024-01-22 10:12:47

This commit is contained in:
Isaac Shoebottom
2024-01-22 10:12:48 -04:00
parent 8cf1b5ba3b
commit ecba3cbcf8
78 changed files with 82766 additions and 0 deletions

View File

@ -0,0 +1,49 @@
Strings and languages:
- An alphabet is a finite set of symbols, such as {1,2,3} or {0,1}
- A string is an alphabet $\sum$ is a finite sequence of symblols from $\sum$, for example 010010 and 10010101 are strings over the alphabet {0,1}
- A languge is a set of strings
- L1 = {00, 01, 10, 11}
- L2 = {a^n | n is an integer non-negative}
Notation: a to the power of n just means a repeated n times
Examples
$L_8 = \{a^m b^n | m,n \in \mathbb{z}^{nonneg}\}$
So valid strings would be
aaabbb, aaabbbb, ab, abb
$L_9 = \{a^n b^n | n \in \mathbb{z}^{nonneg}\}$
So valid strings would be
aabb, ab, aaaabbbb, aaaaaabbbbbb
$L_{11} = \{w \in \{a, b\}^* | \text{The number of "a"s is equal to the number of "b"s}\}$
This would include everything that L9 includes, but allows for the alphabet can be out of order
You can also written this as
$L_{11} = \{w \in \{a, b\}^* | n_a(w) = n_b(w)\}$
You can extend the repetition notation (exponent) to include multiple symbols by wrapping it in parentheses
Example:
$L_{12} = \{(ab)^n | n \in \mathbb{z}^{nonneg}\}$
This means we need to be careful as
$L_{13} = \{ab^n | n \in \mathbb{z}^{nonneg}\}$
is different, as L12 is asking for repetition of ab, while L13 is assigning a prefix of a and repetition of b
$L_{14} = \{a^i b^j c^k | i,j,k \in \mathbb{z}^{nonneg}, j = 2i + 3k\}$
So this means that for any number of "a"s and "c"s, the number of "b"s is predetermined if you have selected your "a"s and "c"s
Intro to functions and relations
Informally, a function (f) descrives an input output situation (A -> B)
For every input element a in A, there is exactly one ouput element b in B
f maps a to b
A is the domain of f
B is the co-domain of f

View File

@ -0,0 +1,52 @@
Lecture Topic: Functions
For every input element $a \in A$ there is exactly one output element $b \in B$
Jargon:
- f maps a to b
- the image of a under f is b
functions are one-to-one (or injective):
$\forall x,y \in A, x \neq y \rightarrow f(x) \neq f(y)$
or in other terms
$\forall x,y \in A, x = y \rightarrow f(x) = f(y)$
Example:
$f(x) = x^2$ is not one to one
Proof by counter example:
$x = -1$ and $y = 1$ are two integers in the domain that $x=y$ but $f(-1)$ and $f(1)$ are both equal to 1, so it is not one to one
To prove a function is one to one, it is a little more tricky, and needs to be general, for example:
Let x and y be any arbitrary elements of the domain where f(x) = f(y)
So it follows that x and y are equal (x = y)
Example for a real function: $g(x) = 3x - 11$
Real Numbers
Let x and y be any real number such that $g(x) = g(y)$. We will show that $x = y$
Since we know that g(x) = g(y), it means that $3x - 11 = 3y - 11$
Add 11 to both sides: $\therefore 3x = 3y$
Divide both sides by 3: $\therefore x = y$
Important to note: The definition (domain and co-domain) can change if a function is one to one, for example the square function on all integers vs all positive integers
To prove that a function A -> B is onto:
- Let be represent and arbitrary element in the co-domain B
- We want to find an element a in the domain and show that f(a) = b
Example:
Real Numbers, $f(x) = 5x + 2$ is onto
Proof: Let b be any arbitrary real number (we want to find a real number a and show that f(a) = b)
A through process might follow that, I want a value a such that f(a) = b, I want $5a + 2 = b$, then $5a = b - 2$, then $a = \frac{b - 2}{5}$
So, let $a = \frac{b - 2}{5}$ , which is a real number. Then plug this back into the function
$f(a) = f(\frac{b - 2}{5}$) (Substitution)
$= 5\frac{b-2}{5}+2$ (Definition of f)
$= (b-2) +2)$ (Algebra)
$=b$ (Algebra)
Beginning of proving a function is not onto:
Find some specific co-domain element b and show that there is no domain element that could map to b

View File

@ -0,0 +1,61 @@
Lecture Topic: Functions & Relations
When a function is onto, it means that the entire co-domain of a function is the range of the function
Proving a function is not onto:
Just prove for any element b in the co-domain B and show that b cannot be equal to f(a) for any a in the domain.
Example: $g: \mathbb{R} \rightarrow \mathbb{R}, g(x) = x^2 + 10$ is not onto
Proof:
For example, choose the element $-1$ from the co-domain $\mathbb{R}$
Consider any domain element $a$
The function will square $a$, and $a^2 \geq 0$ (because no squares are negative reals)
Then $a^2 + 10 \geq 10$, so this means that $-1$ is not in the co-domain
$\therefore$ The function is not onto
You can also use a proof by contradiction by saying that:
$g(a) = -1$
$\therefore a^2 + 10 = -1$
$\therefore a^2 = -11$
Squares of a real number cannot be negative, so the function is not onto
A function is not always numbers:
Example: Favourite UNB Course : S -> C
Where S is all students and C is all courses
What would have to be true for this to be one to one or onto?:
- One to one:
- Onto:
# Relations:
A binary relation R on two sets A and B is a subset of $A \times B$
- e.g. S = all students, C = all students, s is any given student, c is any given course
- Relation: HasTaken: for (s, c) s has taken c
- Relation Aplus: for (s,c) s got A+ in c
A relation can be between the same set, for example the set of A = {John, Jane, Bill, Sue, Mary, Betty}, we can define a relation that is the relationship between who loves who $A \times A$
- e.g. (John, Jane)
A binary relation $R \subseteq A \times A$ is also called an equivalence relation if the following conditions hold:
- reflexive: $\forall a \in A, (a,a) \in R$
- symmetric: $\forall a,b \in A, (a,b) \in R \rightarrow (b,a) \in R$
- transitive: $\forall a,b,c \in A, [(a,b) \in R \wedge (b,c) \in R] \rightarrow (a,c) \in R$
Example:
$G = \{(x,y) | x \in \mathbb{R}, y \in \mathbb{R}, x > y\}$
Is G reflexive? (Is is true that every real number is relation to itself)
No, because we can show that $(5,5) \notin \mathbb{R}$ because $5 \ngtr 5$
Is G symmetric? (Is it the case that whenever $(a,b) \in G, (b,a)$ will also be in G)
No, for example $(10,3) \in G$ because $10 > 3$ but $(3, 10) \notin G$ because $3 \ngtr 10$
Is G transitive? (Is it true that whenever (a,b) and (b,c) are in G, (a,c) will also be in G)
Yes, let a,b,c be any real numbers where $(a,b) \in G$ and $(b,c) \in G$
Since $(a,b) \in G$, we know that $a > b$
Since $(b,c) \in G$, we know that $b > c$
Then $a > b > c$, so that means that $a > c$, so also $(a,c) \in G$