Grammars - PowerPoint PPT Presentation

About This Presentation
Title:

Grammars

Description:

Example: the English language. 3. 4. A derivation of 'the boy walks': 5 ... A Linear Grammar. Grammars with. at most one variable on the right side. of a production ... – PowerPoint PPT presentation

Number of Views:36
Avg rating:3.0/5.0
Slides: 34
Provided by: costas
Learn more at: http://www.cs.rpi.edu
Category:

less

Transcript and Presenter's Notes

Title: Grammars


1
Grammars

2
Grammars
  • Grammars express languages
  • Example the English language

3

4
  • A derivation of the boy walks

5
  • A derivation of a dog runs

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
Notation

Variable or Non-terminal
Terminal
Production rule
8
Another Example
  • Grammar
  • Derivation of sentence

9
  • Derivation of sentence

10
  • Other derivations

11
  • Language of the grammar

12
More Notation
  • Grammar

Set of variables
Set of terminal symbols
Start variable
Set of Production rules
13
Example
  • Grammar

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

Sentential Forms
sentence
15
  • We write
  • Instead of

16
  • In general we write
  • If

17
  • By default

18
Examples

Grammar
19
Another Example
  • Grammar G

Derivations
20

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

22
Example
  • For grammar G

Since
23
A Convenient Notation

24
Linear Grammars

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

26
A Non-Linear Grammar

Grammar
27
Another Linear Grammar
  • Grammar

28
Right-Linear Grammars
  • All productions have the form
  • Example

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

or
30
Regular Grammars

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

32
Observation
  • Regular grammars generate
  • regular languages
  • Examples

Grammar G
Grammar G
33
Theorem
  • A Language is regular
  • if and only if
  • there is a grammar such that
Write a Comment
User Comments (0)
About PowerShow.com