Download presentation
Presentation is loading. Please wait.
Published byKelly Taylor Modified over 8 years ago
1
1 Linear Grammars Grammars with at most one variable at the right side of a production Examples:
2
2 A Non-Linear Grammar Grammar :
3
3 Another Linear Grammar Grammar :
4
4 Right-Linear Grammars All productions have form: Example: or
5
5 Left-Linear Grammars All productions have form: Example: or
6
6 Regular Grammars
7
7 A regular grammar is any right-linear or left-linear grammar Examples:
8
8 Observation Regular grammars generate regular languages Examples:
9
9 Regular Grammars Generate Regular Languages
10
10 Theorem Languages Generated by Regular Grammars Regular Languages
11
11 Theorem - Part 1 Languages Generated by Regular Grammars Regular Languages Any regular grammar generates a regular language
12
12 Theorem - Part 2 Languages Generated by Regular Grammars Regular Languages Any regular language is generated by a regular grammar
13
13 Proof – Part 1 Languages Generated by Regular Grammars Regular Languages The language generated by any regular grammar is regular
14
14 The case of Right-Linear Grammars Let be a right-linear grammar We will prove: is regular Proof idea: We will construct NFA with
15
15 Grammar is right-linear Example:
16
16 Construct NFA such that every state is a grammar variable: special final state
17
17 Add edges for each production:
18
18
19
19
20
20
21
21
22
22
23
23 Grammar NFA
24
24 In General A right-linear grammar has variables: and productions: or
25
25 We construct the NFA such that: each variable corresponds to a node: special final state
26
26 For each production: we add transitions and intermediate nodes ………
27
27 For each production: we add transitions and intermediate nodes ………
28
28 Resulting NFA looks like this: It holds that:
29
29 Proof - Part 2 Languages Generated by Regular Grammars Regular Languages Any regular language is generated by some regular grammar
30
30 Proof idea: Let be the NFA with. Construct from a regular grammar such that Any regular language is generated by some regular grammar
31
31 Since is regular there is an NFA such that Example:
32
32 Convert to a right-linear grammar
33
33
34
34
35
35
36
36 In General For any transition: Add production: variableterminalvariable
37
37 For any final state: Add production:
38
38 Since is right-linear grammar is also a regular grammar with
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.