Lecture 3 Graph Representation for Regular Expressions

Slides:



Advertisements
Similar presentations
Part VI NP-Hardness. Lecture 23 Whats NP? Hard Problems.
Advertisements

Lecture 16 Deterministic Turing Machine (DTM) Finite Control tape head.
Lecture 24 MAS 714 Hartmut Klauck
Lecture 6 Nondeterministic Finite Automata (NFA)
1 Languages. 2 A language is a set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet: Languages.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture4: Regular Expressions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
Courtesy Costas Busch - RPI1 Non Deterministic Automata.
1 Regular Expressions. 2 Regular expressions describe regular languages Example: describes the language.
Fall 2006Costas Busch - RPI1 Deterministic Finite Automata And Regular Languages.
Fall 2004COMP 3351 Single Final State for NFA. Fall 2004COMP 3352 Any NFA can be converted to an equivalent NFA with a single final state.
1 Languages and Finite Automata or how to talk to machines...
1 Single Final State for NFAs and DFAs. 2 Observation Any Finite Automaton (NFA or DFA) can be converted to an equivalent NFA with a single final state.
Fall 2006Costas Busch - RPI1 Non-Deterministic Finite Automata.
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
Fall 2004COMP 3351 Another NFA Example. Fall 2004COMP 3352 Language accepted (redundant state)
Costas Busch - LSU1 Non-Deterministic Finite Automata.
1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final.
Regular Languages A language is regular over  if it can be built from ;, {  }, and { a } for every a 2 , using operators union ( [ ), concatenation.
Formal Language Finite set of alphabets Σ: e.g., {0, 1}, {a, b, c}, { ‘{‘, ‘}’ } Language L is a subset of strings on Σ, e.g., {00, 110, 01} a finite language,
Lecture 2UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 2.
Ding-Zhu Du Office: ECSS 3-611, M 3:15-4:30 Lecture: ECSS 2.311, MW 12:30-1:45.
Fall 2006Costas Busch - RPI1 Deterministic Finite Automaton (DFA) Input Tape “Accept” or “Reject” String Finite Automaton Output.
Decidable Questions About Regular languages 1)Membership problem: “Given a specification of known type and a string w, is w in the language specified?”
Lecture Pushdown Automata. stack stack head finite control tape head tape.
Lecture # 12. Nondeterministic Finite Automaton (NFA) Definition: An NFA is a TG with a unique start state and a property of having single letter as label.
Lecture 8 Context-Free Grammar- Cont.
Finite State Machines 1.Finite state machines with output 2.Finite state machines with no output 3.DFA 4.NDFA.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 1 Regular Languages Some slides are in courtesy.
Modeling Computation: Finite State Machines without Output
CS 154 Formal Languages and Computability February 9 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron.
Overview of Previous Lesson(s) Over View  A token is a pair consisting of a token name and an optional attribute value.  A pattern is a description.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
 2004 SDU Lecture4 Regular Expressions.  2004 SDU 2 Regular expressions A third way to view regular languages. Say that R is a regular expression if.
Finite Automata A simple model of computation. 2 Finite Automata2 Outline Deterministic finite automata (DFA) –How a DFA works.
1 Section 11.2 Finite Automata Can a machine(i.e., algorithm) recognize a regular language? Yes! Deterministic Finite Automata A deterministic finite automaton.
Akram Salah ISSR Basic Concepts Languages Grammar Automata (Automaton)
Lecture #5 Advanced Computation Theory Finite Automata.
Costas Busch - LSU1 Deterministic Finite Automata And Regular Languages.
Chapters 11 and 12 Decision Problems and Undecidability.
Fall 2004COMP 3351 Finite Automata. Fall 2004COMP 3352 Finite Automaton Input String Output String Finite Automaton.
Deterministic Finite-State Machine (or Deterministic Finite Automaton) A DFA is a 5-tuple, (S, Σ, T, s, A), consisting of: S: a finite set of states Σ:
Introduction to Automata Theory Theory of Computation Lecture 3 Tasneem Ghnaimat.
Design and Analysis of Approximation Algorithms
Theory of Computation Pushdown Automata pda Lecture #10.
Finite automate.
Languages.
Part VI NP-Hardness.
Lecture2 Regular Language
Non Deterministic Automata
PROPERTIES OF REGULAR LANGUAGES
Deterministic Finite Automata
Chapter 9 TURING MACHINES.
Chapter 2 FINITE AUTOMATA.
COSC 3340: Introduction to Theory of Computation
Deterministic Finite Automata
THEORY OF COMPUTATION Lecture One: Automata Theory Automata Theory.
Deterministic Finite Automata And Regular Languages Prof. Busch - LSU.
Non-Deterministic Finite Automata
Non-Deterministic Finite Automata
CSE322 Definition and description of finite Automata
Non Deterministic Automata
Finite Automata.
4b Lexical analysis Finite Automata
4b Lexical analysis Finite Automata
Chapter 1 Regular Language
Teori Bahasa dan Automata Lecture 10: Push Down Automata
CS6382 Theory of Computation
Presentation transcript:

Lecture 3 Graph Representation for Regular Expressions

digraph (directed graph) A digraph is a pair of sets (V, E) such that each element of E is an ordered pair of elements in V. A path is an alternative sequence of vertices and edges such that all edges are in the same direction.

string-labeled digraph A string-labeled digraph is a digraph in which each edge is labeled by a string. In a string-labeled digraph, every path is associated with a string which is obtained by concatenating all strings on the path. This string is called the label of the path.

G(r) For each regular expression r, we can construct a digraph G(r) with edges labeled by symbols and ε as follows. If r=Φ, then If r≠Φ, then

Φ* ε ε

Theorem 1 G(r) has a property that a string x belongs to r if and only if x is the label of a path from the initial vertex to the final vertex. Proof is done by induction on r.

Graph Representation A graph representation of a regular expression r is a string-labeled graph with an initial vertex s and a final vertex f such that a string x belongs to r if and only if x is associated with a path from s to f.

Corollary 2 For any regular expression r, there exists a string-labeled digraph with two special vertices, a initial vertex s and a final vertex f, such that a string x belongs to r if and only if x is associated with a path from s to f.

Puzzle: If a regular expression r contains u ``+''s, v ``·''s, and w ``*''s, how many ε-edges does G(r) contain? Question: How to reduce the number of ε-edges?

Theorem 3 An ε-edge (u,v) in G(r) which is a unique out-edge from a nonfinal vertex u or a unique in-edge to a noninitial vertex v can be shrunk to a single vertex. (If one of u and v is the initial vertex or the final vertex, so is the resulting vertex.) Remark: Shrinking should be done one by one.

Lecture 4 Deterministic Finite Automata (DFA)

DFA Finite Control tape head

p h b e t a l a The tape is divided into finitely many cells. Each cell contains a symbol in an alphabet Σ.

a The head scans at a cell on the tape and can read a symbol on the cell. In each move, the head can move to the right cell.

The finite control has finitely many states which form a set Q The finite control has finitely many states which form a set Q. For each move, the state is changed according to the evaluation of a transition function δ : Q x Σ → Q .

a a q p δ(q, a) = p means that if the head reads symbol a and the finite control is in the state q, then the next state should be p, and the head moves one cell to the right.

s There are some special states: an initial state s and a set F of final states. Initially, the DFA is in the initial state s and the head scans the leftmost cell. The tape holds an input string.

Otherwise, the input string is rejected. x h When the head gets off the tape, the DFA stops. An input string x is accepted by the DFA if the DFA stops at a final state. Otherwise, the input string is rejected.

The DFA can be represented by M = (Q, Σ, δ, s, F) where Σ is the alphabet of input symbols. The set of all strings accepted by a DFA M is denoted by L(M). We also say that the language L(M) is accepted by M.

The transition diagram of a DFA is an alternative way to represent the DFA. For M = (Q, Σ, δ, s, F), the transition diagram of M is a symbol-labeled digraph G=(V, E) satisfying the following: V = Q (s = , f = for f \in F) E = { q p | δ(q, a) = p}. a

δ 0 1 s p s p q s q q q 1 0, 1 s p q 1 L(M) = (0+1)*00(0+1)*.

The transition diagram of the DFA M has the following properties: For every vertex q and every symbol a, there exists an edge with label a from q. For each string x, there exists exactly one path starting from the initial state s associated with x. A string x is accepted by M if and only if this path ends at a final state.