Presentation is loading. Please wait.

Presentation is loading. Please wait.

CIS Automata and Formal Languages – Pei Wang

Similar presentations


Presentation on theme: "CIS Automata and Formal Languages – Pei Wang"— Presentation transcript:

1 CIS 5513 - Automata and Formal Languages – Pei Wang
2. Finite Automata CIS Automata and Formal Languages – Pei Wang

2 Deterministic finite automata
A deterministic finite automaton (DFA) A = (Q, ∑, δ, q0, F) where Q is a finite set of states ∑ is the alphabet of input symbols δ: Q×∑ → Q, a transition function that specifies the state change given an input q0  Q, the start state F  Q, the final (accepting) states

3 Example of DFA Define a DFA that accepts language L = { x01y | x and y are binary strings } ∑ = {0,1} Q = {q0, q1, q2} F = {q1} δ: represented as the following transition diagram or table

4 Example of transition function

5 Extended transition function
δ is extended into δ^ (delta-hat): Q×∑* → Q δ^(q, ϵ) = q δ^(q, xa) = δ(δ^(q, x), a) Example: L = {w | w has both an even number of 0’s and an even number of 1’s}

6 Extended transition function (cont.)

7 DFA and regular language
For a given DFA A = (Q, ∑, δ, q0, F) the language it accepts is L(A) = { w | δ^(q0, w)  F } Such a L is called a regular language Kleene’s theorem: A language over an alphabet is regular if and only if it can be accepted by a finite automaton

8 Exercise 2.2.1(a) Solution:

9 More exercises Exercise 2.2.4(a): Given a DFA that accepts the set of all binary strings ending in 00 Exercise 2.2.6(a): Given a DFA that accepts the set of all binary strings that are binary numbers divisible by 5 Exercise (a): Consider the DFA defined as ({A, B}, {0, 1}, δ, A, {B}) where δ(A, 0) = A, δ(A, 1) = B, δ(B, 0) = B, δ(B, 1) = A. What language does it accept? Prove the conclusion Solutions:

10 Nondeterministic finite automata
A NFA has a transition function δ: Q×∑ → 2Q δ(q, a) is a set of states that it may be in Other interpretations: a NFA can explore accepting possibilities in parallel, or can guess about the future input Example: to accept binary strings {x01} Here δ only specifies possible ways to accept

11 Extended transition in NFA
Extending δ into δ^: Q×∑* → 2Q in an NFA: δ^(q, ε) = {q} δ^(q, xa) = δ(pi,a), where piδ^(q,x)

12 NFA and regular language
For a given NFA A = (Q, ∑, δ, q0, F) the language it accepts is L(A) = { w | δ^(q0, w) ∩ F  Ø } A word is accepted if it may lead to a final state Such an L is also a regular language A DFA can be converted into an equivalent NFA by changing each δ(p, a) = q into δ(p, a) = {q}

13 NFA to DFA For a given NFA N, a DFA D can be constructed so that L(D) = L(N) For N = (QN, ∑, δN, q0, FN), the corresponding D = (QD, ∑, δD, {q0}, FD): QD is the power set of QN δD(S, a) = δN(p, a) for each p  S FD is the set containing all subsets of QN with non-empty intersection with FN

14 Example of NFA to DFA

15 Example of NFA to DFA (cont.)
After removing the states inaccessible from the start, the resulting DFA is:

16 NFA to DFA: approaches There are two approaches in specifying QD: Exhaustively generate the power set of QN, then remove the inaccessible ones Begin from the start state, and only list the accessible states The state corresponding to empty set of states in N may be an accessible state in D

17 More examples Exercise 2.3.4(a): Give an NFA to accept the set of digit strings such that the final digit has appeared before Solutions:

18 Text search

19 NFAs with epsilon-transitions
An ε-transition in an NFA changes state with an empty string as input 2.18: A decimal number can be 12.4, 0.34, -.01, and +3., but not 123 or .

20 Epsilon-NFA An ε-NFA has δ: Q×(∑{ε}) → 2Q , i.e., it may take ε as the second argument to form “ε-transitions” The ε-closure of a state q is the set of states that can be reached from q with ε-transitions Given any ε-NFA, a DFA can be built to accept the same language like given a NFA, except that the ε-closures of state sets are used

21 Exercise 2.5.1 Solutions:


Download ppt "CIS Automata and Formal Languages – Pei Wang"

Similar presentations


Ads by Google