Differences

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

Link to this comparison view

Next revision
Previous revision
lfa:prop [2017/11/01 16:15]
pdmatei created
lfa:prop [2019/10/31 13:56] (current)
pdmatei
Line 11: Line 11:
 Consider the following NFA built (with respect to $math[M_a]) to accept words of the above language: Consider the following NFA built (with respect to $math[M_a]) to accept words of the above language:
  
-{{:lfa:arithmetic_fin.jpg?600|}}+{{:lfa:parenexpr.jpg?600|}}
  
 One can easily observe that the above automaton can only accept words of the following forms: One can easily observe that the above automaton can only accept words of the following forms:
Line 25: Line 25:
 **However**,​ it is **not possible** to add a **finite** number of states (and transitions) which can accommodate for an **//​arbitrary//​ finite** ​ number of parenthesis nestings. (e.g. ''​1 + (2 + ...  ))))''​). Each automaton which we know how to build, can only accept a **//​unique//​ finite** number of nestings, hence it can only describe arithmetic expressions with parenthesis nesting of up to some $math[k\in\mathbb{N}]. **However**,​ it is **not possible** to add a **finite** number of states (and transitions) which can accommodate for an **//​arbitrary//​ finite** ​ number of parenthesis nestings. (e.g. ''​1 + (2 + ...  ))))''​). Each automaton which we know how to build, can only accept a **//​unique//​ finite** number of nestings, hence it can only describe arithmetic expressions with parenthesis nesting of up to some $math[k\in\mathbb{N}].
  
-This happens because our language **is not regular**.+This happens because our language **is not reg 
 +ular**.
  
 ===== The pumping lemma ===== ===== The pumping lemma =====
Line 37: Line 38:
  
 $theorem[Pumping Lemma] $theorem[Pumping Lemma]
-Let $math[L] be a regular language. Then there exists $math[n] (dependent on $math[L]) such that for every word $math[w\in L] satisfying ​$math[|w|\leq ​n] has the following form:+Let $math[L] be a regular language. Then there exists $math[n] (dependent on $math[L]) such that for every word $math[w\in L] of length larger than $math[n] has the following form:
   * $math[w = xyz] where   * $math[w = xyz] where
   * $math[\mid xy \mid \leq n]   * $math[\mid xy \mid \leq n]
   * $math[y \neq \epsilon]   * $math[y \neq \epsilon]
-  * for all $math[k\leq 0], we have $math[xy^kz \in L]+  * for all $math[k ​0], we have $math[xy^kz \in L]
 $end $end
  
Line 50: Line 51:
   * a prefix $math[x];   * a prefix $math[x];
   * a **non-empty** word $math[y] which may repeat zero-or-more times   * a **non-empty** word $math[y] which may repeat zero-or-more times
-  * a suffix $math[z] which may be finite.+  * a suffix $math[z] which may be  
 +finite.
  
 Note that arithmetic expressions cannot be broken-down in this way. Note that arithmetic expressions cannot be broken-down in this way.
Line 123: Line 125:
  
 $proof $proof
-Let $math[M_A = (K,​\Sigma,​\delta,​q_0,​F)] be a DFA which accepts $math[A]. We build the DFA $math[\overline{M_A} = (K,​\Sigma,​\delta,​q_0,​K\setminus F)]. $math[\overline{M_A}] only differs from $math[M_A] in the accepting (or final) states: each **final** state in $math[M_A] is **non-final** in $math[\overline{M_A}] and vice-versa. It follows immediately that, for all words $math[w], w is accepted by $math[M_A] iff $math[w] is not accepted by $math[\overline{M_A}]. Thus, $math[M_A] accepts any word not in $math[A], i.e. the language $math[\overline{A}].+Let $math[M_A = (K,​\Sigma,​\delta,​q_0,​F)] be a DFA which accepts $math[A]. We build the DFA $math[\overline{M_A} = (K,​\Sigma,​\delta,​q_0,​K\setminus F)]. $math[\overline{M_A}] only differs from $math[M_A] in the accepting (or final) states: each **final** state in $math[M_A] is **non-final** in $math[\overline{M_A}] and vice-versa. It follows immediately that, for 
 +ll words $math[w], w is accepted by $math[M_A] iff $math[w] is not accepted by $math[\overline{M_A}]. Thus, $math[M_A] accepts any word not in $math[A], i.e. the language $math[\overline{A}].
 $end $end
  
Line 136: Line 139:
 $end $end
  
-An alternative and more useful proof is to construct, starting from DFAs $math[M_A=(K_A,​\Sigma,​q_A,​F_A)] and $math[M_B==(K_B,​\Sigma,​q_B,​F_B)] which accept languages $math[A] and $math[B], respectively,​ a DFA for $math[A\cap B]. The construction is called **product automaton** (written $math[M_A\times M_B]), and is as follows:+An alternative and more useful proof is to construct, starting from DFAs $math[M_A=(K_A,​\Sigma,​q_A,​F_A)] and $math[M_B=(K_B,​\Sigma,​q_B,​F_B)] which accept languages $math[A] and $math[B], respectively,​ a DFA for $math[A\cap B]. The construction is called **product automaton** (written $math[M_A\times M_B]), and is as follows:
  
   * the set of states is $math[K_A\times K_B] - each state in the product automaton is a pair of states;   * the set of states is $math[K_A\times K_B] - each state in the product automaton is a pair of states;
Line 143: Line 146:
   * the set of final states is $math[F_A \times F_B]   * the set of final states is $math[F_A \times F_B]
  
-It is easy to prove by induction that for each word $math[w] such that $math[(q_A,​w)\vdash_{M_A}^*(p,​\epsilon)] and +It is easy to prove by induction that for each word $math[w] such that $math[(q_A,​w)\ 
 +vdash_{M_A}^*(p,​\epsilon)] and 
 $math[(q_B,​w)\vdash_{M_B}^*(r,​\epsilon)],​ with $math[p\in F_A] and $math[r\in F_B], we also have in the product automaton $math[((q_A,​q_B),​w)\vdash^*_{M_{A\times B}}(p,​r),​\epsilon]. $math[(q_B,​w)\vdash_{M_B}^*(r,​\epsilon)],​ with $math[p\in F_A] and $math[r\in F_B], we also have in the product automaton $math[((q_A,​q_B),​w)\vdash^*_{M_{A\times B}}(p,​r),​\epsilon].