Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Fundamentals of Formal Grammars and Pushdown Automata, Quizzes of Data Structures and Algorithms

Definitions and concepts related to formal grammars, production rules, terminals, nonterminals, and pushdown automata, which are essential in computer science for defining programming languages and data sets. It includes the concepts of derivation steps, sentential forms, regular grammars, context-free grammars, and pushdown automata, along with their associated stack operations and acceptance criteria.

Typology: Quizzes

Pre 2010

Uploaded on 12/14/2009

shlooper
shlooper 🇺🇸

4 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
TERM 1
Grammar (informal)
DEFINITION 1
A set of rules used to define the structure of the strings in a
language
TERM 2
Language of a grammar
DEFINITION 2
If G is a grammar with start symbol S and set of terminals T,
then the language of G is the set L(G) = {s | s is an element
T* and S => + s} If G is a grammar then the language of G is
the set of terminal strings derived from the start symbol of G.
TERM 3
grammar (formal)
DEFINITION 3
1. An alphabet N of grammar symbols called nonterminals 2. An
alphabet T of symbols called terminals. The terminals are distinct
from the nonterminals. 3. A specific N.T S, called the start symbol
4. A finite set of pr.tions of the form a -> B where a and B are
strings over the alphabet N U T with the restriction that a is not
the empty string. There is at least one pro. with only the start
symbol S on its left side. Each NT must appear on the left side of
some prd.
TERM 4
Nonterminal
DEFINITION 4
uppercase letters, production rules
TERM 5
Terminals
DEFINITION 5
Literal strings of input into a grammar denoted by lower case
letters
pf3
pf4
pf5

Partial preview of the text

Download Fundamentals of Formal Grammars and Pushdown Automata and more Quizzes Data Structures and Algorithms in PDF only on Docsity!

Grammar (informal)

A set of rules used to define the structure of the strings in a language TERM 2

Language of a grammar

DEFINITION 2 If G is a grammar with start symbol S and set of terminals T, then the language of G is the set L(G) = {s | s is an element T* and S => + s} If G is a grammar then the language of G is the set of terminal strings derived from the start symbol of G. TERM 3

grammar (formal)

DEFINITION 3

  1. An alphabet N of grammar symbols called nonterminals 2. An alphabet T of symbols called terminals. The terminals are distinct from the nonterminals. 3. A specific N.T S, called the start symbol
  2. A finite set of pr.tions of the form a -> B where a and B are strings over the alphabet N U T with the restriction that a is not the empty string. There is at least one pro. with only the start symbol S on its left side. Each NT must appear on the left side of some prd. TERM 4

Nonterminal

DEFINITION 4 uppercase letters, production rules TERM 5

Terminals

DEFINITION 5 Literal strings of input into a grammar denoted by lower case letters

grammars important to CS

for defining programming languages and defining data sets for programs. TERM 7

inductive definition of a

set

DEFINITION 7 Basis: Specify one or more elements of S Induction: Give one or more rules to construct new elements of S from existing elements of S. Closure: State that S consists exactly of the elements obtained by the basis and induction steps. This step is usually assumed. Any language defined by a grammar is an inductively defined set TERM 8

production

DEFINITION 8 the grammar rule a -> B is called a production TERM 9

Derivation step

DEFINITION 9 the process of replacing S by aS (using a production) TERM 10

sentential form

DEFINITION 10 A string made up of terminals and/or nonterminals

4 representations of regular languages

regular expressions, DFAs, NFAs, and regular grammars any regular grammar, or regular language is context free TERM 17

pushdown automaton (informal)

DEFINITION 17 is a finite automaton with a stack, used to recognize context- free languages. TERM 18

3 stack operations associated with

PDA

DEFINITION 18 push -- writes a designated symbol onto the top of the stack pop reads the top symbol and removes it from the stack nop does nothing to the stack TERM 19

final state PDA accept/reject

DEFINITION 19 accepted if there is some path from the start state to a final state that consumes all the letters of the string, otherwise the string is rejected. the language is the set of strings that it accepts TERM 20

nondeterministic/deterministic PDA

DEFINITION 20 if there is at most one move possible from each state it is deterministic. Two types of nondeterministic 1) A state has 2 or more outgoing edges with the same input symbol and same stack symbol 2) A state has 2 outgoing edges with the same top stack symbol and one input symbol is lamda with the other being an alphabet symbol

famous example of irregular

language

{a^nb^n | n >=0} TERM 22

empty-stack acceptance PDA

DEFINITION 22 the input string is consumed and the stack is empty but final state does not matter TERM 23

7 tuple (S, A, B, I, E, s,

F)

DEFINITION 23 (S,A,B,I,E,s,F) S- set of states A - alphabet for input string B - set of stack symbols I - set of instructions E - stack start symbol s - the start state F - set of final states TERM 24

Instantaneous Description (ID) (i, abc, XYZW)

DEFINITION 24 describes the execution work of a PDA (i, abc, XYZW) i - pda current state 'a' - is the current input symbol X - is stack top symbol TERM 25

Can nearly all compiler constructs be

represented by CFGs?

DEFINITION 25 True, generally deterministic PDAs because then you dont have to deal with backtracking