Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS-5800 Theory of Computation II PROJECT PRESENTATION By Quincy Campbell & Sandeep Ravikanti.

Similar presentations


Presentation on theme: "CS-5800 Theory of Computation II PROJECT PRESENTATION By Quincy Campbell & Sandeep Ravikanti."— Presentation transcript:

1 CS-5800 Theory of Computation II PROJECT PRESENTATION By Quincy Campbell & Sandeep Ravikanti

2 Text Searching Conversion of Regular Expression to DFA and Use for Text Searching.

3 Introduction Text Searching, an application of Finite State automata concepts. A regular expression which is initially defined is parsed to DFA (Deterministic Finite Automata). The obtained DFA is transformed to a transition table. Thus the Scenario of Searching text is implemented with the help transition table.

4 Regular Expression: Regular expressions consist of constants and operator symbols that denote sets of strings and operations over these sets, which is therefore referred to as a regular set or language. Let ∑ be an alphabet. The regular expression over ∑ are defined recursively Basis :Ø, λ and a,for every a €∑, are regular expressions over ∑. Recursive Step: Let u and v be regular expressions over ∑. (u U v) (uv) (u * ) These Expressions are regular expressions over ∑. Closure: u is a regular expression over ∑ only if it can be obtained from the basis elements by a finite number of applications of recursive step.

5 Deterministic Finite Automata: A deterministic finite automata M is a quintuple, (Q, Σ, δ, q 0, F), consisting of a finite set of states (Q) a finite set of input symbols called the alphabet (Σ) a transition function (δ : Q × Σ → Q) a start state (q 0 ∈ Q) a set of accept states (F ⊆ Q)

6 Text searching using a “*” Kleen Closure: Input String : (ab)* Output :Final State are “2”,”0” in transition table: Strings that can be obtained from the given expression { λ,ab, abab, ababab……etc.….}

7 Kleen closure: Input String : a* Output :Final State are “2”,”0” in transition table: Strings that can be obtained from the given expression { λ,ab, abab, ababab……etc.….}

8 Union “(a)+”: Input: Union Closure. Of a+” Output: Final States of “1” with transitions from a  a

9 Regular Expression With Parenthesis, Kleen Closure And Union Closure Input: ((ab)*(cd)+) with String “ When hug” Output: Final States would be “4” with No Matches for given String for searching.

10 Issues: Limitations of accessibility in handling transitions Using of –closures operation for the Union operation is necessary. An example for the expression which doesn’t work…

11 New Approach Based on the limitations we had in the previous approach, we designed Text Searching with the Implementation of Thompson’s algorithm. Parsing of regular expression to NFA- Non Deterministic Finite Automata is done with the Thompson’s algorithm.The obtained NFA is converted DFA (Deterministic Finite Automata) with Subset Construction Algorithm. The generated DFA is formed into transition table and used for text Searching.

12 THOMPSON’S ALGORITHM The simplest method to convert a regular expression to a NFA is Thompson's Construction, also known as Thompson's Algorithm. Roughly speaking this works by reducing the regular expression to its smallest constituent regular expressions, converting these to NFA and then joining these NFA together. Derives a nondeterministic finite automata (NFA) from any regular expression by splitting it into its constituent sub expressions, from which the NFA will be constructed using a set of rules

13 Rules of Thompson’s Algorithm For a regular expression of a single symbol such as “b” resultant NFA would be as follows:

14 For Union of regular expression “a|b:”

15 For Kleen Star “(a|b)*”

16 Final NFA: The NFA obtained after the application of rules of Thompson’s algorithm

17 SUBSET CONSTRUCTION ALGORITHM: 1.Create the start state of the DFA by taking the Є-closure of the start state of the NFA. 2.Perform the following for the new DFA state: For each possible input symbol: 1.Apply move to the newly-created state and the input symbol; this will return a set of states. 2.Apply the Є -closure to this set of states, possibly resulting in a new set. 3.This set of NFA states will be a single state in the DFA. 4.Each time we generate a new DFA state, we must apply step 2 to it. The process is complete when applying step 2 does not yield any new states. 5.The finish states of the DFA are those which contain any of the finish states of the NFA. Example: If A, B and C are states, move({A,B,C},`a') = Move (A, ‘a’) move(B, ‘a’) move(C, ‘a’).

18

19 Given NFA Considering an Example to perform Subset Construction Algorithm to generate DFA from the given NFA

20 Creating the Start State for DFA.by removing the epsilon closures

21

22 q0 q1 q2 q3 c c c b b a c a b The Final DFA : q0={1,3,5,7,8,9}start state q1={1,2,3,5,6,8,9} q2={1,3,4,5,6,8,9} q3={10} final state

23 Sample Output

24

25

26 Conclusion: We finally conclude that the searching of text is implemented with achievement transition table of DFA for the given regular expression.

27 References : Sudkamp A Thomas., Languages and Machines.Introduction to Theory of Computer Science Hop craft, J.E., and Ullman[1979],Introduction to automata theory,Languages and Computation, Addison-Wesley, Reading,MA https://class.coursera.org/automata/lecture/preview http://en.wikipedia.org/wiki/Thompson's_construction_algo rithm

28 Thank you


Download ppt "CS-5800 Theory of Computation II PROJECT PRESENTATION By Quincy Campbell & Sandeep Ravikanti."

Similar presentations


Ads by Google