Automata and Formal Language (chapter 3) ppt

50 651 0
Automata and Formal Language (chapter 3) ppt

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Regular Language and Regular Grammar Objectives • Regular Expression and Regular Language • Regular Expression vs Regular Language • Regular Grammar Regular Expression Alphabet Σ 1. ∅, λ, a∈Σ are regular expressions (known as primitive regular expressions). 2. If r 1 and r 2 are regular expressions, so are r 1 + r 2 , r 1 . r 2 , r 1 * , and (r 1 ). Operator Precedence • parentheses • star-closure (*) • concatenation (.) • union (+) Languages Associated with Regular Expressions • Each regular expression stands for a set of strings of symbols in Σ  each regular expression represents a language, called regular language • r L(r) Example 3.1 • L(a) = {a} • L((a + b.c)* ) = {λ, a, bc, aa, abc, bca, bcbc, aaa, aabc, } • L(a + b +)  syntax error Regular Languages 1. L(∅) = {} 2. L(λ) = {λ} 3. L(a) = {a} 4. L(r 1 + r 2 ) = L(r 1 )∪L(r 2 ) 5. L(r 1 . r 2 ) = L(r 1 )L(r 2 ) 6. L(r 1 * ) = (L(r 1 )) * 7. L((r 1 )) = L(r 1 ) Example 3.2 L(a * . (a + b)) = L(a * ) L(a + b) = (L(a)) * (L(a)∪L(b)) = {λ, a, aa, aaa, }.{a, b} = {a, aa, aaa, , b, ab, aab, } Example 3.3 r = (a + b) * (a + bb) L(r) = ? Example 3.3 r = (a + b) * (a + bb) L(r) = {w| w ends with a or bb} [...]... no pair of consecutive zeros} r = (1 + 01)* (0 + λ) Equivalent Regular Expression r1 and r2 are equivalent iff L(r1) = L(r2) Example 3.8 r1 = a (b + c) r2 = a b + a c L(r1) = L(r2) = {ab, ac} Regular Expressions and Languages Given a regular expression r, there exists an NFA that accepts L(r)  L(r) is a regular language Primitive NFAs q0 q0 q0 q1 λ a NFA that accepts ∅ q1 NFA that accepts {λ} q1... NFAs (cont’d) λ M(r1) λ M(r2) λ Primitive NFAs (cont’d) NFA that accepts L(r1*) λ λ M(r1) λ λ Example 3.9 r = (a + bb)*(ba* + λ) λ a λ λ λ b λ b λ λ λ λ λ λ λ λ b λ λ λ a λ λ λ λ Languages and Regular Expressions Given a regular language L, there exists a regular expression r such that L = L(r) Generalized Transition Graph Generalized transition graph is a transition graph whose edges are labelled with... Expression r1 and r2 are equivalent iff L(r1) = L(r2) • Example 3.14 r1 = a (b + c) r2 = a b + a c L(r1) = L(r2) = {ab, ac} Grammar Recalled • Formal grammar: G = (V, T, S, P) V: finite set of variables T: finite set of terminal symbols S∈V: start variable P: finite set of productions Right-linear Grammar • Right-linear grammar: G = (V, T, S, P) Productions are of the form: A → xB A→x A, B ∈ V and x ∈... Right-linear grammar: G = (V, T, S, P) Productions are of the form: A → xB A→x A, B ∈ V and x ∈ T* Left-linear Grammar • Left-linear grammar: G = (V, T, S, P) Productions are of the form: A → Bx A→x A, B ∈ V and x ∈ T* . Regular Language and Regular Grammar Objectives • Regular Expression and Regular Language • Regular Expression vs Regular Language • Regular Grammar Regular Expression Alphabet. expressions). 2. If r 1 and r 2 are regular expressions, so are r 1 + r 2 , r 1 . r 2 , r 1 * , and (r 1 ). Operator Precedence • parentheses • star-closure (*) • concatenation (.) • union (+) Languages. Regular Expressions • Each regular expression stands for a set of strings of symbols in Σ  each regular expression represents a language, called regular language • r L(r) Example 3.1 • L(a) = {a} • L((a

Ngày đăng: 14/07/2014, 02:20

Từ khóa liên quan

Mục lục

  • Regular Language and Regular Grammar

  • Objectives

  • Regular Expression

  • Operator Precedence

  • Languages Associated with Regular Expressions

  • Example 3.1

  • Regular Languages

  • Example 3.2

  • Example 3.3

  • Slide 10

  • Example 3.5

  • Slide 12

  • Example 3.6

  • Slide 14

  • Example 3.7

  • Slide 16

  • Equivalent Regular Expression

  • Example 3.8

  • Regular Expressions and Languages

  • Primitive NFAs

Tài liệu cùng người dùng

Tài liệu liên quan