SlideShare a Scribd company logo
1 of 17
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

Lecture: Context-Free Grammars
Lecture: Context-Free GrammarsLecture: Context-Free Grammars
Lecture: Context-Free GrammarsMarina Santini
 
Regular Languages
Regular LanguagesRegular Languages
Regular Languagesparmeet834
 
Undecidability.pptx
Undecidability.pptxUndecidability.pptx
Undecidability.pptxPEzhumalai
 
Turing Machine
Turing MachineTuring Machine
Turing MachineRajendran
 
Context free languages
Context free languagesContext free languages
Context free languagesJahurul Islam
 
Regular expressions-Theory of computation
Regular expressions-Theory of computationRegular expressions-Theory of computation
Regular expressions-Theory of computationBipul Roy Bpl
 
Lecture 3,4
Lecture 3,4Lecture 3,4
Lecture 3,4shah zeb
 
Regular expressions
Regular expressionsRegular expressions
Regular expressionsShiraz316
 
Compiler design syntax analysis
Compiler design syntax analysisCompiler design syntax analysis
Compiler design syntax analysisRicha Sharma
 
Mealy and moore machine
Mealy and moore machineMealy and moore machine
Mealy and moore machineEhatsham Riaz
 
Theory of Automata
Theory of AutomataTheory of Automata
Theory of AutomataFarooq Mian
 
Structure of the compiler
Structure of the compilerStructure of the compiler
Structure of the compilerSudhaa Ravi
 
Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Animesh Chaturvedi
 
Syntax Analysis in Compiler Design
Syntax Analysis in Compiler Design Syntax Analysis in Compiler Design
Syntax Analysis in Compiler Design MAHASREEM
 
Lecture 3,4
Lecture 3,4Lecture 3,4
Lecture 3,4shah zeb
 
NFA or Non deterministic finite automata
NFA or Non deterministic finite automataNFA or Non deterministic finite automata
NFA or Non deterministic finite automatadeepinderbedi
 

What's hot (20)

Lecture: Context-Free Grammars
Lecture: Context-Free GrammarsLecture: Context-Free Grammars
Lecture: Context-Free Grammars
 
Regular Languages
Regular LanguagesRegular Languages
Regular Languages
 
Undecidability.pptx
Undecidability.pptxUndecidability.pptx
Undecidability.pptx
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
 
Context free languages
Context free languagesContext free languages
Context free languages
 
push down automata
push down automatapush down automata
push down automata
 
Regular expressions-Theory of computation
Regular expressions-Theory of computationRegular expressions-Theory of computation
Regular expressions-Theory of computation
 
Lecture 3,4
Lecture 3,4Lecture 3,4
Lecture 3,4
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Compiler design syntax analysis
Compiler design syntax analysisCompiler design syntax analysis
Compiler design syntax analysis
 
NFA to DFA
NFA to DFANFA to DFA
NFA to DFA
 
Mealy and moore machine
Mealy and moore machineMealy and moore machine
Mealy and moore machine
 
Theory of Automata
Theory of AutomataTheory of Automata
Theory of Automata
 
Structure of the compiler
Structure of the compilerStructure of the compiler
Structure of the compiler
 
Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)
 
Syntax Analysis in Compiler Design
Syntax Analysis in Compiler Design Syntax Analysis in Compiler Design
Syntax Analysis in Compiler Design
 
Lecture 3,4
Lecture 3,4Lecture 3,4
Lecture 3,4
 
NFA or Non deterministic finite automata
NFA or Non deterministic finite automataNFA or Non deterministic finite automata
NFA or Non deterministic finite automata
 
pushdown automata
pushdown automatapushdown automata
pushdown automata
 
Flat unit 3
Flat unit 3Flat unit 3
Flat unit 3
 

Similar to context free language

Context Free Grammar
Context Free GrammarContext Free Grammar
Context Free GrammarAkhil Kaushik
 
Syntax Analyzer.pdf
Syntax Analyzer.pdfSyntax Analyzer.pdf
Syntax Analyzer.pdfkenilpatel65
 
contextfreegrammars-120925004035-phpapp02.pdf
contextfreegrammars-120925004035-phpapp02.pdfcontextfreegrammars-120925004035-phpapp02.pdf
contextfreegrammars-120925004035-phpapp02.pdfry54321288
 
Automata theory - CFG and normal forms
Automata theory - CFG and normal formsAutomata theory - CFG and normal forms
Automata theory - CFG and normal formsAkila Krishnamoorthy
 
9781284077247_PPTx_CH01.pptx
9781284077247_PPTx_CH01.pptx9781284077247_PPTx_CH01.pptx
9781284077247_PPTx_CH01.pptxmainakmail2585
 
2. context free langauages
2. context free langauages2. context free langauages
2. context free langauagesdanhumble
 
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.pptxAbhishekKumarPandit5
 
Conteext-free Grammer
Conteext-free GrammerConteext-free Grammer
Conteext-free GrammerHASHIR RAZA
 
Context free langauges
Context free langaugesContext free langauges
Context free langaugessudhir sharma
 
Chomsky hierarchy
Chomsky hierarchyChomsky hierarchy
Chomsky hierarchySANUC2
 
Chapter Three(2)
Chapter Three(2)Chapter Three(2)
Chapter Three(2)bolovv
 
Theory of computing
Theory of computingTheory of computing
Theory of computingRanjan Kumar
 
NLP_KASHK:Finite-State Morphological Parsing
NLP_KASHK:Finite-State Morphological ParsingNLP_KASHK:Finite-State Morphological Parsing
NLP_KASHK:Finite-State Morphological ParsingHemantha Kulathilake
 
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 grammarsMohd Arif Ansari
 
Introduction to the theory of computation
Introduction to the theory of computationIntroduction to the theory of computation
Introduction to the theory of computationprasadmvreddy
 
CS911-Lecture-21_43709.pptx
CS911-Lecture-21_43709.pptxCS911-Lecture-21_43709.pptx
CS911-Lecture-21_43709.pptxAliZaib71
 

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
 
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
 
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
 
Introduction to the theory of computation
Introduction to the theory of computationIntroduction to the theory of computation
Introduction to the theory of computation
 
CS911-Lecture-21_43709.pptx
CS911-Lecture-21_43709.pptxCS911-Lecture-21_43709.pptx
CS911-Lecture-21_43709.pptx
 
Module 1 TOC.pptx
Module 1 TOC.pptxModule 1 TOC.pptx
Module 1 TOC.pptx
 

More from khush_boo31

L attribute in compiler design
L  attribute in compiler designL  attribute in compiler design
L attribute in compiler designkhush_boo31
 
Classification of data mart
Classification of data martClassification of data mart
Classification of data martkhush_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 programmingkhush_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

ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 

Recently uploaded (20)

ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 

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.