Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
lfa:dfa [2018/07/23 13:18]
pdmatei
lfa:dfa [2020/10/19 15:36] (current)
pdmatei
Line 1: Line 1:
 ====== Deterministic automata ====== ====== Deterministic automata ======
- 
-===== Motivation ===== 
- 
-In the last lecture, we have shown that, for **each** regular expression $math[e], we can construct an NFA $math[M], such that $math[L(e) = L(M)]. 
- 
-While NFAs are a computational instrument for establishing acceptance, they **are not an ideal one**. Nondeterminism is difficult to translate per. se. in a programming language. 
- 
-Suppose we enforce the following restriction on the **transition relation** $math[\Delta]:​ 
- * $math[\Delta : K \times \Sigma \rightarrow K], 
- * the function $math[\Delta] is **total** (i.e. it is defined for all possible values in its input). 
- 
-Thus: 
-  * each transition must occur on a **symbol**, ​ 
-  * exactly **one** transition is possible for each state-symbol combination 
  
 $def[DFA] $def[DFA]
-A **Deterministic Finite Automata** is an NFA, where $math[\Delta : K \times \Sigma \rightarrow K] is a **total** ​function. In what follows, we write $math[\delta] instead of $math[\Delta] to refer to the transition function ​of a DFA.+A **Deterministic Finite Automata** is a tuple $math[(K,​\Sigma,​\delta,​q_0,​F)], where $math[K] is a set of states, $math[\Sigma] is the alphabet, ​$math[\Delta : K \times \Sigma \rightarrow K] is a **total** transition function. ​
 $end $end
  
Line 33: Line 19:
 We say a word $math[w] is **accepted** by a DFA $math[M] iff $math[(q_0,​w)\vdash_M^*(q,​\epsilon)] and $math[q\in F] ($math[q] is a final state). We say a word $math[w] is **accepted** by a DFA $math[M] iff $math[(q_0,​w)\vdash_M^*(q,​\epsilon)] and $math[q\in F] ($math[q] is a final state).
 $end $end
- 
-Example(s) 
  
  
 ===== NFA to DFA transformation ===== ===== NFA to DFA transformation =====
  
-Let $math[M=(K,​\Sig +Let $math[M=(K,​\Sigma, \Delta, q_0, F)] be an NFA. We assume $math[M] **does not contain transitions on words of length larger than 1**. If $math[(q,​w,​q'​)\in\Delta] for some $math[w=c_1\ldots c_n] of size 2 or more, we construct intermediary states $math[q^1, \ldots, q^{n+1}] as well as transitions $math[(q^1,​c_1,​q^2),​ \ldots (q^n,​c_n,​q^{n+1})],​ where $math[q=q^1] and $math[q'​=q^n]
-ma, \Delta, q_0, F)] be an NFA. We assume $math[M] **does not contain transitions on words of length larger than 1**. If $math[(q,​w,​q'​)\in\Delta] for some $math[w=c_1\ldots c_n] of size 2 or more, we construct intermediary states $math[q^1, \ldots, q^{n+1}] as well as transitions $math[(q^1,​c_1,​q^2),​ \ldots (q^n,​c_n,​q^{n+1})],​ where $math[q=q^1] and $math[q'​=q^n]+
  
 We denote by $math[E_M(q) = \{p\in K\mid (q,​\epsilon)\vdash^*_M (p,​\epsilon)\}],​ the **$math[\epsilon]-closure** of state $math[q]. In effect $math[E_M(q)] contains **all states reachable from $math[q] via $math[\epsilon]-transitions**. When the automaton $math[M] is understood from the context, we omit the subscript and simply write $math[E(q)]. We denote by $math[E_M(q) = \{p\in K\mid (q,​\epsilon)\vdash^*_M (p,​\epsilon)\}],​ the **$math[\epsilon]-closure** of state $math[q]. In effect $math[E_M(q)] contains **all states reachable from $math[q] via $math[\epsilon]-transitions**. When the automaton $math[M] is understood from the context, we omit the subscript and simply write $math[E(q)].
Line 55: Line 38:
  
 $prop[1] $prop[1]
-For all $math[q,p], $math[(q,​w)\vdash^*_M (p,​\epsilon)] iff $math[(E(q),​w)\vdash^*_{M'​}(P,​\epsilon)] ​with $math[p\in P].+For all $math[q,p\in K], $math[(q,​w)\vdash^*_M (p,​\epsilon)] iff $math[(E(q),​w)\vdash^*_{M'​}(P,​\epsilon)], for some $math[P] such that $math[p\in P].
 $end $end
  
Line 85: Line 68:
     - Suppose $math[(q,​\epsilon) \vdash^*_M(p,​\epsilon)].     - Suppose $math[(q,​\epsilon) \vdash^*_M(p,​\epsilon)].
     - From the definition of $math[E] and 1., we have that $math[p\in E(q)].     - From the definition of $math[E] and 1., we have that $math[p\in E(q)].
-    - Since $math[\vdash^*_{M'​}] is **reflexive**,​ we have $math[E(q)=P]. +    - Since $math[\vdash^*_{M'​}] is **reflexive**,​ we have $math[(E(q),​\epsilon)\vdash^*_{M'​}(E(q),​\epsilon)]. 
-    - From 2. and 3. we have $math[E(q),​\epsilon)\vdash^*_{M'​}(P,​\epsilon)] with $math[p\in P].+    - Therefore, ​we have $math[E(q),​\epsilon)\vdash^*_{M'​}(P,​\epsilon)] with $math[p\in P]: $math[P] is actually $math[E(q)].
  
   * //direction $math[\impliedby]://​   * //direction $math[\impliedby]://​
Line 98: Line 81:
   * //direction $math[\implies]:// ​   * //direction $math[\implies]:// ​
     - Suppose $math[(q,​wa)\vdash^*_{M} (p,​\epsilon)]. ​     - Suppose $math[(q,​wa)\vdash^*_{M} (p,​\epsilon)]. ​
-    - By the definition of $math[\vdash^*],​ we have: $math[(q,wa)\vdash^*_{M} (r_1,a) \vdash_{M} (r_2,​\epsilon)\vdash^*_{M} (p,​\epsilon)]. In words, there is a path from $math[q] which takes us to $math[r_1] by consuming $math[w], then to $math[r_2] via a **one-step** transition, then to $math[p] in zero or more $math[\epsilon]-transitions. Notice that $math[p] may be equal to $math[r_2], which is taken into account since $math[\vdash^*_{M}] is reflexive.+    - By the definition of $math[\vdash^*],​ we have: $math[(q,w)\vdash^*_{M} (r_1,a) \vdash_{M} (r_2,​\epsilon)\vdash^*_{M} (p,​\epsilon)]. In other words, there is a //path// from $math[q] which takes us to $math[r_1] by consuming $math[w], then to $math[r_2] via a **one-step** transition, then to $math[p] in zero or more $math[\epsilon]-transitions. Notice that $math[p] may be equal to $math[r_2], which is taken into account since $math[\vdash^*_{M}] is reflexive.
     - By the construction of $math[\vdash^*_{M}],​ we also have $math[(q,​w)\vdash^*_{M}(r_1,​\epsilon)]     - By the construction of $math[\vdash^*_{M}],​ we also have $math[(q,​w)\vdash^*_{M}(r_1,​\epsilon)]
     - From 3. by **induction hypothesis**,​ we have $math[(E(q),​w)\vdash^*_{M'​}(R_1,​\epsilon)] with $math[r_1 \in R_1]     - From 3. by **induction hypothesis**,​ we have $math[(E(q),​w)\vdash^*_{M'​}(R_1,​\epsilon)] with $math[r_1 \in R_1]