From 1f74368dc8ce378a1b1295e8ba15bcf8fced477a Mon Sep 17 00:00:00 2001 From: John Sarkela Date: Fri, 19 Sep 2025 11:54:51 -0400 Subject: [PATCH] add state machine and reg ex lecture --- lectures/index.md | 3 +- lectures/stateMachinesAndRegularExprs.md | 35 ++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 lectures/stateMachinesAndRegularExprs.md diff --git a/lectures/index.md b/lectures/index.md index fe2704b..b6eb8ac 100644 --- a/lectures/index.md +++ b/lectures/index.md @@ -2,4 +2,5 @@ * [semiotics](./semiotics.md) * [languages and machines](./chomsky.md) * [all about names](./names.md) -* [lambda calculus](./lambda.md) \ No newline at end of file +* [lambda calculus](./lambda.md) +* [state machines and regular expression](./stateMachinesAndRegularExprs.md) diff --git a/lectures/stateMachinesAndRegularExprs.md b/lectures/stateMachinesAndRegularExprs.md new file mode 100644 index 0000000..f163293 --- /dev/null +++ b/lectures/stateMachinesAndRegularExprs.md @@ -0,0 +1,35 @@ +# Finite State Machines +A **deterministic finite automata** is sometimes called a **DFA**. The DFA named, A, is defined mathematically with a 5-tuple. + +A = (Q, Σ, δ, q0, F) + +* Q is a finite set of states +* Σ is a finite set of symbols (an alphabet) +* δ is a transition function δ:QxΣ->Q +* q0 is the start state +* F is a set of final or accepting states F ⊆ Q + +**Σ*** denotes the set of all finite strings that can be made using letters from Σ. +The empty string is denoted **ε**. + +The δ function has a natural extension to a function δ̂:QxΣ*->Q. We call this function **delta-hat**. It is defined to be the result of iteratively applying each letter in the second argument to produce the next state. + +δ̂(q, 123) = δ(δ(δ(q0, 1), 2), 3) + +We can define the **language of a state machine** A in the following way: + +L(A) = {w∈Σ* | δ̂(q0, w)∈F} + +In plain English, The language of A is the set of all words from the alphabet Σ that will cause the delta-hat function to return a final state when beginning at the start state. + +# Regular Expressions +The language of finite state machines are the regular expressions. There are five rules the define a regular expression. + +* A symbol taken from the alphabet is a regular expression. +* If E is a regular expression, then (E) is also a regular expression with the same language. L(E) = L((E)). +* If A and B are regular expressions, then A+B is a regular expression. L(A+B) == L(A) ∪ L(B) +* If A and B are regular expressions, then AB is a regular expression. (concatenation A followed by B) L(AB) = L(A) X L(B) +* If A is a regular expression, then A* is a regular expression. (closure zero or more occurrences of A) +The precedence of the last three operators are in order from lowest precedence, to highest. + +