SlideShare a Scribd company logo
1 of 60
Chomsky and Greibach Normal
Forms
Chomsky and Greibach Normal Forms – p.1/2
Simplifying a CFG
Chomsky and Greibach Normal Forms – p.2/2
It is often convenient to simplify CFG
Simplifying a CFG
Chomsky and Greibach Normal Forms – p.2/2
It is often convenient to simplify CFG
One of the simplest and most useful simplified forms of
CFG is called the Chomsky normal form
Simplifying a CFG
Chomsky and Greibach Normal Forms – p.2/2
It is often convenient to simplify CFG
One of the simplest and most useful simplified forms of
CFG is called the Chomsky normal form
Another normal form usually used in algebraic
specifications is Greibach normal form
Simplifying a CFG
Chomsky and Greibach Normal Forms – p.2/2
It is often convenient to simplify CFG
One of the simplest and most useful simplified forms of
CFG is called the Chomsky normal form
Another normal form usually used in algebraic
specifications is Greibach normal form
Note the difference between grammar cleaning and simplifi cation
Note
Chomsky and Greibach Normal Forms – p.3/2
Normal forms are useful when more advanced topics in
computation theory are approached, as we shall see further
Definition
Chomsky and Greibach Normal Forms – p.4/2
is in Chomsky normal form ifA context-free grammar
every rule is of the form:
where is a terminal, are nonterminals, and
may not be the start variable (the axiom)
Note
Chomsky and Greibach Normal Forms – p.5/2
The rule , where is the start variable, is not ex-
cluded from a CFG in Chomsky normal form.
Theorem 2.9
Chomsky and Greibach Normal Forms – p.6/2
Any context-free language is generated by a context-free
grammar in Chomsky normal form.
Theorem 2.9
Chomsky and Greibach Normal Forms – p.6/2
Any context-free language is generated by a context-free
grammar in Chomsky normal form.
Proof idea:
Theorem 2.9
Chomsky and Greibach Normal Forms – p.6/2
Any context-free language is generated by a context-free
grammar in Chomsky normal form.
Proof idea:
Show that any CFG can be converted into a CFG in
Chomsky normal form
Theorem 2.9
Chomsky and Greibach Normal Forms – p.6/2
Any context-free language is generated by a context-free
grammar in Chomsky normal form.
Proof idea:
Show that any CFG can be converted into a CFG in
Chomsky normal form
Conversion procedure has several stages where the rules that
violate Chomsky normal form conditions are replaced with
equivalent rules that satisfy these conditions
Theorem 2.9
Chomsky and Greibach Normal Forms – p.6/2
Any context-free language is generated by a context-free
grammar in Chomsky normal form.
Proof idea:
Show that any CFG can be converted into a CFG in
Chomsky normal form
Conversion procedure has several stages where the rules that
violate Chomsky normal form conditions are replaced with
equivalent rules that satisfy these conditions
Order of transformations: (1) add a new start variable, (2)
eliminate all-rules, (3) eliminate unit-rules, (4) convert other rules
Theorem 2.9
Chomsky and Greibach Normal Forms – p.6/2
Any context-free language is generated by a context-free
grammar in Chomsky normal form.
Proof idea:
Show that any CFG can be converted into a CFG in
Chomsky normal form
Conversion procedure has several stages where the rules that
violate Chomsky normal form conditions are replaced with
equivalent rules that satisfy these conditions
Order of transformations: (1) add a new start variable, (2)
eliminate all-rules, (3) eliminate unit-rules, (4) convert other rules
Check that the obtained CFG defi nes the same language
Proof
Chomsky and Greibach Normal Forms – p.7/2
Let be the original CFG.
Proof
Chomsky and Greibach Normal Forms – p.7/2
Let be the original CFG.
Step 1: add a new start symbol to , and the rule to
Proof
Chomsky and Greibach Normal Forms – p.7/2
Let be the original CFG.
to
does not occur
Step 1: add a new start symbol to , and the rule
Note: this change guarantees that the startsymbol of
on the of any rule
Step 2: eliminate
Chomsky and Greibach Normal Forms – p.8/2
-rules
Repeat
1. Eliminate the rule from where is not the start symbol
2. For each occurrence of on the of a rule, add a new rule to
with that occurrence of deleted
Example: replace by ;
unless the
replace by
3. Replace the rule , (if it is present) by
rule has been previously eliminated
until all rules are eliminated
Step 3: remove unit rules
Chomsky and Greibach Normal Forms – p.9/2
Repeat
1. Remove a unit rule
2. For each rule , add the rule to , unless
was a unit rule previously removed
until all unit rules are eliminated
Note: is a string of variables and terminals
Convert all remaining rules
Repeat
, , where each , ,1. Replace a rule
is a variable or a terminal, by:
, , ,
are new variables
replace any terminal with a new variable and add the
where , , ,
2. If
rule
withuntil no rules of the form
remain
Chomsky and Greibach Normal Forms – p.10/2
Convert all remaining rules
Repeat
, , where each , ,1. Replace a rule
is a variable or a terminal, by:
, , ,
are new variables
replace any terminal with a new variable and add the
where , , ,
2. If
rule
withuntil no rules of the form
remain
Chomsky and Greibach Normal Forms – p.10/2
Convert all remaining rules
Repeat
, , where each , ,1. Replace a rule
is a variable or a terminal, by:
, , ,
are new variables
replace any terminal with a new variable and add the
where , , ,
2. If
rule
withuntil no rules of the form
remain
Chomsky and Greibach Normal Forms – p.10/2
Example CFG conversion
Chomsky and Greibach Normal Forms – p.11/2
Consider the grammar whose rules are:
Notation: symbols removed are green and those added are red.
After fi rst step of transformation we get:
Example CFG conversion
Chomsky and Greibach Normal Forms – p.11/2
Consider the grammar whose rules are:
Notation: symbols removed are green and those added are red.
After fi rst step of transformation we get:
Example CFG conversion
Chomsky and Greibach Normal Forms – p.11/2
Consider the grammar whose rules are:
Notation: symbols removed are green and those added are red.
After fi rst step of transformation we get:
Removing
Chomsky and Greibach Normal Forms – p.12/2
rules
Removing :
Removing :
Removing
Chomsky and Greibach Normal Forms – p.12/2
rules
Removing :
Removing :
Removing
Chomsky and Greibach Normal Forms – p.12/2
rules
Removing :
Removing :
Removing unit rule
Chomsky and Greibach Normal Forms – p.13/2
Removing :
Removing :
Removing unit rule
Chomsky and Greibach Normal Forms – p.13/2
Removing :
Removing :
Removing unit rule
Chomsky and Greibach Normal Forms – p.13/2
Removing :
Removing :
More unit rules
Chomsky and Greibach Normal Forms – p.14/2
Removing :
Removing :
More unit rules
Chomsky and Greibach Normal Forms – p.14/2
Removing :
Removing :
More unit rules
Chomsky and Greibach Normal Forms – p.14/2
Removing :
Removing :
Converting remaining rules
Chomsky and Greibach Normal Forms – p.15/2
Converting remaining rules
Chomsky and Greibach Normal Forms – p.15/2
Converting remaining rules
Chomsky and Greibach Normal Forms – p.15/2
Note
The conversion procedure produces several
variables along with several rules .
Since all these represent the same rule, we
may simplify the result using a single variable
and a single rule
Chomsky and Greibach Normal Forms – p.16/2
Note
The conversion procedure produces several
variables along with several rules .
Since all these represent the same rule, we
may simplify the result using a single variable
and a single rule
Chomsky and Greibach Normal Forms – p.16/2
Note
The conversion procedure produces several
variables along with several rules .
Since all these represent the same rule, we
may simplify the result using a single variable
and a single rule
Chomsky and Greibach Normal Forms – p.16/2
Greibach Normal Form
is in
has the
and
A context-free grammar
Greibach normal form if each rule
property: , ,
.
Chomsky and Greibach Normal Forms – p.17/2
Note: Greibach normal form provides a justifi ca-
tion of operator prefi x-notation usually employed
in algebra.
Greibach Normal Form
is in
has the
and
A context-free grammar
Greibach normal form if each rule
property: , ,
.
Chomsky and Greibach Normal Forms – p.17/2
Note: Greibach normal form provides a justifi ca-
tion of operator prefi x-notation usually employed
in algebra.
Greibach Normal Form
is in
has the
and
A context-free grammar
Greibach normal form if each rule
property: , ,
.
Chomsky and Greibach Normal Forms – p.17/2
Note: Greibach normal form provides a justifi ca-
tion of operator prefi x-notation usually employed
in algebra.
Greibach Theorem
Every CFL where can be generated by a
CFG in Greibach normal form.
Chomsky and Greibach Normal Forms – p.18/2
be a CFG generating . Assume thatProof idea: Let
is in Chomsky normal form
Let be an ordering of nonterminals.
Construct the Greibach normal form from Chomsky normal form
Greibach Theorem
Every CFL where can be generated by a
CFG in Greibach normal form.
Chomsky and Greibach Normal Forms – p.18/2
be a CFG generating . Assume thatProof idea: Let
is in Chomsky normal form
Let be an ordering of nonterminals.
Construct the Greibach normal form from Chomsky normal form
Greibach Theorem
Every CFL where can be generated by a
CFG in Greibach normal form.
Chomsky and Greibach Normal Forms – p.18/2
be a CFG generating . Assume thatProof idea: Let
is in Chomsky normal form
Let be an ordering of nonterminals.
Construct the Greibach normal form from Chomsky normal form
Construction
Chomsky and Greibach Normal Forms – p.19/2
so that if1. Modify the rules in
2. Starting with and proceeding to
then
this is done as follows:
(a) Assume that productions have been modifi ed so that for
,
(b) If
only if
is a production with , generate a new set of
the rhs of eachproductions substituting for the
production
times we obtain rules of the form(c) Repeating (b) at most
,
(d) Replace rules by removing left-recursive rules
Construction
Chomsky and Greibach Normal Forms – p.19/2
so that if1. Modify the rules in
2. Starting with and proceeding to
then
this is done as follows:
(a) Assume that productions have been modifi ed so that for
,
(b) If
only if
is a production with , generate a new set of
the rhs of eachproductions substituting for the
production
times we obtain rules of the form(c) Repeating (b) at most
,
(d) Replace rules by removing left-recursive rules
Construction
Chomsky and Greibach Normal Forms – p.19/2
so that if1. Modify the rules in
2. Starting with and proceeding to
then
this is done as follows:
(a) Assume that productions have been modifi ed so that for
,
(b) If
only if
is a production with , generate a new set of
the rhs of eachproductions substituting for the
production
times we obtain rules of the form(c) Repeating (b) at most
,
(d) Replace rules by removing left-recursive rules
Removing left-recursion
Chomsky and Greibach Normal Forms – p.20/2
Left-recursion can be eliminated by the following
scheme:
If are all left recursive rules, and
are all remaining -rules then chose a
new
nonterminal, sayAdd the new
Replace the
-rules ,
-rules by ,
This construction preserve the language .
Removing left-recursion
Chomsky and Greibach Normal Forms – p.20/2
Left-recursion can be eliminated by the following
scheme:
If are all left recursive rules, and
are all remaining -rules then chose a
new
nonterminal, sayAdd the new
Replace the
-rules ,
-rules by ,
This construction preserve the language .
Removing left-recursion
Chomsky and Greibach Normal Forms – p.20/2
Left-recursion can be eliminated by the following
scheme:
If are all left recursive rules, and
are all remaining -rules then chose a
new
nonterminal, sayAdd the new
Replace the
-rules ,
-rules by ,
This construction preserve the language .
21-1
More on Greibach NF
Chomsky and Greibach Normal Forms – p.22/2
See Introduction to Automata Theory, Languages,
and Computation, J.E, Hopcroft and J.D Ullman,
Addison-Wesley 1979, p. 94–96
Example
Chomsky and Greibach Normal Forms – p.23/2
Convert the CFG
where
into Greibach normal form.
Example
Chomsky and Greibach Normal Forms – p.23/2
Convert the CFG
where
into Greibach normal form.
Example
Chomsky and Greibach Normal Forms – p.23/2
Convert the CFG
where
into Greibach normal form.
Solution
Chomsky and Greibach Normal Forms – p.24/2
1. Step 1: ordering the rules: (Only rules violate ordering
conditions, hence only rules need to be changed).
Following the procedure we replace rules by:
2. Eliminating left-recursion we get: ,
3. All rules start with a terminal. We use them to replace
. This introduces the rules
4. Use production to make them start with a terminal
Solution
Chomsky and Greibach Normal Forms – p.24/2
1. Step 1: ordering the rules: (Only rules violate ordering
conditions, hence only rules need to be changed).
Following the procedure we replace rules by:
2. Eliminating left-recursion we get: ,
3. All rules start with a terminal. We use them to replace
. This introduces the rules
4. Use production to make them start with a terminal
Solution
Chomsky and Greibach Normal Forms – p.24/2
1. Step 1: ordering the rules: (Only rules violate ordering
conditions, hence only rules need to be changed).
Following the procedure we replace rules by:
2. Eliminating left-recursion we get: ,
3. All rules start with a terminal. We use them to replace
. This introduces the rules
4. Use production to make them start with a terminal

More Related Content

What's hot

ELEMENTS OF TRANSPORT PROTOCOL
ELEMENTS OF TRANSPORT PROTOCOLELEMENTS OF TRANSPORT PROTOCOL
ELEMENTS OF TRANSPORT PROTOCOLShashank Rustagi
Β 
closure properties of regular language.pptx
closure properties of regular language.pptxclosure properties of regular language.pptx
closure properties of regular language.pptxThirumoorthy64
Β 
CONTEXT FREE GRAMMAR
CONTEXT FREE GRAMMAR CONTEXT FREE GRAMMAR
CONTEXT FREE GRAMMAR Zahid Parvez
Β 
Intermediate code generator
Intermediate code generatorIntermediate code generator
Intermediate code generatorsanchi29
Β 
Type Checking(Compiler Design) #ShareThisIfYouLike
Type Checking(Compiler Design) #ShareThisIfYouLikeType Checking(Compiler Design) #ShareThisIfYouLike
Type Checking(Compiler Design) #ShareThisIfYouLikeUnited International University
Β 
Type checking in compiler design
Type checking in compiler designType checking in compiler design
Type checking in compiler designSudip Singh
Β 
Master method theorem
Master method theoremMaster method theorem
Master method theoremRajendran
Β 
I. AO* SEARCH ALGORITHM
I. AO* SEARCH ALGORITHMI. AO* SEARCH ALGORITHM
I. AO* SEARCH ALGORITHMvikas dhakane
Β 
4.3 techniques for turing machines construction
4.3 techniques for turing machines construction4.3 techniques for turing machines construction
4.3 techniques for turing machines constructionSampath Kumar S
Β 
Dataflow Analysis
Dataflow AnalysisDataflow Analysis
Dataflow AnalysisEelco Visser
Β 
Pass 1 flowchart
Pass 1 flowchartPass 1 flowchart
Pass 1 flowchartNamisha Sharma
Β 
Context free grammars
Context free grammarsContext free grammars
Context free grammarsRonak Thakkar
Β 
Comet Cloud
Comet CloudComet Cloud
Comet Cloudpradeepas7
Β 
Threaded Binary Tree
Threaded Binary TreeThreaded Binary Tree
Threaded Binary Treekhabbab_h
Β 
Computer architecture instruction formats
Computer architecture instruction formatsComputer architecture instruction formats
Computer architecture instruction formatsMazin Alwaaly
Β 
Intermediate code generation in Compiler Design
Intermediate code generation in Compiler DesignIntermediate code generation in Compiler Design
Intermediate code generation in Compiler DesignKuppusamy P
Β 

What's hot (20)

ELEMENTS OF TRANSPORT PROTOCOL
ELEMENTS OF TRANSPORT PROTOCOLELEMENTS OF TRANSPORT PROTOCOL
ELEMENTS OF TRANSPORT PROTOCOL
Β 
closure properties of regular language.pptx
closure properties of regular language.pptxclosure properties of regular language.pptx
closure properties of regular language.pptx
Β 
CONTEXT FREE GRAMMAR
CONTEXT FREE GRAMMAR CONTEXT FREE GRAMMAR
CONTEXT FREE GRAMMAR
Β 
Intermediate code generator
Intermediate code generatorIntermediate code generator
Intermediate code generator
Β 
Type Checking(Compiler Design) #ShareThisIfYouLike
Type Checking(Compiler Design) #ShareThisIfYouLikeType Checking(Compiler Design) #ShareThisIfYouLike
Type Checking(Compiler Design) #ShareThisIfYouLike
Β 
Type checking in compiler design
Type checking in compiler designType checking in compiler design
Type checking in compiler design
Β 
Master method theorem
Master method theoremMaster method theorem
Master method theorem
Β 
I. AO* SEARCH ALGORITHM
I. AO* SEARCH ALGORITHMI. AO* SEARCH ALGORITHM
I. AO* SEARCH ALGORITHM
Β 
4.3 techniques for turing machines construction
4.3 techniques for turing machines construction4.3 techniques for turing machines construction
4.3 techniques for turing machines construction
Β 
DFS and BFS
DFS and BFSDFS and BFS
DFS and BFS
Β 
Dataflow Analysis
Dataflow AnalysisDataflow Analysis
Dataflow Analysis
Β 
BFS and DFS
BFS and DFSBFS and DFS
BFS and DFS
Β 
Pass 1 flowchart
Pass 1 flowchartPass 1 flowchart
Pass 1 flowchart
Β 
Context free grammar
Context free grammarContext free grammar
Context free grammar
Β 
Context free grammars
Context free grammarsContext free grammars
Context free grammars
Β 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
Β 
Comet Cloud
Comet CloudComet Cloud
Comet Cloud
Β 
Threaded Binary Tree
Threaded Binary TreeThreaded Binary Tree
Threaded Binary Tree
Β 
Computer architecture instruction formats
Computer architecture instruction formatsComputer architecture instruction formats
Computer architecture instruction formats
Β 
Intermediate code generation in Compiler Design
Intermediate code generation in Compiler DesignIntermediate code generation in Compiler Design
Intermediate code generation in Compiler Design
Β 

Viewers also liked

CNF & Leftmost Derivation - Theory of Computation
CNF & Leftmost Derivation - Theory of ComputationCNF & Leftmost Derivation - Theory of Computation
CNF & Leftmost Derivation - Theory of ComputationDrishti Bhalla
Β 
Chomsky by zeeshan khan and Raheel Khan
Chomsky by zeeshan khan and Raheel KhanChomsky by zeeshan khan and Raheel Khan
Chomsky by zeeshan khan and Raheel KhanM Khan
Β 
Chomsky & Greibach Normal Forms
Chomsky & Greibach Normal FormsChomsky & Greibach Normal Forms
Chomsky & Greibach Normal FormsRajendran
Β 
Context free languages
Context free languagesContext free languages
Context free languagesJahurul Islam
Β 
Bakus naur form
Bakus naur formBakus naur form
Bakus naur formgrahamwell
Β 
Lecture: Context-Free Grammars
Lecture: Context-Free GrammarsLecture: Context-Free Grammars
Lecture: Context-Free GrammarsMarina Santini
Β 
Simplifiaction of grammar
Simplifiaction of grammarSimplifiaction of grammar
Simplifiaction of grammarlavishka_anuj
Β 
Theory of Automata and formal languages unit 2
Theory of Automata and formal languages unit 2Theory of Automata and formal languages unit 2
Theory of Automata and formal languages unit 2Abhimanyu Mishra
Β 
Properties of cfg
Properties of cfgProperties of cfg
Properties of cfglavishka_anuj
Β 
Context free langauges
Context free langaugesContext free langauges
Context free langaugessudhir sharma
Β 
Context free grammars
Context free grammarsContext free grammars
Context free grammarsShiraz316
Β 
Turing machines
Turing machinesTuring machines
Turing machineslavishka_anuj
Β 
Turing machine by_deep
Turing machine by_deepTuring machine by_deep
Turing machine by_deepDeepjyoti Kalita
Β 
Cs2303 theory of computation may june 2016
Cs2303 theory of computation may june 2016Cs2303 theory of computation may june 2016
Cs2303 theory of computation may june 2016appasami
Β 
Programming Haskell Chapter8
Programming Haskell Chapter8Programming Haskell Chapter8
Programming Haskell Chapter8Kousuke Ruichi
Β 
Meta Languages Bnf Ebnf Student Version
Meta Languages Bnf Ebnf Student VersionMeta Languages Bnf Ebnf Student Version
Meta Languages Bnf Ebnf Student VersionKelly Bauer
Β 
Algorithms Vs Meta Language
Algorithms Vs Meta LanguageAlgorithms Vs Meta Language
Algorithms Vs Meta LanguageKelly Bauer
Β 
Cs2303 theory of computation all anna University question papers
Cs2303 theory of computation all anna University question papersCs2303 theory of computation all anna University question papers
Cs2303 theory of computation all anna University question papersappasami
Β 
Control structure
Control structureControl structure
Control structurebaran19901990
Β 

Viewers also liked (20)

CNF & Leftmost Derivation - Theory of Computation
CNF & Leftmost Derivation - Theory of ComputationCNF & Leftmost Derivation - Theory of Computation
CNF & Leftmost Derivation - Theory of Computation
Β 
Chomsky by zeeshan khan and Raheel Khan
Chomsky by zeeshan khan and Raheel KhanChomsky by zeeshan khan and Raheel Khan
Chomsky by zeeshan khan and Raheel Khan
Β 
Chomsky & Greibach Normal Forms
Chomsky & Greibach Normal FormsChomsky & Greibach Normal Forms
Chomsky & Greibach Normal Forms
Β 
L3 cfg
L3 cfgL3 cfg
L3 cfg
Β 
Context free languages
Context free languagesContext free languages
Context free languages
Β 
Bakus naur form
Bakus naur formBakus naur form
Bakus naur form
Β 
Lecture: Context-Free Grammars
Lecture: Context-Free GrammarsLecture: Context-Free Grammars
Lecture: Context-Free Grammars
Β 
Simplifiaction of grammar
Simplifiaction of grammarSimplifiaction of grammar
Simplifiaction of grammar
Β 
Theory of Automata and formal languages unit 2
Theory of Automata and formal languages unit 2Theory of Automata and formal languages unit 2
Theory of Automata and formal languages unit 2
Β 
Properties of cfg
Properties of cfgProperties of cfg
Properties of cfg
Β 
Context free langauges
Context free langaugesContext free langauges
Context free langauges
Β 
Context free grammars
Context free grammarsContext free grammars
Context free grammars
Β 
Turing machines
Turing machinesTuring machines
Turing machines
Β 
Turing machine by_deep
Turing machine by_deepTuring machine by_deep
Turing machine by_deep
Β 
Cs2303 theory of computation may june 2016
Cs2303 theory of computation may june 2016Cs2303 theory of computation may june 2016
Cs2303 theory of computation may june 2016
Β 
Programming Haskell Chapter8
Programming Haskell Chapter8Programming Haskell Chapter8
Programming Haskell Chapter8
Β 
Meta Languages Bnf Ebnf Student Version
Meta Languages Bnf Ebnf Student VersionMeta Languages Bnf Ebnf Student Version
Meta Languages Bnf Ebnf Student Version
Β 
Algorithms Vs Meta Language
Algorithms Vs Meta LanguageAlgorithms Vs Meta Language
Algorithms Vs Meta Language
Β 
Cs2303 theory of computation all anna University question papers
Cs2303 theory of computation all anna University question papersCs2303 theory of computation all anna University question papers
Cs2303 theory of computation all anna University question papers
Β 
Control structure
Control structureControl structure
Control structure
Β 

More from Rajendran

Element distinctness lower bounds
Element distinctness lower boundsElement distinctness lower bounds
Element distinctness lower boundsRajendran
Β 
Scheduling with Startup and Holding Costs
Scheduling with Startup and Holding CostsScheduling with Startup and Holding Costs
Scheduling with Startup and Holding CostsRajendran
Β 
Divide and conquer surfing lower bounds
Divide and conquer  surfing lower boundsDivide and conquer  surfing lower bounds
Divide and conquer surfing lower boundsRajendran
Β 
Red black tree
Red black treeRed black tree
Red black treeRajendran
Β 
Hash table
Hash tableHash table
Hash tableRajendran
Β 
Medians and order statistics
Medians and order statisticsMedians and order statistics
Medians and order statisticsRajendran
Β 
Proof master theorem
Proof master theoremProof master theorem
Proof master theoremRajendran
Β 
Recursion tree method
Recursion tree methodRecursion tree method
Recursion tree methodRajendran
Β 
Recurrence theorem
Recurrence theoremRecurrence theorem
Recurrence theoremRajendran
Β 
Master method
Master method Master method
Master method Rajendran
Β 
Master method theorem
Master method theoremMaster method theorem
Master method theoremRajendran
Β 
Hash tables
Hash tablesHash tables
Hash tablesRajendran
Β 
Lower bound
Lower boundLower bound
Lower boundRajendran
Β 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithmsRajendran
Β 
Longest common subsequences in Algorithm Analysis
Longest common subsequences in Algorithm AnalysisLongest common subsequences in Algorithm Analysis
Longest common subsequences in Algorithm AnalysisRajendran
Β 
Dynamic programming in Algorithm Analysis
Dynamic programming in Algorithm AnalysisDynamic programming in Algorithm Analysis
Dynamic programming in Algorithm AnalysisRajendran
Β 
Average case Analysis of Quicksort
Average case Analysis of QuicksortAverage case Analysis of Quicksort
Average case Analysis of QuicksortRajendran
Β 
Np completeness
Np completenessNp completeness
Np completenessRajendran
Β 
computer languages
computer languagescomputer languages
computer languagesRajendran
Β 
proving non-computability
proving non-computabilityproving non-computability
proving non-computabilityRajendran
Β 

More from Rajendran (20)

Element distinctness lower bounds
Element distinctness lower boundsElement distinctness lower bounds
Element distinctness lower bounds
Β 
Scheduling with Startup and Holding Costs
Scheduling with Startup and Holding CostsScheduling with Startup and Holding Costs
Scheduling with Startup and Holding Costs
Β 
Divide and conquer surfing lower bounds
Divide and conquer  surfing lower boundsDivide and conquer  surfing lower bounds
Divide and conquer surfing lower bounds
Β 
Red black tree
Red black treeRed black tree
Red black tree
Β 
Hash table
Hash tableHash table
Hash table
Β 
Medians and order statistics
Medians and order statisticsMedians and order statistics
Medians and order statistics
Β 
Proof master theorem
Proof master theoremProof master theorem
Proof master theorem
Β 
Recursion tree method
Recursion tree methodRecursion tree method
Recursion tree method
Β 
Recurrence theorem
Recurrence theoremRecurrence theorem
Recurrence theorem
Β 
Master method
Master method Master method
Master method
Β 
Master method theorem
Master method theoremMaster method theorem
Master method theorem
Β 
Hash tables
Hash tablesHash tables
Hash tables
Β 
Lower bound
Lower boundLower bound
Lower bound
Β 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithms
Β 
Longest common subsequences in Algorithm Analysis
Longest common subsequences in Algorithm AnalysisLongest common subsequences in Algorithm Analysis
Longest common subsequences in Algorithm Analysis
Β 
Dynamic programming in Algorithm Analysis
Dynamic programming in Algorithm AnalysisDynamic programming in Algorithm Analysis
Dynamic programming in Algorithm Analysis
Β 
Average case Analysis of Quicksort
Average case Analysis of QuicksortAverage case Analysis of Quicksort
Average case Analysis of Quicksort
Β 
Np completeness
Np completenessNp completeness
Np completeness
Β 
computer languages
computer languagescomputer languages
computer languages
Β 
proving non-computability
proving non-computabilityproving non-computability
proving non-computability
Β 

Recently uploaded

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
Β 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
Β 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
Β 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
Β 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
Β 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
Β 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
Β 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
Β 
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
Β 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
Β 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
Β 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
Β 
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
Β 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
Β 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
Β 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
Β 

Recently uploaded (20)

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
Β 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Β 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
Β 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
Β 
Model Call Girl in Bikash Puri Delhi reach out to us at πŸ”9953056974πŸ”
Model Call Girl in Bikash Puri  Delhi reach out to us at πŸ”9953056974πŸ”Model Call Girl in Bikash Puri  Delhi reach out to us at πŸ”9953056974πŸ”
Model Call Girl in Bikash Puri Delhi reach out to us at πŸ”9953056974πŸ”
Β 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
Β 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
Β 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
Β 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
Β 
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πŸ”
Β 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
Β 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Β 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
Β 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
Β 
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
Β 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
Β 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
Β 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
Β 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
Β 

CFG Normal Forms: Chomsky and Greibach

  • 1. Chomsky and Greibach Normal Forms Chomsky and Greibach Normal Forms – p.1/2
  • 2. Simplifying a CFG Chomsky and Greibach Normal Forms – p.2/2 It is often convenient to simplify CFG
  • 3. Simplifying a CFG Chomsky and Greibach Normal Forms – p.2/2 It is often convenient to simplify CFG One of the simplest and most useful simplified forms of CFG is called the Chomsky normal form
  • 4. Simplifying a CFG Chomsky and Greibach Normal Forms – p.2/2 It is often convenient to simplify CFG One of the simplest and most useful simplified forms of CFG is called the Chomsky normal form Another normal form usually used in algebraic specifications is Greibach normal form
  • 5. Simplifying a CFG Chomsky and Greibach Normal Forms – p.2/2 It is often convenient to simplify CFG One of the simplest and most useful simplified forms of CFG is called the Chomsky normal form Another normal form usually used in algebraic specifications is Greibach normal form Note the difference between grammar cleaning and simplifi cation
  • 6. Note Chomsky and Greibach Normal Forms – p.3/2 Normal forms are useful when more advanced topics in computation theory are approached, as we shall see further
  • 7. Definition Chomsky and Greibach Normal Forms – p.4/2 is in Chomsky normal form ifA context-free grammar every rule is of the form: where is a terminal, are nonterminals, and may not be the start variable (the axiom)
  • 8. Note Chomsky and Greibach Normal Forms – p.5/2 The rule , where is the start variable, is not ex- cluded from a CFG in Chomsky normal form.
  • 9. Theorem 2.9 Chomsky and Greibach Normal Forms – p.6/2 Any context-free language is generated by a context-free grammar in Chomsky normal form.
  • 10. Theorem 2.9 Chomsky and Greibach Normal Forms – p.6/2 Any context-free language is generated by a context-free grammar in Chomsky normal form. Proof idea:
  • 11. Theorem 2.9 Chomsky and Greibach Normal Forms – p.6/2 Any context-free language is generated by a context-free grammar in Chomsky normal form. Proof idea: Show that any CFG can be converted into a CFG in Chomsky normal form
  • 12. Theorem 2.9 Chomsky and Greibach Normal Forms – p.6/2 Any context-free language is generated by a context-free grammar in Chomsky normal form. Proof idea: Show that any CFG can be converted into a CFG in Chomsky normal form Conversion procedure has several stages where the rules that violate Chomsky normal form conditions are replaced with equivalent rules that satisfy these conditions
  • 13. Theorem 2.9 Chomsky and Greibach Normal Forms – p.6/2 Any context-free language is generated by a context-free grammar in Chomsky normal form. Proof idea: Show that any CFG can be converted into a CFG in Chomsky normal form Conversion procedure has several stages where the rules that violate Chomsky normal form conditions are replaced with equivalent rules that satisfy these conditions Order of transformations: (1) add a new start variable, (2) eliminate all-rules, (3) eliminate unit-rules, (4) convert other rules
  • 14. Theorem 2.9 Chomsky and Greibach Normal Forms – p.6/2 Any context-free language is generated by a context-free grammar in Chomsky normal form. Proof idea: Show that any CFG can be converted into a CFG in Chomsky normal form Conversion procedure has several stages where the rules that violate Chomsky normal form conditions are replaced with equivalent rules that satisfy these conditions Order of transformations: (1) add a new start variable, (2) eliminate all-rules, (3) eliminate unit-rules, (4) convert other rules Check that the obtained CFG defi nes the same language
  • 15. Proof Chomsky and Greibach Normal Forms – p.7/2 Let be the original CFG.
  • 16. Proof Chomsky and Greibach Normal Forms – p.7/2 Let be the original CFG. Step 1: add a new start symbol to , and the rule to
  • 17. Proof Chomsky and Greibach Normal Forms – p.7/2 Let be the original CFG. to does not occur Step 1: add a new start symbol to , and the rule Note: this change guarantees that the startsymbol of on the of any rule
  • 18. Step 2: eliminate Chomsky and Greibach Normal Forms – p.8/2 -rules Repeat 1. Eliminate the rule from where is not the start symbol 2. For each occurrence of on the of a rule, add a new rule to with that occurrence of deleted Example: replace by ; unless the replace by 3. Replace the rule , (if it is present) by rule has been previously eliminated until all rules are eliminated
  • 19. Step 3: remove unit rules Chomsky and Greibach Normal Forms – p.9/2 Repeat 1. Remove a unit rule 2. For each rule , add the rule to , unless was a unit rule previously removed until all unit rules are eliminated Note: is a string of variables and terminals
  • 20. Convert all remaining rules Repeat , , where each , ,1. Replace a rule is a variable or a terminal, by: , , , are new variables replace any terminal with a new variable and add the where , , , 2. If rule withuntil no rules of the form remain Chomsky and Greibach Normal Forms – p.10/2
  • 21. Convert all remaining rules Repeat , , where each , ,1. Replace a rule is a variable or a terminal, by: , , , are new variables replace any terminal with a new variable and add the where , , , 2. If rule withuntil no rules of the form remain Chomsky and Greibach Normal Forms – p.10/2
  • 22. Convert all remaining rules Repeat , , where each , ,1. Replace a rule is a variable or a terminal, by: , , , are new variables replace any terminal with a new variable and add the where , , , 2. If rule withuntil no rules of the form remain Chomsky and Greibach Normal Forms – p.10/2
  • 23. Example CFG conversion Chomsky and Greibach Normal Forms – p.11/2 Consider the grammar whose rules are: Notation: symbols removed are green and those added are red. After fi rst step of transformation we get:
  • 24. Example CFG conversion Chomsky and Greibach Normal Forms – p.11/2 Consider the grammar whose rules are: Notation: symbols removed are green and those added are red. After fi rst step of transformation we get:
  • 25. Example CFG conversion Chomsky and Greibach Normal Forms – p.11/2 Consider the grammar whose rules are: Notation: symbols removed are green and those added are red. After fi rst step of transformation we get:
  • 26. Removing Chomsky and Greibach Normal Forms – p.12/2 rules Removing : Removing :
  • 27. Removing Chomsky and Greibach Normal Forms – p.12/2 rules Removing : Removing :
  • 28. Removing Chomsky and Greibach Normal Forms – p.12/2 rules Removing : Removing :
  • 29. Removing unit rule Chomsky and Greibach Normal Forms – p.13/2 Removing : Removing :
  • 30. Removing unit rule Chomsky and Greibach Normal Forms – p.13/2 Removing : Removing :
  • 31. Removing unit rule Chomsky and Greibach Normal Forms – p.13/2 Removing : Removing :
  • 32. More unit rules Chomsky and Greibach Normal Forms – p.14/2 Removing : Removing :
  • 33. More unit rules Chomsky and Greibach Normal Forms – p.14/2 Removing : Removing :
  • 34. More unit rules Chomsky and Greibach Normal Forms – p.14/2 Removing : Removing :
  • 35. Converting remaining rules Chomsky and Greibach Normal Forms – p.15/2
  • 36. Converting remaining rules Chomsky and Greibach Normal Forms – p.15/2
  • 37. Converting remaining rules Chomsky and Greibach Normal Forms – p.15/2
  • 38. Note The conversion procedure produces several variables along with several rules . Since all these represent the same rule, we may simplify the result using a single variable and a single rule Chomsky and Greibach Normal Forms – p.16/2
  • 39. Note The conversion procedure produces several variables along with several rules . Since all these represent the same rule, we may simplify the result using a single variable and a single rule Chomsky and Greibach Normal Forms – p.16/2
  • 40. Note The conversion procedure produces several variables along with several rules . Since all these represent the same rule, we may simplify the result using a single variable and a single rule Chomsky and Greibach Normal Forms – p.16/2
  • 41. Greibach Normal Form is in has the and A context-free grammar Greibach normal form if each rule property: , , . Chomsky and Greibach Normal Forms – p.17/2 Note: Greibach normal form provides a justifi ca- tion of operator prefi x-notation usually employed in algebra.
  • 42. Greibach Normal Form is in has the and A context-free grammar Greibach normal form if each rule property: , , . Chomsky and Greibach Normal Forms – p.17/2 Note: Greibach normal form provides a justifi ca- tion of operator prefi x-notation usually employed in algebra.
  • 43. Greibach Normal Form is in has the and A context-free grammar Greibach normal form if each rule property: , , . Chomsky and Greibach Normal Forms – p.17/2 Note: Greibach normal form provides a justifi ca- tion of operator prefi x-notation usually employed in algebra.
  • 44. Greibach Theorem Every CFL where can be generated by a CFG in Greibach normal form. Chomsky and Greibach Normal Forms – p.18/2 be a CFG generating . Assume thatProof idea: Let is in Chomsky normal form Let be an ordering of nonterminals. Construct the Greibach normal form from Chomsky normal form
  • 45. Greibach Theorem Every CFL where can be generated by a CFG in Greibach normal form. Chomsky and Greibach Normal Forms – p.18/2 be a CFG generating . Assume thatProof idea: Let is in Chomsky normal form Let be an ordering of nonterminals. Construct the Greibach normal form from Chomsky normal form
  • 46. Greibach Theorem Every CFL where can be generated by a CFG in Greibach normal form. Chomsky and Greibach Normal Forms – p.18/2 be a CFG generating . Assume thatProof idea: Let is in Chomsky normal form Let be an ordering of nonterminals. Construct the Greibach normal form from Chomsky normal form
  • 47. Construction Chomsky and Greibach Normal Forms – p.19/2 so that if1. Modify the rules in 2. Starting with and proceeding to then this is done as follows: (a) Assume that productions have been modifi ed so that for , (b) If only if is a production with , generate a new set of the rhs of eachproductions substituting for the production times we obtain rules of the form(c) Repeating (b) at most , (d) Replace rules by removing left-recursive rules
  • 48. Construction Chomsky and Greibach Normal Forms – p.19/2 so that if1. Modify the rules in 2. Starting with and proceeding to then this is done as follows: (a) Assume that productions have been modifi ed so that for , (b) If only if is a production with , generate a new set of the rhs of eachproductions substituting for the production times we obtain rules of the form(c) Repeating (b) at most , (d) Replace rules by removing left-recursive rules
  • 49. Construction Chomsky and Greibach Normal Forms – p.19/2 so that if1. Modify the rules in 2. Starting with and proceeding to then this is done as follows: (a) Assume that productions have been modifi ed so that for , (b) If only if is a production with , generate a new set of the rhs of eachproductions substituting for the production times we obtain rules of the form(c) Repeating (b) at most , (d) Replace rules by removing left-recursive rules
  • 50. Removing left-recursion Chomsky and Greibach Normal Forms – p.20/2 Left-recursion can be eliminated by the following scheme: If are all left recursive rules, and are all remaining -rules then chose a new nonterminal, sayAdd the new Replace the -rules , -rules by , This construction preserve the language .
  • 51. Removing left-recursion Chomsky and Greibach Normal Forms – p.20/2 Left-recursion can be eliminated by the following scheme: If are all left recursive rules, and are all remaining -rules then chose a new nonterminal, sayAdd the new Replace the -rules , -rules by , This construction preserve the language .
  • 52. Removing left-recursion Chomsky and Greibach Normal Forms – p.20/2 Left-recursion can be eliminated by the following scheme: If are all left recursive rules, and are all remaining -rules then chose a new nonterminal, sayAdd the new Replace the -rules , -rules by , This construction preserve the language .
  • 53. 21-1
  • 54. More on Greibach NF Chomsky and Greibach Normal Forms – p.22/2 See Introduction to Automata Theory, Languages, and Computation, J.E, Hopcroft and J.D Ullman, Addison-Wesley 1979, p. 94–96
  • 55. Example Chomsky and Greibach Normal Forms – p.23/2 Convert the CFG where into Greibach normal form.
  • 56. Example Chomsky and Greibach Normal Forms – p.23/2 Convert the CFG where into Greibach normal form.
  • 57. Example Chomsky and Greibach Normal Forms – p.23/2 Convert the CFG where into Greibach normal form.
  • 58. Solution Chomsky and Greibach Normal Forms – p.24/2 1. Step 1: ordering the rules: (Only rules violate ordering conditions, hence only rules need to be changed). Following the procedure we replace rules by: 2. Eliminating left-recursion we get: , 3. All rules start with a terminal. We use them to replace . This introduces the rules 4. Use production to make them start with a terminal
  • 59. Solution Chomsky and Greibach Normal Forms – p.24/2 1. Step 1: ordering the rules: (Only rules violate ordering conditions, hence only rules need to be changed). Following the procedure we replace rules by: 2. Eliminating left-recursion we get: , 3. All rules start with a terminal. We use them to replace . This introduces the rules 4. Use production to make them start with a terminal
  • 60. Solution Chomsky and Greibach Normal Forms – p.24/2 1. Step 1: ordering the rules: (Only rules violate ordering conditions, hence only rules need to be changed). Following the procedure we replace rules by: 2. Eliminating left-recursion we get: , 3. All rules start with a terminal. We use them to replace . This introduces the rules 4. Use production to make them start with a terminal