尊敬的 微信汇率:1円 ≈ 0.046166 元 支付宝汇率:1円 ≈ 0.046257元 [退出登录]
SlideShare a Scribd company logo
Definition Of Context
Free
Language
NAME:Khusboo Jethwa
ENROLLMENT NO.:140950107028
SUBJECT:TOC
BRANCH:CSE-B
ITM UNIVERSE
Context-Free Languages
•Context-Free Languages (CFL) are described
using Context-Free Grammars (CFG).
•A CFG is a simple recursive method of
specifying grammar rules which can generate
strings in a language – these languages are the
CFL’s.
Context-Free Grammars
• The following is an example of a CFG, call it G1:
• A → 1A0 (A and B = variables)
• A → B
• B → # (0, 1 and # = terminals)
• A grammar consists of a collection of substitution rules
(projections).
• A is start variable in this case – usually occurs on left
hand side of topmost rule.
Use grammar to describe a language by
generating each string of language:
• Write down start variable.
• Find a variable and a rule which starts with that variable. Replace
written variable with the right hand side of this rule.
• Repeat the second step until no variables remain.
•All strings generated in this manner constitute
the language of the grammar.
•L(G1) = language of grammar G1.
•Can show that L(G1) is {1n
#0n
| n ≥ 0}.
•Any language that can be generated by some
context-free grammar is called a context-free
language.
Defining CFG
• Informally a CFG consists of:
• A set of replacement rules, each having a Left-
Hand Side (LHS) and a Right-Hand Side (RHS).
• Two types of symbols; variables and terminals.
• LHS of each rule is a single variable (no
terminals).
• RHS of each rule is a string of zero or more
variables and terminals.
• A string consists of only terminals.
Definition of a CFG
•Formally, a context-free grammar is a 4-tuple
(V, T , R, S ), where
• V are the variables (finite set)
• T are the terminal states (finite set)
• R is the set of rules
• S is the start variable, S V
Context-Free Grammars
• In grammar G1, V = {A, B}, Σ = {0, 1, #}, S = A, and R
is the collections of the rules:
• A → 1A0
• A → B
• B → #
• Consider G3 = ({S}, {a,b}, R, S). The set of rules R, is
• S → aSb | SS | ε
• This grammar generates strings such as ab, abab,
aababb and aaabbb.
Pushdown Automata (PDA)
•Pushdown Automata are similar to
nondeterministic finite automata but have an
extra element – stack.
•This stack provided extra memory space.
•Also allows pushdown automata to recognise
some nonregular languages.
Context Free Language
•A language is context free if and only if some
pushdown automata recognises it.
•Every regular language is recognised by a
finite automaton and every finite automaton
is automatically a pushdown automaton that
ignores the stack, we can note that every
regular language is also a context-free
language.
Regular and Context-FreeRegular and Context-Free
LanguagesLanguages
Closure Properties of
CFL
The context free languages are closed under
the following operations:
1.Union
2.Concatenation
3.Closure
4.Homomorphism
Derivation Tree
Definition: Let G = (V, T, P, S) be a CFG. A tree is a
derivation (or parse) tree if:
• Every vertex has a label from V union T union {ε}
• The label of the root is S
• If a vertex with label A has children with labels X1, X2,
…, Xn, from left to right, then
A –> X1, X2,…, Xn must be a production in P
• If a vertex has label ε, then that vertex is a leaf and
the only child of its’ parent
More Generally, a derivation tree can be defined with
any non-terminal as the root.
Backus-Naur Form
• The backus-naur form is a convenient notation use
to represent CFG in an intuitive and more compact
manner.
• In BNF we use the following symbols:
< > := |
• Given a CFG (V, T , R, S ) a variable is enclosed in
< and >.A terminal is represented as itself and a
production is represented as
<V>:=symbols
•When describing languages,BNF is a formal
notation for encoding grammars.
•Many programming languages,protocols or
formats have a BNF description in their
specification.
Thank You !!

More Related Content

What's hot

Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)
Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)
Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)
Mohammad Ilyas Malik
 
Automata Theory - Turing machine
Automata Theory - Turing machineAutomata Theory - Turing machine
Automata Theory - Turing machine
Akila Krishnamoorthy
 
Chomsky classification of Language
Chomsky classification of LanguageChomsky classification of Language
Chomsky classification of Language
Dipankar Boruah
 
NFA to DFA
NFA to DFANFA to DFA
NFA to DFA
Animesh Chaturvedi
 
Lecture: Automata
Lecture: AutomataLecture: Automata
Lecture: Automata
Marina Santini
 
Turing machine - theory of computation
Turing machine - theory of computationTuring machine - theory of computation
Turing machine - theory of computation
Rubaya Mim
 
Compiler Design LR parsing SLR ,LALR CLR
Compiler Design LR parsing SLR ,LALR CLRCompiler Design LR parsing SLR ,LALR CLR
Compiler Design LR parsing SLR ,LALR CLR
Riazul Islam
 
Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite Automata
Ratnakar Mikkili
 
Decision properties of reular languages
Decision properties of reular languagesDecision properties of reular languages
Decision properties of reular languages
SOMNATHMORE2
 
Chapter 6 intermediate code generation
Chapter 6   intermediate code generationChapter 6   intermediate code generation
Chapter 6 intermediate code generation
Vipul Naik
 
Top down parsing
Top down parsingTop down parsing
Top down parsing
ASHOK KUMAR REDDY
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
Dr. C.V. Suresh Babu
 
Context free grammar
Context free grammarContext free grammar
Context free grammar
Radhakrishnan Chinnusamy
 
Code generation
Code generationCode generation
Code generation
Aparna Nayak
 
CONTEXT FREE GRAMMAR
CONTEXT FREE GRAMMAR CONTEXT FREE GRAMMAR
CONTEXT FREE GRAMMAR
Zahid Parvez
 
Parse Tree
Parse TreeParse Tree
Parse Tree
A. S. M. Shafi
 
LINEAR BOUNDED AUTOMATA (LBA).pptx
LINEAR BOUNDED AUTOMATA (LBA).pptxLINEAR BOUNDED AUTOMATA (LBA).pptx
LINEAR BOUNDED AUTOMATA (LBA).pptx
AkhilJoseph63
 
Pda
PdaPda
Issues in the design of Code Generator
Issues in the design of Code GeneratorIssues in the design of Code Generator
Issues in the design of Code Generator
Darshan sai Reddy
 
Pumping lemma for regular set h1
Pumping lemma for regular set h1Pumping lemma for regular set h1
Pumping lemma for regular set h1
Rajendran
 

What's hot (20)

Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)
Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)
Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)
 
Automata Theory - Turing machine
Automata Theory - Turing machineAutomata Theory - Turing machine
Automata Theory - Turing machine
 
Chomsky classification of Language
Chomsky classification of LanguageChomsky classification of Language
Chomsky classification of Language
 
NFA to DFA
NFA to DFANFA to DFA
NFA to DFA
 
Lecture: Automata
Lecture: AutomataLecture: Automata
Lecture: Automata
 
Turing machine - theory of computation
Turing machine - theory of computationTuring machine - theory of computation
Turing machine - theory of computation
 
Compiler Design LR parsing SLR ,LALR CLR
Compiler Design LR parsing SLR ,LALR CLRCompiler Design LR parsing SLR ,LALR CLR
Compiler Design LR parsing SLR ,LALR CLR
 
Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite Automata
 
Decision properties of reular languages
Decision properties of reular languagesDecision properties of reular languages
Decision properties of reular languages
 
Chapter 6 intermediate code generation
Chapter 6   intermediate code generationChapter 6   intermediate code generation
Chapter 6 intermediate code generation
 
Top down parsing
Top down parsingTop down parsing
Top down parsing
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
 
Context free grammar
Context free grammarContext free grammar
Context free grammar
 
Code generation
Code generationCode generation
Code generation
 
CONTEXT FREE GRAMMAR
CONTEXT FREE GRAMMAR CONTEXT FREE GRAMMAR
CONTEXT FREE GRAMMAR
 
Parse Tree
Parse TreeParse Tree
Parse Tree
 
LINEAR BOUNDED AUTOMATA (LBA).pptx
LINEAR BOUNDED AUTOMATA (LBA).pptxLINEAR BOUNDED AUTOMATA (LBA).pptx
LINEAR BOUNDED AUTOMATA (LBA).pptx
 
Pda
PdaPda
Pda
 
Issues in the design of Code Generator
Issues in the design of Code GeneratorIssues in the design of Code Generator
Issues in the design of Code Generator
 
Pumping lemma for regular set h1
Pumping lemma for regular set h1Pumping lemma for regular set h1
Pumping lemma for regular set h1
 

Similar to context free language

Context Free Grammar
Context Free GrammarContext Free Grammar
Context Free Grammar
Akhil Kaushik
 
Syntax Analyzer.pdf
Syntax Analyzer.pdfSyntax Analyzer.pdf
Syntax Analyzer.pdf
kenilpatel65
 
Flat unit 3
Flat unit 3Flat unit 3
Flat unit 3
VenkataRaoS1
 
contextfreegrammars-120925004035-phpapp02.pdf
contextfreegrammars-120925004035-phpapp02.pdfcontextfreegrammars-120925004035-phpapp02.pdf
contextfreegrammars-120925004035-phpapp02.pdf
ry54321288
 
Automata theory - CFG and normal forms
Automata theory - CFG and normal formsAutomata theory - CFG and normal forms
Automata theory - CFG and normal forms
Akila Krishnamoorthy
 
9781284077247_PPTx_CH01.pptx
9781284077247_PPTx_CH01.pptx9781284077247_PPTx_CH01.pptx
9781284077247_PPTx_CH01.pptx
mainakmail2585
 
Unit2 Toc.pptx
Unit2 Toc.pptxUnit2 Toc.pptx
Unit2 Toc.pptx
viswanath kani
 
2. context free langauages
2. context free langauages2. context free langauages
2. context free langauages
danhumble
 
Normal-forms-for-Context-Free-Grammars.ppt
Normal-forms-for-Context-Free-Grammars.pptNormal-forms-for-Context-Free-Grammars.ppt
Normal-forms-for-Context-Free-Grammars.ppt
Karthik Rohan
 
Automata_Theory_and_compiler_design_UNIT-1.pptx.pdf
Automata_Theory_and_compiler_design_UNIT-1.pptx.pdfAutomata_Theory_and_compiler_design_UNIT-1.pptx.pdf
Automata_Theory_and_compiler_design_UNIT-1.pptx.pdf
TONY562
 
LECTURE 1 ALPHABET,STRINGS, LANGUAGE CHOMSKY TYPES OF GRAMMAR.pptx
LECTURE 1 ALPHABET,STRINGS, LANGUAGE CHOMSKY TYPES OF GRAMMAR.pptxLECTURE 1 ALPHABET,STRINGS, LANGUAGE CHOMSKY TYPES OF GRAMMAR.pptx
LECTURE 1 ALPHABET,STRINGS, LANGUAGE CHOMSKY TYPES OF GRAMMAR.pptx
AbhishekKumarPandit5
 
Syntax
SyntaxSyntax
Conteext-free Grammer
Conteext-free GrammerConteext-free Grammer
Conteext-free Grammer
HASHIR RAZA
 
Context free langauges
Context free langaugesContext free langauges
Context free langauges
sudhir sharma
 
Chomsky hierarchy
Chomsky hierarchyChomsky hierarchy
Chomsky hierarchy
SANUC2
 
Chapter Three(2)
Chapter Three(2)Chapter Three(2)
Chapter Three(2)
bolovv
 
Theory of computing
Theory of computingTheory of computing
Theory of computing
Ranjan Kumar
 
NLP_KASHK:Finite-State Morphological Parsing
NLP_KASHK:Finite-State Morphological ParsingNLP_KASHK:Finite-State Morphological Parsing
NLP_KASHK:Finite-State Morphological Parsing
Hemantha Kulathilake
 
Control structure
Control structureControl structure
Control structure
baran19901990
 
A195259101 22750 24_2018_grammars and languages generated by grammars
A195259101 22750 24_2018_grammars and languages generated by grammarsA195259101 22750 24_2018_grammars and languages generated by grammars
A195259101 22750 24_2018_grammars and languages generated by grammars
Mohd Arif Ansari
 

Similar to context free language (20)

Context Free Grammar
Context Free GrammarContext Free Grammar
Context Free Grammar
 
Syntax Analyzer.pdf
Syntax Analyzer.pdfSyntax Analyzer.pdf
Syntax Analyzer.pdf
 
Flat unit 3
Flat unit 3Flat unit 3
Flat unit 3
 
contextfreegrammars-120925004035-phpapp02.pdf
contextfreegrammars-120925004035-phpapp02.pdfcontextfreegrammars-120925004035-phpapp02.pdf
contextfreegrammars-120925004035-phpapp02.pdf
 
Automata theory - CFG and normal forms
Automata theory - CFG and normal formsAutomata theory - CFG and normal forms
Automata theory - CFG and normal forms
 
9781284077247_PPTx_CH01.pptx
9781284077247_PPTx_CH01.pptx9781284077247_PPTx_CH01.pptx
9781284077247_PPTx_CH01.pptx
 
Unit2 Toc.pptx
Unit2 Toc.pptxUnit2 Toc.pptx
Unit2 Toc.pptx
 
2. context free langauages
2. context free langauages2. context free langauages
2. context free langauages
 
Normal-forms-for-Context-Free-Grammars.ppt
Normal-forms-for-Context-Free-Grammars.pptNormal-forms-for-Context-Free-Grammars.ppt
Normal-forms-for-Context-Free-Grammars.ppt
 
Automata_Theory_and_compiler_design_UNIT-1.pptx.pdf
Automata_Theory_and_compiler_design_UNIT-1.pptx.pdfAutomata_Theory_and_compiler_design_UNIT-1.pptx.pdf
Automata_Theory_and_compiler_design_UNIT-1.pptx.pdf
 
LECTURE 1 ALPHABET,STRINGS, LANGUAGE CHOMSKY TYPES OF GRAMMAR.pptx
LECTURE 1 ALPHABET,STRINGS, LANGUAGE CHOMSKY TYPES OF GRAMMAR.pptxLECTURE 1 ALPHABET,STRINGS, LANGUAGE CHOMSKY TYPES OF GRAMMAR.pptx
LECTURE 1 ALPHABET,STRINGS, LANGUAGE CHOMSKY TYPES OF GRAMMAR.pptx
 
Syntax
SyntaxSyntax
Syntax
 
Conteext-free Grammer
Conteext-free GrammerConteext-free Grammer
Conteext-free Grammer
 
Context free langauges
Context free langaugesContext free langauges
Context free langauges
 
Chomsky hierarchy
Chomsky hierarchyChomsky hierarchy
Chomsky hierarchy
 
Chapter Three(2)
Chapter Three(2)Chapter Three(2)
Chapter Three(2)
 
Theory of computing
Theory of computingTheory of computing
Theory of computing
 
NLP_KASHK:Finite-State Morphological Parsing
NLP_KASHK:Finite-State Morphological ParsingNLP_KASHK:Finite-State Morphological Parsing
NLP_KASHK:Finite-State Morphological Parsing
 
Control structure
Control structureControl structure
Control structure
 
A195259101 22750 24_2018_grammars and languages generated by grammars
A195259101 22750 24_2018_grammars and languages generated by grammarsA195259101 22750 24_2018_grammars and languages generated by grammars
A195259101 22750 24_2018_grammars and languages generated by grammars
 

More from khush_boo31

L attribute in compiler design
L  attribute in compiler designL  attribute in compiler design
L attribute in compiler design
khush_boo31
 
Classification of data mart
Classification of data martClassification of data mart
Classification of data mart
khush_boo31
 
statement interface
statement interface statement interface
statement interface
khush_boo31
 
parameter passing in c#
parameter passing in c#parameter passing in c#
parameter passing in c#
khush_boo31
 
Knapsack problem using dynamic programming
Knapsack problem using dynamic programmingKnapsack problem using dynamic programming
Knapsack problem using dynamic programming
khush_boo31
 
Parsing
ParsingParsing
Parsing
khush_boo31
 

More from khush_boo31 (6)

L attribute in compiler design
L  attribute in compiler designL  attribute in compiler design
L attribute in compiler design
 
Classification of data mart
Classification of data martClassification of data mart
Classification of data mart
 
statement interface
statement interface statement interface
statement interface
 
parameter passing in c#
parameter passing in c#parameter passing in c#
parameter passing in c#
 
Knapsack problem using dynamic programming
Knapsack problem using dynamic programmingKnapsack problem using dynamic programming
Knapsack problem using dynamic programming
 
Parsing
ParsingParsing
Parsing
 

Recently uploaded

220711130083 SUBHASHREE RAKSHIT Internet resources for social science
220711130083 SUBHASHREE RAKSHIT  Internet resources for social science220711130083 SUBHASHREE RAKSHIT  Internet resources for social science
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
Kalna College
 
8+8+8 Rule Of Time Management For Better Productivity
8+8+8 Rule Of Time Management For Better Productivity8+8+8 Rule Of Time Management For Better Productivity
8+8+8 Rule Of Time Management For Better Productivity
RuchiRathor2
 
How to Create a Stage or a Pipeline in Odoo 17 CRM
How to Create a Stage or a Pipeline in Odoo 17 CRMHow to Create a Stage or a Pipeline in Odoo 17 CRM
How to Create a Stage or a Pipeline in Odoo 17 CRM
Celine George
 
Creating Images and Videos through AI.pptx
Creating Images and Videos through AI.pptxCreating Images and Videos through AI.pptx
Creating Images and Videos through AI.pptx
Forum of Blended Learning
 
Accounting for Restricted Grants When and How To Record Properly
Accounting for Restricted Grants  When and How To Record ProperlyAccounting for Restricted Grants  When and How To Record Properly
Accounting for Restricted Grants When and How To Record Properly
TechSoup
 
BỘ BÀI TẬP TEST THEO UNIT - FORM 2025 - TIẾNG ANH 12 GLOBAL SUCCESS - KÌ 1 (B...
BỘ BÀI TẬP TEST THEO UNIT - FORM 2025 - TIẾNG ANH 12 GLOBAL SUCCESS - KÌ 1 (B...BỘ BÀI TẬP TEST THEO UNIT - FORM 2025 - TIẾNG ANH 12 GLOBAL SUCCESS - KÌ 1 (B...
BỘ BÀI TẬP TEST THEO UNIT - FORM 2025 - TIẾNG ANH 12 GLOBAL SUCCESS - KÌ 1 (B...
Nguyen Thanh Tu Collection
 
Post init hook in the odoo 17 ERP Module
Post init hook in the  odoo 17 ERP ModulePost init hook in the  odoo 17 ERP Module
Post init hook in the odoo 17 ERP Module
Celine George
 
Brand Guideline of Bashundhara A4 Paper - 2024
Brand Guideline of Bashundhara A4 Paper - 2024Brand Guideline of Bashundhara A4 Paper - 2024
Brand Guideline of Bashundhara A4 Paper - 2024
khabri85
 
78 Microsoft-Publisher - Sirin Sultana Bora.pptx
78 Microsoft-Publisher - Sirin Sultana Bora.pptx78 Microsoft-Publisher - Sirin Sultana Bora.pptx
78 Microsoft-Publisher - Sirin Sultana Bora.pptx
Kalna College
 
Non-Verbal Communication for Tech Professionals
Non-Verbal Communication for Tech ProfessionalsNon-Verbal Communication for Tech Professionals
Non-Verbal Communication for Tech Professionals
MattVassar1
 
managing Behaviour in early childhood education.pptx
managing Behaviour in early childhood education.pptxmanaging Behaviour in early childhood education.pptx
managing Behaviour in early childhood education.pptx
nabaegha
 
Erasmus + DISSEMINATION ACTIVITIES Croatia
Erasmus + DISSEMINATION ACTIVITIES CroatiaErasmus + DISSEMINATION ACTIVITIES Croatia
Erasmus + DISSEMINATION ACTIVITIES Croatia
whatchangedhowreflec
 
What are the new features in the Fleet Odoo 17
What are the new features in the Fleet Odoo 17What are the new features in the Fleet Odoo 17
What are the new features in the Fleet Odoo 17
Celine George
 
The Science of Learning: implications for modern teaching
The Science of Learning: implications for modern teachingThe Science of Learning: implications for modern teaching
The Science of Learning: implications for modern teaching
Derek Wenmoth
 
Interprofessional Education Platform Introduction.pdf
Interprofessional Education Platform Introduction.pdfInterprofessional Education Platform Introduction.pdf
Interprofessional Education Platform Introduction.pdf
Ben Aldrich
 
Observational Learning
Observational Learning Observational Learning
Observational Learning
sanamushtaq922
 
Creativity for Innovation and Speechmaking
Creativity for Innovation and SpeechmakingCreativity for Innovation and Speechmaking
Creativity for Innovation and Speechmaking
MattVassar1
 
pol sci Election and Representation Class 11 Notes.pdf
pol sci Election and Representation Class 11 Notes.pdfpol sci Election and Representation Class 11 Notes.pdf
pol sci Election and Representation Class 11 Notes.pdf
BiplabHalder13
 
Slides Peluncuran Amalan Pemakanan Sihat.pptx
Slides Peluncuran Amalan Pemakanan Sihat.pptxSlides Peluncuran Amalan Pemakanan Sihat.pptx
Slides Peluncuran Amalan Pemakanan Sihat.pptx
shabeluno
 
IoT (Internet of Things) introduction Notes.pdf
IoT (Internet of Things) introduction Notes.pdfIoT (Internet of Things) introduction Notes.pdf
IoT (Internet of Things) introduction Notes.pdf
roshanranjit222
 

Recently uploaded (20)

220711130083 SUBHASHREE RAKSHIT Internet resources for social science
220711130083 SUBHASHREE RAKSHIT  Internet resources for social science220711130083 SUBHASHREE RAKSHIT  Internet resources for social science
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
 
8+8+8 Rule Of Time Management For Better Productivity
8+8+8 Rule Of Time Management For Better Productivity8+8+8 Rule Of Time Management For Better Productivity
8+8+8 Rule Of Time Management For Better Productivity
 
How to Create a Stage or a Pipeline in Odoo 17 CRM
How to Create a Stage or a Pipeline in Odoo 17 CRMHow to Create a Stage or a Pipeline in Odoo 17 CRM
How to Create a Stage or a Pipeline in Odoo 17 CRM
 
Creating Images and Videos through AI.pptx
Creating Images and Videos through AI.pptxCreating Images and Videos through AI.pptx
Creating Images and Videos through AI.pptx
 
Accounting for Restricted Grants When and How To Record Properly
Accounting for Restricted Grants  When and How To Record ProperlyAccounting for Restricted Grants  When and How To Record Properly
Accounting for Restricted Grants When and How To Record Properly
 
BỘ BÀI TẬP TEST THEO UNIT - FORM 2025 - TIẾNG ANH 12 GLOBAL SUCCESS - KÌ 1 (B...
BỘ BÀI TẬP TEST THEO UNIT - FORM 2025 - TIẾNG ANH 12 GLOBAL SUCCESS - KÌ 1 (B...BỘ BÀI TẬP TEST THEO UNIT - FORM 2025 - TIẾNG ANH 12 GLOBAL SUCCESS - KÌ 1 (B...
BỘ BÀI TẬP TEST THEO UNIT - FORM 2025 - TIẾNG ANH 12 GLOBAL SUCCESS - KÌ 1 (B...
 
Post init hook in the odoo 17 ERP Module
Post init hook in the  odoo 17 ERP ModulePost init hook in the  odoo 17 ERP Module
Post init hook in the odoo 17 ERP Module
 
Brand Guideline of Bashundhara A4 Paper - 2024
Brand Guideline of Bashundhara A4 Paper - 2024Brand Guideline of Bashundhara A4 Paper - 2024
Brand Guideline of Bashundhara A4 Paper - 2024
 
78 Microsoft-Publisher - Sirin Sultana Bora.pptx
78 Microsoft-Publisher - Sirin Sultana Bora.pptx78 Microsoft-Publisher - Sirin Sultana Bora.pptx
78 Microsoft-Publisher - Sirin Sultana Bora.pptx
 
Non-Verbal Communication for Tech Professionals
Non-Verbal Communication for Tech ProfessionalsNon-Verbal Communication for Tech Professionals
Non-Verbal Communication for Tech Professionals
 
managing Behaviour in early childhood education.pptx
managing Behaviour in early childhood education.pptxmanaging Behaviour in early childhood education.pptx
managing Behaviour in early childhood education.pptx
 
Erasmus + DISSEMINATION ACTIVITIES Croatia
Erasmus + DISSEMINATION ACTIVITIES CroatiaErasmus + DISSEMINATION ACTIVITIES Croatia
Erasmus + DISSEMINATION ACTIVITIES Croatia
 
What are the new features in the Fleet Odoo 17
What are the new features in the Fleet Odoo 17What are the new features in the Fleet Odoo 17
What are the new features in the Fleet Odoo 17
 
The Science of Learning: implications for modern teaching
The Science of Learning: implications for modern teachingThe Science of Learning: implications for modern teaching
The Science of Learning: implications for modern teaching
 
Interprofessional Education Platform Introduction.pdf
Interprofessional Education Platform Introduction.pdfInterprofessional Education Platform Introduction.pdf
Interprofessional Education Platform Introduction.pdf
 
Observational Learning
Observational Learning Observational Learning
Observational Learning
 
Creativity for Innovation and Speechmaking
Creativity for Innovation and SpeechmakingCreativity for Innovation and Speechmaking
Creativity for Innovation and Speechmaking
 
pol sci Election and Representation Class 11 Notes.pdf
pol sci Election and Representation Class 11 Notes.pdfpol sci Election and Representation Class 11 Notes.pdf
pol sci Election and Representation Class 11 Notes.pdf
 
Slides Peluncuran Amalan Pemakanan Sihat.pptx
Slides Peluncuran Amalan Pemakanan Sihat.pptxSlides Peluncuran Amalan Pemakanan Sihat.pptx
Slides Peluncuran Amalan Pemakanan Sihat.pptx
 
IoT (Internet of Things) introduction Notes.pdf
IoT (Internet of Things) introduction Notes.pdfIoT (Internet of Things) introduction Notes.pdf
IoT (Internet of Things) introduction Notes.pdf
 

context free language

  • 1. Definition Of Context Free Language NAME:Khusboo Jethwa ENROLLMENT NO.:140950107028 SUBJECT:TOC BRANCH:CSE-B ITM UNIVERSE
  • 2. Context-Free Languages •Context-Free Languages (CFL) are described using Context-Free Grammars (CFG). •A CFG is a simple recursive method of specifying grammar rules which can generate strings in a language – these languages are the CFL’s.
  • 3. Context-Free Grammars • The following is an example of a CFG, call it G1: • A → 1A0 (A and B = variables) • A → B • B → # (0, 1 and # = terminals) • A grammar consists of a collection of substitution rules (projections). • A is start variable in this case – usually occurs on left hand side of topmost rule.
  • 4. Use grammar to describe a language by generating each string of language: • Write down start variable. • Find a variable and a rule which starts with that variable. Replace written variable with the right hand side of this rule. • Repeat the second step until no variables remain.
  • 5. •All strings generated in this manner constitute the language of the grammar. •L(G1) = language of grammar G1. •Can show that L(G1) is {1n #0n | n ≥ 0}. •Any language that can be generated by some context-free grammar is called a context-free language.
  • 6. Defining CFG • Informally a CFG consists of: • A set of replacement rules, each having a Left- Hand Side (LHS) and a Right-Hand Side (RHS). • Two types of symbols; variables and terminals. • LHS of each rule is a single variable (no terminals). • RHS of each rule is a string of zero or more variables and terminals. • A string consists of only terminals.
  • 7. Definition of a CFG •Formally, a context-free grammar is a 4-tuple (V, T , R, S ), where • V are the variables (finite set) • T are the terminal states (finite set) • R is the set of rules • S is the start variable, S V
  • 8. Context-Free Grammars • In grammar G1, V = {A, B}, Σ = {0, 1, #}, S = A, and R is the collections of the rules: • A → 1A0 • A → B • B → # • Consider G3 = ({S}, {a,b}, R, S). The set of rules R, is • S → aSb | SS | ε • This grammar generates strings such as ab, abab, aababb and aaabbb.
  • 9. Pushdown Automata (PDA) •Pushdown Automata are similar to nondeterministic finite automata but have an extra element – stack. •This stack provided extra memory space. •Also allows pushdown automata to recognise some nonregular languages.
  • 10. Context Free Language •A language is context free if and only if some pushdown automata recognises it. •Every regular language is recognised by a finite automaton and every finite automaton is automatically a pushdown automaton that ignores the stack, we can note that every regular language is also a context-free language.
  • 11. Regular and Context-FreeRegular and Context-Free LanguagesLanguages
  • 12. Closure Properties of CFL The context free languages are closed under the following operations: 1.Union 2.Concatenation 3.Closure 4.Homomorphism
  • 13. Derivation Tree Definition: Let G = (V, T, P, S) be a CFG. A tree is a derivation (or parse) tree if: • Every vertex has a label from V union T union {ε} • The label of the root is S • If a vertex with label A has children with labels X1, X2, …, Xn, from left to right, then A –> X1, X2,…, Xn must be a production in P • If a vertex has label ε, then that vertex is a leaf and the only child of its’ parent More Generally, a derivation tree can be defined with any non-terminal as the root.
  • 14.
  • 15. Backus-Naur Form • The backus-naur form is a convenient notation use to represent CFG in an intuitive and more compact manner. • In BNF we use the following symbols: < > := | • Given a CFG (V, T , R, S ) a variable is enclosed in < and >.A terminal is represented as itself and a production is represented as <V>:=symbols
  • 16. •When describing languages,BNF is a formal notation for encoding grammars. •Many programming languages,protocols or formats have a BNF description in their specification.
  翻译: