DSCI 220, 2025 W1
November 4, 2025
What’s closure?
(p,q)
p ∈ F1 or q ∈ F2p ∈ F1 and q ∈ F2L1 - L2 = \(L1\cap L2^c\)Build a DFA for the union of:
L1: contains 11 (use the machine we built)L2: ends with 00 (three states: T, T0, T00)Hint: sketch product states (S_i, T_j) and mark accept pairs for union (or).
DFA: exactly one transition for each input symbol in each state.
NFA: may have multiple choices on a symbol and \(\varepsilon\)-moves (move without consuming input).
Acceptance: a string is accepted if there exists a path that reads all characters and lands in an accept state.
Direct from a regex: Translate patterns piece-by-piece without tricky state discovery.
Local “gadgets”: Build tiny NFAs for literal, union (\(|\)), concatenation, Kleene star (\(^*\)) and wire together with \(\varepsilon\).
NFAs and DFAs have the same power!! (Kleene’s Theorem)
Build a DFA from NFA algorithmically if you need one.
^(ab|ba)*$
^(0|1)*11(0|1)*$
Task: Sketch an NFA for ^1(01|10)*0$ using only the four gadgets.
Plan: literal 1 … union(01,10) … star … literal 0.
\(0^n1^n\)
Language: \(\{\,0^n1^n : n\ge 0\,\}\) (equal 0s followed by equal 1s)
Finite-state limitation:
Assume a DFA exists that accepts \(0^n1^n\), and let \(k\) denote its number of states.
Among the \(k+1\) prefixes \(0^0, 0^1, \dots, 0^k\) two must land in the same state.
From those two prefixes, feed the same number of 1s. One string should accept, and the other should not.
A context-free grammar (CFG) has:
Notes:
Grammar:
\(S \to 0S1 \ \mid\ \varepsilon\)
Derivations:
01: \[
S \Rightarrow 0S1 \Rightarrow 01
\]000111: \[
S \Rightarrow 0S1 \Rightarrow 00S11 \Rightarrow 000S111 \Rightarrow 000111
\]Parse tree shape for 0011:
If \(L_1, L_2\) are context-free:
(Intersection with regular languages is CF; general intersection/complement are not.)
https://www.json.org/json-en.html
We ignore lexical details and focus on structure.
true | false | null{ Members } | {}, Members: Value[ Elements ] | [], ElementsExample: Is {"a":[1,2,{"b":null}]} in the language?