Formal Languages ContextFree Languages Regular Languages 2 ContextFree
- Slides: 82
Formal Languages Context-Free Languages
Regular Languages 2
Context-Free Languages Regular Languages 3
Context-Free Languages Context-Free Grammars Pushdown Automata stack automaton 4
Context-Free Grammars 5
Grammars express languages Example: the English language 6
7
A derivation of “the dog walks”: 8
A derivation of “a cat runs”: 9
Language of the grammar: L = { “a cat runs”, “a cat walks”, “the cat runs”, “the cat walks”, “a dog runs”, “a dog walks”, “the dog runs”, “the dog walks” } 10
Notation Production Rules Variable Terminal 11
Another Example Grammar: Derivation of sentence : 12
Language? 13
Grammar: Derivation of sentence : 14
Other derivations: 15
Language of the grammar 16
More Notation Grammar Set of variables Set of terminal symbols Start variable Set of Production rules 17
Example Grammar : 18
More Notation Sentential Form: A sentence that contains variables and terminals Example: Sentential Forms sentence 19
We write: Instead of: 20
In general we write: If: 21
By default: 22
Example Grammar Derivations 23
Example Grammar Derivations 24
Another Grammar Example Grammar : Derivations: 25
Language? 26
More Derivations 27
Language of a Grammar For a grammar with start variable : String of terminals 28
Example For grammar : Since: 29
A Convenient Notation 30
Example A context-free grammar : A derivation: 31
A context-free grammar : Another derivation: 32
Describes parentheses: (((( )))) 33
Example A context-free grammar : A derivation: 34
Language? 35
A context-free grammar : Another derivation: 36
37
Example A context-free grammar : A derivation: 38
Language? 39
A context-free grammar : A derivation: 40
Interpretation? 41
Describes matched parentheses: () ((( ))) (( )) 42
Definition: Context-Free Grammars Grammar Variables Terminal symbols Start variable Productions of the form: Variable String of variables and terminals 43
44
Definition: Context-Free Languages A language is context-free if and only if there is a context-free grammar with 45
Derivation Order Leftmost derivation: Rightmost derivation: 46
Language? 47
Leftmost derivation: Rightmost derivation: 48
Language? 49
Derivation Trees 50
51
52
53
54
Derivation Tree 55
Derivation Tree yield 56
Partial Derivation Trees Partial derivation tree 57
Partial derivation tree 58
sentential form Partial derivation tree yield 59
Sometimes, derivation order doesn’t matter Leftmost: Rightmost: Same derivation tree 60
Ambiguity 61
leftmost derivation 62
leftmost derivation 63
Two derivation trees 64
The grammar is ambiguous: string has two derivation trees 65
The grammar is ambiguous: string has two leftmost derivations 66
Definition: A context-free grammar if some string is ambiguous has: two or more derivation trees 67
In other words: A context-free grammar if some string is ambiguous has: two or more leftmost derivations (or rightmost) 68
Why do we care about ambiguity? take 69
70
71
Correct result: 72
• Ambiguity is bad for programming languages • We want to remove ambiguity 73
We fix the ambiguous grammar: New non-ambiguous grammar: 74
75
Unique derivation tree 76
The grammar : is non-ambiguous: Every string has a unique derivation tree 77
Another Ambiguous Grammar IF_STMT if EXPR then STMT else STMT 78
If expr 1 then if expr 2 then stmt 1 else stmt 2 IF_STMT if expr 1 if then expr 2 STMT then stmt 1 else STMT else stmt 2 IF_STMT if expr 1 if then expr 2 then stmt 1 79
Inherent Ambiguity Some context free languages have only ambiguous grammars Example: 80
The string has two derivation trees 81
Ambiguity in natural language? 82
- Every linear grammar generates a regular language
- Proof by contradiction examples
- Decision properties of regular languages
- Decision properties of regular languages
- Closure properties of regular languages
- Decision properties of regular languages
- Properties of regular languages
- Closure under union
- Regular and irregular languages
- Pumping lemma non regular languages examples
- Decision properties of regular languages
- Csci 3130
- Automata theory tutorial
- Formal relational query languages
- An introduction to formal languages and automata
- Cyk algo
- Grouping in relational algebra
- Formal relational query languages
- Cyk algorithm
- Csci3130
- Definisi kepimpinan
- Non formal education examples
- Venn diagram formal education and nonformal education
- Aap1 - linguagem e oralidade
- Whats formal education
- Pola komunikasi ke atas
- Objektif falsafah pendidikan kebangsaan
- Falasi tidak formal
- Manajemen paud formal dan non formal
- Registro de habla inculto informal
- Contoh topik dan tema
- Mnpr
- Swim past participle
- Principal parts of regular and irregular verbs
- Regular grammar is
- Regular expression
- Area of nonagon
- 10-2 developing formulas for circles and regular polygons
- Measure of one exterior angle of a pentagon
- Two syllable adjectives not ending in y
- Developing formulas for circles and regular polygons
- Expressao regular
- Reading english
- Excludente de ilicitude
- Regular expression symbols
- How many lines of symmetry in a regular octagon
- Reversed polish notation
- Um recipiente tem a forma de piramide regular
- Bowerpoint
- Regular expression to nfa
- Angulos internos de um pentagono
- 11-4 areas of regular polygons
- Defective comparative and superlative
- Transition diagram for relational operator
- 1/3 lwh
- Chart for military time
- Area del hexagono
- Muy bien bien regular mal
- Orderly visual search pattern
- Iddis scale
- Global regular expression print
- Adjectives irregular
- Xkcd regular expressions
- Realidades 2 preterite of regular verbs
- Poligonos regulares e irregulares
- 10-2 developing formulas for circles and regular polygons
- Regular demand
- Modo imperativo afirmativo
- Regular pattern of sound
- Pronunciation past simple regular verbs
- Ipde process examples
- Gustar y verbos similares
- Regular expression symbols
- A regular hexagonal lamina has equal sides
- Preterite tense of regular verbs
- Tener verbos irregulares
- Angle sum of polygon
- Poliedros
- Normal range for vital signs
- Regular expressions wikipedia
- Devoir in future tense
- Regular vs diffuse reflection
- 4 pics 1 word quiz ppt