Download presentation

Presentation is loading. Please wait.

Published byRuby Girling Modified over 3 years ago

1
Erik Jonsson School of Engineering and Computer Science FEARLESS Engineering CS 4384 – 001 Automata Theory http://www.utdallas.edu/~pervin Thursday: Context-Free Languages Sections 3.1-3.3 Tuesday 2-25-14 1

2
EXAMINATION ANSWERS Regular Languages 2 ANSWERS

3
Distinguished States 3

4
4

5
Context-free Languages Chapter Three 5Tuesday 2-25

6
Definition A context-free grammar (CFG) G is a quadruple (V, Σ, R, S) where V: a set of non-terminal symbols (Variables) Σ: a set of terminals (V ∩ Σ = Ǿ) (Alphabet) R: a set of rules (R: V → (V U Σ)*) S: a start symbol (a variable)

7
How do we use rules? If R: A → B, then xAy xBy and we say that xBy is derived from xAy using rule R. If s ··· t, then we write s * t. A string x in Σ* is generated by G=(V,Σ,R,S) if S * x. L(G) = { x in Σ* | S * x}.

8
Example G = ({S}, {0,1}. {S → 0S1 | ε }, S) ε in L(G) because S ε. 01 in L(G) because S 0S1 01. 0011 in L(G) because S 0S1 00S11 0011. 0 1 in L(G) because S * 0 1. L(G) = {0 1 | n > 0} n n nn n n

9
Context-free A context-free grammar is “context-free’’ because we can use a rule R no matter what the context. E.g., (M&S P.89, Def. 3.1.2) from the rule R: A -> w, we can derive from the string uAv in one step the string uwv, no matter what the context (that is, for any strings u and v). 9

10
10

11
11

12
12 Palindromes

13
13 Any positive even number of a’s with any number of b’s anywhere

14
14

15
15

16
16

17
17

18
18

19
19

20
Parsing Expressions G = (V, ∑, R, E) V = {E, T, F} ∑= {x, 1, 2, +, *, (, )} R = { E -> E + T | T; T -> T * F | F; F -> (E) | x1 | x2 } Expressions, Terms, Factors 20

21
21

22
22Parse Tree

23
Closure Properties 23

24
24

25
25

26
26

27
Theorem For every regular language L, there exists a CFG G (in fact a Regular Grammar) such that L=L(G). 27

28
Theorem For every regular language L, there exists a CFG G such that L=L(G). Proof.Let L=L(M) for a DFA M=(Q, Σ, δ, s, F). Construct a CFG G=(V, Σ, R, S) as follows. V = Q, Σ = Σ, R = { q → ap | δ(q, a) = p } U { f → ε | f in F}, S = q0. sq1q1 f=q n x1x1 xnxn S x 1 q 1 x 1 x 2 q 2 ··· x 1 …x n f x 1 …x n 28

29
29

30
Regular Grammars 30Note: A -> a is unnecessary

31
31What's wrong with (ab)*a*?

32
32

33
Simplified and Normal Forms 33

Similar presentations

OK

1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 9 Mälardalen University 2006.

1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 9 Mälardalen University 2006.

© 2018 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on condition monitoring of transformers Free ppt on american war of independence Ppt on conservation of wildlife and natural vegetation Ppt on natural and manmade disaster Ppt on railway track design Fema ppt on cert training Ppt on channels of distribution for service Ppt on holographic technology videos Ppt on modern periodic table for class 10 Ppt on relations and functions for class 11th chemistry