[PDF] [PDF] Chapter 3 Regular grammars - MONTEFIORE - Who is who?

nondeterministic finite automata, 4 regular grammars 75 Page 18 Properties of regular languages Let 



Previous PDF Next PDF





[PDF] Converting DFA to Regular Grammar - JFLAP

Using the algorithm, any DFA may be converted to a regular grammar Every DFA has exactly one start state; this translates to the start variable for the grammar Each transition in the DFA becomes one production rule in the grammar A DFA must have at least one final state which allows for the derivation to terminate



5 Regular Grammars and Finite-State Automata

5 1 1 Regular Languages in CF Parsing In some parsers for CF grammars, a subparser can be discerned which handles a regular grammar Such a subparser  



[PDF] Regular Languages and Finite Automata

The aim of this short course will be to introduce the mathematical formalisms of finite state machines, regular expressions and grammars, and to explain their 



[PDF] Chapter 3 Regular grammars - MONTEFIORE - Who is who?

nondeterministic finite automata, 4 regular grammars 75 Page 18 Properties of regular languages Let 



[PDF] CS 301 - Lecture 5 Regular Grammars, Regular Languages, and

Nondeterministic Finite Automata – Equivalence of NFA and DFA – Regular Expressions • Today: – Regular Grammars and Regular Languages – Properties 



[PDF] Non-Deterministic Finite Automata and Grammars

Derive an NFA from the regular expression; 2 Convert the NFA to a DFA; 3 The resulting DFA may not be minimal, so apply the minimisation algo- rithm to erase  



[PDF] Regular Grammars

A regular language may be expressed using a deterministic or non-‐deterministic finite automaton, a regular expression, or a regular grammar A regular 



[PDF] 114 Regular Language Topics

S → a S b C C → Λ c C EXAMPLE 1 Sample Regular Grammars Page 3 56 Regular Languages and Finite Automata



[PDF] Regular languages, grammars and automata

Fact: If M is a deterministic finite state machine, then every input string α ∈ Σ* has a unique computation path This means that for each input string, the automaton 



[PDF] Regular expressions into finite automata - CORE

It is a well-established fact that each regular expression can be transformed into a nondeterministic finite automaton (NFA) with or without s-transitions,

[PDF] finite state automata

[PDF] finland emergency medical services

[PDF] fintech 2019

[PDF] fintech in india

[PDF] fintech investment in india 2019

[PDF] fintech ranking

[PDF] fintech startups

[PDF] fip travel

[PDF] fipy: partial differential equations with python

[PDF] fir and iir filters pdf

[PDF] fir copy sample

[PDF] fir filter applications ppt

[PDF] fir filter design

[PDF] fir filter design matlab

[PDF] fir filter design based on fpga pdf

Chapter 3

Regular grammars

59

3.1 Introduction

Other view of the concept of language:

not the formalization of the notion of eective procedure, but set of words satisfying a given set of rules

Origin : formalization of natural language.

60

Example

aphraseis of the formsubject verb asubjectis apronoun apronounisheorshe a verb issleepsorlistens

Possible phrases:

1.he listens

2.he sleeps

3.she sleeps

4.she listens

61

Grammars

Grammar:generativedescription of a language

Automaton:analyticaldescription

Example: programming languages are dened by a grammar (BNF), but recognized with an analytical description (the parser of a compiler), Language theory establishes links between analytical and generative language descriptions. 62

3.2 Grammars

A grammar is a 4-tupleG= (V;;R;S), where

Vis an alphabet,

Vis the setterminal symbols(V is the set ofnonterminal symbols), R(V+V) is a nite set ofproduction rules(also called simply rules or productions),

S2V is thestart symbol.

63

Notation:

Elements ofV :A;B;:::

Elements of :a;b;:::.

Rules (;)2R:!or!G.

The start symbol is usually written asS.

Empty word:".

64

Example :

V=fS;A;B;a;bg,

=fa;bg,

R=fS!A;S!B;B!bB;A!aA;A!";B!"g,

Sis the start symbol.

65

Words generated by a grammar: example

aaaais in the language generated by the grammar we have just described: S

AruleS!A

aA A!aA aaA A!aA aaaA A!aA aaaaA A!aA aaaa A!" 66

Generated words: denition

LetG= (V;;R;S) be a grammar andu2V+; v2Vbe words. The wordvcan be derived in one step fromubyG(notationu)Gv) if and only if: u=xu0y(ucan be decomposed in three partsx,u0andy; the partsx andybeing allowed to be empty), v=xv0y(vcan be decomposed in three partsx,v0andy), u0!Gv0(the rule (u0;v0) is inR). 67
LetG= (V;;R;S) be a grammar andu2V+; v2Vbe words. The wordvcan be derived in several steps fromu(notationu)Gv) if and only if9k0 andv0:::vk2V+such that u=v0, v=vk, vi)Gvi+1for 0i < k. 68
Words generated by a grammarG: wordsv2(containing only terminal symbols) such that S )Gv: The language generated by a grammarG(writtenL(G)) is the set

L(G) =fv2jS)Gvg:

Example :

The language generated by the grammar shown in the example above is the set of all words containing either onlya's or onlyb's. 69

Types of grammars

Type 0:no restrictions on the rules.

Type 1:Context sensitivegrammars.

The rules

satisfy the condition jj jj:

Exception: the rule

S!" is allowed as long as the start symbolSdoes not appear in the right hand side of a rule. 70

Type 2:context-freegrammars.

Productions of the form

A! whereA2V and there is no restriction on.

Type 3:regulargrammars.

Productions rules of the form

A!wB A!w whereA;B2V andw2. 71

3.3 Regular grammars

Theorem:

A language is regular if and only if it can be generated by a regular grammar. A. If a language is regular, it can be generated by a regular grammar.

IfLis regular, there exists

M= (Q;;;s;F)

such thatL=L(M). FromM, one can easily construct a regular grammar

G= (VG;G;SG;RG)

generatingL. 72

Gis dened by:

G= ,

VG=Q[,

SG=s,

RG=(A!wB;for all(A;w;B)2

A!"for allA2F)

73
B. If a language is generated by a regular grammar, it is regular. Let

G= (VG;G;SG;RG)

be the grammar generatingL. A nondeterministic nite automaton acceptingLcan be dened as follows: Q=VGG[ ffg(the states ofMare the nonterminal symbols ofG to which a new statefis added), = G, s=SG,

F=ffg,

=((A;w;B);for allA!wB2RG(A;w;f);for allA!w2RG) 74

3.4 The regular languages

We have seen four characterizations of the regular languages: 1. regula rexp ressions, 2. deterministic nite automata, 3. nondeterministic nite automata, 4. regula rgramma rs. 75

Properties of regular languages

LetL1andL2be two regular languages.

L1[L2is regular.

L1L2is regular.

L1is regular.

LR1is regular.

L1=

L1is regular.

L1\L2is regular.

76
L

1\L2regular ?

L

1\L2=L1

[L2 Alternatively, ifM1= (Q1;; 1;s1;F1) acceptsL1andM2= (Q2;;2;s2; F

2) acceptsL2, the following automaton, acceptsL1\L2:

Q=Q1Q2,

((q1;q2);) = (p1;p2) if and only if1(q1;) =p1and2(q2;) =p2, s= (s1;s2),

F=F1F2.

77
Let be the alphabet on whichL1is dened, and let: !0be a function from to another alphabet 0. This fonction, called aprojection functioncan be extended to words by applying it to every symbol in the word,i.e.forw=w1:::wk2, (w) =(w1):::(wk).

IfL1is regular, the language(L1) is also regular.

78

Algorithms

Les following problems can be solved by algorithms for regular languages: w2L? L=;?

L= ? (L=;)

L1L2? (L2\L1=;)

L1=L2? (L1L2andL2L1)

79

3.5 Beyond regular languages

Many languages are regular,

But, all languages cannot be regular for cardinality reasons. We will now prove, using another techniques that some specic languages are not regular. 80

Basic Observations

1. All nite languages (including only a nite numb erof w ords)a re regular. 2. A non regula rlanguage must thus include an innite numb erof w ords. 3. If a language includes an innite numb erof w ords,there is no b ound on the size of the words in the language. 4. Any regula rlanguage is accepted b ya nite automaton that has a given number numbermof states. 81

5.Consider an innite regula rlanguage and an automaton with mstates

accepting this language. For any word whose length is greater thanm, the execution of the automaton on this word must go through an identical stateskat least twice, a nonempty part of the word being read between these two visits tosk.ssssksskssfx u y 6. Consequently ,all w ordsof the fo rmxuyare also accepted by the automaton and thus are in the language. 82

The "pumping" lemmas (theorems)

First version

LetLbe an innite regular language. Then there exists wordsx;u;y2, withu6="such thatxuny2L8n0.

Second version :

LetLbe a regular language and letw2Lbe such thatjwj jQjwhereQ is the set of states of a determnistic automaton acceptingL. Then

9x;u;y, withu6="andjxuj jQjsuch thatxuy=wand,8n; xuny2L.

83

Applications of the pumping lemmas

The langage

a nbn is not regular. Indeed, it is not possible to nd wordsx;u;ysuch that xu ky2anbn8kand thus the pumping lemma cannot be true for this language. u2a:imp ossible. u2b:imp ossible. u2(a[b)(a[b) :imp ossible. 84

The language

L=an2 is not regular. Indeed, the pumping lemma (second version) is contradicted. Letm=jQjbe the number of states of an automaton acceptingL. Consideram2. Sincem2m, there must existx,uandysuch that jxuj mandxuny2L8n. Explicitly, we have x=ap0pm1; u=aq0< qm; y=arr0: Consequentlyxu2y62Lsincep+ 2q+ris not a perfect square. Indeed, m

2< p+ 2q+rm2+m <(m+ 1)2=m2+ 2m+ 1:

85

The language

L=fanjnis primeg

is not regular. The rst pumping lemma implies that there exists constantsp,qandrsuch that8kquotesdbs_dbs14.pdfusesText_20