Presentation is loading. Please wait.

Presentation is loading. Please wait.

Prof. Busch - LSU1 Linear Grammars Grammars with at most one variable at the right side of a production Examples:

Similar presentations


Presentation on theme: "Prof. Busch - LSU1 Linear Grammars Grammars with at most one variable at the right side of a production Examples:"— Presentation transcript:

1 Prof. Busch - LSU1 Linear Grammars Grammars with at most one variable at the right side of a production Examples:

2 Prof. Busch - LSU2 A Non-Linear Grammar Grammar : Number of in string

3 Prof. Busch - LSU3 Another Linear Grammar Grammar :

4 Prof. Busch - LSU4 Right-Linear Grammars All productions have form: Example: or string of terminals

5 Prof. Busch - LSU5 Left-Linear Grammars All productions have form: Example: or string of terminals

6 Prof. Busch - LSU6 Regular Grammars

7 Prof. Busch - LSU7 Regular Grammars A regular grammar is any right-linear or left-linear grammar Examples:

8 Prof. Busch - LSU8 Observation Regular grammars generate regular languages Examples:

9 Prof. Busch - LSU9 Regular Grammars Generate Regular Languages

10 Prof. Busch - LSU10 Theorem Languages Generated by Regular Grammars Regular Languages

11 Prof. Busch - LSU11 Theorem - Part 1 Languages Generated by Regular Grammars Regular Languages Any regular grammar generates a regular language

12 Prof. Busch - LSU12 Theorem - Part 2 Languages Generated by Regular Grammars Regular Languages Any regular language is generated by a regular grammar

13 Prof. Busch - LSU13 Proof – Part 1 Languages Generated by Regular Grammars Regular Languages The language generated by any regular grammar is regular

14 Prof. Busch - LSU14 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 Prof. Busch - LSU15 Grammar is right-linear Example:

16 Prof. Busch - LSU16 Construct NFA such that every state is a grammar variable: special final state

17 Prof. Busch - LSU17 Add edges for each production:

18 Prof. Busch - LSU18

19 Prof. Busch - LSU19

20 Prof. Busch - LSU20

21 Prof. Busch - LSU21

22 Prof. Busch - LSU22

23 Prof. Busch - LSU23 Grammar NFA

24 Prof. Busch - LSU24 In General A right-linear grammar has variables: and productions: or

25 Prof. Busch - LSU25 We construct the NFA such that: each variable corresponds to a node: special final state

26 Prof. Busch - LSU26 For each production: we add transitions and intermediate nodes ………

27 Prof. Busch - LSU27 For each production: we add transitions and intermediate nodes ………

28 Prof. Busch - LSU28 Resulting NFA looks like this: It holds that:

29 Prof. Busch - LSU29 The case of Left-Linear Grammars Let be a left-linear grammar We will prove: is regular Proof idea: We will construct a right-linear grammar with

30 Prof. Busch - LSU30 Since is left-linear grammar the productions look like:

31 Prof. Busch - LSU31 Construct right-linear grammar Left linear Right linear

32 Prof. Busch - LSU32 Construct right-linear grammar Left linear Right linear

33 Prof. Busch - LSU33 It is easy to see that: Since is right-linear, we have: Regular Language Regular Language Regular Language

34 Prof. Busch - LSU34 Proof - Part 2 Languages Generated by Regular Grammars Regular Languages Any regular language is generated by some regular grammar

35 Prof. Busch - LSU35 Proof idea: Let be the NFA with. Construct from a regular grammar such that Any regular language is generated by some regular grammar

36 Prof. Busch - LSU36 Since is regular there is an NFA such that Example:

37 Prof. Busch - LSU37 Convert to a right-linear grammar

38 Prof. Busch - LSU38

39 Prof. Busch - LSU39

40 Prof. Busch - LSU40

41 Prof. Busch - LSU41 In General For any transition: Add production: variableterminalvariable

42 Prof. Busch - LSU42 For any final state: Add production:

43 Prof. Busch - LSU43 Since is right-linear grammar is also a regular grammar with


Download ppt "Prof. Busch - LSU1 Linear Grammars Grammars with at most one variable at the right side of a production Examples:"

Similar presentations


Ads by Google