Renormalize files

This commit is contained in:
2025-01-07 19:27:29 -04:00
parent 2bf7d29931
commit f34e528b5a
112 changed files with 12951 additions and 12951 deletions

View File

@ -1,49 +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
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

@ -1,52 +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:
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

@ -1,61 +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$
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$

View File

@ -1,76 +1,76 @@
Lecture Topic: Relation examples
# Relation Example 1
$R = \{(i,j) | i \in \mathbb{Z}, j \in \mathbb{Z}, i-j =5n \text{ for some integer n}\}$
e.g $(22,7) \in R$ because $22-7 = 5(3)$
e.g $(7,22) \in R$ because $7-22 = -15 = 5(-3)$
e.g $(22,9) \notin R$ because $22-9 = 13$, which is not a multiple of 5
Reflexive? Yes
For every integer a, $a-a = 0 = 5(0)$
Therefor $(a,a) \in R$ for every integer a
Symmetric? Yes
Let a, b be any integer, such that (a,b) is in the relation (can we prove that (b,a) is in relation as well?)
Since (a,b) is in the relation, $a-b = 5n$, so, $b-a = -5(n) = 5(-n)$
Note: $(b-a) = -(a-b)$
Transitive? Yes
Let a,b,c be any integers such that $(a,b) \in R$ and $(b,c) \in R$
Can we prove that $(a,c) \in R$ ?
Since $(a,b) \in R$, we know $a-b=5n$ for some $n \in \mathbb{Z}$
Since $(b,c) \in R$, we know $b-c=5p$ for some $n \in \mathbb{Z}$
Now, $(a-c) = (a-b) + (b-c) = 5n + 5p = 5(np)$
Therefore, $(a-c) \in R$
Note: This is an integer because it is the sum of integers
# Relation Example 2
$R = \{(i,j) | i \in \mathbb{R}, j \in \mathbb{R}, i + 2 > j\}$
Examples:
- $(5,2) \in R$ because $(5+2) > 2$
- $(3,4) \in R$ because $(3+2) > 4$
- $(0,7) \notin R$ because $(0+2) \ngtr 7$
Reflexive? Yes
Symmetric? No
Transitive? No
Proof: We need to find real numbers where $a,b,c$ where $(a,b) \in R$ and $(b,c) \in R$ but $(a,c) \notin R$
For example, a = 1, b = 2, c = 3
$(1,2) \in R$ because $1+2 > 2$
$(2,3) \in R$ because $2+2 > 3$
But $(1,3) \notin R$ because $(1+2) \ngtr 3$
$\therefore$ R is not transitive
# Equivalence relations
Equivalence relations have all three of these properties
Any equivalence relation R on a set A induces a partition of A
- Splits A into equivalence classes
- Each class contains elements that are related to themselves and to each other, but to nothing outside the class
So, for the above relation:
$$R = \{(i,j) | i \in \mathbb{Z}, j \in \mathbb{Z}, i-j =5n \text{ for some integer n}\}$$
This forms an equivalence relation
So for the set of all integers, this forms 5 equivalence classes:
- $..., 0, 5, 10, ...$
- $..., 1, 6, 11, ...$
- $..., 2, 7, 12, ...$
- $..., 3, 8, 13, ...$
- $..., 4, 9, 14, ...$
## Example
$A = \{-3, -2, -1, 0, 1, 2, 3\}$
$R = \{(i,j) | i \in \mathbb{A}, j \in \mathbb{A}, i^2 = j^2\}$
So the equivalence classes induced by this relation:
- -3, 3
- -2, 2
- -1, 1
Lecture Topic: Relation examples
# Relation Example 1
$R = \{(i,j) | i \in \mathbb{Z}, j \in \mathbb{Z}, i-j =5n \text{ for some integer n}\}$
e.g $(22,7) \in R$ because $22-7 = 5(3)$
e.g $(7,22) \in R$ because $7-22 = -15 = 5(-3)$
e.g $(22,9) \notin R$ because $22-9 = 13$, which is not a multiple of 5
Reflexive? Yes
For every integer a, $a-a = 0 = 5(0)$
Therefor $(a,a) \in R$ for every integer a
Symmetric? Yes
Let a, b be any integer, such that (a,b) is in the relation (can we prove that (b,a) is in relation as well?)
Since (a,b) is in the relation, $a-b = 5n$, so, $b-a = -5(n) = 5(-n)$
Note: $(b-a) = -(a-b)$
Transitive? Yes
Let a,b,c be any integers such that $(a,b) \in R$ and $(b,c) \in R$
Can we prove that $(a,c) \in R$ ?
Since $(a,b) \in R$, we know $a-b=5n$ for some $n \in \mathbb{Z}$
Since $(b,c) \in R$, we know $b-c=5p$ for some $n \in \mathbb{Z}$
Now, $(a-c) = (a-b) + (b-c) = 5n + 5p = 5(np)$
Therefore, $(a-c) \in R$
Note: This is an integer because it is the sum of integers
# Relation Example 2
$R = \{(i,j) | i \in \mathbb{R}, j \in \mathbb{R}, i + 2 > j\}$
Examples:
- $(5,2) \in R$ because $(5+2) > 2$
- $(3,4) \in R$ because $(3+2) > 4$
- $(0,7) \notin R$ because $(0+2) \ngtr 7$
Reflexive? Yes
Symmetric? No
Transitive? No
Proof: We need to find real numbers where $a,b,c$ where $(a,b) \in R$ and $(b,c) \in R$ but $(a,c) \notin R$
For example, a = 1, b = 2, c = 3
$(1,2) \in R$ because $1+2 > 2$
$(2,3) \in R$ because $2+2 > 3$
But $(1,3) \notin R$ because $(1+2) \ngtr 3$
$\therefore$ R is not transitive
# Equivalence relations
Equivalence relations have all three of these properties
Any equivalence relation R on a set A induces a partition of A
- Splits A into equivalence classes
- Each class contains elements that are related to themselves and to each other, but to nothing outside the class
So, for the above relation:
$$R = \{(i,j) | i \in \mathbb{Z}, j \in \mathbb{Z}, i-j =5n \text{ for some integer n}\}$$
This forms an equivalence relation
So for the set of all integers, this forms 5 equivalence classes:
- $..., 0, 5, 10, ...$
- $..., 1, 6, 11, ...$
- $..., 2, 7, 12, ...$
- $..., 3, 8, 13, ...$
- $..., 4, 9, 14, ...$
## Example
$A = \{-3, -2, -1, 0, 1, 2, 3\}$
$R = \{(i,j) | i \in \mathbb{A}, j \in \mathbb{A}, i^2 = j^2\}$
So the equivalence classes induced by this relation:
- -3, 3
- -2, 2
- -1, 1
- 0

View File

@ -1,52 +1,52 @@
Lecture Topic:
# Equivalence Classes
You can represent equivalence classes by writing each one as a set:
$$C_0 = \{..., -10, -5, 0, 5, 10, 15, ...\} \text{ or } \{5p | p \in \mathbb{Z}\}$$
$$C_0 = \{..., -9, -4, 1, 6, 11, 16, ...\} \text{ or } \{5p + 1| p \in \mathbb{Z}\}$$
$$\text{and so on...}$$
# Graphs
Definitions:
- For each *vertex* v, the **degree** of v is the number of edges incident on v
- A *path* is a **sequence** of vertices connected by edges
- A *cycle* is a path that **starts and ends** at the same vertex
- A *simple path* is a path that has **no repeated** vertices
- A *connected graph* contains a path between **every pair** of vertices
- A *disconnected graph* is the opposite (look at slides for real def)
# Regular Languages
A class of languages that can be processed by simple computers called **finite automata**
## Simple Example of a finite automaton
Vending machine/toll booth gate
Requires 25 cents or more to be deposited (gives no change)
Takes as input, 5 cent, 10 cent, 25 cent coins
Uses **states** to remember how much has been deposited so far
States:
- q_0 : 0 cents deposited (START STATE)
- q_5 : 5 cents
- q_10 : 10 cents
- q_15 : 15 cents
- q_20 : 20 cents
- q_25 : 25 cents (ACCEPT STATE)
We represent the input as a **string** of symbols.
- n = nickel
- d = dime
- q = quarter
Examples:
- ddn
- ndd
- dnd
- q
Not accepted examples:
- nd
- d
- $\epsilon$
## State Diagram
(not really possible without an image in obsidian)
# Finite Automata
Lecture Topic:
# Equivalence Classes
You can represent equivalence classes by writing each one as a set:
$$C_0 = \{..., -10, -5, 0, 5, 10, 15, ...\} \text{ or } \{5p | p \in \mathbb{Z}\}$$
$$C_0 = \{..., -9, -4, 1, 6, 11, 16, ...\} \text{ or } \{5p + 1| p \in \mathbb{Z}\}$$
$$\text{and so on...}$$
# Graphs
Definitions:
- For each *vertex* v, the **degree** of v is the number of edges incident on v
- A *path* is a **sequence** of vertices connected by edges
- A *cycle* is a path that **starts and ends** at the same vertex
- A *simple path* is a path that has **no repeated** vertices
- A *connected graph* contains a path between **every pair** of vertices
- A *disconnected graph* is the opposite (look at slides for real def)
# Regular Languages
A class of languages that can be processed by simple computers called **finite automata**
## Simple Example of a finite automaton
Vending machine/toll booth gate
Requires 25 cents or more to be deposited (gives no change)
Takes as input, 5 cent, 10 cent, 25 cent coins
Uses **states** to remember how much has been deposited so far
States:
- q_0 : 0 cents deposited (START STATE)
- q_5 : 5 cents
- q_10 : 10 cents
- q_15 : 15 cents
- q_20 : 20 cents
- q_25 : 25 cents (ACCEPT STATE)
We represent the input as a **string** of symbols.
- n = nickel
- d = dime
- q = quarter
Examples:
- ddn
- ndd
- dnd
- q
Not accepted examples:
- nd
- d
- $\epsilon$
## State Diagram
(not really possible without an image in obsidian)
# Finite Automata
(look at slides, didn't catch it)

View File

@ -1,85 +1,85 @@
# Finite Automata
Simple machines that take in strings (sequences of symbols) as input and recognize whether or note each input string satisfies some condition(s)
Finite automata use states to keep track of important information about symbols
## Mathematical definition of a finite automaton
$M = (Q, \sum, \delta, q, F)$
- $Q$ is a finite set of states
- $\sum$ is a finite set of input symbols called the input alphabet
- $\delta$ is the transition function
- Takes every pair consisting of a state and an input smbol and returns the next state, this tells us everything we need to know about what the machine does in one computation step
- $q \in Q$ is the start state
- $F \subseteq Q$ is the set of accept states
## Acceptance by a finite automaton
Let M be a finite automaton
Let $w = w_1, w_2, ..., w_n$ be n input string over \sum
As input string w is process by $M$, define the sequence of visited states $r_0, r_1, ..., r_n$ as follows:
- $r_0 = q$
- $\forall i = 0,1, ... n-1, r_{i+1} = \delta(r_i, w_{i+1})$
If $r_n \in F$ then $M$ accepts $w$, otherwise $M$ rejects $w$
Note: The empty string $\epsilon$ has length $0$, it is accepted by $M$ if any only if the start state is an accept state
For a given finite automaton $M$, the set of stings accepted by $M$ is the language of $M$ and is denoted $L(M)$
A language $A$ is called regular if there exists a finite automaton $M$ such that $A = L(M)$
## Example of finite automata
A finite automation $M_1$ that accepts
$$\{w \in \{0,1\}^* \ | \ n_1(w) \geq 2\}$$
(State diagram on board)
A is the start sate and C is the accept state
A -> B (On 1)
B -> C (On 1)
A -> A (On 0)
B -> B (On 0)
C -> C (On 0, 1)
A: we have seen no ones yet
B: we have seen exactly one 1
C: we have seen two ore more 1's
## Example 2 of finite automata
A finite automation $M_2$ that accepts
$$\{w \in \{0,1\}^* \ | \ n_1(w) = 2\}$$
(State diagram on board)
A is the start state and C is the accept state
A -> B (On 1)
B -> C (On 1)
C -> D (On 1)
A -> A (On 0)
B -> B (On 0)
C -> C (On 0)
D -> D (On 0, 1)
Note: D is an example of a dead state, in which you cannot escape after
## Example 3 of finite automata
A finite automation $M_3$ that accepts
$$\{w \in \{a,b\}^* \ | \ \text{w starts with abb}\}$$
(State diagram on board)
A is the start state and D is the accept state
A -> B (On a)
B -> C (On b)
C -> D (On b)
D -> D (On a, b)
A -> X (On b)
B -> X (On a)
C -> X (On a)
X -> X (On a ,b)
## Example 4 of finite automata
A finite automation $M_4$ that accepts
(Didn't catch the definition)
$$\{w \in \{0,1\}^* \ | \ n_1(w) = 2\}$$
(State diagram on board)
A is the start state and D is the accept state
(state transitions would go here)
A: the most recent symbol was 1 or we have seen no symbols
B: the last symbol was 0, but we have noon seen 010 yet
C: the last two symbols were 01, but we have not seen 010
# Finite Automata
Simple machines that take in strings (sequences of symbols) as input and recognize whether or note each input string satisfies some condition(s)
Finite automata use states to keep track of important information about symbols
## Mathematical definition of a finite automaton
$M = (Q, \sum, \delta, q, F)$
- $Q$ is a finite set of states
- $\sum$ is a finite set of input symbols called the input alphabet
- $\delta$ is the transition function
- Takes every pair consisting of a state and an input smbol and returns the next state, this tells us everything we need to know about what the machine does in one computation step
- $q \in Q$ is the start state
- $F \subseteq Q$ is the set of accept states
## Acceptance by a finite automaton
Let M be a finite automaton
Let $w = w_1, w_2, ..., w_n$ be n input string over \sum
As input string w is process by $M$, define the sequence of visited states $r_0, r_1, ..., r_n$ as follows:
- $r_0 = q$
- $\forall i = 0,1, ... n-1, r_{i+1} = \delta(r_i, w_{i+1})$
If $r_n \in F$ then $M$ accepts $w$, otherwise $M$ rejects $w$
Note: The empty string $\epsilon$ has length $0$, it is accepted by $M$ if any only if the start state is an accept state
For a given finite automaton $M$, the set of stings accepted by $M$ is the language of $M$ and is denoted $L(M)$
A language $A$ is called regular if there exists a finite automaton $M$ such that $A = L(M)$
## Example of finite automata
A finite automation $M_1$ that accepts
$$\{w \in \{0,1\}^* \ | \ n_1(w) \geq 2\}$$
(State diagram on board)
A is the start sate and C is the accept state
A -> B (On 1)
B -> C (On 1)
A -> A (On 0)
B -> B (On 0)
C -> C (On 0, 1)
A: we have seen no ones yet
B: we have seen exactly one 1
C: we have seen two ore more 1's
## Example 2 of finite automata
A finite automation $M_2$ that accepts
$$\{w \in \{0,1\}^* \ | \ n_1(w) = 2\}$$
(State diagram on board)
A is the start state and C is the accept state
A -> B (On 1)
B -> C (On 1)
C -> D (On 1)
A -> A (On 0)
B -> B (On 0)
C -> C (On 0)
D -> D (On 0, 1)
Note: D is an example of a dead state, in which you cannot escape after
## Example 3 of finite automata
A finite automation $M_3$ that accepts
$$\{w \in \{a,b\}^* \ | \ \text{w starts with abb}\}$$
(State diagram on board)
A is the start state and D is the accept state
A -> B (On a)
B -> C (On b)
C -> D (On b)
D -> D (On a, b)
A -> X (On b)
B -> X (On a)
C -> X (On a)
X -> X (On a ,b)
## Example 4 of finite automata
A finite automation $M_4$ that accepts
(Didn't catch the definition)
$$\{w \in \{0,1\}^* \ | \ n_1(w) = 2\}$$
(State diagram on board)
A is the start state and D is the accept state
(state transitions would go here)
A: the most recent symbol was 1 or we have seen no symbols
B: the last symbol was 0, but we have noon seen 010 yet
C: the last two symbols were 01, but we have not seen 010
D: we have seen the pattern 010

View File

@ -1,3 +1,3 @@
Lecture Topic: More Finite Automata
# Examples
Lots of example of finite automata, easier to look at posted slides
Lecture Topic: More Finite Automata
# Examples
Lots of example of finite automata, easier to look at posted slides

View File

@ -1,3 +1,3 @@
Lecture Topic: More FAs
Lecture Topic: More FAs
This lecture we also tried to determine the language from a visual example of a finite automata

View File

@ -1,15 +1,15 @@
Lecture Topic: Non-determinism
# So Far
All of the finite automata have been deterministic. This means that for any combination of state and input symbol there is exactly one transition defined
There are advantages to this
- Easier to trace a string through the finite automata
Also some disadvantages
- Can make it harder to design
Example on whiteboard
In a non-deterministic finite automata (NFA), there are different paths, or choices you can make, so there can be more than one, or no transition defined for a given state.
Lecture Topic: Non-determinism
# So Far
All of the finite automata have been deterministic. This means that for any combination of state and input symbol there is exactly one transition defined
There are advantages to this
- Easier to trace a string through the finite automata
Also some disadvantages
- Can make it harder to design
Example on whiteboard
In a non-deterministic finite automata (NFA), there are different paths, or choices you can make, so there can be more than one, or no transition defined for a given state.
To verify a string in a NFA, you need to follow each "choice" until a string completes, (ie, for two transitions defined, fork and check both paths)

View File

@ -1,11 +1,11 @@
Lecture Topic: More NFA
Design a state diagram for an NFA that accepts
$$L = \{w \in \{a,b,c\}^* | \text{w starts with abc, ends with aab, and contains the substring bb}\}$$
So, the first three states must be connecting a, b and c
(D) -a, b, c> (D)
(F) -a, b, c> (F)
(A) -a> (B) -b> (C) -c> (D) -b> (E) -b> (F) -a> (G) -a> (H) -b> ((I))
Lecture Topic: More NFA
Design a state diagram for an NFA that accepts
$$L = \{w \in \{a,b,c\}^* | \text{w starts with abc, ends with aab, and contains the substring bb}\}$$
So, the first three states must be connecting a, b and c
(D) -a, b, c> (D)
(F) -a, b, c> (F)
(A) -a> (B) -b> (C) -c> (D) -b> (E) -b> (F) -a> (G) -a> (H) -b> ((I))
It's important that on D and F, that b is allowed to loop, as if it did not, some valid strings would not be accepted, as it would only allow for two bs in the middle

View File

@ -1,2 +1,2 @@
Lecture Topics: NFA examples
Lecture Topics: NFA examples

View File

@ -1,17 +1,17 @@
Lecture Topic: Proofs
For any DFA, we already have an NFA, it just not happen to use any characteristics of NFAs like epsilon transitions or more/less than 1 transition per symbol per state
Suppose we have an NFA N that accepts language L
We can construct a DFA D that accepts the same language
* The DFA keeps track of all the possible states the NFA could be in after seeing any sequence of input symbols
Example in slides
Reminder: Any language that can be accepted by a FA is called a regular language
Let A and B languages, we define the regular operations, union, concatenation and star
Union: Is all the strings that are in either of the languages A or B
Concatenation: All the strings that can be formed by the concatenation of A and B
Star: Any sequence of strings formed from any combination strings in a language A
Lecture Topic: Proofs
For any DFA, we already have an NFA, it just not happen to use any characteristics of NFAs like epsilon transitions or more/less than 1 transition per symbol per state
Suppose we have an NFA N that accepts language L
We can construct a DFA D that accepts the same language
* The DFA keeps track of all the possible states the NFA could be in after seeing any sequence of input symbols
Example in slides
Reminder: Any language that can be accepted by a FA is called a regular language
Let A and B languages, we define the regular operations, union, concatenation and star
Union: Is all the strings that are in either of the languages A or B
Concatenation: All the strings that can be formed by the concatenation of A and B
Star: Any sequence of strings formed from any combination strings in a language A
Examples in slides

View File

@ -1,3 +1,3 @@
Lecture Topic: NFA to DFA proof, Regex Intro
Lecture Topic: NFA to DFA proof, Regex Intro
Look at posted notes