Languages. A language is a set of strings. String: A sequence of letters. Examples: cat, dog, house, Defined over an alphabet:

Similar documents
FABER Formal Languages, Automata. Lecture 2. Mälardalen University

Sri vidya college of engineering and technology

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I

HKN CS/ECE 374 Midterm 1 Review. Nathan Bleier and Mahir Morshed

CSE 105 THEORY OF COMPUTATION

Regular Expressions. Definitions Equivalence to Finite Automata

Great Theoretical Ideas in Computer Science. Lecture 4: Deterministic Finite Automaton (DFA), Part 2

What Is a Language? Grammars, Languages, and Machines. Strings: the Building Blocks of Languages

Unit 6. Non Regular Languages The Pumping Lemma. Reading: Sipser, chapter 1

Plan for Today and Beginning Next week (Lexical Analysis)

CS 154. Finite Automata, Nondeterminism, Regular Expressions

Finite Automata and Regular Languages (part II)

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CS 455/555: Finite automata

1.3 Regular Expressions

Closure Properties of Regular Languages. Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism

CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1)

CSE 105 Homework 1 Due: Monday October 9, Instructions. should be on each page of the submission.

Formal Languages. We ll use the English language as a running example.

CSC236 Week 10. Larry Zhang

Formal Languages. We ll use the English language as a running example.

Proofs, Strings, and Finite Automata. CS154 Chris Pollett Feb 5, 2007.

COSE312: Compilers. Lecture 2 Lexical Analysis (1)

Nondeterministic Finite Automata and Regular Expressions

1 Alphabets and Languages

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism,

Computational Models #1

CS 121, Section 2. Week of September 16, 2013

Outline. Nondetermistic Finite Automata. Transition diagrams. A finite automaton is a 5-tuple (Q, Σ,δ,q 0,F)

Theory of Computation (I) Yijia Chen Fudan University

Formal Languages, Automata and Models of Computation

Nondeterministic Finite Automata

CS243, Logic and Computation Nondeterministic finite automata

CS 154, Lecture 3: DFA NFA, Regular Expressions

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Properties of Context-Free Languages. Closure Properties Decision Properties

Computational Models - Lecture 1 1

Text Search and Closure Properties

Text Search and Closure Properties

Properties of Regular Languages. BBM Automata Theory and Formal Languages 1

Closure under the Regular Operations

Finite State Transducers

Theory of computation: initial remarks (Chapter 11)

More Properties of Regular Languages

Automata Theory. Lecture on Discussion Course of CS120. Runzhe SJTU ACM CLASS

The Pumping Lemma and Closure Properties

Regular Languages. Problem Characterize those Languages recognized by Finite Automata.

Finite Automata Part Two

Lecture 3: Nondeterministic Finite Automata

Finite Automata Part One

Uses of finite automata

T (s, xa) = T (T (s, x), a). The language recognized by M, denoted L(M), is the set of strings accepted by M. That is,

CMPSCI 250: Introduction to Computation. Lecture #22: From λ-nfa s to NFA s to DFA s David Mix Barrington 22 April 2013

CPS 220 Theory of Computation REGULAR LANGUAGES

Inf2A: Converting from NFAs to DFAs and Closure Properties

Deterministic Finite Automata (DFAs)

CSC173 Workshop: 13 Sept. Notes

CSE 105 THEORY OF COMPUTATION

Lecture 1: Finite State Automaton

Deterministic Finite Automata (DFAs)

TAFL 1 (ECS-403) Unit- II. 2.1 Regular Expression: The Operators of Regular Expressions: Building Regular Expressions

Büchi Automata and their closure properties. - Ajith S and Ankit Kumar

Finite Automata. Seungjin Choi

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata

M = (Q,Σ,δ,q 0,F) Σ is the alphabet over which the transitions are defined.

Finite Automata. Wen-Guey Tzeng Computer Science Department National Chiao Tung University

UNIT-III REGULAR LANGUAGES

Closure Properties of Context-Free Languages. Foundations of Computer Science Theory

1. Draw a parse tree for the following derivation: S C A C C A b b b b A b b b b B b b b b a A a a b b b b a b a a b b 2. Show on your parse tree u,

Automata Theory for Presburger Arithmetic Logic

Building a befer mousetrap. Transi-on Graphs. L = { abba } Building a befer mousetrap. L = { abba } L = { abba } 2/16/15

Finite Automata. BİL405 - Automata Theory and Formal Languages 1

Finite Automata Part One

Finite Automata Part One

CSE 105 THEORY OF COMPUTATION

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2017

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Equivalence of DFAs and NFAs

Chapter 3. Regular grammars

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) September,

CMPSCI 250: Introduction to Computation. Lecture #29: Proving Regular Language Identities David Mix Barrington 6 April 2012

Lecture 2: Regular Expression

Harvard CS 121 and CSCI E-207 Lecture 4: NFAs vs. DFAs, Closure Properties

DM17. Beregnelighed. Jacob Aae Mikkelsen

Regular Expressions and Language Properties

Non-deterministic Finite Automata (NFAs)

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) September,

Theory of Computation

Deterministic Finite Automata (DFAs)

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

3515ICT: Theory of Computation. Regular languages

Finite Automata and Regular languages

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Computational Models: Class 1

CMSC 330: Organization of Programming Languages. Theory of Regular Expressions Finite Automata

Regular expressions and Kleene s theorem

Fooling Sets and. Lecture 5

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

Finite Automata and Languages

September 11, Second Part of Regular Expressions Equivalence with Finite Aut

Transcription:

Languages 1

Languages A language is a set of strings String: A sequence of letters Examples: cat, dog, house, Defined over an alphaet: a,, c,, z 2

Alphaets and Strings We will use small alphaets: Strings a a u a aa v aaa aa w aa aaaaaa 3

String Operations w a a 1 2 a n aa v 1 2 m aaa Concatenation wv a a 1 2 an 1 2 m aaaaa 4

w a a 1 2 a n aaaaa Reverse w R a n a 2 a 1 aaaaa 5

w String Length a a 1 2 a n Length: w n Examples: aa 4 aa 2 a 1 6

Recursive Definition of Length For any letter: a 1 For any string wa : wa w 1 Example: aa a 1 a 11 a 111 1111 4 7

Length of Concatenation uv u v Example: u aa, u 3 v aaa, v 5 uv aaaaa 8 uv u v 3 5 8 8

Claim: Proof of Concatenation Length uv u v Proof: By induction on the length v Induction asis: v 1 From definition of length: uv u 1 u v 9

Inductive hypothesis: uv u v for v 1,2,,n Inductive step: we will prove uv u v for v n 1 10

Inductive Step v wa w n, a 1 Write, where From definition of length: uv uwa uw 1 wa w 1 From inductive hypothesis: uw u w Thus: uv u w 1 u wa u v 11

Empty String A string with no letters: Oservations: 0 w w w aa aa aa 12

Sustring of string: Sustring a susequence of consecutive characters String aa aa aa aa Sustring a aa a 13

Prefixes Prefix and Suffix aa Suffixes aa w uv a a a a prefix suffix a a aa aa 14

Another Operation n w ww w n Example: 2 aa aaaa Definition: 0 w 0 aa 15

* The * Operation : the set of all possile strings from alphaet a, *, a,, aa, a, a,, aaa, aa, 16

The + Operation : the set of all possile strings from alphaet a, except *, a,, aa, a, a,, aaa, aa, * a,, aa, a, a,, aaa, aa, 17

Language A language is any suset of * Example: a, *, a,, aa, a, a,, aaa, Languages: a, aa, aa {, aa, aa, aa, a, aaaaaa} 18

Another Example An infinite language L { a n n : n 0} a aa aaaaa L al 19

Operations on Languages The usual set operations a, a, aaaa, a a, a, aaaa, a { a, a,, aaaa} { a} a, a, aaaa, a a, aaaa Complement: L * L a, a,, aa, a,, aaa, 20

Definition: L R Reverse R { w : wl} Examples: R a, aa, aa a, aa, aa L { a n n : n 0} L R { n a n : n 0} 21

Concatenation Definition: L 1 L 2 xy 1, : x L yl 2 Example: a, a, a, aa a, aaa, a, aaa, a, aaa 22

Definition: Another Operation n L LL L n a, a, a, a, 3 aaa, aa, aa, a, aa, a, a, Special case: L 0,, aaa 0 a a 23

More Examples L n n { a : n 0} L 2 n n m m { a a : n, m 0} 2 aaaaal 24

Star-Closure (Kleene *) Definition: 0 1 L* L L L 2 Example: a, *, a,, aa, a, a,,,,, aaa aa aa a, 25

26 Positive Closure Definition: * 2 1 L L L L,,,,,,,,,,, aaa aa aa a a a aa a a

Finite Automata 27

Finite Automaton Input String Finite Automaton Output String 28

Finite Accepter Input String Finite Automaton Output Accept or Reject 29

Transition Graph Aa -Finite Accepter a a a a q0 q1 q2 3 q 5 q q4 initial state state transition final state accept 30

Initial Configuration Input String a a q 0 a a a a q1 q2 3 q 5 q q4 31

Reading the Input a a a a a a q0 q1 q2 3 q 5 q q4 32

a a a a a a q0 q1 q2 3 q 5 q q4 33

a a a a a a q0 q1 q2 3 q 5 q q4 34

a a a a a a q0 q1 q2 3 q 5 q q4 35

Input finished a a a a a a q0 q1 q2 3 q 5 q q4 Output: accept 36

Rejection a a q 0 a a a a q1 q2 3 q 5 q q4 37

a a a a a a q0 q1 q2 3 q 5 q q4 38

a a a a a a q0 q1 q2 3 q 5 q q4 39

a a a a a a q0 q1 q2 3 q 5 q q4 40

Input finished a a a a a a q0 q1 q2 3 q 5 q q4 Output: reject 41

Another Example a a a q0 1 a, q q2 42

a a a q0 1 a, q q2 43

a a a q0 1 a, q q2 44

a a a q0 1 a, q q2 45

Input finished a a a Output: accept q0 1 a, q q2 46

Rejection a a q0 1 a, q q2 47

a a q0 1 a, q q2 48

a a q0 1 a, q q2 49

a a q0 1 a, q q2 50

Input finished a a q0 1 a, q q2 Output: reject 51

Formalities Deterministic Finite Accepter (DFA) M Q,,, q0, F Q q 0 F : set of states : input alphaet : transition function : initial state : set of final states 52

Input Alphaet a a a a q0 q1 q2 3 q 5 q q4 53

Set of States Q Q q 0 1, 2, 3, 4,, q q q q q 5 a a a a q0 q1 q2 3 q 5 q q4 54

Initial State q0 q 0 a a a a q1 q2 3 q 5 q q4 55

Set of Final States F F q 4 a a a q q a 3 q0 q1 2 q 5 q 4 56

Transition Function : Q Q a a a a q0 q1 q2 3 q 5 q q4 57

q0, a q1 a a a a q0 q1 q2 3 q 5 q q4 58

q0, q5 q 0 a a a a q1 q2 3 q 5 q q4 59

3 2, q q a a a a q0 q1 q2 3 q 5 q q4 60

a q 0 q 1 q 2 q 3 q 4 q 5 q1 q5 q5 q2 q2 q3 q4 q5 q 5 q 5 Transition Function q 5 q 5 a a a a q0 q1 q2 3 q 5 q q4 61

Extended Transition Function * *: Q * Q a a a a q0 q1 q2 3 q 5 q q4 62

q0, a 2 * q a a a q q2 a q0 1 q 5 q3 q4 63

q0, aa 4 * q a a a a q0 q1 q2 3 q 5 q q4 64

q0, aaa 5 * q q 0 a a a a q1 q2 3 q 5 q q4 65

Oservation: There is a walk from with lael aaa q 0 to q 1 q0, aaa 5 * q q 0 a a a a q1 q2 3 q 5 q q4 66

Recursive Definition * q, q * q, wa ( *( q, w), a) a a a a q0 q1 q2 3 q 5 q q4 67

68 0 q 1 q 2 q 3 q 4 q a a q 5 a a 2 1 0 0 0 0,,,,,, * ),, *(, * q q a q a q a q a q

Languages Accepted y DFAs Take DFA M Definition: The language L contains all input strings accepted y M M L M M = { strings that drive to a final state} 69

M aa Example L M a a a a q0 q1 q2 3 q 5 q q4 accept 70

Another Example M, a aa L, M a a a a q0 q1 q2 3 accept accept q 5 q q4 accept 71

Formally For a DFA M Q,,, q0, F M Language accepted y : L M w : * q, w * 0 F alphaet transition initial final function state states 72

Oservation Language accepted y M : L M w : * q, w * 0 F Language rejected y : M L M w : * q, w * 0 F 73

More Examples L n M { a : n 0} a q0 1 a, q q2 accept trap state 74

L M = { all sustrings with prefix a } q a 0 q1 q2 a accept q 3 75

L M = { all strings without 001 sustring } 1 1 0 1 0 00 001 0 0 0, 1 76

Regular Languages A language a DFA L is regular if there is M L LM such that All regular languages form a language family 77

Example The language L awa: w a, * is regular: a q a 0 q2 q3 a q 4 78