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

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

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

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

CS-5800Theory of Computation II

PROJECT PRESENTATION

ByQuincy Campbell

&Sandeep Ravikanti

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

Text Searching

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

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

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.

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

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.

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

Deterministic Finite Automata:A deterministic finite automata M is a

quintuple, (Q, Σ, δ, q0, 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 (q0   ∈ Q)• a set of accept states (F   ⊆ Q)

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

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.….}

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

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.….}

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

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

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

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

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

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…

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

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.

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

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

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

Rules of Thompson’s Algorithm

For a regular expression of a single symbol such as “b” resultant NFA would be as follows:

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

For Union of regular expression “a|b:”

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

For Kleen Star “(a|b)*”

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

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

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

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’).

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

Given NFA

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

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

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

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

q0

q1

q2

q3c

c

cb

ba

c

a

b

The Final DFA :

q0={1,3,5,7,8,9}start stateq1={1,2,3,5,6,8,9} q2={1,3,4,5,6,8,9}q3={10} final state

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

Sample Output

Page 24: CS-5800 Theory of Computation II PROJECT PRESENTATION By Quincy Campbell & Sandeep Ravikanti.
Page 25: CS-5800 Theory of Computation II PROJECT PRESENTATION By Quincy Campbell & Sandeep Ravikanti.
Page 26: CS-5800 Theory of Computation II PROJECT PRESENTATION By Quincy Campbell & Sandeep Ravikanti.

Conclusion:We finally conclude that the searching of

text is implemented with achievement transition table of DFA for the given regular expression.

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

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_algorithm

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

Thank you