TO REGULAR EXPRESSIONS

Similar documents
Lexical Analysis: Constructing a Scanner from Regular Expressions

Definition of Regular Expression

Fig.25: the Role of LEX

Dr. D.M. Akbar Hussain

Finite Automata. Lecture 4 Sections Robb T. Koether. Hampden-Sydney College. Wed, Jan 21, 2015

CSCE 531, Spring 2017, Midterm Exam Answer Key

In the last lecture, we discussed how valid tokens may be specified by regular expressions.

ΕΠΛ323 - Θεωρία και Πρακτική Μεταγλωττιστών

Deterministic. Finite Automata. And Regular Languages. Fall 2018 Costas Busch - RPI 1

Theory of Computation CSE 105

CS321 Languages and Compiler Design I. Winter 2012 Lecture 5

Lexical analysis, scanners. Construction of a scanner

Languages. L((a (b)(c))*) = { ε,a,bc,aa,abc,bca,... } εw = wε = w. εabba = abbaε = abba. (a (b)(c)) *

ASTs, Regex, Parsing, and Pretty Printing

Reducing a DFA to a Minimal DFA

Assignment 4. Due 09/18/17

CS143 Handout 07 Summer 2011 June 24 th, 2011 Written Set 1: Lexical Analysis

ΕΠΛ323 - Θεωρία και Πρακτική Μεταγλωττιστών. Lecture 3b Lexical Analysis Elias Athanasopoulos

CS 340, Fall 2014 Dec 11 th /13 th Final Exam Note: in all questions, the special symbol ɛ (epsilon) is used to indicate the empty string.

CS 321 Programming Languages and Compilers. Bottom Up Parsing

CS 432 Fall Mike Lam, Professor a (bc)* Regular Expressions and Finite Automata

Topic 2: Lexing and Flexing

CSCI 3130: Formal Languages and Automata Theory Lecture 12 The Chinese University of Hong Kong, Fall 2011

this grammar generates the following language: Because this symbol will also be used in a later step, it receives the

CMPSC 470: Compiler Construction

CSE 401 Midterm Exam 11/5/10 Sample Solution

COMPUTER SCIENCE 123. Foundations of Computer Science. 6. Tuples

Compilers Spring 2013 PRACTICE Midterm Exam

CSc 453. Compilers and Systems Software. 4 : Lexical Analysis II. Department of Computer Science University of Arizona

CS412/413. Introduction to Compilers Tim Teitelbaum. Lecture 4: Lexical Analyzers 28 Jan 08

Quiz2 45mins. Personal Number: Problem 1. (20pts) Here is an Table of Perl Regular Ex

Applied Databases. Sebastian Maneth. Lecture 13 Online Pattern Matching on Strings. University of Edinburgh - February 29th, 2016

Implementing Automata. CSc 453. Compilers and Systems Software. 4 : Lexical Analysis II. Department of Computer Science University of Arizona

Lecture T1: Pattern Matching

Should be done. Do Soon. Structure of a Typical Compiler. Plan for Today. Lab hours and Office hours. Quiz 1 is due tonight, was posted Tuesday night

Lecture T4: Pattern Matching

Solving Problems by Searching. CS 486/686: Introduction to Artificial Intelligence

2 Computing all Intersections of a Set of Segments Line Segment Intersection

acronyms possibly used in this test: CFG :acontext free grammar CFSM :acharacteristic finite state machine DFA :adeterministic finite automata

2014 Haskell January Test Regular Expressions and Finite Automata

Solving Problems by Searching. CS 486/686: Introduction to Artificial Intelligence Winter 2016

CS 241 Week 4 Tutorial Solutions

Ma/CS 6b Class 1: Graph Recap

COMP 423 lecture 11 Jan. 28, 2008

Example: Source Code. Lexical Analysis. The Lexical Structure. Tokens. What do we really care here? A Sample Toy Program:

Sample Midterm Solutions COMS W4115 Programming Languages and Translators Monday, October 12, 2009

Presentation Martin Randers

Ma/CS 6b Class 1: Graph Recap

Homework. Context Free Languages III. Languages. Plan for today. Context Free Languages. CFLs and Regular Languages. Homework #5 (due 10/22)

CS201 Discussion 10 DRAWTREE + TRIES

The Fundamental Theorem of Calculus

Slides for Data Mining by I. H. Witten and E. Frank

ECE 468/573 Midterm 1 September 28, 2012

Midterm 2 Sample solution

CS 340, Fall 2016 Sep 29th Exam 1 Note: in all questions, the special symbol ɛ (epsilon) is used to indicate the empty string.

Midterm I Solutions CS164, Spring 2006

Chapter44. Polygons and solids. Contents: A Polygons B Triangles C Quadrilaterals D Solids E Constructing solids

Fall 2018 Midterm 1 October 11, ˆ You may not ask questions about the exam except for language clarifications.

Lexical Analysis. Amitabha Sanyal. ( as) Department of Computer Science and Engineering, Indian Institute of Technology, Bombay

Section 3.1: Sequences and Series

Unit 5 Vocabulary. A function is a special relationship where each input has a single output.

PARALLEL AND DISTRIBUTED COMPUTING

Problem Set 2 Fall 16 Due: Wednesday, September 21th, in class, before class begins.

CS 241. Fall 2017 Midterm Review Solutions. October 24, Bits and Bytes 1. 3 MIPS Assembler 6. 4 Regular Languages 7.

Scanner Termination. Multi Character Lookahead. to its physical end. Most parsers require an end of file token. Lex and Jlex automatically create an

Regular Expressions and Automata using Miranda

UNIVERSITY OF EDINBURGH COLLEGE OF SCIENCE AND ENGINEERING SCHOOL OF INFORMATICS INFORMATICS 1 COMPUTATION & LOGIC INSTRUCTIONS TO CANDIDATES

What are suffix trees?

CS 430 Spring Mike Lam, Professor. Parsing

Mid-term exam. Scores. Fall term 2012 KAIST EE209 Programming Structures for EE. Thursday Oct 25, Student's name: Student ID:

Systems I. Logic Design I. Topics Digital logic Logic gates Simple combinational logic circuits

CMSC 331 First Midterm Exam

Context-Free Grammars

PPS: User Manual. Krishnendu Chatterjee, Martin Chmelik, Raghav Gupta, and Ayush Kanodia

Operator Precedence. Java CUP. E E + T T T * P P P id id id. Does a+b*c mean (a+b)*c or

CMPT 379 Compilers. Lexical Analysis

Migrating vrealize Automation to 7.3 or March 2018 vrealize Automation 7.3

LR Parsing, Part 2. Constructing Parse Tables. Need to Automatically Construct LR Parse Tables: Action and GOTO Table

SERIES. Patterns and Algebra OUT. Name

CS2204 DIGITAL LOGIC & STATE MACHINE DESIGN SPRING 2014

LING/C SC/PSYC 438/538. Lecture 21 Sandiway Fong

Mathematics Background

COS 333: Advanced Programming Techniques

CS481: Bioinformatics Algorithms

NOTES. Figure 1 illustrates typical hardware component connections required when using the JCM ICB Asset Ticket Generator software application.

Regular Expression Matching with Multi-Strings and Intervals. Philip Bille Mikkel Thorup

Context-Free Grammars

Epson Projector Content Manager Operation Guide

Suffix trees, suffix arrays, BWT

INTRODUCTION TO SIMPLICIAL COMPLEXES

Fig.1. Let a source of monochromatic light be incident on a slit of finite width a, as shown in Fig. 1.

COS 333: Advanced Programming Techniques

Fall Compiler Principles Lecture 1: Lexical Analysis. Roman Manevich Ben-Gurion University of the Negev

Compiler Construction D7011E

Distributed Systems Principles and Paradigms

If you are at the university, either physically or via the VPN, you can download the chapters of this book as PDFs.

CSEP 573 Artificial Intelligence Winter 2016

McAfee Network Security Platform

1.5 Extrema and the Mean Value Theorem

Simplifying Algebra. Simplifying Algebra. Curriculum Ready.

Transcription:

Suject :- Computer Science Course Nme :- Theory Of Computtion DA TO REGULAR EXPRESSIONS Report Sumitted y:- Ajy Singh Meen 07000505 jysmeen@cse.iit.c.in

BASIC DEINITIONS DA:- A finite stte mchine where for ech pir of stte nd input symol there is one nd only one trnsition to next stte. DAs recognize the set of regulr lnguges nd no other lnguges. Regulr Expressions:- Regulr expressions consist of constnts nd opertors tht denote sets of strings nd opertions over these sets, respectively. A regulr expression represents "pttern" strings tht mtch the pttern re in the lnguge, strings tht do not mtch the pttern re not in the lnguge. All strings contining exctly one on = {0, } *. 0 0 Strting Sttet Regulr Expressions for this lnguge over is :- 0 * 0 * Non-inl Stte inl Stte

AIM & PROCEDURE The im of this nimtion is to clrify the concepts of DA to Regulr Expressions y illustrting some exmples. In this nimtion we will explin this topic y first giving its rief introduction through its definition nd then some nottions of Automt Theory. In this nimtion we will hve two exmples for explining this topic. In the first exmple we will ply with less numer of sttes simply displying i circles for the sttes t nd lines connecting them nd then ccording to the lgorithm we will convert tht DA into regulr expression. In the second exmple we will hndle with more numer of sttes. And do the required nimtion like first exmple. The nimtion will show the construction of simple sttes reducing digrms nd chnge in their trnsction nd strings over the trnsction hppening. And inlly we will get our Regulr Expression for the given DA.

Prolem Sttementt t Input:- A figure with given numer of non-finl sttes nd finl sttes. Output:- A regulr expression for the given DA. Regulr Expression contining comintions of some finite symols over.

Prolem :- Input :-Lnguge over ={0,} *,such tht every string is multiple of 3 in inry. Output:- A Regulr Expression representing the ove DA. Solution:- DA representing the ove prolem:- Where 0,,2 02in circles 0 represents the 0 reminders. 0 2 0 Step :- Add new initil stte (S) nd new finl stte () with - trnsition:- New-Strting 0 Stte S 0 0 2 New-inl Stte 0

Step 2:- Remove the circle with reminder 2. 0 Now circles with 0, doesn t represent S 0 0 * 0 reminders here. inl Step:- After Removing ll the circles with 0,. S Strting Stte (0 + (0 * 0)) * inl Stte So, the finl Regulr Expression for the ove DA is :- * * (0 + (0 * 0)) *

Prolem 2:- Input :-Lnguge over ={,} *,such tht every string strts nd ends with the sme symol. Output:- A Regulr Expression representing the ove DA. Solution:- DA representing the ove prolem:- Strting Stte q0 q2 q q3 q4

Step :- Add new initil stte (S) nd new finl stte () with - trnsition:- q q3 S q0 Strting q2 q4 Stte Step 2:- Remove the circle nmed s q3 nd q4. S Strting Stte q0 q ( + * ) * ( ) ( + * ) * q2 ( )

Step 3:- Remove the circle nmed s q0. Strting ti Stte S q ( + * ) * q2 ( + * ) * inl Step:- After Removing ll the circles nmed s q,q2. S [ + ( + * ) * + ( + * ) * ] So, the finl Regulr Expression for the ove DA is :- * * * * [ + ( + * ) * + ( + * ) * ]

urther Interctivity ti it We will rrnge more nd more questions for the user y which he or she cn do some questions sed on this topic. or this nimtion user input is very-very hrd so I m voiding it. We will show the formtion of reduced digrms/figure ccording to the lgorithm in the nimtion. We will show how the lgorithm works in the nimtion prt nd how the no of sttes chnges when they re removed or dded in the nimtion.

Review Questions Output is the DA listed s regulr expressions. (ns:- miniml) A DA represents finite stte mchine tht recognizes. (ns:- Regulr Expression) Wht is the regulr expression for the given DA of lnguge contining even numer of :- q0 q. -----------------------------------------[ns :- ( + * ) * ] Regulr Expression for this DA is :- q0 q q2.-----------------------------[ns:- (() * )]

urther Reding Links http://www.cs.geneseo.edu/~ldwin/csci342/fll2006/099df2re.html http://www.cs.uiuc.edu/clss/f05/cs475/lectures/new/lec05.pdf http://www.mec.c.in/resources/notes/notes/utomt/trnsforming%20s A%20into%20RE.htm http://en.wikipedi.org/wiki/deterministic_finite stte_mchine http://en.wikipedi.org/wiki/regulr_expressions expressions

CREDITS