diff --git a/Formal Lang.md b/Formal Lang.md index d32cf41..2aeb819 100644 --- a/Formal Lang.md +++ b/Formal Lang.md @@ -59,4 +59,99 @@ Symbol: Member of alphabet String: Sequence of symbols -Language: Set of strings \ No newline at end of file +Language: Set of strings + +# Lecture Jan 24 + +idk he was talking about proofs in stuff I wasn't paying attention + +# Lecture Jan 27 + +## 1.1 Finite Automata + +One of the simplest models of computation is the finite state machine also called finite automata + +### Example + +Smoke Alarm + +| Sensors | Values | +| ------------ | -------------------- | +| Smoke Sensor | Smoke, No smoke | +| Button | Not pressed, pressed | + +#### State Diagram + +![[fsm-diagram.png]] + +#### State Transition Table + +| | No Smoke, unpressed | No smoke, pressed | Smoke, unpressed | Smoke, pressed | +| -------- | ------------------- | ----------------- | ---------------- | -------------- | +| No Alarm | No Alarm | No Alarm | Alarm | No Alarm | +| Alarm | No Alarm | No Alarm | Alarm | No Alarm | + + +### Formal Definition of a Finite State Machine + +A finite automaton is a 5 tuple (Q, $\Sigma$, $\delta$, q, F) where +1) Q is a finite set called the states +2) $\Sigma$ is a finite set called the _alphabet_ +3) $\delta = Q \times \Sigma \rightarrow Q$ is the transition function +4) $q \in Q$ is the start state +5) $F \subset Q$ is the set of accept state + +# Lecture Jan 29 + +__Define__ A language is called a _regular language_ if some FSM recognizes it. + +# Lecture Feb 5 + +The transition function is taking in the current state ($Q$), a symbol ($\Sigma$), and outputs a new state ($Q$). + +DFA - Determinant Finite Automata + +$\delta((q_{01}, q_2), b) = (\delta(q_{01}, b), \delta(q_2, b))$ + +# Lecture Feb 7th + +![[Pasted image 20250207085048.png]] + +^ NFA that accepts any string that has a zero three places from the end + +## Formal Definition of an NFA + +An NFA is a 5 tuple ($Q$, $\Sigma$, $\delta$, $q_o$, F) where + +1) $Q$ is a finite set of states +2) $\Sigma$ is the alphabet +3) $\delta : Q \times \Sigma_\epsilon \rightarrow P(Q)$ +4) $q_0 \in Q$ + + +# Lecture Feb 10th + +When reading a particular symbol $a$ in a state $R_1$ our DFA simulator will apply the following the transition $f^n$ + +$\delta^1(R,a) = {r \in R} | \delta(r,a)$ + +## NFA to DFA example + +![[NFA-to-DFA.png]] + +Top is an NFA, lower is DFA version of it + +# Lecture Feb 14th + +$A^\star = \{x | x \in \{0, \text{None}\}\}$ +$B^\star = \{x | x \in \{1, \text{None}\}\}$ + +Is $01 \in \{A^\star \cup B^\star \}$? No. +$\{A^\star \cup B^\star \} = \{\{0\}^\star \cup \{1\}^\star \}$ + +Is $01 \in (A \cup B)^\star$? Yes. +$= (0 \cup 1)^\star$ +$A \cup B = \{0, 1\}$ + +Empty set != empty string +$\{\varnothing\} \neq \{\epsilon\}$ diff --git a/Formal Midterm Review.md b/Formal Midterm Review.md new file mode 100644 index 0000000..bc919c7 --- /dev/null +++ b/Formal Midterm Review.md @@ -0,0 +1,40 @@ +# Pumping Lemma + +Show $L = \{0^n1^n | n=03 \text{ is not regular}\}$. +Assume $L$ is regular. + +Pick a string and some pumping length, $P$. + +$s=0^p1^p$ + +Now show that for any way to divide the string into $xyz$, pumping $s$ results in a string outside of the language. + +$xy^2z$ contains symbols out of order, and more 0s than 1s. + +# Finite State Machine + +A finite automaton is a 5 tuple (Q, $\Sigma$, $\delta$, q, F) where +1) Q is a finite set called the states +2) $\Sigma$ is a finite set called the _alphabet_ +3) $\delta = Q \times \Sigma \rightarrow Q$ is the transition function +4) $q \in Q$ is the start state +5) $F \subset Q$ is the set of accept state + +# Chomsky Normal Form + +Let $G$ be a Context Free Grammar (CFG). $G$ is in Chomsky Normal Form provided that all rules are of the form +1) $A \rightarrow AA$ +2) $A \rightarrow u$ + +The start state cannot appear on the right hand side. Cannot $A \rightarrow \epsilon$ unless start state. + +# NFA that's the union of two languages + + + +# Misc. + +$\text{REG} \in \text{CFL}$ +but +$\text{REG} \neq \text{CFL}$ + diff --git a/NFA-to-DFA.png b/NFA-to-DFA.png new file mode 100644 index 0000000..00fe6aa Binary files /dev/null and b/NFA-to-DFA.png differ diff --git a/Pasted image 20250207085048.png b/Pasted image 20250207085048.png new file mode 100644 index 0000000..3860cd1 Binary files /dev/null and b/Pasted image 20250207085048.png differ diff --git a/fsm-diagram.png b/fsm-diagram.png new file mode 100644 index 0000000..999133f Binary files /dev/null and b/fsm-diagram.png differ