Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Grammars. 2 Grammars express languages Example: the English language.

Similar presentations


Presentation on theme: "1 Grammars. 2 Grammars express languages Example: the English language."— Presentation transcript:

1 1 Grammars

2 2 Grammars express languages Example: the English language

3 3

4 4 A derivation of “the boy walks”:

5 5 A derivation of “a dog runs”:

6 6 Language of the grammar: L = { “a boy runs”, “a boy walks”, “the boy runs”, “the boy walks”, “a dog runs”, “a dog walks”, “the dog runs”, “the dog walks” }

7 7 Notation Variable or Non-terminal Terminal Production rule

8 8 Another Example Grammar: Derivation of sentence :

9 9

10 10 Other derivations:

11 11 Language of the grammar

12 12 More Notation Grammar Set of variables Set of terminal symbols Start variable Set of Production rules

13 13 Example Grammar :

14 14 More Notation Sentential Form: A sentence that contains Variables and terminals Example: Sentential Formssentence

15 15 We write: Instead of:

16 16 In general we write: If:

17 17 By default:

18 18 Examples Grammar:

19 19 Another Example Grammar G: Derivations:

20 20

21 21 Language of a Grammar For a grammar with start variable

22 22 Example For grammar G: Since:

23 23 A Convenient Notation

24 24 Linear Grammars

25 25 A Linear Grammar Grammars with at most one variable on the right side of a production Examples:

26 26 A Non-Linear Grammar Grammar

27 27 Another Linear Grammar Grammar

28 28 Right-Linear Grammars All productions have the form: Example: or

29 29 Left-Linear Grammars All productions have form: Example: or

30 30 Regular Grammars

31 31 Regular Grammars Definition: A regular grammar is any right-linear or left-linear grammar Examples:

32 32 Observation Regular grammars generate regular languages Examples: Grammar G:

33 33 Theorem A Language is regular if and only if there is a grammar such that


Download ppt "1 Grammars. 2 Grammars express languages Example: the English language."

Similar presentations


Ads by Google