# ContextFree Languages 1 Regular Languages 2 ContextFree Languages

- Slides: 43

Context-Free Languages 1

Regular Languages 2

Context-Free Languages Regular Languages 3

Context-Free Languages Context-Free Grammars Pushdown Automata stack automaton 4

Context-Free Grammars 5

A context-free grammar G: 6

A context-free grammar G: 8

9

A context-free grammar G: 10

Definition of Context-Free Grammars Any grammar G=(V, T, S, P) V: variables T: terminal symbols S: start variable P: production rules of the form : string of variables and terminals 12

Definition of Context-Free Languages A language L is context-free if and only if there is a grammar G with L = L(G) 13

Derivation Order Leftmost derivation: Rightmost derivation: 14

Derivation Trees 15

16

17

18

19

Derivation Tree 20

sentence Derivation Tree yield 21

Partial Derivation Trees Partial derivation tree 22

sentential form Partial derivation tree yield 23

Often, derivation order doesn’t matter Same Derivation Tree 24

Ambiguity 25

26

27

28

The grammar is ambiguous: string has two derivation trees 29

The grammar is ambiguous: string has two leftmost derivations 30

In general: A context-free grammar if some string is ambiguous has: two or more derivation trees 31

In other words: A context-free grammar if some string is ambiguous has: two or more leftmost derivations rightmost 32

Why do we care about ambiguity? take 33

34

35

The right solution: 36

Therefore: Ambiguity is bad for programming languages We want to remove the ambiguity 37

We fix the ambiguous grammar: New grammar: 38

39

Unique derivation tree 40

The grammar Is not ambiguous 41

Inherent Ambiguity Some context free languages have only ambiguous grammars Example: 42

The string has two derivation trees 43

- Regular grammars generate regular languages.
- Inverse homomorphism in regular languages
- Regular and irregular languages
- Pumping lemma non regular languages examples
- Decision properties of regular languages
- Proof by contradiction examples
- Decision properties of regular languages
- Decision properties of regular languages
- Right linear grammar
- Decision properties of regular language
- Properties of regular languages
- Insulina regular
- Como se clasifican los teselados
- Notasi ekspresi regular
- Positive sentences
- Prisma regular
- Vertices
- Blank verse
- The diagram shows part of a regular polygon
- Tessellation using 2 regular polygons
- Yellow connective tissue
- Karate chop verbs spanish
- Regular expression
- 10 verbos regulares
- Insulina regular conforme dextro
- Present tense of blow
- Irregular solids
- Regular comparative adjectives
- Irregular verbs principal parts
- The trampoline shown is shaped like a regular dodecagon
- Geometry area of regular polygons
- Five regular solids
- Perl6 失敗
- Area
- Concave polygon
- Projection of solids square prism
- Developing formulas for circles and regular polygons
- Symmetry of regular octagon
- Cylinder isometric view
- Each reflex interior angle of a regular pentagram
- área de um octaedro regular
- Surface area of tetrahedron
- Lesson 11-4 areas of regular polygons
- Preterite ir and ser